diff --git a/admin/addcategory.php b/admin/addcategory.php index 8665cbf2b2..6fcbb92d9f 100644 --- a/admin/addcategory.php +++ b/admin/addcategory.php @@ -14,7 +14,7 @@ $phpgw_info['flags']['currentapp'] = 'admin'; include('../header.inc.php'); - $t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin')); + $t = new Template(PHPGW_APP_TPL); $t->set_file(array('form' => 'category_form.tpl')); $t->set_block('form','add','addhandle'); $t->set_block('form','edit','edithandle'); diff --git a/admin/deletecategory.php b/admin/deletecategory.php index bee1f224de..0ada25da31 100644 --- a/admin/deletecategory.php +++ b/admin/deletecategory.php @@ -11,66 +11,95 @@ \**************************************************************************/ /* $Id$ */ - if ($confirm) + if ($confirm) + { + $phpgw_info['flags'] = array('noheader' => True, + 'nonavbar' => True); + } + + $phpgw_info['flags']['currentapp'] = 'admin'; + include('../header.inc.php'); + + $c = CreateObject('phpgwapi.categories'); + $c->categories($phpgw_info['user']['account_id'],'phpgw'); + + if (! $cat_id) + { + Header('Location: ' . $phpgw->link('/admin/categories.php')); + } + + if ($confirm) + { + if ($subs) { - $phpgw_info['flags'] = array( - 'noheader' => True, - 'nonavbar' => True - ); - } - - $phpgw_info['flags']['currentapp'] = 'admin'; - include('../header.inc.php'); - - $c = CreateObject('phpgwapi.categories'); - $c->categories($phpgw_info['user']['account_id'],'phpgw'); - - if (! $cat_id) - { - Header('Location: ' . $phpgw->link('/admin/categories.php')); - } - - if ($confirm) - { - if ($subs) { $c->delete($cat_id,'True'); } - else { $c->delete($cat_id); } - Header('Location: ' . $phpgw->link('/admin/categories.php',"start=$start&query=$query&sort=$sort&order=$order&filter=$filter")); + $c->delete($cat_id,'True'); } else { - $hidden_vars = "\n" + $c->delete($cat_id); + } + Header('Location: ' . $phpgw->link('/admin/categories.php',"start=$start&query=$query&sort=$sort&order=$order&filter=$filter")); + } + else + { + $hidden_vars = "\n" . "\n" . "\n" . "\n" . "\n" . "\n"; - $t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin')); - $t->set_file(array('category_delete' => 'delete_cat.tpl')); - $t->set_var('messages',lang('Are you sure you want to delete this category ?')); - $t->set_var('hidden_vars',$hidden_vars); + $t = new Template(PHPGW_APP_TPL); + $t->set_file(array('category_delete' => 'delete_cat.tpl')); + $t->set_block('category_delete','delete','deletehandle'); + $t->set_block('category_delete','done','donehandle'); - $exists = $c->exists('subs',$cat_name='',$cat_id); + $nolink = $phpgw->link('/admin/categories.php',"cat_id=$cat_id&start=$start&query=$query&sort=$sort&order=$order&filter=$filter"); - if ($exists==True) - { - $t->set_var('lang_subs',lang('Do you also want to delete all subcategories ?')); - $t->set_var('subs',''); - } - else - { - $t->set_var('lang_subs',''); - $t->set_var('subs', ''); - } + $apps_cats = $c->exists('subs',$cat_name='',$cat_id); - $t->set_var('nolink',$phpgw->link('/admin/categories.php',"cat_id=$cat_id&start=$start&query=$query&sort=$sort&order=$order&filter=$filter")); - $t->set_var('lang_no',lang('No')); - - $t->set_var('action_url',$phpgw->link('/admin/deletecategory.php',"cat_id=$cat_id")); - $t->set_var('lang_yes',lang('Yes')); - - $t->pparse('out','category_delete'); + if ($apps_cats==True) + { + $t->set_var('messages',lang('This category is used from applications as parent category !')); + $t->set_var('hidden_vars',$hidden_vars); + $t->set_var('lang_subs',''); + $t->set_var('subs',''); + $t->set_var('nolink',$nolink); + $t->set_var('lang_done',lang('Done')); + $t->set_var('deletehandle',''); + $t->set_var('donehandle',''); + $t->pparse('out','category_delete'); + $t->pparse('donehandle','done'); + $phpgw->common->phpgw_footer(); } + else + { + $t->set_var('messages',lang('Are you sure you want to delete this category ?')); + $t->set_var('hidden_vars',$hidden_vars); -$phpgw->common->phpgw_footer(); + $exists = $c->exists('subs',$cat_name='',$cat_id); + + if ($exists==True) + { + $t->set_var('lang_subs',lang('Do you also want to delete all global subcategories ?')); + $t->set_var('subs',''); + } + else + { + $t->set_var('lang_subs',''); + $t->set_var('subs', ''); + } + + $t->set_var('nolink',$nolink); + $t->set_var('lang_no',lang('No')); + + $t->set_var('action_url',$phpgw->link('/admin/deletecategory.php',"cat_id=$cat_id")); + $t->set_var('lang_yes',lang('Yes')); + $t->set_var('deletehandle',''); + $t->set_var('donehandle',''); + $t->pparse('out','category_delete'); + $t->pparse('deletehandle','delete'); + $phpgw->common->phpgw_footer(); + } + } ?> diff --git a/admin/templates/default/delete_cat.tpl b/admin/templates/default/delete_cat.tpl index 568d9334a5..babcbc9eb7 100644 --- a/admin/templates/default/delete_cat.tpl +++ b/admin/templates/default/delete_cat.tpl @@ -9,6 +9,9 @@ {lang_subs} {subs} + + + {hidden_vars} @@ -18,4 +21,20 @@ - \ No newline at end of file + + + + + + + + + {hidden_vars} + {lang_done} + + + + + + + diff --git a/preferences/addcategory.php b/preferences/addcategory.php index fb001b2f80..325b40a6af 100644 --- a/preferences/addcategory.php +++ b/preferences/addcategory.php @@ -24,6 +24,7 @@ . "\n" . "\n" . "\n" + . "\n" . "\n" . "\n"; @@ -79,32 +80,59 @@ $t->set_var('lang_main',lang('Main category')); $t->set_var('lang_new_main',lang('New main category')); - $t->set_var('main_category_list',$c->formated_list('select','mains',$cat_main)); - if ($cats_level) { - $category_list = $c->formated_list('select','all',$cat_parent); + if ($global_cats) + { + $t->set_var('main_category_list',$c->formated_list('select','mains',$cat_main,True)); + } + else + { + $t->set_var('main_category_list',$c->formated_list('select','mains',$cat_main)); + } + + if ($cats_level) + { + if ($global_cats) + { + $category_list = $c->formated_list('select','all',$cat_parent,True); + } + else + { + $category_list = $c->formated_list('select','all',$cat_parent); + } + $t->set_var('category_select',''); $t->set_var('lang_parent',lang('Parent category')); } - else { + else + { $t->set_var('lang_parent',''); $t->set_var('category_select',''); } $t->set_var('lang_access',lang('Private')); - if ($access) { $t->set_var('access', ''); } - else { $t->set_var('access', ''); } + + if ($access) + { + $t->set_var('access', ''); + } + else + { + $t->set_var('access', ''); + } $t->set_var('lang_name',lang('Name')); $t->set_var('lang_descr',lang('Description')); $t->set_var('cat_name',$cat_name); $t->set_var('cat_description',$cat_description); - if ($extra) { + if ($extra) + { $t->set_var('td_data',''); $t->set_var('lang_data',lang($extra)); } - else { + else + { $t->set_var('td_data',''); $t->set_var('lang_data',''); } @@ -118,4 +146,4 @@ $t->pparse('addhandle','add'); $phpgw->common->phpgw_footer(); -?> \ No newline at end of file +?> diff --git a/preferences/categories.php b/preferences/categories.php index 7e7ea9f96f..eb94ec0e8c 100644 --- a/preferences/categories.php +++ b/preferences/categories.php @@ -30,6 +30,7 @@ . "\n" . "\n" . "\n" + . "\n" . "\n" . "\n"; @@ -37,48 +38,68 @@ $t->set_var('user_name',$phpgw_info['user']['fullname']); $t->set_var('title_categories',lang('categories for')); $t->set_var('lang_action',lang('Category list')); - $t->set_var('add_action',$phpgw->link('/preferences/addcategory.php',"cats_app=$cats_app&extra=$extra&cats_level=$cats_level")); + $t->set_var('add_action',$phpgw->link('/preferences/addcategory.php',"cats_app=$cats_app&extra=$extra&cats_level=$cats_level&global_cats=$global_cats")); $t->set_var('lang_add',lang('Add')); $t->set_var('lang_search',lang('Search')); - $t->set_var('actionurl',$phpgw->link('/preferences/categories.php',"cats_app=$cats_app&extra=$extra&cats_level=$cats_level")); + $t->set_var('actionurl',$phpgw->link('/preferences/categories.php',"cats_app=$cats_app&extra=$extra&cats_level=$cats_level&global_cats=$global_cats")); $t->set_var('lang_done',lang('Done')); $t->set_var('doneurl',$phpgw->link('/preferences/')); if (! $start) { $start = 0; } - if($phpgw_info['user']['preferences']['common']['maxmatchs'] && $phpgw_info['user']['preferences']['common']['maxmatchs'] > 0) { + if($phpgw_info['user']['preferences']['common']['maxmatchs'] && $phpgw_info['user']['preferences']['common']['maxmatchs'] > 0) + { $limit = $phpgw_info['user']['preferences']['common']['maxmatchs']; } - else { $limit = 15; } + else + { + $limit = 15; + } $c = CreateObject('phpgwapi.categories'); $c->app_name = $cats_app; - $categories = $c->return_array('all',$start,$limit,$query,$sort,$order); + + if ($global_cats) + { + $categories = $c->return_array('all',$start,$limit,$query,$sort,$order,True); + } + else + { + $categories = $c->return_array('all',$start,$limit,$query,$sort,$order); + } //--------------------------------- nextmatch -------------------------------------------- - $left = $phpgw->nextmatchs->left('/preferences/categories.php',$start,$c->total_records,"&cats_app=$cats_app&extra=$extra&cats_level=$cats_level"); - $right = $phpgw->nextmatchs->right('/preferences/categories.php',$start,$c->total_records,"&cats_app=$cats_app&extra=$extra&cats_level=$cats_level"); + $left = $phpgw->nextmatchs->left('/preferences/categories.php',$start,$c->total_records,"&cats_app=$cats_app&extra=$extra&cats_level=$cats_level&global_cats=$global_cats"); + $right = $phpgw->nextmatchs->right('/preferences/categories.php',$start,$c->total_records,"&cats_app=$cats_app&extra=$extra&cats_level=$cats_level&global_cats=$global_cats"); $t->set_var('left',$left); $t->set_var('right',$right); - if ($c->total_records > $limit) { + if ($c->total_records > $limit) + { $t->set_var('lang_showing',lang('showing x - x of x',($start + 1),($start + $limit),$c->total_records)); } - else { $t->set_var('lang_showing',lang('showing x',$c->total_records)); } + else + { + $t->set_var('lang_showing',lang('showing x',$c->total_records)); + } // ------------------------------ end nextmatch ------------------------------------------ //------------------- list header variable template-declarations ------------------------- $t->set_var('th_bg',$phpgw_info['theme']['th_bg']); - $t->set_var('sort_name',$phpgw->nextmatchs->show_sort_order($sort,'cat_name',$order,'/preferences/categories.php',lang('Name'),"&cats_app=$cats_app&extra=$extra&cats_level=$cats_level")); - $t->set_var('sort_description',$phpgw->nextmatchs->show_sort_order($sort,'cat_description',$order,'/preferences/categories.php',lang('Description'),"&cats_app=$cats_app&extra=$extra&cats_level=$cats_level")); - if ($extra) { + $t->set_var('sort_name',$phpgw->nextmatchs->show_sort_order($sort,'cat_name',$order,'/preferences/categories.php',lang('Name'),"&cats_app=$cats_app&extra=$extra&cats_level=$cats_level&global_cats=$global_cats")); + $t->set_var('sort_description',$phpgw->nextmatchs->show_sort_order($sort,'cat_description',$order,'/preferences/categories.php',lang('Description'),"&cats_app=$cats_app&extra=$extra&cats_level=$cats_level&global_cats=$global_cats")); + if ($extra) + { $t->set_var('sort_data','' - . $phpgw->nextmatchs->show_sort_order($sort,'cat_data',$order,'/preferences/categories.php',lang($extra),"&cats_app=$cats_app&extra=$extra&cats_level=$cats_level") . ''); + . $phpgw->nextmatchs->show_sort_order($sort,'cat_data',$order,'/preferences/categories.php',lang($extra),"&cats_app=$cats_app&extra=$extra&cats_level=$cats_level&global_cats=$global_cats") . ''); + } + else + { + $t->set_var('sort_data',''); } - else { $t->set_var('sort_data',''); } $t->set_var('lang_app',lang($cats_app)); $t->set_var('lang_edit',lang('Edit')); @@ -86,62 +107,81 @@ // -------------------------- end header declaration -------------------------------------- - for ($i=0;$inextmatchs->alternate_row_color($tr_color); - $t->set_var('tr_color',$tr_color); + $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); + $t->set_var('tr_color',$tr_color); - $cat_id = $categories[$i]['id']; - $owner = $categories[$i]['owner']; - $level = $categories[$i]['level']; - $space = '  '; + $cat_id = $categories[$i]['id']; + $owner = $categories[$i]['owner']; + $level = $categories[$i]['level']; + $space = '  '; - if ($level > 0) { - $spaceset = str_repeat($space,$level); - $name = $spaceset .$phpgw->strip_html($categories[$i]['name']); - } + if ($categories[$i]['app_name'] == 'phpgw') + { + $appendix = '<' . lang('Global') . '>'; + } + else + { + $appendix = ''; + } - $descr = $phpgw->strip_html($categories[$i]['description']); - if (! $descr) { $descr = ' '; } + if ($level > 0) + { + $spaceset = str_repeat($space,$level); + $name = $spaceset .$phpgw->strip_html($categories[$i]['name']) . $appendix; + } - if ($extra) { - $data = $categories[$i]['data']; - if (! $data) { $data = ' '; } - $t->set_var('td_data','' . $data . ''); - } - else { $t->set_var('td_data',''); } + $descr = $phpgw->strip_html($categories[$i]['description']); + if (! $descr) { $descr = ' '; } - if ($level == 0) { - $name = '' . $phpgw->strip_html($categories[$i]['name']) . ''; - $descr = '' . $descr . ''; - $data = '' . $data . ''; - } + if ($extra) + { + $data = $categories[$i]['data']; + if (! $data) { $data = ' '; } + $t->set_var('td_data','' . $data . ''); + } + else + { + $t->set_var('td_data',''); + } + + if ($level == 0) + { + $name = '' . $phpgw->strip_html($categories[$i]['name']) . '' . $appendix; + $descr = '' . $descr . ''; + $data = '' . $data . ''; + } //-------------------------- template declaration for list records --------------------------- - $t->set_var(array('name' => $name, + $t->set_var(array('name' => $name, 'descr' => $descr)); + $t->set_var('app_url',$phpgw->link('/' . $phpgw_info['flags']['currentapp'] . '/index.php',"cat_id=$cat_id")); - $t->set_var('app_url',$phpgw->link('/' . $phpgw_info['flags']['currentapp'] . '/index.php',"cat_id=$cat_id")); - - if ($categories[$i]['owner'] == $phpgw_info['user']['account_id']) { - $t->set_var('edit',$phpgw->link('/preferences/editcategory.php',"cat_id=$cat_id&cats_app=$cats_app&extra=$extra&cats_level=$cats_level")); - $t->set_var('lang_edit_entry',lang('Edit')); - } - else { - $t->set_var('edit',''); - $t->set_var('lang_edit_entry',' '); - } - if ($categories[$i]['owner'] == $phpgw_info['user']['account_id']) { - $t->set_var('delete',$phpgw->link('/preferences/deletecategory.php',"cat_id=$cat_id&cats_app=$cats_app&extra=$extra&cats_level=$cats_level")); - $t->set_var('lang_delete_entry',lang('Delete')); - } - else { - $t->set_var('delete',''); - $t->set_var('lang_delete_entry',' '); - } - $t->parse('list','cat_list',True); + if ($categories[$i]['owner'] == $phpgw_info['user']['account_id'] && $categories[$i]['app_name'] != 'phpgw') + { + $t->set_var('edit',$phpgw->link('/preferences/editcategory.php',"cat_id=$cat_id&cats_app=$cats_app&extra=$extra&cats_level=$cats_level&global_cats=$global_cats")); + $t->set_var('lang_edit_entry',lang('Edit')); + } + else + { + $t->set_var('edit',''); + $t->set_var('lang_edit_entry',' '); + } + if ($categories[$i]['owner'] == $phpgw_info['user']['account_id'] && $categories[$i]['app_name'] != 'phpgw') + { + $t->set_var('delete',$phpgw->link('/preferences/deletecategory.php',"cat_id=$cat_id&cats_app=$cats_app&extra=$extra&cats_level=$cats_level&global_cats=$global_cats")); + $t->set_var('lang_delete_entry',lang('Delete')); + } + else + { + $t->set_var('delete',''); + $t->set_var('lang_delete_entry',' '); + } + $t->parse('list','cat_list',True); } // ---------------------------- end record declaration ----------------------------------------- @@ -149,4 +189,4 @@ $t->p('out'); $phpgw->common->phpgw_footer(); -?> \ No newline at end of file +?> diff --git a/preferences/editcategory.php b/preferences/editcategory.php index c282b9efbd..43f80b2f6e 100644 --- a/preferences/editcategory.php +++ b/preferences/editcategory.php @@ -24,12 +24,14 @@ . "\n" . "\n" . "\n" + . "\n" . "\n" . "\n"; - if (! $cat_id) { - Header('Location: ' . $phpgw->link('/preferences/categories.php',"sort=$sort&order=$order&query=$query&start=$start" - . "&filter=$filter&cats_app=$cats_app&extra=$extra&cats_level=$cats_level")); + if (! $cat_id) + { + Header('Location: ' . $phpgw->link('/preferences/categories.php',"sort=$sort&order=$order&query=$query&start=$start" + . "&filter=$filter&cats_app=$cats_app&extra=$extra&cats_level=$cats_level&global_cats=$global_cats")); } $t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('preferences')); @@ -40,12 +42,14 @@ $c = CreateObject('phpgwapi.categories'); $c->app_name = $cats_app; - if ($submit) { + if ($submit) + { $errorcount = 0; if (!$cat_name) { $error[$errorcount++] = lang('Please enter a name for that category !'); } - if (!$error) { + if (!$error) + { if (!$cat_parent) { $exists = $c->exists('mains',$cat_name,$cat_id); } else { $exists = $c->exists('subs',$cat_name,$cat_id); } if ($exists == True) { $error[$errorcount++] = lang('That category name has been used already !'); } @@ -73,15 +77,34 @@ $cat_main = $cats[0]['main']; $t->set_var('lang_main',lang('Main category')); $t->set_var('lang_new_main',lang('New main category')); - $t->set_var('main_category_list',$c->formated_list('select','mains',$cat_main)); - if ($cats_level) { + if ($global_cats) + { + $t->set_var('main_category_list',$c->formated_list('select','mains',$cat_main,True)); + } + else + { + $t->set_var('main_category_list',$c->formated_list('select','mains',$cat_main)); + } + + if ($cats_level) + { $cat_parent = $cats[0]['parent']; - $category_list = $c->formated_list('select','all',$cat_parent); + + if ($global_cats) + { + $category_list = $c->formated_list('select','all',$cat_parent,True); + } + else + { + $category_list = $c->formated_list('select','all',$cat_parent); + } + $t->set_var('category_select',''); $t->set_var('lang_parent',lang('Parent category')); } - else { + else + { $t->set_var('lang_parent',''); $t->set_var('category_select',''); } @@ -96,19 +119,28 @@ $t->set_var('lang_name',lang('Name')); $t->set_var('lang_descr',lang('Description')); $t->set_var('lang_access',lang('Private')); - if ($cats[0]['access']=='private') { $t->set_var('access', ''); } - else { $t->set_var('access', 'set_var('access', ''); + } + else + { + $t->set_var('access', 'set_var('cat_name',$phpgw->strip_html($cats[0]['name'])); $t->set_var('cat_description',$phpgw->strip_html($cats[0]['description'])); - if ($extra) { + if ($extra) + { $t->set_var('td_data',''); $t->set_var('lang_data',lang($extra)); } - else { + else + { $t->set_var('td_data',''); $t->set_var('lang_data',''); } @@ -124,4 +156,4 @@ $t->pparse('edithandle','edit'); $phpgw->common->phpgw_footer(); -?> \ No newline at end of file +?>