mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
doxygen
This commit is contained in:
parent
19339bb0ea
commit
b9bac939e6
|
|
@ -62,8 +62,19 @@ class EcmDirectory extends CommonObject
|
|||
*/
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* @var int cache nb of doc
|
||||
*/
|
||||
public $cachenbofdoc = -1; // By default cache initialized with value 'not calculated'
|
||||
|
||||
/**
|
||||
* @var int date_c
|
||||
*/
|
||||
public $date_c;
|
||||
|
||||
/**
|
||||
* @var int date_m
|
||||
*/
|
||||
public $date_m;
|
||||
|
||||
/**
|
||||
|
|
@ -81,25 +92,31 @@ class EcmDirectory extends CommonObject
|
|||
*/
|
||||
public $ref;
|
||||
|
||||
/**
|
||||
* @var array array of categories
|
||||
*/
|
||||
public $cats = array();
|
||||
|
||||
/**
|
||||
* @var array array of children categories
|
||||
*/
|
||||
public $motherof = array();
|
||||
|
||||
/**
|
||||
* @var array array of forbidden chars
|
||||
*/
|
||||
public $forbiddenchars = array('<', '>', ':', '/', '\\', '?', '*', '|', '"');
|
||||
|
||||
/**
|
||||
* @var array array of forbidden chars for dir
|
||||
*/
|
||||
public $forbiddencharsdir = array('<', '>', ':', '?', '*', '|', '"');
|
||||
|
||||
/**
|
||||
* @var int 1 if full arbo loaded
|
||||
*/
|
||||
public $full_arbo_loaded;
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error;
|
||||
|
||||
/**
|
||||
* @var string[] Error codes (or messages)
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
|
@ -131,13 +148,14 @@ class EcmDirectory extends CommonObject
|
|||
$this->description = trim($this->description);
|
||||
$this->date_c = $now;
|
||||
$this->fk_user_c = $user->id;
|
||||
if ($this->fk_parent <= 0) $this->fk_parent = 0;
|
||||
if ($this->fk_parent <= 0) {
|
||||
$this->fk_parent = 0;
|
||||
}
|
||||
|
||||
|
||||
// Check if same directory does not exists with this name
|
||||
$relativepath = $this->label;
|
||||
if ($this->fk_parent)
|
||||
{
|
||||
if ($this->fk_parent) {
|
||||
$parent = new EcmDirectory($this->db);
|
||||
$parent->fetch($this->fk_parent);
|
||||
$relativepath = $parent->getRelativePath().$relativepath;
|
||||
|
|
@ -148,19 +166,16 @@ class EcmDirectory extends CommonObject
|
|||
$cat = new EcmDirectory($this->db);
|
||||
$cate_arbo = $cat->get_full_arbo(1);
|
||||
$pathfound = 0;
|
||||
foreach ($cate_arbo as $key => $categ)
|
||||
{
|
||||
foreach ($cate_arbo as $key => $categ) {
|
||||
$path = str_replace($this->forbiddencharsdir, '_', $categ['fullrelativename']);
|
||||
//print $relativepath.' - '.$path.'<br>';
|
||||
if ($path == $relativepath)
|
||||
{
|
||||
if ($path == $relativepath) {
|
||||
$pathfound = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($pathfound)
|
||||
{
|
||||
if ($pathfound) {
|
||||
$this->error = "ErrorDirAlreadyExists";
|
||||
dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING);
|
||||
return -1;
|
||||
|
|
@ -188,21 +203,23 @@ class EcmDirectory extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."ecm_directories");
|
||||
|
||||
$dir = $conf->ecm->dir_output.'/'.$this->getRelativePath();
|
||||
$result = dol_mkdir($dir);
|
||||
if ($result < 0) { $error++; $this->error = "ErrorFailedToCreateDir"; }
|
||||
if ($result < 0) {
|
||||
$error++; $this->error = "ErrorFailedToCreateDir";
|
||||
}
|
||||
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('MYECMDIR_CREATE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
} else {
|
||||
|
|
@ -249,22 +266,21 @@ class EcmDirectory extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->error = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger)
|
||||
{
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('MYECMDIR_MODIFY', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
|
|
@ -284,20 +300,26 @@ class EcmDirectory extends CommonObject
|
|||
{
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
|
||||
if (preg_match('/[0-9]+/', $value)) $sql .= " cachenbofdoc = ".(int) $value;
|
||||
else $sql .= " cachenbofdoc = cachenbofdoc ".$value." 1";
|
||||
if (preg_match('/[0-9]+/', $value)) {
|
||||
$sql .= " cachenbofdoc = ".(int) $value;
|
||||
} else {
|
||||
$sql .= " cachenbofdoc = cachenbofdoc ".$value." 1";
|
||||
}
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::changeNbOfFiles", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$this->error = "Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
} else {
|
||||
if (preg_match('/[0-9]+/', $value)) $this->cachenbofdoc = (int) $value;
|
||||
elseif ($value == '+') $this->cachenbofdoc++;
|
||||
elseif ($value == '-') $this->cachenbofdoc--;
|
||||
if (preg_match('/[0-9]+/', $value)) {
|
||||
$this->cachenbofdoc = (int) $value;
|
||||
} elseif ($value == '+') {
|
||||
$this->cachenbofdoc++;
|
||||
} elseif ($value == '-') {
|
||||
$this->cachenbofdoc--;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
@ -327,11 +349,9 @@ class EcmDirectory extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
if ($obj) {
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
|
||||
|
|
@ -374,7 +394,9 @@ class EcmDirectory extends CommonObject
|
|||
|
||||
$error = 0;
|
||||
|
||||
if ($mode != 'databaseonly') $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3
|
||||
if ($mode != 'databaseonly') {
|
||||
$relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly') ? '' : ' relativepath='.$relativepath));
|
||||
|
||||
|
|
@ -385,35 +407,30 @@ class EcmDirectory extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$this->db->rollback();
|
||||
$this->error = "Error ".$this->db->lasterror();
|
||||
return -2;
|
||||
} else {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('MYECMDIR_DELETE', $user);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if ($mode != 'databaseonly')
|
||||
{
|
||||
if ($mode != 'databaseonly') {
|
||||
$file = $conf->ecm->dir_output."/".$relativepath;
|
||||
if ($deletedirrecursive)
|
||||
{
|
||||
if ($deletedirrecursive) {
|
||||
$result = @dol_delete_dir_recursive($file, 0, 0);
|
||||
} else {
|
||||
$result = @dol_delete_dir($file, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result || !@is_dir(dol_osencode($file)))
|
||||
{
|
||||
if ($result || !@is_dir(dol_osencode($file))) {
|
||||
$this->db->commit();
|
||||
} else {
|
||||
$this->error = 'ErrorFailToDeleteDir';
|
||||
|
|
@ -422,8 +439,11 @@ class EcmDirectory extends CommonObject
|
|||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) return 1;
|
||||
else return -1;
|
||||
if (!$error) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -465,17 +485,27 @@ class EcmDirectory extends CommonObject
|
|||
$linkclose = '"'.($more ? ' '.$more : '').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
|
||||
$linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/dir_card.php?section='.$this->id.$linkclose;
|
||||
if ($option == 'index') $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&sectionexpand=true'.$linkclose;
|
||||
if ($option == 'indexexpanded') $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&sectionexpand=false'.$linkclose;
|
||||
if ($option == 'indexnotexpanded') $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&sectionexpand=true'.$linkclose;
|
||||
if ($option == 'index') {
|
||||
$linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&sectionexpand=true'.$linkclose;
|
||||
}
|
||||
if ($option == 'indexexpanded') {
|
||||
$linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&sectionexpand=false'.$linkclose;
|
||||
}
|
||||
if ($option == 'indexnotexpanded') {
|
||||
$linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&sectionexpand=true'.$linkclose;
|
||||
}
|
||||
$linkend = '</a>';
|
||||
|
||||
//$picto=DOL_URL_ROOT.'/theme/common/treemenu/folder.gif';
|
||||
$picto = 'dir';
|
||||
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
if ($withpicto != 2) $result .= ($max ?dol_trunc($newref, $max, 'middle') : $newref);
|
||||
if ($withpicto) {
|
||||
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= ($max ?dol_trunc($newref, $max, 'middle') : $newref);
|
||||
}
|
||||
$result .= $linkend;
|
||||
|
||||
return $result;
|
||||
|
|
@ -497,18 +527,15 @@ class EcmDirectory extends CommonObject
|
|||
do {
|
||||
// Get index cursor in this->cats for id_mere
|
||||
$cursorindex = -1;
|
||||
foreach ($this->cats as $key => $val)
|
||||
{
|
||||
if ($this->cats[$key]['id'] == $idtosearch)
|
||||
{
|
||||
foreach ($this->cats as $key => $val) {
|
||||
if ($this->cats[$key]['id'] == $idtosearch) {
|
||||
$cursorindex = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//print "c=".$idtosearch."-".$cursorindex;
|
||||
|
||||
if ($cursorindex >= 0)
|
||||
{
|
||||
if ($cursorindex >= 0) {
|
||||
// Path is label sanitized (no space and no special char) and concatenated
|
||||
$ret = dol_sanitizeFileName($this->cats[$cursorindex]['label']).'/'.$ret;
|
||||
|
||||
|
|
@ -541,11 +568,9 @@ class EcmDirectory extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
// This assignment in condition is not a bug. It allows walking the results.
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$this->motherof[$obj->id_son] = $obj->id_parent;
|
||||
}
|
||||
return 1;
|
||||
|
|
@ -608,8 +633,7 @@ class EcmDirectory extends CommonObject
|
|||
// phpcs:enable
|
||||
global $conf;
|
||||
|
||||
if (empty($force) && !empty($this->full_arbo_loaded))
|
||||
{
|
||||
if (empty($force) && !empty($this->full_arbo_loaded)) {
|
||||
return $this->cats;
|
||||
}
|
||||
|
||||
|
|
@ -632,13 +656,11 @@ class EcmDirectory extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::get_full_arbo", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$this->cats = array();
|
||||
$i = 0;
|
||||
// This assignment in condition is not a bug. It allows walking the results.
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$this->cats[$obj->rowid]['id'] = $obj->rowid;
|
||||
$this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid]) ? $this->motherof[$obj->rowid] : '');
|
||||
$this->cats[$obj->rowid]['label'] = $obj->label;
|
||||
|
|
@ -648,10 +670,8 @@ class EcmDirectory extends CommonObject
|
|||
$this->cats[$obj->rowid]['fk_user_c'] = $obj->fk_user_c;
|
||||
$this->cats[$obj->rowid]['login_c'] = $obj->login_c;
|
||||
|
||||
if (!empty($obj->rowid_fille))
|
||||
{
|
||||
if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children']))
|
||||
{
|
||||
if (!empty($obj->rowid_fille)) {
|
||||
if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) {
|
||||
$newelempos = count($this->cats[$obj->rowid]['id_children']);
|
||||
//print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements<br>";
|
||||
$this->cats[$obj->rowid]['id_children'][$newelempos] = $obj->rowid_fille;
|
||||
|
|
@ -668,9 +688,10 @@ class EcmDirectory extends CommonObject
|
|||
}
|
||||
|
||||
// We add properties fullxxx to all elements
|
||||
foreach ($this->cats as $key => $val)
|
||||
{
|
||||
if (isset($motherof[$key])) continue;
|
||||
foreach ($this->cats as $key => $val) {
|
||||
if (isset($motherof[$key])) {
|
||||
continue;
|
||||
}
|
||||
$this->build_path_from_id_categ($key, 0);
|
||||
}
|
||||
|
||||
|
|
@ -693,8 +714,7 @@ class EcmDirectory extends CommonObject
|
|||
{
|
||||
// phpcs:enable
|
||||
// Define fullpath
|
||||
if (!empty($this->cats[$id_categ]['id_mere']))
|
||||
{
|
||||
if (!empty($this->cats[$id_categ]['id_mere'])) {
|
||||
$this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath'];
|
||||
$this->cats[$id_categ]['fullpath'] .= '_'.$id_categ;
|
||||
$this->cats[$id_categ]['fullrelativename'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename'];
|
||||
|
|
@ -711,11 +731,11 @@ class EcmDirectory extends CommonObject
|
|||
|
||||
// Traite ces enfants
|
||||
$protection++;
|
||||
if ($protection > 20) return; // On ne traite pas plus de 20 niveaux
|
||||
if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children']))
|
||||
{
|
||||
foreach ($this->cats[$id_categ]['id_children'] as $key => $val)
|
||||
{
|
||||
if ($protection > 20) {
|
||||
return; // On ne traite pas plus de 20 niveaux
|
||||
}
|
||||
if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) {
|
||||
foreach ($this->cats[$id_categ]['id_children'] as $key => $val) {
|
||||
$this->build_path_from_id_categ($val, $protection);
|
||||
}
|
||||
}
|
||||
|
|
@ -741,8 +761,7 @@ class EcmDirectory extends CommonObject
|
|||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
|
||||
$sql .= " cachenbofdoc = '".count($filelist)."'";
|
||||
if (empty($all)) // By default
|
||||
{
|
||||
if (empty($all)) { // By default
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
} else {
|
||||
$sql .= " WHERE entity = ".$conf->entity;
|
||||
|
|
@ -750,8 +769,7 @@ class EcmDirectory extends CommonObject
|
|||
|
||||
dol_syslog(get_class($this)."::refreshcachenboffile", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$this->cachenbofdoc = count($filelist);
|
||||
return $this->cachenbofdoc;
|
||||
} else {
|
||||
|
|
@ -782,8 +800,7 @@ class EcmDirectory extends CommonObject
|
|||
$interface = new Interfaces($this->db);
|
||||
$result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf);
|
||||
if ($result < 0) {
|
||||
if (!empty($this->errors))
|
||||
{
|
||||
if (!empty($this->errors)) {
|
||||
$this->errors = array_merge($this->errors, $interface->errors);
|
||||
} else {
|
||||
$this->errors = $interface->errors;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,15 @@ class EcmFiles extends CommonObject
|
|||
* @var string keywords
|
||||
*/
|
||||
public $keywords;
|
||||
|
||||
/**
|
||||
* @var string cover
|
||||
*/
|
||||
public $cover;
|
||||
|
||||
/**
|
||||
* @var int position
|
||||
*/
|
||||
public $position;
|
||||
|
||||
/**
|
||||
|
|
@ -131,7 +139,15 @@ class EcmFiles extends CommonObject
|
|||
* @var string acl
|
||||
*/
|
||||
public $acl;
|
||||
|
||||
/**
|
||||
* @var string src object type
|
||||
*/
|
||||
public $src_object_type;
|
||||
|
||||
/**
|
||||
* @var int src object id
|
||||
*/
|
||||
public $src_object_id;
|
||||
|
||||
|
||||
|
|
@ -233,8 +249,7 @@ class EcmFiles extends CommonObject
|
|||
$sql .= " WHERE filepath ='".$this->db->escape($this->filepath)."'";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$maxposition = (int) $obj->maxposition;
|
||||
} else {
|
||||
|
|
@ -247,13 +262,11 @@ class EcmFiles extends CommonObject
|
|||
}
|
||||
|
||||
// Check parameters
|
||||
if (empty($this->filename) || empty($this->filepath))
|
||||
{
|
||||
if (empty($this->filename) || empty($this->filepath)) {
|
||||
$this->errors[] = 'Bad property filename or filepath';
|
||||
return --$error;
|
||||
}
|
||||
if (!isset($this->entity))
|
||||
{
|
||||
if (!isset($this->entity)) {
|
||||
$this->entity = $conf->entity;
|
||||
}
|
||||
// Put here code to add control on parameters values
|
||||
|
|
@ -317,11 +330,12 @@ class EcmFiles extends CommonObject
|
|||
$this->position = $maxposition;
|
||||
|
||||
// Triggers
|
||||
if (!$notrigger)
|
||||
{
|
||||
if (!$notrigger) {
|
||||
// Call triggers
|
||||
$result = $this->call_trigger(strtoupper(get_class($this)).'_CREATE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
|
@ -401,8 +415,7 @@ class EcmFiles extends CommonObject
|
|||
} elseif (!empty($hashforshare)) {
|
||||
$sql .= " AND t.share = '".$this->db->escape($hashforshare)."'";
|
||||
//$sql .= " AND t.entity = ".$conf->entity; // hashforshare already unique
|
||||
} elseif ($src_object_type && $src_object_id)
|
||||
{
|
||||
} elseif ($src_object_type && $src_object_id) {
|
||||
// Warning: May return several record, and only first one is returned !
|
||||
$sql .= " AND t.src_object_type ='".$this->db->escape($src_object_type)."' AND t.src_object_id = ".$this->db->escape($src_object_id);
|
||||
$sql .= " AND t.entity = ".$conf->entity;
|
||||
|
|
@ -668,11 +681,12 @@ class EcmFiles extends CommonObject
|
|||
}
|
||||
|
||||
// Triggers
|
||||
if (!$error && !$notrigger)
|
||||
{
|
||||
if (!$error && !$notrigger) {
|
||||
// Call triggers
|
||||
$result = $this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $user);
|
||||
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
} //Do also here what you must do to rollback action if trigger fail
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
|
|
@ -705,11 +719,12 @@ class EcmFiles extends CommonObject
|
|||
$this->db->begin();
|
||||
|
||||
// Triggers
|
||||
if (!$notrigger)
|
||||
{
|
||||
if (!$notrigger) {
|
||||
// Call triggers
|
||||
$result = $this->call_trigger(strtoupper(get_class($this)).'_DELETE', $user);
|
||||
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
} //Do also here what you must do to rollback action if trigger fail
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
|
|
@ -804,7 +819,9 @@ class EcmFiles extends CommonObject
|
|||
global $dolibarr_main_authentication, $dolibarr_main_demo;
|
||||
global $menumanager;
|
||||
|
||||
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
|
||||
if (!empty($conf->dol_no_mouse_hover)) {
|
||||
$notooltip = 1; // Force disable tooltips
|
||||
}
|
||||
|
||||
$result = '';
|
||||
|
||||
|
|
@ -815,25 +832,26 @@ class EcmFiles extends CommonObject
|
|||
$url = DOL_URL_ROOT.'/ecm/'.$this->table_name.'_card.php?id='.$this->id;
|
||||
|
||||
$linkclose = '';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
if (empty($notooltip)) {
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||
$label = $langs->trans("ShowProject");
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
|
||||
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
} else {
|
||||
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
}
|
||||
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
$linkstart .= $linkclose.'>';
|
||||
$linkend = '</a>';
|
||||
|
||||
if ($withpicto)
|
||||
{
|
||||
if ($withpicto) {
|
||||
$result .= ($linkstart.img_object(($notooltip ? '' : $label), 'label', ($notooltip ? '' : 'class="classfortooltip"')).$linkend);
|
||||
if ($withpicto != 2) $result .= ' ';
|
||||
if ($withpicto != 2) {
|
||||
$result .= ' ';
|
||||
}
|
||||
}
|
||||
$result .= $linkstart.$this->ref.$linkend;
|
||||
return $result;
|
||||
|
|
|
|||
|
|
@ -41,20 +41,22 @@ $confirm = GETPOST('confirm', 'alpha');
|
|||
$module = GETPOST('module', 'alpha');
|
||||
$website = GETPOST('website', 'alpha');
|
||||
$pageid = GETPOST('pageid', 'int');
|
||||
if (empty($module)) $module = 'ecm';
|
||||
if (empty($module)) {
|
||||
$module = 'ecm';
|
||||
}
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0)
|
||||
{
|
||||
if ($user->socid > 0) {
|
||||
$action = '';
|
||||
$socid = $user->socid;
|
||||
}
|
||||
|
||||
$section = $urlsection = GETPOST('section', 'alpha');
|
||||
if (empty($urlsection)) $urlsection = 'misc';
|
||||
if (empty($urlsection)) {
|
||||
$urlsection = 'misc';
|
||||
}
|
||||
|
||||
if ($module == 'ecm')
|
||||
{
|
||||
if ($module == 'ecm') {
|
||||
$upload_dir = $conf->ecm->dir_output.'/'.$urlsection;
|
||||
} else // For example $module == 'medias'
|
||||
{
|
||||
|
|
@ -65,19 +67,23 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
|||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) $sortfield = "label";
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "label";
|
||||
}
|
||||
|
||||
$ecmdir = new EcmDirectory($db);
|
||||
if (!empty($section))
|
||||
{
|
||||
if (!empty($section)) {
|
||||
$result = $ecmdir->fetch($section);
|
||||
if (!$result > 0)
|
||||
{
|
||||
if (!$result > 0) {
|
||||
dol_print_error($db, $ecmdir->error);
|
||||
exit;
|
||||
}
|
||||
|
|
@ -86,18 +92,18 @@ if (!empty($section))
|
|||
// Permissions
|
||||
$permtoadd = 0;
|
||||
$permtoupload = 0;
|
||||
if ($module == 'ecm')
|
||||
{
|
||||
if ($module == 'ecm') {
|
||||
$permtoadd = $user->rights->ecm->setup;
|
||||
$permtoupload = $user->rights->ecm->upload;
|
||||
}
|
||||
if ($module == 'medias')
|
||||
{
|
||||
if ($module == 'medias') {
|
||||
$permtoadd = ($user->rights->mailing->creer || $user->rights->website->write);
|
||||
$permtoupload = ($user->rights->mailing->creer || $user->rights->website->write);
|
||||
}
|
||||
|
||||
if (!$permtoadd) accessforbidden();
|
||||
if (!$permtoadd) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -106,12 +112,9 @@ if (!$permtoadd) accessforbidden();
|
|||
*/
|
||||
|
||||
// Action ajout d'un produit ou service
|
||||
if ($action == 'add' && $permtoadd)
|
||||
{
|
||||
if ($cancel)
|
||||
{
|
||||
if (!empty($backtopage))
|
||||
{
|
||||
if ($action == 'add' && $permtoadd) {
|
||||
if ($cancel) {
|
||||
if (!empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
} else {
|
||||
|
|
@ -120,33 +123,31 @@ if ($action == 'add' && $permtoadd)
|
|||
}
|
||||
}
|
||||
|
||||
$ref = GETPOST("ref", 'alpha');
|
||||
$label = GETPOST("label", 'alpha');
|
||||
$desc = GETPOST("desc", 'alpha');
|
||||
$ref = (string) GETPOST("ref", 'alpha');
|
||||
$label = (string) GETPOST("label", 'alpha');
|
||||
$desc = (string) GETPOST("desc", 'alpha');
|
||||
$catParent = GETPOST("catParent", 'alpha'); // Can be an int (with ECM) or a string (with generic filemanager)
|
||||
if ($catParent == '-1') $catParent = 0;
|
||||
if ($catParent == '-1') {
|
||||
$catParent = 0;
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (empty($label))
|
||||
{
|
||||
if (empty($label)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if ($module == 'ecm')
|
||||
{
|
||||
if (!$error) {
|
||||
if ($module == 'ecm') {
|
||||
$ecmdir->ref = $ref;
|
||||
$ecmdir->label = $label;
|
||||
$ecmdir->description = $desc;
|
||||
$ecmdir->fk_parent = (int) $catParent;
|
||||
|
||||
$id = $ecmdir->create($user);
|
||||
if ($id <= 0)
|
||||
{
|
||||
if ($id <= 0) {
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($ecmdir->error, $ecmdir->errors, 'errors');
|
||||
|
|
@ -155,22 +156,18 @@ if ($action == 'add' && $permtoadd)
|
|||
} else // For example $module == 'medias'
|
||||
{
|
||||
$dirfornewdir = '';
|
||||
if ($module == 'medias')
|
||||
{
|
||||
if ($module == 'medias') {
|
||||
$dirfornewdir = $conf->medias->multidir_output[$conf->entity];
|
||||
}
|
||||
if (empty($dirfornewdir))
|
||||
{
|
||||
if (empty($dirfornewdir)) {
|
||||
$error++;
|
||||
dol_print_error('', 'Bad value for module. Not supported.');
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$fullpathofdir = $dirfornewdir.'/'.($catParent ? $catParent.'/' : '').$label;
|
||||
$result = dol_mkdir($fullpathofdir, DOL_DATA_ROOT);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($langs->trans('ErrorFailToCreateDir', $label), null, 'errors');
|
||||
$error++;
|
||||
} else {
|
||||
|
|
@ -180,10 +177,8 @@ if ($action == 'add' && $permtoadd)
|
|||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!empty($backtopage))
|
||||
{
|
||||
if (!$error) {
|
||||
if (!empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
} else {
|
||||
|
|
@ -194,8 +189,7 @@ if ($action == 'add' && $permtoadd)
|
|||
}
|
||||
|
||||
// Deleting file
|
||||
elseif ($action == 'confirm_deletesection' && $confirm == 'yes')
|
||||
{
|
||||
elseif ($action == 'confirm_deletesection' && $confirm == 'yes') {
|
||||
$result = $ecmdir->delete($user);
|
||||
setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs');
|
||||
}
|
||||
|
|
@ -212,8 +206,7 @@ llxHeader('', $langs->trans("ECMNewSection"));
|
|||
$form = new Form($db);
|
||||
$formecm = new FormEcm($db);
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
//***********************
|
||||
// Create
|
||||
//***********************
|
||||
|
|
@ -222,8 +215,12 @@ if ($action == 'create')
|
|||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
|
||||
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
|
||||
if ($website) print '<input type="hidden" name="website" value="'.dol_escape_htmltag($website).'">';
|
||||
if ($pageid) print '<input type="hidden" name="pageid" value="'.dol_escape_htmltag($pageid).'">';
|
||||
if ($website) {
|
||||
print '<input type="hidden" name="website" value="'.dol_escape_htmltag($website).'">';
|
||||
}
|
||||
if ($pageid) {
|
||||
print '<input type="hidden" name="pageid" value="'.dol_escape_htmltag($pageid).'">';
|
||||
}
|
||||
|
||||
$title = $langs->trans("ECMNewSection");
|
||||
print load_fiche_titre($title);
|
||||
|
|
@ -240,8 +237,7 @@ if ($action == 'create')
|
|||
print '</td></tr>'."\n";
|
||||
|
||||
// Description
|
||||
if ($module == 'ecm')
|
||||
{
|
||||
if ($module == 'ecm') {
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
|
||||
print '<textarea name="desc" rows="4" class="quatrevingtpercent">';
|
||||
print $ecmdir->description;
|
||||
|
|
@ -262,8 +258,7 @@ if ($action == 'create')
|
|||
}
|
||||
|
||||
|
||||
if (empty($action) || $action == 'delete_section')
|
||||
{
|
||||
if (empty($action) || $action == 'delete_section') {
|
||||
//***********************
|
||||
// List
|
||||
//***********************
|
||||
|
|
@ -277,21 +272,17 @@ if (empty($action) || $action == 'delete_section')
|
|||
print '<a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php">'.$langs->trans("ECMRoot").'</a>';
|
||||
//print ' -> <b>'.$ecmdir->getNomUrl(1).'</b><br>';
|
||||
print "<br><br>";
|
||||
*/
|
||||
*/
|
||||
|
||||
// Confirmation de la suppression d'une ligne categorie
|
||||
if ($action == 'delete_section')
|
||||
{
|
||||
if ($action == 'delete_section') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection');
|
||||
}
|
||||
|
||||
// Construit fiche rubrique
|
||||
|
||||
|
||||
// Actions buttons
|
||||
print '<div class="tabsAction">';
|
||||
if ($user->rights->ecm->setup)
|
||||
{
|
||||
if ($user->rights->ecm->setup) {
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=delete_section&token='.newToken().'">'.$langs->trans('Delete').'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user