* * 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. */ /** * \file htdocs/ecm/docfile.php * \ingroup ecm * \brief Card of a file for ECM module * \version $Id$ * \author Laurent Destailleur */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/ecm/class/ecmdirectory.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/ecm.lib.php"); // Load traductions files $langs->load("ecm"); $langs->load("companies"); $langs->load("other"); $langs->load("users"); $langs->load("orders"); $langs->load("propal"); $langs->load("bills"); $langs->load("contracts"); $langs->load("categories"); // Load permissions $user->getrights('ecm'); if (!$user->rights->ecm->setup) accessforbidden(); // Get parameters $socid = isset($_GET["socid"])?$_GET["socid"]:''; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="label"; $section=GETPOST("section"); if (! $section) { dol_print_error('','Error, section parameter missing'); exit; } $urlfile=GETPOST("urlfile"); if (! $urlfile) { dol_print_error('',"ErrorParamNotDefined"); exit; } // Load ecm object $ecmdir = new ECMDirectory($db); $result=$ecmdir->fetch(GETPOST("section")); if (! $result > 0) { dol_print_error($db,$ecmdir->error); exit; } $relativepath=$ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; /* $ecmfile = new ECMFile($db); if (! empty($_GET["fileid"])) { $result=$ecmfile->fetch($_GET["fileid"]); if (! $result > 0) { dol_print_error($db,$ecmfile->error); exit; } } */ /******************************************************************* * ACTIONS * * Put here all code to do according to value of "action" parameter ********************************************************************/ // Rename file if (GETPOST('action') == 'update' && ! GETPOST('cancel')) { $error=0; $oldlabel=GETPOST('urlfile'); $newlabel=GETPOST('label'); //$db->begin(); $olddir=$ecmdir->getRelativePath(0); $olddir=$conf->ecm->dir_output.'/'.$olddir; $newdir=$olddir; $oldfile=$olddir.$oldlabel; $newfile=$newdir.$newlabel; //print $oldfile.' - '.$newfile; if ($newlabel != $oldlabel) { $result=dol_move($oldfile,$newfile); if (! $result) { $langs->load('errors'); $mesg='