phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: phpgwapi/inc class.categories.inc.php,1.74.2.11,


From: Bettina Gille <address@hidden>
Subject: [Phpgroupware-cvs] CVS: phpgwapi/inc class.categories.inc.php,1.74.2.11,1.74.2.12
Date: Thu, 12 Sep 2002 12:31:35 -0400

Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv1057

Modified Files:
      Tag: Version-0_9_14-branch
        class.categories.inc.php 
Log Message:
update delete function to support sitemgr

Index: class.categories.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.categories.inc.php,v
retrieving revision 1.74.2.11
retrieving revision 1.74.2.12
diff -C2 -r1.74.2.11 -r1.74.2.12
*** class.categories.inc.php    2 Sep 2002 22:04:07 -0000       1.74.2.11
--- class.categories.inc.php    12 Sep 2002 16:31:32 -0000      1.74.2.12
***************
*** 5,10 ****
        *                  and Bettina Gille address@hidden                *
        * Category manager                                                      
   *
!       * Copyright (C) 2000,2001,2002 Joseph Engo                              
   *
!       * 
-------------------------------------------------------------------------*
        * This library is part of the phpGroupWare API                          
   *
        * http://www.phpgroupware.org/api                                       
   * 
--- 5,10 ----
        *                  and Bettina Gille address@hidden                *
        * Category manager                                                      
   *
!       * Copyright (C) 2000 - 2002 Joseph Engo                                 
   *
!       * 
------------------------------------------------------------------------ *
        * This library is part of the phpGroupWare API                          
   *
        * http://www.phpgroupware.org/api                                       
   * 
***************
*** 58,62 ****
                        $this->db         = $GLOBALS['phpgw']->db;
                        $this->grants     = 
$GLOBALS['phpgw']->acl->get_grants($app_name);
-                       $this->cats       = 
$this->return_array($type,$start,$limit,$query,$sort,$order,$globals);
                }
  
--- 58,61 ----
***************
*** 75,78 ****
--- 74,79 ----
                                case 'appandmains': $s = " AND cat_appname='" . 
$this->app_name . "' AND cat_parent ='0'"; break;
                                case 'appandsubs':  $s = " AND cat_appname='" . 
$this->app_name . "' AND cat_parent !='0'"; break;
+                               case 'noglobal':        $s = " AND cat_appname 
!= '" . $this->app_name . "'"; break;
+                               case 'noglobalapp':     $s = " AND cat_appname 
= '" . $this->app_name . "' AND cat_owner != '" . $this->account_id . "'"; 
break;
                                default:            return False;
                        }
***************
*** 203,208 ****
                }
  
! 
!               function return_sorted_array($start,$limit = True,$query = 
'',$sort = '',$order = '',$globals = False)
                {
                        if ($globals)
--- 204,208 ----
                }
  
!               function return_sorted_array($start,$limit = True,$query = 
'',$sort = '',$order = '',$globals = False, $parent_id = '')
                {
                        if ($globals)
***************
*** 243,250 ****
                                else
                                {
!                                       $grant_cats = " cat_owner='" . 
$this->account_id . "' OR cat_owner='-1' ";
                                }
                        }
  
                        if ($query)
                        {
--- 243,259 ----
                                else
                                {
!                                       $grant_cats = " cat_owner='" . 
$this->account_id . "' or cat_owner='-1' ";
                                }
                        }
  
+                       if ($parent_id)
+                       {
+                               $parent_select = " AND cat_parent='$parent_id'";
+                       }
+                       else
+                       {
+                               $parent_select = " AND cat_parent='0'";
+                       }
+ 
                        if ($query)
                        {
***************
*** 255,267 ****
                                        . $querymethod;
  
-                       $mainselect = ' AND cat_level=0';
- 
                        if ($limit)
                        {
!                               $this->db->limit_query($sql . $mainselect . 
$ordermethod,$start,__LINE__,__FILE__);
                        }
                        else
                        {
!                               $this->db->query($sql . $mainselect . 
$ordermethod,__LINE__,__FILE__);
                        }
  
--- 264,274 ----
                                        . $querymethod;
  
                        if ($limit)
                        {
!                               $this->db->limit_query($sql . $parent_select . 
$ordermethod,$start,__LINE__,__FILE__);
                        }
                        else
                        {
!                               $this->db->query($sql . $parent_select . 
$ordermethod,__LINE__,__FILE__);
                        }
  
***************
*** 285,297 ****
                        for ($i=0;$i < $num_cats;$i++)
                        {
!                               $subselect = " AND cat_parent='" . 
$cats[$i]['id'] . "' AND cat_level='" . ($cats[$i]['level']+1) . "'";
  
                                if ($limit)
                                {
!                                       $this->db->limit_query($sql . 
$subselect . $ordermethod,$start,__LINE__,__FILE__);
                                }
                                else
                                {
!                                       $this->db->query($sql . $subselect . 
$ordermethod,__LINE__,__FILE__);
                                }
  
--- 292,304 ----
                        for ($i=0;$i < $num_cats;$i++)
                        {
!                               $sub_select = " AND cat_parent='" . 
$cats[$i]['id'] . "' AND cat_level='" . ($cats[$i]['level']+1) . "'";
  
                                if ($limit)
                                {
!                                       $this->db->limit_query($sql . 
$sub_select . $ordermethod,$start,__LINE__,__FILE__);
                                }
                                else
                                {
!                                       $this->db->query($sql . $sub_select . 
$ordermethod,__LINE__,__FILE__);
                                }
  
***************
*** 334,338 ****
                        }
                        $this->total_records = count($cats);
- 
                        return $cats;
                }
--- 341,344 ----
***************
*** 509,513 ****
                @param $cat_id int - category id
                */
!               function delete($cat_id,$subs = False)
                {
                        if ($subs)
--- 515,519 ----
                @param $cat_id int - category id
                */
!               /*function delete($cat_id,$subs = False)
                {
                        if ($subs)
***************
*** 517,521 ****
  
                        $this->db->query("DELETE FROM phpgw_categories WHERE 
cat_id='$cat_id' $subdelete AND cat_appname='"
!                               . $this->app_name . "'",__LINE__,__FILE__);
                }
  
--- 523,570 ----
  
                        $this->db->query("DELETE FROM phpgw_categories WHERE 
cat_id='$cat_id' $subdelete AND cat_appname='"
!                                                       . $this->app_name . 
"'",__LINE__,__FILE__);
!               } */
! 
!               function delete($cat_id, $drop_subs = False, $modify_subs = 
False)
!               {
!                       if ($drop_subs)
!                       {
!                               $subdelete = ' OR cat_parent=' . $cat_id . ' OR 
cat_main=' . $cat_id; 
!                       }
! 
!                       if ($modify_subs)
!                       {
!                               $cats = 
$this->return_sorted_array('',False,'','','',False, $cat_id);
! 
!                               $new_parent = $this->id2name($cat_id,'parent');
! 
!                               for ($i=0;$i<count($cats);$i++)
!                               {
!                                       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
!                                       {
!                                               if ($new_main)
!                                               {
!                                                       $update_main = 
',cat_main=' . $new_main;
!                                               }
! 
!                                               if ($cats[$i]['parent'] == 
$cat_id)
!                                               {
!                                                       $update_parent = 
',cat_parent=' . $new_parent;
!                                               }
! 
!                                               $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__);
!                                       }
!                               }
!                       }
! 
!                       $this->db->query("DELETE FROM phpgw_categories WHERE 
cat_id='" . $cat_id . $subdelete . "'AND cat_appname='"
!                                                       . $this->app_name . 
"'",__LINE__,__FILE__);
                }
  
***************
*** 555,560 ****
                {
                        $this->db->query("SELECT cat_id FROM phpgw_categories 
WHERE cat_name='" . $this->db->db_addslashes($cat_name) . "' "
!                               ."AND cat_appname='" . $this->app_name . "' "
!                               ."AND cat_owner=" . 
$this->account_id,__LINE__,__FILE__);
  
                        if(!$this->db->num_rows())
--- 604,608 ----
                {
                        $this->db->query("SELECT cat_id FROM phpgw_categories 
WHERE cat_name='" . $this->db->db_addslashes($cat_name) . "' "
!                                                       ."AND cat_appname='" . 
$this->app_name . "' AND cat_owner=" . $this->account_id,__LINE__,__FILE__);
  
                        if(!$this->db->num_rows())
***************
*** 576,583 ****
                        switch($item)
                        {
!                               case 'name':  $value = 'cat_name'; break;
!                               case 'owner': $value = 'cat_owner'; break;
!                               case 'main':  $value = 'cat_main'; break;
!                               case 'level': $value = 'cat_level'; break;
                        }
  
--- 624,632 ----
                        switch($item)
                        {
!                               case 'name':    $value = 'cat_name'; break;
!                               case 'owner':   $value = 'cat_owner'; break;
!                               case 'main':    $value = 'cat_main'; break;
!                               case 'level':   $value = 'cat_level'; break;
!                               case 'parent':  $value = 'cat_parent'; break;
                        }
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]