30require
'../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
46$langs->loadLangs(array(
'ecm',
'companies',
'other',
'users',
'orders',
'propal',
'bills',
'contracts'));
49$action =
GETPOST(
'action',
'aZ09');
50$confirm =
GETPOST(
'confirm',
'alpha');
51$backtopage =
GETPOST(
'backtopage',
'alpha');
54$file_manager =
GETPOST(
'file_manager',
'alpha');
59$section_dir =
GETPOST(
'section_dir',
'alpha');
62if (empty($action) && $file_manager) {
63 $action =
'file_manager';
68$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
69$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
71if (empty($page) || $page == -1) {
74$offset = $limit * $page;
87 $result = $ecmdir->fetch($section);
89 dol_print_error($db, $ecmdir->error);
96$userstatic =
new User($db);
102 $socid = $user->socid;
106$hookmanager->initHooks(array(
'ecmmediascard',
'globalcard'));
110$permissiontoread = ($user->hasRight(
'ecm',
'read') || $user->hasRight(
'mailing',
'lire') || $user->hasRight(
'website',
'read'));
111$permissiontouploadfile = ($user->hasRight(
'ecm',
'setup') || $user->hasRight(
'mailing',
'creer') || $user->hasRight(
'website',
'write'));
112$permissiontoadd = $permissiontouploadfile;
115$diroutput =
$conf->medias->multidir_output[
$conf->entity];
117$relativepath = $section_dir;
118$upload_dir = preg_replace(
'/\/$/',
'', $diroutput).
'/'.preg_replace(
'/^\//',
'', $relativepath);
128$savbacktopage = $backtopage;
130$paramsbacktopage = array(
132 'website' => (
string) $websitekey,
133 'pageid' => (
string) $pageid,
135if (
GETPOST(
'section_dir',
'alpha')) {
136 $paramsbacktopage[
'section_dir'] =
GETPOST(
'section_dir',
'alpha');
139 $paramsbacktopage[
'sortfield'] = $sortfield;
142 $paramsbacktopage[
'sortorder'] = $sortorder;
144$backtopage =
dolBuildUrl($_SERVER[
"PHP_SELF"], $paramsbacktopage);
145include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
147$backtopage = $savbacktopage;
149if ($action ==
'renamefile') {
150 $action =
'file_manager';
155if ($action ==
'add' && $permissiontouploadfile) {
156 $ecmdir->ref =
'NOTUSEDYET';
157 $ecmdir->label =
GETPOST(
"label");
158 $ecmdir->description =
GETPOST(
"desc");
160 $id = $ecmdir->create($user);
162 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
165 setEventMessages(
'Error '.$langs->trans($ecmdir->error),
null,
'errors');
173if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoadd) {
174 $result = $ecmdir->delete($user);
176 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
178 setEventMessages($ecmdir->error, $ecmdir->errors,
'errors');
187if ($action ==
'refreshmanual' && $permissiontoread) {
193 $diroutputslash = str_replace(
'\\',
'/',
$conf->ecm->dir_output);
194 $diroutputslash .=
'/';
197 $disktree =
dol_dir_list(
$conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'', 0, 0);
200 $treesqldir = $ecmdirstatic->get_full_arbo(0);
205 foreach ($disktree as $dirdesc) {
206 $dirisindatabase = 0;
207 foreach ($treesqldir as $dirsqldesc) {
208 if (
$conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
209 $dirisindatabase = 1;
214 if (!$dirisindatabase) {
215 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
220 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
221 $relativepathtosearchparent = $relativepathmissing;
223 if (preg_match(
'/\//', $relativepathtosearchparent)) {
225 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
226 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
229 $parentdirisindatabase = 0;
230 foreach ($treesqldir as $dirsqldesc) {
231 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
232 $parentdirisindatabase = $dirsqldesc[
'id'];
236 if ($parentdirisindatabase > 0) {
237 dol_syslog(
"Yes with id ".$parentdirisindatabase);
239 $fk_parent = $parentdirisindatabase;
250 if ($fk_parent >= 0) {
251 $ecmdirtmp->ref =
'NOTUSEDYET';
253 $ecmdirtmp->description =
'';
254 $ecmdirtmp->fk_parent = $fk_parent;
256 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
259 $id = $ecmdirtmp->create($user);
263 'id_mere' => $ecmdirtmp->fk_parent,
264 'label' => $ecmdirtmp->label,
265 'description' => $ecmdirtmp->description,
266 'fullrelativename' => $relativepathmissing,
268 $treesqldir[] = $newsqldir;
271 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
274 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
281 foreach ($treesqldir as $dirdesc) {
282 $dirtotest =
$conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
284 $ecmdirtmp->id = $dirdesc[
'id'];
285 $ecmdirtmp->delete($user,
'databaseonly');
290 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
296 if ($adirwascreated) {
309$maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
316 $morejs[] =
"public/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
319llxHeader($moreheadcss.$moreheadjs, $langs->trans(
"ECMArea"),
'',
'', 0, 0, $morejs,
'',
'',
'mod-ecm page-index_medias');
328 $url = DOL_URL_ROOT.
'/ecm/index_medias.php';
330include DOL_DOCUMENT_ROOT.
'/core/tpl/filemanager.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage ECM directories.
Class to manage Dolibarr users.
if(! $sortfield) if(! $sortorder) $module
ecm_prepare_dasboard_head()
Prepare array with list of different ecm main dashboard.
dol_basename($pathfile)
Make a basename working with all page code (default PHP basenamed fails with cyrillic).
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_is_dir($folder)
Test if filename is a directory.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.