29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
45$langs->loadLangs(array(
'ecm',
'companies',
'other',
'users',
'orders',
'propal',
'bills',
'contracts'));
48$action =
GETPOST(
'action',
'aZ09');
49$confirm =
GETPOST(
'confirm',
'alpha');
50$backtopage =
GETPOST(
'backtopage',
'alpha');
53$file_manager =
GETPOST(
'file_manager',
'alpha');
58$section_dir =
GETPOST(
'section_dir',
'alpha');
61if (empty($action) && $file_manager) {
62 $action =
'file_manager';
67$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
68$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
70if (empty($page) || $page == -1) {
73$offset = $limit * $page;
86 $result = $ecmdir->fetch($section);
95$userstatic =
new User($db);
101 $socid = $user->socid;
105$hookmanager->initHooks(array(
'ecmmediascard',
'globalcard'));
109$permissiontoread = ($user->hasRight(
'ecm',
'read') || $user->hasRight(
'mailing',
'lire') || $user->hasRight(
'website',
'read'));
110$permissiontouploadfile = ($user->hasRight(
'ecm',
'setup') || $user->hasRight(
'mailing',
'creer') || $user->hasRight(
'website',
'write'));
111$permissiontoadd = $permissiontouploadfile;
114$diroutput =
$conf->medias->multidir_output[
$conf->entity];
116$relativepath = $section_dir;
117$upload_dir = preg_replace(
'/\/$/',
'', $diroutput).
'/'.preg_replace(
'/^\//',
'', $relativepath);
127$savbacktopage = $backtopage;
128$backtopage = $_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.urlencode((
string) ($websitekey)).
'&pageid='.urlencode((
string) ($pageid)).(GETPOST(
'section_dir',
'alpha') ?
'§ion_dir='.urlencode((
string) (
GETPOST(
'section_dir',
'alpha'))) :
'');
130 $backtopage .=
'&sortfield='.urlencode($sortfield);
133 $backtopage .=
'&sortorder='.urlencode($sortorder);
135include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
137$backtopage = $savbacktopage;
139if ($action ==
'renamefile') {
140 $action =
'file_manager';
145if ($action ==
'add' && $permissiontouploadfile) {
146 $ecmdir->ref =
'NOTUSEDYET';
147 $ecmdir->label =
GETPOST(
"label");
148 $ecmdir->description =
GETPOST(
"desc");
150 $id = $ecmdir->create($user);
152 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
163if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoadd) {
164 $result = $ecmdir->delete($user);
165 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
173if ($action ==
'refreshmanual' && $permissiontoread) {
179 $diroutputslash = str_replace(
'\\',
'/',
$conf->ecm->dir_output);
180 $diroutputslash .=
'/';
183 $disktree =
dol_dir_list(
$conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'', 0, 0);
186 $sqltree = $ecmdirstatic->get_full_arbo(0);
193 foreach ($disktree as $dirdesc) {
194 $dirisindatabase = 0;
195 foreach ($sqltree as $dirsqldesc) {
196 if (
$conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
197 $dirisindatabase = 1;
202 if (!$dirisindatabase) {
203 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
209 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
210 $relativepathtosearchparent = $relativepathmissing;
212 if (preg_match(
'/\//', $relativepathtosearchparent)) {
214 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
215 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
218 $parentdirisindatabase = 0;
219 foreach ($sqltree as $dirsqldesc) {
220 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
221 $parentdirisindatabase = $dirsqldesc[
'id'];
225 if ($parentdirisindatabase > 0) {
226 dol_syslog(
"Yes with id ".$parentdirisindatabase);
228 $fk_parent = $parentdirisindatabase;
239 if ($fk_parent >= 0) {
240 $ecmdirtmp->ref =
'NOTUSEDYET';
242 $ecmdirtmp->description =
'';
243 $ecmdirtmp->fk_parent = $fk_parent;
245 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
248 $id = $ecmdirtmp->create($user);
250 $newdirsql = array(
'id' =>
$id,
251 'id_mere' => $ecmdirtmp->fk_parent,
252 'label' => $ecmdirtmp->label,
253 'description' => $ecmdirtmp->description,
254 'fullrelativename' => $relativepathmissing);
255 $sqltree[] = $newdirsql;
259 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
262 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
270 foreach ($sqltree as $dirdesc) {
271 $dirtotest =
$conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
273 $ecmdirtmp->id = $dirdesc[
'id'];
274 $ecmdirtmp->delete($user,
'databaseonly');
279 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
285 if ($adirwascreated) {
298$maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
304$morejs = array(
'includes/jquery/plugins/blockUI/jquery.blockUI.js',
'core/js/blockUI.js');
306 $morejs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
309$moreheadjs .=
'<script type="text/javascript">'.
"\n";
310$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".
$conf->theme.
"/img/working.gif".
'\';
'."\n";
311$moreheadjs .= '</script>
'."\n";
313llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', 0, 0, $morejs, '', '', 'mod-ecm page-index_medias
');
315$head = ecm_prepare_dasboard_head();
316print dol_get_fiche_head($head, 'index_medias
', '', -1, '');
319// Add filemanager component
322 $url = DOL_URL_ROOT.'/ecm/index_medias.php
'; // Must be an url without param
324include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php
';
327print dol_get_fiche_end();
Class to manage ECM directories.
Class to manage Dolibarr users.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.