update add plus edit cats

This commit is contained in:
bettina 2001-07-18 23:51:52 +00:00
parent c6f9a06500
commit fed982b4a3
10 changed files with 115 additions and 120 deletions

View File

@ -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','<input type="hidden" name="cat_id" value="' . $cat_id . '">');
$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'));

View File

@ -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 = '&nbsp;&nbsp;';
$level = $categories[$i]['level'];
if ($level > 0)
{
$space = '&nbsp;&nbsp;';
$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'));

View File

@ -35,6 +35,11 @@
. '<input type="hidden" name="filter" value="' . $filter . '">' . "\n"
. '<input type="hidden" name="cat_id" value="' . $cat_id . '">' . "\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']));

View File

@ -11,13 +11,9 @@
{message}
<table border="0" width="80%" cellspacing="2" cellpadding="2">
<form name="form" action="{actionurl}" method="POST">
<tr>
<td>{lang_main}</td>
<td><select name="cat_main"><option value="">{lang_new_main}</option>{main_category_list}</select></td>
</tr>
<tr>
<td>{lang_parent}</td>
<td><select name="cat_parent"><option value="">{lang_select_parent}</option>{category_list}</select></td>
<td><select name="new_parent"><option value="">{lang_none}</option>{category_list}</select></td>
</tr>
<tr>
<td>{lang_name}:</td>

View File

@ -25,6 +25,7 @@
<tr bgcolor="{th_bg}">
<td width=20% bgcolor="{th_bg}">{sort_name}</td>
<td width=32% bgcolor="{th_bg}">{sort_description}</td>
<td width=8% bgcolor="{th_bg}" align="center">{lang_sub}</td>
<td width=8% bgcolor="{th_bg}" align="center">{lang_edit}</td>
<td width=8% bgcolor="{th_bg}" align="center">{lang_delete}</td>
</tr>
@ -34,11 +35,12 @@
<tr bgcolor="{tr_color}">
<td>{name}</td>
<td>{descr}</td>
<td align="center"><a href="{add_sub}">{lang_sub_entry}</a></td>
<td align="center"><a href="{edit}">{lang_edit_entry}</a></td>
<td align="center"><a href="{delete}">{lang_delete_entry}</a></td>
</tr>
<!-- END cat_list -->
<!-- END cat_list -->
<!-- BEGINN add -->

View File

@ -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','<select name="cat_parent"><option value="">' . lang('Choose the parent category') . '</option>' . $category_list .'</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', '<input type="checkbox" name="access" value="True" checked>');
$t->set_var('access', '<input type="checkbox" name="cat_access" value="True" checked>');
}
else
{
$t->set_var('access', '<input type="checkbox" name="access" value="True">');
$t->set_var('access', '<input type="checkbox" name="cat_access" value="True">');
}
$t->set_var('lang_name',lang('Name'));
@ -160,7 +156,7 @@
if ($extra)
{
$t->set_var('td_data','<input name="cat_data" size="50" value="' . $cat_data . '">');
$t->set_var('td_data','<input name="cat_data" size="50" value="' . $phpgw->strip_html($cat_data) . '">');
$t->set_var('lang_data',lang($extra));
}
else

View File

@ -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 = '<input type="hidden" name="sort" value="' . $sort . '">' . "\n"
. '<input type="hidden" name="order" value="' . $order . '">' . "\n"
. '<input type="hidden" name="query" value="' . $query . '">' . "\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 = '&nbsp;&nbsp;';
if ($categories[$i]['app_name'] == 'phpgw')
{
@ -126,6 +126,7 @@
if ($level > 0)
{
$space = '&nbsp;&nbsp;';
$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','&nbsp;');
}
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

View File

@ -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','<select name="cat_parent"><option value="">' . lang('Choose the parent category') . '</option>' . $category_list .'</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', '<input type="checkbox" name="access" value="True" checked>');
$t->set_var('access', '<input type="checkbox" name="cat_access" value="True" checked>');
}
else
{
$t->set_var('access', '<input type="checkbox" name="access" value="True"');
$t->set_var('access', '<input type="checkbox" name="cat_access" value="True"');
}
$cat_id = $cats[0]['id'];
@ -167,7 +159,7 @@
if ($extra)
{
$t->set_var('td_data','<input name="cat_data" size="50" value="' . $cats[0]['data'] . '">');
$t->set_var('td_data','<input name="cat_data" size="50" value="' . $phpgw->strip_html($cats[0]['data']) . '">');
$t->set_var('lang_data',lang($extra));
}
else

View File

@ -11,13 +11,9 @@
<font face="{font}">{message}</font>
<table border="0" width="80%" cellspacing="2" cellpadding="2">
<form name="form" action="{actionurl}" method="POST">
<tr>
<td><font face="{font}">{lang_main}</font></td>
<td><font face="{font}"><select name="cat_main"><option value="">{lang_new_main}</option>{main_category_list}</select></font></td>
</tr>
<tr>
<td><font face="{font}">{lang_parent}</font></td>
<td><font face="{font}">{category_select}</font></td>
<td><font face="{font}"><select name="new_parent"><option value="">{lang_none}</option>{category_list}</select></font></td>
</tr>
<tr>
<td><font face="{font}">{lang_name}</font></td>

View File

@ -30,6 +30,7 @@
<td bgcolor="{th_bg}"><font face="{font}">{sort_description}</font></td>
{sort_data}
<td bgcolor="{th_bg}" align="center"><font face="{font}">{lang_app}</font></td>
<td bgcolor="{th_bg}" align=center><font face="{font}">{lang_sub}</font></td>
<td bgcolor="{th_bg}" align=center><font face="{font}">{lang_edit}</font></td>
<td bgcolor="{th_bg}" align=center><font face="{font}">{lang_delete}</font></td>
</tr>
@ -41,6 +42,7 @@
<td><font face="{font}">{descr}</font></td>
{td_data}
<td align="center"><font face="{font}"><a href="{app_url}">{lang_app}</a></font></td>
<td align="center"><font face="{font}"><a href="{add_sub}">{lang_sub_entry}</a></font></td>
<td align="center"><font face="{font}"><a href="{edit}">{lang_edit_entry}</a></font></td>
<td align="center"><font face="{font}"><a href="{delete}">{lang_delete_entry}</a></font></td>
</tr>