Browse Source

Fix scrutinizer

Laurent Destailleur 10 years ago
parent
commit
5c5f725a34

+ 6 - 4
htdocs/comm/action/peruser.php

@@ -893,7 +893,8 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
 		$title1='';$title2='';
 		if (isset($cases1[$h]) && $cases1[$h] != '')
 		{
-			$title1=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
+			//$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
+			if (count($cases1[$h]) > 1) $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
 			$string1=' ';
 			$style1='peruser_notbusy';
 			foreach($cases1[$h] as $id => $ev)
@@ -903,7 +904,8 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
 		}
 		if (isset($cases2[$h]) && $cases2[$h] != '')
 		{
-			$title2=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
+			//$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
+			if (count($cases2[$h]) > 1) $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
 			$string2=' ';
 			$style2='peruser_notbusy';
 			foreach($cases2[$h] as $id => $ev)
@@ -919,7 +921,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
 		{
 			$ids=array_keys($cases1[$h]);
 			$output = array_slice($cases1[$h], 0, 1);
-			if ($output[0]['string']) $title1.=' - '.$output[0]['string'];
+			if ($output[0]['string']) $title1.=($title1?' - ':'').$output[0]['string'];
 			if ($output[0]['color']) $color1 = $output[0]['color'];
 		}
 		else if (count($cases1[$h]) > 1) $color1='222222';
@@ -928,7 +930,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
 		{
 			$ids=array_keys($cases2[$h]);
 			$output = array_slice($cases2[$h], 0, 1);
-			if ($output[0]['string']) $title2.=' - '.$output[0]['string'];
+			if ($output[0]['string']) $title2.=($title2?' - ':'').$output[0]['string'];
 			if ($output[0]['color']) $color2 = $output[0]['color'];
 		}
 		else if (count($cases2[$h]) > 1) $color2='222222';

+ 23 - 23
htdocs/core/class/mobiledetect.class.php

@@ -1073,39 +1073,37 @@ class MobileDetect
 
     /**
      * Check the version of the given property in the User-Agent.
-     * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
+     * Will return a string or float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
      *
-     * @param string $propertyName The name of the property. See self::getProperties() array
-     *                              keys for all possible properties.
-     * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
-     *                      self::VERSION_TYPE_FLOAT indicating a float value. This parameter
-     *                      is optional and defaults to self::VERSION_TYPE_STRING. Passing an
-     *                      invalid parameter will default to the this type as well.
+     * @param string $propertyName 	The name of the property. See self::getProperties() array keys for all possible properties (Ex: 'iPad', 'Android', ...).
+     * @param string $type 			Either self::VERSION_TYPE_STRING to get a string value or
+     *                      		self::VERSION_TYPE_FLOAT indicating a float value. This parameter
+     *                      		is optional and defaults to self::VERSION_TYPE_STRING. Passing an
+     *                      		invalid parameter will default to this type as well.
      *
-     * @return string|float The version of the property we are trying to extract.
+     * @return string|float|boolean The version of the property we are trying to extract.
      */
     public function version($propertyName, $type = self::VERSION_TYPE_STRING)
     {
-        if (empty($propertyName)) {
-            return false;
-        }
+        if (empty($propertyName)) return false;
 
         //set the $type to the default if we don't recognize the type
-        if ($type != self::VERSION_TYPE_STRING && $type != self::VERSION_TYPE_FLOAT) {
+        if ($type != self::VERSION_TYPE_STRING && $type != self::VERSION_TYPE_FLOAT)
+        {
             $type = self::VERSION_TYPE_STRING;
         }
 
         $properties = self::getProperties();
 
         // Check if the property exists in the properties array.
-        if (array_key_exists($propertyName, $properties)) {
-
+        if (array_key_exists($propertyName, $properties))
+        {
             // Prepare the pattern to be matched.
             // Make sure we always deal with an array (string is converted).
             $properties[$propertyName] = (array) $properties[$propertyName];
 
-            foreach ($properties[$propertyName] as $propertyMatchString) {
-
+            foreach ($properties[$propertyName] as $propertyMatchString)
+            {
                 $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
 
                 // Escape the special character which is the delimiter.
@@ -1114,14 +1112,13 @@ class MobileDetect
                 // Identify and extract the version.
                 preg_match('/'.$propertyPattern.'/is', $this->userAgent, $match);
 
-                if (!empty($match[1])) {
+                if (!empty($match[1]))
+                {
                     $version = ( $type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1] );
 
                     return $version;
                 }
-
             }
-
         }
 
         return false;
@@ -1130,7 +1127,7 @@ class MobileDetect
     /**
      * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
      *
-     * @return string One of the self::MOBILE_GRADE_* constants.
+     * @return string 		One of the self::MOBILE_GRADE_* constants.
      */
     public function mobileGrade()
     {
@@ -1210,7 +1207,8 @@ class MobileDetect
             // @reference: http://my.opera.com/community/openweb/idopera/
             $this->version('Opera', self::VERSION_TYPE_FLOAT)>=10 && !$isMobile
 
-        ){
+        )
+        {
             return self::MOBILE_GRADE_A;
         }
 
@@ -1231,7 +1229,8 @@ class MobileDetect
 
             // @todo: report this (tested on Nokia N71)
             $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT)>=11 && $this->is('SymbianOS')
-        ){
+        )
+        {
             return self::MOBILE_GRADE_B;
         }
 
@@ -1241,7 +1240,8 @@ class MobileDetect
             // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
             $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT)<=5.2
 
-        ){
+        )
+        {
             return self::MOBILE_GRADE_C;
         }
 

+ 9 - 5
htdocs/core/db/DoliDB.class.php

@@ -137,8 +137,12 @@ abstract class DoliDB implements Database
 			{
 				$this->transaction_opened=0;
 				dol_syslog("COMMIT Transaction".($log?' '.$log:''),LOG_DEBUG);
+				return 1;
+			}
+			else
+			{
+				return 0;
 			}
-			return $ret;
 		}
 		else
 		{
@@ -248,7 +252,7 @@ abstract class DoliDB implements Database
 	/**
 	 *	Return last error label
 	 *
-	 *	@return	    string	lasterror
+	 *	@return	    string		Last error
 	 */
 	function lasterror()
 	{
@@ -260,9 +264,9 @@ abstract class DoliDB implements Database
 	 * 	19700101020000 -> 3600 with TZ+1 and gmt=0
 	 * 	19700101020000 -> 7200 whaterver is TZ if gmt=1
 	 *
-	 * 	@param	string	$string		Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
-	 *	@param	int		$gm			1=Input informations are GMT values, otherwise local to server TZ
-	 *	@return	date				Date TMS
+	 * 	@param	string				$string		Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
+	 *	@param	int					$gm			1=Input informations are GMT values, otherwise local to server TZ
+	 *	@return	timestamp|string				Date TMS
 	 */
 	function jdate($string, $gm=false)
 	{

+ 6 - 2
htdocs/core/db/mssql.class.php

@@ -255,8 +255,12 @@ class DoliDBMssql extends DoliDB
 			{
 				$this->transaction_opened=0;
 				dol_syslog("COMMIT Transaction",LOG_DEBUG);
+				return 1;
+			}
+			else
+			{
+				return 0;
 			}
-			return $ret;
 		}
 		else
 		{
@@ -672,7 +676,7 @@ class DoliDBMssql extends DoliDB
 	 *
 	 *  @param	string		$database	Name of database
 	 *  @param	string		$table		Nmae of table filter ('xxx%')
-	 *  @return	resource				Resource
+     *  @return	array					List of tables in an array
 	 */
 	function DDLListTables($database,$table='')
 	{

+ 1 - 1
htdocs/core/db/mysql.class.php

@@ -585,7 +585,7 @@ class DoliDBMysql extends DoliDB
 	 *
 	 *  @param	string		$database	Name of database
 	 *  @param	string		$table		Nmae of table filter ('xxx%')
-	 *  @return	resource				Resource
+	 *  @return	array					List of tables in an array
 	 */
 	function DDLListTables($database, $table='')
 	{

+ 1 - 1
htdocs/core/db/mysqli.class.php

@@ -590,7 +590,7 @@ class DoliDBMysqli extends DoliDB
 	 *
 	 *  @param	string		$database	Name of database
 	 *  @param	string		$table		Nmae of table filter ('xxx%')
-	 *  @return	resource				Resource
+	 *  @return	array					List of tables in an array
      */
     function DDLListTables($database, $table='')
     {

+ 3 - 3
htdocs/core/db/pgsql.class.php

@@ -846,8 +846,8 @@ class DoliDBPgsql extends DoliDB
 	 *  List tables into a database
 	 *
 	 *  @param	string		$database	Name of database
-	 *  @param	string		$table		Nmae of table filter ('xxx%')
-	 *  @return	resource				Resource
+	 *  @param	string		$table		Name of table filter ('xxx%')
+	 *  @return	array					List of tables in an array
 	 */
 	function DDLListTables($database, $table='')
 	{
@@ -860,7 +860,7 @@ class DoliDBPgsql extends DoliDB
 		{
 			$listtables[] = $row[0];
 		}
-		return  $listtables;
+		return $listtables;
 	}
 
 	/**

+ 2 - 2
htdocs/core/db/sqlite.class.php

@@ -737,8 +737,8 @@ class DoliDBSqlite extends DoliDB
 	 *  List tables into a database
 	 *
 	 *  @param	string		$database	Name of database
-	 *  @param	string		$table		Nmae of table filter ('xxx%')
-	 *  @return	resource				Resource
+	 *  @param	string		$table		Name of table filter ('xxx%')
+	 *  @return	array					List of tables in an array
      */
     function DDLListTables($database, $table='')
     {

+ 3 - 2
htdocs/core/lib/functions.lib.php

@@ -1026,7 +1026,7 @@ function dol_getdate($timestamp,$fast=false)
  *	@param	int			$year			Year
  *	@param	mixed		$gm				True or 1 or 'gmt'=Input informations are GMT values, False or 0 or 'server' = local to server TZ, 'user' = local to user TZ
  *	@param	int			$check			0=No check on parameters (Can use day 32, etc...)
- *	@return	int							Date as a timestamp, '' if error
+ *	@return	timestamp|string			Date as a timestamp, '' if error
  * 	@see 								dol_print_date, dol_stringtotime, dol_getdate
  */
 function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
@@ -1075,6 +1075,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
 		$dt->setDate($year,$month,$day);
 		$dt->setTime((int) $hour, (int) $minute, (int) $second);
 		$date=$dt->getTimestamp();	// should include daylight saving time
+		return $date;
 	}
 	else
 	{
@@ -1092,8 +1093,8 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
 		{
 			$date=mktime($hour,$minute,$second,$month,$day,$year);
 		}*/
+		return '';
 	}
-	return $date;
 }
 
 

+ 1 - 1
htdocs/core/modules/syslog/mod_syslog_file.php

@@ -49,7 +49,7 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface
 	 */
 	public function isActive()
 	{
-		return 1;
+		return true;
 	}
 
 	/**

+ 2 - 2
htdocs/core/modules/syslog/mod_syslog_firephp.php

@@ -53,7 +53,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
 		    restore_include_path();
 		    if ($res)
 		    {
-		        return 1;
+		        return true;
 		    }
 		}
 		catch(Exception $e)
@@ -61,7 +61,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
 		    print '<!-- FirePHP not available into PHP -->'."\n";
 		}
 
-		return -1;
+		return false;
 	}
 
 	///**

+ 2 - 5
htdocs/core/modules/syslog/mod_syslog_syslog.php

@@ -47,12 +47,9 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
 	public function isActive()
 	{
 		// This function does not exists on some ISP (Ex: Free in France)
-		if (!function_exists('openlog'))
-		{
-			return 0;
-		}
+		if (!function_exists('openlog')) return false;
 
-		return 1;
+		return true;
 	}
 
 	/**