29require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
42require_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);
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);
191 foreach ($disktree as $dirdesc) {
192 $dirisindatabase = 0;
193 foreach ($sqltree as $dirsqldesc) {
194 if (
$conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
195 $dirisindatabase = 1;
200 if (!$dirisindatabase) {
201 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
206 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
207 $relativepathtosearchparent = $relativepathmissing;
209 if (preg_match(
'/\//', $relativepathtosearchparent)) {
211 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
212 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
215 $parentdirisindatabase = 0;
216 foreach ($sqltree as $dirsqldesc) {
217 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
218 $parentdirisindatabase = $dirsqldesc[
'id'];
222 if ($parentdirisindatabase > 0) {
223 dol_syslog(
"Yes with id ".$parentdirisindatabase);
225 $fk_parent = $parentdirisindatabase;
236 if ($fk_parent >= 0) {
237 $ecmdirtmp->ref =
'NOTUSEDYET';
239 $ecmdirtmp->description =
'';
240 $ecmdirtmp->fk_parent = $fk_parent;
242 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
245 $id = $ecmdirtmp->create($user);
249 'id_mere' => $ecmdirtmp->fk_parent,
250 'label' => $ecmdirtmp->label,
251 'description' => $ecmdirtmp->description,
252 'fullrelativename' => $relativepathmissing,
254 $sqltree[] = $newdirsql;
257 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
260 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
267 foreach ($sqltree as $dirdesc) {
268 $dirtotest =
$conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
270 $ecmdirtmp->id = $dirdesc[
'id'];
271 $ecmdirtmp->delete($user,
'databaseonly');
276 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
282 if ($adirwascreated) {
295$maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
302 $morejs[] =
"public/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
305llxHeader($moreheadcss.$moreheadjs, $langs->trans(
"ECMArea"),
'',
'', 0, 0, $morejs,
'',
'',
'mod-ecm page-index_medias');
314 $url = DOL_URL_ROOT.
'/ecm/index_medias.php';
316include DOL_DOCUMENT_ROOT.
'/core/tpl/filemanager.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage ECM directories.
Class to manage Dolibarr users.
ecm_prepare_dasboard_head()
Prepare array with list of different ecm main dashboard.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.