Fix scrutinizer

This commit is contained in:
Laurent Destailleur 2014-10-05 01:22:17 +02:00
parent 11d1be882c
commit 5c5f725a34
12 changed files with 59 additions and 51 deletions

View File

@ -893,7 +893,8 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
$title1='';$title2=''; $title1='';$title2='';
if (isset($cases1[$h]) && $cases1[$h] != '') 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=' '; $string1=' ';
$style1='peruser_notbusy'; $style1='peruser_notbusy';
foreach($cases1[$h] as $id => $ev) 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] != '') 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=' '; $string2=' ';
$style2='peruser_notbusy'; $style2='peruser_notbusy';
foreach($cases2[$h] as $id => $ev) 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]); $ids=array_keys($cases1[$h]);
$output = array_slice($cases1[$h], 0, 1); $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']; if ($output[0]['color']) $color1 = $output[0]['color'];
} }
else if (count($cases1[$h]) > 1) $color1='222222'; 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]); $ids=array_keys($cases2[$h]);
$output = array_slice($cases2[$h], 0, 1); $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']; if ($output[0]['color']) $color2 = $output[0]['color'];
} }
else if (count($cases2[$h]) > 1) $color2='222222'; else if (count($cases2[$h]) > 1) $color2='222222';

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1026,7 +1026,7 @@ function dol_getdate($timestamp,$fast=false)
* @param int $year Year * @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 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...) * @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 * @see dol_print_date, dol_stringtotime, dol_getdate
*/ */
function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) 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->setDate($year,$month,$day);
$dt->setTime((int) $hour, (int) $minute, (int) $second); $dt->setTime((int) $hour, (int) $minute, (int) $second);
$date=$dt->getTimestamp(); // should include daylight saving time $date=$dt->getTimestamp(); // should include daylight saving time
return $date;
} }
else 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); $date=mktime($hour,$minute,$second,$month,$day,$year);
}*/ }*/
return '';
} }
return $date;
} }

View File

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

View File

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

View File

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