NEW Add missing unique key on table llx_links

This commit is contained in:
Laurent Destailleur 2016-11-10 14:24:29 +01:00
parent eaa2125373
commit fe9c880984
6 changed files with 64 additions and 10 deletions

View File

@ -181,7 +181,14 @@ class Form
else if (preg_match('/^text/',$typeofdata) || preg_match('/^note/',$typeofdata))
{
$tmp=explode(':',$typeofdata);
$ret.='<textarea id="'.$htmlname.'" name="'.$htmlname.'" wrap="soft" rows="'.($tmp[1]?$tmp[1]:'20').'" cols="'.($tmp[2]?$tmp[2]:'100').'">'.($editvalue?$editvalue:$value).'</textarea>';
$cols=$tmp[2];
$morealt='';
if (preg_match('/%/',$cols))
{
$morealt=' style="width: '.$cols.'"';
$cols='';
}
$ret.='<textarea id="'.$htmlname.'" name="'.$htmlname.'" wrap="soft" rows="'.($tmp[1]?$tmp[1]:'20').'"'.($cols?' cols="'.$cols.'"':'').$morealt.'">'.($editvalue?$editvalue:$value).'</textarea>';
}
else if ($typeofdata == 'day' || $typeofdata == 'datepicker')
{

View File

@ -62,7 +62,7 @@ class FormFile
* @param int $addcancel 1=Add 'Cancel' button
* @param int $sectionid If upload must be done inside a particular ECM section
* @param int $perm Value of permission to allow upload
* @param int $size Length of input file area
* @param int $size Length of input file area. Deprecated.
* @param Object $object Object to use (when attachment is done on an element)
* @param string $options Add an option column
* @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). 2 should never be used.
@ -106,7 +106,7 @@ class FormFile
if (! empty($options)) $out .= '<td>'.$options.'</td>';
$out .= '<td valign="middle" class="nowrap">';
$out .= '<td valign="middle">';
$max=$conf->global->MAIN_UPLOAD_DOC; // En Kb
$maxphp=@ini_get('upload_max_filesize'); // En inconnu
@ -121,10 +121,10 @@ class FormFile
{
$out .= '<input type="hidden" name="max_file_size" value="'.($max*1024).'">';
}
$out .= '<input class="flat" type="file" name="userfile" size="'.$maxlength.'"';
$out .= '<input class="flat minwidth400" type="file" name="userfile"';
$out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':'');
$out .= '>';
$out .= '&nbsp;';
$out .= ' ';
$out .= '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'"';
$out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':'');
$out .= '>';
@ -183,11 +183,11 @@ class FormFile
$out .= '<div class="valignmiddle" >';
$out .= '<div class="inline-block" style="padding-right: 10px;">';
if (! empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= '<label for="link">'.$langs->trans("URLToLink") . ':</label> ';
$out .= '<input type="text" name="link" size="'.$maxlength.'" id="link" placeholder="'.dol_escape_htmltag($langs->trans("URLToLink")).'">';
$out .= '<input type="text" name="link" class="flat minwidth400imp" id="link" placeholder="'.dol_escape_htmltag($langs->trans("URLToLink")).'">';
$out .= '</div>';
$out .= '<div class="inline-block" style="padding-right: 10px;">';
if (! empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= '<label for="label">'.$langs->trans("Label") . ':</label> ';
$out .= '<input type="text" name="label" id="label" placeholder="'.dol_escape_htmltag($langs->trans("Label")).'">';
$out .= '<input type="text" class="flat" name="label" id="label" placeholder="'.dol_escape_htmltag($langs->trans("Label")).'">';
$out .= '<input type="hidden" name="objecttype" value="' . $object->element . '">';
$out .= '<input type="hidden" name="objectid" value="' . $object->id . '">';
$out .= '</div>';
@ -1451,6 +1451,7 @@ class FormFile
else
{
print '<td>';
print img_picto('', 'object_globe').' ';
print '<a data-ajax="false" href="' . $link->url . '" target="_blank">';
print $link->label;
print '</a>';

View File

@ -63,8 +63,8 @@ elseif ($module == 'shipping') { $permission=$user->rights->expedition->cr
elseif ($module == 'product') { $permission=$user->rights->produit->creer;}
//else dol_print_error('','Bad value '.$module.' for param module');
if (! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:100'; // Rem: This var is for all notes, not only thirdparties note.
else $typeofdata='textarea:12:100';
if (! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:95%'; // Rem: This var is for all notes, not only thirdparties note.
else $typeofdata='textarea:12:95%';
?>

View File

@ -202,3 +202,17 @@ create table llx_user_employment
)ENGINE=innodb;
-- Sequence to removed duplicated values of llx_links. Use serveral times if you still have duplicate.
drop table tmp_links_double;
--select objectid, label, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_links where label is not null group by objectid, label having count(rowid) >= 2;
create table tmp_links_double as (select objectid, label, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_links where label is not null group by objectid, label having count(rowid) >= 2);
--select * from tmp_links_double;
delete from llx_links where (rowid, label) in (select max_rowid, label from tmp_links_double); --update to avoid duplicate, delete to delete
drop table tmp_links_double;
ALTER TABLE llx_links ADD UNIQUE INDEX uk_links (objectid,label);

View File

@ -176,6 +176,7 @@ update llx_opensurvey_sondage set format = 'D' where format = 'D+';
update llx_opensurvey_sondage set format = 'A' where format = 'A+';
update llx_opensurvey_sondage set tms = now();
-- ALTER TABLE llx_facture_fourn ALTER COLUMN fk_cond_reglement DROP NOT NULL;
@ -183,12 +184,21 @@ update llx_product set barcode = null where barcode in ('', '-1', '0');
update llx_societe set barcode = null where barcode in ('', '-1', '0');
-- Sequence to removed duplicated values of llx_links. Use serveral times if you still have duplicate.
drop table tmp_links_double;
--select objectid, label, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_links where label is not null group by objectid, label having count(rowid) >= 2;
create table tmp_links_double as (select objectid, label, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_links where label is not null group by objectid, label having count(rowid) >= 2);
--select * from tmp_links_double;
delete from llx_links where (rowid, label) in (select max_rowid, label from tmp_links_double); --update to avoid duplicate, delete to delete
drop table tmp_links_double;
-- Sequence to removed duplicated values of barcode in llx_product. Use serveral times if you still have duplicate.
drop table tmp_product_double;
--select barcode, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_product where barcode is not null group by barcode having count(rowid) >= 2;
create table tmp_product_double as (select barcode, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_product where barcode is not null group by barcode having count(rowid) >= 2);
--select * from tmp_product_double;
update llx_product set barcode = null where (rowid, barcode) in (select max_rowid, barcode from tmp_product_double);
update llx_product set barcode = null where (rowid, barcode) in (select max_rowid, barcode from tmp_product_double); --update to avoid duplicate, delete to delete
drop table tmp_product_double;

View File

@ -0,0 +1,22 @@
-- ========================================================================
-- Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
--
-- Linked files
-- ========================================================================
ALTER TABLE llx_links ADD UNIQUE INDEX uk_links (objectid,label);