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.
'/core/lib/files.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
46$langs->loadLangs(array(
'ecm',
'companies',
'other',
'users',
'orders',
'propal',
'bills',
'contracts',
'categories'));
48$action =
GETPOST(
'action',
'aZ09');
49$cancel =
GETPOST(
'cancel',
'alpha');
50$backtopage =
GETPOST(
'backtopage',
'alpha');
51$module =
GETPOST(
'module',
'aZ09arobase');
57if ($user->socid > 0) {
59 $socid = $user->socid;
63$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
64$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
66if (empty($page) || $page == -1) {
69$offset = $limit * $page;
79$section =
GETPOST(
"section",
'alpha');
92$result = $ecmdir->fetch(
GETPOSTINT(
"section"));
97$relativepath = $ecmdir->getRelativePath();
98$upload_dir =
$conf->ecm->dir_output.
'/'.$relativepath;
100$fullpath =
$conf->ecm->dir_output.
'/'.$relativepath.$urlfile;
102$relativetodocument =
'ecm/'.$relativepath;
103$filepath = $relativepath.$urlfile;
104$filepathtodocument = $relativetodocument.$urlfile;
110$extrafields->fetch_name_optionals_label(
$object->table_element);
112$result =
$object->fetch(0,
'', $filepathtodocument);
119$permissiontoread = $user->hasRight(
'ecm',
'read');
120$permissiontoadd = $user->hasRight(
'ecm',
'setup');
121$permissiontoupload = $user->hasRight(
'ecm',
'upload');
123if (!$permissiontoread) {
135 header(
"Location: ".$backtopage);
138 $paramscancel = array(
'urlfile' => $urlfile,
'section' => $section);
140 $paramscancel[
'module'] = $module;
142 header(
'Location: '.
dolBuildUrl($_SERVER[
"PHP_SELF"], $paramscancel));
148if ($action ==
'update' && $permissiontoadd) {
151 $oldlabel =
GETPOST(
'urlfile',
'alpha');
153 $shareenabled =
GETPOST(
'shareenabled',
'alpha');
157 $olddir = $ecmdir->getRelativePath(0);
158 $olddirrelativetodocument =
'ecm/'.$olddir;
159 $newdirrelativetodocument =
'ecm/'.$olddir;
160 $olddir =
$conf->ecm->dir_output.
'/'.$olddir;
163 $oldfile = $olddir.$oldlabel;
164 $newfile = $newdir.$newlabel;
165 $newfileformove = $newfile;
167 if (preg_match(
'/\.noexe$/', $oldfile) && !preg_match(
'/\.noexe$/', $newfileformove)) {
168 $newfileformove .=
'.noexe';
175 if ($newlabel != $oldlabel) {
176 $result =
dol_move($oldfile, $newfileformove);
178 $langs->load(
'errors');
179 setEventMessages($langs->trans(
'ErrorFailToRenameFile', $oldfile, $newfile),
null,
'errors');
184 $result =
$object->fetch(0,
'', $newdirrelativetodocument.$newlabel);
193 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
200 $ret = $extrafields->setOptionalsFromPost(
null, $object);
206 $result =
$object->insertExtraFields();
213 $result =
$object->update($user);
220 $object->filepath = preg_replace(
'/[\\/]+$/',
'', $newdirrelativetodocument);
224 $object->gen_or_uploaded =
'unknown';
227 $result =
$object->create($user);
237 $urlfile = $newlabel;
239 if (preg_match(
'/\.noexe$/', $newfileformove)) {
240 $urlfile .=
'.noexe';
243 header(
'Location: '.
dolBuildUrl($_SERVER[
"PHP_SELF"], array(
'urlfile' => $urlfile,
'section' => $section)));
258llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-ecm page-file_card');
260$object->section_id = $ecmdir->id;
264if ($action ==
'edit') {
265 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
266 print
'<input type="hidden" name="token" value="'.newToken().
'">';
267 print
'<input type="hidden" name="section" value="'.$section.
'">';
268 print
'<input type="hidden" name="urlfile" value="'.$urlfile.
'">';
269 print
'<input type="hidden" name="module" value="'.$module.
'">';
270 print
'<input type="hidden" name="action" value="update">';
271 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
279$tmpecmdir->fetch($ecmdir->id);
282while ($tmpecmdir && $result > 0) {
283 $tmpecmdir->ref = $tmpecmdir->label;
284 $s = $tmpecmdir->getNomUrl(1).$s;
285 if ($tmpecmdir->fk_parent) {
287 $result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
294$urlfiletoshow = preg_replace(
'/\.noexe$/',
'', $urlfile);
296$s =
img_picto(
'',
'object_dir').
' <a href="'.DOL_URL_ROOT.
'/ecm/index.php">'.$langs->trans(
"ECMRoot").
'</a> -> '.$s.
' -> ';
297if ($action ==
'edit') {
298 $s .=
'<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfiletoshow.
'">';
300 $s .= $urlfiletoshow;
305 $linkback =
'<a href="'.$backtopage.
'">'.$langs->trans(
"BackToTree").
'</a>';
309dol_banner_tab($object,
'', $linkback, 0,
'',
'', $s);
311print
'<div class="fichecenter">';
313print
'<div class="underbanner clearboth"></div>';
314print
'<table class="border centpercent tableforfield">';
315print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ECMCreationDate").
'</td><td>';
330print
'<tr><td>'.$langs->trans(
"HashOfFileContent").
'</td><td>';
332$object->fetch(0,
'', $filepathtodocument);
336 print
img_warning().
' '.$langs->trans(
"FileNotYetIndexedInDatabase");
342$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
347print $form->textwithpicto($langs->trans(
"DirectDownloadInternalLink"), $langs->trans(
"PrivateDownloadLinkDesc"));
350$paramsrellink = array(
'modulepart' => $modulepart,
'attachment' => 1);
352 $paramsrellink[
'entity'] =
$object->entity;
354$paramsrellink[
'file'] = $filepath;
355$rellink =
dolBuildUrl(
'/document.php', $paramsrellink);
356$fulllink = $urlwithroot.$rellink;
358if ($action !=
'edit') {
359 print
'<input type="text" class="maxquatrevingtpercent widthcentpercentminusxx small" id="downloadinternallink" name="downloadinternellink" value="'.dol_escape_htmltag($fulllink).
'">';
363if ($action !=
'edit') {
364 print
' <a href="'.$fulllink.
'">'.
img_picto($langs->trans(
"Download"),
'download',
'class="opacitymedium paddingrightonly"').
'</a>';
370if ($action !=
'edit') {
371 print $form->textwithpicto($langs->trans(
"DirectDownloadLink"), $langs->trans(
"PublicDownloadLinkDesc"));
373 print $form->textwithpicto($langs->trans(
"FileSharedViaALink"), $langs->trans(
"PublicDownloadLinkDesc"));
377 if ($action !=
'edit') {
378 $fulllink = $urlwithroot.
'/document.php?hashp='.
$object->share;
383 if ($action !=
'edit') {
384 print
'<input type="text" class="maxquatrevingtpercent widthcentpercentminusxx nopadding small downloadexternallink" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).
'" spellcheck="false">';
388 if ($action !=
'edit') {
389 print
' <a href="'.$fulllink.
'">'.
img_picto($langs->trans(
"Download"),
'download',
'class="opacitymedium paddingrightonly"').
'</a>';
392 print
'<input type="checkbox" name="shareenabled" checked="checked" /> ';
395 if ($action !=
'edit') {
396 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotShared").
'</span>';
398 print
'<input type="checkbox" name="shareenabled" /> ';
403print
$object->showOptionals($extrafields, ($action ==
'edit' ?
'edit' :
'view'));
412if ($action ==
'edit') {
413 print $form->buttonsSaveCancel();
420if ($action ==
'deletefile') {
421 print $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], array(
'section' => $section)), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile', $urlfile),
'confirm_deletefile',
'', 1, 1);
424if ($action !=
'edit') {
426 print
'<div class="tabsAction">';
428 if ($user->hasRight(
'ecm',
'setup')) {
429 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.
Class to manage ECM directories.
Class to manage ECM files.
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_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).
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
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.