fix for bug 1286

This commit is contained in:
ceb 2002-10-04 20:59:00 +00:00
parent d9815720e3
commit 0ae563ca08
7 changed files with 106 additions and 99 deletions

View File

@ -34,25 +34,25 @@
function uicategories() function uicategories()
{ {
$this->bo = CreateObject('admin.bocategories'); $this->bo = CreateObject('admin.bocategories');
$this->nextmatchs = CreateObject('phpgwapi.nextmatchs'); $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
$this->start = $this->bo->start; $this->start = $this->bo->start;
$this->query = $this->bo->query; $this->query = $this->bo->query;
$this->sort = $this->bo->sort; $this->sort = $this->bo->sort;
$this->order = $this->bo->order; $this->order = $this->bo->order;
$this->cat_id = $this->bo->cat_id; $this->cat_id = $this->bo->cat_id;
if($this->debug) { $this->_debug_sqsof(); } if($this->debug) { $this->_debug_sqsof(); }
} }
function _debug_sqsof() function _debug_sqsof()
{ {
$data = array( $data = array(
'start' => $this->start, 'start' => $this->start,
'query' => $this->query, 'query' => $this->query,
'sort' => $this->sort, 'sort' => $this->sort,
'order' => $this->order, 'order' => $this->order,
'cat_id' => $this->cat_id 'cat_id' => $this->cat_id
); );
echo '<br>UI:<br>'; echo '<br>UI:<br>';
_debug_array($data); _debug_array($data);
@ -62,10 +62,10 @@
{ {
$data = array $data = array
( (
'start' => $this->start, 'start' => $this->start,
'query' => $this->query, 'query' => $this->query,
'sort' => $this->sort, 'sort' => $this->sort,
'order' => $this->order 'order' => $this->order
); );
if(isset($this->cat_id)) if(isset($this->cat_id))
@ -335,20 +335,18 @@
$this->set_langs(); $this->set_langs();
$new_parent = $GLOBALS['HTTP_POST_VARS']['new_parent']; $new_parent = $GLOBALS['HTTP_POST_VARS']['new_parent'];
$submit = $GLOBALS['HTTP_POST_VARS']['submit']; $submit = $GLOBALS['HTTP_POST_VARS']['submit'];
$cat_parent = $GLOBALS['HTTP_POST_VARS']['cat_parent']; $cat_parent = $GLOBALS['HTTP_POST_VARS']['cat_parent'];
$cat_name = $GLOBALS['HTTP_POST_VARS']['cat_name']; $cat_name = $GLOBALS['HTTP_POST_VARS']['cat_name'];
$cat_description = $GLOBALS['HTTP_POST_VARS']['cat_description']; $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_file(array('cat_form' => 'category_form.tpl'));
$GLOBALS['phpgw']->template->set_block('cat_form','add'); $GLOBALS['phpgw']->template->set_block('cat_form','add');
$GLOBALS['phpgw']->template->set_block('cat_form','edit'); $GLOBALS['phpgw']->template->set_block('cat_form','edit');
$GLOBALS['phpgw']->template->set_block('cat_form','form'); $GLOBALS['phpgw']->template->set_block('cat_form','form');
$hidden_vars = '<input type="hidden" name="cat_id" value="' . $this->cat_id . '">' . "\n";
$GLOBALS['phpgw']->template->set_var('hidden_vars',$hidden_vars);
$GLOBALS['phpgw']->template->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php',$link_data)); $GLOBALS['phpgw']->template->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
if ($new_parent) if ($new_parent)
@ -360,11 +358,12 @@
{ {
$values = array $values = array
( (
'id' => $this->cat_id, 'id' => $this->cat_id,
'parent' => $cat_parent, 'old_parent' => $old_parent,
'descr' => $cat_description, 'parent' => $cat_parent,
'name' => $cat_name, 'descr' => $cat_description,
'access' => 'public' 'name' => $cat_name,
'access' => 'public'
); );
$error = $this->bo->check_values($values); $error = $this->bo->check_values($values);
@ -374,7 +373,7 @@
} }
else 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)); $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')); $GLOBALS['phpgw']->template->set_var('title_categories',lang('Edit global category'));
} }
$hidden_vars = '<input type="hidden" name="cat_id" value="' . $this->cat_id . '">' . "\n"
. '<input type="hidden" name="old_parent" value="' . $cats[0]['parent'] . '">' . "\n";
$GLOBALS['phpgw']->template->set_var('hidden_vars',$hidden_vars);
$link_data['menuaction'] = 'admin.uicategories.edit'; $link_data['menuaction'] = 'admin.uicategories.edit';
$link_data['cat_id'] = $this->cat_id; $link_data['cat_id'] = $this->cat_id;
$GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data)); $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_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('cat_description',$GLOBALS['phpgw']->strip_html($cats[0]['description']));
$GLOBALS['phpgw']->template->set_var('category_list',$this->bo->formatted_list(array( $GLOBALS['phpgw']->template->set_var('category_list',$this->bo->formatted_list(array('select' => 'select',
'select' => 'select', 'all' => 'all',
'all' => 'all', 'cat_parent' => $cats[0]['parent'],
'cat_parent' => $cats[0]['parent'], 'global_cats' => $global_cats)));
'global_cats' => $global_cats
)));
$GLOBALS['phpgw']->template->parse('buttons','edit'); $GLOBALS['phpgw']->template->parse('buttons','edit');
$GLOBALS['phpgw']->template->fp('phpgw_body','form'); $GLOBALS['phpgw']->template->fp('phpgw_body','form');
} }

View File

@ -19,11 +19,9 @@
} }
} }
</SCRIPT> </SCRIPT>
<div style="width: 100%; height: 100%; overflow: auto;">
<table width="75%" border="0" cellspacing="0" cellpadding="0"> <table width="75%" border="0" cellspacing="0" cellpadding="0">
{rows} {rows}
</table> </table>
</div>
<!-- END list --> <!-- END list -->
<!-- BEGIN app_row --> <!-- BEGIN app_row -->

View File

@ -649,26 +649,35 @@
*/ */
function edit($cat_values) 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'); $this->delete(array('cat_id' => $cat_values['id'],'drop_subs' => False,'modify_subs' => True));
$cat_values['level'] = $this->id2name($cat_values['parent'],'level')+1; return $this->add($cat_values);
} }
else else
{ {
$cat_values['main'] = $cat_values['id']; if ($cat_values['parent'] && ($cat_values['parent'] != 0))
$cat_values['level'] = 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['descr'] = $this->db->db_addslashes($cat_values['descr']);
$cat_values['name'] = $this->db->db_addslashes($cat_values['name']); $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'] $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_data='" . $cat_values['data'] . "', cat_parent=" . $cat_values['parent'] . ", cat_access='"
. $cat_values['access'] . "', cat_main='" . $cat_values['main'] . "', cat_level='" . $cat_values['level'] . "' " . $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'] . "'"; . " WHERE cat_appname='" . $this->app_name . "' AND cat_id=" . intval($cat_values['id']);
$this->db->query($sql,__LINE__,__FILE__); $this->db->query($sql,__LINE__,__FILE__);
return intval($cat_values['id']);
} }
function name2id($cat_name) function name2id($cat_name)

View File

@ -1,20 +1,19 @@
<?php <?php
/**************************************************************************\ /**************************************************************************\
* phpGroupWare - Preferences - categories * * phpGroupWare - Preferences - categories *
* http://www.phpgroupware.org * * http://www.phpgroupware.org *
* Written by Bettina Gille [ceb@phpgroupware.org] * * Written by Bettina Gille [ceb@phpgroupware.org] *
* ----------------------------------------------- * * ----------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it * * This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the * * under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your * * Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. * * option) any later version. *
\**************************************************************************/ \**************************************************************************/
/* $Id$ */ /* $Id$ */
class uicategories class uicategories
{ {
var $bo; var $bo;
var $t;
var $start; var $start;
var $query; var $query;
@ -24,34 +23,35 @@
var $public_functions = array var $public_functions = array
( (
'index' => True, 'index' => True,
'add' => True, 'add' => True,
'edit' => True, 'edit' => True,
'delete' => True 'delete' => True
); );
function uicategories() function uicategories()
{ {
$cats_app = get_var('cats_app',array('POST','GET'));
$this->bo = CreateObject('preferences.bocategories',$cats_app); $this->bo = CreateObject('preferences.bocategories',$cats_app);
$this->nextmatchs = CreateObject('phpgwapi.nextmatchs'); $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
$this->account = $GLOBALS['phpgw_info']['user']['account_id']; $this->account = $GLOBALS['phpgw_info']['user']['account_id'];
$this->user = $GLOBALS['phpgw_info']['user']['fullname']; $this->user = $GLOBALS['phpgw_info']['user']['fullname'];
$this->start = $this->bo->start; $this->start = $this->bo->start;
$this->query = $this->bo->query; $this->query = $this->bo->query;
$this->sort = $this->bo->sort; $this->sort = $this->bo->sort;
$this->order = $this->bo->order; $this->order = $this->bo->order;
} }
function save_sessiondata($cats_app) function save_sessiondata($cats_app)
{ {
$data = array $data = array
( (
'start' => $this->start, 'start' => $this->start,
'query' => $this->query, 'query' => $this->query,
'sort' => $this->sort, 'sort' => $this->sort,
'order' => $this->order 'order' => $this->order
); );
$this->bo->save_sessiondata($data,$cats_app); $this->bo->save_sessiondata($data,$cats_app);
} }
@ -94,11 +94,11 @@
$link_data = array $link_data = array
( (
'menuaction' => 'preferences.uicategories.index', 'menuaction' => 'preferences.uicategories.index',
'cats_app' => $cats_app, 'cats_app' => $cats_app,
'extra' => $extra, 'extra' => $extra,
'global_cats' => $global_cats, 'global_cats' => $global_cats,
'cats_level' => $cats_level 'cats_level' => $cats_level
); );
if ($extra) if ($extra)
@ -392,12 +392,13 @@
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data)); Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data));
} }
$new_parent = get_var('new_parent',Array('POST')); $new_parent = get_var('new_parent',Array('POST'));
$cat_parent = get_var('cat_parent',Array('POST')); $cat_parent = get_var('cat_parent',Array('POST'));
$cat_name = get_var('cat_name',Array('POST')); $cat_name = get_var('cat_name',Array('POST'));
$cat_description = get_var('cat_description',Array('POST')); $cat_description = get_var('cat_description',Array('POST'));
$cat_data = get_var('cat_data',Array('POST')); $cat_data = get_var('cat_data',Array('POST'));
$cat_access = get_var('cat_access',Array('POST')); $cat_access = get_var('cat_access',Array('POST'));
$old_parent = get_var('old_parent',array('POST'));
if ($new_parent) if ($new_parent)
{ {
@ -410,12 +411,13 @@
$values = array $values = array
( (
'id' => $cat_id, 'id' => $cat_id,
'parent' => $cat_parent, 'parent' => $cat_parent,
'descr' => $cat_description, 'old_parent' => $old_parent,
'name' => $cat_name, 'descr' => $cat_description,
'access' => $cat_access, 'name' => $cat_name,
'data' => $data 'access' => $cat_access,
'data' => $data
); );
$error = $this->bo->check_values($values); $error = $this->bo->check_values($values);
@ -425,7 +427,7 @@
} }
else else
{ {
$this->bo->save_cat($values); $cat_id = $this->bo->save_cat($values);
$message = lang('Category x has been updated !',$cat_name); $message = lang('Category x has been updated !',$cat_name);
} }
} }
@ -442,6 +444,8 @@
$cats = $this->bo->cats->return_single($cat_id); $cats = $this->bo->cats->return_single($cat_id);
$GLOBALS['phpgw']->template->set_var('hidden_vars','<input type="hidden" name="old_parent" value="' . $cats[0]['parent'] . '">');
$GLOBALS['phpgw']->template->set_var('title_categories',lang('Edit x category for',lang($cats_app))); $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('message',$message);
$GLOBALS['phpgw']->template->set_var('lang_app',lang($cats_app)); $GLOBALS['phpgw']->template->set_var('lang_app',lang($cats_app));

View File

@ -28,6 +28,3 @@ time format preferences en Time format
your current theme is: x preferences en </b> your current theme is: x preferences en </b>
you must enter a password preferences en You must enter a password you must enter a password preferences en You must enter a password
your preferences preferences en Your Preferences your preferences preferences en Your Preferences

View File

@ -59,6 +59,7 @@
<table width="80%" border="0" cellspacing="2" cellpadding="2"> <table width="80%" border="0" cellspacing="2" cellpadding="2">
<tr valign="bottom"> <tr valign="bottom">
<td height="50"> <td height="50">
{hidden_vars}
<input type="submit" name="submit" value="{lang_save}"></form></td> <input type="submit" name="submit" value="{lang_save}"></form></td>
<td height="50" align="center"> <td height="50" align="center">
{delete}</td> {delete}</td>

View File

@ -1,5 +1,4 @@
<!-- BEGIN list --> <!-- BEGIN list -->
<div style="width: 100%; height: 100%; overflow: auto;">
<table border="0" width="100%" cellspacing="0" cellpadding="0"> <table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr> <tr>
<td align="left">{tabs}</td> <td align="left">{tabs}</td>
@ -9,7 +8,6 @@
<table width="75%" border="0" cellspacing="0" cellpadding="0"> <table width="75%" border="0" cellspacing="0" cellpadding="0">
{rows} {rows}
</table> </table>
</div>
<!-- END list --> <!-- END list -->
<!-- BEGIN app_row --> <!-- BEGIN app_row -->