forked from extern/egroupware
ntier for the cats
This commit is contained in:
parent
334e5f0b96
commit
3a5769473b
@ -62,11 +62,11 @@
|
||||
|
||||
if ($global_cats)
|
||||
{
|
||||
$categories = $c->return_array('all',$start,True,$query,$sort,$order,True);
|
||||
$categories = $c->return_sorted_array($start,True,$query,$sort,$order,True);
|
||||
}
|
||||
else
|
||||
{
|
||||
$categories = $c->return_array('all',$start,True,$query,$sort,$order);
|
||||
$categories = $c->return_sorted_array($start,True,$query,$sort,$order);
|
||||
}
|
||||
|
||||
//--------------------------------- nextmatch --------------------------------------------
|
||||
|
167
preferences/inc/class.bocategories.inc.php
Normal file
167
preferences/inc/class.bocategories.inc.php
Normal file
@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - Preferences - categories *
|
||||
* http://www.phpgroupware.org *
|
||||
* Written by Bettina Gille [ceb@phpgroupware.org] *
|
||||
* ----------------------------------------------- *
|
||||
* 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 *
|
||||
* Free Software Foundation; either version 2 of the License, or (at your *
|
||||
* option) any later version. *
|
||||
\**************************************************************************/
|
||||
/* $Id$ */
|
||||
|
||||
class bocategories
|
||||
{
|
||||
var $cats;
|
||||
|
||||
var $start;
|
||||
var $query;
|
||||
var $sort;
|
||||
var $order;
|
||||
|
||||
function bocategories($cats_app)
|
||||
{
|
||||
$this->cats = CreateObject('phpgwapi.categories');
|
||||
$this->cats->app_name = $cats_app;
|
||||
|
||||
$this->read_sessiondata($cats_app);
|
||||
|
||||
$start = $GLOBALS['HTTP_POST_VARS']['start'] ? $GLOBALS['HTTP_POST_VARS']['start'] : $GLOBALS['HTTP_GET_VARS']['start'];
|
||||
$query = $GLOBALS['HTTP_POST_VARS']['query'] ? $GLOBALS['HTTP_POST_VARS']['query'] : $GLOBALS['HTTP_GET_VARS']['query'];
|
||||
$sort = $GLOBALS['HTTP_POST_VARS']['sort'] ? $GLOBALS['HTTP_POST_VARS']['sort'] : $GLOBALS['HTTP_GET_VARS']['sort'];
|
||||
$order = $GLOBALS['HTTP_POST_VARS']['order'] ? $GLOBALS['HTTP_POST_VARS']['order'] : $GLOBALS['HTTP_GET_VARS']['order'];
|
||||
|
||||
if(!empty($start) || $start == '0' || $start == 0)
|
||||
{
|
||||
$this->start = $start;
|
||||
}
|
||||
if((empty($query) && !empty($this->query)) || !empty($query))
|
||||
{
|
||||
$this->query = $query;
|
||||
}
|
||||
|
||||
if(isset($sort) && !empty($sort))
|
||||
{
|
||||
$this->sort = $sort;
|
||||
}
|
||||
if(isset($order) && !empty($order))
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
}
|
||||
|
||||
function save_sessiondata($data, $cats_app)
|
||||
{
|
||||
$colum = $cats_app . '_cats';
|
||||
$GLOBALS['phpgw']->session->appsession('session_data',$column,$data);
|
||||
}
|
||||
|
||||
function read_sessiondata($cats_app)
|
||||
{
|
||||
$colum = $cats_app . '_cats';
|
||||
$data = $GLOBALS['phpgw']->session->appsession('session_data',$column);
|
||||
|
||||
$this->start = $data['start'];
|
||||
$this->query = $data['query'];
|
||||
$this->sort = $data['sort'];
|
||||
$this->order = $data['order'];
|
||||
}
|
||||
|
||||
function get_list()
|
||||
{
|
||||
return $this->cats->return_sorted_array($this->start,True,$this->query,$this->sort,$this->order,True);
|
||||
}
|
||||
|
||||
function save_cat($values)
|
||||
{
|
||||
if ($values['access'])
|
||||
{
|
||||
$values['access'] = 'private';
|
||||
}
|
||||
else
|
||||
{
|
||||
$values['access'] = 'public';
|
||||
}
|
||||
|
||||
if ($values['id'] && $values['id'] != 0)
|
||||
{
|
||||
return $this->cats->edit($values);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->cats->add($values);
|
||||
}
|
||||
}
|
||||
|
||||
function exists($data)
|
||||
{
|
||||
$data['type'] = $data['type'] ? $data['type'] : '';
|
||||
$data['cat_id'] = $data['cat_id'] ? $data['cat_id'] : '';
|
||||
return $this->cats->exists($data['type'],$data['cat_name'],$data['cat_id']);
|
||||
}
|
||||
|
||||
function formatted_list($data)
|
||||
{
|
||||
return $this->cats->formated_list($data['select'],$data['all'],$data['cat_parent']);
|
||||
}
|
||||
|
||||
function delete($cat_id,$subs)
|
||||
{
|
||||
return $this->cats->delete($cat_id,$subs);
|
||||
}
|
||||
|
||||
function check_values($action,$values)
|
||||
{
|
||||
if ($action == 'add')
|
||||
{
|
||||
$values['id'] = '';
|
||||
}
|
||||
|
||||
if (strlen($values['descr']) >= 255)
|
||||
{
|
||||
$error[] = lang('Description can not exceed 255 characters in length !');
|
||||
}
|
||||
|
||||
if (strlen($values['data']) >= 8000)
|
||||
{
|
||||
$error[] = lang('Data can not exceed 8000 characters in length !');
|
||||
}
|
||||
|
||||
if (!$values['name'])
|
||||
{
|
||||
$error[] = lang('Please enter a name');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$values['cat_parent'])
|
||||
{
|
||||
$exists = $this->exists(array
|
||||
(
|
||||
'type' => 'appandmains',
|
||||
'cat_name' => $values['name'],
|
||||
'cat_id' => $values['id']
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
$exists = $this->exists(array
|
||||
(
|
||||
'type' => 'appandsubs',
|
||||
'cat_name' => $values['name'],
|
||||
'cat_id' => $values['id']
|
||||
));
|
||||
}
|
||||
|
||||
if ($exists == True)
|
||||
{
|
||||
$error[] = lang('That name has been used already');
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($error))
|
||||
{
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
}
|
539
preferences/inc/class.uicategories.inc.php
Normal file
539
preferences/inc/class.uicategories.inc.php
Normal file
@ -0,0 +1,539 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - Preferences - categories *
|
||||
* http://www.phpgroupware.org *
|
||||
* Written by Bettina Gille [ceb@phpgroupware.org] *
|
||||
* ----------------------------------------------- *
|
||||
* 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 *
|
||||
* Free Software Foundation; either version 2 of the License, or (at your *
|
||||
* option) any later version. *
|
||||
\**************************************************************************/
|
||||
/* $Id$ */
|
||||
|
||||
class uicategories
|
||||
{
|
||||
var $bo;
|
||||
var $t;
|
||||
|
||||
var $start;
|
||||
var $query;
|
||||
var $sort;
|
||||
var $order;
|
||||
var $cat_id;
|
||||
|
||||
var $public_functions = array
|
||||
(
|
||||
'index' => True,
|
||||
'add' => True,
|
||||
'edit' => True,
|
||||
'delete' => True
|
||||
);
|
||||
|
||||
function uicategories()
|
||||
{
|
||||
$this->bo = CreateObject('preferences.bocategories',$cats_app);
|
||||
$this->t = $GLOBALS['phpgw']->template;
|
||||
$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
|
||||
);
|
||||
|
||||
$this->bo->save_sessiondata($data,$cats_app);
|
||||
}
|
||||
|
||||
function set_langs()
|
||||
{
|
||||
$this->t->set_var('lang_access',lang('Private'));
|
||||
$this->t->set_var('lang_save',lang('Save'));
|
||||
$this->t->set_var('user_name',$this->user);
|
||||
$this->t->set_var('lang_search',lang('Search'));
|
||||
$this->t->set_var('lang_done',lang('Done'));
|
||||
$this->t->set_var('lang_sub',lang('Add sub'));
|
||||
$this->t->set_var('lang_edit',lang('Edit'));
|
||||
$this->t->set_var('lang_delete',lang('Delete'));
|
||||
$this->t->set_var('lang_parent',lang('Parent category'));
|
||||
$this->t->set_var('lang_none',lang('None'));
|
||||
$this->t->set_var('lang_name',lang('Name'));
|
||||
$this->t->set_var('lang_descr',lang('Description'));
|
||||
$this->t->set_var('lang_add',lang('Add'));
|
||||
$this->t->set_var('lang_reset',lang('Clear Form'));
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
global $cats_app, $extra, $global_cats, $cats_level;
|
||||
|
||||
$link_data = array
|
||||
(
|
||||
'menuaction' => 'preferences.uicategories.index',
|
||||
'cats_app' => $cats_app,
|
||||
'extra' => $extra,
|
||||
'global_cats' => $global_cats,
|
||||
'cats_level' => $cats_level
|
||||
);
|
||||
|
||||
$GLOBALS['phpgw']->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
|
||||
$this->t->set_file(array('cat_list_t' => 'listcats.tpl'));
|
||||
$this->t->set_block('cat_list_t','cat_list','list');
|
||||
|
||||
$this->set_langs();
|
||||
|
||||
$this->t->set_var('title_categories',lang('categories for'));
|
||||
$this->t->set_var('lang_app',lang($cats_app));
|
||||
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
|
||||
$this->t->set_var('doneurl',$GLOBALS['phpgw']->link('/preferences/index.php'));
|
||||
|
||||
if(!$this->start)
|
||||
{
|
||||
$this->start = 0;
|
||||
}
|
||||
|
||||
$this->bo->cats->app_name = $cats_app;
|
||||
$cats = $this->bo->get_list();
|
||||
|
||||
//--------------------------------- nextmatch --------------------------------------------
|
||||
|
||||
$left = $this->nextmatchs->left('/index.php',$this->start,$this->bo->cats->total_records,$link_data);
|
||||
$right = $this->nextmatchs->right('/index.php',$this->start,$this->bo->cats->total_records,$link_data);
|
||||
$this->t->set_var('left',$left);
|
||||
$this->t->set_var('right',$right);
|
||||
|
||||
$this->t->set_var('lang_showing',$this->nextmatchs->show_hits($this->bo->cats->total_records,$this->start));
|
||||
|
||||
// ------------------------------ end nextmatch ------------------------------------------
|
||||
|
||||
//------------------- list header variable template-declarations -------------------------
|
||||
|
||||
$this->t->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
|
||||
$this->t->set_var('sort_name',$this->nextmatchs->show_sort_order($this->sort,'cat_name',$this->order,'/index.php',lang('Name'),$link_data));
|
||||
$this->t->set_var('sort_description',$this->nextmatchs->show_sort_order($this->sort,'cat_description',$this->order,'/index.php',lang('Description'),$link_data));
|
||||
|
||||
if ($extra)
|
||||
{
|
||||
$this->t->set_var('sort_data','<td bgcolor="' . $GLOBALS['phpgw_info']['theme']['th_bg'] . '">'
|
||||
. $this->nextmatchs->show_sort_order($this->sort,'cat_data',
|
||||
$this->order,'/index.php',lang($extra),$link_data) . '</td>');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->t->set_var('sort_data','');
|
||||
}
|
||||
|
||||
// -------------------------- end header declaration --------------------------------------
|
||||
|
||||
for ($i=0;$i<count($cats);$i++)
|
||||
{
|
||||
$this->nextmatchs->template_alternate_row_color(&$this->t);
|
||||
|
||||
if ($cats[$i]['app_name'] == 'phpgw')
|
||||
{
|
||||
$appendix = '<' . lang('Global') . '>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$appendix = '';
|
||||
}
|
||||
|
||||
$level = $cats[$i]['level'];
|
||||
|
||||
if ($level > 0)
|
||||
{
|
||||
$space = ' ';
|
||||
$spaceset = str_repeat($space,$level);
|
||||
$name = $spaceset . $GLOBALS['phpgw']->strip_html($cats[$i]['name']) . $appendix;
|
||||
}
|
||||
|
||||
$descr = $GLOBALS['phpgw']->strip_html($cats[$i]['description']);
|
||||
if (!$descr) { $descr = ' '; }
|
||||
|
||||
if ($extra)
|
||||
{
|
||||
$data = $cats[$i]['data'];
|
||||
if (! $data)
|
||||
{
|
||||
$data = ' ';
|
||||
}
|
||||
$this->t->set_var('td_data','<td>' . $data . '</td>');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->t->set_var('td_data','');
|
||||
}
|
||||
|
||||
if ($level == 0)
|
||||
{
|
||||
$name = '<font color="FF0000"><b>' . $GLOBALS['phpgw']->strip_html($cats[$i]['name']) . '</b></font>' . $appendix;
|
||||
$descr = '<font color="FF0000"><b>' . $descr . '</b></font>';
|
||||
$data = '<font color="FF0000"><b>' . $data . '</b></font>';
|
||||
}
|
||||
|
||||
$this->t->set_var(array('name' => $name,
|
||||
'descr' => $descr));
|
||||
|
||||
$this->t->set_var('app_url',$GLOBALS['phpgw']->link('/' . $cats_app . '/index.php','cat_id=' . $cats[$i]['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'];
|
||||
$this->t->set_var('add_sub',$GLOBALS['phpgw']->link('/index.php',$link_data));
|
||||
$this->t->set_var('lang_sub_entry',lang('Add sub'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$t->set_var('add_sub','');
|
||||
$t->set_var('lang_sub_entry',' ');
|
||||
}
|
||||
|
||||
$link_data['cat_id'] = $cats[$i]['id'];
|
||||
if ($cats[$i]['owner'] == $this->account && $cats[$i]['app_name'] != 'phpgw')
|
||||
{
|
||||
$link_data['menuaction'] = 'preferences.uicategories.edit';
|
||||
$this->t->set_var('edit',$GLOBALS['phpgw']->link('/index.php',$link_data));
|
||||
$this->t->set_var('lang_edit_entry',lang('Edit'));
|
||||
|
||||
$link_data['menuaction'] = 'preferences.uicategories.delete';
|
||||
$this->t->set_var('delete',$GLOBALS['phpgw']->link('/index.php',$link_data));
|
||||
$this->t->set_var('lang_delete_entry',lang('Delete'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->t->set_var('edit','');
|
||||
$this->t->set_var('lang_edit_entry',' ');
|
||||
|
||||
$this->t->set_var('delete','');
|
||||
$this->t->set_var('lang_delete_entry',' ');
|
||||
}
|
||||
$this->t->fp('list','cat_list',True);
|
||||
}
|
||||
$link_data['menuaction'] = 'preferences.uicategories.add';
|
||||
$this->t->set_var('add_action',$GLOBALS['phpgw']->link('/index.php',$link_data));
|
||||
$this->save_sessiondata($cats_app);
|
||||
|
||||
$this->t->pfp('out','cat_list_t',True);
|
||||
}
|
||||
|
||||
function add()
|
||||
{
|
||||
global $cats_app, $extra, $global_cats, $cats_level;
|
||||
|
||||
$link_data = array
|
||||
(
|
||||
'menuaction' => 'preferences.uicategories.add',
|
||||
'cats_app' => $cats_app,
|
||||
'extra' => $extra,
|
||||
'global_cats' => $global_cats,
|
||||
'cats_level' => $cats_level
|
||||
);
|
||||
|
||||
$GLOBALS['phpgw']->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
|
||||
$new_parent = $GLOBALS['HTTP_POST_VARS']['new_parent'];
|
||||
$submit = $GLOBALS['HTTP_POST_VARS']['submit'];
|
||||
$cat_parent = $GLOBALS['HTTP_POST_VARS']['cat_parent'] ? $GLOBALS['HTTP_POST_VARS']['cat_parent'] : $GLOBALS['HTTP_GET_VARS']['cat_parent'];
|
||||
$cat_name = $GLOBALS['HTTP_POST_VARS']['cat_name'];
|
||||
$cat_description = $GLOBALS['HTTP_POST_VARS']['cat_description'];
|
||||
$cat_data = $GLOBALS['HTTP_POST_VARS']['cat_data'];
|
||||
$cat_access = $GLOBALS['HTTP_POST_VARS']['cat_access'];
|
||||
|
||||
$this->t->set_file(array('form' => 'category_form.tpl'));
|
||||
$this->t->set_block('form','add','addhandle');
|
||||
$this->t->set_block('form','edit','edithandle');
|
||||
|
||||
$this->set_langs();
|
||||
|
||||
$this->bo->cats->app_name = $cats_app;
|
||||
|
||||
if ($new_parent)
|
||||
{
|
||||
$cat_parent = $new_parent;
|
||||
}
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
$values = array();
|
||||
$values['parent'] = $cat_parent;
|
||||
$values['descr'] = $cat_description;
|
||||
$values['name'] = $cat_name;
|
||||
$values['access'] = $cat_access;
|
||||
$values['data'] = $cat_data;
|
||||
|
||||
$error = $this->bo->check_values('add',$values);
|
||||
if (is_array($error))
|
||||
{
|
||||
$this->t->set_var('message',$GLOBALS['phpgw']->common->error_list($error));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->bo->save_cat($values);
|
||||
$this->t->set_var('message',lang('Category x has been added !', $cat_name));
|
||||
}
|
||||
}
|
||||
|
||||
$this->t->set_var('title_categories',lang('Add x category for',lang($cats_app)));
|
||||
$this->t->set_var('lang_app',lang($cats_app));
|
||||
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
|
||||
|
||||
if ($cats_level)
|
||||
{
|
||||
if ($global_cats)
|
||||
{
|
||||
$cats_list = $this->bo->cats->formated_list('select','all',$cat_parent,True);
|
||||
}
|
||||
else
|
||||
{
|
||||
$cats_list = $this->bo->cats->formated_list('select','all',$cat_parent);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($global_cats)
|
||||
{
|
||||
$cats_list = $this->bo->cats->formated_list('select','mains',$cat_parent,True);
|
||||
}
|
||||
else
|
||||
{
|
||||
$cats_list = $this->bo->cats->formated_list('select','mains',$cat_parent);
|
||||
}
|
||||
}
|
||||
|
||||
$this->t->set_var('category_list',$cats_list);
|
||||
$this->t->set_var('cat_name',$cat_name);
|
||||
$this->t->set_var('cat_description',$cat_description);
|
||||
|
||||
$this->t->set_var('access','<input type="checkbox" name="cat_access" value="True"'
|
||||
. ($cat_access == True ?' checked':'') . '>');
|
||||
|
||||
if ($extra)
|
||||
{
|
||||
$this->t->set_var('td_data','<input name="cat_data" size="50" value="' . $GLOBALS['phpgw']->strip_html($cat_data) . '">');
|
||||
$this->t->set_var('lang_data',lang($extra));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->t->set_var('td_data','');
|
||||
$this->t->set_var('lang_data','');
|
||||
}
|
||||
|
||||
$link_data['menuaction'] = 'preferences.uicategories.index';
|
||||
$this->t->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
|
||||
$this->t->set_var('edithandle','');
|
||||
$this->t->set_var('addhandle','');
|
||||
$this->t->pfp('out','form');
|
||||
$this->t->pfp('addhandle','add');
|
||||
}
|
||||
|
||||
function edit()
|
||||
{
|
||||
global $cats_app, $extra, $global_cats, $cats_level, $cat_id;
|
||||
|
||||
$link_data = array
|
||||
(
|
||||
'menuaction' => 'preferences.uicategories.index',
|
||||
'cats_app' => $cats_app,
|
||||
'extra' => $extra,
|
||||
'global_cats' => $global_cats,
|
||||
'cats_level' => $cats_level,
|
||||
'cat_id' => $cat_id
|
||||
);
|
||||
|
||||
if (!$cat_id)
|
||||
{
|
||||
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data));
|
||||
}
|
||||
|
||||
$GLOBALS['phpgw']->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
|
||||
$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'];
|
||||
$cat_data = $GLOBALS['HTTP_POST_VARS']['cat_data'];
|
||||
$cat_access = $GLOBALS['HTTP_POST_VARS']['cat_access'];
|
||||
|
||||
$this->t->set_file(array('form' => 'category_form.tpl'));
|
||||
$this->t->set_block('form','add','addhandle');
|
||||
$this->t->set_block('form','edit','edithandle');
|
||||
|
||||
$this->set_langs();
|
||||
$this->t->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
|
||||
$this->bo->cats->app_name = $cats_app;
|
||||
|
||||
if ($new_parent)
|
||||
{
|
||||
$cat_parent = $new_parent;
|
||||
}
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
$values = array();
|
||||
$values['id'] = $cat_id;
|
||||
$values['parent'] = $cat_parent;
|
||||
$values['descr'] = $cat_description;
|
||||
$values['name'] = $cat_name;
|
||||
$values['access'] = $cat_access;
|
||||
$values['data'] = $cat_data;
|
||||
|
||||
$error = $this->bo->check_values('edit',$values);
|
||||
if (is_array($error))
|
||||
{
|
||||
$this->t->set_var('message',$GLOBALS['phpgw']->common->error_list($error));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->bo->save_cat($values);
|
||||
$this->t->set_var('message',lang('Category x has been updated !',$cat_name));
|
||||
}
|
||||
}
|
||||
|
||||
$cats = $this->bo->cats->return_single($cat_id);
|
||||
|
||||
$this->t->set_var('title_categories',lang('Edit x category for',lang($cats_app)));
|
||||
$this->t->set_var('lang_app',lang($cats_app));
|
||||
$link_data['menuaction'] = 'preferences.uicategories.edit';
|
||||
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
|
||||
|
||||
$this->t->set_var('cat_name',$GLOBALS['phpgw']->strip_html($cats[0]['name']));
|
||||
$this->t->set_var('cat_description',$GLOBALS['phpgw']->strip_html($cats[0]['description']));
|
||||
|
||||
if ($cats_level)
|
||||
{
|
||||
if ($global_cats)
|
||||
{
|
||||
$cats_list = $this->bo->cats->formated_list('select','all',$cats[0]['parent'],True);
|
||||
}
|
||||
else
|
||||
{
|
||||
$cats_list = $this->bo->cats->formated_list('select','all',$cats[0]['parent']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($global_cats)
|
||||
{
|
||||
$cats_list = $this->bo->cats->formated_list('select','mains',$cats[0]['parent'],True);
|
||||
}
|
||||
else
|
||||
{
|
||||
$cats_list = $this->bo->cats->formated_list('select','mains',$cats[0]['parent']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->t->set_var('category_list',$cats_list);
|
||||
|
||||
$this->t->set_var('access','<input type="checkbox" name="cat_access" value="True"'
|
||||
. ($cat_access == True ?' checked':'') . '>');
|
||||
|
||||
if ($cats[0]['owner'] == $this->account)
|
||||
{
|
||||
$link_data['menuaction'] = 'preferences.uicategories.delete';
|
||||
$this->t->set_var('delete','<form method="POST" action="' . $GLOBALS['phpgw']->link('/index.php',$link_data)
|
||||
. '"><input type="submit" value="' . lang('Delete') .'"></form>');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->t->set_var('delete',' ');
|
||||
}
|
||||
|
||||
$this->t->set_var('edithandle','');
|
||||
$this->t->set_var('addhandle','');
|
||||
$this->t->pfp('out','form');
|
||||
$this->t->pfp('edithandle','edit');
|
||||
}
|
||||
|
||||
function delete()
|
||||
{
|
||||
global $cats_app, $extra, $global_cats, $cats_level, $cat_id;
|
||||
|
||||
$link_data = array
|
||||
(
|
||||
'menuaction' => 'preferences.uicategories.index',
|
||||
'cats_app' => $cats_app,
|
||||
'extra' => $extra,
|
||||
'global_cats' => $global_cats,
|
||||
'cats_level' => $cats_level,
|
||||
'cat_id' => $cat_id
|
||||
);
|
||||
|
||||
if (!$cat_id)
|
||||
{
|
||||
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data));
|
||||
}
|
||||
|
||||
$this->bo->cats->app_name = $cats_app;
|
||||
|
||||
if ($GLOBALS['HTTP_POST_VARS']['confirm'])
|
||||
{
|
||||
if ($GLOBALS['HTTP_POST_VARS']['subs'])
|
||||
{
|
||||
$this->bo->delete($cat_id,True);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->bo->delete($cat_id,False);
|
||||
}
|
||||
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->t->set_file(array('category_delete' => 'delete.tpl'));
|
||||
|
||||
$nolink = $GLOBALS['phpgw']->link('/index.php',$link_data);
|
||||
|
||||
$GLOBALS['phpgw']->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
|
||||
$this->t->set_var('messages',lang('Are you sure you want to delete this category ?'));
|
||||
|
||||
$exists = $this->bo->exists(array
|
||||
(
|
||||
'type' => 'subs',
|
||||
'cat_name' => '',
|
||||
'cat_id' => $cat_id
|
||||
));
|
||||
|
||||
if ($exists)
|
||||
{
|
||||
$this->t->set_var('lang_subs',lang('Do you also want to delete all subcategories ?'));
|
||||
$this->t->set_var('subs','<input type="checkbox" name="subs" value="True">');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->t->set_var('lang_subs','');
|
||||
$this->t->set_var('subs', '');
|
||||
}
|
||||
|
||||
$this->t->set_var('nolink',$nolink);
|
||||
$this->t->set_var('lang_no',lang('No'));
|
||||
$link_data['menuaction'] = 'preferences.uicategories.delete';
|
||||
$this->t->set_var('action_url',$GLOBALS['phpgw']->link('/index.php',$link_data));
|
||||
$this->t->set_var('lang_yes',lang('Yes'));
|
||||
$this->t->pfp('out','category_delete');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -3,72 +3,66 @@
|
||||
<!-- BEGIN form -->
|
||||
|
||||
<center>
|
||||
<table border="0" width="80%" cellspacing="2" cellpadding="2">
|
||||
<tr>
|
||||
<td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>{title_categories}: {user_name}<b/></font></td>
|
||||
</tr>
|
||||
</table>
|
||||
<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_parent}</font></td>
|
||||
<td><font face="{font}"><select name="new_parent"><option value="">{lang_none}</option>{category_list}</select></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><font face="{font}">{lang_name}</font></td>
|
||||
<td><font face="{font}"><input name="cat_name" size="50" value="{cat_name}"></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><font face="{font}">{lang_descr}</font></td>
|
||||
<td colspan=2><font face="{font}"><textarea name="cat_description" rows="4" cols="50" wrap="virtual">{cat_description}</textarea></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><font face="{font}">{lang_data}</font></td>
|
||||
<td><font face="{font}">{td_data}</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><font face="{font}">{lang_access}</font></td>
|
||||
<td colspan=2>{access}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border="0" width="80%" cellspacing="2" cellpadding="2">
|
||||
<tr>
|
||||
<td colspan="1" align="center" bgcolor="#c9c9c9"><b>{title_categories}: {user_name}<b/></td>
|
||||
</tr>
|
||||
</table>
|
||||
{message}
|
||||
<table border="0" width="80%" cellspacing="2" cellpadding="2">
|
||||
<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>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{lang_name}</font></td>
|
||||
<td><input name="cat_name" size="50" value="{cat_name}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{lang_descr}</td>
|
||||
<td colspan="2"><textarea name="cat_description" rows="4" cols="50" wrap="virtual">{cat_description}</textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{lang_data}</td>
|
||||
<td>{td_data}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{lang_access}</td>
|
||||
<td colspan="2">{access}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- BEGIN add -->
|
||||
|
||||
<table width="50%" border="0" cellspacing="2" cellpadding="2">
|
||||
<tr valign="bottom">
|
||||
<td height="50" align="right">
|
||||
{hidden_vars}
|
||||
<font face="{font}"><input type="submit" name="submit" value="{lang_add}"></font></td>
|
||||
<td height="50" align="center">
|
||||
<font face="{font}"><input type="reset" name="reset" value="{lang_reset}"></font></form></td>
|
||||
<td height="50">
|
||||
<form method="POST" action="{doneurl}">
|
||||
{hidden_vars}
|
||||
<font face="{font}"><input type="submit" name="done" value="{lang_done}"></font></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="50%" border="0" cellspacing="2" cellpadding="2">
|
||||
<tr valign="bottom">
|
||||
<td height="50" align="right">
|
||||
<input type="submit" name="submit" value="{lang_add}"></td>
|
||||
<td height="50" align="center">
|
||||
<input type="reset" name="reset" value="{lang_reset}"></form></td>
|
||||
<td height="50">
|
||||
<form method="POST" action="{doneurl}">
|
||||
<input type="submit" name="done" value="{lang_done}"></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
<!-- END add -->
|
||||
|
||||
<!-- BEGIN edit -->
|
||||
|
||||
<table width="50%" border="0" cellspacing="2" cellpadding="2">
|
||||
<tr valign="bottom">
|
||||
<td height="50" align="right">
|
||||
{hidden_vars}
|
||||
<font face="{font}"><input type="submit" name="submit" value="{lang_edit}"></font></form></td>
|
||||
<td height="50" align="center">
|
||||
<form method="POST" action="{deleteurl}">
|
||||
{hidden_vars}
|
||||
<font face="{font}"><input type="submit" name="delete" value="{lang_delete}"></font></form></td>
|
||||
<td height="50">
|
||||
<form method="POST" action="{doneurl}">
|
||||
{hidden_vars}
|
||||
<font face="{font}"><input type="submit" name="done" value="{lang_done}"></font></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="50%" border="0" cellspacing="2" cellpadding="2">
|
||||
<tr valign="bottom">
|
||||
<td height="50" align="right">
|
||||
<input type="submit" name="submit" value="{lang_edit}"></form></td>
|
||||
<td height="50" align="center">
|
||||
{delete}</td>
|
||||
<td height="50">
|
||||
<form method="POST" action="{doneurl}">
|
||||
<input type="submit" name="done" value="{lang_done}"></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
<!-- END edit -->
|
||||
|
@ -1,74 +1,71 @@
|
||||
<!-- $Id$ -->
|
||||
|
||||
<center>
|
||||
<table border="0" cellspacing="0" cellpadding="0" width="80%">
|
||||
<tr>
|
||||
<td colspan="3" width="80%" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>{lang_app} {title_categories}: {user_name}<b/></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align=left>
|
||||
<table border="0" width="100%">
|
||||
<tr>
|
||||
{left}
|
||||
<td align="center"><font face="{font}">{lang_showing}</font></td>
|
||||
{right}
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td colspan="3" align=right>
|
||||
<form method="post" action="{actionurl}">
|
||||
<font face="{font}"><input type="text" name="query"> <input type="submit" name="search" value="{lang_search}"></font>
|
||||
</form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border="0" cellspacing="2" cellpadding="2" width="80%">
|
||||
<tr bgcolor="{th_bg}">
|
||||
<td bgcolor="{th_bg}"><font face="{font}">{sort_name}</font></td>
|
||||
<td bgcolor="{th_bg}"><font face="{font}">{sort_description}</font></td>
|
||||
{sort_data}
|
||||
<td bgcolor="{th_bg}" align="center"><font face="{font}">{lang_app}</font></td>
|
||||
<td bgcolor="{th_bg}" align=center><font face="{font}">{lang_sub}</font></td>
|
||||
<td bgcolor="{th_bg}" align=center><font face="{font}">{lang_edit}</font></td>
|
||||
<td bgcolor="{th_bg}" align=center><font face="{font}">{lang_delete}</font></td>
|
||||
</tr>
|
||||
<center>
|
||||
<table border="0" cellspacing="0" cellpadding="0" width="80%">
|
||||
<tr>
|
||||
<td colspan="3" width="80%" align="center" bgcolor="#c9c9c9"><b>{lang_app} {title_categories}: {user_name}<b/><</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align=left>
|
||||
<table border="0" width="100%">
|
||||
<tr>
|
||||
{left}
|
||||
<td align="center">{lang_showing}</td>
|
||||
{right}
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td colspan="3" align=right>
|
||||
<form method="post" action="{actionurl}">
|
||||
<input type="text" name="query"> <input type="submit" name="search" value="{lang_search}">
|
||||
</form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border="0" cellspacing="2" cellpadding="2" width="80%">
|
||||
<tr bgcolor="{th_bg}">
|
||||
<td bgcolor="{th_bg}">{sort_name}</td>
|
||||
<td bgcolor="{th_bg}">{sort_description}</td>
|
||||
{sort_data}
|
||||
<td bgcolor="{th_bg}" align="center">{lang_app}</td>
|
||||
<td bgcolor="{th_bg}" align=center>{lang_sub}</td>
|
||||
<td bgcolor="{th_bg}" align=center>{lang_edit}</td>
|
||||
<td bgcolor="{th_bg}" align=center>{lang_delete}</td>
|
||||
</tr>
|
||||
|
||||
<!-- BEGIN cat_list -->
|
||||
|
||||
<tr bgcolor="{tr_color}">
|
||||
<td><font face="{font}">{name}</font></td>
|
||||
<td><font face="{font}">{descr}</font></td>
|
||||
{td_data}
|
||||
<td align="center"><font face="{font}"><a href="{app_url}">{lang_app}</a></font></td>
|
||||
<td align="center"><font face="{font}"><a href="{add_sub}">{lang_sub_entry}</a></font></td>
|
||||
<td align="center"><font face="{font}"><a href="{edit}">{lang_edit_entry}</a></font></td>
|
||||
<td align="center"><font face="{font}"><a href="{delete}">{lang_delete_entry}</a></font></td>
|
||||
</tr>
|
||||
<tr bgcolor="{tr_color}">
|
||||
<td>{name}</td>
|
||||
<td>{descr}</td>
|
||||
{td_data}
|
||||
<td align="center"><a href="{app_url}">{lang_app}</a></td>
|
||||
<td align="center"><a href="{add_sub}">{lang_sub_entry}</a></td>
|
||||
<td align="center"><a href="{edit}">{lang_edit_entry}</a></td>
|
||||
<td align="center"><a href="{delete}">{lang_delete_entry}</a></td>
|
||||
</tr>
|
||||
|
||||
<!-- END cat_list -->
|
||||
|
||||
<!-- BEGINN add -->
|
||||
|
||||
</table>
|
||||
<table border="0" cellspacing="2" cellpadding="2" width="80%">
|
||||
<tr valign="bottom">
|
||||
<td width="50%">
|
||||
<form method="POST" action="{add_action}">
|
||||
{hidden_vars}
|
||||
<font face="{font}"><input type="submit" value="{lang_add}"></font>
|
||||
</form>
|
||||
</td>
|
||||
<td width="50%" align="right">
|
||||
<form method="POST" action="{doneurl}">
|
||||
{hidden_vars}
|
||||
<font face="{font}"><input type="submit" name="done" value="{lang_done}"></font>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border="0" cellspacing="2" cellpadding="2" width="80%">
|
||||
<tr valign="bottom">
|
||||
<td width="50%">
|
||||
<form method="POST" action="{add_action}">
|
||||
<input type="submit" value="{lang_add}">
|
||||
</form></td>
|
||||
<td width="50%" align="right">
|
||||
<form method="POST" action="{doneurl}">
|
||||
<input type="submit" name="done" value="{lang_done}">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- END add -->
|
||||
|
||||
</table>
|
||||
</table>
|
||||
</center>
|
||||
|
Loading…
Reference in New Issue
Block a user