configurable fields belonging to our (virtual) organisations, patch from Stefan Becker

This commit is contained in:
Ralf Becker 2008-03-05 10:31:26 +00:00
parent 627aa2c228
commit db165536e1
5 changed files with 68 additions and 8 deletions

View File

@ -246,8 +246,12 @@ class bocontacts extends socontacts
{
$this->own_account_acl = array_merge($this->own_account_acl,array('n_prefix','n_given','n_middle','n_family','n_suffix'));
}
if ($GLOBALS['egw_info']['server']['org_fileds_to_update'])
{
$this->org_fields = unserialize($GLOBALS['egw_info']['server']['org_fileds_to_update']);
}
}
/**
* calculate the file_as string from the contact and the file_as type
*
@ -615,8 +619,8 @@ class bocontacts extends socontacts
list($name,$value) = explode(':',$part);
$org[$name] = $value;
}
$contacts = parent::search('',$this->org_fields,'','','',false,'AND',false,$org);
if (!$contacts) return false;
// create a statistic about the commonness of each fields values
@ -625,7 +629,12 @@ class bocontacts extends socontacts
{
foreach($contact as $name => $value)
{
$fields[$name][$value]++;
if ($name != 'cat_id') $fields[$name][$value]++;
}
foreach(explode(',',$contact['cat_id']) as $part)
{
list($name) = explode(',',$part);
$fields['cat_id'][$name]++;
}
}
foreach($fields as $name => $values)
@ -633,16 +642,28 @@ class bocontacts extends socontacts
if (!in_array($name,$this->org_fields)) continue;
arsort($values,SORT_NUMERIC);
list($value,$num) = each($values);
//echo "<p>$name: '$value' $num/".count($contacts)."=".($num / (double) count($contacts))." >= $this->org_common_factor = ".($num / (double) count($contacts) >= $this->org_common_factor ? 'true' : 'false')."</p>\n";
if ($value && $num / (double) count($contacts) >= $this->org_common_factor)
{
$org[$name] = $value;
if ($name != 'cat_id')
{
$org[$name] = $value;
}
else
{
$org[$name] = array();
foreach ($values as $catid => $catvalue)
{
if ($catid && $catvalue / (double) count($values) >= $this->org_common_factor)
{
$org[$name][] = $catid;
}
}
$org[$name] = implode(',',$org[$name]);
}
}
}
//echo $org_id; _debug_array($org);
return $org;
}

View File

@ -55,5 +55,36 @@ function own_account_acl($config)
{
$GLOBALS['egw']->html =& CreateObject('phpgwapi.html');
}
return $GLOBALS['egw']->html->checkbox_multiselect('newsettings[own_account_acl]',$config['own_account_acl'],$fields,true,'',8);
return $GLOBALS['egw']->html->checkbox_multiselect('newsettings[own_account_acl]',$config['own_account_acl'],$fields,true,'',4);
}
function org_fileds_to_update($config)
{
$bocontacts =& CreateObject('addressbook.bocontacts');
$supported_fields = $bocontacts->get_fields('supported',null,0); // fields supported by the backend (ldap schemas!)
// get the list of account fields
$fields = array();
foreach($bocontacts->contact_fields as $field => $label)
{
// 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')))
{
$fields[$field] = $label;
}
}
if ($config['account_repository'] != 'ldap') // no custom-fields in ldap
{
$custom =& CreateObject('admin.customfields','addressbook');
foreach($custom->get_customfields() as $name => $data)
{
$fields['#'.$name] = $data['label'];
}
}
if (!is_object($GLOBALS['egw']->html))
{
$GLOBALS['egw']->html =& CreateObject('phpgwapi.html');
}
return $GLOBALS['egw']->html->checkbox_multiselect('newsettings[org_fileds_to_update]',
$config['org_fileds_to_update'] ? $config['org_fileds_to_update'] : $bocontacts->org_fields,$fields,true,'',4);
}

View File

@ -343,6 +343,7 @@ tomorrow is %1's birthday. common de Morgen ist der Geburtstag von %1.
translation addressbook de Übersetzung
type addressbook de Typ
update a single entry by passing the fields. addressbook de Aktualisiert einen einzelnen Eintrag durch Übergabe seiner Felder.
update fields by edited organisations? admin de Welche Felder sollen beim Bearbeiten von Organisationen aktualisiert werden?
updated addressbook de Aktualisiert
upload or delete the photo addressbook de Foto hochladen oder löschen
url to link telephone numbers to (use %1 = number to call, %u = account name, %t = account phone) admin de URL mit denen Telefonnummern verlinkt werden sollen (verwenden Sie %1 = anzurufende Nummer, %u = Benutzernamen, %t = Telefon des Benutzers)

View File

@ -343,6 +343,7 @@ tomorrow is %1's birthday. common en Tomorrow is %1's birthday.
translation addressbook en Translation
type addressbook en Type
update a single entry by passing the fields. addressbook en Update a single entry by passing the fields.
update fields by edited organisations? admin en Update Fields by edited organisations?
updated addressbook en Updated
upload or delete the photo addressbook en Upload or delete the photo
url to link telephone numbers to (use %1 = number to call, %u = account name, %t = account phone) admin en URL to link telephone numbers to (use %1 = number to call, %u = account name, %t = account phone)

View File

@ -48,6 +48,12 @@
</td>
</tr>
<tr class="row_off">
<td>&nbsp;{lang_Update_Fields_by_edited_organisations?}</td>
<td>
{hook_org_fileds_to_update}
</td>
</tr>
<tr class="row_on">
<td>&nbsp;{lang_Use_an_extra_tab_for_private_custom_fields?}</td>
<td>
<select name="newsettings[private_cf_tab]">