Merge pull request #1584 from FHenry/develop
Better error return for project delete method
This commit is contained in:
commit
51baae16a4
@ -67,12 +67,19 @@ $pagenext = $page + 1;
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="nom";
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('commcard'));
|
||||
|
||||
$object = new Societe($db);
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$parameters = array('socid' => $id);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
|
||||
|
||||
|
||||
if ($action == 'setcustomeraccountancycode')
|
||||
{
|
||||
$result=$object->fetch($id);
|
||||
@ -814,6 +821,11 @@ if ($id > 0)
|
||||
/*
|
||||
* Barre d'actions
|
||||
*/
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
|
||||
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if (! empty($conf->propal->enabled) && $user->rights->propal->creer)
|
||||
|
||||
@ -1286,7 +1286,7 @@ function getListOfModels($db,$type,$maxfilenamelength=0)
|
||||
$sql.= " WHERE type = '".$type."'";
|
||||
$sql.= " AND entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
|
||||
|
||||
dol_syslog(get_class($this).'::getListOfModels sql='.$sql, LOG_DEBUG);
|
||||
dol_syslog('/core/lib/function2.lib.php::getListOfModels sql='.$sql, LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
|
||||
@ -465,26 +465,46 @@ class Project extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task";
|
||||
$sql.= " WHERE fk_projet=" . $this->id;
|
||||
|
||||
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet";
|
||||
$sql.= " WHERE rowid=" . $this->id;
|
||||
|
||||
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_extrafields";
|
||||
$sql.= " WHERE fk_object=" . $this->id;
|
||||
|
||||
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
|
||||
if ($resql)
|
||||
if (empty($error))
|
||||
{
|
||||
// We remove directory
|
||||
$projectref = dol_sanitizeFileName($this->ref);
|
||||
@ -496,9 +516,8 @@ class Project extends CommonObject
|
||||
$res = @dol_delete_dir_recursive($dir);
|
||||
if (!$res)
|
||||
{
|
||||
$this->error = 'ErrorFailToDeleteDir';
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
$this->errors[] = 'ErrorFailToDeleteDir';
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -512,18 +531,25 @@ class Project extends CommonObject
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
$this->errors = $interface->errors;
|
||||
foreach ($interface->errors as $errmsg ) {
|
||||
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
|
||||
$this->errors[] =$errmsg;
|
||||
}
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
|
||||
if (empty($error)) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $this->db->lasterror();
|
||||
foreach ( $this->errors as $errmsg ) {
|
||||
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
||||
}
|
||||
dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
|
||||
@ -64,7 +64,7 @@ $result = restrictedArea($user, 'projet', $object->id);
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
$date_start=dol_mktime(0,0,0,GETPOST('projectmonth','int'),GETPOST('projectday','int'),GETPOST('projectyear','int'));
|
||||
$date_end=dol_mktime(0,0,0,GETPOST('projectendmonth','int'),GETPOST('projectendday','int'),GETPOST('projectendyear','int'));;
|
||||
$date_end=dol_mktime(0,0,0,GETPOST('projectendmonth','int'),GETPOST('projectendday','int'),GETPOST('projectendyear','int'));
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user