* Addressbook: fixed not working changing of organisation members, also place this feature more prominent beside buttons

This commit is contained in:
Ralf Becker 2012-05-15 15:53:14 +00:00
parent e8f83bede0
commit a8dde2649e
5 changed files with 26 additions and 14 deletions

View File

@ -1215,7 +1215,14 @@ class addressbook_bo extends addressbook_so
{ {
if (isset($fields[$name])) if (isset($fields[$name]))
{ {
$criteria[$name] = $fields[$name]; if (empty($fields[$name]))
{
$criteria[] = "($name IS NULL OR $name='')";
}
else
{
$criteria[$name] = $fields[$name];
}
} }
} }
return parent::search($criteria,false,'n_family,n_given','','',false,'OR',false,array('org_name'=>$org_name)); return parent::search($criteria,false,'n_family,n_given','','',false,'OR',false,array('org_name'=>$org_name));
@ -1231,6 +1238,15 @@ class addressbook_bo extends addressbook_so
*/ */
function changed_fields($from,$to,$only_org_fields=true) function changed_fields($from,$to,$only_org_fields=true)
{ {
// we only care about countryname, if contrycode is empty
foreach(array(
'adr_one_countryname' => 'adr_one_countrycode',
'adr_two_countryname' => 'adr_one_countrycode',
) as $name => $code)
{
if (!empty($from[$code])) $from[$name] = '';
if (!empty($to[$code])) $to[$name] = '';
}
$changed = array(); $changed = array();
foreach($only_org_fields ? $this->org_fields : array_keys($this->contact_fields) as $name) foreach($only_org_fields ? $this->org_fields : array_keys($this->contact_fields) as $name)
{ {

View File

@ -2003,7 +2003,6 @@ class addressbook_ui extends addressbook_bo
} }
$readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(EGW_ACL_DELETE,$content); $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(EGW_ACL_DELETE,$content);
$readonlys['button[edit]'] = !$this->check_perms(EGW_ACL_EDIT,$content); $readonlys['button[edit]'] = !$this->check_perms(EGW_ACL_EDIT,$content);
$content['disable_change_org'] = true;
// how to display addresses // how to display addresses
$content['addr_format'] = $this->addr_format_by_country($content['adr_one_countryname']); $content['addr_format'] = $this->addr_format_by_country($content['adr_one_countryname']);
@ -2036,6 +2035,7 @@ class addressbook_ui extends addressbook_bo
{ {
$content['owner'] .= 'p'; $content['owner'] .= 'p';
} }
$this->tmpl->set_cell_attribute('change_org','disabled',true);
// Prevent double countries - invalid code blanks it, disabling doesn't work // Prevent double countries - invalid code blanks it, disabling doesn't work
$content['adr_one_countrycode'] = '-'; $content['adr_one_countrycode'] = '-';

View File

@ -94,7 +94,7 @@ function org_fileds_to_update($config)
foreach($bocontacts->contact_fields as $field => $label) foreach($bocontacts->contact_fields as $field => $label)
{ {
// some fields never making sense for an organisation // some fields never making sense for an organisation
if (!in_array($field,array('id','tid','owner','created','creator','modified','modifier','private','n_prefix','n_given','n_middle','n_family','n_suffix','n_fn'))) if (!in_array($field,array('id','tid','owner','created','creator','modified','modifier','private','n_prefix','n_given','n_middle','n_family','n_suffix','n_fn','account_id')))
{ {
$fields[$field] = $label; $fields[$field] = $label;
} }
@ -107,7 +107,7 @@ function org_fileds_to_update($config)
$fields['#'.$name] = $data['label']; $fields['#'.$name] = $data['label'];
} }
} }
// Remove country codes as an option, it will be added by BO constructor // Remove country codes as an option, it will be added by BO constructor
unset($fields['adr_one_countrycode']); unset($fields['adr_one_countrycode']);
unset($fields['adr_two_countrycode']); unset($fields['adr_two_countrycode']);

File diff suppressed because one or more lines are too long

View File

@ -259,7 +259,7 @@
</rows> </rows>
</grid> </grid>
</template> </template>
<template id="addressbook.edit.details" template="" lang="" group="0" version="1.9.001"> <template id="addressbook.edit.details" template="" lang="" group="0" version="1.9.002">
<grid width="100%" height="286" overflow="auto"> <grid width="100%" height="286" overflow="auto">
<columns> <columns>
<column/> <column/>
@ -277,11 +277,6 @@
<description value="Notes"/> <description value="Notes"/>
<textbox multiline="true" id="note" rows="6" cols="50"/> <textbox multiline="true" id="note" rows="6" cols="50"/>
</row> </row>
<row class="row_on" disabled="@disable_change_org">
<image src="check"/>
<description/>
<checkbox statustext="Apply changes to all members, whose fields have the same previous content" label="change all organisation members" id="change_org" span="all"/>
</row>
<row> <row>
<image src="home"/> <image src="home"/>
<description value="Last date"/> <description value="Last date"/>
@ -491,7 +486,7 @@
</rows> </rows>
</grid> </grid>
</template> </template>
<template id="addressbook.edit" template="" lang="" group="0" version="1.9.001"> <template id="addressbook.edit" template="" lang="" group="0" version="1.9.002">
<grid> <grid>
<columns> <columns>
<column width="450"/> <column width="450"/>
@ -633,6 +628,7 @@
<button accesskey="s" label="Save" id="button[save]"/> <button accesskey="s" label="Save" id="button[save]"/>
<button label="Apply" id="button[apply]"/> <button label="Apply" id="button[apply]"/>
<button label="Cancel" id="button[cancel]" onclick="if($cont[view]0) return true; self.close(); return false;"/> <button label="Cancel" id="button[cancel]" onclick="if($cont[view]0) return true; self.close(); return false;"/>
<checkbox statustext="Apply changes to all members, whose fields have the same previous content" label="change all organisation members" id="change_org" span="all"/>
</hbox> </hbox>
<button align="right" label="Delete" id="button[delete]" onclick="return confirm('Are you shure you want to delete this contact?');" tabindex="25"/> <button align="right" label="Delete" id="button[delete]" onclick="return confirm('Are you shure you want to delete this contact?');" tabindex="25"/>
</row> </row>