27require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/ecm/class/htmlecm.form.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
47$langs->loadLangs(array(
'ecm',
'companies',
'other',
'users',
'orders',
'propal',
'bills',
'contracts',
'categories'));
49$action =
GETPOST(
'action',
'aZ09');
50$cancel =
GETPOST(
'cancel',
'alpha');
51$backtopage =
GETPOST(
'backtopage',
'alpha');
58if ($user->socid > 0) {
60 $socid = $user->socid;
64$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
65$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
67if (empty($page) || $page == -1) {
70$offset = $limit * $page;
80$section =
GETPOST(
"section",
'alpha');
82 dol_print_error(
null,
'Error, section parameter missing');
87 dol_print_error(
null,
"ErrorParamNotDefined");
93$result = $ecmdir->fetch(
GETPOSTINT(
"section"));
95 dol_print_error($db, $ecmdir->error);
98$relativepath = $ecmdir->getRelativePath();
99$upload_dir =
$conf->ecm->dir_output.
'/'.$relativepath;
101$fullpath =
$conf->ecm->dir_output.
'/'.$relativepath.$urlfile;
103$relativetodocument =
'ecm/'.$relativepath;
104$filepath = $relativepath.$urlfile;
105$filepathtodocument = $relativetodocument.$urlfile;
111$extrafields->fetch_name_optionals_label(
$object->table_element);
113$result =
$object->fetch(0,
'', $filepathtodocument);
120$permissiontoread = $user->hasRight(
'ecm',
'read');
121$permissiontoadd = $user->hasRight(
'ecm',
'setup');
122$permissiontoupload = $user->hasRight(
'ecm',
'upload');
124if (!$permissiontoread) {
136 header(
"Location: ".$backtopage);
139 $paramscancel = array(
'urlfile' => $urlfile,
'section' => $section);
141 $paramscancel[
'module'] =
$module;
143 header(
'Location: '.
dolBuildUrl($_SERVER[
"PHP_SELF"], $paramscancel));
149if ($action ==
'update' && $permissiontoadd) {
152 $oldlabel =
GETPOST(
'urlfile',
'alpha');
154 $shareenabled =
GETPOST(
'shareenabled',
'alpha');
157 $newecmdir = $ecmdir;
159 if ($newsection > 0 && $newsection != $ecmdir->id) {
161 $result = $newecmdir->fetch($newsection);
162 if (!($result > 0)) {
163 dol_print_error($db, $newecmdir->error);
170 $olddir = $ecmdir->getRelativePath(0);
171 $newdir = $newecmdir->getRelativePath(0);
172 $olddirrelativetodocument =
'ecm/'.$olddir;
173 $newdirrelativetodocument =
'ecm/'.$newdir;
174 $olddir =
$conf->ecm->dir_output.
'/'.$olddir;
175 $newdir =
$conf->ecm->dir_output.
'/'.$newdir;
177 $oldfile = $olddir.$oldlabel;
178 $newfile = $newdir.$newlabel;
179 $newfileformove = $newfile;
181 if (preg_match(
'/\.noexe$/', $oldfile) && !preg_match(
'/\.noexe$/', $newfileformove)) {
182 $newfileformove .=
'.noexe';
190 if ($newfileformove != $oldfile &&
dol_is_file($newfileformove)) {
192 $langs->load(
'errors');
193 setEventMessages($langs->trans(
'ErrorDestinationAlreadyExists', $newlabel),
null,
'errors');
196 if (!$error && $newdir != $olddir &&
dol_mkdir($newdir) < 0) {
197 $langs->load(
'errors');
198 setEventMessages($langs->trans(
'ErrorFailToCreateDir', $newdir),
null,
'errors');
201 if (!$error && $newfileformove != $oldfile) {
202 $result =
dol_move($oldfile, $newfileformove);
204 $langs->load(
'errors');
205 setEventMessages($langs->trans(
'ErrorFailToRenameFile', $oldfile, $newfile),
null,
'errors');
210 if (!$error && $newecmdir->id != $ecmdir->id) {
211 $ecmdir->changeNbOfFiles(
'-');
212 $newecmdir->changeNbOfFiles(
'+');
216 $result =
$object->fetch(0,
'', $newdirrelativetodocument.basename($newfileformove));
227 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
235 $ret = $extrafields->setOptionalsFromPost(
null, $object);
241 $result =
$object->insertExtraFields();
248 $result =
$object->update($user);
255 $object->filepath = preg_replace(
'/[\\/]+$/',
'', $newdirrelativetodocument);
259 $object->gen_or_uploaded =
'unknown';
262 $result =
$object->create($user);
272 $urlfile = $newlabel;
274 if (preg_match(
'/\.noexe$/', $newfileformove)) {
275 $urlfile .=
'.noexe';
278 header(
'Location: '.
dolBuildUrl($_SERVER[
"PHP_SELF"], array(
'urlfile' => $urlfile,
'section' => $newecmdir->id)));
291$form =
new Form($db);
293llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-ecm page-file_card');
295$object->section_id = $ecmdir->id;
299if ($action ==
'edit') {
300 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
301 print
'<input type="hidden" name="token" value="'.newToken().
'">';
302 print
'<input type="hidden" name="section" value="'.$section.
'">';
303 print
'<input type="hidden" name="urlfile" value="'.$urlfile.
'">';
304 print
'<input type="hidden" name="module" value="'.$module.
'">';
305 print
'<input type="hidden" name="action" value="update">';
306 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
314$tmpecmdir->fetch($ecmdir->id);
317while ($tmpecmdir && $result > 0) {
318 $tmpecmdir->ref = $tmpecmdir->label;
319 $s = $tmpecmdir->getNomUrl(1).$s;
320 if ($tmpecmdir->fk_parent) {
322 $result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
329$urlfiletoshow = preg_replace(
'/\.noexe$/',
'', $urlfile);
331$s = img_picto(
'',
'object_dir').
' <a href="'.DOL_URL_ROOT.
'/ecm/index.php">'.$langs->trans(
"ECMRoot").
'</a> -> '.$s.
' -> ';
332if ($action ==
'edit') {
333 $s .=
'<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfiletoshow.
'">';
335 $s .= $urlfiletoshow;
340 $linkback =
'<a href="'.$backtopage.
'">'.$langs->trans(
"BackToTree").
'</a>';
344dol_banner_tab($object,
'', $linkback, 0,
'',
'', $s);
346print
'<div class="fichecenter">';
348print
'<div class="underbanner clearboth"></div>';
349print
'<table class="border centpercent tableforfield">';
350print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ECMCreationDate").
'</td><td>';
355if ($action ==
'edit') {
357 print
'<tr><td>'.$langs->trans(
"ECMSection").
'</td><td>';
358 print img_picto(
'',
'object_dir',
'class="pictofixedwidth"').$formecm->selectAllSections($ecmdir->id,
'newsection',
'ecm');
373print
'<tr><td>'.$langs->trans(
"HashOfFileContent").
'</td><td>';
375$object->fetch(0,
'', $filepathtodocument);
379 print img_warning().
' '.$langs->trans(
"FileNotYetIndexedInDatabase");
385$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
390print $form->textwithpicto($langs->trans(
"DirectDownloadInternalLink"), $langs->trans(
"PrivateDownloadLinkDesc"));
393$paramsrellink = array(
'modulepart' => $modulepart,
'attachment' => 1);
395 $paramsrellink[
'entity'] =
$object->entity;
397$paramsrellink[
'file'] = $filepath;
398$rellink =
dolBuildUrl(
'/document.php', $paramsrellink);
399$fulllink = $urlwithroot.$rellink;
400print img_picto(
'',
'globe').
' ';
401if ($action !=
'edit') {
402 print
'<input type="text" class="maxquatrevingtpercent widthcentpercentminusxx small" id="downloadinternallink" name="downloadinternellink" value="'.dol_escape_htmltag($fulllink).
'">';
406if ($action !=
'edit') {
407 print
' <a href="'.$fulllink.
'">'.img_picto($langs->trans(
"Download"),
'download',
'class="opacitymedium paddingrightonly"').
'</a>';
413if ($action !=
'edit') {
414 print $form->textwithpicto($langs->trans(
"DirectDownloadLink"), $langs->trans(
"PublicDownloadLinkDesc"));
416 print $form->textwithpicto($langs->trans(
"FileSharedViaALink"), $langs->trans(
"PublicDownloadLinkDesc"));
420 if ($action !=
'edit') {
421 $fulllink = $urlwithroot.
'/document.php?hashp='.
$object->share;
425 print img_picto(
'',
'globe').
' ';
426 if ($action !=
'edit') {
427 print
'<input type="text" class="maxquatrevingtpercent widthcentpercentminusxx nopadding small downloadexternallink" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).
'" spellcheck="false">';
431 if ($action !=
'edit') {
432 print
' <a href="'.$fulllink.
'">'.img_picto($langs->trans(
"Download"),
'download',
'class="opacitymedium paddingrightonly"').
'</a>';
435 print
'<input type="checkbox" name="shareenabled" checked="checked" /> ';
438 if ($action !=
'edit') {
439 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotShared").
'</span>';
441 print
'<input type="checkbox" name="shareenabled" /> ';
446print
$object->showOptionals($extrafields, ($action ==
'edit' ?
'edit' :
'view'));
455if ($action ==
'edit') {
456 print $form->buttonsSaveCancel();
463if ($action ==
'deletefile') {
464 print $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], array(
'section' => $section)), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile', $urlfile),
'confirm_deletefile',
'', 1, 1);
467if ($action !=
'edit') {
469 print
'<div class="tabsAction">';
471 if ($user->hasRight(
'ecm',
'setup')) {
472 print
'<a class="butAction" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], array(
'action' =>
'edit',
'section' => $section,
'urlfile' => $urlfile)).
'">'.$langs->trans(
'Edit').
'</a>';
if(! $sortfield) if(! $sortorder) $object
global $dolibarr_main_url_root
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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage ECM directories.
Class to manage ECM files.
if(! $sortfield) if(! $sortorder) $module
ecm_file_prepare_head($object)
Prepare array with list of tabs.
dol_move($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=1, $moreinfo=array(), $entity=null)
Move a file into another name.
dol_filemtime($pathoffile)
Return time of a file.
dol_is_file($pathoffile)
Return if path is a file.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_sanitizePathName($str, $newstr='_', $unaccent=0, $allowdash=0)
Clean a string to use it as a path name.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
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.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.