diff --git a/admin/inc/class.uicategories.inc.php b/admin/inc/class.uicategories.inc.php
index a6a6794414..6181cabb60 100644
--- a/admin/inc/class.uicategories.inc.php
+++ b/admin/inc/class.uicategories.inc.php
@@ -34,25 +34,25 @@
function uicategories()
{
- $this->bo = CreateObject('admin.bocategories');
- $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
+ $this->bo = CreateObject('admin.bocategories');
+ $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
- $this->start = $this->bo->start;
- $this->query = $this->bo->query;
- $this->sort = $this->bo->sort;
- $this->order = $this->bo->order;
- $this->cat_id = $this->bo->cat_id;
+ $this->start = $this->bo->start;
+ $this->query = $this->bo->query;
+ $this->sort = $this->bo->sort;
+ $this->order = $this->bo->order;
+ $this->cat_id = $this->bo->cat_id;
if($this->debug) { $this->_debug_sqsof(); }
}
function _debug_sqsof()
{
$data = array(
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'cat_id' => $this->cat_id
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'cat_id' => $this->cat_id
);
echo '
UI:
';
_debug_array($data);
@@ -62,10 +62,10 @@
{
$data = array
(
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order
);
if(isset($this->cat_id))
@@ -335,20 +335,18 @@
$this->set_langs();
- $new_parent = $GLOBALS['HTTP_POST_VARS']['new_parent'];
- $submit = $GLOBALS['HTTP_POST_VARS']['submit'];
- $cat_parent = $GLOBALS['HTTP_POST_VARS']['cat_parent'];
- $cat_name = $GLOBALS['HTTP_POST_VARS']['cat_name'];
- $cat_description = $GLOBALS['HTTP_POST_VARS']['cat_description'];
+ $new_parent = $GLOBALS['HTTP_POST_VARS']['new_parent'];
+ $submit = $GLOBALS['HTTP_POST_VARS']['submit'];
+ $cat_parent = $GLOBALS['HTTP_POST_VARS']['cat_parent'];
+ $cat_name = $GLOBALS['HTTP_POST_VARS']['cat_name'];
+ $cat_description = $GLOBALS['HTTP_POST_VARS']['cat_description'];
+ $old_parent = $GLOBALS['HTTP_POST_VARS']['old_parent'];
$GLOBALS['phpgw']->template->set_file(array('cat_form' => 'category_form.tpl'));
$GLOBALS['phpgw']->template->set_block('cat_form','add');
$GLOBALS['phpgw']->template->set_block('cat_form','edit');
$GLOBALS['phpgw']->template->set_block('cat_form','form');
-
- $hidden_vars = '' . "\n";
- $GLOBALS['phpgw']->template->set_var('hidden_vars',$hidden_vars);
$GLOBALS['phpgw']->template->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
if ($new_parent)
@@ -360,11 +358,12 @@
{
$values = array
(
- 'id' => $this->cat_id,
- 'parent' => $cat_parent,
- 'descr' => $cat_description,
- 'name' => $cat_name,
- 'access' => 'public'
+ 'id' => $this->cat_id,
+ 'old_parent' => $old_parent,
+ 'parent' => $cat_parent,
+ 'descr' => $cat_description,
+ 'name' => $cat_name,
+ 'access' => 'public'
);
$error = $this->bo->check_values($values);
@@ -374,7 +373,7 @@
}
else
{
- $this->bo->save_cat($values);
+ $this->cat_id = $this->bo->save_cat($values);
$GLOBALS['phpgw']->template->set_var('message',lang('Category x has been updated !',$cat_name));
}
}
@@ -390,6 +389,10 @@
$GLOBALS['phpgw']->template->set_var('title_categories',lang('Edit global category'));
}
+ $hidden_vars = '' . "\n"
+ . '' . "\n";
+ $GLOBALS['phpgw']->template->set_var('hidden_vars',$hidden_vars);
+
$link_data['menuaction'] = 'admin.uicategories.edit';
$link_data['cat_id'] = $this->cat_id;
$GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
@@ -398,13 +401,10 @@
$GLOBALS['phpgw']->template->set_var('cat_name',$GLOBALS['phpgw']->strip_html($cats[0]['name']));
$GLOBALS['phpgw']->template->set_var('cat_description',$GLOBALS['phpgw']->strip_html($cats[0]['description']));
- $GLOBALS['phpgw']->template->set_var('category_list',$this->bo->formatted_list(array(
- 'select' => 'select',
- 'all' => 'all',
- 'cat_parent' => $cats[0]['parent'],
- 'global_cats' => $global_cats
- )));
-
+ $GLOBALS['phpgw']->template->set_var('category_list',$this->bo->formatted_list(array('select' => 'select',
+ 'all' => 'all',
+ 'cat_parent' => $cats[0]['parent'],
+ 'global_cats' => $global_cats)));
$GLOBALS['phpgw']->template->parse('buttons','edit');
$GLOBALS['phpgw']->template->fp('phpgw_body','form');
}
diff --git a/admin/templates/default/index.tpl b/admin/templates/default/index.tpl
index f4e5b985ff..112114fb06 100755
--- a/admin/templates/default/index.tpl
+++ b/admin/templates/default/index.tpl
@@ -19,11 +19,9 @@
}
}
-
diff --git a/phpgwapi/inc/class.categories.inc.php b/phpgwapi/inc/class.categories.inc.php
index 3d08877a08..031ff1f5e3 100644
--- a/phpgwapi/inc/class.categories.inc.php
+++ b/phpgwapi/inc/class.categories.inc.php
@@ -649,26 +649,35 @@
*/
function edit($cat_values)
{
- if ($cat_values['parent'] && ($cat_values['parent'] != 0))
+ if (intval($cat_values['old_parent']) != $cat_values['parent'])
{
- $cat_values['main'] = $this->id2name($cat_values['parent'],'main');
- $cat_values['level'] = $this->id2name($cat_values['parent'],'level')+1;
+ $this->delete(array('cat_id' => $cat_values['id'],'drop_subs' => False,'modify_subs' => True));
+ return $this->add($cat_values);
}
else
{
- $cat_values['main'] = $cat_values['id'];
- $cat_values['level'] = 0;
+ if ($cat_values['parent'] && ($cat_values['parent'] != 0))
+ {
+ $cat_values['main'] = intval($this->id2name($cat_values['parent'],'main'));
+ $cat_values['level'] = intval($this->id2name($cat_values['parent'],'level')+1);
+ }
+ else
+ {
+ $cat_values['main'] = intval($cat_values['id']);
+ $cat_values['level'] = 0;
+ }
}
$cat_values['descr'] = $this->db->db_addslashes($cat_values['descr']);
$cat_values['name'] = $this->db->db_addslashes($cat_values['name']);
$sql = "UPDATE phpgw_categories SET cat_name='" . $cat_values['name'] . "', cat_description='" . $cat_values['descr']
- . "', cat_data='" . $cat_values['data'] . "', cat_parent='" . $cat_values['parent'] . "', cat_access='"
- . $cat_values['access'] . "', cat_main='" . $cat_values['main'] . "', cat_level='" . $cat_values['level'] . "' "
- . "WHERE cat_appname='" . $this->app_name . "' AND cat_id='" . $cat_values['id'] . "'";
+ . "', cat_data='" . $cat_values['data'] . "', cat_parent=" . $cat_values['parent'] . ", cat_access='"
+ . $cat_values['access'] . "', cat_main=" . $cat_values['main'] . ", cat_level=" . $cat_values['level']
+ . " WHERE cat_appname='" . $this->app_name . "' AND cat_id=" . intval($cat_values['id']);
$this->db->query($sql,__LINE__,__FILE__);
+ return intval($cat_values['id']);
}
function name2id($cat_name)
diff --git a/preferences/inc/class.uicategories.inc.php b/preferences/inc/class.uicategories.inc.php
index 1445485af0..12812e4372 100644
--- a/preferences/inc/class.uicategories.inc.php
+++ b/preferences/inc/class.uicategories.inc.php
@@ -1,20 +1,19 @@
True,
- 'add' => True,
- 'edit' => True,
- 'delete' => True
+ 'index' => True,
+ 'add' => True,
+ 'edit' => True,
+ 'delete' => True
);
function uicategories()
{
-
- $this->bo = CreateObject('preferences.bocategories',$cats_app);
- $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
- $this->account = $GLOBALS['phpgw_info']['user']['account_id'];
- $this->user = $GLOBALS['phpgw_info']['user']['fullname'];
+ $cats_app = get_var('cats_app',array('POST','GET'));
- $this->start = $this->bo->start;
- $this->query = $this->bo->query;
- $this->sort = $this->bo->sort;
- $this->order = $this->bo->order;
+ $this->bo = CreateObject('preferences.bocategories',$cats_app);
+ $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
+ $this->account = $GLOBALS['phpgw_info']['user']['account_id'];
+ $this->user = $GLOBALS['phpgw_info']['user']['fullname'];
+
+ $this->start = $this->bo->start;
+ $this->query = $this->bo->query;
+ $this->sort = $this->bo->sort;
+ $this->order = $this->bo->order;
}
function save_sessiondata($cats_app)
{
$data = array
(
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order
);
$this->bo->save_sessiondata($data,$cats_app);
}
@@ -94,11 +94,11 @@
$link_data = array
(
- 'menuaction' => 'preferences.uicategories.index',
- 'cats_app' => $cats_app,
- 'extra' => $extra,
- 'global_cats' => $global_cats,
- 'cats_level' => $cats_level
+ 'menuaction' => 'preferences.uicategories.index',
+ 'cats_app' => $cats_app,
+ 'extra' => $extra,
+ 'global_cats' => $global_cats,
+ 'cats_level' => $cats_level
);
if ($extra)
@@ -392,12 +392,13 @@
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data));
}
- $new_parent = get_var('new_parent',Array('POST'));
- $cat_parent = get_var('cat_parent',Array('POST'));
- $cat_name = get_var('cat_name',Array('POST'));
- $cat_description = get_var('cat_description',Array('POST'));
- $cat_data = get_var('cat_data',Array('POST'));
- $cat_access = get_var('cat_access',Array('POST'));
+ $new_parent = get_var('new_parent',Array('POST'));
+ $cat_parent = get_var('cat_parent',Array('POST'));
+ $cat_name = get_var('cat_name',Array('POST'));
+ $cat_description = get_var('cat_description',Array('POST'));
+ $cat_data = get_var('cat_data',Array('POST'));
+ $cat_access = get_var('cat_access',Array('POST'));
+ $old_parent = get_var('old_parent',array('POST'));
if ($new_parent)
{
@@ -410,12 +411,13 @@
$values = array
(
- 'id' => $cat_id,
- 'parent' => $cat_parent,
- 'descr' => $cat_description,
- 'name' => $cat_name,
- 'access' => $cat_access,
- 'data' => $data
+ 'id' => $cat_id,
+ 'parent' => $cat_parent,
+ 'old_parent' => $old_parent,
+ 'descr' => $cat_description,
+ 'name' => $cat_name,
+ 'access' => $cat_access,
+ 'data' => $data
);
$error = $this->bo->check_values($values);
@@ -425,7 +427,7 @@
}
else
{
- $this->bo->save_cat($values);
+ $cat_id = $this->bo->save_cat($values);
$message = lang('Category x has been updated !',$cat_name);
}
}
@@ -442,6 +444,8 @@
$cats = $this->bo->cats->return_single($cat_id);
+ $GLOBALS['phpgw']->template->set_var('hidden_vars','');
+
$GLOBALS['phpgw']->template->set_var('title_categories',lang('Edit x category for',lang($cats_app)));
$GLOBALS['phpgw']->template->set_var('message',$message);
$GLOBALS['phpgw']->template->set_var('lang_app',lang($cats_app));
diff --git a/preferences/setup/phpgw_en.lang b/preferences/setup/phpgw_en.lang
index 950c361349..e6a4f0548a 100644
--- a/preferences/setup/phpgw_en.lang
+++ b/preferences/setup/phpgw_en.lang
@@ -28,6 +28,3 @@ time format preferences en Time format
your current theme is: x preferences en
you must enter a password preferences en You must enter a password
your preferences preferences en Your Preferences
-
-
-
diff --git a/preferences/templates/default/category_form.tpl b/preferences/templates/default/category_form.tpl
index 2d7b597da8..ab3d453172 100644
--- a/preferences/templates/default/category_form.tpl
+++ b/preferences/templates/default/category_form.tpl
@@ -59,6 +59,7 @@