From 9a43c8a14f665b09903bd9f0798d36547accbf0c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 Nov 2011 12:59:06 +0100 Subject: [PATCH] Qual: Removed useless parameter --- htdocs/comm/propal/document.php | 2 +- htdocs/commande/document.php | 2 +- htdocs/compta/facture/document.php | 2 +- htdocs/core/lib/files.lib.php | 134 +++++++++++++++-------------- htdocs/societe/document.php | 2 +- 5 files changed, 75 insertions(+), 67 deletions(-) diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 93eb16b0762..29ffea851c9 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -108,7 +108,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $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). - dol_delete_file($file,0,0,0,'FILE_DELETE',$object); + dol_delete_file($file,0,0,0,$object); $mesg = '
'.$langs->trans("FileWasRemoved").'
'; } } diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 2853ae6b0c3..2833215960d 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -111,7 +111,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $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). - dol_delete_file($file,0,0,0,'FILE_DELETE',$object); + dol_delete_file($file,0,0,0,$object); $mesg = '
'.$langs->trans("FileWasRemoved").'
'; } } diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 17c0e3bdb8c..f6ceb457ea5 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -113,7 +113,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $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). - dol_delete_file($file,0,0,0,'FILE_DELETE',$object); + dol_delete_file($file,0,0,0,$object); $mesg = '
'.$langs->trans("FileWasRemoved").'
'; } } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index ec10c68f2e4..94872285ddc 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -23,8 +23,9 @@ /** * 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) { @@ -37,15 +38,16 @@ function dol_getwebuser($mode) /** * 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 $excludefilter Array of Regex for exclude filter (example: array('\.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), 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') + * + * @param string $path Starting path from which to search + * @param string $types Can be "directories", "files", or "all" + * @param int $recursive Determines whether subdirectories are searched + * @param string $filter Regex for include filter + * @param string $excludefilter Array of Regex for exclude filter (example: array('\.meta$','^\.') + * @param string $sortcriteria Sort criteria ("","name","date","size") + * @param string $sortorder Sort order (SORT_ASC, SORT_DESC) + * @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) { @@ -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 - * @param $a File 1 - * @param $b File 2 - * @return int 1, 0, 1 + * + * @param string $a File 1 + * @param string $b File 2 + * @return int 1, 0, 1 */ function dol_compare_file($a, $b) { @@ -186,12 +189,11 @@ function dol_compare_file($a, $b) /** * Return mime type of a file * - * @param file Filename we looking for MIME type - * @param 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 - * @return string Return a mime type family - * (text/xxx, application/xxx, image/xxx, audio, video, archive) - * @see image_format_supported (images.lib.php) + * @param string $file Filename we looking for MIME type + * @param string $default Default mime type if extension not found in known list + * @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 (text/xxx, application/xxx, image/xxx, audio, video, archive) + * @see image_format_supported (images.lib.php) */ 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 - * @return boolean True if it's a directory, False if not found + * @param string $folder Name of folder + * @return boolean True if it's a directory, False if not found */ function dol_is_dir($folder) { @@ -310,8 +312,8 @@ function dol_is_dir($folder) /** * Return if path is a file * - * @param $pathoffile - * @return boolean True or false + * @param string $pathoffile Path of file + * @return boolean True or false */ function dol_is_file($pathoffile) { @@ -322,8 +324,8 @@ function dol_is_file($pathoffile) /** * Return if path is an URL * - * @param $url - * @return boolean True or false + * @param string $url Url + * @return boolean True or false */ function dol_is_url($url) { @@ -339,8 +341,8 @@ function dol_is_url($url) /** * Test if a folder is empty * - * @param folder Name of folder - * @return boolean True if dir is empty or non-existing, False if it contains files + * @param string $folder Name of folder + * @return boolean True if dir is empty or non-existing, False if it contains files */ function dol_dir_is_emtpy($folder) { @@ -365,8 +367,9 @@ function dol_dir_is_emtpy($folder) /** * 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) { @@ -395,8 +398,9 @@ function dol_count_nb_of_line($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) { @@ -406,8 +410,9 @@ function dol_filesize($pathoffile) /** * 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) { @@ -446,11 +451,12 @@ function dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1) /** * 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 + * + * @param string $srcfile Source file (can't be a directory) + * @param string $destfile Destination file (can't be a directory) + * @param string $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK) + * @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) { @@ -475,13 +481,14 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1) /** * Move an uploaded file after some controls. * 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 allowoverwrite 1=Overwrite target file if it already exists - * @param disablevirusscan 1=Disable virus scan - * @param uploaderrorcode Value of upload error code ($_FILES['field']['error']) - * @param notrigger Disable all triggers - * @return int >0 if OK, <0 or string if KO + * + * @param string $src_file Source full path filename ($_FILES['field']['tmp_name']) + * @param string $dest_file Target full path filename + * @param int $allowoverwrite 1=Overwrite target file if it already exists + * @param int $disablevirusscan 1=Disable virus scan + * @param string $uploaderrorcode Value of upload error code ($_FILES['field']['error']) + * @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) { @@ -606,15 +613,14 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable /** * Remove a file or several files with a mask * - * @param file File to delete or mask of file to delete - * @param disableglob Disable usage of glob like * - * @param nophperrors Disable all PHP output errors - * @param notrigger Disable all triggers - * @param triggercode Code of trigger TODO ???? why ? - * @param object Object for trigger - * @return boolean True if file is deleted, False if error + * @param string $file File to delete or mask of file to delete + * @param int $disableglob Disable usage of glob like * + * @param int $nophperrors Disable all PHP output errors + * @param int $notrigger Disable all triggers + * @param Object $object Object + * @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; @@ -635,10 +641,11 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$trigg if (! is_object($object)) $object=(object) 'dummy'; $object->src_file=$file; + // TODO Replace trigger by a hook. Triggers must be used for business events only. // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $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; } // 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). * If directory is not empty, return false * - * @param dir Directory to delete - * @param nophperrors Disable all PHP output errors - * @return boolean True if success, false if error + * @param string $dir Directory to delete + * @param int $nophperrors Disable all PHP output errors + * @return boolean True if success, false if error */ 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). * 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 donotdeletefile 1=Do not delete physically file - * @return string Message with result of upload and store. + * + * @param int $filenb File nb to delete + * @param int $donotupdatesession 1=Do not edit _SESSION variable + * @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) { diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index d4855b58f4a..4b7057125c4 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -116,7 +116,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') if ($object->fetch($socid)) { $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 = '
'.$langs->trans("FileWasRemoved").'
'; } }