mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
"added quoting"
This commit is contained in:
parent
0a5be8a725
commit
f3181308c5
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* API - Categories
|
||||
*
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @author Joseph Engo <jengo@phpgroupware.org>
|
||||
* @author Bettina Gille <ceb@phpgroupware.org>
|
||||
@ -191,15 +191,15 @@ class categories
|
||||
. $parent_filter . $querymethod . $filter;
|
||||
|
||||
$this->total_records = $this->db->select($this->table,'COUNT(*)',$where,__LINE__,__FILE__)->fetchSingle();
|
||||
|
||||
|
||||
if (!$this->total_records) return false;
|
||||
|
||||
|
||||
foreach($this->db->select($this->table,'*',$where,__LINE__,__FILE__,$limit ? (int) $start : false,$ordermethod) as $cat)
|
||||
{
|
||||
$cat = egw_db::strip_array_keys($cat,'cat_');
|
||||
$cat['app_name'] = $cat['appname'];
|
||||
$this->cache_id2cat_data[$cat['id']] = $cat;
|
||||
|
||||
|
||||
if ($column)
|
||||
{
|
||||
$cats[] = array($column => isset($cat[$column]) ? $cat[$column] : $cat['id']);
|
||||
@ -273,7 +273,7 @@ class categories
|
||||
$cat = egw_db::strip_array_keys($cat,'cat_');
|
||||
$cat['app_name'] = $cat['appname'];
|
||||
$this->cache_id2cat_data[$cat['id']] = $cat;
|
||||
|
||||
|
||||
$cats[] = $cat;
|
||||
$parents[] = $cat['id'];
|
||||
}
|
||||
@ -286,7 +286,7 @@ class categories
|
||||
$cat = egw_db::strip_array_keys($cat,'cat_');
|
||||
$cat['app_name'] = $cat['appname'];
|
||||
$this->cache_id2cat_data[$cat['id']] = $cat;
|
||||
|
||||
|
||||
$parents[] = $cat['id'];
|
||||
$children[$cat['parent']][] = $cat;
|
||||
}
|
||||
@ -309,7 +309,7 @@ class categories
|
||||
}
|
||||
}
|
||||
$this->total_records = count($cats);
|
||||
|
||||
|
||||
if ($limit)
|
||||
{
|
||||
return array_slice($cats,(int)$start,$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']);
|
||||
@ -406,7 +406,7 @@ class categories
|
||||
$s .= '</option>' . "\n";
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'list':
|
||||
$space = ' ';
|
||||
|
||||
@ -469,7 +469,7 @@ class categories
|
||||
'cat_description' => $values['descr'],
|
||||
'cat_data' => $values['data'],
|
||||
'cat_main' => $values['main'],
|
||||
'cat_level' => $values['level'],
|
||||
'cat_level' => $values['level'],
|
||||
'last_mod' => time(),
|
||||
),(int)$values['id'] > 0 ? array('cat_id' => $values['id']) : array(),__LINE__,__FILE__);
|
||||
|
||||
@ -500,8 +500,8 @@ class categories
|
||||
if ($cat['level'] == 1)
|
||||
{
|
||||
$this->db->update($this->table,array(
|
||||
'cat_level' => 0,
|
||||
'cat_parent' => 0,
|
||||
'cat_level' => 0,
|
||||
'cat_parent' => 0,
|
||||
'cat_main' => $cat['id'],
|
||||
),array(
|
||||
'cat_id' => $cat['id'],
|
||||
@ -513,7 +513,7 @@ class categories
|
||||
else
|
||||
{
|
||||
$update = array('cat_level' => $cat['level']-1);
|
||||
|
||||
|
||||
if ($new_main) $update['cat_main'] = $new_main;
|
||||
|
||||
if ($cat['parent'] == $cat_id) $update['cat_parent'] = $new_parent;
|
||||
@ -578,13 +578,13 @@ class categories
|
||||
'cat_id' => $values['id'],
|
||||
'cat_appname' => $this->app_name,
|
||||
),__LINE__,__FILE__);
|
||||
|
||||
|
||||
return (int)$values['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* return category id for a given name
|
||||
*
|
||||
*
|
||||
* Cat's with the given name are returned in this order:
|
||||
* - personal cats first
|
||||
* - then application global categories
|
||||
@ -598,7 +598,7 @@ class categories
|
||||
function name2id($cat_name,$strip=false)
|
||||
{
|
||||
static $cache = array(); // a litle bit of caching
|
||||
|
||||
|
||||
if (isset($cache[$cat_name])) return $cache[$cat_name];
|
||||
|
||||
if ($strip === true)
|
||||
@ -617,13 +617,13 @@ class categories
|
||||
}
|
||||
$cats[] = $stripped_cat_name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$cat = $this->db->select($this->table,array('cat_name','cat_id'),array(
|
||||
'cat_name' => $cats,
|
||||
'cat_appname' => array($this->app_name, 'phpgw'),
|
||||
),__LINE__,__FILE__,0,
|
||||
"ORDER BY cat_name!='$cat_name',(CASE cat_owner WHEN ".(int)$this->account_id." THEN 1 WHEN -1 THEN 2 ELSE 3 END),cat_appname='phpgw'",
|
||||
'ORDER BY cat_name<>'.$this->db->quote($cat_name).',(CASE cat_owner WHEN '.(int)$this->account_id." THEN 1 WHEN -1 THEN 2 ELSE 3 END),cat_appname='phpgw'",
|
||||
false,1)->fetch();
|
||||
|
||||
if (!$cat) return 0; // cat not found, dont cache it, as it might be created in this request
|
||||
@ -643,9 +643,9 @@ class categories
|
||||
function id2name($cat_id=0, $item='name')
|
||||
{
|
||||
if(!$cat_id) return '--';
|
||||
|
||||
|
||||
if (!isset($this->cache_id2cat_data[$cat_id])) $this->return_single($cat_id);
|
||||
|
||||
|
||||
if (!$item) $item = 'parent';
|
||||
|
||||
$cat = $this->cache_id2cat_data[$cat_id];
|
||||
@ -700,7 +700,7 @@ class categories
|
||||
if ($cat_name)
|
||||
{
|
||||
$where['cat_name'] = $cat_name;
|
||||
|
||||
|
||||
if ($cat_id) $where[] = 'cat_id != '.(int)$cat_id;
|
||||
}
|
||||
elseif ($cat_id)
|
||||
@ -711,7 +711,7 @@ class categories
|
||||
|
||||
return $cache[$type][$cat_name][$cat_id] = $this->db->select($this->table,'cat_id',$where,__LINE__,__FILE__)->fetchSingle();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change the owner of all cats owned by $owner to $to OR deletes them if !$to
|
||||
*
|
||||
@ -722,7 +722,7 @@ class categories
|
||||
function change_owner($owner,$to=0,$app='')
|
||||
{
|
||||
$where = array('cat_owner' => $owner);
|
||||
|
||||
|
||||
if ($app) $where['cat_appname'] = $app;
|
||||
|
||||
if ((int)$to)
|
||||
|
Loading…
Reference in New Issue
Block a user