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

@ -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 = "<input type=\"hidden\" name=\"sort\" value=\"$sort\">\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 = "<input type=\"hidden\" name=\"sort\" value=\"$sort\">\n"
. "<input type=\"hidden\" name=\"order\" value=\"$order\">\n"
. "<input type=\"hidden\" name=\"query\" value=\"$query\">\n"
. "<input type=\"hidden\" name=\"start\" value=\"$start\">\n"
. "<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->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','<input type="checkbox" name="subs" value="True">');
}
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','<input type="checkbox" name="subs" value="True">');
}
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();
}
}
?>

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 form -->
<!-- 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) {
$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','<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','');
}
@ -118,4 +146,4 @@
$t->pparse('addhandle','add');
$phpgw->common->phpgw_footer();
?>
?>

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;
$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','<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,62 +107,81 @@
// -------------------------- 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);
$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 = '&nbsp;&nbsp;';
$cat_id = $categories[$i]['id'];
$owner = $categories[$i]['owner'];
$level = $categories[$i]['level'];
$space = '&nbsp;&nbsp;';
if ($level > 0) {
$spaceset = str_repeat($space,$level);
$name = $spaceset .$phpgw->strip_html($categories[$i]['name']);
}
if ($categories[$i]['app_name'] == 'phpgw')
{
$appendix = '&lt;' . lang('Global') . '&gt;';
}
else
{
$appendix = '';
}
$descr = $phpgw->strip_html($categories[$i]['description']);
if (! $descr) { $descr = '&nbsp;'; }
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 = '&nbsp;'; }
$t->set_var('td_data','<td><font face=' . $phpgw_info['theme']['font'] . '>' . $data . '</font></td>');
}
else { $t->set_var('td_data',''); }
$descr = $phpgw->strip_html($categories[$i]['description']);
if (! $descr) { $descr = '&nbsp;'; }
if ($level == 0) {
$name = '<font color="FF0000"><b>' . $phpgw->strip_html($categories[$i]['name']) . '</b></font>';
$descr = '<font color="FF0000"><b>' . $descr . '</b></font>';
$data = '<font color="FF0000"><b>' . $data . '</b></font>';
}
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','');
}
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>';
}
//-------------------------- 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','&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"));
$t->set_var('lang_delete_entry',lang('Delete'));
}
else {
$t->set_var('delete','');
$t->set_var('lang_delete_entry','&nbsp;');
}
$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','&nbsp;');
}
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','&nbsp;');
}
$t->parse('list','cat_list',True);
}
// ---------------------------- end record declaration -----------------------------------------
@ -149,4 +189,4 @@
$t->p('out');
$phpgw->common->phpgw_footer();
?>
?>

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) {
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','<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','');
}
@ -124,4 +156,4 @@
$t->pparse('edithandle','edit');
$phpgw->common->phpgw_footer();
?>
?>