30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
46$langs->loadLangs(array(
'ecm',
'companies',
'other',
'users',
'orders',
'propal',
'bills',
'contracts'));
50$action =
GETPOST(
'action',
'aZ09');
55$section_dir =
GETPOST(
'section_dir',
'alpha');
59$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
60$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
62if (empty($page) || $page == -1) {
65$offset = $limit * $page;
77 $result = $ecmdir->fetch($section);
92 $socid = $user->socid;
95$hookmanager->initHooks(array(
'ecmindexcard',
'globalcard'));
99$permissiontoread = $user->hasRight(
'ecm',
'read');
100$permissiontocreate = $user->hasRight(
'ecm',
'upload');
101$permissiontocreatedir = $user->hasRight(
'ecm',
'setup');
102$permissiontodelete = $user->hasRight(
'ecm',
'upload');
103$permissiontodeletedir = $user->hasRight(
'ecm',
'setup');
119 $relativepath = $ecmdir->getRelativePath();
121 $relativepath = $section_dir;
123 $upload_dir =
$conf->ecm->dir_output.
'/'.$relativepath;
126 if (is_array($_FILES[
'userfile'])) {
127 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
128 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
130 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
134 foreach ($userfiles as $key => $userfile) {
135 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
137 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
140 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
147 $res =
dol_add_file_process($upload_dir, $overwritefile, 1,
'userfile',
'',
null,
'', $generatethumbs);
149 $result = $ecmdir->changeNbOfFiles(
'+');
155if ($action ==
'confirm_deletefile' && $permissiontodelete) {
156 if (
GETPOST(
'confirm') ==
'yes') {
159 $upload_dir =
$conf->ecm->dir_output.($relativepath ?
'/'.$relativepath :
'');
160 $file = $upload_dir.
"/".
GETPOST(
'urlfile',
'alpha');
163 $urlfiletoshow =
GETPOST(
'urlfile',
'alpha');
164 $urlfiletoshow = preg_replace(
'/\.noexe$/',
'', $urlfiletoshow);
165 setEventMessages($langs->trans(
"FileWasRemoved", $urlfiletoshow),
null,
'mesgs');
166 $result = $ecmdir->changeNbOfFiles(
'-');
173 $action =
'file_manager';
177if ($action ==
'add' && $permissiontocreatedir) {
178 $ecmdir->ref =
'NOTUSEDYET';
179 $ecmdir->label =
GETPOST(
"label");
180 $ecmdir->description =
GETPOST(
"desc");
182 $id = $ecmdir->create($user);
184 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
195if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontodeletedir) {
196 $result = $ecmdir->delete($user);
197 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
205if ($action ==
'refreshmanual' && $permissiontoread) {
211 $diroutputslash = str_replace(
'\\',
'/',
$conf->ecm->dir_output);
212 $diroutputslash .=
'/';
215 $disktree =
dol_dir_list(
$conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'', 0, 0);
218 $sqltree = $ecmdirstatic->get_full_arbo(0);
225 foreach ($disktree as $dirdesc) {
226 $dirisindatabase = 0;
227 foreach ($sqltree as $dirsqldesc) {
228 if (
$conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
229 $dirisindatabase = 1;
234 if (!$dirisindatabase) {
235 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
241 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
242 $relativepathtosearchparent = $relativepathmissing;
244 if (preg_match(
'/\//', $relativepathtosearchparent)) {
246 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
247 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
250 $parentdirisindatabase = 0;
251 foreach ($sqltree as $dirsqldesc) {
252 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
253 $parentdirisindatabase = $dirsqldesc[
'id'];
257 if ($parentdirisindatabase > 0) {
258 dol_syslog(
"Yes with id ".$parentdirisindatabase);
260 $fk_parent = $parentdirisindatabase;
271 if ($fk_parent >= 0) {
272 $ecmdirtmp->ref =
'NOTUSEDYET';
274 $ecmdirtmp->description =
'';
275 $ecmdirtmp->fk_parent = $fk_parent;
277 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
280 $id = $ecmdirtmp->create($user);
282 $newdirsql = array(
'id' =>
$id,
283 'id_mere' => $ecmdirtmp->fk_parent,
284 'label' => $ecmdirtmp->label,
285 'description' => $ecmdirtmp->description,
286 'fullrelativename' => $relativepathmissing);
287 $sqltree[] = $newdirsql;
291 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
294 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
302 foreach ($sqltree as $dirdesc) {
303 $dirtotest =
$conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
305 $ecmdirtmp->id = $dirdesc[
'id'];
306 $ecmdirtmp->delete($user,
'databaseonly');
311 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
317 if ($adirwascreated) {
330$maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
334 $morejs[] =
"public/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
337llxHeader(
'', $langs->trans(
"ECMArea"),
'',
'', 0, 0, $morejs,
'',
'',
'mod-ecm page-index');
347 $url = DOL_URL_ROOT.
'/ecm/index.php';
349include 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_add_file_process($upload_dir, $allowoverwrite=0, $updatesessionordb=0, $keyforsourcefile='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null, $forceFullTextIndexation='', $mode=0)
Get and save an upload file (for example after submitting a new file in a mail form).
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
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.