28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
33 require_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 $backtopage =
GETPOST(
'backtopage',
'alpha');
42 $socid =
GETPOST(
'socid',
'int');
43 $file_manager =
GETPOST(
'file_manager',
'alpha');
48 $section_dir =
GETPOST(
'section_dir',
'alpha');
49 $overwritefile =
GETPOST(
'overwritefile',
'int');
51 if (empty($action) && $file_manager) {
52 $action =
'file_manager';
54 $pageid =
GETPOST(
'pageid',
'int');
56 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
57 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
58 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
60 if (empty($page) || $page == -1) {
63 $offset = $limit * $page;
64 $pageprev = $page - 1;
65 $pagenext = $page + 1;
76 $result = $ecmdir->fetch($section);
85 $userstatic =
new User($db);
91 $socid = $user->socid;
95 $permissiontouploadfile = ($user->hasRight(
'ecm',
'setup') || $user->hasRight(
'mailing',
'creer') || $user->hasRight(
'website',
'write'));
96 $diroutput = $conf->medias->multidir_output[$conf->entity];
98 $relativepath = $section_dir;
99 $upload_dir = preg_replace(
'/\/$/',
'', $diroutput).
'/'.preg_replace(
'/^\//',
'', $relativepath);
103 $permissiontoadd = $permissiontouploadfile;
110 $savbacktopage = $backtopage;
111 $backtopage = $_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.urlencode($websitekey).
'&pageid='.urlencode($pageid).(GETPOST(
'section_dir',
'alpha') ?
'§ion_dir='.urlencode(
GETPOST(
'section_dir',
'alpha')) :
'');
113 $backtopage .=
'&sortfield='.urlencode($sortfield);
116 $backtopage .=
'&sortorder='.urlencode($sortorder);
118 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
120 $backtopage = $savbacktopage;
122 if ($action ==
'renamefile') {
123 $action =
'file_manager';
128 if ($action ==
'add' && $permissiontouploadfile) {
129 $ecmdir->ref =
'NOTUSEDYET';
130 $ecmdir->label =
GETPOST(
"label");
131 $ecmdir->description =
GETPOST(
"desc");
133 $id = $ecmdir->create($user);
135 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
146 if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
147 $result = $ecmdir->delete($user);
148 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
156 if ($action ==
'refreshmanual') {
162 $diroutputslash = str_replace(
'\\',
'/', $conf->ecm->dir_output);
163 $diroutputslash .=
'/';
166 $disktree =
dol_dir_list($conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'',
'', 0);
169 $sqltree = $ecmdirstatic->get_full_arbo(0);
176 foreach ($disktree as $dirdesc) {
177 $dirisindatabase = 0;
178 foreach ($sqltree as $dirsqldesc) {
179 if ($conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
180 $dirisindatabase = 1;
185 if (!$dirisindatabase) {
186 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
192 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
193 $relativepathtosearchparent = $relativepathmissing;
195 if (preg_match(
'/\//', $relativepathtosearchparent)) {
197 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
198 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
201 $parentdirisindatabase = 0;
202 foreach ($sqltree as $dirsqldesc) {
203 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
204 $parentdirisindatabase = $dirsqldesc[
'id'];
208 if ($parentdirisindatabase > 0) {
209 dol_syslog(
"Yes with id ".$parentdirisindatabase);
211 $fk_parent = $parentdirisindatabase;
222 if ($fk_parent >= 0) {
223 $ecmdirtmp->ref =
'NOTUSEDYET';
225 $ecmdirtmp->description =
'';
226 $ecmdirtmp->fk_parent = $fk_parent;
228 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
231 $id = $ecmdirtmp->create($user);
233 $newdirsql = array(
'id'=>$id,
234 'id_mere'=>$ecmdirtmp->fk_parent,
235 'label'=>$ecmdirtmp->label,
236 'description'=>$ecmdirtmp->description,
237 'fullrelativename'=>$relativepathmissing);
238 $sqltree[] = $newdirsql;
242 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
245 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
253 foreach ($sqltree as $dirdesc) {
254 $dirtotest = $conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
256 $ecmdirtmp->id = $dirdesc[
'id'];
257 $ecmdirtmp->delete($user,
'databaseonly');
262 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
268 if ($adirwascreated) {
281 $maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
287 $morejs = array(
'includes/jquery/plugins/blockUI/jquery.blockUI.js',
'core/js/blockUI.js');
288 if (empty($conf->global->MAIN_ECM_DISABLE_JS)) {
289 $morejs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
292 $moreheadjs .=
'<script type="text/javascript">'.
"\n";
293 $moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
294 $moreheadjs .= '</script>
'."\n";
296 llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0);
298 $head = ecm_prepare_dasboard_head('');
299 print dol_get_fiche_head($head, 'index_medias
', '', -1, '');
302 // Add filemanager component
305 $url = DOL_URL_ROOT.'/ecm/index_medias.php
'; // Must be an url without param
307 include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php
';
310 print dol_get_fiche_end();
Class to manage ECM directories.
Class to manage Dolibarr users.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.