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$permissiontouploadfile = ($user->hasRight(
'ecm',
'setup') || $user->hasRight(
'mailing',
'creer') || $user->hasRight(
'website',
'write'));
98$diroutput = $conf->medias->multidir_output[$conf->entity];
100$relativepath = $section_dir;
101$upload_dir = preg_replace(
'/\/$/',
'', $diroutput).
'/'.preg_replace(
'/^\//',
'', $relativepath);
105$permissiontoadd = $permissiontouploadfile;
108$hookmanager->initHooks(array(
'ecmmediascard',
'globalcard'));
114$savbacktopage = $backtopage;
115$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'))) :
'');
117 $backtopage .=
'&sortfield='.urlencode($sortfield);
120 $backtopage .=
'&sortorder='.urlencode($sortorder);
122include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
124$backtopage = $savbacktopage;
126if ($action ==
'renamefile') {
127 $action =
'file_manager';
132if ($action ==
'add' && $permissiontouploadfile) {
133 $ecmdir->ref =
'NOTUSEDYET';
134 $ecmdir->label =
GETPOST(
"label");
135 $ecmdir->description =
GETPOST(
"desc");
137 $id = $ecmdir->create($user);
139 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
150if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
151 $result = $ecmdir->delete($user);
152 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
160if ($action ==
'refreshmanual') {
166 $diroutputslash = str_replace(
'\\',
'/', $conf->ecm->dir_output);
167 $diroutputslash .=
'/';
170 $disktree =
dol_dir_list($conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'',
'', 0);
173 $sqltree = $ecmdirstatic->get_full_arbo(0);
180 foreach ($disktree as $dirdesc) {
181 $dirisindatabase = 0;
182 foreach ($sqltree as $dirsqldesc) {
183 if ($conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
184 $dirisindatabase = 1;
189 if (!$dirisindatabase) {
190 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
196 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
197 $relativepathtosearchparent = $relativepathmissing;
199 if (preg_match(
'/\//', $relativepathtosearchparent)) {
201 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
202 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
205 $parentdirisindatabase = 0;
206 foreach ($sqltree as $dirsqldesc) {
207 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
208 $parentdirisindatabase = $dirsqldesc[
'id'];
212 if ($parentdirisindatabase > 0) {
213 dol_syslog(
"Yes with id ".$parentdirisindatabase);
215 $fk_parent = $parentdirisindatabase;
226 if ($fk_parent >= 0) {
227 $ecmdirtmp->ref =
'NOTUSEDYET';
229 $ecmdirtmp->description =
'';
230 $ecmdirtmp->fk_parent = $fk_parent;
232 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
235 $id = $ecmdirtmp->create($user);
237 $newdirsql = array(
'id' => $id,
238 'id_mere' => $ecmdirtmp->fk_parent,
239 'label' => $ecmdirtmp->label,
240 'description' => $ecmdirtmp->description,
241 'fullrelativename' => $relativepathmissing);
242 $sqltree[] = $newdirsql;
246 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
249 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
257 foreach ($sqltree as $dirdesc) {
258 $dirtotest = $conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
260 $ecmdirtmp->id = $dirdesc[
'id'];
261 $ecmdirtmp->delete($user,
'databaseonly');
266 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
272 if ($adirwascreated) {
285$maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
291$morejs = array(
'includes/jquery/plugins/blockUI/jquery.blockUI.js',
'core/js/blockUI.js');
293 $morejs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
296$moreheadjs .=
'<script type="text/javascript">'.
"\n";
297$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
298$moreheadjs .= '</script>
'."\n";
300llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', 0, 0, $morejs, '', 0, 0);
302$head = ecm_prepare_dasboard_head(null);
303print dol_get_fiche_head($head, 'index_medias
', '', -1, '');
306// Add filemanager component
309 $url = DOL_URL_ROOT.'/ecm/index_medias.php
'; // Must be an url without param
311include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php
';
314print 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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.