Browse Source

Quality fixes reported by scrutinizer

Laurent Destailleur 9 years ago
parent
commit
724610ba5b

+ 1 - 1
htdocs/compta/prelevement/card.php

@@ -151,7 +151,7 @@ if ($id > 0)
 
 	if (GETPOST('error','alpha')!='')
 	{
-		print '<div class="error">'.$bon->ReadError(GETPOST('error','alpha')).'</div>';
+		print '<div class="error">'.$bon->getErrorString(GETPOST('error','alpha')).'</div>';
 	}
 
 	/*if ($action == 'credite')

+ 7 - 5
htdocs/compta/prelevement/class/bonprelevement.class.php

@@ -245,16 +245,18 @@ class BonPrelevement extends CommonObject
     }
 
     /**
-     *	Read errors
+     *	Return error string
      *
-     *  @param	int		$error 		id of error
-     *	@return	array 				Array of errors
+     *  @param	int		$error 		 Id of error
+     *	@return	string               Error string
      */
-    function ReadError($error)
+    function getErrorString($error)
     {
+        global $langs;
+        
         $errors = array();
 
-        $errors[1027] = "Date invalide";
+        $errors[1027] = $langs->trans("DateInvalid");
 
         return $errors[abs($error)];
     }

+ 6 - 5
htdocs/core/class/commonobject.class.php

@@ -1733,10 +1733,10 @@ abstract class CommonObject
      *  Save a new position (field rang) for details lines.
      *  You can choose to set position for lines with already a position or lines without any position defined.
      *
-     * 	@param		boolean		$renum				true to renum all already ordered lines, false to renum only not already ordered lines.
-     * 	@param		string		$rowidorder			ASC or DESC
-     * 	@param		boolean		$fk_parent_line		Table with fk_parent_line field or not
-     * 	@return		void
+     * 	@param		boolean		$renum			   True to renum all already ordered lines, false to renum only not already ordered lines.
+     * 	@param		string		$rowidorder		   ASC or DESC
+     * 	@param		boolean		$fk_parent_line    Table with fk_parent_line field or not
+     * 	@return		int                            <0 if KO, >0 if OK
      */
     function line_order($renum=false, $rowidorder='ASC', $fk_parent_line=true)
     {
@@ -1813,6 +1813,7 @@ abstract class CommonObject
 				dol_print_error($this->db);
 			}
 		}
+		return 1;
 	}
 
 	/**
@@ -3004,7 +3005,7 @@ abstract class CommonObject
     /**
      *	Set extra parameters
      *
-     *	@return	void
+     *	@return	int      <0 if KO, >0 if OK
      */
     function setExtraParameters()
     {

+ 3 - 3
htdocs/core/class/fileupload.class.php

@@ -219,7 +219,7 @@ class FileUpload
 	}
 
 	/**
-	 * Enter description here ...
+	 * getFileObject
 	 *
 	 * @param	string		$file_name		Filename
 	 * @return 	stdClass|NULL
@@ -247,7 +247,7 @@ class FileUpload
 	}
 
 	/**
-	 * Enter description here ...
+	 * getFileObjects
 	 *
 	 * @return	void
 	 */
@@ -295,7 +295,7 @@ class FileUpload
 	 * @param 	string	$file				File
 	 * @param 	string	$error				Error
 	 * @param	string	$index				Index
-	 * @return unknown|string
+	 * @return  boolean                     True if OK, False if KO
 	 */
 	protected function validate($uploaded_file, $file, $error, $index)
 	{

+ 0 - 166
htdocs/core/db/sqlite3.class.php

@@ -1271,158 +1271,6 @@ class DoliDBSqlite3 extends DoliDB
         }
     }
 
-    /**
-     * Cette fonction est l'equivalent de la fonction MONTH de MySql.
-     *
-     * @param 	string 		$date		Date
-     * @return 	string
-     */
-    public static function dbMONTH($date)
-    {
-        return date('n', strtotime($date));
-    }
-
-    /**
-     *  calcule du numéro de semaine
-     *
-     *  @param 	string	 	$date		Date
-     *  @param 	int 		$mode		Mode
-     *  @return	string
-     */
-    public static function dbWEEK($date, $mode = 0)
-    {
-        $arr = date_parse($date);
-        $calc_year = 0;
-        return self::calc_week($arr['year'], $arr['month'], $arr['day'], self::week_mode($mode), $calc_year);
-    }
-
-    /**
-     *  db_CURDATE
-     *
-     *  @return	string
-     */
-    public static function dbCURDATE() {
-        return date('Y-m-d');
-    }
-
-    /**
-     *  db_CURTIME
-     *
-     *  @return	string
-     */
-    public static function dbCURTIME() {
-        return date('H:i:s');
-    }
-
-    /**
-     *  dbWEEKDAY
-     *
-     *  @param	int		$date			Date
-     *  @return	double
-     */
-    public static function dbWEEKDAY($date) {
-        $arr = date_parse($date);
-        return self::calc_weekday(self::calc_daynr($arr['year'], $arr['month'], $arr['day']), 0);
-
-    }
-
-    /**
-     * Cette fonction est l'equivelent de la fonction date_format de MySQL.
-	 * @staticvar string $mysql_replacement	Les symboles formatage a remplacer
-	 *
-     * @param 	string $date 	la date dans un format ISO
-     * @param 	string $format 	la chaine de formatage
-     * @return 	string 			La date formatee.
-     */
-    public static function dbdateformat($date, $format)
-    {
-        static $mysql_replacement;
-        if (! isset($mysql_replacement)) {
-            $mysql_replacement = array(
-                '%' => '%',
-                'a' => 'D',
-                'b' => 'M',
-                'c' => 'n',
-                'D' => 'jS',
-                'd' => 'd',
-                'e' => 'j',
-                'f' => 'u',
-                'H' => 'H',
-                'h' => 'h',
-                'I' => 'h',
-                'i' => 'i',
-                'k' => 'H',
-                'l' => 'g',
-                'M' => 'F',
-                'm' => 'm',
-                'p' => 'A',
-                'r' => 'h:i:s A',
-                'S' => 's',
-                's' => 's',
-                'T' => 'H:i:s',
-                'W' => 'l',
-                'w' => 'w',
-                'Y' => 'Y',
-                'y' => 'y',
-            );
-        }
-
-        $fmt = '';
-        $lg = strlen($format);
-        $state = 0;
-        $timestamp = strtotime($date);
-        $yday = date('z', $timestamp);
-        $month = (integer) date("n", $timestamp);
-        $year = (integer) date("Y", $timestamp);
-        $day = (integer) date("d", $timestamp);
-        for($idx = 0; $idx < $lg; ++$idx) {
-            $char = $format[$idx];
-            if ($state == 0) {
-                if ($char == '%') {
-                    $state = 1;
-                } else {
-                    $fmt .= $char;
-                }
-            }
-            elseif ($state == 1) {
-                if (array_key_exists($char, $mysql_replacement)) {
-                    $fmt .= $mysql_replacement[$char];
-                } else {
-                    $calc_year = 0;
-                    switch ($char) {
-						case 'j':	// day of the year 001
-                            $char = sprintf("%03d", $yday+1);
-                            break;
-                        case 'U': // mode 0: semaine 0 = premiere semaine complète qui commence un dimanche
-                            $char = sprintf("%02d", self::calc_week($year, $month, $day, 4, $calc_year));
-                            break;
-                        case 'u': // mode 1: semaine 0 = première semaine de 4 jours. Début le dimanche
-                            $char = sprintf("%02d", self::calc_week($year, $month, $day, 1, $calc_year));
-                            break;
-                        case 'V': // mode 2: semaine 1 = premiere semaine complète qui commence un dimanche
-                            $char = sprintf("%02d", self::calc_week($year, $month, $day, 6, $calc_year));
-                            break;
-                        case 'v':  // mode 3: semaine 1 = premiere semaine de 4 jours. Début le lundi
-                            $char = sprintf("%02d", self::calc_week($year, $month, $day, 3, $calc_year));
-                            break;
-                        case 'X':
-                            self::calc_week($year, $month, $day, 6, $calc_year);
-                            $char = sprintf("%04d", $calc_year);
-                            break;
-                        case 'x':
-                            self::calc_week($year, $month, $day, 3, $calc_year);
-                            $char = sprintf("%04d", $calc_year);
-                            break;
-                    }
-                    $fmt .= $char;
-                }
-                $state = 0;
-            }
-        }
-        return date($fmt, strtotime($date));
-    }
-
-
     /**
      * calc_daynr
      *
@@ -1467,20 +1315,6 @@ class DoliDBSqlite3 extends DoliDB
       return (($year & 3) == 0 && ($year%100 || ($year%400 == 0 && $year)) ? 366 : 365);
     }
 
-    /**
-     * week_mode
-     *
-     * @param 	string	$mode		Mode
-     * @return	integer				Week format
-     */
-    private static function week_mode($mode) {
-        $week_format= ($mode & 7);
-        if (!($week_format & self::WEEK_MONDAY_FIRST)) {
-            $week_format^= self::WEEK_FIRST_WEEKDAY;
-        }
-        return $week_format;
-    }
-
 	/**
 	 * calc_week
 	 *

+ 2 - 2
htdocs/core/lib/geturl.lib.php

@@ -27,8 +27,8 @@
  * @param	string	  $url 				    URL to call.
  * @param	string    $postorget		    'POST', 'GET', 'HEAD', 'PUT', 'PUTALREADYFORMATED', 'DELETE'
  * @param	string    $param			    Parameters of URL (x=value1&y=value2) or may be a formated content with PUTALREADYFORMATED
- * @param	string    $followlocation		1=Follow location, 0=Do not follow
- * @param	array     $addheaders			Array of string to add into header. Example: ('Accept: application/xrds+xml', ....)
+ * @param	integer   $followlocation		1=Follow location, 0=Do not follow
+ * @param	string[]  $addheaders			Array of string to add into header. Example: ('Accept: application/xrds+xml', ....)
  * @return	array						    Returns an associative array containing the response from the server array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...)
  */
 function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addheaders=array())