25require 
'../main.inc.php';
 
   26require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
 
   27require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
 
   28require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
 
   29require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
 
   30require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
 
   31require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
 
   34$langs->loadLangs(array(
'ecm', 
'companies', 
'other', 
'users', 
'orders', 
'propal', 
'bills', 
'contracts', 
'categories'));
 
   36$action = 
GETPOST(
'action', 
'aZ09');
 
   37$cancel = 
GETPOST(
'cancel', 
'alpha');
 
   38$backtopage = 
GETPOST(
'backtopage', 
'alpha');
 
   41$socid = 
GETPOST(
"socid", 
"int");
 
   44if ($user->socid > 0) {
 
   46  $socid = $user->socid;
 
   49$limit = 
GETPOST(
'limit', 
'int') ? 
GETPOST(
'limit', 
'int') : $conf->liste_limit;
 
   50$sortfield = 
GETPOST(
'sortfield', 
'aZ09comma');
 
   51$sortorder = 
GETPOST(
'sortorder', 
'aZ09comma');
 
   52$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) : 
GETPOST(
"page", 
'int');
 
   53if (empty($page) || $page == -1) {
 
   56$offset = $limit * $page;
 
   66$section = 
GETPOST(
"section", 
'alpha');
 
   79$result = $ecmdir->fetch(
GETPOST(
"section", 
'alpha'));
 
   84$relativepath = $ecmdir->getRelativePath();
 
   85$upload_dir = $conf->ecm->dir_output.
'/'.$relativepath;
 
   87$fullpath = $conf->ecm->dir_output.
'/'.$relativepath.$urlfile;
 
   89$relativetodocument = 
'ecm/'.$relativepath; 
 
   90$filepath = $relativepath.$urlfile;
 
   91$filepathtodocument = $relativetodocument.$urlfile;
 
   97$extrafields->fetch_name_optionals_label($object->table_element);
 
   99$result = $object->fetch(0, 
'', $filepathtodocument);
 
  106$permissiontoread = $user->rights->ecm->read;
 
  107$permissiontoadd = $user->rights->ecm->setup;
 
  108$permissiontoupload = $user->rights->ecm->upload;
 
  110if (!$permissiontoread) {
 
  122    header(
"Location: ".$backtopage);
 
  125    header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?urlfile='.urlencode($urlfile).
'§ion='.urlencode($section).($module ? 
'&module='.urlencode($module) : 
''));
 
  131if ($action == 
'update' && $permissiontoadd) {
 
  134  $oldlabel = 
GETPOST(
'urlfile', 
'alpha');
 
  136  $shareenabled = 
GETPOST(
'shareenabled', 
'alpha');
 
  140  $olddir = $ecmdir->getRelativePath(0); 
 
  141  $olddirrelativetodocument = 
'ecm/'.$olddir; 
 
  142  $newdirrelativetodocument = 
'ecm/'.$olddir;
 
  143  $olddir = $conf->ecm->dir_output.
'/'.$olddir;
 
  146  $oldfile = $olddir.$oldlabel;
 
  147  $newfile = $newdir.$newlabel;
 
  148  $newfileformove = $newfile;
 
  150  if (preg_match(
'/\.noexe$/', $oldfile) && !preg_match(
'/\.noexe$/', $newfileformove)) {
 
  151    $newfileformove .= 
'.noexe';
 
  158  if ($newlabel != $oldlabel) {
 
  159    $result = 
dol_move($oldfile, $newfileformove); 
 
  161      $langs->load(
'errors');
 
  162      setEventMessages($langs->trans(
'ErrorFailToRenameFile', $oldfile, $newfile), 
null, 
'errors');
 
  167    $result = $object->fetch(0, 
'', $newdirrelativetodocument.$newlabel);
 
  176      require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
 
  182    if ($object->id > 0) {
 
  183      $ret = $extrafields->setOptionalsFromPost(
null, $object);
 
  189        $result = $object->insertExtraFields();
 
  196      $result = $object->update($user);
 
  202      $object->entity = $conf->entity;
 
  203      $object->filepath = preg_replace(
'/[\\/]+$/', 
'', $newdirrelativetodocument);
 
  204      $object->filename = $newlabel;
 
  205      $object->label = md5_file(
dol_osencode($newfileformove)); 
 
  206      $object->fullpath_orig = 
'';
 
  207      $object->gen_or_uploaded = 
'unknown';
 
  208      $object->description = 
''; 
 
  209      $object->keywords = 
''; 
 
  210      $result = $object->create($user);
 
  220    $urlfile = $newlabel;
 
  222    if (preg_match(
'/\.noexe$/', $newfileformove)) {
 
  223      $urlfile .= 
'.noexe';
 
  226    header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?urlfile='.urlencode($urlfile).
'§ion='.urlencode($section));
 
  239$form = 
new Form($db);
 
  243$object->section_id = $ecmdir->id;
 
  244$object->label = $urlfile;
 
  247if ($action == 
'edit') {
 
  248  print 
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
 
  249  print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  250  print 
'<input type="hidden" name="section" value="'.$section.
'">';
 
  251  print 
'<input type="hidden" name="urlfile" value="'.$urlfile.
'">';
 
  252  print 
'<input type="hidden" name="module" value="'.$module.
'">';
 
  253  print 
'<input type="hidden" name="action" value="update">';
 
  254  print 
'<input type="hidden" name="id" value="'.$object->id.
'">';
 
  262$tmpecmdir->fetch($ecmdir->id);
 
  265while ($tmpecmdir && $result > 0) {
 
  266  $tmpecmdir->ref = $tmpecmdir->label;
 
  267  $s = $tmpecmdir->getNomUrl(1).$s;
 
  268  if ($tmpecmdir->fk_parent) {
 
  270    $result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
 
  277$urlfiletoshow = preg_replace(
'/\.noexe$/', 
'', $urlfile);
 
  279$s = 
img_picto(
'', 
'object_dir').
' <a href="'.DOL_URL_ROOT.
'/ecm/index.php">'.$langs->trans(
"ECMRoot").
'</a> -> '.$s.
' -> ';
 
  280if ($action == 
'edit') {
 
  281  $s .= 
'<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfiletoshow.
'">';
 
  283  $s .= $urlfiletoshow;
 
  288  $linkback = 
'<a href="'.$backtopage.
'">'.$langs->trans(
"BackToTree").
'</a>';
 
  294print 
'<div class="fichecenter">';
 
  296print 
'<div class="underbanner clearboth"></div>';
 
  297print 
'<table class="border centpercent tableforfield">';
 
  298print 
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ECMCreationDate").
'</td><td>';
 
  313print 
'<tr><td>'.$langs->trans(
"HashOfFileContent").
'</td><td>';
 
  315$object->fetch(0, 
'', $filepathtodocument);
 
  316if (!empty($object->label)) {
 
  317  print $object->label;
 
  319  print 
img_warning().
' '.$langs->trans(
"FileNotYetIndexedInDatabase");
 
  324$urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT, 
'/').
'$/i', 
'', trim($dolibarr_main_url_root));
 
  325$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; 
 
  330print $form->textwithpicto($langs->trans(
"DirectDownloadInternalLink"), $langs->trans(
"PrivateDownloadLinkDesc"));
 
  334$rellink = 
'/document.php?modulepart='.$modulepart;
 
  336  $rellink .= 
'&attachment=1';
 
  338if (!empty($object->entity)) {
 
  339  $rellink .= 
'&entity='.$object->entity;
 
  341$rellink .= 
'&file='.urlencode($filepath);
 
  342$fulllink = $urlwithroot.$rellink;
 
  344if ($action != 
'edit') {
 
  345  print 
'<input type="text" class="maxquatrevingtpercent widthcentpercentminusxx" id="downloadinternallink" name="downloadinternellink" value="'.dol_escape_htmltag($fulllink).
'">';
 
  349if ($action != 
'edit') {
 
  350  print 
' <a href="'.$fulllink.
'">'.
img_picto($langs->trans(
"Download"), 
'download', 
'class="opacitymedium paddingrightonly"').
'</a>'; 
 
  356if ($action != 
'edit') {
 
  357  print $form->textwithpicto($langs->trans(
"DirectDownloadLink"), $langs->trans(
"PublicDownloadLinkDesc"));
 
  359  print $form->textwithpicto($langs->trans(
"FileSharedViaALink"), $langs->trans(
"PublicDownloadLinkDesc"));
 
  362if (!empty($object->share)) {
 
  363  if ($action != 
'edit') {
 
  367    if (!empty($object->share)) {
 
  368      $paramlink .= ($paramlink ? 
'&' : 
'').
'hashp='.$object->share; 
 
  370    if ($forcedownload) {
 
  371      $paramlink .= ($paramlink ? 
'&' : 
'').
'attachment=1';
 
  374    $fulllink = $urlwithroot.
'/document.php'.($paramlink ? 
'?'.$paramlink : 
'');
 
  379    if ($action != 
'edit') {
 
  380      print 
'<input type="text" class="quatrevingtpercent nopadding small" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).
'">';
 
  384    if ($action != 
'edit') {
 
  385      print 
' <a href="'.$fulllink.
'">'.$langs->trans(
"Download").
'</a>'; 
 
  388    print 
'<input type="checkbox" name="shareenabled"'.($object->share ? 
' checked="checked"' : 
'').
' /> ';
 
  391  if ($action != 
'edit') {
 
  392    print 
'<span class="opacitymedium">'.$langs->trans(
"FileNotShared").
'</span>';
 
  394    print 
'<input type="checkbox" name="shareenabled"'.($object->share ? 
' checked="checked"' : 
'').
' /> ';
 
  399print $object->showOptionals($extrafields, ($action == 
'edit' ? 
'edit' : 
'view'));
 
  408if ($action == 
'edit') {
 
  409  print $form->buttonsSaveCancel();
 
  416if ($action == 
'deletefile') {
 
  417  print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.urlencode($section), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile', $urlfile), 
'confirm_deletefile', 
'', 1, 1);
 
  420if ($action != 
'edit') {
 
  422  print 
'<div class="tabsAction">';
 
  424  if ($user->rights->ecm->setup) {
 
  425    print 
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit§ion='.urlencode($section).
'&urlfile='.urlencode($urlfile).
'">'.$langs->trans(
'Edit').
'</a>';
 
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
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())
Move a file into another name.
 
dol_filemtime($pathoffile)
Return time of a file.
 
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.
 
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)
Show tabs of a record.
 
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
 
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
 
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
 
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
 
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
 
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
 
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
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.
 
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.