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';
37$langs->loadLangs(array(
'ecm',
'companies',
'other',
'users',
'orders',
'propal',
'bills',
'contracts'));
40$action =
GETPOST(
'action',
'aZ09');
41$confirm =
GETPOST(
'confirm',
'alpha');
42$backtopage =
GETPOST(
'backtopage',
'alpha');
45$file_manager =
GETPOST(
'file_manager',
'alpha');
50$section_dir =
GETPOST(
'section_dir',
'alpha');
53if (empty($action) && $file_manager) {
54 $action =
'file_manager';
59$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
60$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
62if (empty($page) || $page == -1) {
65$offset = $limit * $page;
78 $result = $ecmdir->fetch($section);
87$userstatic =
new User($db);
93 $socid = $user->socid;
97$hookmanager->initHooks(array(
'ecmmediascard',
'globalcard'));
101$permissiontoread = ($user->hasRight(
'ecm',
'read') || $user->hasRight(
'mailing',
'lire') || $user->hasRight(
'website',
'read'));
102$permissiontouploadfile = ($user->hasRight(
'ecm',
'setup') || $user->hasRight(
'mailing',
'creer') || $user->hasRight(
'website',
'write'));
103$permissiontoadd = $permissiontouploadfile;
106$diroutput = $conf->medias->multidir_output[$conf->entity];
108$relativepath = $section_dir;
109$upload_dir = preg_replace(
'/\/$/',
'', $diroutput).
'/'.preg_replace(
'/^\//',
'', $relativepath);
119$savbacktopage = $backtopage;
120$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'))) :
'');
122 $backtopage .=
'&sortfield='.urlencode($sortfield);
125 $backtopage .=
'&sortorder='.urlencode($sortorder);
127include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
129$backtopage = $savbacktopage;
131if ($action ==
'renamefile') {
132 $action =
'file_manager';
137if ($action ==
'add' && $permissiontouploadfile) {
138 $ecmdir->ref =
'NOTUSEDYET';
139 $ecmdir->label =
GETPOST(
"label");
140 $ecmdir->description =
GETPOST(
"desc");
142 $id = $ecmdir->create($user);
144 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
155if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoadd) {
156 $result = $ecmdir->delete($user);
157 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
165if ($action ==
'refreshmanual' && $permissiontoread) {
171 $diroutputslash = str_replace(
'\\',
'/', $conf->ecm->dir_output);
172 $diroutputslash .=
'/';
175 $disktree =
dol_dir_list($conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'', 0, 0);
178 $sqltree = $ecmdirstatic->get_full_arbo(0);
185 foreach ($disktree as $dirdesc) {
186 $dirisindatabase = 0;
187 foreach ($sqltree as $dirsqldesc) {
188 if ($conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
189 $dirisindatabase = 1;
194 if (!$dirisindatabase) {
195 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
201 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
202 $relativepathtosearchparent = $relativepathmissing;
204 if (preg_match(
'/\//', $relativepathtosearchparent)) {
206 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
207 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
210 $parentdirisindatabase = 0;
211 foreach ($sqltree as $dirsqldesc) {
212 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
213 $parentdirisindatabase = $dirsqldesc[
'id'];
217 if ($parentdirisindatabase > 0) {
218 dol_syslog(
"Yes with id ".$parentdirisindatabase);
220 $fk_parent = $parentdirisindatabase;
231 if ($fk_parent >= 0) {
232 $ecmdirtmp->ref =
'NOTUSEDYET';
234 $ecmdirtmp->description =
'';
235 $ecmdirtmp->fk_parent = $fk_parent;
237 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
240 $id = $ecmdirtmp->create($user);
242 $newdirsql = array(
'id' =>
$id,
243 'id_mere' => $ecmdirtmp->fk_parent,
244 'label' => $ecmdirtmp->label,
245 'description' => $ecmdirtmp->description,
246 'fullrelativename' => $relativepathmissing);
247 $sqltree[] = $newdirsql;
251 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
254 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
262 foreach ($sqltree as $dirdesc) {
263 $dirtotest = $conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
265 $ecmdirtmp->id = $dirdesc[
'id'];
266 $ecmdirtmp->delete($user,
'databaseonly');
271 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
277 if ($adirwascreated) {
290$maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
296$morejs = array(
'includes/jquery/plugins/blockUI/jquery.blockUI.js',
'core/js/blockUI.js');
298 $morejs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
301$moreheadjs .=
'<script type="text/javascript">'.
"\n";
302$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
303$moreheadjs .= '</script>
'."\n";
305llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', 0, 0, $morejs, '', '', 'mod-ecm page-index_medias
');
307$head = ecm_prepare_dasboard_head();
308print dol_get_fiche_head($head, 'index_medias
', '', -1, '');
311// Add filemanager component
314 $url = DOL_URL_ROOT.'/ecm/index_medias.php
'; // Must be an url without param
316include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php
';
319print 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.
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.