[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: addressbook/inc class.uiaddressbook.inc.php,1.41
From: |
Miles Lott <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: addressbook/inc class.uiaddressbook.inc.php,1.41,1.42 class.uifields.inc.php,1.4,1.5 |
Date: |
Fri, 12 Apr 2002 23:34:25 -0400 |
Update of /cvsroot/phpgroupware/addressbook/inc
In directory subversions:/tmp/cvs-serv3371/addressbook/inc
Modified Files:
class.uiaddressbook.inc.php class.uifields.inc.php
Log Message:
Fix for addressbook custom fields
Index: class.uiaddressbook.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.uiaddressbook.inc.php,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -r1.41 -r1.42
*** class.uiaddressbook.inc.php 19 Mar 2002 02:44:15 -0000 1.41
--- class.uiaddressbook.inc.php 13 Apr 2002 03:34:23 -0000 1.42
***************
*** 57,60 ****
--- 57,61 ----
$GLOBALS['phpgw']->browser =
CreateObject('phpgwapi.browser');
$GLOBALS['phpgw']->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->fields = CreateObject('addressbook.uifields');
$this->bo =
CreateObject('addressbook.boaddressbook',True);
***************
*** 138,173 ****
}
- function read_custom_fields()
- {
- $fields = array();
- @reset($this->prefs);
- while(list($col,$descr) = @each($this->prefs))
- {
- $tmp = '';
- if(substr($col,0,6) == 'extra_')
- {
- $tmp = ereg_replace('extra_','',$col);
- $tmp = ereg_replace(' ','_',$tmp);
- $fields[$tmp] = $tmp;
- }
- }
- @reset($fields);
- return $fields;
- }
-
- function save_custom_field($old='',$new='')
- {
-
$GLOBALS['phpgw']->preferences->read_repository($GLOBALS['phpgw_info']['user']['account_id']);
- if($old)
- {
-
$GLOBALS['phpgw']->preferences->delete('addressbook','extra_' . $old);
- }
- if($new)
- {
-
$GLOBALS['phpgw']->preferences->add('addressbook','extra_' . $new);
- }
- $GLOBALS['phpgw']->preferences->save_repository(1);
- }
-
/* Return a select form element with the categories option
dialog in it */
function
cat_option($cat_id='',$notall=False,$java=True,$multiple=False)
--- 139,142 ----
***************
*** 300,304 ****
$this->template->set_block('addressbook_list_t','addressbook_footer','addressbook_footer');
! $customfields = $this->read_custom_fields();
if(!isset($this->cat_id))
--- 269,279 ----
$this->template->set_block('addressbook_list_t','addressbook_footer','addressbook_footer');
! $custom = $this->fields->read_custom_fields();
! $customfields = array();
! while(list($x,$y) = @each($custom))
! {
! $customfields[$y['name']] = $y['name'];
! $namedfields[$y['name']] = $y['title'];
! }
if(!isset($this->cat_id))
***************
*** 344,348 ****
if(!$showcol)
{
! $showcol = $column[1];
}
$cols .= ' <td height="21">' . "\n";
--- 319,323 ----
if(!$showcol)
{
! $showcol =
$namedfields[$column[1]];
}
$cols .= ' <td height="21">' . "\n";
***************
*** 364,368 ****
'org_name' => 'org_name'
);
! $columns_to_display = $columns_to_display +
$customfields;
/* No prefs,. so cols above may have been set
to '' or a bunch of <td></td> */
$cols='';
--- 339,343 ----
'org_name' => 'org_name'
);
! // $columns_to_display = $columns_to_display +
$customfields;
/* No prefs,. so cols above may have been set
to '' or a bunch of <td></td> */
$cols='';
***************
*** 705,709 ****
echo parse_navbar();
!
$this->addressbook_form('','menuaction=addressbook.uiaddressbook.add','Add','',$customfields,$this->cat_id,True);
$this->template->set_var('lang_ok',lang('ok'));
--- 680,690 ----
echo parse_navbar();
! $custom = $this->fields->read_custom_fields();
! while(list($x,$y) = @each($custom))
! {
! $customfields[$y['name']] = $y['title'];
! }
!
!
$this->addressbook_form('','menuaction=addressbook.uiaddressbook.add','Add','',$customfields,$this->cat_id);
$this->template->set_var('lang_ok',lang('ok'));
***************
*** 759,763 ****
/* Read in user custom fields, if any */
! $customfields = $this->read_custom_fields();
/* merge in extra fields */
--- 740,748 ----
/* Read in user custom fields, if any */
! $custom = $this->fields->read_custom_fields();
! while(list($x,$y) = @each($custom))
! {
! $customfields[$y['name']] = $y['title'];
! }
/* merge in extra fields */
***************
*** 868,872 ****
$this->template->set_block('view_t','view_buttons','view_buttons');
! $customfields = $this->read_custom_fields();
/* _debug_array($this->prefs); */
while(list($column,$x) =
each($this->contacts->stock_contact_fields))
--- 853,862 ----
$this->template->set_block('view_t','view_buttons','view_buttons');
! $custom = $this->fields->read_custom_fields();
! while(list($x,$y) = @each($custom))
! {
! $customfields[$y['name']] = $y['title'];
! }
!
/* _debug_array($this->prefs); */
while(list($column,$x) =
each($this->contacts->stock_contact_fields))
***************
*** 1096,1100 ****
/* _debug_array($this->prefs); */
! $customfields = $this->read_custom_fields();
$qfields = $this->contacts->stock_contact_fields +
$this->extrafields + $customfields;
--- 1086,1094 ----
/* _debug_array($this->prefs); */
! $custom = $this->fields->read_custom_fields();
! while(list($x,$y) = @each($custom))
! {
! $customfields[$y['name']] = $y['name'];
! }
$qfields = $this->contacts->stock_contact_fields +
$this->extrafields + $customfields;
Index: class.uifields.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.uifields.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** class.uifields.inc.php 17 Jan 2002 03:52:56 -0000 1.4
--- class.uifields.inc.php 13 Apr 2002 03:34:23 -0000 1.5
***************
*** 3,7 ****
* phpGroupWare - Addressbook *
* http://www.phpgroupware.org *
! * Written by Bettina Gille address@hidden *
* ----------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
--- 3,8 ----
* phpGroupWare - Addressbook *
* http://www.phpgroupware.org *
! * Written by Joseph Engo <address@hidden> and *
! * Miles Lott <miloschphpgroupware.org> *
* ----------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
***************
*** 10,13 ****
--- 11,15 ----
* option) any later version. *
\**************************************************************************/
+
/* $Id$ */
***************
*** 25,28 ****
--- 27,31 ----
$GLOBALS['phpgw']->template =
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$GLOBALS['phpgw']->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->config =
CreateObject('phpgwapi.config','addressbook');
}
***************
*** 34,38 ****
echo parse_navbar();
echo lang('access not permitted');
- $GLOBALS['phpgw']->common->phpgw_footer();
$GLOBALS['phpgw']->common->phpgw_exit();
}
--- 37,40 ----
***************
*** 45,53 ****
$field = $GLOBALS['HTTP_POST_VARS']['field'];
! $start = $GLOBALS['HTTP_POST_VARS']['start'];
! $query = $GLOBALS['HTTP_POST_VARS']['query'];
! $sort = $GLOBALS['HTTP_POST_VARS']['sort'];
! $order = $GLOBALS['HTTP_POST_VARS']['order'];
! $filter = $GLOBALS['HTTP_POST_VARS']['filter'];
$common_hidden_vars =
--- 47,53 ----
$field = $GLOBALS['HTTP_POST_VARS']['field'];
! $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'];
$common_hidden_vars =
***************
*** 77,81 ****
}
! $fields =
$this->read_custom_fields($start,$limit,$query,$sort,$order);
$total_records = count($fields);
--- 77,81 ----
}
! $fields =
$this->read_custom_fields($start,$limit,$query,$sort);
$total_records = count($fields);
***************
*** 99,104 ****
$field = $fields[$i]['name'];
!
$GLOBALS['phpgw']->template->set_var('cfield',$field);
$GLOBALS['phpgw']->template->set_var('edit',$GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uifields.edit&field=$field&start=$start&query=$query&sort=$sort&order=$order&filter=$filter"));
--- 99,105 ----
$field = $fields[$i]['name'];
+ $title = $fields[$i]['title'];
!
$GLOBALS['phpgw']->template->set_var('cfield',$title);
$GLOBALS['phpgw']->template->set_var('edit',$GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uifields.edit&field=$field&start=$start&query=$query&sort=$sort&order=$order&filter=$filter"));
***************
*** 112,117 ****
$GLOBALS['phpgw']->template->parse('out','field_list_t',True);
$GLOBALS['phpgw']->template->p('out');
-
- $GLOBALS['phpgw']->common->phpgw_footer();
}
--- 113,116 ----
***************
*** 123,127 ****
echo parse_navbar();
echo lang('access not permitted');
- $GLOBALS['phpgw']->common->phpgw_footer();
$GLOBALS['phpgw']->common->phpgw_exit();
}
--- 122,125 ----
***************
*** 132,135 ****
--- 130,134 ----
$query = $GLOBALS['HTTP_POST_VARS']['query'];
$sort = $GLOBALS['HTTP_POST_VARS']['sort'];
+ $submit = $GLOBALS['HTTP_POST_VARS']['submit'];
$GLOBALS['phpgw']->template->set_file(array('form' =>
'field_form.tpl'));
***************
*** 137,141 ****
$GLOBALS['phpgw']->template->set_block('form','edit','edithandle');
! if($GLOBALS['HTTP_POST_VARS']['submit'])
{
$errorcount = 0;
--- 136,140 ----
$GLOBALS['phpgw']->template->set_block('form','edit','edithandle');
! if($submit)
{
$errorcount = 0;
***************
*** 170,174 ****
$GLOBALS['phpgw']->template->set_var('message',lang('Field x has been added !',
$field_name));
}
! if((! $submit) && (! $error) && (! $errorcount))
{
$GLOBALS['phpgw']->template->set_var('message','');
--- 169,173 ----
$GLOBALS['phpgw']->template->set_var('message',lang('Field x has been added !',
$field_name));
}
! if((!$submit) && (! $error) && (! $errorcount))
{
$GLOBALS['phpgw']->template->set_var('message','');
***************
*** 201,205 ****
echo parse_navbar();
echo lang('access not permitted');
- $GLOBALS['phpgw']->common->phpgw_footer();
$GLOBALS['phpgw']->common->phpgw_exit();
}
--- 200,203 ----
***************
*** 212,216 ****
$submit = $GLOBALS['HTTP_POST_VARS']['submit'];
! if(!$field)
{
Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uifields.index&sort=$sort&query=$query&start=$start"));
--- 210,214 ----
$submit = $GLOBALS['HTTP_POST_VARS']['submit'];
! if (!$field)
{
Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uifields.index&sort=$sort&query=$query&start=$start"));
***************
*** 249,257 ****
$GLOBALS['phpgw']->template->set_var('message',$GLOBALS['phpgw']->common->error_list($error));
}
! if(($submit) && (! $error) && (! $errorcount))
{
$GLOBALS['phpgw']->template->set_var('message',lang('Field x has been updated
!', $field_name));
}
! if((!$submit) && (! $error) && (! $errorcount))
{
$GLOBALS['phpgw']->template->set_var('message','');
--- 247,255 ----
$GLOBALS['phpgw']->template->set_var('message',$GLOBALS['phpgw']->common->error_list($error));
}
! if(($submit) && (! $error) && (!$errorcount))
{
$GLOBALS['phpgw']->template->set_var('message',lang('Field x has been updated
!', $field_name));
}
! if((!$submit) && (!$error) && (!$errorcount))
{
$GLOBALS['phpgw']->template->set_var('message','');
***************
*** 265,274 ****
{
$fields =
$this->read_custom_fields($start,$limit,$field);
! $field =
$GLOBALS['phpgw']->strip_html($fields[0]['name']);
}
$GLOBALS['phpgw']->template->set_var('title_fields',lang('Edit Custom Field'));
$GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uifields.edit'));
!
$GLOBALS['phpgw']->template->set_var('deleteurl',$GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uifields.delete&field=$field&start=$start&query=$query&sort=$sort"));
$GLOBALS['phpgw']->template->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uifields.index&start=$start&query=$query&sort=$sort"));
--- 263,273 ----
{
$fields =
$this->read_custom_fields($start,$limit,$field);
! $field =
$GLOBALS['phpgw']->strip_html($fields[0]['title']);
! $fn = $fields[0]['name'];
}
$GLOBALS['phpgw']->template->set_var('title_fields',lang('Edit Custom Field'));
$GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uifields.edit'));
!
$GLOBALS['phpgw']->template->set_var('deleteurl',$GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uifields.delete&field=$fn&start=$start&query=$query&sort=$sort"));
$GLOBALS['phpgw']->template->set_var('doneurl',$GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uifields.index&start=$start&query=$query&sort=$sort"));
***************
*** 291,294 ****
--- 290,301 ----
function delete()
{
+ if(!$GLOBALS['phpgw']->acl->check('run',1,'admin'))
+ {
+ $GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
+ echo lang('access not permitted');
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ }
+
$field = $GLOBALS['HTTP_POST_VARS']['field'] ?
$GLOBALS['HTTP_POST_VARS']['field'] : $GLOBALS['HTTP_GET_VARS']['field'];
$field_id = $GLOBALS['HTTP_POST_VARS']['field_id'] ?
$GLOBALS['HTTP_POST_VARS']['field_id'] : $GLOBALS['HTTP_GET_VARS']['field_id'];
***************
*** 341,371 ****
}
! function read_custom_fields()
{
! $i = 0; $j = 0;
$fields = array();
!
@reset($GLOBALS['phpgw_info']['user']['preferences']['addressbook']);
! while(list($col,$descr) =
@each($GLOBALS['phpgw_info']['user']['preferences']['addressbook']))
{
! if(substr($col,0,6) == 'extra_')
{
! $fields[$j]['name'] =
ereg_replace('extra_','',$col);
! $fields[$j]['name'] = ereg_replace('
','_',$fields[$j]['name']);
! $fields[$j]['id'] = $i;
! if($query && ($fields[$j]['name'] !=
$query))
! {
! unset($fields[$j]['name']);
! unset($fields[$j]['id']);
! }
! else
{
! /* echo "<br>".$j.":
'".$fields[$j]['name']."'"; */
! $j++;
}
}
! $i++;
}
@reset($fields);
return $fields;
}
--- 348,398 ----
}
! function read_custom_fields($start=0,$limit=5,$query='')
{
! $i = 0;
$fields = array();
!
! $this->config->read_repository();
!
! while(list($name,$descr) =
@each($this->config->config_data['custom_fields']))
{
! /*
! if($start < $i)
{
! continue;
! }
! */
! $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)
{
! break;
}
+ */
+ $i++;
}
! }
! switch($sort)
! {
! case 'DESC';
! krsort($fields);
! break;
! case 'ASC':
! default:
! ksort($fields);
}
@reset($fields);
+
return $fields;
}
***************
*** 373,386 ****
function save_custom_field($old='',$new='')
{
!
$GLOBALS['phpgw']->preferences->read_repository($GLOBALS['phpgw_info']['user']['account_id']);
if($old)
{
!
$GLOBALS['phpgw']->preferences->delete("addressbook","extra_".$old);
}
if($new)
{
!
$GLOBALS['phpgw']->preferences->add("addressbook","extra_".$new);
}
! $GLOBALS['phpgw']->preferences->save_repository(1);
}
}
--- 400,421 ----
function save_custom_field($old='',$new='')
{
! $this->config->read_repository();
!
!
if(!is_array($this->config->config_data['custom_fields']))
! {
! $this->config->config_data['custom_fields'] =
array();
! }
!
if($old)
{
!
unset($this->config->config_data['custom_fields'][$old]);
}
if($new)
{
! $tmp = strtolower(ereg_replace(' ','_',$new));
!
$this->config->config_data['custom_fields'][$tmp] = $new;
}
!
! $this->config->save_repository();
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: addressbook/inc class.uiaddressbook.inc.php,1.41,1.42 class.uifields.inc.php,1.4,1.5,
Miles Lott <address@hidden> <=