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',
'alpha');
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 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?urlfile='.urlencode($urlfile).
'§ion='.urlencode($section).($module ?
'&module='.urlencode($module) :
''));
144if ($action ==
'update' && $permissiontoadd) {
147 $oldlabel =
GETPOST(
'urlfile',
'alpha');
149 $shareenabled =
GETPOST(
'shareenabled',
'alpha');
153 $olddir = $ecmdir->getRelativePath(0);
154 $olddirrelativetodocument =
'ecm/'.$olddir;
155 $newdirrelativetodocument =
'ecm/'.$olddir;
156 $olddir =
$conf->ecm->dir_output.
'/'.$olddir;
159 $oldfile = $olddir.$oldlabel;
160 $newfile = $newdir.$newlabel;
161 $newfileformove = $newfile;
163 if (preg_match(
'/\.noexe$/', $oldfile) && !preg_match(
'/\.noexe$/', $newfileformove)) {
164 $newfileformove .=
'.noexe';
171 if ($newlabel != $oldlabel) {
172 $result =
dol_move($oldfile, $newfileformove);
174 $langs->load(
'errors');
175 setEventMessages($langs->trans(
'ErrorFailToRenameFile', $oldfile, $newfile),
null,
'errors');
180 $result =
$object->fetch(0,
'', $newdirrelativetodocument.$newlabel);
189 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
196 $ret = $extrafields->setOptionalsFromPost(
null, $object);
202 $result =
$object->insertExtraFields();
209 $result =
$object->update($user);
216 $object->filepath = preg_replace(
'/[\\/]+$/',
'', $newdirrelativetodocument);
220 $object->gen_or_uploaded =
'unknown';
223 $result =
$object->create($user);
233 $urlfile = $newlabel;
235 if (preg_match(
'/\.noexe$/', $newfileformove)) {
236 $urlfile .=
'.noexe';
239 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?urlfile='.urlencode($urlfile).
'§ion='.urlencode($section));
254llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-ecm page-file_card');
256$object->section_id = $ecmdir->id;
260if ($action ==
'edit') {
261 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
262 print
'<input type="hidden" name="token" value="'.newToken().
'">';
263 print
'<input type="hidden" name="section" value="'.$section.
'">';
264 print
'<input type="hidden" name="urlfile" value="'.$urlfile.
'">';
265 print
'<input type="hidden" name="module" value="'.$module.
'">';
266 print
'<input type="hidden" name="action" value="update">';
267 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
275$tmpecmdir->fetch($ecmdir->id);
278while ($tmpecmdir && $result > 0) {
279 $tmpecmdir->ref = $tmpecmdir->label;
280 $s = $tmpecmdir->getNomUrl(1).$s;
281 if ($tmpecmdir->fk_parent) {
283 $result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
290$urlfiletoshow = preg_replace(
'/\.noexe$/',
'', $urlfile);
292$s =
img_picto(
'',
'object_dir').
' <a href="'.DOL_URL_ROOT.
'/ecm/index.php">'.$langs->trans(
"ECMRoot").
'</a> -> '.$s.
' -> ';
293if ($action ==
'edit') {
294 $s .=
'<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfiletoshow.
'">';
296 $s .= $urlfiletoshow;
301 $linkback =
'<a href="'.$backtopage.
'">'.$langs->trans(
"BackToTree").
'</a>';
305dol_banner_tab($object,
'', $linkback, 0,
'',
'', $s);
307print
'<div class="fichecenter">';
309print
'<div class="underbanner clearboth"></div>';
310print
'<table class="border centpercent tableforfield">';
311print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ECMCreationDate").
'</td><td>';
326print
'<tr><td>'.$langs->trans(
"HashOfFileContent").
'</td><td>';
328$object->fetch(0,
'', $filepathtodocument);
332 print
img_warning().
' '.$langs->trans(
"FileNotYetIndexedInDatabase");
338$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
343print $form->textwithpicto($langs->trans(
"DirectDownloadInternalLink"), $langs->trans(
"PrivateDownloadLinkDesc"));
346$rellink =
'/document.php?modulepart=' . $modulepart .
'&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 small" 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') {
373 $fulllink = $urlwithroot.
'/document.php?hashp='.
$object->share;
378 if ($action !=
'edit') {
379 print
'<input type="text" class="maxquatrevingtpercent widthcentpercentminusxx nopadding small downloadexternallink" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).
'" spellcheck="false">';
383 if ($action !=
'edit') {
384 print
' <a href="'.$fulllink.
'">'.
img_picto($langs->trans(
"Download"),
'download',
'class="opacitymedium paddingrightonly"').
'</a>';
387 print
'<input type="checkbox" name="shareenabled" checked="checked" /> ';
390 if ($action !=
'edit') {
391 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotShared").
'</span>';
393 print
'<input type="checkbox" name="shareenabled" /> ';
398print
$object->showOptionals($extrafields, ($action ==
'edit' ?
'edit' :
'view'));
402print ajax_autoselect(
'downloadinternallink');
403print ajax_autoselect(
'downloadlink');
407if ($action ==
'edit') {
408 print $form->buttonsSaveCancel();
415if ($action ==
'deletefile') {
416 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.urlencode($section), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile', $urlfile),
'confirm_deletefile',
'', 1, 1);
419if ($action !=
'edit') {
421 print
'<div class="tabsAction">';
423 if ($user->hasRight(
'ecm',
'setup')) {
424 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit§ion='.urlencode($section).
'&urlfile='.urlencode($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.
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.
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)
Return value of a param into GET or POST supervariable.
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).
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
buildzip.php
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.