update cats

This commit is contained in:
ceb 2002-09-04 00:30:50 +00:00
parent 09361d01f8
commit 7d38b22ddb
3 changed files with 82 additions and 68 deletions

View File

@ -125,9 +125,9 @@
function exists($data) function exists($data)
{ {
$data['type'] = $data['type'] ? $data['type'] : ''; //$data['type'] = $data['type'] ? $data['type'] : '';
$data['cat_id'] = $data['cat_id'] ? $data['cat_id'] : ''; //$data['cat_id'] = $data['cat_id'] ? $data['cat_id'] : '';
return $this->cats->exists($data['type'],$data['cat_name'],$data['cat_id']); return $this->cats->exists($data);
} }
function formatted_list($data) function formatted_list($data)

View File

@ -427,39 +427,39 @@
if ($GLOBALS['HTTP_POST_VARS']['confirm']) if ($GLOBALS['HTTP_POST_VARS']['confirm'])
{ {
if ($GLOBALS['HTTP_POST_VARS']['modify_subs']) switch ($GLOBALS['HTTP_POST_VARS']['subs'])
{ {
case 'move':
$this->bo->delete($this->cat_id,False,True); $this->bo->delete($this->cat_id,False,True);
}
elseif ($GLOBALS['HTTP_POST_VARS']['drop_subs'])
{
$this->bo->delete($this->cat_id,True);
}
else
{
$this->bo->delete($this->cat_id);
}
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data)); Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data));
break;
case 'drop':
$this->bo->delete($this->cat_id,True);
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data));
break;
default:
$error_msg = lang('Please choose one of the methods to handle the subcategories');
//$this->bo->delete($this->cat_id);
break;
} }
else }
{
$GLOBALS['phpgw']->template->set_file(array('category_delete' => 'delete_cat.tpl')); $GLOBALS['phpgw']->template->set_file(array('category_delete' => 'delete_cat.tpl'));
$GLOBALS['phpgw']->template->set_var('error_msg',$error_msg);
$nolink = $GLOBALS['phpgw']->link('/index.php',$link_data); $nolink = $GLOBALS['phpgw']->link('/index.php',$link_data);
$apps_cats = $this->bo->exists(array $apps_cats = $this->bo->exists(array
( (
'type' => 'subs', 'type' => 'noapp',
'cat_name' => '', 'cat_name' => '',
'cat_id' => $this->cat_id 'cat_id' => $this->cat_id
)); ));
$GLOBALS['phpgw']->common->phpgw_header(); $GLOBALS['phpgw']->common->phpgw_header();
$GLOBALS['phpgw']->template->set_var('hidden_vars','<input type="hidden" name="cat_id" value="' . $this->cat_id . '">');
$hidden_vars = '<input type="hidden" name="cat_id" value="' . $this->cat_id . '">' . "\n"; if ($apps_cats)
$GLOBALS['phpgw']->template->set_var('hidden_vars',$hidden_vars);
/*if ($apps_cats)
{ {
$GLOBALS['phpgw']->template->set_var('messages',lang('This category is currently being used by applications as a parent category') . '<br>' $GLOBALS['phpgw']->template->set_var('messages',lang('This category is currently being used by applications as a parent category') . '<br>'
. lang('You will need to remove the subcategories before you can delete this category')); . lang('You will need to remove the subcategories before you can delete this category'));
@ -473,7 +473,7 @@
$GLOBALS['phpgw']->template->pfp('donehandle','done'); $GLOBALS['phpgw']->template->pfp('donehandle','done');
} }
else else
{*/ {
$GLOBALS['phpgw']->template->set_var('messages',lang('Are you sure you want to delete this category ?')); $GLOBALS['phpgw']->template->set_var('messages',lang('Are you sure you want to delete this category ?'));
$exists = $this->bo->exists(array $exists = $this->bo->exists(array
@ -485,11 +485,15 @@
if ($exists) if ($exists)
{ {
$GLOBALS['phpgw']->template->set_var('lang_drop_subs',lang('Do you also want to delete all global subcategories ?')); $sub_select = '<input type="radio" name="subs" value="move">' . lang('Do you want to move all global subcategories one level down ?') . '<br>';
$sub_select .= '<input type="radio" name="subs" value="drop">' . lang('Do you want to delete all global subcategories ?');
$GLOBALS['phpgw']->template->set_var('sub_select',$sub_select);
/* $GLOBALS['phpgw']->template->set_var('lang_drop_subs',lang('Do you also want to delete all global subcategories ?'));
$GLOBALS['phpgw']->template->set_var('drop_subs','<input type="checkbox" name="drop_subs" value="True">'); $GLOBALS['phpgw']->template->set_var('drop_subs','<input type="checkbox" name="drop_subs" value="True">');
$GLOBALS['phpgw']->template->set_var('lang_modify_subs',lang('Do you want to move all global subcategories one level down ?')); $GLOBALS['phpgw']->template->set_var('lang_modify_subs',lang('Do you want to move all global subcategories one level down ?'));
$GLOBALS['phpgw']->template->set_var('subs','<input type="checkbox" name="modify_subs" value="True">'); $GLOBALS['phpgw']->template->set_var('subs','<input type="checkbox" name="modify_subs" value="True">'); */
} }
$GLOBALS['phpgw']->template->set_var('nolink',$nolink); $GLOBALS['phpgw']->template->set_var('nolink',$nolink);
@ -501,7 +505,6 @@
$GLOBALS['phpgw']->template->set_var('lang_yes',lang('Yes')); $GLOBALS['phpgw']->template->set_var('lang_yes',lang('Yes'));
$GLOBALS['phpgw']->template->fp('phpgw_body','category_delete'); $GLOBALS['phpgw']->template->fp('phpgw_body','category_delete');
//}
} }
} }
} }

View File

@ -4,8 +4,8 @@
* This file written by Joseph Engo <jengo@phpgroupware.org> * * This file written by Joseph Engo <jengo@phpgroupware.org> *
* and Bettina Gille [ceb@phpgroupware.org] * * and Bettina Gille [ceb@phpgroupware.org] *
* Category manager * * Category manager *
* Copyright (C) 2000,2001,2002 Joseph Engo * * Copyright (C) 2000 - 2002 Joseph Engo *
* -------------------------------------------------------------------------* * ------------------------------------------------------------------------ *
* This library is part of the phpGroupWare API * * This library is part of the phpGroupWare API *
* http://www.phpgroupware.org/api * * http://www.phpgroupware.org/api *
* ------------------------------------------------------------------------ * * ------------------------------------------------------------------------ *
@ -74,6 +74,7 @@
case 'mains': $s = " AND cat_parent = '0'"; break; case 'mains': $s = " AND cat_parent = '0'"; break;
case 'appandmains': $s = " AND cat_appname='" . $this->app_name . "' AND cat_parent ='0'"; break; case 'appandmains': $s = " AND cat_appname='" . $this->app_name . "' AND cat_parent ='0'"; break;
case 'appandsubs': $s = " AND cat_appname='" . $this->app_name . "' AND cat_parent !='0'"; break; case 'appandsubs': $s = " AND cat_appname='" . $this->app_name . "' AND cat_parent !='0'"; break;
case 'noapp': $s = " AND cat_appname != '" . $this->app_name . "'"; break;
default: return False; default: return False;
} }
return $s; return $s;
@ -536,8 +537,8 @@
{ {
if ($cats[$i]['level'] == 1) if ($cats[$i]['level'] == 1)
{ {
$this->db->query('UPDATE phpgw_categories set cat_level=0, cat_parent=0, cat_main=' . $cats[$i]['id'] $this->db->query("UPDATE phpgw_categories set cat_level=0, cat_parent=0, cat_main='" . intval($cats[$i]['id'])
. ' WHERE cat_id=' . $cats[$i]['id'],__LINE__,__FILE__); . " WHERE cat_id='" . intval($cats[$i]['id']) . "' AND cat_appname='" . $this->app_name . "'",__LINE__,__FILE__);
$new_main = $cats[$i]['id']; $new_main = $cats[$i]['id'];
} }
else else
@ -552,8 +553,8 @@
$update_parent = ',cat_parent=' . $new_parent; $update_parent = ',cat_parent=' . $new_parent;
} }
$this->db->query('UPDATE phpgw_categories set cat_level=' . ($cats[$i]['level']-1) . $update_main . $update_parent $this->db->query("UPDATE phpgw_categories set cat_level='" . ($cats[$i]['level']-1) . "'" . $update_main . $update_parent
. ' WHERE cat_id=' . $cats[$i]['id'],__LINE__,__FILE__); . " WHERE cat_id='" . intval($cats[$i]['id']) . "' AND cat_appname='" . $this->app_name . "'",__LINE__,__FILE__);
} }
} }
} }
@ -662,6 +663,16 @@
*/ */
function exists($type,$cat_name = '',$cat_id = '') function exists($type,$cat_name = '',$cat_id = '')
{ {
if(is_array($type))
{
$temp_type = $type['type'];
$cat_name = $type['cat_name'] ? $type['cat_name'] : '';
$cat_id = $type['cat_id'] ? $type['cat_id'] : '';
settype($type,'string');
$type = $temp_type;
unset($temp_type);
}
$filter = $this->filter($type); $filter = $this->filter($type);
if ($cat_name) if ($cat_name)