New: Can rename a file
This commit is contained in:
parent
4cdf6af7d7
commit
56c85825f3
@ -455,17 +455,17 @@ class FormFile
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Show list of documents in a directory
|
* Show list of documents in a directory
|
||||||
* \param filearray Array of files loaded by dol_dir_list function
|
* @param filearray Array of files loaded by dol_dir_list function
|
||||||
* \param object Object on which document is linked to
|
* @param object Object on which document is linked to
|
||||||
* \param modulepart Value for modulepart used by download wrapper
|
* @param modulepart Value for modulepart used by download wrapper
|
||||||
* \param param Parameters on sort links
|
* @param param Parameters on sort links
|
||||||
* \param forcedownload Force to open dialog box "Save As" when clicking on file
|
* @param forcedownload Force to open dialog box "Save As" when clicking on file
|
||||||
* \param relativepath Relative path of docs (autodefined if not provided)
|
* @param relativepath Relative path of docs (autodefined if not provided)
|
||||||
* \param permtodelete Permission to delete
|
* @param permtodelete Permission to delete
|
||||||
* \param useinecm Change output for use in ecm module
|
* @param useinecm Change output for use in ecm module
|
||||||
* \param textifempty Text to show if filearray is empty
|
* @param textifempty Text to show if filearray is empty
|
||||||
* \return int <0 if KO, nb of files shown if OK
|
* @return int <0 if KO, nb of files shown if OK
|
||||||
*/
|
*/
|
||||||
function list_of_documents($filearray,$object,$modulepart,$param,$forcedownload=0,$relativepath='',$permtodelete=1,$useinecm=0,$textifempty='',$maxlength=0)
|
function list_of_documents($filearray,$object,$modulepart,$param,$forcedownload=0,$relativepath='',$permtodelete=1,$useinecm=0,$textifempty='',$maxlength=0)
|
||||||
{
|
{
|
||||||
@ -510,11 +510,9 @@ class FormFile
|
|||||||
print '<td align="right">'.dol_print_size($file['size'],1,1).'</td>';
|
print '<td align="right">'.dol_print_size($file['size'],1,1).'</td>';
|
||||||
print '<td align="center">'.dol_print_date($file['date'],"dayhour").'</td>';
|
print '<td align="center">'.dol_print_date($file['date'],"dayhour").'</td>';
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
//print ' ';
|
if (! empty($useinecm)) print '<a href="'.DOL_URL_ROOT.'/ecm/docfile.php?section='.$_REQUEST["section"].'&urlfile='.urlencode($file['name']).'">'.img_view().'</a> ';
|
||||||
if ($permtodelete)
|
if ($permtodelete) print '<a href="'.$url.'?id='.$object->id.'§ion='.$_REQUEST["section"].'&action=delete&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>';
|
||||||
print '<a href="'.$url.'?id='.$object->id.'§ion='.$_REQUEST["section"].'&action=delete&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>';
|
else print ' ';
|
||||||
else
|
|
||||||
print ' ';
|
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,8 +26,9 @@
|
|||||||
|
|
||||||
require("../main.inc.php");
|
require("../main.inc.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/ecm/class/htmlecm.form.class.php");
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/ecm/class/ecmdirectory.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
|
// Load traductions files
|
||||||
$langs->load("ecm");
|
$langs->load("ecm");
|
||||||
@ -48,9 +49,6 @@ if (!$user->rights->ecm->setup) accessforbidden();
|
|||||||
// Get parameters
|
// Get parameters
|
||||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||||
|
|
||||||
$section=$_GET["section"];
|
|
||||||
if (! $section) $section='misc';
|
|
||||||
$upload_dir = $conf->ecm->dir_output.'/'.$section;
|
|
||||||
|
|
||||||
$page=$_GET["page"];
|
$page=$_GET["page"];
|
||||||
$sortorder=$_GET["sortorder"];
|
$sortorder=$_GET["sortorder"];
|
||||||
@ -61,19 +59,29 @@ $offset = $limit * $page ;
|
|||||||
if (! $sortorder) $sortorder="ASC";
|
if (! $sortorder) $sortorder="ASC";
|
||||||
if (! $sortfield) $sortfield="label";
|
if (! $sortfield) $sortfield="label";
|
||||||
|
|
||||||
$fileid=$_REQUEST["fileid"];
|
$section=GETPOST("section");
|
||||||
if (! $fileid)
|
|
||||||
{
|
|
||||||
dol_print_error('',"ErrorParamNotDefined");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$section=$_REQUEST["section"];
|
|
||||||
if (! $section)
|
if (! $section)
|
||||||
{
|
{
|
||||||
dol_print_error('',"ErrorSectionParamNotDefined");
|
dol_print_error('','Error, section parameter missing');
|
||||||
exit;
|
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;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -97,6 +105,45 @@ if (! empty($_GET["fileid"]))
|
|||||||
* Put here all code to do according to value of "action" parameter
|
* 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='<div class="error">'.$langs->trans('ErrorFailToRenameFile',$oldfile,$newfile).'</div>';
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
//$db->commit();
|
||||||
|
$urlfile=$newlabel;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -109,18 +156,21 @@ if (! empty($_GET["fileid"]))
|
|||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$form=new Form($db);
|
$form=new Form($db);
|
||||||
$formecm=new FormEcm($db);
|
|
||||||
|
|
||||||
|
$fullpath=$conf->ecm->dir_output.'/'.$ecmdir->label.'/'.$urlfile;
|
||||||
|
|
||||||
|
$file->section_id=$ecmdir->id;
|
||||||
|
$file->label=$urlfile;
|
||||||
|
|
||||||
$head = ecm_prepare_head($ecmdir);
|
$head = ecm_file_prepare_head($file);
|
||||||
dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual"));
|
dol_fiche_head($head, 'card', $langs->trans("File"), 0, 'generic');
|
||||||
|
|
||||||
if ($_GET["action"] == 'edit')
|
if ($_GET["action"] == 'edit')
|
||||||
{
|
{
|
||||||
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print '<input type="hidden" name="fileid" value="'.$fileid.'">';
|
print '<input type="hidden" name="section" value="'.$section.'">';
|
||||||
|
print '<input type="hidden" name="urlfile" value="'.$urlfile.'">';
|
||||||
print '<input type="hidden" name="action" value="update">';
|
print '<input type="hidden" name="action" value="update">';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,11 +184,7 @@ $i=0;
|
|||||||
while ($tmpecmdir && $result > 0)
|
while ($tmpecmdir && $result > 0)
|
||||||
{
|
{
|
||||||
$tmpecmdir->ref=$tmpecmdir->label;
|
$tmpecmdir->ref=$tmpecmdir->label;
|
||||||
if ($i == 0 && $_GET["action"] == 'edit')
|
$s=$tmpecmdir->getNomUrl(1).$s;
|
||||||
{
|
|
||||||
$s='<input type="text" name="label" size="32" value="'.$tmpecmdir->label.'">';
|
|
||||||
}
|
|
||||||
else $s=$tmpecmdir->getNomUrl(1).$s;
|
|
||||||
if ($tmpecmdir->fk_parent)
|
if ($tmpecmdir->fk_parent)
|
||||||
{
|
{
|
||||||
$s=' -> '.$s;
|
$s=' -> '.$s;
|
||||||
@ -153,8 +199,11 @@ while ($tmpecmdir && $result > 0)
|
|||||||
|
|
||||||
print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> ';
|
print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> ';
|
||||||
print $s;
|
print $s;
|
||||||
|
print ' -> ';
|
||||||
|
if (GETPOST('action') == 'edit') print '<input type="text" name="label" size="64" value="'.$urlfile.'">';
|
||||||
|
else print $urlfile;
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
|
/*print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
|
||||||
if ($_GET["action"] == 'edit')
|
if ($_GET["action"] == 'edit')
|
||||||
{
|
{
|
||||||
print '<textarea class="flat" name="description" cols="80">';
|
print '<textarea class="flat" name="description" cols="80">';
|
||||||
@ -168,11 +217,11 @@ $userecm=new User($db);
|
|||||||
$userecm->fetch($ecmdir->fk_user_c);
|
$userecm->fetch($ecmdir->fk_user_c);
|
||||||
print $userecm->getNomUrl(1);
|
print $userecm->getNomUrl(1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
*/
|
||||||
print '<tr><td>'.$langs->trans("ECMCreationDate").'</td><td>';
|
print '<tr><td>'.$langs->trans("ECMCreationDate").'</td><td>';
|
||||||
print dol_print_date($ecmdir->date_c,'dayhour');
|
print dol_print_date(dol_filemtime($fullpath),'dayhour');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '<tr><td>'.$langs->trans("ECMDirectoryForFiles").'</td><td>';
|
/*print '<tr><td>'.$langs->trans("ECMDirectoryForFiles").'</td><td>';
|
||||||
//print $conf->ecm->dir_output;
|
|
||||||
print '/ecm/'.$relativepath;
|
print '/ecm/'.$relativepath;
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '<tr><td>'.$langs->trans("ECMNbOfDocs").'</td><td>';
|
print '<tr><td>'.$langs->trans("ECMNbOfDocs").'</td><td>';
|
||||||
@ -181,6 +230,7 @@ print '</td></tr>';
|
|||||||
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>';
|
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>';
|
||||||
print dol_print_size($totalsize);
|
print dol_print_size($totalsize);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
*/
|
||||||
if ($_GET["action"] == 'edit')
|
if ($_GET["action"] == 'edit')
|
||||||
{
|
{
|
||||||
print '<tr><td colspan="2" align="center">';
|
print '<tr><td colspan="2" align="center">';
|
||||||
@ -197,32 +247,36 @@ if ($_GET["action"] == 'edit')
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|
||||||
|
// Confirmation de la suppression d'une ligne categorie
|
||||||
if (! $_GET["action"] || $_GET["action"] == 'delete_section')
|
if ($_GET['action'] == 'delete_file')
|
||||||
|
{
|
||||||
|
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.urlencode($_GET["section"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile',$urlfile), 'confirm_deletefile', '', 1, 1);
|
||||||
|
if ($ret == 'html') print '<br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_GET["action"] != 'edit')
|
||||||
{
|
{
|
||||||
// Confirmation de la suppression d'une ligne categorie
|
|
||||||
if ($_GET['action'] == 'delete_section')
|
|
||||||
{
|
|
||||||
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.urlencode($_GET["section"]), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection');
|
|
||||||
if ($ret == 'html') print '<br>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($mesg) { print $mesg."<br>"; }
|
if ($mesg) { print $mesg."<br>"; }
|
||||||
|
|
||||||
|
|
||||||
// Construit fiche rubrique
|
|
||||||
|
|
||||||
|
|
||||||
// Actions buttons
|
// Actions buttons
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
|
if ($user->rights->ecm->setup)
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit§ion='.$section.'&urlfile='.urlencode($urlfile).'">'.$langs->trans('Edit').'</a>';
|
||||||
|
}
|
||||||
|
/*
|
||||||
if ($user->rights->ecm->setup)
|
if ($user->rights->ecm->setup)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=delete_section">'.$langs->trans('Delete').'</a>';
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=delete_file§ion='.$section.'&urlfile='.urlencode($urlfile).'">'.$langs->trans('Delete').'</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';
|
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
print '</div>';
|
print '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,7 @@ $offset = $conf->liste_limit * $page ;
|
|||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
|
|
||||||
$section=$_REQUEST["section"];
|
$section=GETPOST("section");
|
||||||
if (! $section)
|
if (! $section)
|
||||||
{
|
{
|
||||||
dol_print_error('',"ErrorSectionParamNotDefined");
|
dol_print_error('',"ErrorSectionParamNotDefined");
|
||||||
@ -66,12 +66,7 @@ if (! $section)
|
|||||||
|
|
||||||
// Load ecm object
|
// Load ecm object
|
||||||
$ecmdir = new ECMDirectory($db);
|
$ecmdir = new ECMDirectory($db);
|
||||||
if (empty($_REQUEST["section"]))
|
$result=$ecmdir->fetch(GETPOST("section"));
|
||||||
{
|
|
||||||
dol_print_error('','Error, section parameter missing');
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$result=$ecmdir->fetch($_REQUEST["section"]);
|
|
||||||
if (! $result > 0)
|
if (! $result > 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$ecmdir->error);
|
dol_print_error($db,$ecmdir->error);
|
||||||
@ -155,7 +150,9 @@ if (GETPOST('action') == 'confirm_deletedir' && GETPOST('confirm') == 'yes')
|
|||||||
// Update description
|
// Update description
|
||||||
if (GETPOST('action') == 'update' && ! GETPOST('cancel'))
|
if (GETPOST('action') == 'update' && ! GETPOST('cancel'))
|
||||||
{
|
{
|
||||||
$db->begin();
|
$error=0;
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
$oldlabel=$ecmdir->label;
|
$oldlabel=$ecmdir->label;
|
||||||
$olddir=$ecmdir->getRelativePath(0);
|
$olddir=$ecmdir->getRelativePath(0);
|
||||||
@ -167,8 +164,6 @@ if (GETPOST('action') == 'update' && ! GETPOST('cancel'))
|
|||||||
$result=$ecmdir->update($user);
|
$result=$ecmdir->update($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$error=0;
|
|
||||||
|
|
||||||
// Try to rename file if changed
|
// Try to rename file if changed
|
||||||
if ($oldlabel != $ecmdir->label
|
if ($oldlabel != $ecmdir->label
|
||||||
&& file_exists($olddir))
|
&& file_exists($olddir))
|
||||||
@ -227,7 +222,7 @@ foreach($filearray as $key => $file)
|
|||||||
|
|
||||||
|
|
||||||
$head = ecm_prepare_head($ecmdir);
|
$head = ecm_prepare_head($ecmdir);
|
||||||
dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual"));
|
dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual"), '', 'dir');
|
||||||
|
|
||||||
if ($_GET["action"] == 'edit')
|
if ($_GET["action"] == 'edit')
|
||||||
{
|
{
|
||||||
@ -285,7 +280,6 @@ print '<tr><td>'.$langs->trans("ECMCreationDate").'</td><td>';
|
|||||||
print dol_print_date($ecmdir->date_c,'dayhour');
|
print dol_print_date($ecmdir->date_c,'dayhour');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '<tr><td>'.$langs->trans("ECMDirectoryForFiles").'</td><td>';
|
print '<tr><td>'.$langs->trans("ECMDirectoryForFiles").'</td><td>';
|
||||||
//print $conf->ecm->dir_output;
|
|
||||||
print '/ecm/'.$relativepath;
|
print '/ecm/'.$relativepath;
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '<tr><td>'.$langs->trans("ECMNbOfDocs").'</td><td>';
|
print '<tr><td>'.$langs->trans("ECMNbOfDocs").'</td><td>';
|
||||||
|
|||||||
@ -8,6 +8,7 @@ ErrorBadUrl=Url %s is wrong
|
|||||||
ErrorLoginAlreadyExists=Login %s already exists.
|
ErrorLoginAlreadyExists=Login %s already exists.
|
||||||
ErrorGroupAlreadyExists=Group %s already exists.
|
ErrorGroupAlreadyExists=Group %s already exists.
|
||||||
ErrorRecordNotFound=Record not found.
|
ErrorRecordNotFound=Record not found.
|
||||||
|
ErrorFailToRenameFile=Failed to rename file '<b>%s</b>' into '<b>%s</b>'.
|
||||||
ErrorFailToDeleteFile=Failed to remove file '<b>%s</b>'.
|
ErrorFailToDeleteFile=Failed to remove file '<b>%s</b>'.
|
||||||
ErrorFailToCreateFile=Failed to create file '<b>%s</b>'.
|
ErrorFailToCreateFile=Failed to create file '<b>%s</b>'.
|
||||||
ErrorFailToRenameDir=Failed to rename directory '<b>%s</b>' into '<b>%s</b>'.
|
ErrorFailToRenameDir=Failed to rename directory '<b>%s</b>' into '<b>%s</b>'.
|
||||||
|
|||||||
@ -9,6 +9,7 @@ ErrorLoginAlreadyExists=Le login %s existe déjà.
|
|||||||
ErrorGroupAlreadyExists=Le groupe %s existe déjà.
|
ErrorGroupAlreadyExists=Le groupe %s existe déjà.
|
||||||
ErrorRecordNotFound=Enregistrement non trouvé.
|
ErrorRecordNotFound=Enregistrement non trouvé.
|
||||||
ErrorDuplicateTrigger=Un fichier trigger de classe '<b>%s</b>' est présent plusieurs fois. Supprimer le doublon du répertoire '<b>%s</b>'.
|
ErrorDuplicateTrigger=Un fichier trigger de classe '<b>%s</b>' est présent plusieurs fois. Supprimer le doublon du répertoire '<b>%s</b>'.
|
||||||
|
ErrorFailToRenameFile=Echec du renommage du fichier '<b>%s</b>' en '<b>%s</b>'.
|
||||||
ErrorFailToCreateFile=Echec de la création du fichier '<b>%s</b>'.
|
ErrorFailToCreateFile=Echec de la création du fichier '<b>%s</b>'.
|
||||||
ErrorFailToDeleteFile=Echec de l'effacement du fichier '<b>%s</b>'.
|
ErrorFailToDeleteFile=Echec de l'effacement du fichier '<b>%s</b>'.
|
||||||
ErrorFailToRenameDir=Echec du renommage du répertoire '<b>%s</b>' en '<b>%s</b>'.
|
ErrorFailToRenameDir=Echec du renommage du répertoire '<b>%s</b>' en '<b>%s</b>'.
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2008 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -18,11 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/lib/ecm.lib.php
|
* \file htdocs/lib/ecm.lib.php
|
||||||
\brief Ensemble de fonctions de base pour le module ecm
|
* \brief Ensemble de fonctions de base pour le module ecm
|
||||||
\ingroup ecm
|
* \ingroup ecm
|
||||||
\version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
function ecm_prepare_head($obj)
|
function ecm_prepare_head($obj)
|
||||||
{
|
{
|
||||||
@ -38,13 +39,19 @@ function ecm_prepare_head($obj)
|
|||||||
return $head;
|
return $head;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function ecm_file_prepare_head($obj)
|
||||||
\file htdocs/lib/invoice.lib.php
|
{
|
||||||
\brief Ensemble de fonctions de base pour le module factures
|
global $langs, $conf, $user;
|
||||||
\version $Id$
|
$h = 0;
|
||||||
|
$head = array();
|
||||||
|
|
||||||
Ensemble de fonctions de base de dolibarr sous forme d'include
|
$head[$h][0] = DOL_URL_ROOT.'/ecm/docfile.php?section='.$obj->section_id.'&urlfile='.urlencode($obj->label);
|
||||||
*/
|
$head[$h][1] = $langs->trans("Card");
|
||||||
|
$head[$h][2] = 'card';
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
return $head;
|
||||||
|
}
|
||||||
|
|
||||||
function ecm_prepare_head_fm($fac)
|
function ecm_prepare_head_fm($fac)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -374,20 +374,49 @@ function dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
|
|||||||
global $conf;
|
global $conf;
|
||||||
$result=false;
|
$result=false;
|
||||||
|
|
||||||
dol_syslog("files.lib.php::dol_copy srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask);
|
dol_syslog("files.lib.php::dol_copy srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwritifexists=".$overwriteifexists);
|
||||||
if ($overwriteifexists || ! dol_is_file($destfile))
|
if ($overwriteifexists || ! dol_is_file($destfile))
|
||||||
{
|
{
|
||||||
$result=@copy($srcfile, $destfile);
|
$newpathofsrcfile=dol_osencode($srcfile);
|
||||||
|
$newpathofdestfile=dol_osencode($destfile);
|
||||||
|
|
||||||
|
$result=@copy($newpathofsrcfile, $newpathofdestfile);
|
||||||
//$result=copy($srcfile, $destfile); // To see errors, remove @
|
//$result=copy($srcfile, $destfile); // To see errors, remove @
|
||||||
if (! $result) dol_syslog("files.lib.php::dol_copy failed", LOG_WARNING);
|
if (! $result) dol_syslog("files.lib.php::dol_copy failed", LOG_WARNING);
|
||||||
if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
|
if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
|
||||||
@chmod($file, octdec($newmask));
|
@chmod($newpathofsrcfile, octdec($newmask));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move a file into another name
|
||||||
|
* @param $srcfile Source file (can't be a directory)
|
||||||
|
* @param $destfile Destination file (can't be a directory)
|
||||||
|
* @param $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK)
|
||||||
|
* @param $overwriteifexists Overwrite file if exists (1 by default)
|
||||||
|
* @return boolean True if OK, false if KO
|
||||||
|
*/
|
||||||
|
function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
$result=false;
|
||||||
|
|
||||||
|
dol_syslog("files.lib.php::dol_move srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwritifexists=".$overwriteifexists);
|
||||||
|
if ($overwriteifexists || ! dol_is_file($destfile))
|
||||||
|
{
|
||||||
|
$newpathofsrcfile=dol_osencode($srcfile);
|
||||||
|
$newpathofdestfile=dol_osencode($destfile);
|
||||||
|
|
||||||
|
$result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @
|
||||||
|
if (! $result) dol_syslog("files.lib.php::dol_move failed", LOG_WARNING);
|
||||||
|
if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
|
||||||
|
@chmod($newpathofsrcfile, octdec($newmask));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Move an uploaded file after some controls.
|
* \brief Move an uploaded file after some controls.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user