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.89,1.90


From: Bettina Gille <address@hidden>
Subject: [Phpgroupware-cvs] CVS: phpgwapi/inc class.categories.inc.php,1.89,1.90
Date: Wed, 25 Sep 2002 00:02:13 -0400

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

Modified Files:
        class.categories.inc.php 
Log Message:
added function for cat_select_box using xsl tpl

Index: class.categories.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.categories.inc.php,v
retrieving revision 1.89
retrieving revision 1.90
diff -C2 -r1.89 -r1.90
*** class.categories.inc.php    8 Sep 2002 20:39:51 -0000       1.89
--- class.categories.inc.php    25 Sep 2002 04:02:03 -0000      1.90
***************
*** 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,$parent_id);
                }
  
--- 58,61 ----
***************
*** 205,209 ****
                }
  
- 
                function return_sorted_array($start,$limit = True,$query = 
'',$sort = '',$order = '',$globals = False, $parent_id = '')
                {
--- 204,207 ----
***************
*** 266,271 ****
                                        . $querymethod;
  
-                       //$mainselect = ' AND cat_level=0';
- 
                        if ($limit)
                        {
--- 264,267 ----
***************
*** 345,349 ****
                        }
                        $this->total_records = count($cats);
- 
                        return $cats;
                }
--- 341,344 ----
***************
*** 483,486 ****
--- 478,551 ----
                }
  
+               function formatted_xslt_list($data)
+               {
+                       if(is_array($data))
+                       {
+                               $format = 
(isset($data['format'])?$data['format']:'select');
+                               $type = 
(isset($data['type'])?$data['type']:'all');
+                               $selected = 
(isset($data['selected'])?$data['selected']:'');
+                               $globals = 
(isset($data['globals'])?$data['globals']:False);
+                               $site_link = 
(isset($data['site_link'])?$data['site_link']:'site');
+                       }
+ 
+                       if (!is_array($selected))
+                       {
+                               $selected = explode(',',$selected);
+                       }
+ 
+                       if ($type != 'all')
+                       {
+                               $cats = 
$this->return_array($type,$start,False,$query,$sort,$order,$globals);
+                       }
+                       else
+                       {
+                               $cats = 
$this->return_sorted_array($start,False,$query,$sort,$order,$globals);
+                       }
+ 
+                       if ($format == 'select')
+                       {
+                               while (is_array($cats) && list(,$cat) = 
each($cats))
+                               {
+                                       $sel_cat = '';
+                                       if (in_array($cat['id'],$selected))
+                                       {
+                                               $sel_cat = 'selected';
+                                       }
+ 
+                                       $name = '';
+                                       for ($i=0;$i<$cat['level'];$i++)
+                                       {
+                                               $name .= '-';
+                                       }
+                                       $name .= 
$GLOBALS['phpgw']->strip_html($cat['name']);
+ 
+                                       if ($cat['app_name'] == 'phpgw')
+                                       {
+                                               $name .= ' <' . lang('Global') 
. '>';
+                                       }
+                                       if ($cat['owner'] == '-1')
+                                       {
+                                               $name .= ' <' . lang('Global') 
. ' ' . lang($this->app_name) . '>';
+                                       }
+ 
+                                       $cat_list[] = array
+                                       (
+                                               'id'            => $cat['id'],
+                                               'name'          => $name,
+                                               'selected_cat' => $sel_cat
+                                       );
+                               }
+ 
+                               for ($i=0;$i<count($cat_list);$i++)
+                               {
+                                       if ($cat_list[$i]['selected_cat'] != 
'selected')
+                                       {
+                                               
unset($cat_list[$i]['selected_cat']);
+                                       }
+                               }
+                               return $cat_list;
+                       }
+               }
+ 
                /*!
                @function add
***************
*** 522,566 ****
                @param $cat_id int - category id
                */
!               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__);
                }
  
--- 587,641 ----
                @param $cat_id int - category id
                */
!               function delete($data)
                {
!                       if(is_array($data))
                        {
!                               $cat_id                 = $data['cat_id'];
!                               $drop_subs              = 
(isset($data['drop_subs'])?$data['drop_subs']:False);
!                               $modify_subs    = 
(isset($data['modify_subs'])?$data['modify_subs']:False);
                        }
  
!                       if ($cat_id > 0)
                        {
!                               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__);
!                       }
                }
  





reply via email to

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