mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
update categories
This commit is contained in:
parent
3022447c3f
commit
dea0ac49a9
@ -37,39 +37,72 @@
|
||||
$c = CreateObject('phpgwapi.categories');
|
||||
$c->app_name = $cats_app;
|
||||
|
||||
if ($submit)
|
||||
if ($submit)
|
||||
{
|
||||
$errorcount = 0;
|
||||
|
||||
if (!$cat_name)
|
||||
{
|
||||
$errorcount = 0;
|
||||
|
||||
if (!$cat_name) { $error[$errorcount++] = lang('Please enter a name for that category !'); }
|
||||
|
||||
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 !'); }
|
||||
}
|
||||
|
||||
if ($cat_main && $cat_parent)
|
||||
{
|
||||
$main = $c->return_main($cat_parent);
|
||||
if ($main != $cat_main) { $error[$errorcount++] = lang('You selected an invalid main category !'); }
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$cat_name = addslashes($cat_name);
|
||||
$cat_description = addslashes($cat_description);
|
||||
if ($access) { $cat_access = 'private'; }
|
||||
else { $cat_access = 'public'; }
|
||||
|
||||
$c->add($cat_name,$cat_parent,$cat_description,$cat_data,$cat_access,$cat_main);
|
||||
}
|
||||
$error[$errorcount++] = lang('Please enter a name for that category !');
|
||||
}
|
||||
|
||||
if ($errorcount) { $t->set_var('message',$phpgw->common->error_list($error)); }
|
||||
if (($submit) && (! $error) && (! $errorcount)) { $t->set_var('message',lang('Category x has been added !',$cat_name)); }
|
||||
if ((! $submit) && (! $error) && (! $errorcount)) { $t->set_var('message',''); }
|
||||
if (!$error)
|
||||
{
|
||||
if (!$cat_parent)
|
||||
{
|
||||
$exists = $c->exists('appandmains',$cat_name,$cat_id='');
|
||||
}
|
||||
else
|
||||
{
|
||||
$exists = $c->exists('appandsubs',$cat_name,$cat_id='');
|
||||
}
|
||||
|
||||
if ($exists == True)
|
||||
{
|
||||
$error[$errorcount++] = lang('That category name has been used already !');
|
||||
}
|
||||
}
|
||||
|
||||
if ($cat_main && $cat_parent)
|
||||
{
|
||||
$main = $c->return_main($cat_parent);
|
||||
if ($main != $cat_main)
|
||||
{
|
||||
$error[$errorcount++] = lang('You selected an invalid main category !');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$cat_name = addslashes($cat_name);
|
||||
$cat_description = addslashes($cat_description);
|
||||
if ($access)
|
||||
{
|
||||
$cat_access = 'private';
|
||||
}
|
||||
else
|
||||
{
|
||||
$cat_access = 'public';
|
||||
}
|
||||
|
||||
$c->add($cat_name,$cat_parent,$cat_description,$cat_data,$cat_access,$cat_main);
|
||||
}
|
||||
}
|
||||
|
||||
if ($errorcount)
|
||||
{
|
||||
$t->set_var('message',$phpgw->common->error_list($error));
|
||||
}
|
||||
|
||||
if (($submit) && (! $error) && (! $errorcount))
|
||||
{
|
||||
$t->set_var('message',lang('Category x has been added !',$cat_name));
|
||||
}
|
||||
|
||||
if ((! $submit) && (! $error) && (! $errorcount))
|
||||
{
|
||||
$t->set_var('message','');
|
||||
}
|
||||
|
||||
$t->set_var('actionurl',$phpgw->link('/preferences/addcategory.php'));
|
||||
$t->set_var('title_categories',lang('Add x category for',$cats_app));
|
||||
|
@ -11,9 +11,15 @@
|
||||
\**************************************************************************/
|
||||
/* $Id$ */
|
||||
|
||||
if ($confirm) {
|
||||
$phpgw_info["flags"] = array('noheader' => True,
|
||||
'nonavbar' => True);
|
||||
if (! $cat_id)
|
||||
{
|
||||
Header('Location: ' . $phpgw->link('/preferences/categories.php',"cats_app=$cats_app&extra=$extra&cats_level=$cats_level&global_cats=$global_cats"));
|
||||
}
|
||||
|
||||
if ($confirm)
|
||||
{
|
||||
$phpgw_info['flags'] = array('noheader' => True,
|
||||
'nonavbar' => True);
|
||||
}
|
||||
|
||||
$phpgw_info['flags']['currentapp'] = $cats_app;
|
||||
@ -25,45 +31,52 @@
|
||||
$c = CreateObject('phpgwapi.categories');
|
||||
$c->app_name = $cats_app;
|
||||
|
||||
if (! $cat_id) {
|
||||
Header('Location: ' . $phpgw->link('/preferences/categories.php',"cats_app=$cats_app&extra=$extra&cats_level=$cats_level"));
|
||||
if ($confirm)
|
||||
{
|
||||
if ($subs)
|
||||
{
|
||||
$c->delete($cat_id,'True');
|
||||
}
|
||||
else
|
||||
{
|
||||
$c->delete($cat_id);
|
||||
}
|
||||
Header('Location: ' . $phpgw->link('/preferences/categories.php',"cats_app=$cats_app&extra=$extra&cats_level=$cats_level&global_cats=$global_cats"));
|
||||
}
|
||||
|
||||
if ($confirm) {
|
||||
if ($subs) { $c->delete($cat_id,'True'); }
|
||||
else { $c->delete($cat_id); }
|
||||
Header('Location: ' . $phpgw->link('/preferences/categories.php',"cats_app=$cats_app&extra=$extra&cats_level=$cats_level"));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
$hidden_vars = "<input type=\"hidden\" name=\"cat_id\" value=\"$cat_id\">\n"
|
||||
. "<input type=\"hidden\" name=\"cats_app\" value=\"$cats_app\">\n"
|
||||
. "<input type=\"hidden\" name=\"cats_level\" value=\"$cats_level\">\n"
|
||||
. "<input type=\"hidden\" name=\"global_cats\" value=\"$global_cats\">\n"
|
||||
. "<input type=\"hidden\" name=\"extra\" value=\"$extra\">\n";
|
||||
|
||||
$t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('preferences'));
|
||||
$t->set_file(array('category_delete' => 'delete.tpl'));
|
||||
$t->set_var('deleteheader',lang('Are you sure you want to delete this category ?'));
|
||||
$t->set_var('font',$phpgw_info['theme']['font']);
|
||||
$t->set_var('hidden_vars',$hidden_vars);
|
||||
$t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('preferences'));
|
||||
$t->set_file(array('category_delete' => 'delete.tpl'));
|
||||
$t->set_var('deleteheader',lang('Are you sure you want to delete this category ?'));
|
||||
$t->set_var('font',$phpgw_info['theme']['font']);
|
||||
$t->set_var('hidden_vars',$hidden_vars);
|
||||
|
||||
$exists = $c->exists('subs',$cat_name='',$cat_id);
|
||||
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', '');
|
||||
}
|
||||
$exists = $c->exists('subs',$cat_name='',$cat_id);
|
||||
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', '');
|
||||
}
|
||||
|
||||
$t->set_var('nolink',$phpgw->link('/preferences/categories.php',"cat_id=$cat_id&cats_app=$cats_app&extra=$extra&cats_level=$cats_level"));
|
||||
$t->set_var('lang_no',lang('No'));
|
||||
$t->set_var('nolink',$phpgw->link('/preferences/categories.php',"cat_id=$cat_id&cats_app=$cats_app&extra=$extra&cats_level=$cats_level&global_cats=$global_cats"));
|
||||
$t->set_var('lang_no',lang('No'));
|
||||
|
||||
$t->set_var('action_url',$phpgw->link('/preferences/deletecategory.php',"cat_id=$cat_id$cats_app=$cats_app&extra=$extra&cats_level=$cats_level"));
|
||||
$t->set_var('lang_yes',lang('Yes'));
|
||||
$t->set_var('action_url',$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_yes',lang('Yes'));
|
||||
|
||||
$t->pparse('out','category_delete');
|
||||
$t->pparse('out','category_delete');
|
||||
}
|
||||
|
||||
$phpgw->common->phpgw_footer();
|
||||
?>
|
||||
?>
|
||||
|
@ -11,6 +11,12 @@
|
||||
\**************************************************************************/
|
||||
/* $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&global_cats=$global_cats"));
|
||||
}
|
||||
|
||||
$phpgw_info['flags']['currentapp'] = $cats_app;
|
||||
$phpgw_info['flags']['noappheader'] = True;
|
||||
$phpgw_info['flags']['noappfooter'] = True;
|
||||
@ -28,12 +34,6 @@
|
||||
. "<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&global_cats=$global_cats"));
|
||||
}
|
||||
|
||||
$t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('preferences'));
|
||||
$t->set_file(array('form' => 'category_form.tpl'));
|
||||
$t->set_block('form','add','addhandle');
|
||||
@ -50,8 +50,8 @@
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$cat_parent) { $exists = $c->exists('mains',$cat_name,$cat_id); }
|
||||
else { $exists = $c->exists('subs',$cat_name,$cat_id); }
|
||||
if (!$cat_parent) { $exists = $c->exists('appandmains',$cat_name,$cat_id); }
|
||||
else { $exists = $c->exists('appandsubs',$cat_name,$cat_id); }
|
||||
if ($exists == True) { $error[$errorcount++] = lang('That category name has been used already !'); }
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user