phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] preferences/inc/class.uicategories.inc.php, 1.27


From: nomail
Subject: [Phpgroupware-cvs] preferences/inc/class.uicategories.inc.php, 1.27
Date: Thu, 30 Dec 2004 12:19:04 +0100

Update of /preferences/inc
Modified Files:
        Branch: 
          class.uicategories.inc.php

date: 2004/12/30 11:19:04;  author: skwashd;  state: Exp;  lines: +241 -241

Log Message:
adding missing files to new HEAD
=====================================================================
Index: preferences/inc/class.uicategories.inc.php
diff -u preferences/inc/class.uicategories.inc.php:1.26 
preferences/inc/class.uicategories.inc.php:1.27
--- preferences/inc/class.uicategories.inc.php:1.26     Tue Jun 24 22:33:16 2003
+++ preferences/inc/class.uicategories.inc.php  Thu Dec 30 11:19:04 2004
@@ -4,10 +4,12 @@
        * http://www.phpgroupware.org                                           
   *
        * Written by Bettina Gille address@hidden                          *
        * -----------------------------------------------                       
   *
-       *  This program is free software; you can redistribute it and/or modify 
it *
-       *  under the terms of the GNU General Public License as published by 
the   *
-       *  Free Software Foundation; either version 2 of the License, or (at 
your  *
-       *  option) any later version.                                           
   *
+       * Copyright 2000 - 2003 Free Software Foundation, Inc                   
   *
+       *                                                                       
   *
+       * This program is free software; you can redistribute it and/or modify 
it  *
+       * under the terms of the GNU General Public License as published by the 
   *
+       * Free Software Foundation; either version 2 of the License, or (at 
your   *
+       * option) any later version.                                            
   *
        
\**************************************************************************/
        /* $Id$ */
 
@@ -21,56 +23,54 @@
                var $order;
                var $cat_id;
 
+               var $cats_app;
+
                var $public_functions = array
                (
-                       'index'         => True,
-                       'add'           => True,
-                       'edit'          => True,
-                       'delete'        => True
+                       'index'  => True,
+                       'add'    => True,
+                       'edit'   => True,
+                       'delete' => True
                );
 
                function uicategories()
                {
-                       $cats_app                       = 
get_var('cats_app',array('GET','POST'));      
+                       $cats_app                       = 
get_var('cats_app',array('GET','POST'));
 
                        $this->bo                       = 
CreateObject('preferences.bocategories',$cats_app);
                        $this->nextmatchs       = 
CreateObject('phpgwapi.nextmatchs');
                        $this->account          = 
$GLOBALS['phpgw_info']['user']['account_id'];
                        $this->user                     = 
$GLOBALS['phpgw_info']['user']['fullname'];
 
-                       $this->start            = $this->bo->start;
-                       $this->query            = $this->bo->query;
-                       $this->sort                     = $this->bo->sort;
-                       $this->order            = $this->bo->order;
-                       $this->cat_id           = $this->bo->cat_id;
+                       $this->start = $this->bo->start;
+                       $this->query = $this->bo->query;
+                       $this->sort  = $this->bo->sort;
+                       $this->order = $this->bo->order;
                }
 
                function save_sessiondata($cats_app)
                {
                        $data = array
                        (
-                               'start'         => $this->start,
-                               'query'         => $this->query,
-                               'sort'          => $this->sort,
-                               'order'         => $this->order
+                               'start' => $this->start,
+                               'query' => $this->query,
+                               'sort'  => $this->sort,
+                               'order' => $this->order
                        );
-
-                       if(isset($this->cat_id))
-                       {
-                               $data['cat_id'] = $this->cat_id;
-                       }
                        $this->bo->save_sessiondata($data,$cats_app);
                }
 
                function set_langs()
                {
                        
$GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
+                       
$GLOBALS['phpgw']->template->set_var('row_on',$GLOBALS['phpgw_info']['theme']['row_on']);
+                       
$GLOBALS['phpgw']->template->set_var('row_off',$GLOBALS['phpgw_info']['theme']['row_off']);
                        
$GLOBALS['phpgw']->template->set_var('lang_access',lang('Private'));
                        
$GLOBALS['phpgw']->template->set_var('lang_save',lang('Save'));
                        
$GLOBALS['phpgw']->template->set_var('user_name',$this->user);
                        
$GLOBALS['phpgw']->template->set_var('lang_search',lang('Search'));
-                       
$GLOBALS['phpgw']->template->set_var('lang_done',lang('Done'));
-                       
$GLOBALS['phpgw']->template->set_var('lang_cancel',lang('cancel'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_done',lang('done'));
                        
$GLOBALS['phpgw']->template->set_var('lang_sub',lang('Add sub'));
                        
$GLOBALS['phpgw']->template->set_var('lang_edit',lang('Edit'));
                        
$GLOBALS['phpgw']->template->set_var('lang_delete',lang('Delete'));
@@ -93,31 +93,33 @@
 
                function index()
                {
-                       $cats_app               = 
get_var('cats_app',array('GET','POST'));
-                       $extra                  = 
get_var('extra',array('GET','POST'));
-                       $global_cats    = 
get_var('global_cats',array('GET','POST'));
-                       $cats_level             = 
get_var('cats_level',array('GET','POST'));
+                       $cats_app    = get_var('cats_app',array('GET','POST'));
+                       $extra       = get_var('extra',array('GET','POST'));
+                       $global_cats = 
get_var('global_cats',array('GET','POST'));
+                       $cats_level  = 
get_var('cats_level',array('GET','POST'));
 
                        $link_data = array
                        (
-                               'menuaction'    => 
'preferences.uicategories.index',
-                               'cats_app'              => $cats_app,
-                               'extra'                 => $extra,
-                               'global_cats'   => $global_cats,
-                               'cats_level'    => $cats_level
+                               'menuaction'  => 
'preferences.uicategories.index',
+                               'cats_app'    => $cats_app,
+                               'extra'       => $extra,
+                               'global_cats' => $global_cats,
+                               'cats_level'  => $cats_level
                        );
 
-                       if ($extra)
+                       if($extra)
                        {
                                $edata = explode(',',$extra);
                        }
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
$GLOBALS['phpgw_info']['apps'][$cats_app]['title'].
                                ' '.lang('categories 
for').': '.$this->user;
                        $GLOBALS['phpgw']->common->phpgw_header();
+                       echo parse_navbar();
 
-                       
$GLOBALS['phpgw']->template->set_file(array('cat_list_t' => 'listcats.tpl'));
-                       
$GLOBALS['phpgw']->template->set_block('cat_list_t','cat_list');
-                       
$GLOBALS['phpgw']->template->set_block('cat_list_t','cat_row');
+                       
$GLOBALS['phpgw']->template->set_file(array('cat_list_t'  => 'listcats.tpl',
+                                                                               
                                'data_column' => 'listcats.tpl'));
+                       
$GLOBALS['phpgw']->template->set_block('cat_list_t','data_column','column');
+                       
$GLOBALS['phpgw']->template->set_block('cat_list_t','cat_list','list');
 
                        $this->set_langs();
 
@@ -126,7 +128,12 @@
                        
$GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
                        
$GLOBALS['phpgw']->template->set_var('doneurl',$GLOBALS['phpgw']->link('/preferences/index.php'));
 
-                       if (!$global_cats)
+                       if(!$this->start)
+                       {
+                               $this->start = 0;
+                       }
+
+                       if(!$global_cats)
                        {
                                $global_cats = False;
                        }
@@ -144,50 +151,53 @@
 
 // ------------------------------ end nextmatch 
------------------------------------------
 
-//------------------- list header variable template-declarations 
-------------------------
+//------------------- list header variable template-declarations 
------------------------- 
 
                        
$GLOBALS['phpgw']->template->set_var('sort_name',$this->nextmatchs->show_sort_order($this->sort,'cat_name',$this->order,'/index.php',lang('Name'),$link_data));
                        
$GLOBALS['phpgw']->template->set_var('sort_description',$this->nextmatchs->show_sort_order($this->sort,'cat_description',$this->order,'/index.php',lang('Description'),$link_data));
 
-                       $th_data = '';
                        if (is_array($edata))
                        {
                                for($i=0;$i<count($edata);$i++)
                                {
-                                       $th_data .= '<td bgcolor="' . 
$GLOBALS['phpgw_info']['theme']['th_bg'] . '">' . lang($edata[$i]) . 
'</td>'."\n";
+                                       
$GLOBALS['phpgw']->template->set_var('th_data','<td bgcolor="' . 
$GLOBALS['phpgw_info']['theme']['th_bg'] . '">' . lang($edata[$i]) . '</td>');
+                                       
$GLOBALS['phpgw']->template->fp('column','data_column',True);
                                }
                        }
-                       
$GLOBALS['phpgw']->template->set_var('th_data',$th_data);
+                       else
+                       {
+                               
$GLOBALS['phpgw']->template->set_var('th_data','');
+                       }
 
 // -------------------------- end header declaration 
--------------------------------------
 
                        for ($i=0;$i<count($cats);$i++)
                        {
-                               
$this->nextmatchs->template_alternate_row_color($GLOBALS['phpgw']->template);
+                               
$this->nextmatchs->template_alternate_row_color(&$GLOBALS['phpgw']->template);
 
                                if ($cats[$i]['app_name'] == 'phpgw')
                                {
-                                       $appendix = '&nbsp;&lt;' . 
lang('Global') . '&gt;';
+                                       $appendix = '&lt;' . lang('Global') . 
'&gt;';
                                }
                                elseif ($cats[$i]['owner'] == '-1')
                                {
-                                       $appendix = '&nbsp;&lt;' . 
lang('Global') . '&nbsp;' . $GLOBALS['phpgw_info']['apps'][$cats_app]['title'] 
. '&gt;';
+                                       $appendix = '&lt;' . lang('Global') . 
'&nbsp;' . $GLOBALS['phpgw_info']['apps'][$cats_app]['title'] . '&gt;';
                                }
                                else
                                {
                                        $appendix = '';
                                }
 
-                               $level  = $cats[$i]['level'];
+                               $level = $cats[$i]['level'];
 
                                if ($level > 0)
                                {
-                                       $space = '&nbsp;.&nbsp;';
+                                       $space = '&nbsp;&nbsp;';
                                        $spaceset = str_repeat($space,$level);
                                        $name = $spaceset . 
$GLOBALS['phpgw']->strip_html($cats[$i]['name']) . $appendix;
                                }
 
-                               $descr = 
$GLOBALS['phpgw']->strip_html($cats[$i]['descr']);
+                               $descr = 
$GLOBALS['phpgw']->strip_html($cats[$i]['description']);
                                if (!$descr) { $descr = '&nbsp;'; }
 
                                if (is_array($edata))
@@ -204,10 +214,6 @@
                                                
$GLOBALS['phpgw']->template->set_var('td_data',$this->cat_data($edata,$data));
                                        }
                                }
-                               else
-                               {
-                                       
$GLOBALS['phpgw']->template->set_var('td_data','');
-                               }
 
                                if ($level == 0)
                                {
@@ -216,20 +222,18 @@
                                }
 
                                $GLOBALS['phpgw']->template->set_var(array(
-                                       'name' => $name,
+                                       'name'  => $name,
                                        'descr' => $descr
                                ));
 
-                               
$GLOBALS['phpgw']->template->set_var('app_url',$GLOBALS['phpgw']->link('/' . 
$cats_app . '/index.php','cat_id=' . $cats[$i]['cat_id']));
+                               
$GLOBALS['phpgw']->template->set_var('app_url',$GLOBALS['phpgw']->link('/' . 
$cats_app . '/index.php','cat_id=' . $cats[$i]['id']));
 
                                if ($cats_level || ($level == 0))
                                {
-                                       if ($cats[$i]['owner'] == 
$this->account || $cats[$i]['app_name'] == 'phpgw'
-                                               || ($cats[$i]['owner'] == -1 && 
$cats[$i]['app_name'] == $cats_app))
+                                       if ($cats[$i]['owner'] == 
$this->account || $cats[$i]['app_name'] == 'phpgw')
                                        {
-                                               $link_data['parent'] = '';
                                                $link_data['menuaction'] = 
'preferences.uicategories.add';
-                                               $link_data['parent'] = 
$cats[$i]['cat_id'];
+                                               $link_data['cat_parent'] = 
$cats[$i]['id'];
                                                
$GLOBALS['phpgw']->template->set_var('add_sub',$GLOBALS['phpgw']->link('/index.php',$link_data));
                                                
$GLOBALS['phpgw']->template->set_var('lang_sub_entry',lang('Add sub'));
                                        }
@@ -240,8 +244,7 @@
                                        
$GLOBALS['phpgw']->template->set_var('lang_sub_entry','&nbsp;');
                                }
 
-                               $link_data['cat_id'] = '';
-                               $link_data['cat_id'] = $cats[$i]['cat_id'];
+                               $link_data['cat_id'] = $cats[$i]['id'];
                                if ($cats[$i]['owner'] == $this->account && 
$cats[$i]['app_name'] != 'phpgw')
                                {
                                        $link_data['menuaction'] = 
'preferences.uicategories.edit';
@@ -260,22 +263,21 @@
                                        
$GLOBALS['phpgw']->template->set_var('delete','');
                                        
$GLOBALS['phpgw']->template->set_var('lang_delete_entry','&nbsp;');
                                }
-                               
$GLOBALS['phpgw']->template->fp('rows','cat_row',True);
+                               
$GLOBALS['phpgw']->template->fp('list','cat_list',True);
                        }
                        $link_data['menuaction'] = 
'preferences.uicategories.add';
-                       $link_data['parent'] = '';
                        
$GLOBALS['phpgw']->template->set_var('add_action',$GLOBALS['phpgw']->link('/index.php',$link_data));
                        $this->save_sessiondata($cats_app);
 
-                       
$GLOBALS['phpgw']->template->fp('phpgw_body','cat_list',True);
+                       
$GLOBALS['phpgw']->template->pfp('out','cat_list_t',True);
                }
 
                function add()
                {
-                       $cats_app               = 
get_var('cats_app',array('POST','GET'));
-                       $extra                  = 
get_var('extra',array('POST','GET'));
-                       $global_cats    = 
get_var('global_cats',array('POST','GET'));
-                       $cats_level             = 
get_var('cats_level',array('POST','GET'));
+                       $cats_app    = get_var('cats_app',array('GET','POST'));
+                       $extra       = get_var('extra',array('GET','POST'));
+                       $global_cats = 
get_var('global_cats',array('GET','POST'));
+                       $cats_level  = 
get_var('cats_level',array('GET','POST'));
 
                        $link_data = array
                        (
@@ -286,56 +288,62 @@
                                'cats_level'  => $cats_level
                        );
 
-                       $values         = get_var('values',array('POST'));
-                       $parent         = get_var('parent',array('GET'));
-                       $cat_data       = get_var('cat_data',array('POST'));
-
-                       if ($_POST['save'])
-                       {
-                               if (is_array($cat_data))
-                               {
-                                       $data = serialize($cat_data);
-                               }
-
-                               if (is_array($values))
-                               {
-                                       $values['data'] = $data;
-
-                                       $error = 
$this->bo->check_values($values);
-                                       if (is_array($error))
-                                       {
-                                                $message = 
$GLOBALS['phpgw']->common->error_list($error);
-                                       }
-                                       else
-                                       {
-                                               $this->cat_id = 
$this->bo->save_cat($values);
-                                               $message = lang('Category %1 
has been added !', $values['name']);
-                                       }
-                               }
-                       }
-
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('Add %1 category for',
-                                                                               
                                        
$GLOBALS['phpgw_info']['apps'][$cats_app]['title']).':&nbsp;'.$this->user;
+                               
$GLOBALS['phpgw_info']['apps'][$cats_app]['title']).':&nbsp;'.$this->user;
                        $GLOBALS['phpgw']->common->phpgw_header();
+                       echo parse_navbar();
 
-                       $GLOBALS['phpgw']->template->set_file(array('cat_form' 
=> 'category_form.tpl'));
-                       
$GLOBALS['phpgw']->template->set_block('cat_form','data_row');
-                       
$GLOBALS['phpgw']->template->set_block('cat_form','add');
-                       
$GLOBALS['phpgw']->template->set_block('cat_form','edit');
-                       
$GLOBALS['phpgw']->template->set_block('cat_form','form');
+                       $new_parent      = $_POST['new_parent'];
+                       $cat_parent      = 
get_var('cat_parent',array('POST','GET'));
+                       $cat_name        = $_POST['cat_name'];
+                       $cat_description = $_POST['cat_description'];
+                       $cat_data        = $_POST['cat_data'];
+                       $cat_access      = $_POST['cat_access'];
+
+                       $GLOBALS['phpgw']->template->set_file(array('form' => 
'category_form.tpl'));
+                       
$GLOBALS['phpgw']->template->set_block('form','data_row','row');
+                       
$GLOBALS['phpgw']->template->set_block('form','add','addhandle');
+                       
$GLOBALS['phpgw']->template->set_block('form','edit','edithandle');
 
                        $this->set_langs();
 
-                       
$GLOBALS['phpgw']->template->set_var('title_categories',lang('Add %1 category 
for',lang($cats_app)));
-                       
$GLOBALS['phpgw']->template->set_var('message',$message);
-                       
$GLOBALS['phpgw']->template->set_var('lang_app',lang($cats_app));
-                       
$GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
+                       if ($new_parent)
+                       {
+                               $cat_parent = $new_parent;
+                       }
 
                        if (!$global_cats)
                        {
                                $global_cats = False;
                        }
 
+                       if ($_POST['save'])
+                       {
+                               $data = serialize($cat_data);
+
+                               $values = array
+                               (
+                                       'parent' => $cat_parent,
+                                       'descr'  => $cat_description,
+                                       'name'   => $cat_name,
+                                       'access' => $cat_access,
+                                       'data'   => $data
+                               );
+
+                               $error = $this->bo->check_values($values);
+                               if (is_array($error))
+                               {
+                                       
$GLOBALS['phpgw']->template->set_var('message',$GLOBALS['phpgw']->common->error_list($error));
+                               }
+                               else
+                               {
+                                       $this->bo->save_cat($values);
+                                       
$GLOBALS['phpgw']->template->set_var('message',lang('Category %1 has been added 
!', $cat_name));
+                               }
+                       }
+
+                       
$GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
+
                        if ($cats_level)
                        {
                                $type = 'all';
@@ -345,122 +353,123 @@
                                $type = 'mains';
                        }
 
-                       if ($values['parent'])
-                       {
-                               $parent = $values['parent'];
-                       }
+                       
$GLOBALS['phpgw']->template->set_var('category_list',$this->bo->cats->formated_list('select',$type,$cat_parent,$global_cats));
+                       
$GLOBALS['phpgw']->template->set_var('cat_name',$cat_name);
+                       
$GLOBALS['phpgw']->template->set_var('cat_description',$cat_description);
 
-                       
$GLOBALS['phpgw']->template->set_var('category_list',$this->bo->cats->formatted_list(array('format'
     => 'select',
-                                                                               
                                                                                
                                                'type'  => $type,
-                                                                               
                                                                                
                                        'selected'      => $parent,
-                                                                               
                                                                                
                                        'globals'       => $global_cats)));
-                       
$GLOBALS['phpgw']->template->set_var('cat_name',$values['name']);
-                       
$GLOBALS['phpgw']->template->set_var('cat_description',$values['descr']);
-
-                       
$GLOBALS['phpgw']->template->set_var('access',$values['access'] == 'private'?' 
checked':'');
+                       $GLOBALS['phpgw']->template->set_var('access','<input 
type="checkbox" name="cat_access" value="True"'
+                               . ($cat_access == True ?' checked':'') . '>');
 
                        if ($extra)
                        {
                                $edata = explode(',',$extra);
                                for($i=0;$i<count($edata);$i++)
                                {
+                                       
$GLOBALS['phpgw']->template->set_var('tr_color',$GLOBALS['phpgw']->nextmatchs->alternate_row_color());
                                        
$GLOBALS['phpgw']->template->set_var('td_data','<input name="cat_data[' . 
$edata[$i] . ']" size="50" value="' . $cat_data[$edata[$i]] . '">');
                                        
$GLOBALS['phpgw']->template->set_var('lang_data',lang($edata[$i]));
-                                       
$GLOBALS['phpgw']->template->fp('rows','data_row',True);
+                                       
$GLOBALS['phpgw']->template->fp('row','data_row',True);
                                }
                        }
-                       else
-                       {
-                               $GLOBALS['phpgw']->template->set_var('rows','');
-                       }
 
                        $link_data['menuaction'] = 
'preferences.uicategories.index';
                        
$GLOBALS['phpgw']->template->set_var('cancel_url',$GLOBALS['phpgw']->link('/index.php',$link_data));
-
-                       $GLOBALS['phpgw']->template->parse('buttons','add');
-                       $GLOBALS['phpgw']->template->fp('phpgw_body','form');
+                       $GLOBALS['phpgw']->template->set_var('edithandle','');
+                       $GLOBALS['phpgw']->template->set_var('addhandle','');
+                       $GLOBALS['phpgw']->template->pfp('out','form');
+                       $GLOBALS['phpgw']->template->pfp('addhandle','add');
                }
 
                function edit()
                {
-                       $cats_app               = 
get_var('cats_app',array('POST','GET'));
-                       $extra                  = 
get_var('extra',array('POST','GET'));
-                       $global_cats    = 
get_var('global_cats',array('POST','GET'));
-                       $cats_level             = 
get_var('cats_level',array('POST','GET'));
+                       $cats_app    = get_var('cats_app',array('GET','POST'));
+                       $extra       = get_var('extra',array('GET','POST'));
+                       $global_cats = 
get_var('global_cats',array('GET','POST'));
+                       $cats_level  = 
get_var('cats_level',array('GET','POST'));
+                       $cat_id      = get_var('cat_id',array('GET','POST'));
 
                        $link_data = array
                        (
-                               'menuaction'  => 
'preferences.uicategories.index',
-                               'cats_app'    => $cats_app,
-                               'extra'       => $extra,
-                               'global_cats' => $global_cats,
-                               'cats_level'  => $cats_level
+                               'menuaction'    => 
'preferences.uicategories.index',
+                               'cats_app'              => $cats_app,
+                               'extra'                 => $extra,
+                               'global_cats'   => $global_cats,
+                               'cats_level'    => $cats_level,
+                               'cat_id'                => $cat_id
                        );
 
-                       if (!$this->cat_id)
+                       if (!$cat_id)
                        {
                                
$GLOBALS['phpgw']->link_redirect('/index.php',$link_data);
                        }
 
-                       $values         = get_var('values',Array('POST'));
-                       $cat_data       = get_var('cat_data',Array('POST'));
-
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('Edit %1 category for',
                                
$GLOBALS['phpgw_info']['apps'][$cats_app]['title']).':&nbsp;'.$this->user;
                        $GLOBALS['phpgw']->common->phpgw_header();
+                       echo parse_navbar();
+
+                       $new_parent                     = $_POST['new_parent'];
+                       $cat_parent                     = $_POST['cat_parent'];
+                       $cat_name                       = $_POST['cat_name'];
+                       $cat_description        = $_POST['cat_description'];
+                       $cat_data                       = $_POST['cat_data'];
+                       $cat_access                     = $_POST['cat_access'];
+                       $old_parent                     = $_POST['old_parent'];
+
+                       $GLOBALS['phpgw']->template->set_file(array('form' => 
'category_form.tpl'));
+                       
$GLOBALS['phpgw']->template->set_block('form','data_row','row');
+                       
$GLOBALS['phpgw']->template->set_block('form','add','addhandle');
+                       
$GLOBALS['phpgw']->template->set_block('form','edit','edithandle');
+
+                       $this->set_langs();
+                       
$GLOBALS['phpgw']->template->set_var('cancel_url',$GLOBALS['phpgw']->link('/index.php',$link_data));
+
+                       if ($new_parent)
+                       {
+                               $cat_parent = $new_parent;
+                       }
+
+                       if (!$global_cats)
+                       {
+                               $global_cats = False;
+                       }
 
                        if ($_POST['save'])
                        {
-                               if (is_array($cat_data))
+                               $data = serialize($cat_data);
+
+                               $values = array
+                               (
+                                       'id'                    => $cat_id,
+                                       'parent'                => $cat_parent,
+                                       'descr'                 => 
$cat_description,
+                                       'name'                  => $cat_name,
+                                       'access'                => $cat_access,
+                                       'data'                  => $data,
+                                       'old_parent'    => $old_parent
+                               );
+
+                               $error = $this->bo->check_values($values);
+                               if (is_array($error))
                                {
-                                       $data = serialize($cat_data);
+                                       
$GLOBALS['phpgw']->template->set_var('message',$GLOBALS['phpgw']->common->error_list($error));
                                }
-
-                               if (is_array($values))
+                               else
                                {
-                                       $values['cat_id']       = $this->cat_id;
-                                       $values['data']         = $data;
-
-                                       $error = 
$this->bo->check_values($values);
-                                       if (is_array($error))
-                                       {
-                                               $message = 
$GLOBALS['phpgw']->common->error_list($error);
-                                       }
-                                       else
-                                       {
-                                               $this->cat_id = 
$this->bo->save_cat($values);
-                                               $message = lang('Category %1 
has been updated !',$values['name']);
-                                       }
+                                       $cat_id = $this->bo->save_cat($values);
+                                       
$GLOBALS['phpgw']->template->set_var('message',lang('Category %1 has been 
updated !',$cat_name));
                                }
                        }
 
-                       $GLOBALS['phpgw']->template->set_file(array('cat_form' 
=> 'category_form.tpl'));
-                       
$GLOBALS['phpgw']->template->set_block('cat_form','data_row');
-                       
$GLOBALS['phpgw']->template->set_block('cat_form','add');
-                       
$GLOBALS['phpgw']->template->set_block('cat_form','edit');
-                       
$GLOBALS['phpgw']->template->set_block('cat_form','form');
-
-                       $this->set_langs();
-
-                       $cats = $this->bo->cats->return_single($this->cat_id);
-
-                       
$GLOBALS['phpgw']->template->set_var('title_categories',lang('Edit %1 category 
for',lang($cats_app)));
-                       
$GLOBALS['phpgw']->template->set_var('message',$message);
-                       
$GLOBALS['phpgw']->template->set_var('lang_app',lang($cats_app));
-                       
$GLOBALS['phpgw']->template->set_var('cancel_url',$GLOBALS['phpgw']->link('/index.php',$link_data));
+                       $cats = $this->bo->cats->return_single($cat_id);
 
                        $link_data['menuaction'] = 
'preferences.uicategories.edit';
-                       $link_data['cat_id'] = $this->cat_id;
                        
$GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
 
-                       
$GLOBALS['phpgw']->template->set_var('old_parent',$cats['parent']);
-                       
$GLOBALS['phpgw']->template->set_var('cat_name',$GLOBALS['phpgw']->strip_html($cats['name']));
-                       
$GLOBALS['phpgw']->template->set_var('cat_description',$GLOBALS['phpgw']->strip_html($cats['descr']));
+                       
$GLOBALS['phpgw']->template->set_var('cat_name',$GLOBALS['phpgw']->strip_html($cats[0]['name']));
+                       
$GLOBALS['phpgw']->template->set_var('cat_description',$GLOBALS['phpgw']->strip_html($cats[0]['description']));
 
-                       if (!$global_cats)
-                       {
-                               $global_cats = False;
-                       }
+                       
$GLOBALS['phpgw']->template->set_var('hidden_vars','<input type="hidden" 
name="old_parent" value="' . $cats[0]['parent'] . '">');
 
                        if ($cats_level)
                        {
@@ -471,52 +480,49 @@
                                $type = 'mains';
                        }
 
-                       
$GLOBALS['phpgw']->template->set_var('category_list',$this->bo->cats->formatted_list(array('format'
     => 'select',
-                                                                               
                                                                                
                                                'type'  => $type,
-                                                                               
                                                                                
                                        'selected'      => $cats['parent'],
-                                                                               
                                                                                
                                        'globals'       => $global_cats,
-                                                                               
                                                                                
                                                'self'  => $this->cat_id)));
+                       
$GLOBALS['phpgw']->template->set_var('category_list',$this->bo->cats->formated_list(array('type'
 => $type,'selected' => $cats[0]['parent'],
+                                                                               
                                                                                
                                        'globals' => $global_cats, 'self' => 
$cat_id)));
 
-                       
$GLOBALS['phpgw']->template->set_var('access',$cats['access'] == 'private'?' 
checked':'');
+                       $GLOBALS['phpgw']->template->set_var('access','<input 
type="checkbox" name="cat_access" value="True"'
+                                                                               
                . ($cats[0]['access'] == private ?' checked':'') . '>');
 
                        if ($extra)
                        {
                                $edata = explode(',',$extra);
 
-                               $data = unserialize($cats['data']);
+                               $data = unserialize($cats[0]['data']);
                                for($i=0;$i<count($edata);$i++)
                                {
                                        
$GLOBALS['phpgw']->template->set_var('td_data','<input name="cat_data[' . 
$edata[$i] . ']" size="50" value="' . $data[$edata[$i]] . '">');
                                        
$GLOBALS['phpgw']->template->set_var('lang_data',lang($edata[$i]));
-                                       
$GLOBALS['phpgw']->template->fp('rows','data_row',True);
+                                       
$GLOBALS['phpgw']->template->fp('row','data_row',True);
                                }
                        }
-                       else
-                       {
-                               $GLOBALS['phpgw']->template->set_var('rows','');
-                       }
 
-                       if ($cats['owner'] == $this->account)
+                       if ($cats[0]['owner'] == $this->account)
                        {
                                $link_data['menuaction'] = 
'preferences.uicategories.delete';
                                
$GLOBALS['phpgw']->template->set_var('delete','<form method="POST" action="' . 
$GLOBALS['phpgw']->link('/index.php',$link_data)
-                                                                               
                                        . '"><input type="submit" value="' . 
lang('Delete') .'"></form>');
+                                       . '"><input type="submit" value="' . 
lang('Delete') .'"></form>');
                        }
                        else
                        {
                                
$GLOBALS['phpgw']->template->set_var('delete','&nbsp;');
                        }
 
-                       $GLOBALS['phpgw']->template->parse('buttons','edit');
-                       $GLOBALS['phpgw']->template->fp('phpgw_body','form');
+                       $GLOBALS['phpgw']->template->set_var('edithandle','');
+                       $GLOBALS['phpgw']->template->set_var('addhandle','');
+                       $GLOBALS['phpgw']->template->pfp('out','form');
+                       $GLOBALS['phpgw']->template->pfp('edithandle','edit');
                }
 
                function delete()
                {
-                       $cats_app               = 
get_var('cats_app',array('POST','GET'));
-                       $extra                  = 
get_var('extra',array('POST','GET'));
-                       $global_cats    = 
get_var('global_cats',array('POST','GET'));
-                       $cats_level             = 
get_var('cats_level',array('POST','GET'));
+                       $cats_app    = get_var('cats_app',array('GET','POST'));
+                       $extra       = get_var('extra',array('GET','POST'));
+                       $global_cats = 
get_var('global_cats',array('GET','POST'));
+                       $cats_level  = 
get_var('cats_level',array('GET','POST'));
+                       $cat_id      = get_var('cat_id',array('GET','POST'));
 
                        $link_data = array
                        (
@@ -524,10 +530,11 @@
                                'cats_app'    => $cats_app,
                                'extra'       => $extra,
                                'global_cats' => $global_cats,
-                               'cats_level'  => $cats_level
+                               'cats_level'  => $cats_level,
+                               'cat_id'      => $cat_id
                        );
 
-                       if (!$this->cat_id || $_POST['cancel'])
+                       if (!$cat_id || $_POST['cancel'])
                        {
                                
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
                        }
@@ -536,55 +543,48 @@
                        {
                                if ($_POST['subs'])
                                {
-                                       switch ($_POST['subs'])
-                                       {
-                                               case 'move':
-                                                       
$this->bo->delete(array('cat_id' => $this->cat_id,'modify_subs' => True));
-                                                       break;
-                                               case 'drop':
-                                                       
$this->bo->delete(array('cat_id' => $this->cat_id,'drop_subs' => True));
-                                                       break;
-                                               default:
-                                                       $error_msg = 
lang('Please choose one of the methods to handle the subcategories');
-                                                       break;
-                                       }
+                                       $this->bo->delete($cat_id,True);
                                }
                                else
                                {
-                                       $this->bo->delete(array('cat_id' => 
$this->cat_id));
+                                       $this->bo->delete($cat_id,False);
                                }
                                
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
                        }
+                       else
+                       {
+                               
$GLOBALS['phpgw']->template->set_file(array('category_delete' => 'delete.tpl'));
 
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('Delete Categories');
-                       $GLOBALS['phpgw']->common->phpgw_header();
-                       
$GLOBALS['phpgw']->template->set_file(array('category_delete' => 'delete.tpl'));
+                               $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('Delete Categories');
+                               $GLOBALS['phpgw']->common->phpgw_header();
+                               echo parse_navbar();
+
+                               
$GLOBALS['phpgw']->template->set_var('deleteheader',lang('Are you sure you want 
to delete this category ?'));
+
+                               $exists = $this->bo->exists(array
+                               (
+                                       'type'     => 'subs',
+                                       'cat_name' => '',
+                                       'cat_id'   => $cat_id
+                               ));
 
-                       
$GLOBALS['phpgw']->template->set_var('error_msg',$error_msg);
-                       
$GLOBALS['phpgw']->template->set_var('deleteheader',lang('Are you sure you want 
to delete this category ?'));
+                               if ($exists)
+                               {
+                                       
$GLOBALS['phpgw']->template->set_var('lang_subs',lang('Do you also want to 
delete all subcategories ?'));
+                                       
$GLOBALS['phpgw']->template->set_var('subs','<input type="checkbox" name="subs" 
value="True">');
+                               }
+                               else
+                               {
+                                       
$GLOBALS['phpgw']->template->set_var('lang_subs','');
+                                       
$GLOBALS['phpgw']->template->set_var('subs', '');
+                               }
 
-                       $exists = $this->bo->exists(array
-                       (
-                               'type'     => 'subs',
-                               'cat_name' => '',
-                               'cat_id'   => $this->cat_id
-                       ));
-
-                       if ($exists)
-                       {
-                                       $sub_select = '<input type="radio" 
name="subs" value="move">' . lang('Do you want to move all subcategories one 
level down ?') . '<br>';
-                                       $sub_select .= '<input type="radio" 
name="subs" value="drop">' . lang('Do you want to delete all subcategories ?');
-                                       
$GLOBALS['phpgw']->template->set_var('sub_select',$sub_select);
-                       }
-
-                       
$GLOBALS['phpgw']->template->set_var('nolink',$GLOBALS['phpgw']->link('/index.php',$link_data));
-                       
$GLOBALS['phpgw']->template->set_var('lang_no',lang('No'));
-
-                       $link_data['menuaction'] = 
'preferences.uicategories.delete';
-                       $link_data['cat_id'] = $this->cat_id;
-                       
$GLOBALS['phpgw']->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php',$link_data));
-                       
$GLOBALS['phpgw']->template->set_var('lang_yes',lang('Yes'));
-                       
$GLOBALS['phpgw']->template->fp('phpgw_body','category_delete');
+                               
$GLOBALS['phpgw']->template->set_var('lang_no',lang('No'));
+                               $link_data['menuaction'] = 
'preferences.uicategories.delete';
+                               
$GLOBALS['phpgw']->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php',$link_data));
+                               
$GLOBALS['phpgw']->template->set_var('lang_yes',lang('Yes'));
+                               
$GLOBALS['phpgw']->template->pfp('out','category_delete');
+                       }
                }
        }
 ?>




reply via email to

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