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 $socid =
GETPOST(
'socid',
'int');
40 $action =
GETPOST(
'action',
'aZ09');
45 $section_dir =
GETPOST(
'section_dir',
'alpha');
46 $overwritefile =
GETPOST(
'overwritefile',
'int');
48 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
49 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
52 if (empty($page) || $page == -1) {
55 $offset = $limit * $page;
56 $pageprev = $page - 1;
57 $pagenext = $page + 1;
67 $result = $ecmdir->fetch($section);
76 $userstatic =
new User($db);
82 $socid = $user->socid;
96 if (
GETPOST(
"sendit",
'alphanohtml') && !empty($conf->global->MAIN_UPLOAD_DOC)) {
100 $relativepath = $ecmdir->getRelativePath();
102 $relativepath = $section_dir;
104 $upload_dir = $conf->ecm->dir_output.
'/'.$relativepath;
106 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
107 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
109 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
112 foreach ($userfiles as $key => $userfile) {
113 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
115 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
118 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
125 $res =
dol_add_file_process($upload_dir, $overwritefile, 1,
'userfile',
'',
null,
'', $generatethumbs);
127 $result = $ecmdir->changeNbOfFiles(
'+');
133 if ($action ==
'confirm_deletefile') {
134 if (
GETPOST(
'confirm') ==
'yes') {
137 $upload_dir = $conf->ecm->dir_output.($relativepath ?
'/'.$relativepath :
'');
138 $file = $upload_dir.
"/".
GETPOST(
'urlfile',
'alpha');
141 $urlfiletoshow =
GETPOST(
'urlfile',
'alpha');
142 $urlfiletoshow = preg_replace(
'/\.noexe$/',
'', $urlfiletoshow);
143 setEventMessages($langs->trans(
"FileWasRemoved", $urlfiletoshow),
null,
'mesgs');
144 $result = $ecmdir->changeNbOfFiles(
'-');
151 $action =
'file_manager';
155 if ($action ==
'add' && $user->rights->ecm->setup) {
156 $ecmdir->ref =
'NOTUSEDYET';
157 $ecmdir->label =
GETPOST(
"label");
158 $ecmdir->description =
GETPOST(
"desc");
160 $id = $ecmdir->create($user);
162 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
173 if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
174 $result = $ecmdir->delete($user);
175 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
183 if ($action ==
'refreshmanual') {
189 $diroutputslash = str_replace(
'\\',
'/', $conf->ecm->dir_output);
190 $diroutputslash .=
'/';
193 $disktree =
dol_dir_list($conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'',
'', 0);
196 $sqltree = $ecmdirstatic->get_full_arbo(0);
203 foreach ($disktree as $dirdesc) {
204 $dirisindatabase = 0;
205 foreach ($sqltree as $dirsqldesc) {
206 if ($conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
207 $dirisindatabase = 1;
212 if (!$dirisindatabase) {
213 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
219 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
220 $relativepathtosearchparent = $relativepathmissing;
222 if (preg_match(
'/\//', $relativepathtosearchparent)) {
224 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
225 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
228 $parentdirisindatabase = 0;
229 foreach ($sqltree as $dirsqldesc) {
230 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
231 $parentdirisindatabase = $dirsqldesc[
'id'];
235 if ($parentdirisindatabase > 0) {
236 dol_syslog(
"Yes with id ".$parentdirisindatabase);
238 $fk_parent = $parentdirisindatabase;
249 if ($fk_parent >= 0) {
250 $ecmdirtmp->ref =
'NOTUSEDYET';
252 $ecmdirtmp->description =
'';
253 $ecmdirtmp->fk_parent = $fk_parent;
255 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
258 $id = $ecmdirtmp->create($user);
260 $newdirsql = array(
'id'=>$id,
261 'id_mere'=>$ecmdirtmp->fk_parent,
262 'label'=>$ecmdirtmp->label,
263 'description'=>$ecmdirtmp->description,
264 'fullrelativename'=>$relativepathmissing);
265 $sqltree[] = $newdirsql;
269 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
272 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
280 foreach ($sqltree as $dirdesc) {
281 $dirtotest = $conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
283 $ecmdirtmp->id = $dirdesc[
'id'];
284 $ecmdirtmp->delete($user,
'databaseonly');
289 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
295 if ($adirwascreated) {
308 $maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
314 $morejs = array(
'includes/jquery/plugins/blockUI/jquery.blockUI.js',
'core/js/blockUI.js');
315 if (empty($conf->global->MAIN_ECM_DISABLE_JS)) {
316 $morejs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
319 $moreheadjs .=
'<script type="text/javascript">'.
"\n";
320 $moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
321 $moreheadjs .= '</script>
'."\n";
323 llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0);
325 $head = ecm_prepare_dasboard_head('');
326 print dol_get_fiche_head($head, 'index
', '', -1, '');
329 // Add filemanager component
332 $url = DOL_URL_ROOT.'/ecm/index.php
'; // Must be an url without param
334 include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php
';
337 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_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($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_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null)
Get and save an upload file (for example after submitting a new file a mail form).
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.