update sort categories

This commit is contained in:
bettina 2001-04-27 16:06:17 +00:00
parent b0199b263f
commit 7144eef917
12 changed files with 157 additions and 79 deletions

View File

@ -36,21 +36,25 @@
$cat_description = addslashes($cat_description);
$cat_access = 'public';
$c->add($cat_name,$cat_parent,$cat_description,$cat_data,$cat_access);
$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',lang('Category x has been added !', $cat_name)); }
if ((! $submit) && (! $error) && (! $errorcount)) { $t->set_var('message',''); }
$t->set_var('title_categories',lang('Add global category'));
$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_select_parent',lang('Select parent category'));
$t->set_var('category_list',$c->formated_list('select','all',$cat_parent,'False'));
$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('Select parent category'));
$t->set_var('category_list',$c->formated_list('select','all',$cat_parent));
$t->set_var('lang_name',lang('Category name'));
$t->set_var('lang_descr',lang('Category description'));
$t->set_var('cat_name',$cat_name);

View File

@ -82,15 +82,20 @@
$cat_id = $categories[$i]['id'];
$owner = $categories[$i]['owner'];
$space = "&nbsp;&nbsp;";
if ($categories[$i]['parent'] > 0) { $name = $space . $phpgw->strip_html($categories[$i]['name']); }
$space = '&nbsp;&nbsp;';
$level = $categories[$i]['level'];
if ($level > 0) {
$spaceset = str_repeat($space,$level);
$name = $spaceset . $phpgw->strip_html($categories[$i]['name']);
}
$descr = $phpgw->strip_html($categories[$i]['description']);
if (! $descr) { $descr = "&nbsp;"; }
if (! $descr) { $descr = '&nbsp;'; }
if ($categories[$i]['parent'] == 0) {
$name = "<font color=FF0000><b>" . $phpgw->strip_html($categories[$i]['name']) . "</b></font>";
$descr = "<font color=FF0000><b>" . $descr . "</b></font>";
if ($level == 0) {
$name = '<font color="FF0000"><b>' . $phpgw->strip_html($categories[$i]['name']) . '</b></font>';
$descr = '<font color="FF0000"><b>' . $descr . '</b></font>';
}
//-------------------------- template declaration for list records ---------------------------

View File

@ -51,12 +51,13 @@
}
if ($errorcount) { $t->set_var('message',$phpgw->common->error_list($error)); }
if (($submit) && (! $error) && (! $errorcount)) { $t->set_var('message',lang("Category x has been updated !",$cat_name)); }
if (($submit) && (! $error) && (! $errorcount)) { $t->set_var('message',lang('Category x has been updated !',$cat_name)); }
if ((! $submit) && (! $error) && (! $errorcount)) { $t->set_var('message',''); }
$cats = $c->return_single($cat_id);
$t->set_var('title_categories',lang('Edit global category'));
$t->set_var('lang_parent',lang('Parent category'));
$t->set_var('lang_select_parent',lang('Select parent category'));
$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"));
@ -69,12 +70,15 @@
$t->set_var('lang_edit',lang('Edit'));
$t->set_var('lang_delete',lang('Delete'));
$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));
$cat_id = $cats[0]['id'];
$cat_parent = $cats[0]['parent'];
$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',$cat_parent,'False'));
$t->set_var('category_list',$c->formated_list('select','all',$cat_parent));
$t->set_var('edithandle','');
$t->set_var('addhandle','');
@ -83,4 +87,4 @@
$t->pparse('edithandle','edit');
$phpgw->common->phpgw_footer();
?>
?>

View File

@ -10,7 +10,11 @@
<table border="0" width="80%" cellspacing="2" cellpadding="2">
<form name="form" action="{actionurl}" method="POST">
<tr>
<td>&nbsp;</td>
<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>
</tr>
<tr>
@ -59,4 +63,4 @@
</table>
</center>
<!-- END edit -->
<!-- END form -->
<!-- END form -->

View File

@ -10,7 +10,11 @@
<table border="0" width="80%" cellspacing="2" cellpadding="2">
<form name="form" action="{actionurl}" method="POST">
<tr>
<td>&nbsp;</td>
<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>
</tr>
<tr>
@ -59,4 +63,4 @@
</table>
</center>
<!-- END edit -->
<!-- END form -->
<!-- END form -->

View File

@ -10,7 +10,11 @@
<table border="0" width="80%" cellspacing="2" cellpadding="2">
<form name="form" action="{actionurl}" method="POST">
<tr>
<td>&nbsp;</td>
<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>
</tr>
<tr>
@ -59,4 +63,4 @@
</table>
</center>
<!-- END edit -->
<!-- END form -->
<!-- END form -->

View File

@ -93,9 +93,7 @@
{
global $phpgw, $phpgw_info;
$this->db2 = $this->db;
if ($public)
if ($public)
{
$public_cats = " OR cat_appname='phpgw' ";
}
@ -113,7 +111,7 @@
}
else
{
$ordermethod = " order by cat_parent asc";
$ordermethod = " order by cat_main asc";
}
if (is_array($this->grants))
@ -138,14 +136,11 @@
if ($query)
{
$sql = "SELECT * from phpgw_categories WHERE (cat_appname='" . $this->app_name . "' $public_cats $parent_filter) AND "
. " $grant_cats AND (cat_name like '%$query%' OR cat_description like '%$query%') $filter $ordermethod";
}
else
{
$sql = "SELECT * from phpgw_categories WHERE (cat_appname='" . $this->app_name . "' $public_cats $parent_filter) AND "
. " $grant_cats $filter $ordermethod";
$querymethod = " AND (cat_name like '%$query%' OR cat_description like '%$query%') ";
}
$sql = "SELECT * from phpgw_categories WHERE (cat_appname='" . $this->app_name . "' $public_cats $parent_filter) AND "
. " $grant_cats $querymethod $filter $ordermethod";
$this->db2->query($sql,__LINE__,__FILE__);
$this->total_records = $this->db2->num_rows();
@ -155,14 +150,16 @@
$i = 0;
while ($this->db->next_record())
{
$cats[$i]['id'] = $this->db->f('cat_id');
$cats[$i]['owner'] = $this->db->f('cat_owner');
$cats[$i]['access'] = $this->db->f('cat_access');
$cats[$i]['app_name'] = $this->db->f('cat_appname');
$cats[$i]['parent'] = $this->db->f('cat_parent');
$cats[$i]['name'] = $this->db->f('cat_name');
$cats[$i]['description'] = $this->db->f('cat_description');
$cats[$i]['data'] = $this->db->f('cat_data');
$cats[$i]['id'] = $this->db->f('cat_id');
$cats[$i]['owner'] = $this->db->f('cat_owner');
$cats[$i]['access'] = $this->db->f('cat_access');
$cats[$i]['app_name'] = $this->db->f('cat_appname');
$cats[$i]['main'] = $this->db->f('cat_main');
$cats[$i]['level'] = $this->db->f('cat_level');
$cats[$i]['parent'] = $this->db->f('cat_parent');
$cats[$i]['name'] = $this->db->f('cat_name');
$cats[$i]['description'] = $this->db->f('cat_description');
$cats[$i]['data'] = $this->db->f('cat_data');
$i++;
}
return $cats;
@ -182,14 +179,16 @@
$this->db->next_record();
$cats[0]['id'] = $this->db->f('cat_id');
$cats[0]['owner'] = $this->db->f('cat_owner');
$cats[0]['access'] = $this->db->f('cat_access');
$cats[0]['parent'] = $this->db->f('cat_parent');
$cats[0]['name'] = $this->db->f('cat_name');
$cats[0]['description'] = $this->db->f('cat_description');
$cats[0]['data'] = $this->db->f('cat_data');
$cats[0]['id'] = $this->db->f('cat_id');
$cats[0]['owner'] = $this->db->f('cat_owner');
$cats[0]['access'] = $this->db->f('cat_access');
$cats[0]['main'] = $this->db->f('cat_main');
$cats[0]['level'] = $this->db->f('cat_level');
$cats[0]['parent'] = $this->db->f('cat_parent');
$cats[0]['name'] = $this->db->f('cat_name');
$cats[0]['description'] = $this->db->f('cat_description');
$cats[0]['data'] = $this->db->f('cat_data');
return $cats;
}
/*!
@ -212,6 +211,7 @@
$this->account_id = $account_id;
$this->app_name = $app_name;
$this->db = $phpgw->db;
$this->db2 = $this->db;
$this->total_records = $this->db->num_rows();
$this->grants = $phpgw->acl->get_grants($app_name);
$this->cats = $this->return_array($type,$start,$limit,$query,$sort,$order,$public);
@ -265,12 +265,33 @@
@param $cat_description category description defaults to ''
@param $cat_data category data defaults to ''
*/
function add($cat_name,$cat_parent,$cat_description = '', $cat_data = '',$cat_access = '')
function add($cat_name,$cat_parent,$cat_description = '', $cat_data = '',$cat_access = '',$cat_main)
{
$this->db->query('insert into phpgw_categories (cat_parent,cat_owner,cat_access,cat_appname,cat_name,'
if ($cat_main)
{
$this->db2->query("Select cat_level from phpgw_categories where cat_id='$cat_parent'",__LINE__,__FILE__);
$this->db2->next_record();
$cat_level = $this->db2->f('cat_level')+1;
$this->db->query("insert into phpgw_categories (cat_parent,cat_owner,cat_access,cat_appname,cat_name,"
. "cat_description,cat_data) values ('$cat_parent','" . $this->account_id . "','$cat_access','"
. $this->app_name . "','" . addslashes($cat_name) . "','" . addslashes($cat_description)
. "','$cat_data')",__LINE__,__FILE__);
. "','$cat_data','$cat_main','$cat_level')",__LINE__,__FILE__);
}
else
{
$this->db->query("insert into phpgw_categories (cat_parent,cat_owner,cat_access,cat_appname,cat_name,"
. "cat_description,cat_data,cat_main,cat_level) values ('$cat_parent','" . $this->account_id . "','$cat_access','"
. $this->app_name . "','" . addslashes($cat_name) . "','" . addslashes($cat_description)
. "','$cat_data','$cat_main','$cat_level')",__LINE__,__FILE__);
$this->db2->query("select max(cat_id) as max from phpgw_categories",__LINE__,__FILE__);
$this->db2->next_record();
$this->db->query("update phpgw_categories set cat_main='" . $this->db2->f('max') . "' where cat_id='"
. $this->db2->f('max') . "'",__LINE__,__FILE__);
}
}
/*!
@function delete
@ -296,12 +317,32 @@
@param $cat_description category description defaults to ''
@param $cat_data category data defaults to ''
*/
function edit($cat_id,$cat_parent,$cat_name,$cat_description = '',$cat_data = '',$cat_access = '')
function edit($cat_id,$cat_parent,$cat_name,$cat_description = '',$cat_data = '',$cat_access = '',$cat_main)
{
if ($cat_main)
{
$this->db2->query("Select cat_level from phpgw_categories where cat_id='$cat_parent'",__LINE__,__FILE__);
$this->db2->next_record();
$cat_level = $this->db2->f('cat_level')+1;
$this->db->query("update phpgw_categories set cat_name='" . addslashes($cat_name) . "', "
. "cat_description='" . addslashes($cat_description) . "', cat_data='"
. "$cat_data', cat_parent='$cat_parent', cat_access='$cat_access' where cat_appname='"
. $this->app_name . "' and cat_id='$cat_id'",__LINE__,__FILE__);
. "cat_description='" . addslashes($cat_description) . "', cat_data='"
. "$cat_data', cat_parent='$cat_parent', cat_access='$cat_access', cat_main='$cat_main', cat_level='$cat_level' "
. "where cat_appname='" . $this->app_name . "' and cat_id='$cat_id'",__LINE__,__FILE__);
}
else
{
$this->db->query("update phpgw_categories set cat_name='" . addslashes($cat_name) . "', "
. "cat_description='" . addslashes($cat_description) . "', cat_data='"
. "$cat_data', cat_parent='$cat_parent', cat_access='$cat_access', cat_main='$cat_main', cat_level='$cat_level' "
. "where cat_appname='" . $this->app_name . "' and cat_id='$cat_id'",__LINE__,__FILE__);
$this->db2->query("select max(cat_id) as max from phpgw_categories",__LINE__,__FILE__);
$this->db2->next_record();
$this->db->query("update phpgw_categories set cat_main='" . $this->db2->f('max') . "' where cat_id='"
. $this->db2->f('max') . "'",__LINE__,__FILE__);
}
}
function name2id($cat_name)

View File

@ -54,7 +54,7 @@
if ($access) { $cat_access = 'private'; }
else { $cat_access = 'public'; }
$c->add($cat_name,$cat_parent,$cat_description,$cat_data,$cat_access);
$c->add($cat_name,$cat_parent,$cat_description,$cat_data,$cat_access,$cat_main);
}
}
@ -63,10 +63,14 @@
if ((! $submit) && (! $error) && (! $errorcount)) { $t->set_var('message',''); }
$t->set_var('font',$phpgw_info["theme"]["font"]);
$t->set_var('category_list',$c->formated_list('select','all',$cat_parent,'False'));
$t->set_var('lang_main',lang('Main category'));
$t->set_var('lang_new_main',lang('New main category'));
$t->set_var('font',$phpgw_info['theme']['font']);
$t->set_var('main_category_list',$c->formated_list('select','mains',$cat_main));
$t->set_var('category_list',$c->formated_list('select','all',$cat_parent));
$t->set_var('hidden_vars',$hidden_vars);
$t->set_var('user_name',$phpgw_info["user"]["fullname"]);
$t->set_var('user_name',$phpgw_info['user']['fullname']);
$t->set_var('doneurl',$phpgw->link('/preferences/categories.php'));
$t->set_var('title_categories',lang("Add x category for",$cats_app));
$t->set_var('actionurl',$phpgw->link('/preferences/addcategory.php'));

View File

@ -52,7 +52,7 @@
$c = CreateObject('phpgwapi.categories');
$c->app_name = $cats_app;
$categories = $c->return_array('all',$start,$limit,$query,$sort,$order,'False');
$categories = $c->return_array('all',$start,$limit,$query,$sort,$order);
//--------------------------------- nextmatch --------------------------------------------
@ -92,28 +92,28 @@
$cat_id = $categories[$i]['id'];
$owner = $categories[$i]['owner'];
$level = $categories[$i]['level'];
$space = '&nbsp;&nbsp;';
if ($categories[$i]['parent'] > 0)
{
$parent_data = $c->return_single($categories[$i]['parent']);
$name = $space . $phpgw->strip_html($parent_data[0]['name'] . ' :: ' . $categories[$i]['name']);
}
if ($level > 0) {
$spaceset = str_repeat($space,$level);
$name = $spaceset .$phpgw->strip_html($categories[$i]['name']);
}
$descr = $phpgw->strip_html($categories[$i]['description']);
if (! $descr) { $descr = '&nbsp;'; }
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>');
$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 ($categories[$i]['parent'] == 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 ($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>';
}
//-------------------------- template declaration for list records ---------------------------

View File

@ -52,20 +52,24 @@
if ($access) { $cat_access = 'private'; }
else { $cat_access = 'public'; }
if (! $error) { $c->edit($cat_id,$cat_parent,$cat_name,$cat_description,$cat_data,$cat_access); }
if (! $error) { $c->edit($cat_id,$cat_parent,$cat_name,$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 updated !",$cat_name)); }
if (($submit) && (! $error) && (! $errorcount)) { $t->set_var('message',lang('Category x has been updated !',$cat_name)); }
if ((! $submit) && (! $error) && (! $errorcount)) { $t->set_var('message',''); }
$cats = $c->return_single($cat_id);
$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));
$cat_parent = $cats[0]['parent'];
$t->set_var('category_list',$c->formated_list('select','all',$cat_parent,'False'));
$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",$cats_app));
$t->set_var('category_list',$c->formated_list('select','all',$cat_parent));
$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',$cats_app));
$t->set_var('doneurl',$phpgw->link('/preferences/categories.php'));
$t->set_var('actionurl',$phpgw->link('/preferences/editcategory.php'));
$t->set_var('deleteurl',$phpgw->link('/preferences/deletecategory.php'));

View File

@ -9,6 +9,10 @@
<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}"><select name="cat_parent"><option value="">{lang_select_parent}</option>{category_list}</select></font></td>

View File

@ -11,5 +11,5 @@
/* $Id$ */
$phpgw_info['server']['versions']['phpgwapi'] = '0.9.11.002';
$phpgw_info['server']['versions']['phpgwapi'] = '0.9.11.003';
$phpgw_info['server']['versions']['current_header'] = '1.11';