27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
33require_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');
56if ($user->socid > 0) {
58 $socid = $user->socid;
62$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
63$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
65if (empty($page) || $page == -1) {
68$offset = $limit * $page;
78$section =
GETPOST(
"section",
'alpha');
91$result = $ecmdir->fetch(
GETPOSTINT(
"section"));
96$relativepath = $ecmdir->getRelativePath();
97$upload_dir =
$conf->ecm->dir_output.
'/'.$relativepath;
99$fullpath =
$conf->ecm->dir_output.
'/'.$relativepath.$urlfile;
101$relativetodocument =
'ecm/'.$relativepath;
102$filepath = $relativepath.$urlfile;
103$filepathtodocument = $relativetodocument.$urlfile;
109$extrafields->fetch_name_optionals_label(
$object->table_element);
111$result =
$object->fetch(0,
'', $filepathtodocument);
118$permissiontoread = $user->hasRight(
'ecm',
'read');
119$permissiontoadd = $user->hasRight(
'ecm',
'setup');
120$permissiontoupload = $user->hasRight(
'ecm',
'upload');
122if (!$permissiontoread) {
134 header(
"Location: ".$backtopage);
137 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?urlfile='.urlencode($urlfile).
'§ion='.urlencode($section).($module ?
'&module='.urlencode($module) :
''));
143if ($action ==
'update' && $permissiontoadd) {
146 $oldlabel =
GETPOST(
'urlfile',
'alpha');
148 $shareenabled =
GETPOST(
'shareenabled',
'alpha');
152 $olddir = $ecmdir->getRelativePath(0);
153 $olddirrelativetodocument =
'ecm/'.$olddir;
154 $newdirrelativetodocument =
'ecm/'.$olddir;
155 $olddir =
$conf->ecm->dir_output.
'/'.$olddir;
158 $oldfile = $olddir.$oldlabel;
159 $newfile = $newdir.$newlabel;
160 $newfileformove = $newfile;
162 if (preg_match(
'/\.noexe$/', $oldfile) && !preg_match(
'/\.noexe$/', $newfileformove)) {
163 $newfileformove .=
'.noexe';
170 if ($newlabel != $oldlabel) {
171 $result =
dol_move($oldfile, $newfileformove);
173 $langs->load(
'errors');
174 setEventMessages($langs->trans(
'ErrorFailToRenameFile', $oldfile, $newfile),
null,
'errors');
179 $result =
$object->fetch(0,
'', $newdirrelativetodocument.$newlabel);
188 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
195 $ret = $extrafields->setOptionalsFromPost(
null, $object);
201 $result =
$object->insertExtraFields();
208 $result =
$object->update($user);
215 $object->filepath = preg_replace(
'/[\\/]+$/',
'', $newdirrelativetodocument);
219 $object->gen_or_uploaded =
'unknown';
222 $result =
$object->create($user);
232 $urlfile = $newlabel;
234 if (preg_match(
'/\.noexe$/', $newfileformove)) {
235 $urlfile .=
'.noexe';
238 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?urlfile='.urlencode($urlfile).
'§ion='.urlencode($section));
251$form =
new Form($db);
253llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-ecm page-file_card');
255$object->section_id = $ecmdir->id;
259if ($action ==
'edit') {
260 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
261 print
'<input type="hidden" name="token" value="'.newToken().
'">';
262 print
'<input type="hidden" name="section" value="'.$section.
'">';
263 print
'<input type="hidden" name="urlfile" value="'.$urlfile.
'">';
264 print
'<input type="hidden" name="module" value="'.$module.
'">';
265 print
'<input type="hidden" name="action" value="update">';
266 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
274$tmpecmdir->fetch($ecmdir->id);
277while ($tmpecmdir && $result > 0) {
278 $tmpecmdir->ref = $tmpecmdir->label;
279 $s = $tmpecmdir->getNomUrl(1).$s;
280 if ($tmpecmdir->fk_parent) {
282 $result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
289$urlfiletoshow = preg_replace(
'/\.noexe$/',
'', $urlfile);
291$s =
img_picto(
'',
'object_dir').
' <a href="'.DOL_URL_ROOT.
'/ecm/index.php">'.$langs->trans(
"ECMRoot").
'</a> -> '.$s.
' -> ';
292if ($action ==
'edit') {
293 $s .=
'<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfiletoshow.
'">';
295 $s .= $urlfiletoshow;
300 $linkback =
'<a href="'.$backtopage.
'">'.$langs->trans(
"BackToTree").
'</a>';
304dol_banner_tab($object,
'', $linkback, 0,
'',
'', $s);
306print
'<div class="fichecenter">';
308print
'<div class="underbanner clearboth"></div>';
309print
'<table class="border centpercent tableforfield">';
310print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ECMCreationDate").
'</td><td>';
325print
'<tr><td>'.$langs->trans(
"HashOfFileContent").
'</td><td>';
327$object->fetch(0,
'', $filepathtodocument);
331 print
img_warning().
' '.$langs->trans(
"FileNotYetIndexedInDatabase");
337$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
342print $form->textwithpicto($langs->trans(
"DirectDownloadInternalLink"), $langs->trans(
"PrivateDownloadLinkDesc"));
346$rellink =
'/document.php?modulepart='.$modulepart;
348 $rellink .=
'&attachment=1';
351 $rellink .=
'&entity='.$object->entity;
353$rellink .=
'&file='.urlencode($filepath);
354$fulllink = $urlwithroot.$rellink;
356if ($action !=
'edit') {
357 print
'<input type="text" class="maxquatrevingtpercent widthcentpercentminusxx small" id="downloadinternallink" name="downloadinternellink" value="'.dol_escape_htmltag($fulllink).
'">';
361if ($action !=
'edit') {
362 print
' <a href="'.$fulllink.
'">'.
img_picto($langs->trans(
"Download"),
'download',
'class="opacitymedium paddingrightonly"').
'</a>';
368if ($action !=
'edit') {
369 print $form->textwithpicto($langs->trans(
"DirectDownloadLink"), $langs->trans(
"PublicDownloadLinkDesc"));
371 print $form->textwithpicto($langs->trans(
"FileSharedViaALink"), $langs->trans(
"PublicDownloadLinkDesc"));
375 if ($action !=
'edit') {
380 $paramlink .= ($paramlink ?
'&' :
'').
'hashp='.
$object->share;
382 if ($forcedownload) {
383 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
386 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
391 if ($action !=
'edit') {
392 print
'<input type="text" class="maxquatrevingtpercent widthcentpercentminusxx nopadding small" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).
'">';
396 if ($action !=
'edit') {
397 print
' <a href="'.$fulllink.
'">'.
img_picto($langs->trans(
"Download"),
'download',
'class="opacitymedium paddingrightonly"').
'</a>';
400 print
'<input type="checkbox" name="shareenabled"'.($object->share ?
' checked="checked"' :
'').
' /> ';
403 if ($action !=
'edit') {
404 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotShared").
'</span>';
406 print
'<input type="checkbox" name="shareenabled"'.($object->share ?
' checked="checked"' :
'').
' /> ';
411print
$object->showOptionals($extrafields, ($action ==
'edit' ?
'edit' :
'view'));
420if ($action ==
'edit') {
421 print $form->buttonsSaveCancel();
428if ($action ==
'deletefile') {
429 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.urlencode($section), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile', $urlfile),
'confirm_deletefile',
'', 1, 1);
432if ($action !=
'edit') {
434 print
'<div class="tabsAction">';
436 if ($user->hasRight(
'ecm',
'setup')) {
437 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit§ion='.urlencode($section).
'&urlfile='.urlencode($urlfile).
'">'.$langs->trans(
'Edit').
'</a>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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_filemtime($pathoffile)
Return time of a file.
dol_move($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=1, $moreinfo=array(), $entity=0)
Move a file into another name.
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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
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_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
dol_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.