source: trunk/preferences/inc/class.uicategories.inc.php @ 7655

Revision 7655, 20.5 KB checked in by douglasz, 11 years ago (diff)

Ticket #3236 - Melhorias de performance no codigo do Expresso.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        /**************************************************************************\
3        * phpGroupWare - Preferences - categories                                  *
4        * http://www.phpgroupware.org                                              *
5        * Written by Bettina Gille [ceb@phpgroupware.org]                          *
6        * -----------------------------------------------                          *
7        * Copyright 2000 - 2003 Free Software Foundation, Inc                      *
8        *                                                                          *
9        * This program is free software; you can redistribute it and/or modify it  *
10        * under the terms of the GNU General Public License as published by the    *
11        * Free Software Foundation; either version 2 of the License, or (at your   *
12        * option) any later version.                                               *
13        \**************************************************************************/
14
15        class uicategories
16        {
17                var $bo;
18
19                var $start;
20                var $query;
21                var $sort;
22                var $order;
23                var $cat_id;
24
25                var $cats_app;
26
27                var $public_functions = array
28                (
29                        'index'  => True,
30                        'add'    => True,
31                        'edit'   => True,
32                        'delete' => True
33                );
34
35                function uicategories()
36                {
37                        $cats_app                       = get_var('cats_app',array('GET','POST'));
38
39                        $this->bo                       = CreateObject('preferences.bocategories',$cats_app);
40                        $this->nextmatchs       = CreateObject('phpgwapi.nextmatchs');
41                        $this->account          = $GLOBALS['phpgw_info']['user']['account_id'];
42                        $this->user                     = $GLOBALS['phpgw_info']['user']['fullname'];
43
44                        $this->start = $this->bo->start;
45                        $this->query = $this->bo->query;
46                        $this->sort  = $this->bo->sort;
47                        $this->order = $this->bo->order;
48                }
49
50                function save_sessiondata($cats_app)
51                {
52                        $data = array
53                        (
54                                'start' => $this->start,
55                                'query' => $this->query,
56                                'sort'  => $this->sort,
57                                'order' => $this->order
58                        );
59                        $this->bo->save_sessiondata($data,$cats_app);
60                }
61
62                function set_langs()
63                {
64                        $GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
65                        $GLOBALS['phpgw']->template->set_var('row_on',$GLOBALS['phpgw_info']['theme']['row_on']);
66                        $GLOBALS['phpgw']->template->set_var('row_off',$GLOBALS['phpgw_info']['theme']['row_off']);
67                        $GLOBALS['phpgw']->template->set_var('lang_access',lang('Private'));
68                        $GLOBALS['phpgw']->template->set_var('lang_save',lang('Save'));
69                        $GLOBALS['phpgw']->template->set_var('user_name',$this->user);
70                        $GLOBALS['phpgw']->template->set_var('lang_search',lang('Search'));
71                        $GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel'));
72                        $GLOBALS['phpgw']->template->set_var('lang_sub',lang('Add sub'));
73                        $GLOBALS['phpgw']->template->set_var('lang_edit',lang('Edit'));
74                        $GLOBALS['phpgw']->template->set_var('lang_delete',lang('Delete'));
75                        $GLOBALS['phpgw']->template->set_var('lang_parent',lang('Parent category'));
76                        $GLOBALS['phpgw']->template->set_var('lang_none',lang('None'));
77                        $GLOBALS['phpgw']->template->set_var('lang_name',lang('Name'));
78                        $GLOBALS['phpgw']->template->set_var('lang_descr',lang('Description'));
79                        $GLOBALS['phpgw']->template->set_var('lang_add',lang('Add'));
80                        $GLOBALS['phpgw']->template->set_var('lang_reset',lang('Clear Form'));
81                }
82
83                function cat_data($edata,$data)
84                {
85                        for ($j=0;$j<count($edata);++$j)
86                        {
87                                $td_data .= '<td>' . $data[$edata[$j]] . '</td>' . "\n";
88                        }
89                        return $td_data;
90                }
91
92                function index()
93                {
94                        $cats_app    = get_var('cats_app',array('GET','POST'));
95                        $extra       = get_var('extra',array('GET','POST'));
96                        $global_cats = get_var('global_cats',array('GET','POST'));
97                        $cats_level  = get_var('cats_level',array('GET','POST'));
98
99                        $this->bo->query = get_var('query',array('GET','POST'));
100                        $this->bo->order = get_var('order',array('GET','POST'));
101                        $this->bo->start = get_var('start',array('GET','POST'));
102                        $this->bo->sort  = get_var('sort',array('GET','POST'));
103                        $this->query = get_var('query',array('GET','POST'));
104                        $this->order = get_var('order',array('GET','POST'));
105                        $this->start = get_var('start',array('GET','POST'));
106                        $this->sort  = get_var('sort',array('GET','POST'));
107                        $GLOBALS['query'] = get_var('query',array('GET','POST'));
108
109                        $link_data = array
110                        (
111                                'menuaction'  => 'preferences.uicategories.index',
112                                'cats_app'    => $cats_app,
113                                'extra'       => $extra,
114                                'global_cats' => $global_cats,
115                                'cats_level'  => $cats_level
116                        );
117
118                        if($extra)
119                        {
120                                $edata = explode(',',$extra);
121                        }
122                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps'][$cats_app]['title'].
123                                '&nbsp;'.lang('categories for').':&nbsp;'.$this->user;
124                        $GLOBALS['phpgw']->common->phpgw_header();
125                        echo parse_navbar();
126
127                        $GLOBALS['phpgw']->template->set_file(array(
128                                'cat_list_t'  => 'listcats.tpl',
129                                'data_column' => 'listcats.tpl'
130                        ));
131                        $GLOBALS['phpgw']->template->set_block('cat_list_t','data_column','column');
132                        $GLOBALS['phpgw']->template->set_block('cat_list_t','cat_list','list');
133
134                        $this->set_langs();
135
136                        $GLOBALS['phpgw']->template->set_var('title_categories',lang('categories for'));
137                        $GLOBALS['phpgw']->template->set_var('lang_app',lang($cats_app));
138                        $GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
139                        $GLOBALS['phpgw']->template->set_var('doneurl',$GLOBALS['phpgw']->link('/preferences/index.php'));
140
141                        if(!$this->start)
142                        {
143                                $this->start = 0;
144                        }
145
146                        if(!$global_cats)
147                        {
148                                $global_cats = False;
149                        }
150
151                        $cats = $this->bo->get_list($global_cats);
152
153//--------------------------------- nextmatch --------------------------------------------
154
155                        $left  = $this->nextmatchs->left('/index.php',$this->start,$this->bo->cats->total_records,$link_data);
156                        $right = $this->nextmatchs->right('/index.php',$this->start,$this->bo->cats->total_records,$link_data);
157                        $GLOBALS['phpgw']->template->set_var('left',$left);
158                        $GLOBALS['phpgw']->template->set_var('right',$right);
159
160                        $GLOBALS['phpgw']->template->set_var('lang_showing',$this->nextmatchs->show_hits($this->bo->cats->total_records,$this->start));
161
162// ------------------------------ end nextmatch ------------------------------------------
163
164//------------------- list header variable template-declarations -------------------------
165
166                        $GLOBALS['phpgw']->template->set_var('sort_name',$this->nextmatchs->show_sort_order($this->sort,'cat_name',$this->order,'/index.php',lang('Name'),$link_data));
167                        $GLOBALS['phpgw']->template->set_var('sort_description',$this->nextmatchs->show_sort_order($this->sort,'cat_description',$this->order,'/index.php',lang('Description'),$link_data));
168
169                        if (is_array($edata))
170                        {
171                                for($i=0;$i<count($edata);++$i)
172                                {
173                                        $GLOBALS['phpgw']->template->set_var('th_data','<td bgcolor="' . $GLOBALS['phpgw_info']['theme']['th_bg'] . '">' . lang($edata[$i]) . '</td>');
174                                        $GLOBALS['phpgw']->template->fp('column','data_column',True);
175                                }
176                        }
177                        else
178                        {
179                                $GLOBALS['phpgw']->template->set_var('th_data','');
180                        }
181
182// -------------------------- end header declaration --------------------------------------
183
184                        for ($i=0;$i<count($cats);++$i)
185                        {
186                                $this->nextmatchs->template_alternate_row_color($GLOBALS['phpgw']->template);
187
188                                if ($cats[$i]['app_name'] == 'phpgw')
189                                {
190                                        $appendix = '&lt;' . lang('Global') . '&gt;';
191                                }
192                                elseif ($cats[$i]['owner'] == '-1')
193                                {
194                                        $appendix = '&lt;' . lang('Global') . '&nbsp;' . $GLOBALS['phpgw_info']['apps'][$cats_app]['title'] . '&gt;';
195                                }
196                                else
197                                {
198                                        $appendix = '';
199                                }
200
201                                $level = $cats[$i]['level'];
202
203                                if ($level > 0)
204                                {
205                                        $space = '&nbsp;&nbsp;';
206                                        $spaceset = str_repeat($space,$level);
207                                        $name = $spaceset . $GLOBALS['phpgw']->strip_html($cats[$i]['name']) . $appendix;
208                                }
209
210                                $descr = $GLOBALS['phpgw']->strip_html($cats[$i]['description']);
211                                if (!$descr) { $descr = '&nbsp;'; }
212
213                                if (is_array($edata))
214                                {
215                                        $data = unserialize($cats[$i]['data']);
216                                        if (! is_array($data))
217                                        {
218                                                $holder = '<td>&nbsp;</td>' . "\n";
219                                                $placeholder = str_repeat($holder,count($edata));
220                                                $GLOBALS['phpgw']->template->set_var('td_data',$placeholder);
221                                        }
222                                        else
223                                        {
224                                                $GLOBALS['phpgw']->template->set_var('td_data',$this->cat_data($edata,$data));
225                                        }
226                                }
227
228                                if ($level == 0)
229                                {
230                                        $name = '<font color="FF0000"><b>' . $GLOBALS['phpgw']->strip_html($cats[$i]['name']) . '</b></font>' . $appendix;
231                                        $descr = '<font color="FF0000"><b>' . $descr . '</b></font>';
232                                }
233
234                                $GLOBALS['phpgw']->template->set_var(array(
235                                        'name'  => $name,
236                                        'descr' => $descr
237                                ));
238
239                                $GLOBALS['phpgw']->template->set_var('app_url',$GLOBALS['phpgw']->link('/' . $cats_app . '/index.php','cat_id=' . $cats[$i]['id']));
240
241                                if ($cats_level || ($level == 0))
242                                {
243                                        if ($cats[$i]['owner'] == $this->account || $cats[$i]['app_name'] == 'phpgw')
244                                        {
245                                                $link_data['menuaction'] = 'preferences.uicategories.add';
246                                                $link_data['cat_parent'] = $cats[$i]['id'];
247                                                $GLOBALS['phpgw']->template->set_var('add_sub',$GLOBALS['phpgw']->link('/index.php',$link_data));
248                                                $GLOBALS['phpgw']->template->set_var('lang_sub_entry',lang('Add sub'));
249                                        }
250                                }
251                                else
252                                {
253                                        $GLOBALS['phpgw']->template->set_var('add_sub','');
254                                        $GLOBALS['phpgw']->template->set_var('lang_sub_entry','&nbsp;');
255                                }
256
257                                $link_data['cat_id'] = $cats[$i]['id'];
258
259                                if ($cats[$i]['owner'] == $GLOBALS['phpgw']->accounts->id2name($this->account) && $cats[$i]['app_name'] != 'phpgw')
260                                {
261                                        $link_data['menuaction'] = 'preferences.uicategories.edit';
262                                        $GLOBALS['phpgw']->template->set_var('edit',$GLOBALS['phpgw']->link('/index.php',$link_data));
263                                        $GLOBALS['phpgw']->template->set_var('lang_edit_entry',lang('Edit'));
264
265                                        $link_data['menuaction'] = 'preferences.uicategories.delete';
266                                        $GLOBALS['phpgw']->template->set_var('delete',$GLOBALS['phpgw']->link('/index.php',$link_data));
267                                        $GLOBALS['phpgw']->template->set_var('lang_delete_entry',lang('Delete'));
268                                }
269                                else
270                                {
271                                        $GLOBALS['phpgw']->template->set_var('edit','');
272                                        $GLOBALS['phpgw']->template->set_var('lang_edit_entry','&nbsp;');
273
274                                        $GLOBALS['phpgw']->template->set_var('delete','');
275                                        $GLOBALS['phpgw']->template->set_var('lang_delete_entry','&nbsp;');
276                                }
277                                $GLOBALS['phpgw']->template->fp('list','cat_list',True);
278                        }
279                        $link_data['menuaction'] = 'preferences.uicategories.add';
280                        $GLOBALS['phpgw']->template->set_var('add_action',$GLOBALS['phpgw']->link('/index.php',$link_data));
281                        $this->save_sessiondata($cats_app);
282
283                        $GLOBALS['phpgw']->template->pfp('out','cat_list_t',True);
284                }
285
286                function add()
287                {
288                        $cats_app    = get_var('cats_app',array('GET','POST'));
289                        $extra       = get_var('extra',array('GET','POST'));
290                        $global_cats = get_var('global_cats',array('GET','POST'));
291                        $cats_level  = get_var('cats_level',array('GET','POST'));
292
293                        $link_data = array
294                        (
295                                'menuaction'  => 'preferences.uicategories.add',
296                                'cats_app'    => $cats_app,
297                                'extra'       => $extra,
298                                'global_cats' => $global_cats,
299                                'cats_level'  => $cats_level
300                        );
301
302                        $new_parent      = $_POST['new_parent'];
303                        $cat_parent      = get_var('cat_parent',array('POST','GET'));
304                        $cat_name        = $_POST['cat_name'];
305                        $cat_description = $_POST['cat_description'];
306                        $cat_data        = $_POST['cat_data'];
307                        $cat_access      = $_POST['cat_access'];
308
309                        $GLOBALS['phpgw']->template->set_file(array('form' => 'category_form.tpl'));
310                        $GLOBALS['phpgw']->template->set_block('form','data_row','row');
311                        $GLOBALS['phpgw']->template->set_block('form','add','addhandle');
312                        $GLOBALS['phpgw']->template->set_block('form','edit','edithandle');
313
314                        $this->set_langs();
315
316                        if ($new_parent)
317                        {
318                                $cat_parent = $new_parent;
319                        }
320
321                        if (!$global_cats)
322                        {
323                                $global_cats = False;
324                        }
325
326                        if ($_POST['save'])
327                        {
328                                $data = serialize($cat_data);
329
330                                $values = array
331                                (
332                                        'parent' => $cat_parent,
333                                        'descr'  => $cat_description,
334                                        'name'   => $cat_name,
335                                        'access' => $cat_access,
336                                        'data'   => $data
337                                );
338
339                                $error = $this->bo->check_values($values);
340                                if (is_array($error))
341                                {
342                                        $GLOBALS['phpgw']->template->set_var('message',$GLOBALS['phpgw']->common->error_list($error));
343                                }
344                                else
345                                {
346                                        $this->bo->save_cat($values);
347                                        return $this->index();
348                                        //$GLOBALS['phpgw']->template->set_var('message',lang('Category %1 has been added !', $cat_name));
349                                }
350                        }
351                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Add %1 category for',
352                                $GLOBALS['phpgw_info']['apps'][$cats_app]['title']).':&nbsp;'.$this->user;
353                        $GLOBALS['phpgw']->common->phpgw_header();
354                        echo parse_navbar();
355
356                        $GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
357
358                        if ($cats_level)
359                        {
360                                $type = 'all';
361                        }
362                        else
363                        {
364                                $type = 'mains';
365                        }
366
367                        $GLOBALS['phpgw']->template->set_var('category_list',$this->bo->cats->formated_list('select',$type,$cat_parent,$global_cats));
368                        $GLOBALS['phpgw']->template->set_var('cat_name',$cat_name);
369                        $GLOBALS['phpgw']->template->set_var('cat_description',$cat_description);
370
371                        $GLOBALS['phpgw']->template->set_var('access','<input type="checkbox" name="cat_access" value="True"'
372                                . ($cat_access == True ?' checked':'') . '>');
373
374                        if ($extra)
375                        {
376                                $edata = explode(',',$extra);
377                                for($i=0;$i<count($edata);++$i)
378                                {
379                                        $GLOBALS['phpgw']->template->set_var('tr_color',$GLOBALS['phpgw']->nextmatchs->alternate_row_color());
380                                        $GLOBALS['phpgw']->template->set_var('td_data','<input name="cat_data[' . $edata[$i] . ']" size="50" value="' . $cat_data[$edata[$i]] . '">');
381                                        $GLOBALS['phpgw']->template->set_var('lang_data',lang($edata[$i]));
382                                        $GLOBALS['phpgw']->template->fp('row','data_row',True);
383                                }
384                        }
385
386                        $link_data['menuaction'] = 'preferences.uicategories.index';
387                        $GLOBALS['phpgw']->template->set_var('cancel_url',$GLOBALS['phpgw']->link('/index.php',$link_data));
388                        $GLOBALS['phpgw']->template->set_var('edithandle','');
389                        $GLOBALS['phpgw']->template->set_var('addhandle','');
390                        $GLOBALS['phpgw']->template->pfp('out','form');
391                        $GLOBALS['phpgw']->template->pfp('addhandle','add');
392                }
393
394                function edit()
395                {
396                        $cats_app    = get_var('cats_app',array('GET','POST'));
397                        $extra       = get_var('extra',array('GET','POST'));
398                        $global_cats = get_var('global_cats',array('GET','POST'));
399                        $cats_level  = get_var('cats_level',array('GET','POST'));
400                        $cat_id      = get_var('cat_id',array('GET','POST'));
401
402                        $link_data = array
403                        (
404                                'menuaction'    => 'preferences.uicategories.index',
405                                'cats_app'              => $cats_app,
406                                'extra'                 => $extra,
407                                'global_cats'   => $global_cats,
408                                'cats_level'    => $cats_level,
409                                'cat_id'                => $cat_id
410                        );
411
412                        if (!$cat_id)
413                        {
414                                $GLOBALS['phpgw']->link_redirect('/index.php',$link_data);
415                        }
416
417                        $new_parent                     = $_POST['new_parent'];
418                        $cat_parent                     = $_POST['cat_parent'];
419                        $cat_name                       = $_POST['cat_name'];
420                        $cat_description        = $_POST['cat_description'];
421                        $cat_data                       = $_POST['cat_data'];
422                        $cat_access                     = $_POST['cat_access'];
423                        $old_parent                     = $_POST['old_parent'];
424
425                        $GLOBALS['phpgw']->template->set_file(array('form' => 'category_form.tpl'));
426                        $GLOBALS['phpgw']->template->set_block('form','data_row','row');
427                        $GLOBALS['phpgw']->template->set_block('form','add','addhandle');
428                        $GLOBALS['phpgw']->template->set_block('form','edit','edithandle');
429
430                        $this->set_langs();
431                        $GLOBALS['phpgw']->template->set_var('cancel_url',$GLOBALS['phpgw']->link('/index.php',$link_data));
432
433                        if ($new_parent)
434                        {
435                                $cat_parent = $new_parent;
436                        }
437
438                        if (!$global_cats)
439                        {
440                                $global_cats = False;
441                        }
442
443                        if ($_POST['save'])
444                        {
445                                $data = serialize($cat_data);
446
447                                $values = array
448                                (
449                                        'id'                    => $cat_id,
450                                        'parent'                => $cat_parent,
451                                        'descr'                 => $cat_description,
452                                        'name'                  => $cat_name,
453                                        'access'                => $cat_access,
454                                        'data'                  => $data,
455                                        'old_parent'    => $old_parent
456                                );
457
458                                $error = $this->bo->check_values($values);
459                                if (is_array($error))
460                                {
461                                        $GLOBALS['phpgw']->template->set_var('message',$GLOBALS['phpgw']->common->error_list($error));
462                                }
463                                else
464                                {
465                                        $cat_id = $this->bo->save_cat($values);
466                                        return $this->index();
467                                        //$GLOBALS['phpgw']->template->set_var('message',lang('Category %1 has been updated !',$cat_name));
468                                }
469                        }
470
471                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Edit %1 category for',
472                                $GLOBALS['phpgw_info']['apps'][$cats_app]['title']).':&nbsp;'.$this->user;
473                        $GLOBALS['phpgw']->common->phpgw_header();
474                        echo parse_navbar();
475
476                        $cats = $this->bo->cats->return_single($cat_id);
477
478                        $link_data['menuaction'] = 'preferences.uicategories.edit';
479                        $GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
480
481                        $GLOBALS['phpgw']->template->set_var('cat_name',$GLOBALS['phpgw']->strip_html($cats[0]['name']));
482                        $GLOBALS['phpgw']->template->set_var('cat_description',$GLOBALS['phpgw']->strip_html($cats[0]['description']));
483
484                        $GLOBALS['phpgw']->template->set_var('hidden_vars','<input type="hidden" name="old_parent" value="' . $cats[0]['parent'] . '">');
485
486                        if ($cats_level)
487                        {
488                                $type = 'all';
489                        }
490                        else
491                        {
492                                $type = 'mains';
493                        }
494
495                        $GLOBALS['phpgw']->template->set_var('category_list',$this->bo->cats->formated_list(array(
496                                'type' => $type,'selected' => $cats[0]['parent'],
497                                'globals' => $global_cats, 'self' => $cat_id
498                        )));
499
500                        $GLOBALS['phpgw']->template->set_var('access','<input type="checkbox" name="cat_access" value="True"'
501                                . ($cats[0]['access'] == 'private' ? ' checked' : '') . '>');
502
503                        if ($extra)
504                        {
505                                $edata = explode(',',$extra);
506
507                                $data = unserialize($cats[0]['data']);
508                                for($i=0;$i<count($edata);++$i)
509                                {
510                                        $GLOBALS['phpgw']->template->set_var('td_data','<input name="cat_data[' . $edata[$i] . ']" size="50" value="' . $data[$edata[$i]] . '">');
511                                        $GLOBALS['phpgw']->template->set_var('lang_data',lang($edata[$i]));
512                                        $GLOBALS['phpgw']->template->fp('row','data_row',True);
513                                }
514                        }
515
516                        if ($cats[0]['owner'] == $this->account)
517                        {
518                                $link_data['menuaction'] = 'preferences.uicategories.delete';
519                                $GLOBALS['phpgw']->template->set_var('delete','<form method="POST" action="' . $GLOBALS['phpgw']->link('/index.php',$link_data)
520                                        . '"><input type="submit" value="' . lang('Delete') .'"></form>');
521                        }
522                        else
523                        {
524                                $GLOBALS['phpgw']->template->set_var('delete','&nbsp;');
525                        }
526
527                        $GLOBALS['phpgw']->template->set_var('edithandle','');
528                        $GLOBALS['phpgw']->template->set_var('addhandle','');
529                        $GLOBALS['phpgw']->template->pfp('out','form');
530                        $GLOBALS['phpgw']->template->pfp('edithandle','edit');
531                }
532
533                function delete()
534                {
535                        $cats_app    = get_var('cats_app',array('GET','POST'));
536                        $extra       = get_var('extra',array('GET','POST'));
537                        $global_cats = get_var('global_cats',array('GET','POST'));
538                        $cats_level  = get_var('cats_level',array('GET','POST'));
539                        $cat_id      = get_var('cat_id',array('GET','POST'));
540
541                        $link_data = array
542                        (
543                                'menuaction'  => 'preferences.uicategories.index',
544                                'cats_app'    => $cats_app,
545                                'extra'       => $extra,
546                                'global_cats' => $global_cats,
547                                'cats_level'  => $cats_level,
548                                'cat_id'      => $cat_id
549                        );
550
551                        if (!$cat_id || $_POST['cancel'])
552                        {
553                                $GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
554                        }
555
556                        if ($_POST['confirm'])
557                        {
558                                if ($_POST['subs'])
559                                {
560                                        $this->bo->delete($cat_id,True);
561                                }
562                                else
563                                {
564                                        $this->bo->delete($cat_id,False);
565                                }
566                                $GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
567                        }
568                        else
569                        {
570                                $GLOBALS['phpgw']->template->set_file(array('category_delete' => 'delete.tpl'));
571
572                                $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Delete Categories');
573                                $GLOBALS['phpgw']->common->phpgw_header();
574                                echo parse_navbar();
575
576                                $GLOBALS['phpgw']->template->set_var('deleteheader',lang('Are you sure you want to delete this category ?'));
577
578                                $exists = $this->bo->exists(array
579                                (
580                                        'type'     => 'subs',
581                                        'cat_name' => '',
582                                        'cat_id'   => $cat_id
583                                ));
584
585                                if ($exists)
586                                {
587                                        $GLOBALS['phpgw']->template->set_var('lang_subs',lang('Do you also want to delete all subcategories ?'));
588                                        $GLOBALS['phpgw']->template->set_var('subs','<input type="checkbox" name="subs" value="True">');
589                                }
590                                else
591                                {
592                                        $GLOBALS['phpgw']->template->set_var('lang_subs','');
593                                        $GLOBALS['phpgw']->template->set_var('subs', '');
594                                }
595
596                                $GLOBALS['phpgw']->template->set_var('lang_no',lang('No'));
597                                $link_data['menuaction'] = 'preferences.uicategories.delete';
598                                $GLOBALS['phpgw']->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php',$link_data));
599                                $GLOBALS['phpgw']->template->set_var('lang_yes',lang('Yes'));
600                                $GLOBALS['phpgw']->template->pfp('out','category_delete');
601                        }
602                }
603        }
604?>
Note: See TracBrowser for help on using the repository browser.