diff --git a/addressbook/inc/class.addressbook_bo.inc.php b/addressbook/inc/class.addressbook_bo.inc.php index 50fa34c496..b93309c649 100755 --- a/addressbook/inc/class.addressbook_bo.inc.php +++ b/addressbook/inc/class.addressbook_bo.inc.php @@ -1209,16 +1209,18 @@ class addressbook_bo extends addressbook_so { $criteria = is_array($pattern) ? $pattern['search'] : $pattern; } - if($options['start'] || $options['num_rows']) { + if($options['start'] || $options['num_rows']) + { $limit = array($options['start'], $options['num_rows']); } $filter = (array)$options['filter']; if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null; - if (($contacts = parent::search($criteria,false,'org_name,n_family,n_given,cat_id','','%',false,'OR', $limit, $filter))) + if (($contacts = parent::search($criteria,false,'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR', $limit, $filter))) { foreach($contacts as $contact) { - $result[$contact['id']] = $this->link_title($contact); + $result[$contact['id']] = $this->link_title($contact). + ($options['type'] === 'email' ? ' <'.$contact['email'].'>' : ''); // show category color if ($contact['cat_id'] && ($color = etemplate::cats2color($contact['cat_id']))) { @@ -1233,6 +1235,27 @@ class addressbook_bo extends addressbook_so return $result; } + /** + * Query for subtype email (returns only contacts with email address set) + * + * @param string|array $pattern + * @param array $options + * @return Ambigous string > + */ + function link_query_email($pattern, Array &$options = array()) + { + if (isset($options['filter']) && !is_array($options['filter'])) + { + $options['filter'] = (array)$options['filter']; + } + // return only contacts with email set + $options['filter'][] = "contact_email LIKE '%@%'"; + + // let link query know, to append email to list + $options['type'] = 'email'; + + return $this->link_query($pattern,$options); + } /** * Check access to the projects file store * @@ -1244,7 +1267,7 @@ class addressbook_bo extends addressbook_so { return $this->check_perms($check,$id); } - + /** * returns info about contacts for calender * diff --git a/addressbook/inc/class.addressbook_hooks.inc.php b/addressbook/inc/class.addressbook_hooks.inc.php index 6f7aef69d3..2d9f3b45ea 100644 --- a/addressbook/inc/class.addressbook_hooks.inc.php +++ b/addressbook/inc/class.addressbook_hooks.inc.php @@ -323,6 +323,12 @@ class addressbook_hooks 'add_popup' => '870x440', 'file_access'=> 'addressbook.addressbook_bo.file_access', 'default_types' => array('n' => array('name' => 'contact', 'options' => array('icon' => 'navbar.png','template' => 'addressbook.edit'))), + // registers an addtional type 'addressbook-email', returning only contacts with email, title has email appended + 'additional' => array( + 'addressbook-email' => array( + 'query' => 'addressbook.addressbook_bo.link_query_email', + ), + ) ); } diff --git a/phpgwapi/inc/class.egw_link.inc.php b/phpgwapi/inc/class.egw_link.inc.php index 973fda4373..88b2d54fc8 100644 --- a/phpgwapi/inc/class.egw_link.inc.php +++ b/phpgwapi/inc/class.egw_link.inc.php @@ -61,6 +61,11 @@ * ), * 'edit_id' => 'app_id', * 'edit_popup' => '400x300', + * 'additional' => array( // allow one app to register sub-types, + * 'app-sub' => array( // different from 'types' approach above + * // every value defined above + * ) + * ) * } * All entries are optional, thought you only get conected functionality, if you implement them ... * @@ -142,6 +147,15 @@ class egw_link extends solink { foreach($search_link_hooks as $app => $data) { + // allow apps to register additional types + if (isset($data['additional'])) + { + foreach($data['additional'] as $name => $values) + { + self::$app_register[$name] = $values; + } + unset($data['additional']); + } if (is_array($data)) { self::$app_register[$app] = $data;