Qual: Removed useless parameter

This commit is contained in:
Laurent Destailleur
2011-11-12 12:59:06 +01:00
parent 3f495ef3b5
commit 9a43c8a14f
5 changed files with 75 additions and 67 deletions

View File

@@ -108,7 +108,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$upload_dir = $conf->propale->dir_output . "/" . dol_sanitizeFileName($object->ref); $upload_dir = $conf->propale->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,'FILE_DELETE',$object); dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>'; $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
} }
} }

View File

@@ -111,7 +111,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,'FILE_DELETE',$object); dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>'; $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
} }
} }

View File

@@ -113,7 +113,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,'FILE_DELETE',$object); dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>'; $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
} }
} }

View File

@@ -23,8 +23,9 @@
/** /**
* Return user/group account of web server * Return user/group account of web server
* @param $mode 'user' or 'group' *
* @return string * @param string $mode 'user' or 'group'
* @return string Return user or group of web server
*/ */
function dol_getwebuser($mode) function dol_getwebuser($mode)
{ {
@@ -37,15 +38,16 @@ function dol_getwebuser($mode)
/** /**
* Scan a directory and return a list of files/directories. * Scan a directory and return a list of files/directories.
* Content for string is UTF8 and dir separator is "/". * 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 string $path Starting path from which to search
* @param $recursive Determines whether subdirectories are searched * @param string $types Can be "directories", "files", or "all"
* @param $filter Regex for include filter * @param int $recursive Determines whether subdirectories are searched
* @param $excludefilter Array of Regex for exclude filter (example: array('\.meta$','^\.') * @param string $filter Regex for include filter
* @param $sortcriteria Sort criteria ("","name","date","size") * @param string $excludefilter Array of Regex for exclude filter (example: array('\.meta$','^\.')
* @param $sortorder Sort order (SORT_ASC, SORT_DESC) * @param string $sortcriteria Sort criteria ("","name","date","size")
* @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 * @param string $sortorder Sort order (SORT_ASC, SORT_DESC)
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file') * @param int $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) function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
{ {
@@ -152,9 +154,10 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
/** /**
* Fast compare of 2 files identified by their properties ->name, ->date and ->size * Fast compare of 2 files identified by their properties ->name, ->date and ->size
* @param $a File 1 *
* @param $b File 2 * @param string $a File 1
* @return int 1, 0, 1 * @param string $b File 2
* @return int 1, 0, 1
*/ */
function dol_compare_file($a, $b) function dol_compare_file($a, $b)
{ {
@@ -186,12 +189,11 @@ function dol_compare_file($a, $b)
/** /**
* Return mime type of a file * Return mime type of a file
* *
* @param file Filename we looking for MIME type * @param string $file Filename we looking for MIME type
* @param default Default mime type if extension not found in known list * @param string $default Default mime type if extension not found in known list
* @param mode 0=Return full mime, 1=otherwise short mime string, 2=image for mime type, 3=source language * @param int $mode 0=Return full mime, 1=otherwise short mime string, 2=image for mime type, 3=source language
* @return string Return a mime type family * @return string Return a mime type family (text/xxx, application/xxx, image/xxx, audio, video, archive)
* (text/xxx, application/xxx, image/xxx, audio, video, archive) * @see image_format_supported (images.lib.php)
* @see image_format_supported (images.lib.php)
*/ */
function dol_mimetype($file,$default='application/octet-stream',$mode=0) function dol_mimetype($file,$default='application/octet-stream',$mode=0)
{ {
@@ -295,10 +297,10 @@ function dol_mimetype($file,$default='application/octet-stream',$mode=0)
/** /**
* Test if filename is a directory * Test if filename is a directory
* *
* @param folder Name of folder * @param string $folder Name of folder
* @return boolean True if it's a directory, False if not found * @return boolean True if it's a directory, False if not found
*/ */
function dol_is_dir($folder) function dol_is_dir($folder)
{ {
@@ -310,8 +312,8 @@ function dol_is_dir($folder)
/** /**
* Return if path is a file * Return if path is a file
* *
* @param $pathoffile * @param string $pathoffile Path of file
* @return boolean True or false * @return boolean True or false
*/ */
function dol_is_file($pathoffile) function dol_is_file($pathoffile)
{ {
@@ -322,8 +324,8 @@ function dol_is_file($pathoffile)
/** /**
* Return if path is an URL * Return if path is an URL
* *
* @param $url * @param string $url Url
* @return boolean True or false * @return boolean True or false
*/ */
function dol_is_url($url) function dol_is_url($url)
{ {
@@ -339,8 +341,8 @@ function dol_is_url($url)
/** /**
* Test if a folder is empty * Test if a folder is empty
* *
* @param folder Name of folder * @param string $folder Name of folder
* @return boolean True if dir is empty or non-existing, False if it contains files * @return boolean True if dir is empty or non-existing, False if it contains files
*/ */
function dol_dir_is_emtpy($folder) function dol_dir_is_emtpy($folder)
{ {
@@ -365,8 +367,9 @@ function dol_dir_is_emtpy($folder)
/** /**
* Count number of lines in a file * Count number of lines in a file
* @param file Filename *
* @return int <0 if KO, Number of lines in files if OK * @param string $file Filename
* @return int <0 if KO, Number of lines in files if OK
*/ */
function dol_count_nb_of_line($file) function dol_count_nb_of_line($file)
{ {
@@ -395,8 +398,9 @@ function dol_count_nb_of_line($file)
/** /**
* Return size of a file * Return size of a file
* @param $pathoffile *
* @return string File size * @param tring $pathoffile Path of file
* @return string File size
*/ */
function dol_filesize($pathoffile) function dol_filesize($pathoffile)
{ {
@@ -406,8 +410,9 @@ function dol_filesize($pathoffile)
/** /**
* Return time of a file * Return time of a file
* @param $pathoffile *
* @return timestamp Time of file * @param string $pathoffile Path of file
* @return timestamp Time of file
*/ */
function dol_filemtime($pathoffile) function dol_filemtime($pathoffile)
{ {
@@ -446,11 +451,12 @@ function dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
/** /**
* Move a file into another name * 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 string $srcfile Source file (can't be a directory)
* @param $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK) * @param string $destfile Destination file (can't be a directory)
* @param $overwriteifexists Overwrite file if exists (1 by default) * @param string $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK)
* @return boolean True if OK, false if KO * @param int $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) function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
{ {
@@ -475,13 +481,14 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
/** /**
* Move an uploaded file after some controls. * Move an uploaded file after some controls.
* If there is errors (virus found, antivir in error, bad filename), file is not moved. * If there is errors (virus found, antivir in error, bad filename), file is not moved.
* @param src_file Source full path filename ($_FILES['field']['tmp_name']) *
* @param dest_file Target full path filename * @param string $src_file Source full path filename ($_FILES['field']['tmp_name'])
* @param allowoverwrite 1=Overwrite target file if it already exists * @param string $dest_file Target full path filename
* @param disablevirusscan 1=Disable virus scan * @param int $allowoverwrite 1=Overwrite target file if it already exists
* @param uploaderrorcode Value of upload error code ($_FILES['field']['error']) * @param int $disablevirusscan 1=Disable virus scan
* @param notrigger Disable all triggers * @param string $uploaderrorcode Value of upload error code ($_FILES['field']['error'])
* @return int >0 if OK, <0 or string if KO * @param int $notrigger Disable all triggers
* @return int >0 if OK, <0 or string if KO
*/ */
function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $notrigger=0) function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $notrigger=0)
{ {
@@ -606,15 +613,14 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
/** /**
* Remove a file or several files with a mask * Remove a file or several files with a mask
* *
* @param file File to delete or mask of file to delete * @param string $file File to delete or mask of file to delete
* @param disableglob Disable usage of glob like * * @param int $disableglob Disable usage of glob like *
* @param nophperrors Disable all PHP output errors * @param int $nophperrors Disable all PHP output errors
* @param notrigger Disable all triggers * @param int $notrigger Disable all triggers
* @param triggercode Code of trigger TODO ???? why ? * @param Object $object Object
* @param object Object for trigger * @return boolean True if file is deleted, False if error
* @return boolean True if file is deleted, False if error
*/ */
function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$triggercode='FILE_DELETE',$object=null) function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$object=null)
{ {
global $db, $conf, $user, $langs; global $db, $conf, $user, $langs;
@@ -635,10 +641,11 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$trigg
if (! is_object($object)) $object=(object) 'dummy'; if (! is_object($object)) $object=(object) 'dummy';
$object->src_file=$file; $object->src_file=$file;
// TODO Replace trigger by a hook. Triggers must be used for business events only.
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db); $interface=new Interfaces($db);
$result=$interface->run_triggers($triggercode,$object,$user,$langs,$conf); $result=$interface->run_triggers('FILE_DELETE',$object,$user,$langs,$conf);
if ($result < 0) { $error++; $errors=$interface->errors; } if ($result < 0) { $error++; $errors=$interface->errors; }
// Fin appel triggers // Fin appel triggers
} }
@@ -660,9 +667,9 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$trigg
* Remove a directory (not recursive, so content must be empty). * Remove a directory (not recursive, so content must be empty).
* If directory is not empty, return false * If directory is not empty, return false
* *
* @param dir Directory to delete * @param string $dir Directory to delete
* @param nophperrors Disable all PHP output errors * @param int $nophperrors Disable all PHP output errors
* @return boolean True if success, false if error * @return boolean True if success, false if error
*/ */
function dol_delete_dir($dir,$nophperrors=0) function dol_delete_dir($dir,$nophperrors=0)
{ {
@@ -886,10 +893,11 @@ function dol_add_file_process($upload_dir,$allowoverwrite=0,$donotupdatesession=
/** /**
* Remove an uploaded file (for example after submitting a new file a mail form). * Remove an uploaded file (for example after submitting a new file a mail form).
* All information used are in db, conf, langs, user and _FILES. * All information used are in db, conf, langs, user and _FILES.
* @param filenb File nb to delete *
* @param donotupdatesession 1=Do not edit _SESSION variable * @param int $filenb File nb to delete
* @param donotdeletefile 1=Do not delete physically file * @param int $donotupdatesession 1=Do not edit _SESSION variable
* @return string Message with result of upload and store. * @param int $donotdeletefile 1=Do not delete physically file
* @return string Message with result of upload and store.
*/ */
function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile=0) function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile=0)
{ {

View File

@@ -116,7 +116,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
if ($object->fetch($socid)) if ($object->fetch($socid))
{ {
$file = $upload_dir . "/" . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir . "/" . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,'FILE_DELETE',$object); dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>'; $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
} }
} }