update categories to have the possibility to choose global parent cats for apps_sub_cats

This commit is contained in:
bettina 2001-05-11 00:47:50 +00:00
parent 3883ba049a
commit a0404d3b53
6 changed files with 279 additions and 131 deletions

View File

@ -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');

View File

@ -13,10 +13,8 @@
if ($confirm)
{
$phpgw_info['flags'] = array(
'noheader' => True,
'nonavbar' => True
);
$phpgw_info['flags'] = array('noheader' => True,
'nonavbar' => True);
}
$phpgw_info['flags']['currentapp'] = 'admin';
@ -32,8 +30,14 @@
if ($confirm)
{
if ($subs) { $c->delete($cat_id,'True'); }
else { $c->delete($cat_id); }
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"));
}
else
@ -45,8 +49,31 @@
. "<input type=\"hidden\" name=\"filter\" value=\"$filter\">\n"
. "<input type=\"hidden\" name=\"cat_id\" value=\"$cat_id\">\n";
$t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin'));
$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');
$nolink = $phpgw->link('/admin/categories.php',"cat_id=$cat_id&start=$start&query=$query&sort=$sort&order=$order&filter=$filter");
$apps_cats = $c->exists('subs',$cat_name='',$cat_id);
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);
@ -54,7 +81,7 @@
if ($exists==True)
{
$t->set_var('lang_subs',lang('Do you also want to delete all subcategories ?'));
$t->set_var('lang_subs',lang('Do you also want to delete all global subcategories ?'));
$t->set_var('subs','<input type="checkbox" name="subs" value="True">');
}
else
@ -63,14 +90,16 @@
$t->set_var('subs', '');
}
$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('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();
}
}
$phpgw->common->phpgw_footer();
?>

View File

@ -9,6 +9,9 @@
<td align="center">{lang_subs}</td>
<td align="center">{subs}</td>
</tr>
<!-- BEGIN delete -->
<tr>
<td align="center">
{hidden_vars}
@ -18,4 +21,20 @@
</tr>
</table>
</center>
<!-- END delete -->
<!-- BEGIN done -->
</form>
<tr>
<td align="center">
{hidden_vars}
<a href="{nolink}">{lang_done}</a></td>
</tr>
</table>
</center>
<!-- END done -->
<!-- END form -->

View File

@ -24,6 +24,7 @@
. "<input type=\"hidden\" name=\"start\" value=\"$start\">\n"
. "<input type=\"hidden\" name=\"cats_app\" value=\"$cats_app\">\n"
. "<input type=\"hidden\" name=\"extra\" value=\"$extra\">\n"
. "<input type=\"hidden\" name=\"global_cats\" value=\"$global_cats\">\n"
. "<input type=\"hidden\" name=\"cats_level\" value=\"$cats_level\">\n"
. "<input type=\"hidden\" name=\"filter\" value=\"$filter\">\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) {
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','<select name="cat_parent"><option value="">' . lang('Select parent category') . '</option>' . $category_list .'</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', '<input type="checkbox" name="access" value="True" checked>'); }
else { $t->set_var('access', '<input type="checkbox" name="access" value="True">'); }
if ($access)
{
$t->set_var('access', '<input type="checkbox" name="access" value="True" checked>');
}
else
{
$t->set_var('access', '<input type="checkbox" name="access" value="True">');
}
$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','<input name="cat_data" size="50" value="' . $cat_data . '">');
$t->set_var('lang_data',lang($extra));
}
else {
else
{
$t->set_var('td_data','');
$t->set_var('lang_data','');
}

View File

@ -30,6 +30,7 @@
. "<input type=\"hidden\" name=\"start\" value=\"$start\">\n"
. "<input type=\"hidden\" name=\"cats_app\" value=\"$cats_app\">\n"
. "<input type=\"hidden\" name=\"extra\" value=\"$extra\">\n"
. "<input type=\"hidden\" name=\"global_cats\" value=\"$global_cats\">\n"
. "<input type=\"hidden\" name=\"cats_level\" value=\"$cats_level\">\n"
. "<input type=\"hidden\" name=\"filter\" value=\"$filter\">\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;
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','<td bgcolor="' . $phpgw_info['theme']['th_bg'] . '"><font face="' . $phpgw_info['theme']['font'] . '">'
. $phpgw->nextmatchs->show_sort_order($sort,'cat_data',$order,'/preferences/categories.php',lang($extra),"&cats_app=$cats_app&extra=$extra&cats_level=$cats_level") . '</td>');
. $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") . '</td>');
}
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,7 +107,8 @@
// -------------------------- end header declaration --------------------------------------
for ($i=0;$i<count($categories);$i++) {
for ($i=0;$i<count($categories);$i++)
{
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$t->set_var('tr_color',$tr_color);
@ -96,23 +118,38 @@
$level = $categories[$i]['level'];
$space = '&nbsp;&nbsp;';
if ($level > 0) {
if ($categories[$i]['app_name'] == 'phpgw')
{
$appendix = '&lt;' . lang('Global') . '&gt;';
}
else
{
$appendix = '';
}
if ($level > 0)
{
$spaceset = str_repeat($space,$level);
$name = $spaceset .$phpgw->strip_html($categories[$i]['name']);
$name = $spaceset .$phpgw->strip_html($categories[$i]['name']) . $appendix;
}
$descr = $phpgw->strip_html($categories[$i]['description']);
if (! $descr) { $descr = '&nbsp;'; }
if ($extra) {
if ($extra)
{
$data = $categories[$i]['data'];
if (! $data) { $data = '&nbsp;'; }
$t->set_var('td_data','<td><font face=' . $phpgw_info['theme']['font'] . '>' . $data . '</font></td>');
}
else { $t->set_var('td_data',''); }
else
{
$t->set_var('td_data','');
}
if ($level == 0) {
$name = '<font color="FF0000"><b>' . $phpgw->strip_html($categories[$i]['name']) . '</b></font>';
if ($level == 0)
{
$name = '<font color="FF0000"><b>' . $phpgw->strip_html($categories[$i]['name']) . '</b></font>' . $appendix;
$descr = '<font color="FF0000"><b>' . $descr . '</b></font>';
$data = '<font color="FF0000"><b>' . $data . '</b></font>';
}
@ -122,22 +159,25 @@
$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"));
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"));
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 {
else
{
$t->set_var('edit','');
$t->set_var('lang_edit_entry','&nbsp;');
}
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"));
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 {
else
{
$t->set_var('delete','');
$t->set_var('lang_delete_entry','&nbsp;');
}

View File

@ -24,12 +24,14 @@
. "<input type=\"hidden\" name=\"cats_app\" value=\"$cats_app\">\n"
. "<input type=\"hidden\" name=\"cat_id\" value=\"$cat_id\">\n"
. "<input type=\"hidden\" name=\"extra\" value=\"$extra\">\n"
. "<input type=\"hidden\" name=\"global_cats\" value=\"$global_cats\">\n"
. "<input type=\"hidden\" name=\"cats_level\" value=\"$cats_level\">\n"
. "<input type=\"hidden\" name=\"filter\" value=\"$filter\">\n";
if (! $cat_id) {
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"));
. "&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'];
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','<select name="cat_parent"><option value="">' . lang('Select parent category') . '</option>' . $category_list .'</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', '<input type="checkbox" name="access" value="True" checked>'); }
else { $t->set_var('access', '<input type="checkbox" name="access" value="True"'); }
if ($cats[0]['access']=='private')
{
$t->set_var('access', '<input type="checkbox" name="access" value="True" checked>');
}
else
{
$t->set_var('access', '<input type="checkbox" name="access" value="True"');
}
$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']));
if ($extra) {
if ($extra)
{
$t->set_var('td_data','<input name="cat_data" size="50" value="' . $cats[0]['data'] . '">');
$t->set_var('lang_data',lang($extra));
}
else {
else
{
$t->set_var('td_data','');
$t->set_var('lang_data','');
}