diff --git a/admin/inc/class.bocategories.inc.php b/admin/inc/class.bocategories.inc.php index 8917367fbc..1f452ac645 100644 --- a/admin/inc/class.bocategories.inc.php +++ b/admin/inc/class.bocategories.inc.php @@ -124,7 +124,7 @@ function formatted_list($data) { - return $this->cats->formated_list($data['select'],$data['all'],$data['cat_parent']); + return $this->cats->formated_list($data['select'],$data['all'],$data['cat_parent'],True); } function delete($cat_id,$subs=False) diff --git a/admin/inc/class.uicategories.inc.php b/admin/inc/class.uicategories.inc.php index 56d2a37e4a..af9a1b3a31 100644 --- a/admin/inc/class.uicategories.inc.php +++ b/admin/inc/class.uicategories.inc.php @@ -59,7 +59,6 @@ _debug_array($data); } - /* Called only by index() */ function save_sessiondata() { $data = array @@ -166,7 +165,7 @@ $descr = '' . $descr . ''; } - if ($categories[$i]['app_name'] == 'phpgw') + if ($GLOBALS['appname'] && $categories[$i]['app_name'] == 'phpgw') { $appendix = '<' . lang('Global') . '>'; } @@ -182,8 +181,6 @@ )); $link_data['menuaction'] = 'admin.uicategories.add'; - $this->template->set_var('add_action',$GLOBALS['phpgw']->link('/index.php',$link_data)); - $link_data['cat_parent'] = $id; $this->template->set_var('add_sub',$GLOBALS['phpgw']->link('/index.php',$link_data)); $this->template->set_var('lang_sub_entry',lang('Add sub')); @@ -200,35 +197,45 @@ $this->template->fp('list','cat_list',True); } + $link_data['menuaction'] = 'admin.uicategories.add'; + $link_data['cat_parent'] = ''; + $this->template->set_var('add_action',$GLOBALS['phpgw']->link('/index.php',$link_data)); + $this->save_sessiondata(); $this->template->pfp('out','cat_list_t',True); } function add() { + $link_data = array + ( + 'menuaction' => 'admin.uicategories.index', + 'appname' => $GLOBALS['appname'] + )); + $GLOBALS['phpgw']->common->phpgw_header(); echo parse_navbar(); $this->set_langs(); - $new_parent = $GLOBALS['HTTP_POST_VARS']['new_parent']; - $submit = $GLOBALS['HTTP_POST_VARS']['submit']; - $cat_parent = $GLOBALS['HTTP_POST_VARS']['cat_parent'] ? $GLOBALS['HTTP_POST_VARS']['cat_parent'] : $GLOBALS['HTTP_GET_VARS']['cat_parent']; - $cat_name = $GLOBALS['HTTP_POST_VARS']['cat_name']; - $cat_description = $GLOBALS['HTTP_POST_VARS']['cat_description']; + $new_parent = $GLOBALS['HTTP_POST_VARS']['new_parent']; + $submit = $GLOBALS['HTTP_POST_VARS']['submit']; + $cat_parent = $GLOBALS['HTTP_POST_VARS']['cat_parent'] ? $GLOBALS['HTTP_POST_VARS']['cat_parent'] : $GLOBALS['HTTP_GET_VARS']['cat_parent']; + $cat_name = $GLOBALS['HTTP_POST_VARS']['cat_name']; + $cat_description = $GLOBALS['HTTP_POST_VARS']['cat_description']; $this->template->set_file(array('form' => 'category_form.tpl')); $this->template->set_block('form','add','addhandle'); $this->template->set_block('form','edit','edithandle'); + $this->template->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php',$link_data)); + if ($GLOBALS['appname']) { - $this->bo->cats->app_name = $GLOBALS['appname']; $this->template->set_var('title_categories',lang('Add global category for %1',$GLOBALS['phpgw_info']['apps'][$GLOBALS['appname']]['title'])); } else { - $this->bo->cats->app_name = 'phpgw'; $this->template->set_var('title_categories',lang('Add global category')); } @@ -259,9 +266,9 @@ } } - $this->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.add' . '&appname=' . $GLOBALS['appname'])); - $this->template->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.index' . '&appname=' . $GLOBALS['appname'])); - $this->template->set_var('hidden_vars',''); + $link_data['menuaction'] = 'admin.uicategories.add'; + $this->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data)); + $this->template->set_var('category_list',$this->bo->formatted_list(array('select' => 'select','all' => 'all','cat_parent' => $cat_parent))); $this->template->set_var('cat_name',$cat_name); $this->template->set_var('cat_description',$cat_description); @@ -274,9 +281,15 @@ function edit() { + $link_data = array + ( + 'menuaction' => 'admin.uicategories.index', + 'appname' => $GLOBALS['appname'] + )); + if (!$this->cat_id) { - Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.index')); + Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data)); } $GLOBALS['phpgw']->common->phpgw_header(); @@ -284,19 +297,19 @@ $this->set_langs(); - $new_parent = $GLOBALS['HTTP_POST_VARS']['new_parent']; - $submit = $GLOBALS['HTTP_POST_VARS']['submit']; - $cat_parent = $GLOBALS['HTTP_POST_VARS']['cat_parent']; - $cat_name = $GLOBALS['HTTP_POST_VARS']['cat_name']; - $cat_description = $GLOBALS['HTTP_POST_VARS']['cat_description']; + $new_parent = $GLOBALS['HTTP_POST_VARS']['new_parent']; + $submit = $GLOBALS['HTTP_POST_VARS']['submit']; + $cat_parent = $GLOBALS['HTTP_POST_VARS']['cat_parent']; + $cat_name = $GLOBALS['HTTP_POST_VARS']['cat_name']; + $cat_description = $GLOBALS['HTTP_POST_VARS']['cat_description']; $this->template->set_file(array('form' => 'category_form.tpl')); $this->template->set_block('form','add','addhandle'); $this->template->set_block('form','edit','edithandle'); - $this->bo->cats->app_name = 'phpgw'; - $hidden_vars = '' . "\n"; + $this->template->set_var('hidden_vars',$hidden_vars); + $this->template->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php',$link_data)); if ($new_parent) { @@ -337,10 +350,11 @@ $this->template->set_var('title_categories',lang('Edit global category')); } - $this->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.edit&appname=' . $GLOBALS['appname'])); - $this->template->set_var('deleteurl',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.delete&cat_id=' . $this->cat_id . '&appname=' . $GLOBALS['appname'])); - $this->template->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.index&appname=' . $GLOBALS['appname'])); - $this->template->set_var('hidden_vars',$hidden_vars); + $link_data['menuaction'] = 'admin.uicategories.edit'; + $link_data['cat_id'] = $this->cat_id; + $this->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data)); + $link_data['menuaction'] = 'admin.uicategories.delete'; + $this->template->set_var('deleteurl',$GLOBALS['phpgw']->link('/index.php',$link_data)); $this->template->set_var('cat_name',$GLOBALS['phpgw']->strip_html($cats[0]['name'])); $this->template->set_var('cat_description',$GLOBALS['phpgw']->strip_html($cats[0]['description'])); @@ -365,8 +379,6 @@ Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data)); } - $this->bo->cats->app_name = 'phpgw'; - if ($GLOBALS['HTTP_POST_VARS']['confirm']) { if ($GLOBALS['HTTP_POST_VARS']['subs']) @@ -381,8 +393,6 @@ } else { - $hidden_vars = '' . "\n"; - $this->template->set_file(array('category_delete' => 'delete_cat.tpl')); $this->template->set_block('category_delete','delete','deletehandle'); $this->template->set_block('category_delete','done','donehandle'); @@ -399,11 +409,14 @@ $GLOBALS['phpgw']->common->phpgw_header(); echo parse_navbar(); + $hidden_vars = '' . "\n"; + $this->template->set_var('hidden_vars',$hidden_vars); + if ($apps_cats) { $this->template->set_var('messages',lang('This category is currently being used by applications as a parent category') . '
' . lang('You will need to remove the subcategories before you can delete this category')); - $this->template->set_var('hidden_vars',$hidden_vars); + $this->template->set_var('lang_subs',''); $this->template->set_var('subs',''); $this->template->set_var('nolink',$nolink); @@ -415,13 +428,14 @@ else { $this->template->set_var('messages',lang('Are you sure you want to delete this category ?')); - $this->template->set_var('hidden_vars',$hidden_vars); - $exists = $this->bo->exists(array( + $exists = $this->bo->exists(array + ( 'type' => 'subs', 'cat_name' => '', 'cat_id' => $this->cat_id )); + if ($exists) { $this->template->set_var('lang_subs',lang('Do you also want to delete all global subcategories ?')); diff --git a/admin/templates/default/category_form.tpl b/admin/templates/default/category_form.tpl index 4b41dccc80..0d9b078f62 100644 --- a/admin/templates/default/category_form.tpl +++ b/admin/templates/default/category_form.tpl @@ -30,13 +30,11 @@
- {hidden_vars}
- {hidden_vars}
@@ -56,7 +54,6 @@
- {hidden_vars}
diff --git a/phpgwapi/inc/class.categories.inc.php b/phpgwapi/inc/class.categories.inc.php index 394b7d05c4..e88c70ae76 100644 --- a/phpgwapi/inc/class.categories.inc.php +++ b/phpgwapi/inc/class.categories.inc.php @@ -137,19 +137,26 @@ $ordermethod = ' ORDER BY cat_main, cat_level, cat_name ASC'; } - if (is_array($this->grants)) + if ($this->account_id == '-1') { - $grants = $this->grants; - while(list($user) = each($grants)) - { - $public_user_list[] = $user; - } - reset($public_user_list); - $grant_cats = " (cat_owner='" . $this->account_id . "' OR cat_owner='-1' OR cat_access='public' AND cat_owner in(" . implode(',',$public_user_list) . ")) "; + $grant_cats = " cat_owner='-1' "; } else { - $grant_cats = " cat_owner='" . $this->account_id . "' or cat_owner='-1' "; + if (is_array($this->grants)) + { + $grants = $this->grants; + while(list($user) = each($grants)) + { + $public_user_list[] = $user; + } + reset($public_user_list); + $grant_cats = " (cat_owner='" . $this->account_id . "' OR cat_owner='-1' OR cat_access='public' AND cat_owner in(" . implode(',',$public_user_list) . ")) "; + } + else + { + $grant_cats = " cat_owner='" . $this->account_id . "' OR cat_owner='-1' "; + } } if ($parent_id) @@ -216,19 +223,26 @@ $ordermethod = ' ORDER BY cat_name ASC'; } - if (is_array($this->grants)) + if ($this->account_id == '-1') { - $grants = $this->grants; - while(list($user) = each($grants)) - { - $public_user_list[] = $user; - } - reset($public_user_list); - $grant_cats = " (cat_owner='" . $this->account_id . "' OR cat_owner='-1' OR cat_access='public' AND cat_owner in(" . implode(',',$public_user_list) . ")) "; + $grant_cats = " cat_owner='-1' "; } else { - $grant_cats = " cat_owner='" . $this->account_id . "' or cat_owner='-1' "; + if (is_array($this->grants)) + { + $grants = $this->grants; + while(list($user) = each($grants)) + { + $public_user_list[] = $user; + } + reset($public_user_list); + $grant_cats = " (cat_owner='" . $this->account_id . "' OR cat_owner='-1' OR cat_access='public' AND cat_owner in(" . implode(',',$public_user_list) . ")) "; + } + else + { + $grant_cats = " cat_owner='" . $this->account_id . "' or cat_owner='-1' "; + } } if ($query) diff --git a/preferences/inc/class.uicategories.inc.php b/preferences/inc/class.uicategories.inc.php index 9bd920728c..c65b895459 100644 --- a/preferences/inc/class.uicategories.inc.php +++ b/preferences/inc/class.uicategories.inc.php @@ -173,6 +173,10 @@ { $appendix = '<' . lang('Global') . ' ' . $GLOBALS['phpgw_info']['apps'][$cats_app]['title'] . '>'; } + else + { + $appendix = ''; + } $level = $cats[$i]['level'];