New: A lot of enhancements into ECM module. Dir can contains special characters. Speed enhancements. Dir can be created outside of dolibarr, the refresh button will update database.
This commit is contained in:
parent
640e03422f
commit
a6c0e62107
@ -66,6 +66,9 @@ class Conf
|
||||
|
||||
var $logbuffer = array();
|
||||
|
||||
var $filesystem_forbidden_chars = array('<','>',':','/','\\','?','*','|','"');
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
||||
@ -51,6 +51,8 @@ class EcmDirectory // extends CommonObject
|
||||
var $cats=array();
|
||||
var $motherof=array();
|
||||
|
||||
var $forbiddenchars = array('<','>',':','/','\\','?','*','|','"');
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructor
|
||||
@ -64,18 +66,18 @@ class EcmDirectory // extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* \brief Create record into database
|
||||
* \param user User that create
|
||||
* \return int <0 si ko, >0 si ok
|
||||
* Create record into database
|
||||
* @param user User that create
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$now=time();
|
||||
$now=dol_now();
|
||||
|
||||
// Clean parameters
|
||||
$this->label=dol_string_nospecial(trim($this->label));
|
||||
$this->label=dol_sanitizeFileName(trim($this->label));
|
||||
$this->fk_parent=trim($this->fk_parent);
|
||||
$this->description=trim($this->description);
|
||||
if (! $this->cachenbofdoc) $this->cachenbofdoc=0;
|
||||
@ -83,6 +85,7 @@ class EcmDirectory // extends CommonObject
|
||||
$this->fk_user_c=$user->id;
|
||||
if ($this->fk_parent <= 0) $this->fk_parent=0;
|
||||
|
||||
|
||||
// Check if same directory does not exists with this name
|
||||
$relativepath=$this->label;
|
||||
if ($this->fk_parent)
|
||||
@ -99,7 +102,7 @@ class EcmDirectory // extends CommonObject
|
||||
$pathfound=0;
|
||||
foreach ($cate_arbo as $key => $categ)
|
||||
{
|
||||
$path=preg_replace('/([\s-><\/])+/i','/',$categ['fulllabel']);
|
||||
$path=str_replace($this->forbiddenchars,'_',$categ['fulllabel']);
|
||||
//print $path.'<br>';
|
||||
if ($path == $relativepath)
|
||||
{
|
||||
@ -352,7 +355,7 @@ class EcmDirectory // extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error='ErrorFailedToDeleteDir';
|
||||
$this->error='ErrorFailToDeleteDir';
|
||||
dol_syslog("EcmDirectories::delete ".$this->error, LOG_ERR);
|
||||
$this->db->rollback();
|
||||
$error++;
|
||||
@ -408,7 +411,8 @@ class EcmDirectory // extends CommonObject
|
||||
//$picto=DOL_URL_ROOT.'/theme/common/treemenu/folder.gif';
|
||||
$picto='dir';
|
||||
|
||||
$newref=str_replace('_',' ',$this->ref);
|
||||
//$newref=str_replace('_',' ',$this->ref);
|
||||
$newref=$this->ref;
|
||||
$newlabel=$langs->trans("ShowECMSection").': '.$newref;
|
||||
|
||||
if ($withpicto) $result.=($lien.img_object($newlabel,$picto,'',1).$lienfin);
|
||||
@ -491,22 +495,22 @@ class EcmDirectory // extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* \brief Reconstruit l'arborescence des categories sous la forme d'un tableau
|
||||
* Renvoi un tableau de tableau('id','id_mere',...) trie selon
|
||||
* arbre et avec:
|
||||
* id = id de la categorie
|
||||
* id_mere = id de la categorie mere
|
||||
* id_children = tableau des id enfant
|
||||
* label = nom de la categorie
|
||||
* cachenbofdoc = nb of documents
|
||||
* date_c = date creation
|
||||
* fk_user_c = user creation
|
||||
* login_c = login creation
|
||||
* fullpath Full path (Added by build_path_from_id_categ call)
|
||||
* fulllabel Full label (Added by build_path_from_id_categ call)
|
||||
* level Level of line (Added by build_path_from_id_categ call)
|
||||
* \param force Force reload of full arbo even if already loaded
|
||||
* \return array Tableau de array
|
||||
* Reconstruit l'arborescence des categories sous la forme d'un tableau
|
||||
* Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec:
|
||||
* id Id de la categorie
|
||||
* id_mere Id de la categorie mere
|
||||
* id_children Tableau des id enfant
|
||||
* label Name of directory
|
||||
* cachenbofdoc Nb of documents
|
||||
* date_c Date creation
|
||||
* fk_user_c User creation
|
||||
* login_c Login creation
|
||||
* fullpath Full path of id (Added by build_path_from_id_categ call)
|
||||
* fullrelativename Full path name (Added by build_path_from_id_categ call)
|
||||
* fulllabel Full label (Added by build_path_from_id_categ call)
|
||||
* level Level of line (Added by build_path_from_id_categ call)
|
||||
* @param force Force reload of full arbo even if already loaded in cache $this->cats
|
||||
* @return array Tableau de array
|
||||
*/
|
||||
function get_full_arbo($force=0)
|
||||
{
|
||||
@ -576,7 +580,7 @@ class EcmDirectory // extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
// On ajoute la propriete fullpath a tous les elements
|
||||
// We add properties fullxxx to all elements
|
||||
foreach($this->cats as $key => $val)
|
||||
{
|
||||
if (isset($motherof[$key])) continue;
|
||||
@ -590,7 +594,7 @@ class EcmDirectory // extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calcule les proprietes fullpath et fulllabel d'une categorie
|
||||
* \brief Calcule les proprietes fullpath, fullrelativename, fulllabel d'un repertoire
|
||||
* du tableau this->cats et de toutes ces enfants
|
||||
* \param id_categ id_categ entry to update
|
||||
* \param protection Deep counter to avoid infinite loop
|
||||
@ -602,16 +606,19 @@ class EcmDirectory // extends CommonObject
|
||||
{
|
||||
$this->cats[$id_categ]['fullpath'] =$this->cats[$this->cats[$id_categ]['id_mere']]['fullpath'];
|
||||
$this->cats[$id_categ]['fullpath'].='_'.$id_categ;
|
||||
$this->cats[$id_categ]['fullrelativename'] =$this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename'];
|
||||
$this->cats[$id_categ]['fullrelativename'].='/'.$this->cats[$id_categ]['label'];
|
||||
$this->cats[$id_categ]['fulllabel'] =$this->cats[$this->cats[$id_categ]['id_mere']]['fulllabel'];
|
||||
$this->cats[$id_categ]['fulllabel'].=' >> '.$this->cats[$id_categ]['label'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->cats[$id_categ]['fullpath']='_'.$id_categ;
|
||||
$this->cats[$id_categ]['fullrelativename']=$this->cats[$id_categ]['label'];
|
||||
$this->cats[$id_categ]['fulllabel']=$this->cats[$id_categ]['label'];
|
||||
}
|
||||
// We count number of _ to have level
|
||||
$this->cats[$id_categ]['level']=dol_strlen(preg_replace('/([^_])/i','',$this->cats[$id_categ]['fullpath']));
|
||||
// We count number of _ to have level (we use strlen that is faster than dol_strlen)
|
||||
$this->cats[$id_categ]['level']=strlen(preg_replace('/([^_])/i','',$this->cats[$id_categ]['fullpath']));
|
||||
|
||||
// Traite ces enfants
|
||||
$protection++;
|
||||
@ -647,7 +654,7 @@ class EcmDirectory // extends CommonObject
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
|
||||
$sql.= " cachenbofdoc = '".sizeof($filelist)."'";
|
||||
if (empty($all))
|
||||
if (empty($all)) // By default
|
||||
{
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2008-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2008-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -88,8 +88,8 @@ $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
|
||||
* Put here all code to do according to value of "action" parameter
|
||||
********************************************************************/
|
||||
|
||||
// Envoie fichier
|
||||
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
// Upload file
|
||||
if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
||||
|
||||
@ -126,9 +126,9 @@ if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
}
|
||||
|
||||
// Remove file
|
||||
if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
|
||||
if (GETPOST('action') == 'confirm_deletefile' && GETPOST('confirm') == 'yes')
|
||||
{
|
||||
$file = $upload_dir . "/" . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
$result=dol_delete_file($file);
|
||||
|
||||
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
|
||||
@ -137,7 +137,7 @@ if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
|
||||
}
|
||||
|
||||
// Remove dir
|
||||
if ($_POST['action'] == 'confirm_deletedir' && $_POST['confirm'] == 'yes')
|
||||
if (GETPOST('action') == 'confirm_deletedir' && GETPOST('confirm') == 'yes')
|
||||
{
|
||||
// Fetch was already done
|
||||
$result=$ecmdir->delete($user);
|
||||
@ -148,12 +148,12 @@ if ($_POST['action'] == 'confirm_deletedir' && $_POST['confirm'] == 'yes')
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$langs->trans($ecmdir->error).'</div>';
|
||||
$mesg = '<div class="error">'.$langs->trans($ecmdir->error,$ecmdir->label).'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Update description
|
||||
if ($_POST['action'] == 'update' && ! $_POST['cancel'])
|
||||
if (GETPOST('action') == 'update' && ! GETPOST('cancel'))
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
@ -162,8 +162,8 @@ if ($_POST['action'] == 'update' && ! $_POST['cancel'])
|
||||
$olddir=$conf->ecm->dir_output.'/'.$olddir;
|
||||
|
||||
// Fetch was already done
|
||||
$ecmdir->label = $_POST["label"];
|
||||
$ecmdir->description = $_POST["description"];
|
||||
$ecmdir->label = GETPOST("label");
|
||||
$ecmdir->description = GETPOST("description");
|
||||
$result=$ecmdir->update($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
@ -218,7 +218,7 @@ $form=new Form($db);
|
||||
|
||||
|
||||
// Construit liste des fichiers
|
||||
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
|
||||
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),3);
|
||||
$totalsize=0;
|
||||
foreach($filearray as $key => $file)
|
||||
{
|
||||
@ -312,7 +312,7 @@ print '</div>';
|
||||
|
||||
|
||||
// Actions buttons
|
||||
if ($_GET["action"] != 'edit' && $_GET['action'] != 'delete_dir' && $_GET['action'] != 'delete')
|
||||
if ($_GET["action"] != 'edit' && $_GET['action'] != 'delete')
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
@ -361,7 +361,8 @@ if ($_GET['action'] == 'delete')
|
||||
// Confirm remove file
|
||||
if ($_GET['action'] == 'delete_dir')
|
||||
{
|
||||
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"], $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection'), 'confirm_deletedir');
|
||||
$relativepathwithoutslash=preg_replace('/[\/]$/','',$relativepath);
|
||||
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"], $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$relativepathwithoutslash), 'confirm_deletedir', '', 1, 1);
|
||||
if ($ret == 'html') print '<br>';
|
||||
}
|
||||
|
||||
|
||||
@ -50,9 +50,9 @@ $result = restrictedArea($user, 'ecm','');
|
||||
$user->getrights('ecm');
|
||||
|
||||
// Get parameters
|
||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
$action = isset($_GET["action"])?$_GET["action"]:$_POST['action'];
|
||||
$section=isset($_GET["section"])?$_GET["section"]:$_POST['section'];
|
||||
$socid=GETPOST('socid');
|
||||
$action=GETPOST("action");
|
||||
$section=GETPOST("section");
|
||||
if (! $section) $section=0;
|
||||
|
||||
$upload_dir = $conf->ecm->dir_output.'/'.$section;
|
||||
@ -67,9 +67,9 @@ if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="label";
|
||||
|
||||
$ecmdir = new ECMDirectory($db);
|
||||
if (! empty($_REQUEST["section"]))
|
||||
if (GETPOST("section"))
|
||||
{
|
||||
$result=$ecmdir->fetch($_REQUEST["section"]);
|
||||
$result=$ecmdir->fetch(GETPOST("section"));
|
||||
if (! $result > 0)
|
||||
{
|
||||
dol_print_error($db,$ecmdir->error);
|
||||
@ -77,6 +77,10 @@ if (! empty($_REQUEST["section"]))
|
||||
}
|
||||
}
|
||||
|
||||
$form=new Form($db);
|
||||
$ecmdirstatic = new ECMDirectory($db);
|
||||
$userstatic = new User($db);
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* ACTIONS
|
||||
@ -84,17 +88,9 @@ if (! empty($_REQUEST["section"]))
|
||||
* Put here all code to do according to value of "action" parameter
|
||||
********************************************************************/
|
||||
|
||||
// Envoie fichier
|
||||
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
// Upload file
|
||||
if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
||||
|
||||
$result=$ecmdir->fetch($_REQUEST["section"]);
|
||||
if (! $result > 0)
|
||||
{
|
||||
dol_print_error($db,$ecmdir->error);
|
||||
exit;
|
||||
}
|
||||
$relativepath=$ecmdir->getRelativePath();
|
||||
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
|
||||
|
||||
@ -131,12 +127,12 @@ if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
}
|
||||
}
|
||||
|
||||
// Action ajout d'un produit ou service
|
||||
if ($_POST["action"] == 'add' && $user->rights->ecm->setup)
|
||||
// Add directory
|
||||
if (GETPOST("action") == 'add' && $user->rights->ecm->setup)
|
||||
{
|
||||
$ecmdir->ref = $_POST["ref"];
|
||||
$ecmdir->label = $_POST["label"];
|
||||
$ecmdir->description = $_POST["desc"];
|
||||
$ecmdir->ref = 'NOTUSEDYET';
|
||||
$ecmdir->label = GETPOST("label");
|
||||
$ecmdir->description = GETPOST("desc");
|
||||
|
||||
$id = $ecmdir->create($user);
|
||||
if ($id > 0)
|
||||
@ -152,9 +148,9 @@ if ($_POST["action"] == 'add' && $user->rights->ecm->setup)
|
||||
}
|
||||
|
||||
// Remove file
|
||||
if ($_REQUEST['action'] == 'confirm_deletefile' && $_REQUEST['confirm'] == 'yes')
|
||||
if (GETPOST('action') == 'confirm_deletefile' && GETPOST('confirm') == 'yes')
|
||||
{
|
||||
$result=$ecmdir->fetch($_REQUEST["section"]);
|
||||
$result=$ecmdir->fetch(GETPOST("section"));
|
||||
if (! $result > 0)
|
||||
{
|
||||
dol_print_error($db,$ecmdir->error);
|
||||
@ -162,7 +158,7 @@ if ($_REQUEST['action'] == 'confirm_deletefile' && $_REQUEST['confirm'] == 'yes'
|
||||
}
|
||||
$relativepath=$ecmdir->getRelativePath();
|
||||
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
|
||||
$file = $upload_dir . "/" . $_REQUEST['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
|
||||
$result=dol_delete_file($file);
|
||||
|
||||
@ -173,13 +169,123 @@ if ($_REQUEST['action'] == 'confirm_deletefile' && $_REQUEST['confirm'] == 'yes'
|
||||
}
|
||||
|
||||
// Remove directory
|
||||
if ($_REQUEST['action'] == 'confirm_deletesection' && $_REQUEST['confirm'] == 'yes')
|
||||
if (GETPOST('action') == 'confirm_deletesection' && GETPOST('confirm') == 'yes')
|
||||
{
|
||||
$result=$ecmdir->delete($user);
|
||||
$mesg = '<div class="ok">'.$langs->trans("ECMSectionWasRemoved", $ecmdir->label).'</div>';
|
||||
}
|
||||
|
||||
// Refresh directory view
|
||||
if (GETPOST("action") == 'refreshmanual')
|
||||
{
|
||||
$diroutputslash=str_replace('\\','/',$conf->ecm->dir_output);
|
||||
$diroutputslash.='/';
|
||||
|
||||
// Scan directory tree on disk
|
||||
$disktree=dol_dir_list($conf->ecm->dir_output,'directories',1,'','','','',0);
|
||||
|
||||
// Scan directory tree in database
|
||||
$sqltree=$ecmdirstatic->get_full_arbo(0);
|
||||
|
||||
$adirwascreated=0;
|
||||
|
||||
// Now we compare both trees to complete missing trees into database
|
||||
//var_dump($disktree);
|
||||
//var_dump($sqltree);
|
||||
foreach($disktree as $dirdesc)
|
||||
{
|
||||
$dirisindatabase=0;
|
||||
foreach($sqltree as $dirsqldesc)
|
||||
{
|
||||
if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname'])
|
||||
{
|
||||
$dirisindatabase=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $dirisindatabase)
|
||||
{
|
||||
$txt="Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it";
|
||||
dol_syslog($txt);
|
||||
print $txt."<br>\n";
|
||||
|
||||
// We must first find the fk_parent of directory to create $dirdesc['fullname']
|
||||
$fk_parent=-1;
|
||||
$relativepathmissing=str_replace($diroutputslash,'',$dirdesc['fullname']);
|
||||
$relativepathtosearchparent=$relativepathmissing;
|
||||
//dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent);
|
||||
if (preg_match('/\//',$relativepathtosearchparent))
|
||||
//while (preg_match('/\//',$relativepathtosearchparent))
|
||||
{
|
||||
$relativepathtosearchparent=preg_replace('/\/[^\/]*$/','',$relativepathtosearchparent);
|
||||
$txt="Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?";
|
||||
dol_syslog($txt);
|
||||
print $txt." -> ";
|
||||
$parentdirisindatabase=0;
|
||||
foreach($sqltree as $dirsqldesc)
|
||||
{
|
||||
if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent)
|
||||
{
|
||||
$parentdirisindatabase=$dirsqldesc['id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($parentdirisindatabase > 0)
|
||||
{
|
||||
dol_syslog("Yes with id ".$parentdirisindatabase);
|
||||
print "Yes with id ".$parentdirisindatabase."<br>\n";
|
||||
$fk_parent=$parentdirisindatabase;
|
||||
//break; // We found parent, we can stop the while loop
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("No");
|
||||
print "No<br>\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$fk_parent=0; // Parent is root
|
||||
}
|
||||
|
||||
if ($fk_parent >= 0)
|
||||
{
|
||||
$ecmdirtmp=new ECMDirectory($db);
|
||||
$ecmdirtmp->ref = 'NOTUSEDYET';
|
||||
$ecmdirtmp->label = basename($dirdesc['fullname']);
|
||||
$ecmdirtmp->description = '';
|
||||
$ecmdirtmp->fk_parent = $fk_parent;
|
||||
|
||||
$txt="We create directory ".$ecmdirtmp->label." with parent ".$fk_parent;
|
||||
dol_syslog($txt);
|
||||
print $txt."<br>\n";
|
||||
$id = $ecmdirtmp->create($user);
|
||||
//$id=999;
|
||||
if ($id > 0)
|
||||
{
|
||||
$newdirsql=array('id'=>$id,
|
||||
'id_mere'=>$ecmdirtmp->fk_parent,
|
||||
'label'=>$ecmdirtmp->label,
|
||||
'description'=>$ecmdirtmp->description,
|
||||
'fullrelativename'=>$relativepathmissing);
|
||||
$sqltree[]=$newdirsql; // We complete fulltree for following loops
|
||||
//var_dump($sqltree);
|
||||
$adirwascreated=1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$txt="Parent of ".$dirdesc['fullname']." not found";
|
||||
dol_syslog($txt);
|
||||
print $txt."<br>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If a directory was added, the fulltree array is not correctly completed and sorted, so we clean
|
||||
// it to be sure that fulltree array is not used without reloading it.
|
||||
if ($adirwascreated) $sqltree=null;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
@ -231,7 +337,7 @@ html, body {
|
||||
center__paneSelector: \".ui-in-layout-center\"
|
||||
, south__paneSelector: \".ui-in-layout-south\"
|
||||
, resizable: false
|
||||
, south__miSize: 34
|
||||
, south__minSize: 32
|
||||
, south__resizable: false
|
||||
, south__closable: false
|
||||
, useStateCookie: true /* Put this to false for dev */
|
||||
@ -241,11 +347,6 @@ html, body {
|
||||
|
||||
llxHeader($morehead,$langs->trans("ECM"),'','','','',$morejs,'',0,0);
|
||||
|
||||
$form=new Form($db);
|
||||
$ecmdirstatic = new ECMDirectory($db);
|
||||
$userstatic = new User($db);
|
||||
|
||||
|
||||
// Ajout rubriques automatiques
|
||||
$rowspan=0;
|
||||
$sectionauto=array();
|
||||
@ -269,7 +370,7 @@ print $langs->trans("ECMAreaDesc2")."<br>";
|
||||
print "<br>\n";
|
||||
|
||||
// Confirm remove file
|
||||
if ($_GET['action'] == 'delete')
|
||||
if (GETPOST('action') == 'delete')
|
||||
{
|
||||
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"].'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile','','',1);
|
||||
if ($ret == 'html') print '<br>';
|
||||
@ -277,7 +378,7 @@ if ($_GET['action'] == 'delete')
|
||||
|
||||
if ($mesg) { print $mesg."<br>"; }
|
||||
|
||||
// Tool bar
|
||||
// Toolbar
|
||||
$head = ecm_prepare_head_fm($fac);
|
||||
//dol_fiche_head($head, 'file_manager', '', 1);
|
||||
|
||||
@ -300,9 +401,9 @@ else
|
||||
print '<tr><td colspan="2" style="background: #FFFFFF" style="height: 24px !important">';
|
||||
}
|
||||
|
||||
// Construit liste des repertoires
|
||||
if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$action))
|
||||
{
|
||||
// Show button to create a directory
|
||||
//if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$action))
|
||||
//{
|
||||
if ($user->rights->ecm->setup)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create" title="'.dol_escape_htmltag($langs->trans('ECMAddSection')).'">';
|
||||
@ -317,13 +418,10 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
|
||||
print '<img width="32" height="32" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
|
||||
print '</a>';
|
||||
}
|
||||
}
|
||||
//print '</td>';
|
||||
//print '<td class="liste_titre" colspan="5" align="right">';
|
||||
//print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual'.($section?'&section='.$section:'').'">'.img_picto($langs->trans("Refresh"),'refresh').'</a>';
|
||||
//}
|
||||
// Show button to refresh listing
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual'.($section?'&section='.$section:'').'" title="'.dol_escape_htmltag($langs->trans('Refresh')).'">';
|
||||
print '<img width="32" height="32" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">';
|
||||
//print $langs->trans('Refresh');
|
||||
print '</a>';
|
||||
|
||||
|
||||
@ -498,7 +596,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
|
||||
|
||||
|
||||
// Load full tree
|
||||
$fulltree=$ecmdirstatic->get_full_arbo();
|
||||
if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0);
|
||||
|
||||
// ----- This section will show a tree from a fulltree array -----
|
||||
// $section must also be defined
|
||||
@ -506,7 +604,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
|
||||
|
||||
// Define fullpathselected ( _x_y_z ) of $section parameter
|
||||
$fullpathselected='';
|
||||
foreach($fulltree as $key => $val)
|
||||
foreach($sqltree as $key => $val)
|
||||
{
|
||||
//print $val['id']."-".$section."<br>";
|
||||
if ($val['id'] == $section)
|
||||
@ -542,7 +640,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
|
||||
foreach($oldexpandedsectionarray as $sectioncursor)
|
||||
{
|
||||
// is_in_subtree(fulltree,sectionparent,sectionchild)
|
||||
if ($sectioncursor && ! is_in_subtree($fulltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor;
|
||||
if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor;
|
||||
}
|
||||
$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
|
||||
}
|
||||
@ -551,7 +649,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
|
||||
$nbofentries=0;
|
||||
$oldvallevel=0;
|
||||
$var=true;
|
||||
foreach($fulltree as $key => $val)
|
||||
foreach($sqltree as $key => $val)
|
||||
{
|
||||
$var=false;
|
||||
|
||||
@ -593,7 +691,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
|
||||
// Show tree graph pictos
|
||||
print '<td align="left">';
|
||||
print '<table class="nobordernopadding"><tr class="nobordernopadding"><td>';
|
||||
$resarray=tree_showpad($fulltree,$key);
|
||||
$resarray=tree_showpad($sqltree,$key);
|
||||
$a=$resarray[0];
|
||||
$nbofsubdir=$resarray[1];
|
||||
$c=$resarray[2];
|
||||
@ -609,7 +707,8 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
|
||||
else $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/minustop'.$n.'.gif','',1);
|
||||
if ($option == 'indexexpanded') $lien = '<a href="'.$_SERVER["PHP_SELF"].'?section='.$val['id'].'&sectionexpand=false">';
|
||||
if ($option == 'indexnotexpanded') $lien = '<a href="'.$_SERVER["PHP_SELF"].'?section='.$val['id'].'&sectionexpand=true">';
|
||||
$newref=str_replace('_',' ',$ref);
|
||||
//$newref=str_replace('_',' ',$ref);
|
||||
$newref=$ref;
|
||||
$lienfin='</a>';
|
||||
print $lien.$newref.$lienfin;
|
||||
if (! in_array($val['id'],$expandedsectionarray)) print img_picto($ecmdirstatic->ref,DOL_URL_ROOT.'/theme/common/treemenu/folder.gif','',1);
|
||||
@ -766,7 +865,6 @@ else
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
|
||||
// End of page
|
||||
$db->close();
|
||||
|
||||
@ -73,3 +73,7 @@ ALTER TABLE llx_categorie ADD COLUMN import_key varchar(14);
|
||||
|
||||
ALTER TABLE llx_product ADD COLUMN customcode varchar(32) after note;
|
||||
ALTER TABLE llx_product ADD COLUMN fk_country integer after customcode;
|
||||
|
||||
|
||||
ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX idx_ecm_directories (label, fk_parent, entity);
|
||||
ALTER TABLE llx_ecm_documents ADD UNIQUE INDEX idx_ecm_documents (fullpath_dol);
|
||||
|
||||
23
htdocs/install/mysql/tables/llx_ecm_directories.key.sql
Normal file
23
htdocs/install/mysql/tables/llx_ecm_directories.key.sql
Normal file
@ -0,0 +1,23 @@
|
||||
-- ============================================================================
|
||||
-- Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 2 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program; if not, write to the Free Software
|
||||
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
--
|
||||
-- $Id$
|
||||
-- ============================================================================
|
||||
|
||||
|
||||
ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX idx_ecm_directories (label, fk_parent, entity);
|
||||
|
||||
23
htdocs/install/mysql/tables/llx_ecm_documents.key.sql
Normal file
23
htdocs/install/mysql/tables/llx_ecm_documents.key.sql
Normal file
@ -0,0 +1,23 @@
|
||||
-- ============================================================================
|
||||
-- Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 2 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program; if not, write to the Free Software
|
||||
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
--
|
||||
-- $Id$
|
||||
-- ============================================================================
|
||||
|
||||
|
||||
ALTER TABLE llx_ecm_documents ADD UNIQUE INDEX idx_ecm_documents (fullpath_dol);
|
||||
|
||||
@ -24,23 +24,24 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Scan a directory and return a list of files/directories. Content for string is UTF8.
|
||||
* Scan a directory and return a list of files/directories.
|
||||
* Content for string is UTF8 and dir separator is "/".
|
||||
* @param $path Starting path from which to search
|
||||
* @param $types Can be "directories", "files", or "all"
|
||||
* @param $recursive Determines whether subdirectories are searched
|
||||
* @param $filter Regex for include filter
|
||||
* @param $exludefilter Regex for exclude filter (example: '\.meta$')
|
||||
* @param $sortcriteria Sort criteria ("name","date","size")
|
||||
* @param $excludefilter Regex for exclude filter (example: '\.meta$')
|
||||
* @param $sortcriteria Sort criteria ("","name","date","size")
|
||||
* @param $sortorder Sort order (SORT_ASC, SORT_DESC)
|
||||
* @param $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower)
|
||||
* @param $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only
|
||||
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file')
|
||||
*/
|
||||
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
|
||||
{
|
||||
dol_syslog("files.lib.php::dol_dir_list path=".$path." types=".$types." recursive=".$recursive." filter=".$filter." excludefilter=".$excludefilter);
|
||||
|
||||
$loaddate=$mode?true:false;
|
||||
$loadsize=$mode?true:false;
|
||||
$loaddate=($mode==1||$mode==2)?true:false;
|
||||
$loadsize=($mode==1||$mode==3)?true:false;
|
||||
|
||||
// Clean parameters
|
||||
$path=preg_replace('/([\\/]+)$/i','',$path);
|
||||
@ -114,7 +115,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
|
||||
$myarray[$key] = $row[$sortcriteria];
|
||||
}
|
||||
// Sort the data
|
||||
array_multisort($myarray, $sortorder, $file_list);
|
||||
if ($sortorder) array_multisort($myarray, $sortorder, $file_list);
|
||||
|
||||
return $file_list;
|
||||
}
|
||||
|
||||
@ -111,22 +111,23 @@ function dol_now($mode='tzserver')
|
||||
|
||||
|
||||
/**
|
||||
* \brief Clean a string to use it as a file name.
|
||||
* \param str String to clean
|
||||
* \param newstr String to replace bad chars by
|
||||
* \return string String cleaned (a-zA-Z_)
|
||||
* \seealso dol_string_nospecial, dol_string_unaccent
|
||||
* Clean a string to use it as a file name.
|
||||
* @param str String to clean
|
||||
* @param newstr String to replace bad chars with
|
||||
* @return string String cleaned (a-zA-Z_)
|
||||
* @see dol_string_nospecial, dol_string_unaccent
|
||||
*/
|
||||
function dol_sanitizeFileName($str,$newstr='_')
|
||||
{
|
||||
return dol_string_nospecial(dol_string_unaccent($str),$newstr);
|
||||
global $conf;
|
||||
return dol_string_nospecial(dol_string_unaccent($str),$newstr,$conf->filesystem_forbidden_chars);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
|
||||
* \param str String to clean
|
||||
* \return string Cleaned string
|
||||
* \seealso dol_sanitizeFilename, dol_string_nospecial
|
||||
* Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
|
||||
* @param str String to clean
|
||||
* @return string Cleaned string
|
||||
* @see dol_sanitizeFilename, dol_string_nospecial
|
||||
*/
|
||||
function dol_string_unaccent($str)
|
||||
{
|
||||
@ -169,19 +170,21 @@ function dol_string_unaccent($str)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Clean a string from all punctuation characters to use it as a ref or login.
|
||||
* \param str String to clean
|
||||
* \param newstr String to replace bad chars by
|
||||
* \return string Cleaned string
|
||||
* \seealso dol_sanitizeFilename, dol_string_unaccent
|
||||
* Clean a string from all punctuation characters to use it as a ref or login.
|
||||
* @param str String to clean
|
||||
* @param newstr String to replace forbidden chars with
|
||||
* @param badchars List of forbidden characters
|
||||
* @return string Cleaned string
|
||||
* @see dol_sanitizeFilename, dol_string_unaccent
|
||||
*/
|
||||
function dol_string_nospecial($str,$newstr='_')
|
||||
function dol_string_nospecial($str,$newstr='_',$badchars='')
|
||||
{
|
||||
$forbidden_chars_to_underscore=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
|
||||
//$forbidden_chars_to_remove=array("(",")");
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
|
||||
$forbidden_chars_to_remove=array();
|
||||
if (is_array($badchars)) $forbidden_chars_to_replace=$badchars;
|
||||
//$forbidden_chars_to_remove=array("(",")");
|
||||
|
||||
return str_replace($forbidden_chars_to_underscore,$newstr,str_replace($forbidden_chars_to_remove,"",$str));
|
||||
return str_replace($forbidden_chars_to_replace,$newstr,str_replace($forbidden_chars_to_remove,"",$str));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user