From 6c91a354e094e662541a0a86bd2e236ad94033ed Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Sat, 21 Apr 2001 14:51:25 +0000 Subject: [PATCH] Add functions to edit custom fields --- addressbook/inc/functions.inc.php | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/addressbook/inc/functions.inc.php b/addressbook/inc/functions.inc.php index 35a2a4d3cd..eeaed23aea 100755 --- a/addressbook/inc/functions.inc.php +++ b/addressbook/inc/functions.inc.php @@ -33,6 +33,52 @@ } } + function read_custom_fields($start='',$limit='',$query='',$sort='ASC') + { + global $phpgw,$phpgw_info; + $phpgw->preferences->read_repository($phpgw_info['user']['account_id']); + + $i=0;$j=0; + while (list($col,$descr) = each($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 "
".$j.": '".$fields[$j]['name']."'"; + $j++; + } + } + $i++; + } + return $fields; + } + + function save_custom_field($old='',$new='') + { + global $phpgw,$phpgw_info; + + $phpgw->preferences->read_repository($phpgw_info['user']['account_id']); + if ($old) + { + $phpgw->preferences->delete("addressbook","extra_".$old); + } + if($new) + { + $phpgw->preferences->add("addressbook","extra_".$new); + } + $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) { global $phpgw_info;