From fed982b4a3326878ab360c657d741767795a476d Mon Sep 17 00:00:00 2001 From: bettina Date: Wed, 18 Jul 2001 23:51:52 +0000 Subject: [PATCH] update add plus edit cats --- admin/addcategory.php | 31 ++++----- admin/categories.php | 7 +- admin/editcategory.php | 33 ++++------ admin/templates/default/category_form.tpl | 6 +- admin/templates/default/listcats.tpl | 4 +- preferences/addcategory.php | 64 +++++++++---------- preferences/categories.php | 24 +++++-- preferences/editcategory.php | 58 ++++++++--------- .../templates/default/category_form.tpl | 6 +- preferences/templates/default/listcats.tpl | 2 + 10 files changed, 115 insertions(+), 120 deletions(-) diff --git a/admin/addcategory.php b/admin/addcategory.php index 8092ead8a8..7323594fb5 100644 --- a/admin/addcategory.php +++ b/admin/addcategory.php @@ -22,6 +22,11 @@ $c = CreateObject('phpgwapi.categories'); $c->app_name = 'phpgw'; + if ($new_parent) + { + $cat_parent = $new_parent; + } + if ($submit) { $errorcount = 0; @@ -48,22 +53,15 @@ } } - if ($cat_main && $cat_parent) - { - $main = $c->id2name($cat_parent,'main'); - if ($main != $cat_main) - { - $error[$errorcount++] = lang('You have selected an invalid main category !'); - } - } - if (!$error) { - $cat_name = addslashes($cat_name); - $cat_description = addslashes($cat_description); - $cat_access = 'public'; - - $c->add($cat_name,$cat_parent,$cat_description,$cat_data,$cat_access,$cat_main); + $c->add(array + ( + 'parent' => $cat_parent, + 'descr' => $cat_description, + 'name' => $cat_name, + 'access' => 'public' + )); } } @@ -86,11 +84,8 @@ $t->set_var('actionurl',$phpgw->link('/admin/addcategory.php')); $t->set_var('doneurl',$phpgw->link('/admin/categories.php')); $t->set_var('hidden_vars',''); - $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)); $t->set_var('lang_parent',lang('Parent category')); - $t->set_var('lang_select_parent',lang('Choose the parent category')); + $t->set_var('lang_none',lang('None')); $t->set_var('category_list',$c->formated_list('select','all',$cat_parent)); $t->set_var('lang_name',lang('Name')); $t->set_var('lang_descr',lang('Description')); diff --git a/admin/categories.php b/admin/categories.php index 44dff1003a..e1c672e3fa 100644 --- a/admin/categories.php +++ b/admin/categories.php @@ -59,6 +59,7 @@ $t->set_var('th_bg',$phpgw_info['theme']['th_bg']); $t->set_var('sort_name',$phpgw->nextmatchs->show_sort_order($sort,'cat_name',$order,'/admin/categories.php',lang('Name'))); $t->set_var('sort_description',$phpgw->nextmatchs->show_sort_order($sort,'cat_description',$order,'/admin/categories.php',lang('Description'))); + $t->set_var('lang_sub',lang('Add sub')); $t->set_var('lang_edit',lang('Edit')); $t->set_var('lang_delete',lang('Delete')); @@ -70,11 +71,11 @@ $t->set_var(tr_color,$tr_color); $cat_id = $categories[$i]['id']; - $space = '  '; $level = $categories[$i]['level']; if ($level > 0) { + $space = '  '; $spaceset = str_repeat($space,$level); $name = $spaceset . $phpgw->strip_html($categories[$i]['name']); } @@ -93,6 +94,10 @@ $t->set_var(array('name' => $name, 'descr' => $descr)); + $t->set_var('add_sub',$phpgw->link('/admin/addcategory.php','cat_parent=' . $cat_id . '&start=' . $start . '&query=' . $query . '&sort=' . $sort + . '&order=' . $order . '&filter=' . $filter)); + $t->set_var('lang_sub_entry',lang('Add sub')); + $t->set_var('edit',$phpgw->link('/admin/editcategory.php','cat_id=' . $cat_id . '&start=' . $start . '&query=' . $query . '&sort=' . $sort . '&order=' . $order . '&filter=' . $filter)); $t->set_var('lang_edit_entry',lang('Edit')); diff --git a/admin/editcategory.php b/admin/editcategory.php index 142ca60bec..8212de4e3c 100644 --- a/admin/editcategory.php +++ b/admin/editcategory.php @@ -35,6 +35,11 @@ . '' . "\n" . '' . "\n"; + if ($new_parent) + { + $cat_parent = $new_parent; + } + if ($submit) { $errorcount = 0; @@ -61,22 +66,16 @@ } } - if ($cat_main && $cat_parent) - { - $main = $c->id2name($cat_parent,'main'); - if ($main != $cat_main) - { - $error[$errorcount++] = lang('You have selected an invalid main category !'); - } - } - - $cat_name = addslashes($cat_name); - $cat_description = addslashes($cat_description); - $cat_access = 'public'; - if (! $error) { - $c->edit($cat_id,$cat_parent,$cat_name,$cat_description,$cat_data,$cat_access,$cat_main); + $c->edit(array + ( + 'access' => 'public', + 'parent' => $cat_parent, + 'descr' => $cat_description, + 'name' => $cat_name, + 'id' => $cat_id + )); } } @@ -99,7 +98,7 @@ $t->set_var('title_categories',lang('Edit global category')); $t->set_var('lang_parent',lang('Parent category')); - $t->set_var('lang_select_parent',lang('Choose the parent category')); + $t->set_var('lang_none',lang('None')); $t->set_var('actionurl',$phpgw->link('/admin/editcategory.php')); $t->set_var('deleteurl',$phpgw->link('/admin/deletecategory.php','cat_id=' . $cat_id . '&start=' . $start . '&query=' . $query . '&sort=' . $sort . '&order=' . $order . '&filter=' . $filter)); @@ -110,11 +109,7 @@ $t->set_var('lang_done',lang('Done')); $t->set_var('lang_edit',lang('Edit')); $t->set_var('lang_delete',lang('Delete')); - $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',$cats[0]['main'])); - $cat_id = $cats[0]['id']; $t->set_var('cat_name',$phpgw->strip_html($cats[0]['name'])); $t->set_var('cat_description',$phpgw->strip_html($cats[0]['description'])); $t->set_var('category_list',$c->formated_list('select','all',$cats[0]['parent'])); diff --git a/admin/templates/default/category_form.tpl b/admin/templates/default/category_form.tpl index d36dbdb358..33ea5a3f60 100644 --- a/admin/templates/default/category_form.tpl +++ b/admin/templates/default/category_form.tpl @@ -11,13 +11,9 @@ {message} - - - - - + diff --git a/admin/templates/default/listcats.tpl b/admin/templates/default/listcats.tpl index 6f709bd571..a0322b04dc 100644 --- a/admin/templates/default/listcats.tpl +++ b/admin/templates/default/listcats.tpl @@ -25,6 +25,7 @@ + @@ -34,11 +35,12 @@ + - + diff --git a/preferences/addcategory.php b/preferences/addcategory.php index eed3699398..5f5fa78dd5 100644 --- a/preferences/addcategory.php +++ b/preferences/addcategory.php @@ -36,6 +36,11 @@ $c = CreateObject('phpgwapi.categories'); $c->app_name = $cats_app; + if ($new_parent) + { + $cat_parent = $new_parent; + } + if ($submit) { $errorcount = 0; @@ -62,20 +67,9 @@ } } - if ($cat_main && $cat_parent) - { - $main = $c->id2name($cat_parent,'main'); - if ($main != $cat_main) - { - $error[$errorcount++] = lang('You have selected an invalid main category'); - } - } - if (!$error) { - $cat_name = addslashes($cat_name); - $cat_description = addslashes($cat_description); - if ($access) + if ($cat_access) { $cat_access = 'private'; } @@ -84,7 +78,14 @@ $cat_access = 'public'; } - $c->add($cat_name,$cat_parent,$cat_description,$cat_data,$cat_access,$cat_main); + $c->add(array + ( + 'name' => $cat_name, + 'descr' => $cat_description, + 'parent' => $cat_parent, + 'access' => $cat_access, + 'data' => $cat_data + )); } } @@ -109,18 +110,8 @@ $t->set_var('user_name',$phpgw_info['user']['fullname']); $t->set_var('hidden_vars',$hidden_vars); $t->set_var('font',$phpgw_info['theme']['font']); - - $t->set_var('lang_main',lang('Main category')); - $t->set_var('lang_new_main',lang('New main category')); - - 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)); - } + $t->set_var('lang_parent',lang('Parent category')); + $t->set_var('lang_none',lang('None')); if ($cats_level) { @@ -132,25 +123,30 @@ { $category_list = $c->formated_list('select','all',$cat_parent); } - - $t->set_var('category_select',''); - $t->set_var('lang_parent',lang('Parent category')); } else { - $t->set_var('lang_parent',''); - $t->set_var('category_select',''); + if ($global_cats) + { + $category_list = $c->formated_list('select','mains',$cat_parent,True); + } + else + { + $category_list = $c->formated_list('select','mains',$cat_parent); + } } + $t->set_var('category_list',$category_list); + $t->set_var('lang_access',lang('Private')); - if ($access) + if ($cat_access) { - $t->set_var('access', ''); + $t->set_var('access', ''); } else { - $t->set_var('access', ''); + $t->set_var('access', ''); } $t->set_var('lang_name',lang('Name')); @@ -160,7 +156,7 @@ if ($extra) { - $t->set_var('td_data',''); + $t->set_var('td_data',''); $t->set_var('lang_data',lang($extra)); } else diff --git a/preferences/categories.php b/preferences/categories.php index 7b0e3c5feb..9eadef8a68 100644 --- a/preferences/categories.php +++ b/preferences/categories.php @@ -31,6 +31,9 @@ 'cat_list' => 'listcats.tpl')); $t->set_block('cat_list_t','cat_list','list'); + $c = CreateObject('phpgwapi.categories'); + $c->app_name = $cats_app; + $hidden_vars = '' . "\n" . '' . "\n" . '' . "\n" @@ -57,9 +60,6 @@ if (! $start) { $start = 0; } - $c = CreateObject('phpgwapi.categories'); - $c->app_name = $cats_app; - if ($global_cats) { $categories = $c->return_array('all',$start,True,$query,$sort,$order,True); @@ -101,6 +101,7 @@ } $t->set_var('lang_app',lang($cats_app)); + $t->set_var('lang_sub',lang('Add sub')); $t->set_var('lang_edit',lang('Edit')); $t->set_var('lang_delete',lang('Delete')); @@ -113,7 +114,6 @@ $cat_id = $categories[$i]['id']; $owner = $categories[$i]['owner']; $level = $categories[$i]['level']; - $space = '  '; if ($categories[$i]['app_name'] == 'phpgw') { @@ -126,6 +126,7 @@ if ($level > 0) { + $space = '  '; $spaceset = str_repeat($space,$level); $name = $spaceset .$phpgw->strip_html($categories[$i]['name']) . $appendix; } @@ -158,6 +159,21 @@ $t->set_var('app_url',$phpgw->link('/' . $phpgw_info['flags']['currentapp'] . '/index.php','cat_id=' . $cat_id)); + if ($cats_level || ($level == 0)) + { + if ($categories[$i]['owner'] == $phpgw_info['user']['account_id'] || $categories[$i]['app_name'] == 'phpgw') + { + $t->set_var('add_sub',$phpgw->link('/preferences/addcategory.php','cat_parent=' . $cat_id . '&cats_app=' . $cats_app . '&extra=' . $extra + . '&cats_level=' . $cats_level . '&global_cats=' . $global_cats)); + $t->set_var('lang_sub_entry',lang('Add sub')); + } + } + else + { + $t->set_var('add_sub',''); + $t->set_var('lang_sub_entry',' '); + } + 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 diff --git a/preferences/editcategory.php b/preferences/editcategory.php index a135fdf7d3..4cd0937ed9 100644 --- a/preferences/editcategory.php +++ b/preferences/editcategory.php @@ -67,18 +67,7 @@ } } - if ($cat_main && $cat_parent) - { - $main = $c->id2name($cat_parent,'main'); - if ($main != $cat_main) - { - $error[$errorcount++] = lang('You have selected an invalid main category'); - } - } - - $cat_name = addslashes($cat_name); - $cat_description = addslashes($cat_description); - if ($access) + if ($cat_access) { $cat_access = 'private'; } @@ -89,7 +78,15 @@ if (! $error) { - $c->edit($cat_id,$cat_parent,$cat_name,$cat_description,$cat_data,$cat_access,$cat_main); + $c->edit(array + ( + 'id' => $cat_id, + 'parent' => $cat_parent, + 'name' => $cat_name, + 'descr' => $cat_description, + 'access' => $cat_access, + 'data' => $cat_data + )); } } @@ -108,18 +105,6 @@ $cats = $c->return_single($cat_id); - $t->set_var('lang_main',lang('Main category')); - $t->set_var('lang_new_main',lang('New main category')); - - if ($global_cats) - { - $t->set_var('main_category_list',$c->formated_list('select','mains',$cats[0]['main'],True)); - } - else - { - $t->set_var('main_category_list',$c->formated_list('select','mains',$cats[0]['main'])); - } - if ($cats_level) { if ($global_cats) @@ -130,16 +115,23 @@ { $category_list = $c->formated_list('select','all',$cats[0]['parent']); } - - $t->set_var('category_select',''); - $t->set_var('lang_parent',lang('Parent category')); } else { - $t->set_var('lang_parent',''); - $t->set_var('category_select',''); + if ($global_cats) + { + $category_list = $c->formated_list('select','mains',$cats[0]['parent'],True); + } + else + { + $category_list = $c->formated_list('select','mains',$cats[0]['parent']); + } } + $t->set_var('category_list',$category_list); + $t->set_var('lang_parent',lang('Parent category')); + $t->set_var('lang_none',lang('None')); + $t->set_var('font',$phpgw_info['theme']['font']); $t->set_var('user_name',$phpgw_info['user']['fullname']); $t->set_var('title_categories',lang('Edit x category for',lang($cats_app))); @@ -153,11 +145,11 @@ if ($cats[0]['access']=='private') { - $t->set_var('access', ''); + $t->set_var('access', ''); } else { - $t->set_var('access', 'set_var('access', 'set_var('td_data',''); + $t->set_var('td_data',''); $t->set_var('lang_data',lang($extra)); } else diff --git a/preferences/templates/default/category_form.tpl b/preferences/templates/default/category_form.tpl index 15a91f9d7d..1186ff835c 100644 --- a/preferences/templates/default/category_form.tpl +++ b/preferences/templates/default/category_form.tpl @@ -11,13 +11,9 @@ {message}
{lang_main}
{lang_parent}
{lang_name}:
{sort_name} {sort_description}{lang_sub} {lang_edit} {lang_delete}
{name} {descr}{lang_sub_entry} {lang_edit_entry} {lang_delete_entry}
- - - - - + diff --git a/preferences/templates/default/listcats.tpl b/preferences/templates/default/listcats.tpl index 68e877751e..5dc91215a3 100644 --- a/preferences/templates/default/listcats.tpl +++ b/preferences/templates/default/listcats.tpl @@ -30,6 +30,7 @@ {sort_data} + @@ -41,6 +42,7 @@ {td_data} +
{lang_main}
{lang_parent}{category_select}
{lang_name}{sort_description}{lang_app}{lang_sub} {lang_edit} {lang_delete}
{descr}{lang_app}{lang_sub_entry} {lang_edit_entry} {lang_delete_entry}