fixed not shown/working customfields, 2. phone-numbers, file-as and links in own account acl

This commit is contained in:
Ralf Becker 2007-06-03 12:24:49 +00:00
parent 6a001d1cdf
commit 9957f21e21
2 changed files with 49 additions and 5 deletions

View File

@ -1304,10 +1304,7 @@ class uicontacts extends bocontacts
// for editing the own account (by a non-admin), enable only the fields allowed via the "own_account_acl" // for editing the own account (by a non-admin), enable only the fields allowed via the "own_account_acl"
if (!$content['owner'] && !$this->is_admin($content)) if (!$content['owner'] && !$this->is_admin($content))
{ {
foreach($this->get_fields('supported',$content['id'],$content['owner']) as $field) $this->_set_readonlys_for_own_account_acl($readonlys,$id);
{
if (!$this->own_account_acl || !in_array($field,$this->own_account_acl)) $readonlys[$field] = true;
}
} }
for($i = -23; $i<=23; $i++) $tz[$i] = ($i > 0 ? '+' : '').$i; for($i = -23; $i<=23; $i++) $tz[$i] = ($i > 0 ? '+' : '').$i;
$sel_options['tz'] = $tz; $sel_options['tz'] = $tz;
@ -1339,6 +1336,51 @@ class uicontacts extends bocontacts
return $this->tmpl->exec('addressbook.uicontacts.edit',$content,$sel_options,$readonlys,$content, 2); return $this->tmpl->exec('addressbook.uicontacts.edit',$content,$sel_options,$readonlys,$content, 2);
} }
/**
* Set the readonlys for non-admins editing their own account
*
* @param array &$readonlys
* @param int $id
*/
function _set_readonlys_for_own_account_acl(&$readonlys,$id)
{
// regular fields depending on the backend
foreach($this->get_fields('supported',$id,0) as $field)
{
if (!$this->own_account_acl || !in_array($field,$this->own_account_acl))
{
$readonlys[$field] = true;
switch($field)
{
case 'tel_work':
case 'tel_cell':
case 'tel_home':
$readonlys[$field.'2'] = true;
break;
case 'n_fileas':
$readonlys['fileas_type'] = true;
break;
}
}
}
// custom fields
if ($this->customfields)
{
foreach($this->customfields as $name => $data)
{
if (!$this->own_account_acl || !in_array('#'.$name,$this->own_account_acl))
{
$readonlys['#'.$name] = true;
}
}
}
// links
if (!$this->own_account_acl || !in_array('link_to',$this->own_account_acl))
{
$readonlys['link_to'] = true;
}
}
function ajax_setFileasOptions($n_prefix,$n_given,$n_middle,$n_family,$n_suffix,$org_name) function ajax_setFileasOptions($n_prefix,$n_given,$n_middle,$n_family,$n_suffix,$org_name)
{ {
$names = array( $names = array(

View File

@ -41,9 +41,11 @@ function own_account_acl($config)
$fields[$field] = $label; $fields[$field] = $label;
} }
} }
$fields['link_to'] = 'Links';
if ($config['account_repository'] != 'ldap') // no custom-fields in ldap if ($config['account_repository'] != 'ldap') // no custom-fields in ldap
{ {
$custom =& CreateObject('admin.customfields',$contact_app); $custom =& CreateObject('admin.customfields','addressbook');
foreach($custom->get_customfields() as $name => $data) foreach($custom->get_customfields() as $name => $data)
{ {
$fields['#'.$name] = $data['label']; $fields['#'.$name] = $data['label'];