2001-12-24 18:35:58 +01:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
2004-01-25 23:02:59 +01:00
|
|
|
* eGroupWare - Addressbook *
|
|
|
|
* http://www.egroupware.org *
|
2002-04-13 05:34:23 +02:00
|
|
|
* Written by Joseph Engo <jengo@phpgroupware.org> and *
|
2004-01-25 23:02:59 +01:00
|
|
|
* Miles Lott <milosch@groupwhere.org> *
|
2001-12-24 18:35:58 +01:00
|
|
|
* ----------------------------------------------- *
|
|
|
|
* 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. *
|
|
|
|
\**************************************************************************/
|
2002-04-13 05:34:23 +02:00
|
|
|
|
2001-12-24 18:35:58 +01:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
class uifields
|
|
|
|
{
|
|
|
|
var $public_functions = array(
|
|
|
|
'index' => True,
|
|
|
|
'add' => True,
|
|
|
|
'edit' => True,
|
|
|
|
'delete' => True
|
|
|
|
);
|
|
|
|
|
2004-03-14 18:02:18 +01:00
|
|
|
function uifields($only_bo=False)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2004-03-14 18:02:18 +01:00
|
|
|
if (!$only_bo)
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
|
|
|
|
$GLOBALS['egw']->nextmatchs = CreateObject('phpgwapi.nextmatchs');
|
2004-03-14 18:02:18 +01:00
|
|
|
}
|
2002-04-13 05:34:23 +02:00
|
|
|
$this->config = CreateObject('phpgwapi.config','addressbook');
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function index()
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
if(!$GLOBALS['egw']->acl->check('run',1,'admin'))
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->common->phpgw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
2001-12-24 18:35:58 +01:00
|
|
|
echo lang('access not permitted');
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->common->phpgw_exit();
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_file(array(
|
2001-12-24 18:35:58 +01:00
|
|
|
'field_list_t' => 'listfields.tpl',
|
|
|
|
'field_list' => 'listfields.tpl'
|
|
|
|
));
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_block('field_list_t','field_list','list');
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
$field = $_POST['field'];
|
|
|
|
$start = $_POST['start'] ? $_POST['start'] : $_GET['start'];
|
|
|
|
$query = $_POST['query'] ? $_POST['query'] : $_GET['query'];
|
|
|
|
$sort = $_POST['sort'] ? $_POST['sort'] : $_GET['sort'];
|
2001-12-24 18:35:58 +01:00
|
|
|
|
|
|
|
$common_hidden_vars =
|
|
|
|
'<input type="hidden" name="sort" value="' . $sort . '">' . "\n"
|
|
|
|
. '<input type="hidden" name="order" value="' . $order . '">' . "\n"
|
|
|
|
. '<input type="hidden" name="query" value="' . $query . '">' . "\n"
|
|
|
|
. '<input type="hidden" name="start" value="' . $start . '">' . "\n"
|
|
|
|
. '<input type="hidden" name="filter" value="' . $filter . '">' . "\n";
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_action',lang('Custom Fields'));
|
|
|
|
$GLOBALS['egw']->template->set_var('add_action',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.add'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_add',lang('Add'));
|
|
|
|
$GLOBALS['egw']->template->set_var('title_fields',lang('addressbook').' - '.lang('Custom Fields'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_search',lang('Search'));
|
|
|
|
$GLOBALS['egw']->template->set_var('actionurl',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.index'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_done',lang('Done'));
|
|
|
|
$GLOBALS['egw']->template->set_var('doneurl',$GLOBALS['egw']->link('/admin/index.php'));
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2002-01-17 04:52:56 +01:00
|
|
|
if(!$start)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
|
|
|
$start = 0;
|
|
|
|
}
|
|
|
|
|
2002-01-17 04:52:56 +01:00
|
|
|
if(!$sort)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
|
|
|
$sort = 'ASC';
|
|
|
|
}
|
|
|
|
|
2002-04-13 05:34:23 +02:00
|
|
|
$fields = $this->read_custom_fields($start,$limit,$query,$sort);
|
2001-12-24 18:35:58 +01:00
|
|
|
$total_records = count($fields);
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->common->phpgw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('left',$GLOBALS['egw']->nextmatchs->left('/index.php',$start,$total_records,'menuaction=addressbook.uifields.index'));
|
|
|
|
$GLOBALS['egw']->template->set_var('right',$GLOBALS['egw']->nextmatchs->right('/index.php',$start,$total_records,'menuaction=addressbook.uifields.index'));
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_showing',$GLOBALS['egw']->nextmatchs->show_hits($total_records,$start));
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']);
|
|
|
|
$GLOBALS['egw']->template->set_var('sort_field',$GLOBALS['egw']->nextmatchs->show_sort_order($sort,'name',$order,'/index.php',lang('Name')),'menuaction=addressbook.uifields.index');
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_edit',lang('Edit'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_delete',lang('Delete'));
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2002-01-17 04:52:56 +01:00
|
|
|
for($i=0;$i<count($fields);$i++)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$tr_color = $GLOBALS['egw']->nextmatchs->alternate_row_color($tr_color);
|
|
|
|
$GLOBALS['egw']->template->set_var(tr_color,$tr_color);
|
2001-12-24 18:35:58 +01:00
|
|
|
|
|
|
|
$field = $fields[$i]['name'];
|
2002-04-13 05:34:23 +02:00
|
|
|
$title = $fields[$i]['title'];
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('cfield',$title);
|
2004-02-22 16:18:36 +01:00
|
|
|
|
2003-04-06 14:11:03 +02:00
|
|
|
$params = array(
|
|
|
|
'menuaction' => 'addressbook.uifields.edit',
|
|
|
|
'field' => urlencode($field),
|
|
|
|
'start' => $start,
|
|
|
|
'query' => $query,
|
|
|
|
'sort' => $sort,
|
|
|
|
'order' => $order,
|
|
|
|
'filter' => $filter
|
|
|
|
);
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('edit',$GLOBALS['egw']->link('/index.php',$params));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_edit_entry',lang('Edit'));
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2003-04-06 14:11:03 +02:00
|
|
|
$params['menuaction'] = 'addressbook.uifields.delete';
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('delete',$GLOBALS['egw']->link('/index.php',$params));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_delete_entry',lang('Delete'));
|
|
|
|
$GLOBALS['egw']->template->parse('list','field_list',True);
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->parse('out','field_list_t',True);
|
|
|
|
$GLOBALS['egw']->template->p('out');
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function add()
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
if(!$GLOBALS['egw']->acl->check('run',1,'admin'))
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->common->phpgw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
2001-12-24 18:35:58 +01:00
|
|
|
echo lang('access not permitted');
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->common->phpgw_exit();
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
$field = stripslashes($_POST['field']);
|
|
|
|
$field_name = stripslashes($_POST['field_name']);
|
|
|
|
$start = $_POST['start'];
|
|
|
|
$query = $_POST['query'];
|
|
|
|
$sort = $_POST['sort'];
|
|
|
|
$submit = $_POST['submit'];
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_file(array('form' => 'field_form.tpl'));
|
|
|
|
$GLOBALS['egw']->template->set_block('form','add','addhandle');
|
|
|
|
$GLOBALS['egw']->template->set_block('form','edit','edithandle');
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2002-04-13 05:34:23 +02:00
|
|
|
if($submit)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
|
|
|
$errorcount = 0;
|
|
|
|
|
2002-01-17 04:52:56 +01:00
|
|
|
if(!$field_name)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
|
|
|
$error[$errorcount++] = lang('Please enter a name for that field !');
|
|
|
|
}
|
|
|
|
|
|
|
|
$fields = $this->read_custom_fields($start,$limit,$field_name);
|
2002-01-17 04:52:56 +01:00
|
|
|
if($fields[0]['name'])
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
|
|
|
$error[$errorcount++] = lang('That field name has been used already !');
|
|
|
|
}
|
|
|
|
|
2002-01-17 04:52:56 +01:00
|
|
|
if(!$error)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
|
|
|
$this->save_custom_field($field,$field_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->common->phpgw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2002-01-17 04:52:56 +01:00
|
|
|
if($errorcount)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('message',$GLOBALS['egw']->common->error_list($error));
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
2003-12-01 01:46:45 +01:00
|
|
|
if(($submit) && (!$error) && (!$errorcount))
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('message',lang('Field %1 has been added !', $field_name));
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
2003-12-01 01:46:45 +01:00
|
|
|
if((!$submit) && (!$error) && (!$errorcount))
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('message','');
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('title_fields',lang('Add Custom Field'));
|
|
|
|
$GLOBALS['egw']->template->set_var('actionurl',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.add'));
|
|
|
|
$GLOBALS['egw']->template->set_var('doneurl',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.index'));
|
|
|
|
$GLOBALS['egw']->template->set_var('hidden_vars','<input type="hidden" name="field" value="' . $field . '">');
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_name',lang('Field name'));
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_add',lang('Add'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_reset',lang('Clear Form'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_done',lang('Done'));
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('field_name',$field_name);
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('edithandle','');
|
|
|
|
$GLOBALS['egw']->template->set_var('addhandle','');
|
|
|
|
$GLOBALS['egw']->template->pparse('out','form');
|
|
|
|
$GLOBALS['egw']->template->pparse('addhandle','add');
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function edit()
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
if(!$GLOBALS['egw']->acl->check('run',1,'admin'))
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->common->phpgw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
2001-12-24 18:35:58 +01:00
|
|
|
echo lang('access not permitted');
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->common->phpgw_exit();
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
$field = stripslashes($_POST['field'] ? $_POST['field'] : $_GET['field']);
|
|
|
|
$field_name = stripslashes($_POST['field_name']);
|
|
|
|
$start = $_POST['start'] ? $_POST['start'] : $_GET['start'];
|
|
|
|
$query = $_POST['query'] ? $_POST['query'] : $_GET['query'];
|
|
|
|
$sort = $_POST['sort'] ? $_POST['sort'] : $_GET['sort'];
|
|
|
|
$submit = $_POST['submit'];
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!$field)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
Header('Location: ' . $GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.index&sort=$sort&query=$query&start=$start"));
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_file(array('form' => 'field_form.tpl'));
|
|
|
|
$GLOBALS['egw']->template->set_block('form','add','addhandle');
|
|
|
|
$GLOBALS['egw']->template->set_block('form','edit','edithandle');
|
2001-12-24 18:35:58 +01:00
|
|
|
|
|
|
|
$hidden_vars = '<input type="hidden" name="sort" value="' . $sort . '">' . "\n"
|
|
|
|
. '<input type="hidden" name="query" value="' . $query . '">' . "\n"
|
|
|
|
. '<input type="hidden" name="start" value="' . $start . '">' . "\n"
|
|
|
|
. '<input type="hidden" name="field" value="' . $field . '">' . "\n";
|
|
|
|
|
2002-01-17 04:52:56 +01:00
|
|
|
if($submit)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
|
|
|
$errorcount = 0;
|
2002-01-17 04:52:56 +01:00
|
|
|
if(!$field_name)
|
|
|
|
{
|
2003-04-27 23:13:00 +02:00
|
|
|
$error[$errorcount++] = lang('Please enter a name for that field !');
|
2002-01-17 04:52:56 +01:00
|
|
|
}
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2002-01-17 04:52:56 +01:00
|
|
|
if(!$error)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
|
|
|
$this->save_custom_field($field,$field_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->common->phpgw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2002-01-17 04:52:56 +01:00
|
|
|
if($errorcount)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('message',$GLOBALS['egw']->common->error_list($error));
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
2003-12-01 01:46:45 +01:00
|
|
|
if(($submit) && (!$error) && (!$errorcount))
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('message',lang('Field %1 has been updated !', $field_name));
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
2002-04-13 05:34:23 +02:00
|
|
|
if((!$submit) && (!$error) && (!$errorcount))
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('message','');
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
|
2002-01-17 04:52:56 +01:00
|
|
|
if($submit)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
|
|
|
$field = $field_name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$fields = $this->read_custom_fields($start,$limit,$field);
|
2005-05-01 16:34:59 +02:00
|
|
|
$field = $GLOBALS['egw']->strip_html($fields[0]['title']);
|
2002-04-13 05:34:23 +02:00
|
|
|
$fn = $fields[0]['name'];
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('title_fields',lang('Edit Custom Field'));
|
|
|
|
$GLOBALS['egw']->template->set_var('actionurl',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.edit'));
|
|
|
|
$GLOBALS['egw']->template->set_var('deleteurl',$GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.delete&field=$fn&start=$start&query=$query&sort=$sort"));
|
|
|
|
$GLOBALS['egw']->template->set_var('doneurl',$GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.index&start=$start&query=$query&sort=$sort"));
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('hidden_vars',$hidden_vars);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_name',lang('Field name'));
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_done',lang('Done'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_edit',lang('Edit'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_delete',lang('Delete'));
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('field_name',$field);
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('edithandle','');
|
|
|
|
$GLOBALS['egw']->template->set_var('addhandle','');
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->pparse('out','form');
|
|
|
|
$GLOBALS['egw']->template->pparse('edithandle','edit');
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function delete()
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
if(!$GLOBALS['egw']->acl->check('run',1,'admin'))
|
2002-04-13 05:34:23 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->common->phpgw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
2002-04-13 05:34:23 +02:00
|
|
|
echo lang('access not permitted');
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->common->phpgw_exit();
|
2002-04-13 05:34:23 +02:00
|
|
|
}
|
|
|
|
|
2005-03-02 03:50:42 +01:00
|
|
|
$field = urldecode($_POST['field'] ? $_POST['field'] : $_GET['field']);
|
2003-12-01 01:46:45 +01:00
|
|
|
$field_id = $_POST['field_id'] ? $_POST['field_id'] : $_GET['field_id'];
|
|
|
|
$start = $_POST['start'] ? $_POST['start'] : $_GET['start'];
|
|
|
|
$query = $_POST['query'] ? $_POST['query'] : $_GET['query'];
|
|
|
|
$sort = $_POST['sort'] ? $_POST['sort'] : $_GET['sort'];
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2002-01-17 04:52:56 +01:00
|
|
|
if(!$field)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
Header('Location: ' . $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.index'));
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($_POST['confirm'])
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
|
|
|
$this->save_custom_field($field);
|
2005-05-01 16:34:59 +02:00
|
|
|
Header('Location: ' . $GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.index&start=$start&query=$query&sort=$sort"));
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->common->phpgw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
2001-12-24 18:35:58 +01:00
|
|
|
|
|
|
|
$hidden_vars = '<input type="hidden" name="sort" value="' . $sort . '">' . "\n"
|
|
|
|
. '<input type="hidden" name="order" value="' . $order .'">' . "\n"
|
|
|
|
. '<input type="hidden" name="query" value="' . $query .'">' . "\n"
|
|
|
|
. '<input type="hidden" name="start" value="' . $start .'">' . "\n"
|
|
|
|
. '<input type="hidden" name="field" value="' . $field .'">' . "\n";
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_file(array('field_delete' => 'delete_common.tpl'));
|
|
|
|
$GLOBALS['egw']->template->set_var('messages',lang('Are you sure you want to delete this field?'));
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$nolinkf = $GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.index&field_id=$field_id&start=$start&query=$query&sort=$sort");
|
2001-12-24 18:35:58 +01:00
|
|
|
$nolink = '<a href="' . $nolinkf . '">' . lang('No') . '</a>';
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('no',$nolink);
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$yeslinkf = $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifieldsdelete&field_id=' . $field_id . '&confirm=True');
|
|
|
|
$yeslinkf = '<form method="POST" name="yesbutton" action="' . $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.delete') . '">'
|
2001-12-24 18:35:58 +01:00
|
|
|
. $hidden_vars
|
|
|
|
. '<input type="hidden" name="field_id" value="' . $field_id . '">'
|
|
|
|
. '<input type="hidden" name="confirm" value="True">'
|
|
|
|
. '<input type="submit" name="yesbutton" value="Yes">'
|
|
|
|
. '</form><script>document.yesbutton.yesbutton.focus()</script>';
|
|
|
|
|
|
|
|
$yeslink = '<a href="' . $yeslinkf . '">' . lang('Yes') . '</a>';
|
|
|
|
$yeslink = $yeslinkf;
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('yes',$yeslink);
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->pparse('out','field_delete');
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-13 05:34:23 +02:00
|
|
|
function read_custom_fields($start=0,$limit=5,$query='')
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2002-04-13 05:34:23 +02:00
|
|
|
$i = 0;
|
2001-12-24 18:35:58 +01:00
|
|
|
$fields = array();
|
2002-04-13 05:34:23 +02:00
|
|
|
|
|
|
|
$this->config->read_repository();
|
|
|
|
|
|
|
|
while(list($name,$descr) = @each($this->config->config_data['custom_fields']))
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2002-04-13 05:34:23 +02:00
|
|
|
/*
|
|
|
|
if($start < $i)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2002-04-13 05:34:23 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
*/
|
2001-12-24 18:35:58 +01:00
|
|
|
|
2002-04-13 05:34:23 +02:00
|
|
|
$test = @strtolower($name);
|
|
|
|
//if($query && !strstr($test,strtolower($query)))
|
|
|
|
if($query && ($query != $test))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$fields[$i]['name'] = $name;
|
|
|
|
$fields[$i]['title'] = $descr;
|
|
|
|
$fields[$i]['id'] = $i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
if($i >= $limit)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2002-04-13 05:34:23 +02:00
|
|
|
break;
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
2002-04-13 05:34:23 +02:00
|
|
|
*/
|
|
|
|
$i++;
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
2002-04-13 05:34:23 +02:00
|
|
|
}
|
|
|
|
switch($sort)
|
|
|
|
{
|
|
|
|
case 'DESC';
|
|
|
|
krsort($fields);
|
|
|
|
break;
|
|
|
|
case 'ASC':
|
|
|
|
default:
|
|
|
|
ksort($fields);
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
@reset($fields);
|
2002-04-13 05:34:23 +02:00
|
|
|
|
2001-12-24 18:35:58 +01:00
|
|
|
return $fields;
|
|
|
|
}
|
|
|
|
|
|
|
|
function save_custom_field($old='',$new='')
|
|
|
|
{
|
2002-04-13 05:34:23 +02:00
|
|
|
$this->config->read_repository();
|
|
|
|
|
|
|
|
if(!is_array($this->config->config_data['custom_fields']))
|
|
|
|
{
|
|
|
|
$this->config->config_data['custom_fields'] = array();
|
|
|
|
}
|
|
|
|
|
2002-01-17 04:52:56 +01:00
|
|
|
if($old)
|
2001-12-24 18:35:58 +01:00
|
|
|
{
|
2002-04-13 05:34:23 +02:00
|
|
|
unset($this->config->config_data['custom_fields'][$old]);
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
if($new)
|
|
|
|
{
|
2003-12-19 10:27:23 +01:00
|
|
|
$tmp = strtolower(str_replace(' ','_',$new));
|
2002-04-13 05:34:23 +02:00
|
|
|
$this->config->config_data['custom_fields'][$tmp] = $new;
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
2002-04-13 05:34:23 +02:00
|
|
|
|
|
|
|
$this->config->save_repository();
|
2001-12-24 18:35:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|