mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:07 +01:00
update
This commit is contained in:
parent
79998e203b
commit
8095e83fc5
@ -20,8 +20,8 @@
|
||||
* along with this library; if not, write to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||
\**************************************************************************/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/*!
|
||||
@class categories
|
||||
@abstract class adds ability for applications to make use of categories
|
||||
@ -93,8 +93,7 @@
|
||||
{
|
||||
if ($public)
|
||||
{
|
||||
$pub_pre = '(';
|
||||
$public_cats = " OR cat_appname='phpgw') ";
|
||||
$public_cats = " OR cat_appname='phpgw' ";
|
||||
}
|
||||
|
||||
$filter = $this->filter($type);
|
||||
@ -138,8 +137,8 @@
|
||||
$querymethod = " AND (cat_name LIKE '%$query%' OR cat_description LIKE '%$query%') ";
|
||||
}
|
||||
|
||||
$sql = "SELECT * from phpgw_categories WHERE (" . $pub_pre . "cat_appname='" . $this->app_name . "' " . $public_cats . $parent_filter . " AND "
|
||||
. " $grant_cats) " . $querymethod . $filter;
|
||||
$sql = "SELECT * from phpgw_categories WHERE (cat_appname='" . $this->app_name . "'" . $public_cats . ")" . $parent_filter . " AND"
|
||||
. $grant_cats . $querymethod . $filter;
|
||||
|
||||
$this->db2->query($sql,__LINE__,__FILE__);
|
||||
|
||||
@ -154,21 +153,19 @@
|
||||
$this->db->query($sql . $ordermethod,__LINE__,__FILE__);
|
||||
}
|
||||
|
||||
//echo '<b>TEST:</b>' . $sql;
|
||||
|
||||
$i = 0;
|
||||
while ($this->db->next_record())
|
||||
{
|
||||
$cats[$i]['id'] = $this->db->f('cat_id');
|
||||
$cats[$i]['owner'] = $this->db->f('cat_owner');
|
||||
$cats[$i]['access'] = $this->db->f('cat_access');
|
||||
$cats[$i]['app_name'] = $this->db->f('cat_appname');
|
||||
$cats[$i]['main'] = $this->db->f('cat_main');
|
||||
$cats[$i]['level'] = $this->db->f('cat_level');
|
||||
$cats[$i]['parent'] = $this->db->f('cat_parent');
|
||||
$cats[$i]['name'] = $this->db->f('cat_name');
|
||||
$cats[$i]['description'] = $this->db->f('cat_description');
|
||||
$cats[$i]['data'] = $this->db->f('cat_data');
|
||||
$cats[$i]['id'] = $this->db->f('cat_id');
|
||||
$cats[$i]['owner'] = $this->db->f('cat_owner');
|
||||
$cats[$i]['access'] = $this->db->f('cat_access');
|
||||
$cats[$i]['app_name'] = $this->db->f('cat_appname');
|
||||
$cats[$i]['main'] = $this->db->f('cat_main');
|
||||
$cats[$i]['level'] = $this->db->f('cat_level');
|
||||
$cats[$i]['parent'] = $this->db->f('cat_parent');
|
||||
$cats[$i]['name'] = $this->db->f('cat_name');
|
||||
$cats[$i]['description'] = $this->db->f('cat_description');
|
||||
$cats[$i]['data'] = $this->db->f('cat_data');
|
||||
$i++;
|
||||
}
|
||||
return $cats;
|
||||
@ -182,20 +179,20 @@
|
||||
*/
|
||||
function return_single($id = '')
|
||||
{
|
||||
$this->db->query('SELECT * FROM phpgw_categories WHERE cat_id='.$id,__LINE__,__FILE__);
|
||||
$this->db->query('SELECT * FROM phpgw_categories WHERE cat_id=' . $id,__LINE__,__FILE__);
|
||||
|
||||
if ($this->db->next_record())
|
||||
{
|
||||
$cats[0]['id'] = $this->db->f('cat_id');
|
||||
$cats[0]['owner'] = $this->db->f('cat_owner');
|
||||
$cats[0]['access'] = $this->db->f('cat_access');
|
||||
$cats[0]['app_name'] = $this->db->f('cat_appname');
|
||||
$cats[0]['main'] = $this->db->f('cat_main');
|
||||
$cats[0]['level'] = $this->db->f('cat_level');
|
||||
$cats[0]['parent'] = $this->db->f('cat_parent');
|
||||
$cats[0]['name'] = $this->db->f('cat_name');
|
||||
$cats[0]['description'] = $this->db->f('cat_description');
|
||||
$cats[0]['data'] = $this->db->f('cat_data');
|
||||
$cats[0]['id'] = $this->db->f('cat_id');
|
||||
$cats[0]['owner'] = $this->db->f('cat_owner');
|
||||
$cats[0]['access'] = $this->db->f('cat_access');
|
||||
$cats[0]['app_name'] = $this->db->f('cat_appname');
|
||||
$cats[0]['main'] = $this->db->f('cat_main');
|
||||
$cats[0]['level'] = $this->db->f('cat_level');
|
||||
$cats[0]['parent'] = $this->db->f('cat_parent');
|
||||
$cats[0]['name'] = $this->db->f('cat_name');
|
||||
$cats[0]['description'] = $this->db->f('cat_description');
|
||||
$cats[0]['data'] = $this->db->f('cat_data');
|
||||
}
|
||||
return $cats;
|
||||
}
|
||||
@ -214,13 +211,13 @@
|
||||
$app_name = $GLOBALS['phpgw_info']['flags']['currentapp'];
|
||||
}
|
||||
|
||||
$this->account_id= $account_id;
|
||||
$this->app_name = $app_name;
|
||||
$this->db = $GLOBALS['phpgw']->db;
|
||||
$this->db2 = $this->db;
|
||||
$this->total_records = $this->db2->num_rows();
|
||||
$this->grants = $GLOBALS['phpgw']->acl->get_grants($app_name);
|
||||
$this->cats = $this->return_array($type,$start,$limit,$query,$sort,$order,$public);
|
||||
$this->account_id = $account_id;
|
||||
$this->app_name = $app_name;
|
||||
$this->db = $GLOBALS['phpgw']->db;
|
||||
$this->db2 = $this->db;
|
||||
$this->total_records = $this->db2->num_rows();
|
||||
$this->grants = $GLOBALS['phpgw']->acl->get_grants($app_name);
|
||||
$this->cats = $this->return_array($type,$start,$limit,$query,$sort,$order,$public);
|
||||
}
|
||||
|
||||
function in_array($needle,$haystack)
|
||||
@ -350,17 +347,17 @@
|
||||
$cat_values['descr'] = $this->db->db_addslashes($cat_values['descr']);
|
||||
$cat_values['name'] = $this->db->db_addslashes($cat_values['name']);
|
||||
|
||||
$this->db->query("INSERT INTO phpgw_categories (cat_parent,cat_owner,cat_access,cat_appname,cat_name,"
|
||||
. "cat_description,cat_data,cat_main,cat_level) VALUES ('" . $cat_values['parent'] . "','" . $this->account_id . "','" . $cat_values['access'] . "','"
|
||||
. $this->app_name . "','" . $cat_values['name'] . "','" . $cat_values['descr']
|
||||
. "','" . $cat_values['data'] . "','" . $cat_values['main'] . "','" . $cat_values['level'] . "')",__LINE__,__FILE__);
|
||||
$this->db->query("INSERT INTO phpgw_categories (cat_parent,cat_owner,cat_access,cat_appname,cat_name,cat_description,cat_data,"
|
||||
. "cat_main,cat_level) VALUES ('" . $cat_values['parent'] . "','" . $this->account_id . "','" . $cat_values['access']
|
||||
. "','" . $this->app_name . "','" . $cat_values['name'] . "','" . $cat_values['descr'] . "','" . $cat_values['data']
|
||||
. "','" . $cat_values['main'] . "','" . $cat_values['level'] . "')",__LINE__,__FILE__);
|
||||
|
||||
if (!$cat_values['parent'] || $cat_values['parent'] == 0)
|
||||
{
|
||||
$this->db2->query("SELECT MAX(cat_id) AS max FROM phpgw_categories",__LINE__,__FILE__);
|
||||
$this->db2->next_record();
|
||||
$this->db->query("UPDATE phpgw_categories SET cat_main='" . $this->db2->f('max') . "' WHERE cat_id='"
|
||||
. $this->db2->f('max') . "'",__LINE__,__FILE__);
|
||||
. $this->db2->f('max') . "'",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -377,7 +374,7 @@
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM phpgw_categories WHERE cat_id='$cat_id' $subdelete AND cat_appname='"
|
||||
. $this->app_name . "'",__LINE__,__FILE__);
|
||||
. $this->app_name . "'",__LINE__,__FILE__);
|
||||
}
|
||||
/*!
|
||||
@function edit
|
||||
@ -391,31 +388,30 @@
|
||||
{
|
||||
if ($cat_values['parent'] && ($cat_values['parent'] != 0))
|
||||
{
|
||||
$cat_values['main'] = $this->id2name($cat_values['parent'],'main');
|
||||
$cat_values['level'] = $this->id2name($cat_values['parent'],'level')+1;
|
||||
$cat_values['main'] = $this->id2name($cat_values['parent'],'main');
|
||||
$cat_values['level'] = $this->id2name($cat_values['parent'],'level')+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cat_values['main'] = $cat_values['id'];
|
||||
$cat_values['level'] = 0;
|
||||
$cat_values['main'] = $cat_values['id'];
|
||||
$cat_values['level'] = 0;
|
||||
}
|
||||
|
||||
$cat_values['descr'] = $this->db->db_addslashes($cat_values['descr']);
|
||||
$cat_values['name'] = $this->db->db_addslashes($cat_values['name']);
|
||||
$sql = "UPDATE phpgw_categories SET cat_name='" . $cat_values['name'] . "', cat_description='"
|
||||
. $cat_values['descr'] . "', cat_data='" . $cat_values['data'] . "', cat_parent='"
|
||||
. $cat_values['parent'] . "', cat_access='" . $cat_values['access'] . "', cat_main='"
|
||||
. $cat_values['main'] . "', cat_level='" . $cat_values['level'] . "' "
|
||||
. "WHERE cat_appname='" . $this->app_name . "' AND cat_id='" . $cat_values['id'] . "'";
|
||||
|
||||
$sql = "UPDATE phpgw_categories SET cat_name='" . $cat_values['name'] . "', cat_description='" . $cat_values['descr']
|
||||
. "', cat_data='" . $cat_values['data'] . "', cat_parent='" . $cat_values['parent'] . "', cat_access='"
|
||||
. $cat_values['access'] . "', cat_main='" . $cat_values['main'] . "', cat_level='" . $cat_values['level'] . "' "
|
||||
. "WHERE cat_appname='" . $this->app_name . "' AND cat_id='" . $cat_values['id'] . "'";
|
||||
|
||||
$this->db->query($sql,__LINE__,__FILE__);
|
||||
}
|
||||
|
||||
function name2id($cat_name)
|
||||
{
|
||||
$this->db->query('SELECT cat_id FROM phpgw_categories '
|
||||
. "WHERE cat_name='".$cat_name."' AND "
|
||||
. "cat_appname='".$this->app_name."' AND "
|
||||
. "cat_owner=".$this->account_id,__LINE__,__FILE__);
|
||||
$this->db->query("SELECT cat_id FROM phpgw_categories WHERE cat_name='" . $cat_name . "' AND cat_appname='" . $this->app_name
|
||||
. "' AND cat_owner=" . $this->account_id,__LINE__,__FILE__);
|
||||
|
||||
if(!$this->db->num_rows())
|
||||
{
|
||||
@ -441,8 +437,7 @@
|
||||
case 'level': $value = 'cat_level'; break;
|
||||
}
|
||||
|
||||
$this->db->query("SELECT $value FROM phpgw_categories WHERE cat_id='"
|
||||
. "$cat_id'",__LINE__,__FILE__);
|
||||
$this->db->query("SELECT $value FROM phpgw_categories WHERE cat_id='" . $cat_id . "'",__LINE__,__FILE__);
|
||||
$this->db->next_record();
|
||||
|
||||
if ($this->db->f($value))
|
||||
|
Loading…
Reference in New Issue
Block a user