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;
106 $hookmanager->initHooks(array(
'ecmmediascard',
'globalcard'));
112 $savbacktopage = $backtopage;
113 $backtopage = $_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.urlencode($websitekey).
'&pageid='.urlencode($pageid).(GETPOST(
'section_dir',
'alpha') ?
'§ion_dir='.urlencode(
GETPOST(
'section_dir',
'alpha')) :
'');
115 $backtopage .=
'&sortfield='.urlencode($sortfield);
118 $backtopage .=
'&sortorder='.urlencode($sortorder);
120 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
122 $backtopage = $savbacktopage;
124 if ($action ==
'renamefile') {
125 $action =
'file_manager';
130 if ($action ==
'add' && $permissiontouploadfile) {
131 $ecmdir->ref =
'NOTUSEDYET';
132 $ecmdir->label =
GETPOST(
"label");
133 $ecmdir->description =
GETPOST(
"desc");
135 $id = $ecmdir->create($user);
137 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
148 if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
149 $result = $ecmdir->delete($user);
150 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
158 if ($action ==
'refreshmanual') {
164 $diroutputslash = str_replace(
'\\',
'/', $conf->ecm->dir_output);
165 $diroutputslash .=
'/';
168 $disktree =
dol_dir_list($conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'',
'', 0);
171 $sqltree = $ecmdirstatic->get_full_arbo(0);
178 foreach ($disktree as $dirdesc) {
179 $dirisindatabase = 0;
180 foreach ($sqltree as $dirsqldesc) {
181 if ($conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
182 $dirisindatabase = 1;
187 if (!$dirisindatabase) {
188 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
194 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
195 $relativepathtosearchparent = $relativepathmissing;
197 if (preg_match(
'/\//', $relativepathtosearchparent)) {
199 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
200 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
203 $parentdirisindatabase = 0;
204 foreach ($sqltree as $dirsqldesc) {
205 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
206 $parentdirisindatabase = $dirsqldesc[
'id'];
210 if ($parentdirisindatabase > 0) {
211 dol_syslog(
"Yes with id ".$parentdirisindatabase);
213 $fk_parent = $parentdirisindatabase;
224 if ($fk_parent >= 0) {
225 $ecmdirtmp->ref =
'NOTUSEDYET';
227 $ecmdirtmp->description =
'';
228 $ecmdirtmp->fk_parent = $fk_parent;
230 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
233 $id = $ecmdirtmp->create($user);
235 $newdirsql = array(
'id'=>$id,
236 'id_mere'=>$ecmdirtmp->fk_parent,
237 'label'=>$ecmdirtmp->label,
238 'description'=>$ecmdirtmp->description,
239 'fullrelativename'=>$relativepathmissing);
240 $sqltree[] = $newdirsql;
244 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
247 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
255 foreach ($sqltree as $dirdesc) {
256 $dirtotest = $conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
258 $ecmdirtmp->id = $dirdesc[
'id'];
259 $ecmdirtmp->delete($user,
'databaseonly');
264 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
270 if ($adirwascreated) {
283 $maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
289 $morejs = array(
'includes/jquery/plugins/blockUI/jquery.blockUI.js',
'core/js/blockUI.js');
290 if (empty($conf->global->MAIN_ECM_DISABLE_JS)) {
291 $morejs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
294 $moreheadjs .=
'<script type="text/javascript">'.
"\n";
295 $moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
296 $moreheadjs .= '</script>
'."\n";
298 llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0);
300 $head = ecm_prepare_dasboard_head(null);
301 print dol_get_fiche_head($head, 'index_medias
', '', -1, '');
304 // Add filemanager component
307 $url = DOL_URL_ROOT.'/ecm/index_medias.php
'; // Must be an url without param
309 include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php
';
312 print dol_get_fiche_end();
Class to manage ECM directories.
Class to manage Dolibarr users.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
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...
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.
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.