28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
36$langs->loadLangs(array(
'ecm',
'companies',
'other',
'users',
'orders',
'propal',
'bills',
'contracts'));
39$action =
GETPOST(
'action',
'aZ09');
40$confirm =
GETPOST(
'confirm',
'alpha');
41$backtopage =
GETPOST(
'backtopage',
'alpha');
43$socid =
GETPOST(
'socid',
'int');
44$file_manager =
GETPOST(
'file_manager',
'alpha');
49$section_dir =
GETPOST(
'section_dir',
'alpha');
50$overwritefile =
GETPOST(
'overwritefile',
'int');
52if (empty($action) && $file_manager) {
53 $action =
'file_manager';
55$pageid =
GETPOST(
'pageid',
'int');
57$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
58$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
59$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
60$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
61if (empty($page) || $page == -1) {
64$offset = $limit * $page;
77 $result = $ecmdir->fetch($section);
86$userstatic =
new User($db);
92 $socid = $user->socid;
96$permissiontouploadfile = ($user->hasRight(
'ecm',
'setup') || $user->hasRight(
'mailing',
'creer') || $user->hasRight(
'website',
'write'));
97$diroutput = $conf->medias->multidir_output[$conf->entity];
99$relativepath = $section_dir;
100$upload_dir = preg_replace(
'/\/$/',
'', $diroutput).
'/'.preg_replace(
'/^\//',
'', $relativepath);
104$permissiontoadd = $permissiontouploadfile;
107$hookmanager->initHooks(array(
'ecmmediascard',
'globalcard'));
113$savbacktopage = $backtopage;
114$backtopage = $_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.urlencode($websitekey).
'&pageid='.urlencode($pageid).(GETPOST(
'section_dir',
'alpha') ?
'§ion_dir='.urlencode(
GETPOST(
'section_dir',
'alpha')) :
'');
116 $backtopage .=
'&sortfield='.urlencode($sortfield);
119 $backtopage .=
'&sortorder='.urlencode($sortorder);
121include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
123$backtopage = $savbacktopage;
125if ($action ==
'renamefile') {
126 $action =
'file_manager';
131if ($action ==
'add' && $permissiontouploadfile) {
132 $ecmdir->ref =
'NOTUSEDYET';
133 $ecmdir->label =
GETPOST(
"label");
134 $ecmdir->description =
GETPOST(
"desc");
136 $id = $ecmdir->create($user);
138 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
149if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
150 $result = $ecmdir->delete($user);
151 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
159if ($action ==
'refreshmanual') {
165 $diroutputslash = str_replace(
'\\',
'/', $conf->ecm->dir_output);
166 $diroutputslash .=
'/';
169 $disktree =
dol_dir_list($conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'',
'', 0);
172 $sqltree = $ecmdirstatic->get_full_arbo(0);
179 foreach ($disktree as $dirdesc) {
180 $dirisindatabase = 0;
181 foreach ($sqltree as $dirsqldesc) {
182 if ($conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
183 $dirisindatabase = 1;
188 if (!$dirisindatabase) {
189 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
195 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
196 $relativepathtosearchparent = $relativepathmissing;
198 if (preg_match(
'/\//', $relativepathtosearchparent)) {
200 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
201 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
204 $parentdirisindatabase = 0;
205 foreach ($sqltree as $dirsqldesc) {
206 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
207 $parentdirisindatabase = $dirsqldesc[
'id'];
211 if ($parentdirisindatabase > 0) {
212 dol_syslog(
"Yes with id ".$parentdirisindatabase);
214 $fk_parent = $parentdirisindatabase;
225 if ($fk_parent >= 0) {
226 $ecmdirtmp->ref =
'NOTUSEDYET';
228 $ecmdirtmp->description =
'';
229 $ecmdirtmp->fk_parent = $fk_parent;
231 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
234 $id = $ecmdirtmp->create($user);
236 $newdirsql = array(
'id'=>$id,
237 'id_mere'=>$ecmdirtmp->fk_parent,
238 'label'=>$ecmdirtmp->label,
239 'description'=>$ecmdirtmp->description,
240 'fullrelativename'=>$relativepathmissing);
241 $sqltree[] = $newdirsql;
245 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
248 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
256 foreach ($sqltree as $dirdesc) {
257 $dirtotest = $conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
259 $ecmdirtmp->id = $dirdesc[
'id'];
260 $ecmdirtmp->delete($user,
'databaseonly');
265 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
271 if ($adirwascreated) {
284$maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
290$morejs = array(
'includes/jquery/plugins/blockUI/jquery.blockUI.js',
'core/js/blockUI.js');
291if (empty($conf->global->MAIN_ECM_DISABLE_JS)) {
292 $morejs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
295$moreheadjs .=
'<script type="text/javascript">'.
"\n";
296$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
297$moreheadjs .= '</script>
'."\n";
299llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0);
301$head = ecm_prepare_dasboard_head(null);
302print dol_get_fiche_head($head, 'index_medias
', '', -1, '');
305// Add filemanager component
308 $url = DOL_URL_ROOT.'/ecm/index_medias.php
'; // Must be an url without param
310include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php
';
313print 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($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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.