isReadOnly())
pla_error(_('You cannot perform updates while server is in read-only mode'));
$entry['dn']['string'] = get_request('dn','GET');
$entry['rdn'] = get_rdn($entry['dn']['string']);
printf('
%s %s
',_('Add new attribute'),htmlspecialchars($entry['rdn']));
printf('%s: %s %s: %s
',
_('Server'),$ldapserver->name,_('Distinguished Name'),htmlspecialchars($entry['dn']['string']));
$dn['attrs'] = $ldapserver->getDNAttrs($entry['dn']['string']);
$dn['oclasses'] = $ldapserver->getDNAttr($entry['dn']['string'],'objectClass');
if (! is_array($dn['oclasses']))
$dn['oclasses'] = array($dn['oclasses']);
$ldap['attrs']['avail'] = array();
if (array_search('extensibleObject',$dn['oclasses']) !== false) {
$ldap['attrs']['ldap'] = $ldapserver->SchemaAttributes();
foreach ($ldap['attrs']['ldap'] as $attr)
$ldap['attrs']['avail'][] = $attr->getName();
} else {
$ldap['oclasses'] = $ldapserver->SchemaObjectClasses($entry['dn']['string']);
foreach ($dn['oclasses'] as $oclass) {
$ldap['oclass'] = $ldapserver->getSchemaObjectClass($oclass,$entry['dn']['string']);
if ($ldap['oclass'] && strcasecmp('objectclass',get_class($ldap['oclass'])) == 0)
$ldap['attrs']['avail'] = array_merge($ldap['oclass']->getMustAttrNames($ldap['oclasses']),
$ldap['oclass']->getMayAttrNames($ldap['oclasses']),
$ldap['attrs']['avail']);
}
}
$ldap['attrs']['avail'] = array_unique($ldap['attrs']['avail']);
$ldap['attrs']['avail'] = array_filter($ldap['attrs']['avail'],'not_an_attr');
sort($ldap['attrs']['avail']);
$ldap['binattrs']['avail'] = array();
foreach ($ldap['attrs']['avail'] as $i => $attr) {
if ($ldapserver->isAttrBinary($attr)) {
$ldap['binattrs']['avail'][] = $attr;
unset($ldap['attrs']['avail'][$i]);
}
}
echo '';
if (is_array($ldap['attrs']['avail']) && count($ldap['attrs']['avail']) > 0) {
echo '
';
echo _('Add new attribute');
echo '
';
echo '
';
echo '';
} else {
echo '
';
printf('(%s)',_('no new attributes available for this entry'));
}
if (count($ldap['binattrs']['avail']) > 0) {
echo '
';
echo _('Add new binary attribute');
echo '
';
echo '
';
echo '';
echo '';
} else {
echo '
';
printf('(%s)',_('no new binary attributes available for this entry'));
}
echo '';
/**
* Given an attribute $x, this returns true if it is NOT already specified
* in the current entry, returns false otherwise.
*
* @param attr $x
* @return bool
* @ignore
*/
function not_an_attr($x) {
global $dn;
foreach ($dn['attrs'] as $attr => $values)
if (strcasecmp($attr,$x) == 0)
return false;
return true;
}
?>