[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: phpgwapi/inc class.categories.inc.php,1.95,1.96
From: |
Bettina Gille <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: phpgwapi/inc class.categories.inc.php,1.95,1.96 |
Date: |
Sat, 12 Oct 2002 17:18:25 -0400 |
Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv27810
Modified Files:
class.categories.inc.php
Log Message:
update edit_cats to move the subtree with the cat if the parent changes
Index: class.categories.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.categories.inc.php,v
retrieving revision 1.95
retrieving revision 1.96
diff -C2 -r1.95 -r1.96
*** class.categories.inc.php 12 Oct 2002 18:01:39 -0000 1.95
--- class.categories.inc.php 12 Oct 2002 21:18:23 -0000 1.96
***************
*** 146,150 ****
$filter = $this->filter($type);
!
if (!$sort)
{
--- 146,150 ----
$filter = $this->filter($type);
!
if (!$sort)
{
***************
*** 195,199 ****
$sql = "SELECT * from phpgw_categories WHERE
(cat_appname='" . $this->app_name . "' AND" . $grant_cats . $global_cats . ")"
. $parent_filter . $querymethod . $filter;
!
if ($limit)
{
--- 195,199 ----
$sql = "SELECT * from phpgw_categories WHERE
(cat_appname='" . $this->app_name . "' AND" . $grant_cats . $global_cats . ")"
. $parent_filter . $querymethod . $filter;
!
if ($limit)
{
***************
*** 331,351 ****
$this->db->query('SELECT * FROM phpgw_categories WHERE
cat_id=' . intval($id),__LINE__,__FILE__);
! if ($this->db->next_record())
! {
! $cats = array
! (
! 'cat_id' =>
$this->db->f('cat_id'),
! 'owner' =>
$this->db->f('cat_owner'),
! 'access' =>
$this->db->f('cat_access'),
! 'app_name' =>
$this->db->f('cat_appname'),
! 'main' =>
$this->db->f('cat_main'),
! 'level' =>
$this->db->f('cat_level'),
! 'parent' =>
$this->db->f('cat_parent'),
! 'name' =>
$this->db->f('cat_name'),
! 'descr' =>
$this->db->f('cat_description'),
! 'data' =>
$this->db->f('cat_data')
! );
! }
! return $cats;
}
--- 331,337 ----
$this->db->query('SELECT * FROM phpgw_categories WHERE
cat_id=' . intval($id),__LINE__,__FILE__);
! list($cat) = $this->db2cats();
!
! return $cat;
}
***************
*** 540,545 ****
if ($values['parent'] && $values['parent'] != 0)
{
! $values['main'] =
intval($this->id2item(array('cat_id' => $values['parent'],'item' => 'main')));
! $values['level'] =
intval($this->id2item(array('cat_id' => $values['parent'],'item' =>
'level'))+1);
}
--- 526,531 ----
if ($values['parent'] && $values['parent'] != 0)
{
! $values['main'] =
intval($this->id2item(array('cat_id' => $values['parent'],'item' => 'main')));
! $values['level'] =
intval($this->id2item(array('cat_id' => $values['parent'],'item' =>
'level'))+1);
}
***************
*** 552,556 ****
$id_val = $values['cat_id'].',';
}
-
$this->db->query("INSERT INTO phpgw_categories
(${id_col}cat_parent,cat_owner,cat_access,cat_appname,cat_name,cat_description,cat_data,"
. "cat_main,cat_level) VALUES ($id_val'" .
intval($values['parent']) . "','" . $this->account_id . "','" .
$values['access']
--- 538,541 ----
***************
*** 558,566 ****
. "','" . $values['main'] . "','" .
$values['level'] . "')",__LINE__,__FILE__);
- if (isset($values['cat_id']))
- {
- $max = intval($values['cat_id']);
- }
-
$max =
$this->db->get_last_insert_id('phpgw_categories','cat_id');
--- 543,546 ----
***************
*** 604,610 ****
if ($cats[$i]['level'] == 1)
{
!
$this->db->query("UPDATE phpgw_categories set cat_level=0, cat_parent=0,
cat_main='" . intval($cats[$i]['id'])
!
. "' WHERE cat_id='" . intval($cats[$i]['id']) . "' AND cat_appname='" .
$this->app_name . "'",__LINE__,__FILE__);
! $new_main =
$cats[$i]['id'];
}
else
--- 584,590 ----
if ($cats[$i]['level'] == 1)
{
!
$this->db->query("UPDATE phpgw_categories set cat_level=0, cat_parent=0,
cat_main='" . intval($cats[$i]['cat_id'])
!
. "' WHERE cat_id='" . intval($cats[$i]['cat_id']) . "' AND cat_appname='" .
$this->app_name . "'",__LINE__,__FILE__);
! $new_main =
$cats[$i]['cat_id'];
}
else
***************
*** 621,625 ****
$this->db->query("UPDATE phpgw_categories set cat_level='" .
($cats[$i]['level']-1) . "'" . $update_main . $update_parent
!
. " WHERE cat_id='" . intval($cats[$i]['id']) . "' AND cat_appname='" .
$this->app_name . "'",__LINE__,__FILE__);
}
}
--- 601,605 ----
$this->db->query("UPDATE phpgw_categories set cat_level='" .
($cats[$i]['level']-1) . "'" . $update_main . $update_parent
!
. " WHERE cat_id='" . intval($cats[$i]['cat_id']) . "' AND
cat_appname='" . $this->app_name . "'",__LINE__,__FILE__);
}
}
***************
*** 635,639 ****
if (!is_array($main))
{
! $this->db->query("SELECT * from
phpgw_categories WHERE cat_main = $main");
$main = $this->db2cats();
//echo "main: "; _debug_array($main);
--- 615,619 ----
if (!is_array($main))
{
! $this->db->query("SELECT * from
phpgw_categories WHERE cat_main = $main",__LINE__,__FILE__);
$main = $this->db2cats();
//echo "main: "; _debug_array($main);
***************
*** 645,650 ****
if ($cat['parent'] == $parent)
{
! //echo "Adding($cat['cat_id'])<br>";
! $subs[] = $cat;
$this->subs($cat['cat_id'],$subs,$main);
}
--- 625,630 ----
if ($cat['parent'] == $parent)
{
! //echo "Adding($cat[cat_id])<br>";
! $subs[$cat['cat_id']] = $cat;
$this->subs($cat['cat_id'],$subs,$main);
}
***************
*** 657,665 ****
$parent = $values['parent'];
$old_parent = $values['old_parent'];
! $main = $old_parent ?
intval($this->id2item(array('cat_id' => $old_parent,'item' => 'main'))) : $id;
! //echo
"<p>reparent($id,$parent,$old_parent,$main)</p>\n";
$subs = array();
$this->subs($id,$subs,$main);
$new_main = $parent ? $this->id2name($parent,'main') :
$id;
--- 637,662 ----
$parent = $values['parent'];
$old_parent = $values['old_parent'];
! $main = $old_parent ?
intval($this->id2name($old_parent,'main')) : $id;
! //echo "<p>reparent: $id/$main: $old_parent -->
$parent</p>\n";
$subs = array();
$this->subs($id,$subs,$main);
+ //echo "<p>subs($id) = "; _debug_array($subs);
+
+ if (isset($subs[$parent]))
+ {
+ //echo "<p>new parent $parent is sub of
$id</p>\n";
+ $parent = $subs[$parent];
+ $parent['old_parent'] = $parent['parent'];
+ $parent['parent'] =
intval($values['old_parent']);
+ $this->reparent($parent);
+
+ unset($parent['old_parent']);
+ unset($parent['main']);
+
+ $this->edit($parent);
+ $this->reparent($values);
+ return;
+ }
$new_main = $parent ? $this->id2name($parent,'main') :
$id;
***************
*** 673,676 ****
--- 670,674 ----
$subs[$n]['main'] = $new_main;
$subs[$n]['level'] -= $level_adj;
+ //echo "<p>$n: id=".$subs[$n]['cat_id']." set
main to $new_main, subs[$n] = \n"; _debug_array($subs[$n]);
$this->edit($subs[$n]);
}
***************
*** 694,708 ****
$this->reparent($values);
}
! else
{
if ($values['parent'] && ($values['parent'] !=
0))
{
! $values['main'] =
intval($this->id2item(array('cat_id' => $values['parent'],'item' => 'main')));
! $values['level'] =
intval($this->id2item(array('cat_id' => $values['parent'],'item' =>
'level'))+1);
}
else
{
! $values['main'] =
intval($values['id']);
! $values['level'] = 0;
}
}
--- 692,706 ----
$this->reparent($values);
}
! if (!isset($values['main']) || !isset($values['level']))
{
if ($values['parent'] && ($values['parent'] !=
0))
{
! $values['main'] =
intval($this->id2item(array('cat_id' => $values['parent'],'item' => 'main')));
! $values['level'] =
intval($this->id2item(array('cat_id' => $values['parent'],'item' =>
'level'))+1);
}
else
{
! $values['main'] =
intval($values['cat_id']);
! $values['parent'] =
$values['level'] = 0; // parent need to be set to 0, as it can be ''
}
}
***************
*** 715,719 ****
. $values['access'] . "', cat_main=" .
$values['main'] . ", cat_level=" . $values['level']
. " WHERE cat_appname='" .
$this->app_name . "' AND cat_id=" . intval($values['cat_id']);
-
$this->db->query($sql,__LINE__,__FILE__);
return intval($values['cat_id']);
--- 713,716 ----
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: phpgwapi/inc class.categories.inc.php,1.95,1.96,
Bettina Gille <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: preferences/inc class.bocategories.inc.php,1.11,1.12 class.uicategories.inc.php,1.19,1.20
- Next by Date:
[Phpgroupware-cvs] CVS: phpgwapi/inc class.categories.inc.php,1.96,1.97
- Previous by thread:
[Phpgroupware-cvs] CVS: preferences/inc class.bocategories.inc.php,1.11,1.12 class.uicategories.inc.php,1.19,1.20
- Next by thread:
[Phpgroupware-cvs] CVS: phpgwapi/inc class.categories.inc.php,1.96,1.97
- Index(es):