24 require
'../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
26 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
33 $langs->loadLangs(array(
'ecm',
'companies',
'other',
'users',
'orders',
'propal',
'bills',
'contracts',
'categories'));
35 $action =
GETPOST(
'action',
'aZ09');
36 $cancel =
GETPOST(
'cancel',
'alpha');
37 $backtopage =
GETPOST(
'backtopage',
'alpha');
42 $socid =
GETPOST(
"socid",
"int");
48 $socid = $user->socid;
51 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
52 $sortfield =
GETPOST(
"sortfield",
'alpha');
53 $sortorder =
GETPOST(
"sortorder",
'alpha');
55 if (empty($page) || $page == -1) { $page = 0; }
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
59 if (!$sortorder) $sortorder =
"ASC";
60 if (!$sortfield) $sortfield =
"label";
62 $section =
GETPOST(
"section",
'alpha');
77 $result = $ecmdir->fetch(
GETPOST(
"section",
'alpha'));
83 $relativepath = $ecmdir->getRelativePath();
84 $upload_dir = $conf->ecm->dir_output.
'/'.$relativepath;
86 $fullpath = $conf->ecm->dir_output.
'/'.$relativepath.$urlfile;
88 $file =
new stdClass();
89 $file->section_id = $ecmdir->id;
90 $file->label = $urlfile;
92 $relativetodocument =
'ecm/'.$relativepath;
93 $filepath = $relativepath.$file->label;
94 $filepathtodocument = $relativetodocument.$file->label;
97 $object =
new ECMFiles($db);
100 $extrafields->fetch_name_optionals_label($object->table_element);
102 $result = $object->fetch(0,
'', $filepathtodocument);
120 header(
"Location: ".$backtopage);
123 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?urlfile='.urlencode($urlfile).
'§ion='.urlencode($section).($module ?
'&module='.urlencode($module) :
''));
129 if ($action ==
'update')
133 $oldlabel =
GETPOST(
'urlfile',
'alpha');
135 $shareenabled =
GETPOST(
'shareenabled',
'alpha');
139 $olddir = $ecmdir->getRelativePath(0);
140 $olddirrelativetodocument =
'ecm/'.$olddir;
141 $newdirrelativetodocument =
'ecm/'.$olddir;
142 $olddir = $conf->ecm->dir_output.
'/'.$olddir;
145 $oldfile = $olddir.$oldlabel;
146 $newfile = $newdir.$newlabel;
147 $newfileformove = $newfile;
149 if (preg_match(
'/\.noexe$/', $oldfile) && !preg_match(
'/\.noexe$/', $newfileformove)) {
150 $newfileformove .=
'.noexe';
157 if ($newlabel != $oldlabel)
159 $result =
dol_move($oldfile, $newfileformove);
162 $langs->load(
'errors');
163 setEventMessages($langs->trans(
'ErrorFailToRenameFile', $oldfile, $newfile), null,
'errors');
168 $result = $object->fetch(0,
'', $newdirrelativetodocument.$newlabel);
180 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
188 $ret = $extrafields->setOptionalsFromPost(null, $object);
189 if ($ret < 0) $error++;
192 $result = $object->insertExtraFields();
199 $result = $object->update($user);
206 $object->entity = $conf->entity;
207 $object->filepath = preg_replace(
'/[\\/]+$/',
'', $newdirrelativetodocument);
208 $object->filename = $newlabel;
209 $object->label = md5_file(
dol_osencode($newfileformove));
210 $object->fullpath_orig =
'';
211 $object->gen_or_uploaded =
'unknown';
212 $object->description =
'';
213 $object->keyword =
'';
214 $result = $object->create($user);
226 $urlfile = $newlabel;
228 if (preg_match(
'/\.noexe$/', $newfileformove)) {
229 $urlfile .=
'.noexe';
232 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?urlfile='.urlencode($urlfile).
'§ion='.urlencode($section));
245 $form =
new Form($db);
251 if ($action ==
'edit')
253 print '<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
254 print '<input type="hidden" name="token" value="'.newToken().
'">';
255 print '<input type="hidden" name="section" value="'.$section.
'">';
256 print '<input type="hidden" name="urlfile" value="'.$urlfile.
'">';
257 print '<input type="hidden" name="module" value="'.$module.
'">';
258 print '<input type="hidden" name="action" value="update">';
259 print '<input type="hidden" name="id" value="'.$object->id.
'">';
267 $tmpecmdir->fetch($ecmdir->id);
270 while ($tmpecmdir && $result > 0)
272 $tmpecmdir->ref = $tmpecmdir->label;
273 $s = $tmpecmdir->getNomUrl(1).$s;
274 if ($tmpecmdir->fk_parent)
277 $result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
284 $urlfiletoshow = preg_replace(
'/\.noexe$/',
'', $urlfile);
286 $s =
img_picto(
'',
'object_dir').
' <a href="'.DOL_URL_ROOT.
'/ecm/index.php">'.$langs->trans(
"ECMRoot").
'</a> -> '.$s.
' -> ';
287 if ($action ==
'edit') $s .=
'<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfiletoshow.
'">';
288 else $s .= $urlfiletoshow;
292 $linkback =
'<a href="'.$backtopage.
'">'.$langs->trans(
"BackToTree").
'</a>';
298 print '<div class="fichecenter">';
300 print '<div class="underbanner clearboth"></div>';
301 print '<table class="border centpercent tableforfield">';
302 print '<tr><td class="titlefield">'.$langs->trans(
"ECMCreationDate").
'</td><td>';
317 print '<tr><td>'.$langs->trans(
"HashOfFileContent").
'</td><td>';
319 $object->fetch(0,
'', $filepathtodocument);
320 if (!empty($object->label))
322 print $object->label;
329 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
330 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
334 print '<tr><td>'.$langs->trans(
"DirectDownloadInternalLink").
'</td><td>';
337 $rellink =
'/document.php?modulepart='.$modulepart;
338 if ($forcedownload) $rellink .=
'&attachment=1';
339 if (!empty($object->entity)) $rellink .=
'&entity='.$object->entity;
340 $rellink .=
'&file='.urlencode($filepath);
341 $fulllink = $urlwithroot.$rellink;
343 if ($action !=
'edit')
print '<input type="text" class="quatrevingtpercent" id="downloadinternallink" name="downloadinternellink" value="'.dol_escape_htmltag($fulllink).
'">';
344 else print $fulllink;
345 if ($action !=
'edit')
print ' <a href="'.$fulllink.
'">'.$langs->trans(
"Download").
'</a>';
350 if ($action !=
'edit')
print $langs->trans(
"DirectDownloadLink");
351 else print $langs->trans(
"FileSharedViaALink");
353 if (!empty($object->share))
355 if ($action !=
'edit')
360 if (!empty($object->share)) $paramlink .= ($paramlink ?
'&' :
'').
'hashp='.$object->share;
361 if ($forcedownload) $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
363 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
368 if ($action !=
'edit')
print '<input type="text" class="quatrevingtpercent" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).
'">';
369 else print $fulllink;
370 if ($action !=
'edit')
print ' <a href="'.$fulllink.
'">'.$langs->trans(
"Download").
'</a>';
372 print '<input type="checkbox" name="shareenabled"'.($object->share ?
' checked="checked"' :
'').
' /> ';
375 if ($action !=
'edit')
377 print '<span class="opacitymedium">'.$langs->trans(
"FileNotShared").
'</span>';
379 print '<input type="checkbox" name="shareenabled"'.($object->share ?
' checked="checked"' :
'').
' /> ';
384 print $object->showOptionals($extrafields, ($action ==
'edit' ?
'edit' :
'view'));
393 if ($action ==
'edit')
395 print '<div class="center">';
396 print '<input type="submit" class="button button-save" name="submit" value="'.$langs->trans(
"Save").
'">';
397 print ' ';
398 print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
406 if ($action ==
'delete_file')
408 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?section='.urlencode($section), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile', $urlfile),
'confirm_deletefile',
'', 1, 1);
411 if ($action !=
'edit')
414 print '<div class="tabsAction">';
416 if ($user->rights->ecm->setup)
418 print '<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit§ion='.urlencode($section).
'&urlfile='.urlencode($urlfile).
'">'.$langs->trans(
'Edit').
'</a>';
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizePathName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a path name.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvirus=0, $indexdatabase=1)
Move a file into another name.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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 Calling this function terminate execution ...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
ecm_file_prepare_head($object)
Prepare array with list of tabs.
ajax_autoselect($htmlname, $addlink= '')
Make content of an input box selected when we click into input field.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_filemtime($pathoffile)
Return time of a file.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
Class to manage ECM directories.
Class to manage ECM files.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.