intval -> (int), remove unnecessary switch statement

This commit is contained in:
Miles Lott 2003-12-14 16:50:34 +00:00
parent 0b48089323
commit e18438cdcc
2 changed files with 30 additions and 41 deletions

View File

@ -10,16 +10,16 @@
/* $Id$ */ /* $Id$ */
/** /*
* Database abstraction library * Database abstraction library
* *
* This allows eGroupWare to use multiple database backends via ADOdb * This allows eGroupWare to use multiple database backends via ADOdb
* *
* @package phpgwapi * @package phpgwapi
* @subpackage db * @subpackage db
* @author RalfBecker@outdoor-training.de * @author RalfBecker@outdoor-training.de
* @license LGPL * @license LGPL
*/ */
if(empty($GLOBALS['phpgw_info']['server']['db_type'])) if(empty($GLOBALS['phpgw_info']['server']['db_type']))
{ {
@ -210,7 +210,6 @@
*/ */
function disconnect() function disconnect()
{ {
} }
/** /**
@ -296,7 +295,7 @@
if (!$this->connect()) if (!$this->connect())
{ {
return 0; /* we already complained in connect() about that. */ return 0; /* we already complained in connect() about that. */
}; }
# New query, discard previous result. # New query, discard previous result.
if ($this->Query_ID) if ($this->Query_ID)
@ -313,7 +312,7 @@
} }
if ($num_rows > 0) if ($num_rows > 0)
{ {
$this->Query_ID = $this->Link_ID->SelectLimit($Query_String,$num_rows,intval($offset)); $this->Query_ID = $this->Link_ID->SelectLimit($Query_String,$num_rows,(int)$offset);
} }
else else
{ {
@ -679,7 +678,7 @@
'table_name' => $table, 'table_name' => $table,
'tablespace_name' => $this->Database, 'tablespace_name' => $this->Database,
'database' => $this->Database 'database' => $this->Database
); );
} }
} }
return $result; return $result;
@ -709,7 +708,7 @@
/** /**
* Implodes an array of column-value pairs for the use in sql-querys. * Implodes an array of column-value pairs for the use in sql-querys.
* All data is either run through addslashes() or intval(). * All data is either run through addslashes() or (int).
* *
* @author RalfBecker<at>outdoor-training.de * @author RalfBecker<at>outdoor-training.de
* *
@ -720,7 +719,7 @@
* typicaly used to form a WHERE-clause from the primary keys * typicaly used to form a WHERE-clause from the primary keys
* @param array/boolean $column_definitions this can be set to the column-definitions-array * @param array/boolean $column_definitions this can be set to the column-definitions-array
* of your table ($tables_baseline[$table]['fd'] of the setup/tables_current.inc.php file). * of your table ($tables_baseline[$table]['fd'] of the setup/tables_current.inc.php file).
* If its set, the column-type-data determinates if intval() or addslashes is used. * If its set, the column-type-data determinates if (int) or addslashes is used.
*/ */
function column_data_implode($glue,$array,$use_key=True,$only=False,$column_definitions=False) function column_data_implode($glue,$array,$use_key=True,$only=False,$column_definitions=False)
{ {
@ -736,7 +735,7 @@
$column_type = is_array($column_definitions) ? @$colum_definitions[$key]['type'] : False; $column_type = is_array($column_definitions) ? @$colum_definitions[$key]['type'] : False;
$values[] = ($use_key ? $key.'=' : ''). $values[] = ($use_key ? $key.'=' : '').
($column_type == 'int' || $colum_type == 'auto' ? ($column_type == 'int' || $colum_type == 'auto' ?
intval($data) : "'".$this->db_addslashes($data)."'"); (int)$data : "'" . $this->db_addslashes($data) . "'");
} }
} }
return implode($glue,$values); return implode($glue,$values);
@ -749,7 +748,7 @@
* *
* @param array/boolean $column_definitions this can be set to the column-definitions-array * @param array/boolean $column_definitions this can be set to the column-definitions-array
* of your table ($tables_baseline[$table]['fd'] of the setup/tables_current.inc.php file). * of your table ($tables_baseline[$table]['fd'] of the setup/tables_current.inc.php file).
* If its set, the column-type-data determinates if intval() or addslashes is used. * If its set, the column-type-data determinates if (int) or addslashes is used.
*/ */
function set_column_definitions($column_definitions=False) function set_column_definitions($column_definitions=False)
{ {

View File

@ -56,9 +56,9 @@
} }
if(isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) && if(isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) &&
intval($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) > 0) (int)$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0)
{ {
$this->maxmatches = intval($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']); $this->maxmatches = (int)$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
} }
else else
{ {
@ -96,21 +96,11 @@
*/ */
function set_icon($align,$img,$label) function set_icon($align,$img,$label)
{ {
switch(strtolower($GLOBALS['phpgw_info']['user']['account_lid']))
{
case 'ceb':
$border = 2;
break;
default:
$border = 0;
break;
}
$var = array( $var = array(
'align' => $align, 'align' => $align,
'img' => $GLOBALS['phpgw']->common->image('phpgwapi',$img), 'img' => $GLOBALS['phpgw']->common->image('phpgwapi',$img),
'label' => lang($label), 'label' => lang($label),
'border' => $border 'border' => 0
); );
$this->template->set_var($var); $this->template->set_var($var);
return $this->template->fp('out','link'); return $this->template->fp('out','link');
@ -159,7 +149,7 @@
{ {
// if(is_int($value)) // if(is_int($value))
// { // {
// $param = intval($value); // $param = (int)$value;
// } // }
// else // else
// { // {
@ -442,8 +432,8 @@
{ {
if(is_array($search_obj)) if(is_array($search_obj))
{ {
$params = $search_obj; $params = $search_obj;
$s_query = stripslashes($params['query']); $s_query = stripslashes($params['query']);
$search_obj = $params['search_obj']; $search_obj = $params['search_obj'];
} }
else else
@ -455,7 +445,7 @@
// Our only option is to remove it // Our only option is to remove it
if (ereg('"',$_query)) if (ereg('"',$_query))
{ {
$_query = ereg_replace('"','',$_query); $_query = str_replace('"','',$_query);
} }
$var = array $var = array
( (
@ -530,9 +520,9 @@
{ {
if (is_array($yours)) if (is_array($yours))
{ {
$params = $yours; $params = $yours;
$filter = $params['filter']; $filter = $params['filter'];
$yours = $params['yours']; $yours = $params['yours'];
} }
else else
{ {
@ -604,14 +594,14 @@
{ {
if(is_array($data)) if(is_array($data))
{ {
$filter = (isset($data['filter'])?$data['filter']:''); $filter = (isset($data['filter'])?$data['filter']:'');
$format = (isset($data['format'])?$data['format']:'all'); $format = (isset($data['format'])?$data['format']:'all');
} }
else else
{ {
//$filter = get_var('filter',Array('GET','POST')); //$filter = get_var('filter',Array('GET','POST'));
$filter = $data; $filter = $data;
$format = 'all'; $format = 'all';
} }
switch($format) switch($format)