Clean code
This commit is contained in:
parent
8477c0a3f1
commit
0649dc598d
@ -110,10 +110,12 @@ class Conf
|
||||
// Common objects that are not modules
|
||||
$this->mycompany = new stdClass();
|
||||
$this->admin = new stdClass();
|
||||
$this->browser = new stdClass();
|
||||
$this->medias = new stdClass();
|
||||
$this->global = new stdClass();
|
||||
|
||||
// Common objects that are not modules and set by the main and not into the this->setValues()
|
||||
$this->browser = new stdClass();
|
||||
|
||||
$this->cache = array();
|
||||
$this->modules = array();
|
||||
$this->modules_parts = array(
|
||||
@ -152,7 +154,6 @@ class Conf
|
||||
$this->facture = new stdClass();
|
||||
$this->contrat = new stdClass();
|
||||
$this->user = new stdClass();
|
||||
$this->usergroup = new stdClass();
|
||||
$this->adherent = new stdClass();
|
||||
$this->bank = new stdClass();
|
||||
$this->notification = new stdClass();
|
||||
@ -162,18 +163,18 @@ class Conf
|
||||
}
|
||||
|
||||
/**
|
||||
* Load setup values into conf object (read llx_const) for a specified entity
|
||||
* Note that this->db->xxx, this->file->xxx and this->multicompany have been already loaded when setValues is called.
|
||||
* Load setup values into conf object (read llx_const) for a specified entity
|
||||
* Note that this->db->xxx, this->file->xxx and this->multicompany have been already loaded when setValues is called.
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param int $entity Entity to get
|
||||
* @return int < 0 if KO, >= 0 if OK
|
||||
*/
|
||||
public function setEntityValues($db, $entity)
|
||||
public function setEntityValues($entity)
|
||||
{
|
||||
if ($this->entity != $entity) {
|
||||
// If we ask to reload setup for a new entity
|
||||
$this->entity = $entity;
|
||||
return $this->setValues($db);
|
||||
return $this->setValues($this->db);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -197,31 +198,39 @@ class Conf
|
||||
}
|
||||
}
|
||||
|
||||
// Properly declare multi-modules objects.
|
||||
$this->global = new stdClass();
|
||||
$this->multicompany = new stdClass();
|
||||
// Common objects that are not modules
|
||||
$this->mycompany = new stdClass();
|
||||
$this->admin = new stdClass();
|
||||
$this->medias = new stdClass();
|
||||
$this->global = new stdClass();
|
||||
|
||||
// Common objects that are not modules and set by the main and not into the this->setValues()
|
||||
//$this->browser = new stdClass(); // This is set by main and not into this setValues(), so we keep it intact.
|
||||
|
||||
// First level object
|
||||
// TODO Remove this part.
|
||||
$this->expedition_bon = new stdClass();
|
||||
$this->delivery_note = new stdClass();
|
||||
$this->fournisseur = new stdClass();
|
||||
$this->syslog = new stdClass();
|
||||
$this->expedition_bon = new stdClass();
|
||||
$this->delivery_note = new stdClass();
|
||||
$this->fournisseur = new stdClass();
|
||||
$this->product = new stdClass();
|
||||
$this->service = new stdClass();
|
||||
$this->contrat = new stdClass();
|
||||
$this->actions = new stdClass();
|
||||
$this->agenda = new stdClass();
|
||||
$this->commande = new stdClass();
|
||||
$this->propal = new stdClass();
|
||||
$this->commande = new stdClass();
|
||||
$this->propal = new stdClass();
|
||||
$this->facture = new stdClass();
|
||||
$this->contrat = new stdClass();
|
||||
$this->usergroup = new stdClass();
|
||||
$this->user = new stdClass();
|
||||
$this->adherent = new stdClass();
|
||||
$this->bank = new stdClass();
|
||||
$this->bank = new stdClass();
|
||||
$this->notification = new stdClass();
|
||||
$this->mailing = new stdClass();
|
||||
$this->mailing = new stdClass();
|
||||
$this->expensereport = new stdClass();
|
||||
$this->productbatch = new stdClass();
|
||||
|
||||
$this->cache = array();
|
||||
$this->modules = array();;
|
||||
$this->modules_parts = array(
|
||||
'css' => array(),
|
||||
@ -470,10 +479,6 @@ class Conf
|
||||
$this->user->dir_output = $rootforuser."/users";
|
||||
$this->user->dir_temp = $rootfortemp."/users/temp";
|
||||
|
||||
// For usergroup storage
|
||||
$this->usergroup->dir_output = $rootforuser."/usergroups";
|
||||
$this->usergroup->dir_temp = $rootfortemp."/usergroups/temp";
|
||||
|
||||
// For proposal storage
|
||||
$this->propal->multidir_output = array($this->entity => $rootfordata."/propale");
|
||||
$this->propal->multidir_temp = array($this->entity => $rootfortemp."/propale/temp");
|
||||
|
||||
@ -258,7 +258,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
|
||||
}
|
||||
}
|
||||
|
||||
$dir = $conf->usergroup->dir_output;
|
||||
$dir = $conf->user->dir_output.'/usergroups';
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
if (!preg_match('/specimen/i', $objectref)) {
|
||||
$dir .= "/".$objectref;
|
||||
|
||||
@ -1081,7 +1081,7 @@ class Cronjob extends CommonObject
|
||||
dol_syslog("We try to run a job in entity ".$this->entity." when we are in entity ".$conf->entity, LOG_WARNING);
|
||||
}
|
||||
$savcurrententity = $conf->entity;
|
||||
$conf->setEntityValues($this->db, $this->entity);
|
||||
$conf->setEntityValues($this->entity);
|
||||
dol_syslog(get_class($this)."::run_jobs entity for running job is ".$conf->entity);
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
@ -1090,13 +1090,13 @@ class Cronjob extends CommonObject
|
||||
if ($result < 0) {
|
||||
$this->error = "User Error:".$user->error;
|
||||
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
|
||||
$conf->setEntityValues($this->db, $savcurrententity);
|
||||
$conf->setEntityValues($savcurrententity);
|
||||
return -1;
|
||||
} else {
|
||||
if (empty($user->id)) {
|
||||
$this->error = " User user login:".$userlogin." do not exists";
|
||||
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
|
||||
$conf->setEntityValues($this->db, $savcurrententity);
|
||||
$conf->setEntityValues($savcurrententity);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1126,7 +1126,7 @@ class Cronjob extends CommonObject
|
||||
$result = $this->update($user); // This include begin/commit
|
||||
if ($result < 0) {
|
||||
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
|
||||
$conf->setEntityValues($this->db, $savcurrententity);
|
||||
$conf->setEntityValues($savcurrententity);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1241,7 +1241,7 @@ class Cronjob extends CommonObject
|
||||
if ($ret === false) {
|
||||
$this->error = $langs->trans('CronCannotLoadLib').': '.$libpath;
|
||||
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
|
||||
$conf->setEntityValues($this->db, $savcurrententity);
|
||||
$conf->setEntityValues($savcurrententity);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1250,7 +1250,7 @@ class Cronjob extends CommonObject
|
||||
$result = $langs->load($this->module_name.'@'.$this->module_name); // If this->module_name was an existing language file, this will make nothing
|
||||
if ($result < 0) { // If technical error
|
||||
dol_syslog(get_class($this)."::run_jobs Cannot load module langs".$langs->error, LOG_ERR);
|
||||
$conf->setEntityValues($this->db, $savcurrententity);
|
||||
$conf->setEntityValues($savcurrententity);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1316,11 +1316,11 @@ class Cronjob extends CommonObject
|
||||
$result = $this->update($user); // This include begin/commit
|
||||
if ($result < 0) {
|
||||
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
|
||||
$conf->setEntityValues($this->db, $savcurrententity);
|
||||
$conf->setEntityValues($savcurrententity);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$conf->setEntityValues($this->db, $savcurrententity);
|
||||
$conf->setEntityValues($savcurrententity);
|
||||
return $error ?-1 : 1;
|
||||
}
|
||||
|
||||
|
||||
@ -237,7 +237,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
|
||||
// Actions to build doc
|
||||
$upload_dir = $conf->usergroup->dir_output;
|
||||
$upload_dir = $conf->user->dir_output.'/usergroups';
|
||||
$permissiontoadd = $user->rights->user->user->creer;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
}
|
||||
@ -478,7 +478,7 @@ if ($action == 'create') {
|
||||
*/
|
||||
|
||||
$filename = dol_sanitizeFileName($object->ref);
|
||||
$filedir = $conf->usergroup->dir_output."/".dol_sanitizeFileName($object->ref);
|
||||
$filedir = $conf->user->dir_output."/usergroups/".dol_sanitizeFileName($object->ref);
|
||||
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
|
||||
$genallowed = $user->rights->user->user->creer;
|
||||
$delallowed = $user->rights->user->user->supprimer;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user