26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
43$langs->loadLangs(array(
'ecm',
'companies',
'other',
'users',
'orders',
'propal',
'bills',
'contracts',
'categories'));
45$action =
GETPOST(
'action',
'aZ09');
46$cancel =
GETPOST(
'cancel',
'alpha');
47$backtopage =
GETPOST(
'backtopage',
'alpha');
53if ($user->socid > 0) {
55 $socid = $user->socid;
59$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
60$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
62if (empty($page) || $page == -1) {
65$offset = $limit * $page;
75$section =
GETPOST(
"section",
'alpha');
88$result = $ecmdir->fetch(
GETPOST(
"section",
'alpha'));
93$relativepath = $ecmdir->getRelativePath();
94$upload_dir =
$conf->ecm->dir_output.
'/'.$relativepath;
96$fullpath =
$conf->ecm->dir_output.
'/'.$relativepath.$urlfile;
98$relativetodocument =
'ecm/'.$relativepath;
99$filepath = $relativepath.$urlfile;
100$filepathtodocument = $relativetodocument.$urlfile;
106$extrafields->fetch_name_optionals_label(
$object->table_element);
108$result =
$object->fetch(0,
'', $filepathtodocument);
115$permissiontoread = $user->hasRight(
'ecm',
'read');
116$permissiontoadd = $user->hasRight(
'ecm',
'setup');
117$permissiontoupload = $user->hasRight(
'ecm',
'upload');
119if (!$permissiontoread) {
131 header(
"Location: ".$backtopage);
134 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?urlfile='.urlencode($urlfile).
'§ion='.urlencode($section).($module ?
'&module='.urlencode($module) :
''));
140if ($action ==
'update' && $permissiontoadd) {
143 $oldlabel =
GETPOST(
'urlfile',
'alpha');
145 $shareenabled =
GETPOST(
'shareenabled',
'alpha');
149 $olddir = $ecmdir->getRelativePath(0);
150 $olddirrelativetodocument =
'ecm/'.$olddir;
151 $newdirrelativetodocument =
'ecm/'.$olddir;
152 $olddir =
$conf->ecm->dir_output.
'/'.$olddir;
155 $oldfile = $olddir.$oldlabel;
156 $newfile = $newdir.$newlabel;
157 $newfileformove = $newfile;
159 if (preg_match(
'/\.noexe$/', $oldfile) && !preg_match(
'/\.noexe$/', $newfileformove)) {
160 $newfileformove .=
'.noexe';
167 if ($newlabel != $oldlabel) {
168 $result =
dol_move($oldfile, $newfileformove);
170 $langs->load(
'errors');
171 setEventMessages($langs->trans(
'ErrorFailToRenameFile', $oldfile, $newfile),
null,
'errors');
176 $result =
$object->fetch(0,
'', $newdirrelativetodocument.$newlabel);
185 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
192 $ret = $extrafields->setOptionalsFromPost(
null, $object);
198 $result =
$object->insertExtraFields();
205 $result =
$object->update($user);
212 $object->filepath = preg_replace(
'/[\\/]+$/',
'', $newdirrelativetodocument);
216 $object->gen_or_uploaded =
'unknown';
219 $result =
$object->create($user);
229 $urlfile = $newlabel;
231 if (preg_match(
'/\.noexe$/', $newfileformove)) {
232 $urlfile .=
'.noexe';
235 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?urlfile='.urlencode($urlfile).
'§ion='.urlencode($section));
248$form =
new Form($db);
250llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-ecm page-file_card');
252$object->section_id = $ecmdir->id;
256if ($action ==
'edit') {
257 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
258 print
'<input type="hidden" name="token" value="'.newToken().
'">';
259 print
'<input type="hidden" name="section" value="'.$section.
'">';
260 print
'<input type="hidden" name="urlfile" value="'.$urlfile.
'">';
261 print
'<input type="hidden" name="module" value="'.$module.
'">';
262 print
'<input type="hidden" name="action" value="update">';
263 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
271$tmpecmdir->fetch($ecmdir->id);
274while ($tmpecmdir && $result > 0) {
275 $tmpecmdir->ref = $tmpecmdir->label;
276 $s = $tmpecmdir->getNomUrl(1).$s;
277 if ($tmpecmdir->fk_parent) {
279 $result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
286$urlfiletoshow = preg_replace(
'/\.noexe$/',
'', $urlfile);
288$s =
img_picto(
'',
'object_dir').
' <a href="'.DOL_URL_ROOT.
'/ecm/index.php">'.$langs->trans(
"ECMRoot").
'</a> -> '.$s.
' -> ';
289if ($action ==
'edit') {
290 $s .=
'<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfiletoshow.
'">';
292 $s .= $urlfiletoshow;
297 $linkback =
'<a href="'.$backtopage.
'">'.$langs->trans(
"BackToTree").
'</a>';
301dol_banner_tab($object,
'', $linkback, 0,
'',
'', $s);
303print
'<div class="fichecenter">';
305print
'<div class="underbanner clearboth"></div>';
306print
'<table class="border centpercent tableforfield">';
307print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ECMCreationDate").
'</td><td>';
322print
'<tr><td>'.$langs->trans(
"HashOfFileContent").
'</td><td>';
324$object->fetch(0,
'', $filepathtodocument);
328 print
img_warning().
' '.$langs->trans(
"FileNotYetIndexedInDatabase");
333$urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
334$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
339print $form->textwithpicto($langs->trans(
"DirectDownloadInternalLink"), $langs->trans(
"PrivateDownloadLinkDesc"));
343$rellink =
'/document.php?modulepart='.$modulepart;
345 $rellink .=
'&attachment=1';
348 $rellink .=
'&entity='.$object->entity;
350$rellink .=
'&file='.urlencode($filepath);
351$fulllink = $urlwithroot.$rellink;
353if ($action !=
'edit') {
354 print
'<input type="text" class="maxquatrevingtpercent widthcentpercentminusxx" id="downloadinternallink" name="downloadinternellink" value="'.dol_escape_htmltag($fulllink).
'">';
358if ($action !=
'edit') {
359 print
' <a href="'.$fulllink.
'">'.
img_picto($langs->trans(
"Download"),
'download',
'class="opacitymedium paddingrightonly"').
'</a>';
365if ($action !=
'edit') {
366 print $form->textwithpicto($langs->trans(
"DirectDownloadLink"), $langs->trans(
"PublicDownloadLinkDesc"));
368 print $form->textwithpicto($langs->trans(
"FileSharedViaALink"), $langs->trans(
"PublicDownloadLinkDesc"));
372 if ($action !=
'edit') {
377 $paramlink .= ($paramlink ?
'&' :
'').
'hashp='.
$object->share;
379 if ($forcedownload) {
380 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
383 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
388 if ($action !=
'edit') {
389 print
'<input type="text" class="quatrevingtpercent nopadding small" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).
'">';
393 if ($action !=
'edit') {
394 print
' <a href="'.$fulllink.
'">'.$langs->trans(
"Download").
'</a>';
397 print
'<input type="checkbox" name="shareenabled"'.($object->share ?
' checked="checked"' :
'').
' /> ';
400 if ($action !=
'edit') {
401 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotShared").
'</span>';
403 print
'<input type="checkbox" name="shareenabled"'.($object->share ?
' checked="checked"' :
'').
' /> ';
408print
$object->showOptionals($extrafields, ($action ==
'edit' ?
'edit' :
'view'));
417if ($action ==
'edit') {
418 print $form->buttonsSaveCancel();
425if ($action ==
'deletefile') {
426 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.urlencode($section), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile', $urlfile),
'confirm_deletefile',
'', 1, 1);
429if ($action !=
'edit') {
431 print
'<div class="tabsAction">';
433 if ($user->hasRight(
'ecm',
'setup')) {
434 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
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())
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_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
Show tabs of a record.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.