some (crm) features:

- filter for business country
- sorting by postal code
- add can create now already linked entries by specifying app/id pairs in the url (as eg. timesheet)
- setting egw_info[flags][currentid] in view to allow to add already linked entries via quick add
some bugfixes:
- sql can now change the ownership if a user gets deleted, ldap implementation still missing, but gives no more error
- photo template was not shown under some circumstances
This commit is contained in:
Ralf Becker 2006-12-11 07:35:49 +00:00
parent 696fd0064d
commit 93396fe850
9 changed files with 119 additions and 16 deletions

View File

@ -766,6 +766,25 @@ class bocontacts extends socontacts
'menuaction' => 'addressbook.uicontacts.view'
),
'view_id' => 'contact_id',
'add' => array(
'menuaction' => 'addressbook.uicontacts.edit'
),
'add_app' => 'link_app',
'add_id' => 'link_id',
'add_popup' => '850x440',
);
}
/**
* Register contacts as calendar resources (items which can be sheduled by the calendar)
*
* @param array $args hook-params (not used)
* @return array
*/
function calendar_resources($args)
{
return array(
'type' => 'c',// one char type-identifiy for this resources
);
}

View File

@ -1137,4 +1137,15 @@ class so_ldap
$ldapContact['c'] = array();
}
}
/**
* Change the ownership of contacts owned by a given account
*
* @param int $account_id account-id of the old owner
* @param int $new_owner account-id of the new owner
*/
function change_owner($account_id,$new_owner)
{
error_log("so_ldap::change_owner($account_id,$new_owner) not yet implemented");
}
}

View File

@ -488,7 +488,16 @@ class socontacts
{
//echo "<p>socontacts::search(".print_r($criteria,true).",'$only_keys','$order_by','$extra_cols','$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')</p>\n";
//error_log("socontacts::search(".print_r($criteria,true).",'$only_keys','$order_by','$extra_cols','$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')");
// the nextmatch custom-filter-header country-select returns a 2 letter country-code
if (isset($filter['adr_one_countryname']) && strlen($filter['adr_one_countryname']) == 2)
{
if (!is_object($GLOBALS['egw']->country))
{
$GLOBALS['egw']->country =& CreateObject('phpgwapi.country');
}
$filter['adr_one_countryname'] = $GLOBALS['egw']->country->get_full_name($filter['adr_one_countryname']);
}
$backend =& $this->get_backend(null,$filter['owner']);
// single string to search for --> create so_sql conformant search criterial for the standard search columns
if ($criteria && !is_array($criteria))

View File

@ -268,13 +268,32 @@ class socontacts_sql extends so_sql
if ($search_customfields) // search the custom-fields
{
$join .= $this->extra_join;
if (is_string($only_keys)) $only_keys = 'DISTINCT '.str_replace(array('contact_id','contact_owner'),
array($this->table_name.'.contact_id',$this->table_name.'.contact_owner'),$only_keys);
// only return the egw_addressbook columns, to not generate dublicates by the left join
// and to not return the NULL for contact_{id|owner} of not found custom fields!
if (is_bool($only_keys)) $only_keys = 'DISTINCT '.$this->table_name.'.*';
switch(gettype($only_keys))
{
case 'boolean':
// only return the egw_addressbook columns, to not generate dublicates by the left join
// and to not return the NULL for contact_{id|owner} of not found custom fields!
$only_keys = 'DISTINCT '.$this->table_name.'.'.($only_keys ? 'contact_id' : '*');
break;
case 'string':
$only_keys = explode(',',$only_keys);
// fall through
case 'array':
foreach($only_keys as $key => $val)
{
switch($key)
{
case 'id': case 'contact_id':
$only_keys[$key] = $this->table_name.'.contact_id';
break;
case 'owner': case 'contact_owner':
$only_keys[$key] = $this->table_name.'.contact_owner';
break;
}
}
break;
}
if (isset($filter['owner']))
{
$filter[] = $this->table_name.'.contact_owner='.(int)$filter['owner'];
@ -303,4 +322,23 @@ class socontacts_sql extends so_sql
}
return '('.implode(' OR ',$cat_filter).')';
}
/**
* Change the ownership of contacts owned by a given account
*
* @param int $account_id account-id of the old owner
* @param int $new_owner account-id of the new owner
*/
function change_owner($account_id,$new_owner)
{
if (!$new_owner) // otherwise we would create an account (contact_owner==0)
{
die("socontacts_sql::change_owner($account_id,$new_owner) new owner must not be 0");
}
$this->db->update($this->table_name,array(
'contact_owner' => $new_owner,
),array(
'contact_owner' => $account_id,
),__LINE__,__FILE__);
}
}

View File

@ -616,10 +616,14 @@ class uicontacts extends bocontacts
case 'n_fileas':
$order = "n_fileas!='' DESC,n_fileas $sort";
break;
case 'adr_one_postalcode':
$order = "adr_one_postalcode!='' DESC,adr_one_postalcode $sort,org_name $sort,n_family $sort,n_given $sort";
break;
}
if ($query['searchletter']) // only show contacts if the order-criteria starts with the given letter
{
$query['col_filter'][] = $query['order'].' LIKE '.$GLOBALS['egw']->db->quote($query['searchletter'].'%');
$query['col_filter'][] = ($query['order']=='adr_one_postalcode' ? 'org_name' : $query['order']).
' LIKE '.$GLOBALS['egw']->db->quote($query['searchletter'].'%');
}
$wildcard = '%';
$op = 'OR';
@ -665,6 +669,7 @@ class uicontacts extends bocontacts
switch($order)
{
case 'adr_one_postalcode':
case 'org_name':
$row['line1'] = $row['org_name'];
$row['line2'] = $row['n_family'].($given ? ', '.$given : '');
@ -781,7 +786,7 @@ class uicontacts extends bocontacts
}
if ($query['searchletter'])
{
$order = $order == 'org_name' ? lang('company name') : ($order == 'n_given' ? lang('first name') : lang('last name'));
$order = $order == 'n_given' ? lang('first name') : ($order == 'n_family' ? lang('last name') : lang('Organisation'));
$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.lang("%1 starts with '%2'",$order,$query['searchletter']);
}
if ($query['search'])
@ -1061,6 +1066,19 @@ class uicontacts extends bocontacts
{
$content['link_to']['to_id'] = $contact_id;
}
// automatic link new entries to entries specified in the url
if (!$contact_id && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id']))
{
$link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']);
foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
{
$link_id = $link_ids[$n];
if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // gard against XSS
{
$this->link->link('addressbook',$content['link_to']['to_id'],$link_app,$link_id);
}
}
}
}
$content['disable_change_org'] = $view || !$content['org_name'];
//_debug_array($content);
@ -1115,7 +1133,7 @@ class uicontacts extends bocontacts
'to_app' => 'addressbook',
'to_id' => $content['link_to']['to_id'],
);
$content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'template');
$content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'photo');
if ($content['private']) $content['owner'] .= 'p';
@ -1279,6 +1297,9 @@ $readonlys['button[vcard]'] = true;
$this->tmpl->set_cell_attribute($name,'no_lang',true);
}
}
// set id for automatic linking via quick add
$GLOBALS['egw_info']['flags']['currentid'] = $content['id'];
$this->tmpl->exec('addressbook.uicontacts.view',$content,$sel_options,$readonlys,array('id' => $content['id']));
$GLOBALS['egw']->hooks->process(array(

File diff suppressed because one or more lines are too long

View File

@ -37,6 +37,7 @@ $setup_info['addressbook']['hooks']['settings'] = 'addressbook.contacts_admin_pr
$setup_info['addressbook']['hooks'][] = 'home';
$setup_info['addressbook']['hooks']['deleteaccount'] = 'addressbook.bocontacts.deleteaccount';
$setup_info['addressbook']['hooks']['search_link'] = 'addressbook.bocontacts.search_link';
$setup_info['addressbook']['hooks']['calendar_resources'] = 'addressbook.bocontacts.calendar_resources';
$setup_info['addressbook']['hooks']['edit_user'] = 'addressbook.contacts_admin_prefs.edit_user';
$setup_info['addressbook']['hooks'][] = 'config';

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -3,7 +3,7 @@
<overlay>
<template id="addressbook.index.left" template="" lang="" group="0" version="1.3.001">
<menulist class="bold">
<menupopup data="" rows="1" cols="1" id="org_view" no_lang="1" statustext="Select a view" onchange="1" options="All contacts"/>
<menupopup rows="1" cols="1" id="org_view" no_lang="1" statustext="Select a view" onchange="1" options="All contacts"/>
</menulist>
</template>
<template id="addressbook.index.right" template="" lang="" group="0" version="1.3.001">
@ -47,7 +47,7 @@
<row>
<nextmatch-sortheader id="org_name" label="Organisation" span="all"/>
</row>
<row disabled="!@order=/^(org_name|n_fileas)$/">
<row disabled="!@order=/^(org_name|n_fileas|adr_one_postalcode)$/">
<nextmatch-sortheader id="n_family" label="Name"/>
<nextmatch-sortheader id="n_given" label="Firstname" class="leftPad5"/>
</row>
@ -57,7 +57,11 @@
</rows>
</grid>
<description value="Photo"/>
<description value="Business address"/>
<vbox options="0,0">
<description value="Business address"/>
<nextmatch-customfilter id="adr_one_countryname" options="select-country,Country,1" class="countrySelect"/>
<nextmatch-sortheader id="adr_one_postalcode" label="zip code"/>
</vbox>
<description value="Home address"/>
<vbox options="0,0">
<description id="tel_work" value="Business phone"/>