autoloading of addressbook classes

This commit is contained in:
Ralf Becker 2008-05-10 12:06:15 +00:00
parent 7a2e1a66e2
commit 4885518b88
4 changed files with 86 additions and 90 deletions

View File

@ -8,16 +8,14 @@
* @subpackage api * @subpackage api
* @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
require_once(EGW_API_INC.'/class.html.inc.php');
/** /**
* Abstract base class for trackering: * Abstract base class for trackering:
* - logging all modifications of an entry * - logging all modifications of an entry
* - notifying users about changes in an entry * - notifying users about changes in an entry
* *
* You need to extend these class in your application: * You need to extend these class in your application:
* 1. set the required class-vars: app, id_field * 1. set the required class-vars: app, id_field
* 2. optional set class-vars: creator_field, assigned_field, check2prefs * 2. optional set class-vars: creator_field, assigned_field, check2prefs
@ -72,13 +70,13 @@ class bo_tracking
var $prefer_user_as_sender = true; var $prefer_user_as_sender = true;
/** /**
* Should the current user be email-notified (about change he made himself) * Should the current user be email-notified (about change he made himself)
* *
* Popup notifications are never send to the current user! * Popup notifications are never send to the current user!
* *
* @var boolean * @var boolean
*/ */
var $notify_current_user = false; var $notify_current_user = false;
/** /**
* Array with error-messages if track($data,$old) returns false * Array with error-messages if track($data,$old) returns false
* *
@ -93,10 +91,10 @@ class bo_tracking
* @var historylog * @var historylog
*/ */
var $historylog; var $historylog;
/** /**
* Current user, can be set via bo_tracking::track(,,$user) * Current user, can be set via bo_tracking::track(,,$user)
* *
* @access private * @access private
* @var int; * @var int;
*/ */
@ -122,27 +120,32 @@ class bo_tracking
var $tz_offset_s; var $tz_offset_s;
/** /**
* Should the class allow html content (for notifications) * Should the class allow html content (for notifications)
* *
* @var boolean * @var boolean
*/ */
var $html_content_allow = false; var $html_content_allow = false;
/** /**
* Constructor * Constructor
* *
* @return bo_tracking * @return bo_tracking
*/ */
function bo_tracking() function __construct()
{ {
} }
function bo_tracking()
{
self::__construct
}
/** /**
* Get a config value, which can depend on $data and $old * Get a config value, which can depend on $data and $old
* *
* Need to be implemented in your extended tracking class! * Need to be implemented in your extended tracking class!
* *
* @abstract * @abstract
* @param string $what possible values are: * @param string $what possible values are:
* - 'copy' array of email addresses notifications should be copied too, can depend on $data * - 'copy' array of email addresses notifications should be copied too, can depend on $data
* - 'lang' string lang code for copy mail * - 'lang' string lang code for copy mail
@ -153,9 +156,9 @@ class bo_tracking
*/ */
function get_config($name,$data,$old=null) function get_config($name,$data,$old=null)
{ {
die('You need to extend the bo_tracking class, to be able to use it (abstract base class)!'); die('You need to extend the bo_tracking class, to be able to use it (abstract base class)!');
} }
/** /**
* Tracks the changes in one entry $data, by comparing it with the last version in $old * Tracks the changes in one entry $data, by comparing it with the last version in $old
* *
@ -182,7 +185,7 @@ class bo_tracking
} }
return $changes; return $changes;
} }
/** /**
* Save changes to the history log * Save changes to the history log
* *
@ -212,7 +215,7 @@ class bo_tracking
} }
return $changes; return $changes;
} }
/** /**
* sending all notifications for the changed entry * sending all notifications for the changed entry
* *
@ -234,10 +237,10 @@ class bo_tracking
// entry creator // entry creator
if ($this->creator_field && ($email = $GLOBALS['egw']->accounts->id2name($data[$this->creator_field],'account_email')) && if ($this->creator_field && ($email = $GLOBALS['egw']->accounts->id2name($data[$this->creator_field],'account_email')) &&
!in_array($email, $email_sent)) !in_array($email, $email_sent))
{ {
$this->send_notification($data,$old,$email,$data[$this->creator_field],'notify_creator'); $this->send_notification($data,$old,$email,$data[$this->creator_field],'notify_creator');
$email_sent[] = $email; $email_sent[] = $email;
} }
// assigned / responsible users // assigned / responsible users
@ -247,12 +250,12 @@ class bo_tracking
$assignees = $old_assignees = array(); $assignees = $old_assignees = array();
if ($data[$this->assigned_field]) // current assignments if ($data[$this->assigned_field]) // current assignments
{ {
$assignees = is_array($data[$this->assigned_field]) ? $assignees = is_array($data[$this->assigned_field]) ?
$data[$this->assigned_field] : explode(',',$data[$this->assigned_field]); $data[$this->assigned_field] : explode(',',$data[$this->assigned_field]);
} }
if ($old && $old[$this->assigned_field]) if ($old && $old[$this->assigned_field])
{ {
$old_assignees = is_array($old[$this->assigned_field]) ? $old_assignees = is_array($old[$this->assigned_field]) ?
$old[$this->assigned_field] : explode(',',$old[$this->assigned_field]); $old[$this->assigned_field] : explode(',',$old[$this->assigned_field]);
} }
foreach(array_unique(array_merge($assignees,$old_assignees)) as $assignee) foreach(array_unique(array_merge($assignees,$old_assignees)) as $assignee)
@ -267,7 +270,7 @@ class bo_tracking
{ {
$this->send_notification($data,$old,$email,$assignee,'notify_assigned', $this->send_notification($data,$old,$email,$assignee,'notify_assigned',
in_array($assignee,$assignees) !== in_array($assignee,$old_assignees) || $deleted); // assignment changed in_array($assignee,$assignees) !== in_array($assignee,$old_assignees) || $deleted); // assignment changed
$email_sent[] = $email; $email_sent[] = $email;
} }
} }
else // item assignee is a group else // item assignee is a group
@ -291,7 +294,7 @@ class bo_tracking
$lang = $this->get_config('lang',$data,$old); $lang = $this->get_config('lang',$data,$old);
foreach($copies as $email) foreach($copies as $email)
{ {
if (strchr($email,'@') !== false && !in_array($email, $email_sent)) if (strchr($email,'@') !== false && !in_array($email, $email_sent))
{ {
$this->send_notification($data,$old,$email,$lang,'notify_copy'); $this->send_notification($data,$old,$email,$lang,'notify_copy');
$email_sent[] = $email; $email_sent[] = $email;
@ -303,14 +306,14 @@ class bo_tracking
if ($this->save_prefs) $GLOBALS['egw_info']['user'] = $this->save_prefs; unset($this->save_prefs); if ($this->save_prefs) $GLOBALS['egw_info']['user'] = $this->save_prefs; unset($this->save_prefs);
if ($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != $GLOBALS['egw']->translation->userlang) if ($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != $GLOBALS['egw']->translation->userlang)
{ {
$GLOBALS['egw']->translation->init(); $GLOBALS['egw']->translation->init();
} }
return !count($this->errors); return !count($this->errors);
} }
/** /**
* Sending a notification to the given email-address * Sending a notification to the given email-address
* *
* Called by track() or externally for sending async notifications * Called by track() or externally for sending async notifications
* *
* @param array $data current entry * @param array $data current entry
@ -327,7 +330,7 @@ class bo_tracking
if (!$email) return false; if (!$email) return false;
if (!$this->save_prefs) $this->save_prefs = $GLOBALS['egw_info']['user']; if (!$this->save_prefs) $this->save_prefs = $GLOBALS['egw_info']['user'];
if (is_numeric($user_or_lang)) // user --> read everything from his prefs if (is_numeric($user_or_lang)) // user --> read everything from his prefs
{ {
if ($user_or_lang != $this->user) if ($user_or_lang != $this->user)
@ -345,7 +348,7 @@ class bo_tracking
return false; // only notification about changed assignment requested return false; // only notification about changed assignment requested
} }
if($this->user == $user_or_lang && !$this->notify_current_user) if($this->user == $user_or_lang && !$this->notify_current_user)
{ {
return false; // no popup for own actions return false; // no popup for own actions
} }
} }
@ -359,7 +362,7 @@ class bo_tracking
{ {
$GLOBALS['egw']->translation->init(); $GLOBALS['egw']->translation->init();
} }
// send over notification_app // send over notification_app
if ($GLOBALS['egw_info']['apps']['notifications']['enabled']) { if ($GLOBALS['egw_info']['apps']['notifications']['enabled']) {
// send via notification_app // send via notification_app
@ -383,10 +386,10 @@ class bo_tracking
} else { } else {
error_log('tracking: cannot send any notifications because notifications is not installed'); error_log('tracking: cannot send any notifications because notifications is not installed');
} }
return true; return true;
} }
/** /**
* Return date+time formatted for the currently notified user (prefs in $GLOBALS['egw_info']['user']['preferences']) * Return date+time formatted for the currently notified user (prefs in $GLOBALS['egw_info']['user']['preferences'])
* *
@ -406,13 +409,13 @@ class bo_tracking
//error_log("bo_tracking::datetime($timestamp,$do_time)=date('$format',$timestamp+$this->tz_offset_s)='".date($format,$timestamp+$this->tz_offset_s).'\')'); //error_log("bo_tracking::datetime($timestamp,$do_time)=date('$format',$timestamp+$this->tz_offset_s)='".date($format,$timestamp+$this->tz_offset_s).'\')');
return date($format,$timestamp+3600 * $GLOBALS['egw_info']['user']['preferences']['common']['tz_offset']); return date($format,$timestamp+3600 * $GLOBALS['egw_info']['user']['preferences']['common']['tz_offset']);
} }
/** /**
* Get sender address * Get sender address
* *
* The default implementation prefers depending on the prefer_user_as_sender class-var the user over * The default implementation prefers depending on the prefer_user_as_sender class-var the user over
* what is returned by get_config('sender'). * what is returned by get_config('sender').
* *
* @param int $user account_lid of user * @param int $user account_lid of user
* @param array $data * @param array $data
* @param array $old * @param array $old
@ -424,11 +427,11 @@ class bo_tracking
$sender = $this->get_config('sender',$data,$old); $sender = $this->get_config('sender',$data,$old);
//echo "<p>bo_tracking::get_sender() get_config('sender',...)='".htmlspecialchars($sender)."'</p>\n"; //echo "<p>bo_tracking::get_sender() get_config('sender',...)='".htmlspecialchars($sender)."'</p>\n";
if (($this->prefer_user_as_sender || !$sender) && $this->user && if (($this->prefer_user_as_sender || !$sender) && $this->user &&
($email = $GLOBALS['egw']->accounts->id2name($this->user,'account_email'))) ($email = $GLOBALS['egw']->accounts->id2name($this->user,'account_email')))
{ {
$name = $GLOBALS['egw']->accounts->id2name($this->user,'account_fullname'); $name = $GLOBALS['egw']->accounts->id2name($this->user,'account_fullname');
if($prefer_id) { if($prefer_id) {
$sender = $this->user; $sender = $this->user;
} else { } else {
@ -442,7 +445,7 @@ class bo_tracking
//echo "<p>bo_tracking::get_sender()='".htmlspecialchars($sender)."'</p>\n"; //echo "<p>bo_tracking::get_sender()='".htmlspecialchars($sender)."'</p>\n";
return $sender; return $sender;
} }
/** /**
* Get the title for a given entry, can be reimplemented * Get the title for a given entry, can be reimplemented
* *
@ -457,7 +460,7 @@ class bo_tracking
/** /**
* Get the subject for a given entry, can be reimplemented * Get the subject for a given entry, can be reimplemented
* *
* Default implementation uses the link-title * Default implementation uses the link-title
* *
* @param array $data * @param array $data
@ -471,7 +474,7 @@ class bo_tracking
/** /**
* Get the modified / new message (1. line of mail body) for a given entry, can be reimplemented * Get the modified / new message (1. line of mail body) for a given entry, can be reimplemented
* *
* Default implementation does nothing * Default implementation does nothing
* *
* @param array $data * @param array $data
@ -485,7 +488,7 @@ class bo_tracking
/** /**
* Get a link to view the entry, can be reimplemented * Get a link to view the entry, can be reimplemented
* *
* Default implementation checks get_config('link') (appending the id) or link::view($this->app,$id) * Default implementation checks get_config('link') (appending the id) or link::view($this->app,$id)
* *
* @param array $data * @param array $data
@ -519,12 +522,12 @@ class bo_tracking
{ {
// remove the session-id in the notification mail! // remove the session-id in the notification mail!
$link = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',$link); $link = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',$link);
if ($popup) $link .= '&nopopup=1'; if ($popup) $link .= '&nopopup=1';
} }
return $allow_popup ? array($link,$popup) : $link; return $allow_popup ? array($link,$popup) : $link;
} }
/** /**
* Get a link for notifications to view the entry, can be reimplemented * Get a link for notifications to view the entry, can be reimplemented
* *
@ -545,8 +548,8 @@ class bo_tracking
); );
} }
return false; return false;
} }
/** /**
* Get the body of the notification message, can be reimplemented * Get the body of the notification message, can be reimplemented
* *
@ -560,7 +563,7 @@ class bo_tracking
{ {
$body = ''; $body = '';
if ($html_email) if ($html_email)
{ {
$body = '<table cellspacing="2" cellpadding="0" border="0" width="100%">'."\n"; $body = '<table cellspacing="2" cellpadding="0" border="0" width="100%">'."\n";
} }
// new or modified message // new or modified message
@ -579,7 +582,7 @@ class bo_tracking
$modified = $old && $data[$name] != $old[$name] && !(!$data[$name] && !$old[$name]); $modified = $old && $data[$name] != $old[$name] && !(!$data[$name] && !$old[$name]);
//if ($modified) error_log("data[$name]=".print_r($data[$name],true).", old[$name]=".print_r($old[$name],true)." --> modified=".(int)$modified); //if ($modified) error_log("data[$name]=".print_r($data[$name],true).", old[$name]=".print_r($old[$name],true)." --> modified=".(int)$modified);
if (empty($detail['value']) && !$modified) continue; // skip unchanged, empty values if (empty($detail['value']) && !$modified) continue; // skip unchanged, empty values
$body .= $this->format_line($html_email,$detail['type'],$modified, $body .= $this->format_line($html_email,$detail['type'],$modified,
($detail['label'] ? $detail['label'].': ':'').$detail['value']); ($detail['label'] ? $detail['label'].': ':'').$detail['value']);
} }
@ -587,14 +590,14 @@ class bo_tracking
{ {
$body .= "</table>\n"; $body .= "</table>\n";
} }
return $body; return $body;
} }
/** /**
* Format one line to the mail body * Format one line to the mail body
* *
* @internal * @internal
* @param boolean $html_mail * @param boolean $html_mail
* @param string $type 'link', 'message', 'summary', 'multiline', 'reply' and ''=regular content * @param string $type 'link', 'message', 'summary', 'multiline', 'reply' and ''=regular content
* @param boolean $modified mark field as modified * @param boolean $modified mark field as modified
@ -605,7 +608,7 @@ class bo_tracking
function format_line($html_mail,$type,$modified,$line,$link=null) function format_line($html_mail,$type,$modified,$line,$link=null)
{ {
$content = ''; $content = '';
if ($html_mail) if ($html_mail)
{ {
if (!$this->html_content_allow) $line = html::htmlspecialchars($line); // XSS if (!$this->html_content_allow) $line = html::htmlspecialchars($line); // XSS
@ -630,24 +633,24 @@ class bo_tracking
case 'multiline': case 'multiline':
// Only Convert nl2br on non-html content // Only Convert nl2br on non-html content
$pos = strpos($line, '<br'); $pos = strpos($line, '<br');
if ($pos===false) if ($pos===false)
{ {
$line = nl2br($line); $line = nl2br($line);
} }
break; break;
case 'reply': case 'reply':
$background = '#F1F1F1'; $background = '#F1F1F1';
break; break;
default: default:
$size = '100%'; $size = '100%';
} }
$style = ($bold ? 'font-weight:bold;' : '').($size ? 'font-size:'.$size.';' : '').($color?'color:'.$color:''); $style = ($bold ? 'font-weight:bold;' : '').($size ? 'font-size:'.$size.';' : '').($color?'color:'.$color:'');
$content = '<tr style="background-color: '.$background.';"><td style="'.$style.'">'; $content = '<tr style="background-color: '.$background.';"><td style="'.$style.'">';
} }
else // text-mail else // text-mail
{ {
if ($type == 'reply') $content = str_repeat('-',64)."\n"; if ($type == 'reply') $content = str_repeat('-',64)."\n";
if ($modified) $content .= '> '; if ($modified) $content .= '> ';
} }
@ -656,7 +659,7 @@ class bo_tracking
if ($link) if ($link)
{ {
$content .= ' '; $content .= ' ';
if ($html_mail) if ($html_mail)
{ {
// the link is often too long for html boxes // the link is often too long for html boxes
@ -669,12 +672,12 @@ class bo_tracking
} }
} }
if ($html_mail) $content .= '</td></tr>'; if ($html_mail) $content .= '</td></tr>';
$content .= "\n"; $content .= "\n";
return $content; return $content;
} }
/** /**
* Get the attachments for a notification * Get the attachments for a notification
* *

View File

@ -983,6 +983,10 @@ class etemplate extends boetemplate
} }
$extra_label = True; $extra_label = True;
if (strchr($cell['onchange'],'$') || $cell['onchange']{0} == '@')
{
$cell['onchange'] = $this->expand_name($cell['onchange'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
}
// the while loop allows to build extensions from other extensions // the while loop allows to build extensions from other extensions
// please note: only the first extension's post_process function is called !!! // please note: only the first extension's post_process function is called !!!
list($type,$sub_type) = explode('-',$cell['type']); list($type,$sub_type) = explode('-',$cell['type']);
@ -1069,10 +1073,10 @@ class etemplate extends boetemplate
} }
if ($cell['onchange'] && !($cell['type'] == 'button' || $cell['type'] == 'buttononly')) if ($cell['onchange'] && !($cell['type'] == 'button' || $cell['type'] == 'buttononly'))
{ {
if (strchr($cell['onchange'],'$') || $cell['onchange']{0} == '@') /* if (strchr($cell['onchange'],'$') || $cell['onchange']{0} == '@')
{ {
$cell['onchange'] = $this->expand_name($cell['onchange'],$show_c,$show_row,$content['.c'],$content['.row'],$content); $cell['onchange'] = $this->expand_name($cell['onchange'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
} }*/
$options .= ' onChange="'.($cell['onchange'] == '1' ? 'this.form.submit();' : $this->js_pseudo_funcs($cell['onchange'],$cname)).'"'; $options .= ' onChange="'.($cell['onchange'] == '1' ? 'this.form.submit();' : $this->js_pseudo_funcs($cell['onchange'],$cname)).'"';
} }
} }

View File

@ -60,12 +60,8 @@ class uidefinitions
$GLOBALS['egw_info']['flags']['currentapp'] = self::_appname; $GLOBALS['egw_info']['flags']['currentapp'] = self::_appname;
$GLOBALS['egw_info']['flags']['include_xajax'] = true; $GLOBALS['egw_info']['flags']['include_xajax'] = true;
if(!@is_object($GLOBALS['egw']->js))
{
$GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript');
}
$this->etpl =& new etemplate(); $this->etpl =& new etemplate();
$this->clock = $GLOBALS['egw']->html->image(self::_appname,'clock'); $this->clock = html::image(self::_appname,'clock');
$this->steps = array( $this->steps = array(
'wizzard_step10' => lang('Choose an application'), 'wizzard_step10' => lang('Choose an application'),
'wizzard_step20' => lang('Choose a plugin'), 'wizzard_step20' => lang('Choose a plugin'),
@ -232,7 +228,7 @@ class uidefinitions
$this->response->addAssign('exec[button][cancel]','style.display', 'none'); $this->response->addAssign('exec[button][cancel]','style.display', 'none');
} }
$this->response->addAssign('contentbox', 'innerHTML', $html); $this->response->addAssign('contentbox', 'innerHTML', $html);
if (is_object($GLOBALS['egw']->js) && $GLOBALS['egw']->js->body['onLoad']) if (isset($GLOBALS['egw']->js) && $GLOBALS['egw']->js->body['onLoad'])
{ {
$this->response->addScript($GLOBALS['egw']->js->body['onLoad']); $this->response->addScript($GLOBALS['egw']->js->body['onLoad']);
} }

View File

@ -5,22 +5,15 @@
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package api * @package api
* @copyright (c) 2006 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2006-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.bocontacts.inc.php');
/** /**
* contacts service provided by the addressbook application * contacts service provided by the addressbook application
*
* @package api
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2006 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
*/ */
class contacts extends bocontacts class contacts extends addressbook_bo
{ {
/** /**
* @deprecated since 1.3 use total * @deprecated since 1.3 use total
@ -36,20 +29,20 @@ class contacts extends bocontacts
/** /**
* constructor calling the constructor of the extended class * constructor calling the constructor of the extended class
*/ */
function contacts($contact_app='addressbook') function __construct($contact_app='addressbook')
{ {
$this->bocontacts($contact_app); parent::__construct($contact_app);
$this->total_records =& $this->total; $this->total_records =& $this->total;
$this->stock_contact_fields = array_keys($this->contact_fields); $this->stock_contact_fields = array_keys($this->contact_fields);
} }
/** /**
* reads contacts matched by key and puts all cols in the data array * reads contacts matched by key and puts all cols in the data array
* *
* reimplemented from bocontacts to call the old read function, if more then one param * reimplemented from bocontacts to call the old read function, if more then one param
* *
* @param int/string $contact_id * @param int/string $contact_id
* @return array/boolean contact data or false on error * @return array/boolean contact data or false on error
*/ */
function read($contact_id) function read($contact_id)
@ -67,7 +60,7 @@ class contacts extends bocontacts
* *
* They will be removed after one release, so dont use them in new code!!! * They will be removed after one release, so dont use them in new code!!!
*/ */
/** /**
* Searches for contacts meating certain criteria and evtl. return only a range of them * Searches for contacts meating certain criteria and evtl. return only a range of them
* *
@ -95,7 +88,7 @@ class contacts extends bocontacts
foreach(explode(',',$filter) as $expr) foreach(explode(',',$filter) as $expr)
{ {
list($col,$value) = explode('=',$expr); list($col,$value) = explode('=',$expr);
if ($col == 'access') // text field access is renamed to private and using boolean 0/1 if ($col == 'access') // text field access is renamed to private and using boolean 0/1
{ {
$col = 'private'; $col = 'private';
@ -115,8 +108,8 @@ class contacts extends bocontacts
$fields2 = array_values($fields); $fields2 = array_values($fields);
// check if the fields are in the keys with values true or 1 // check if the fields are in the keys with values true or 1
$fields = $fields2[0] === true || $fields2[0] === 1 ? array_keys($fields) : $fields2; $fields = $fields2[0] === true || $fields2[0] === 1 ? array_keys($fields) : $fields2;
foreach($old2new as $old => $new) foreach($old2new as $old => $new)
{ {
if (($key = array_search($old,$fields)) !== false) if (($key = array_search($old,$fields)) !== false)
@ -131,11 +124,11 @@ class contacts extends bocontacts
} }
if (!$order) $order = $fields ? $fields[0] : 'org_name,n_family,n_given'; if (!$order) $order = $fields ? $fields[0] : 'org_name,n_family,n_given';
if ($order && strpos($order,'_') === false) $order = 'contact_'.$order; if ($order && strpos($order,'_') === false) $order = 'contact_'.$order;
//echo '<p>contacts::search('.($cquery ? $cquery.'*' : $query).','.print_r($fields,true).",'$order $sort','','".($cquery ? '' : '%')."',false,'OR',".(!$limit ? 'false' : "array($start,$limit)").",".print_r($sfilter,true).");</p>\n"; //echo '<p>contacts::search('.($cquery ? $cquery.'*' : $query).','.print_r($fields,true).",'$order $sort','','".($cquery ? '' : '%')."',false,'OR',".(!$limit ? 'false' : "array($start,$limit)").",".print_r($sfilter,true).");</p>\n";
$rows =& $this->search($cquery ? $cquery.'*' : $query,$fields,$order.($sort ? ' '.$sort : ''),'', $rows =& $this->search($cquery ? $cquery.'*' : $query,$fields,$order.($sort ? ' '.$sort : ''),'',
$cquery ? '' : '%',false,'OR',!$limit ? false : array((int)$start,(int)$limit),$sfilter); $cquery ? '' : '%',false,'OR',!$limit ? false : array((int)$start,(int)$limit),$sfilter);
// return the old birthday format // return the old birthday format
if ($rows && (is_null($fields) || array_intersect($old2new,$fields))) if ($rows && (is_null($fields) || array_intersect($old2new,$fields)))
{ {
@ -168,7 +161,7 @@ class contacts extends bocontacts
{ {
return $this->read($id); return $this->read($id);
} }
/** /**
* add a contact * add a contact
* *