update edit_cats to move the subtree with the cat if the parent changes

This commit is contained in:
ceb 2002-10-12 18:27:22 +00:00
parent 22ff2988c7
commit 05653960d4
3 changed files with 86 additions and 104 deletions

View File

@ -31,11 +31,17 @@
$query = get_var('query',Array('GET','POST'));
$sort = get_var('sort',Array('GET','POST'));
$order = get_var('order',Array('GET','POST'));
$cat_id = intval(get_var('cat_id', array('POST','GET')));
if(!empty($start) || $start == '0' || $start == 0)
{
$this->start = $start;
}
else
{
$this->start = 0;
}
if((empty($query) && !empty($this->query)) || !empty($query))
{
$this->query = $query;
@ -49,6 +55,15 @@
{
$this->order = $order;
}
if(isset($cat_id))
{
$this->cat_id = $cat_id;
}
if($cat_id == 0)
{
unset($this->cat_id);
}
}
function save_sessiondata($data, $cats_app)
@ -66,6 +81,7 @@
$this->query = $data['query'];
$this->sort = $data['sort'];
$this->order = $data['order'];
$this->cat_id = $data['cat_id'];
}
function get_list($global_cats)
@ -84,7 +100,7 @@
$values['access'] = 'public';
}
if ($values['id'] && $values['id'] != 0)
if ($values['cat_id'] && $values['cat_id'] != 0)
{
return $this->cats->edit($values);
}
@ -131,7 +147,7 @@
(
'type' => 'appandmains',
'cat_name' => $values['name'],
'cat_id' => $values['id']
'cat_id' => $values['cat_id']
));
}
else
@ -140,7 +156,7 @@
(
'type' => 'appandsubs',
'cat_name' => $values['name'],
'cat_id' => $values['id']
'cat_id' => $values['cat_id']
));
}

View File

@ -42,6 +42,7 @@
$this->query = $this->bo->query;
$this->sort = $this->bo->sort;
$this->order = $this->bo->order;
$this->cat_id = $this->bo->cat_id;
}
function save_sessiondata($cats_app)
@ -51,7 +52,8 @@
'start' => $this->start,
'query' => $this->query,
'sort' => $this->sort,
'order' => $this->order
'order' => $this->order,
'cat_id' => $this->cat_id
);
$this->bo->save_sessiondata($data,$cats_app);
}
@ -90,7 +92,6 @@
$extra = get_var('extra',array('POST','GET'));
$global_cats = get_var('global_cats',array('POST','GET'));
$cats_level = get_var('cats_level',array('POST','GET'));
$cat_id = get_var('cat_id',array('POST','GET'));
$link_data = array
(
@ -119,11 +120,6 @@
$GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('doneurl',$GLOBALS['phpgw']->link('/preferences/index.php'));
if(!$this->start)
{
$this->start = 0;
}
if (!$global_cats)
{
$global_cats = False;
@ -186,7 +182,7 @@
$name = $spaceset . $GLOBALS['phpgw']->strip_html($cats[$i]['name']) . $appendix;
}
$descr = $GLOBALS['phpgw']->strip_html($cats[$i]['description']);
$descr = $GLOBALS['phpgw']->strip_html($cats[$i]['descr']);
if (!$descr) { $descr = ' '; }
if (is_array($edata))
@ -215,14 +211,13 @@
'descr' => $descr
));
$GLOBALS['phpgw']->template->set_var('app_url',$GLOBALS['phpgw']->link('/' . $cats_app . '/index.php','cat_id=' . $cats[$i]['id']));
$GLOBALS['phpgw']->template->set_var('app_url',$GLOBALS['phpgw']->link('/' . $cats_app . '/index.php','cat_id=' . $cats[$i]['cat_id']));
if ($cats_level || ($level == 0))
{
if ($cats[$i]['owner'] == $this->account || $cats[$i]['app_name'] == 'phpgw')
{
$link_data['menuaction'] = 'preferences.uicategories.add';
$link_data['cat_parent'] = $cats[$i]['id'];
$GLOBALS['phpgw']->template->set_var('add_sub',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('lang_sub_entry',lang('Add sub'));
}
@ -233,7 +228,7 @@
$GLOBALS['phpgw']->template->set_var('lang_sub_entry',' ');
}
$link_data['cat_id'] = $cats[$i]['id'];
$link_data['cat_id'] = $cats[$i]['cat_id'];
if ($cats[$i]['owner'] == $this->account && $cats[$i]['app_name'] != 'phpgw')
{
$link_data['menuaction'] = 'preferences.uicategories.edit';
@ -267,7 +262,6 @@
$extra = get_var('extra',array('POST','GET'));
$global_cats = get_var('global_cats',array('POST','GET'));
$cats_level = get_var('cats_level',array('POST','GET'));
$cat_id = get_var('cat_id',array('POST','GET'));
$link_data = array
(
@ -278,30 +272,19 @@
'cats_level' => $cats_level
);
$new_parent = get_var('new_parent',Array('POST'));
$cat_parent = get_var('cat_parent',Array('GET','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'));
if ($new_parent)
{
$cat_parent = $new_parent;
}
$values = get_var('values',array('POST'));
$cat_data = get_var('cat_data',array('POST'));
if (get_var('submit',Array('POST')))
{
if (is_array($cat_data))
{
$data = serialize($cat_data);
}
$values = array
(
'parent' => $cat_parent,
'descr' => $cat_description,
'name' => $cat_name,
'access' => $cat_access,
'data' => $data
);
if (is_array($values))
{
$values['data'] = $data;
$error = $this->bo->check_values($values);
if (is_array($error))
@ -310,8 +293,9 @@
}
else
{
$this->bo->save_cat($values);
$message = lang('Category x has been added !', $cat_name);
$this->cat_id = $this->bo->save_cat($values);
$message = lang('Category x has been added !', $values['name']);
}
}
}
@ -375,7 +359,6 @@
$extra = get_var('extra',array('POST','GET'));
$global_cats = get_var('global_cats',array('POST','GET'));
$cats_level = get_var('cats_level',array('POST','GET'));
$cat_id = get_var('cat_id',array('POST','GET'));
$link_data = array
(
@ -383,42 +366,28 @@
'cats_app' => $cats_app,
'extra' => $extra,
'global_cats' => $global_cats,
'cats_level' => $cats_level,
'cat_id' => $cat_id
'cats_level' => $cats_level
);
if (!$cat_id)
if (!$this->cat_id)
{
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'));
$values = get_var('values',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)
{
$cat_parent = $new_parent;
}
if (get_var('submit',Array('POST')))
{
if (is_array($cat_data))
{
$data = serialize($cat_data);
}
$values = array
(
'id' => $cat_id,
'parent' => $cat_parent,
'old_parent' => $old_parent,
'descr' => $cat_description,
'name' => $cat_name,
'access' => $cat_access,
'data' => $data
);
if (is_array($values))
{
$values['cat_id'] = $this->cat_id;
$values['data'] = $data;
$error = $this->bo->check_values($values);
if (is_array($error))
@ -427,8 +396,9 @@
}
else
{
$cat_id = $this->bo->save_cat($values);
$message = lang('Category x has been updated !',$cat_name);
$this->cat_id = $this->bo->save_cat($values);
$message = lang('Category x has been updated !',$values['name']);
}
}
}
@ -442,9 +412,7 @@
$this->set_langs();
$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'] . '">');
$cats = $this->bo->cats->return_single($this->cat_id);
$GLOBALS['phpgw']->template->set_var('title_categories',lang('Edit x category for',lang($cats_app)));
$GLOBALS['phpgw']->template->set_var('message',$message);
@ -454,8 +422,9 @@
$link_data['menuaction'] = 'preferences.uicategories.edit';
$GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
$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('old_parent',$cats['parent']);
$GLOBALS['phpgw']->template->set_var('cat_name',$GLOBALS['phpgw']->strip_html($cats['name']));
$GLOBALS['phpgw']->template->set_var('cat_description',$GLOBALS['phpgw']->strip_html($cats['descr']));
if (!$global_cats)
{
@ -471,16 +440,15 @@
$type = 'mains';
}
$GLOBALS['phpgw']->template->set_var('category_list',$this->bo->cats->formated_list('select',$type,$cats[0]['parent'],$global_cats));
$GLOBALS['phpgw']->template->set_var('category_list',$this->bo->cats->formated_list('select',$type,$cats['parent'],$global_cats));
$GLOBALS['phpgw']->template->set_var('access','<input type="checkbox" name="cat_access" value="True"'
. ($cats[0]['access'] == private ?' checked':'') . '>');
$GLOBALS['phpgw']->template->set_var('access',$cats['access'] == 'private' ?' checked':'');
if ($extra)
{
$edata = explode(',',$extra);
$data = unserialize($cats[0]['data']);
$data = unserialize($cats['data']);
for($i=0;$i<count($edata);$i++)
{
$GLOBALS['phpgw']->template->set_var('td_data','<input name="cat_data[' . $edata[$i] . ']" size="50" value="' . $data[$edata[$i]] . '">');
@ -510,7 +478,6 @@
$extra = get_var('extra',array('POST','GET'));
$global_cats = get_var('global_cats',array('POST','GET'));
$cats_level = get_var('cats_level',array('POST','GET'));
$cat_id = get_var('cat_id',array('POST','GET'));
$link_data = array
(
@ -518,11 +485,10 @@
'cats_app' => $cats_app,
'extra' => $extra,
'global_cats' => $global_cats,
'cats_level' => $cats_level,
'cat_id' => $cat_id
'cats_level' => $cats_level
);
if (!$cat_id)
if (!$this->cat_id)
{
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data));
}
@ -565,7 +531,7 @@
(
'type' => 'subs',
'cat_name' => '',
'cat_id' => $cat_id
'cat_id' => $this->cat_id
));
if ($exists)

View File

@ -13,22 +13,22 @@
<form name="form" action="{actionurl}" method="POST">
<tr>
<td>{lang_parent}</td>
<td><select name="new_parent"><option value="">{lang_none}</option>{category_list}</select></td>
<td><select name="values[parent]"><option value="">{lang_none}</option>{category_list}</select></td>
</tr>
<tr>
<td>{lang_name}</td>
<td><input name="cat_name" size="50" value="{cat_name}"></td>
<td><input name="values[name]" size="50" value="{cat_name}"></td>
</tr>
<tr>
<td>{lang_descr}</td>
<td><textarea name="cat_description" rows="4" cols="50" wrap="virtual">{cat_description}</textarea></td>
<td><textarea name="values[descr]" rows="4" cols="50" wrap="virtual">{cat_description}</textarea></td>
</tr>
{rows}
<tr>
<td>{lang_access}</td>
<td>{access}</td>
<td><input type="checkbox" name="values[access]" value="True" {access}></td>
</tr>
</table>
@ -59,7 +59,7 @@
<table width="80%" border="0" cellspacing="2" cellpadding="2">
<tr valign="bottom">
<td height="50">
{hidden_vars}
<input type="hidden" name="values[old_parent]" value="{old_parent}">
<input type="submit" name="submit" value="{lang_save}"></form></td>
<td height="50" align="center">
{delete}</td>