2
0
forked from Wavyzz/dolibarr

Compare commits

...

12 Commits
6.0.0 ... 5.0.6

Author SHA1 Message Date
Laurent Destailleur
a158f5ab9d Doc 2017-09-04 12:01:51 +02:00
Laurent Destailleur
61ee071f43 Fix regression 2017-09-04 10:17:51 +02:00
Laurent Destailleur
2c3a696b78 Merge branch '4.0' of git@github.com:Dolibarr/dolibarr.git into 5.0 2017-09-04 10:16:02 +02:00
Laurent Destailleur
65b6b142bd Tag only whe publishing on sf 2017-09-04 09:29:44 +02:00
Laurent Destailleur
f92129dcdb Fix packager to avoid symlinks into custom 2017-09-03 00:55:49 +02:00
Laurent Destailleur
9fe1d8462a Merge pull request #7318 from atm-maxime/fix_extrafieldsline_insert
Fix extrafieldsline insert
2017-09-02 00:07:00 +02:00
Laurent Destailleur
ffb408f440 Merge branch '5.0' of git@github.com:Dolibarr/dolibarr.git into 5.0 2017-09-01 15:20:48 +02:00
Laurent Destailleur
ac08dec2c3 Avoid warnings 2017-09-01 15:20:29 +02:00
Maxime Kohlhaas
cf49c274a6 Better fix 2017-09-01 10:38:50 +02:00
Maxime Kohlhaas
1a956cce9a Fix : insert line extrafield 2017-09-01 10:31:22 +02:00
Laurent Destailleur
5a81073cd8 Merge pull request #7308 from hregis/5.0_bug2
Fix: documents dir not rename and delete
2017-08-30 16:41:17 +02:00
Regis Houssin
45136de664 Fix: documents dir not rename and delete 2017-08-30 11:26:48 +02:00
4 changed files with 195 additions and 146 deletions

View File

@@ -2,6 +2,9 @@
English Dolibarr ChangeLog English Dolibarr ChangeLog
-------------------------------------------------------------- --------------------------------------------------------------
***** ChangeLog for 5.0.6 compared to 5.0.5 *****
FIX: Removed a bad symbolic link into custom directory.
FIX: Renaming a resouce ref rename also the directory of attached files.
***** ChangeLog for 5.0.5 compared to 5.0.4 ***** ***** ChangeLog for 5.0.5 compared to 5.0.4 *****
FIX: #7075 : bad path for document FIX: #7075 : bad path for document

View File

@@ -334,7 +334,7 @@ foreach my $target (sort keys %CHOOSEDTARGET) {
} }
foreach my $target (sort keys %CHOOSEDPUBLISH) { foreach my $target (sort keys %CHOOSEDPUBLISH) {
if ($CHOOSEDPUBLISH{$target} < 0) { next; } if ($CHOOSEDPUBLISH{$target} < 0) { next; }
if ($target eq 'ASSO') { $nbofpublishneedchangelog++; $nbofpublishneedtag++; } if ($target eq 'ASSO') { $nbofpublishneedchangelog++; }
if ($target eq 'SF') { $nbofpublishneedchangelog++; $nbofpublishneedtag++; } if ($target eq 'SF') { $nbofpublishneedchangelog++; $nbofpublishneedtag++; }
$nboftargetok++; $nboftargetok++;
} }
@@ -594,7 +594,9 @@ if ($nboftargetok) {
print "Remove subdir of custom dir\n"; print "Remove subdir of custom dir\n";
print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\;\n"; print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\;\n";
$ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to keep dir $ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to keep files only
print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type l -exec rm -fr {} \\;\n";
$ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type l -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to keep files only
} }
# Build package for each target # Build package for each target

View File

@@ -57,7 +57,7 @@ $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if ($page == -1) { $page = 0; } if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@@ -127,9 +127,9 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$search_number=''; $search_number='';
$search_statut=''; $search_statut='';
} }
/* /*
* View * View
*/ */
@@ -299,9 +299,9 @@ if (! empty($arrayfields['toreconcile']['checked'])) print_liste_field_titr
// Extra fields // Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{ {
foreach($extrafields->attribute_label as $key => $val) foreach($extrafields->attribute_label as $key => $val)
{ {
if (! empty($arrayfields["ef.".$key]['checked'])) if (! empty($arrayfields["ef.".$key]['checked']))
{ {
$align=$extrafields->getAlignFlag($key); $align=$extrafields->getAlignFlag($key);
print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
@@ -435,7 +435,7 @@ $var=true;
foreach ($accounts as $key=>$type) foreach ($accounts as $key=>$type)
{ {
if ($i >= $limit) break; if ($i >= $limit) break;
$found++; $found++;
$acc = new Account($db); $acc = new Account($db);
@@ -452,7 +452,7 @@ foreach ($accounts as $key=>$type)
{ {
$lastcurrencycode=$acc->currency_code; $lastcurrencycode=$acc->currency_code;
} }
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
// Ref // Ref
@@ -461,14 +461,14 @@ foreach ($accounts as $key=>$type)
print '<td>'.$acc->getNomUrl(1).'</td>'; print '<td>'.$acc->getNomUrl(1).'</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Label // Label
if (! empty($arrayfields['b.label']['checked'])) if (! empty($arrayfields['b.label']['checked']))
{ {
print '<td>'.$acc->label.'</td>'; print '<td>'.$acc->label.'</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Account type // Account type
if (! empty($arrayfields['accountype']['checked'])) if (! empty($arrayfields['accountype']['checked']))
{ {
@@ -477,14 +477,14 @@ foreach ($accounts as $key=>$type)
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Number // Number
if (! empty($arrayfields['b.number']['checked'])) if (! empty($arrayfields['b.number']['checked']))
{ {
print '<td>'.$acc->number.'</td>'; print '<td>'.$acc->number.'</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Account number // Account number
if (! empty($arrayfields['b.account_number']['checked'])) if (! empty($arrayfields['b.account_number']['checked']))
{ {
@@ -492,7 +492,7 @@ foreach ($accounts as $key=>$type)
print '<td>'.length_accountg($acc->account_number).'</td>'; print '<td>'.length_accountg($acc->account_number).'</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Accountancy journal // Accountancy journal
if (! empty($arrayfields['b.accountancy_journal']['checked'])) if (! empty($arrayfields['b.accountancy_journal']['checked']))
{ {
@@ -500,7 +500,7 @@ foreach ($accounts as $key=>$type)
print '<td>'.length_accountg($acc->accountancy_journal).'</td>'; print '<td>'.length_accountg($acc->accountancy_journal).'</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Transactions to reconcile // Transactions to reconcile
if (! empty($arrayfields['toreconcile']['checked'])) if (! empty($arrayfields['toreconcile']['checked']))
{ {
@@ -519,13 +519,13 @@ foreach ($accounts as $key=>$type)
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Extra fields // Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{ {
foreach($extrafields->attribute_label as $key => $val) foreach($extrafields->attribute_label as $key => $val)
{ {
if (! empty($arrayfields["ef.".$key]['checked'])) if (! empty($arrayfields["ef.".$key]['checked']))
{ {
print '<td'; print '<td';
$align=$extrafields->getAlignFlag($key); $align=$extrafields->getAlignFlag($key);
@@ -558,14 +558,14 @@ foreach ($accounts as $key=>$type)
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Statut // Statut
if (! empty($arrayfields['b.clos']['checked'])) if (! empty($arrayfields['b.clos']['checked']))
{ {
print '<td align="center">'.$acc->getLibStatut(5).'</td>'; print '<td align="center">'.$acc->getLibStatut(5).'</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Balance // Balance
if (! empty($arrayfields['balance']['checked'])) if (! empty($arrayfields['balance']['checked']))
{ {
@@ -576,7 +576,7 @@ foreach ($accounts as $key=>$type)
if (! $i) $totalarray['totalbalancefield']=$totalarray['nbfield']; if (! $i) $totalarray['totalbalancefield']=$totalarray['nbfield'];
$totalarray['totalbalance'] += $solde; $totalarray['totalbalance'] += $solde;
} }
// Action column // Action column
print '<td class="nowrap" align="center">'; print '<td class="nowrap" align="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
@@ -587,7 +587,7 @@ foreach ($accounts as $key=>$type)
} }
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
print '</tr>'; print '</tr>';
$total[$acc->currency_code] += $solde; $total[$acc->currency_code] += $solde;

View File

@@ -43,6 +43,8 @@ class Dolresource extends CommonObject
var $type_label; var $type_label;
var $tms=''; var $tms='';
var $oldcopy;
/** /**
* Constructor * Constructor
* *
@@ -230,85 +232,108 @@ class Dolresource extends CommonObject
* @param int $notrigger 0=launch triggers after, 1=disable triggers * @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function update($user=null, $notrigger=0) function update($user=null, $notrigger=0)
{ {
global $conf, $langs, $hookmanager; global $conf, $langs, $hookmanager;
$error=0; $error=0;
// Clean parameters // Clean parameters
if (isset($this->ref)) $this->ref=trim($this->ref); if (isset($this->ref)) $this->ref=trim($this->ref);
if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource=trim($this->fk_code_type_resource); if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource=trim($this->fk_code_type_resource);
if (isset($this->description)) $this->description=trim($this->description); if (isset($this->description)) $this->description=trim($this->description);
// Update request if (empty($this->oldcopy))
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; {
$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; $org=new self($this->db);
$sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; $org->fetch($this->id);
$sql.= " fk_code_type_resource=".(isset($this->fk_code_type_resource)?"'".$this->db->escape($this->fk_code_type_resource)."'":"null").","; $this->oldcopy=$org;
$sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').""; }
$sql.= " WHERE rowid=".$this->id;
$this->db->begin(); // Update request
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
$sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").",";
$sql.= " fk_code_type_resource=".(isset($this->fk_code_type_resource)?"'".$this->db->escape($this->fk_code_type_resource)."'":"null").",";
$sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null')."";
$sql.= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG); $this->db->begin();
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error) dol_syslog(get_class($this)."::update", LOG_DEBUG);
{ $resql = $this->db->query($sql);
if (! $notrigger) if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//// Call triggers if (! $error)
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; {
$interface=new Interfaces($this->db); if (! $notrigger)
$result=$interface->run_triggers('RESOURCE_MODIFY',$this,$user,$langs,$conf); {
if ($result < 0) { $error++; $this->errors=$interface->errors; } // Call trigger
//// End call triggers $result=$this->call_trigger('RESOURCE_MODIFY',$user);
} if ($result < 0) $error++;
} // End call triggers
if (! $error) }
{ }
$action='update';
// Actions on extra fields (by external module or standard code) if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref))
// TODO le hook fait double emploi avec le trigger !! {
$hookmanager->initHooks(array('actioncommdao')); // We remove directory
$parameters=array('actcomm'=>$this->id); if (! empty($conf->resource->dir_output))
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks {
if (empty($reshook)) $olddir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref);
{ $newdir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($this->ref);
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used if (file_exists($olddir))
{ {
$result=$this->insertExtraFields(); $res = @rename($olddir, $newdir);
if ($result < 0) if (! $res)
{ {
$error++; $langs->load("errors");
} $this->error=$langs->trans('ErrorFailToRenameDir',$olddir,$newdir);
} $error++;
} }
else if ($reshook < 0) $error++; }
} }
}
// Commit or rollback if (! $error)
if ($error) {
{ $action='update';
foreach($this->errors as $errmsg)
{ // Actions on extra fields (by external module or standard code)
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); // TODO le hook fait double emploi avec le trigger !!
$this->error.=($this->error?', '.$errmsg:$errmsg); $hookmanager->initHooks(array('actioncommdao'));
} $parameters=array('actcomm'=>$this->id);
$this->db->rollback(); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
return -1*$error; if (empty($reshook))
} {
else if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {
$this->db->commit(); $result=$this->insertExtraFields();
return 1; if ($result < 0)
} {
} $error++;
}
}
}
else if ($reshook < 0) $error++;
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/** /**
* Load object in memory from database * Load object in memory from database
@@ -375,65 +400,84 @@ class Dolresource extends CommonObject
* @param int $notrigger Disable all triggers * @param int $notrigger Disable all triggers
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
*/ */
function delete($rowid, $notrigger=0) function delete($rowid, $notrigger=0)
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
$error=0; $error=0;
$this->db->begin(); $this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE rowid =".$rowid; $sql.= " WHERE rowid =".$rowid;
dol_syslog(get_class($this), LOG_DEBUG); dol_syslog(get_class($this), LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources";
$sql.= " WHERE element_type='resource' AND resource_id =".$this->db->escape($rowid); $sql.= " WHERE element_type='resource' AND resource_id =".$this->db->escape($rowid);
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (!$resql) if (!$resql)
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
$error++; $error++;
} }
} }
else else
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
$error++; $error++;
} }
// Removed extrafields // Removed extrafields
if (! $error) { if (! $error) {
$result=$this->deleteExtraFields(); $result=$this->deleteExtraFields();
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR);
} }
} }
if (! $notrigger) if (! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('RESOURCE_DELETE',$user); $result=$this->call_trigger('RESOURCE_DELETE',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
} }
if (! $error) if (! $error)
{ {
$this->db->commit(); // We remove directory
return 1; $ref = dol_sanitizeFileName($this->ref);
} if (! empty($conf->resource->dir_output))
else {
{ $dir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($this->ref);
$this->db->rollback(); if (file_exists($dir))
return -1; {
} $res=@dol_delete_dir_recursive($dir);
} if (! $res)
{
$this->errors[] = 'ErrorFailToDeleteDir';
$error++;
}
}
}
}
if (! $error)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
return -1;
}
}
/** /**
* Load resource objects into $this->lines * Load resource objects into $this->lines