* allow to pick CC of tickets from addressbook

- also added a different approach allowing apps to register themselfs multiple times in the link registry, was necessary as types approach from Nathan changes the usage of the original app, while this adds sub-types like an arbitrary app responded to the link hook
This commit is contained in:
Ralf Becker 2010-09-22 09:36:26 +00:00
parent d5962bd0ed
commit 1f8e2e93df
3 changed files with 47 additions and 4 deletions

View File

@ -1209,16 +1209,18 @@ class addressbook_bo extends addressbook_so
{ {
$criteria = is_array($pattern) ? $pattern['search'] : $pattern; $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']); $limit = array($options['start'], $options['num_rows']);
} }
$filter = (array)$options['filter']; $filter = (array)$options['filter'];
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null; 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) 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 // show category color
if ($contact['cat_id'] && ($color = etemplate::cats2color($contact['cat_id']))) if ($contact['cat_id'] && ($color = etemplate::cats2color($contact['cat_id'])))
{ {
@ -1233,6 +1235,27 @@ class addressbook_bo extends addressbook_so
return $result; return $result;
} }
/**
* Query for subtype email (returns only contacts with email address set)
*
* @param string|array $pattern
* @param array $options
* @return Ambigous <multitype:, string, multitype:Ambigous <multitype:, string> 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 * Check access to the projects file store
* *
@ -1244,7 +1267,7 @@ class addressbook_bo extends addressbook_so
{ {
return $this->check_perms($check,$id); return $this->check_perms($check,$id);
} }
/** /**
* returns info about contacts for calender * returns info about contacts for calender
* *

View File

@ -323,6 +323,12 @@ class addressbook_hooks
'add_popup' => '870x440', 'add_popup' => '870x440',
'file_access'=> 'addressbook.addressbook_bo.file_access', 'file_access'=> 'addressbook.addressbook_bo.file_access',
'default_types' => array('n' => array('name' => 'contact', 'options' => array('icon' => 'navbar.png','template' => 'addressbook.edit'))), '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',
),
)
); );
} }

View File

@ -61,6 +61,11 @@
* ), * ),
* 'edit_id' => 'app_id', * 'edit_id' => 'app_id',
* 'edit_popup' => '400x300', * '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 ... * 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) 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)) if (is_array($data))
{ {
self::$app_register[$app] = $data; self::$app_register[$app] = $data;