isReadOnly()) error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); # The DN and ATTR we are working with. $entry = array(); $entry['dn']['encode'] = get_request('dn','GET',true); $entry['dn']['string'] = urldecode($entry['dn']['encode']); $entry['dn']['html'] = htmlspecialchars($entry['dn']['string']); $entry['attr']['string'] = get_request('attr','GET',true); $entry['attr']['encode'] = rawurlencode($entry['attr']['string']); $entry['attr']['html'] = htmlspecialchars($entry['attr']['string']); if (! is_null($entry['dn']['string'])) $entry['rdn']['string'] = get_rdn($entry['dn']['string']); else $entry['rdn']['string'] = null; $entry['rdn']['html'] = htmlspecialchars($entry['rdn']['string']); /***************/ /* get entry */ /***************/ if (! $entry['dn']['string'] || ! $ldapserver->dnExists($entry['dn']['string'])) error(sprintf(_('The entry (%s) does not exist.'),$entry['dn']['html']),'error','index.php'); $tree = get_cached_item($ldapserver->server_id,'tree'); $entry['ldap'] = null; if ($tree) { $entry['ldap'] = $tree->getEntry($entry['dn']['string']); if (! $entry['ldap']) $tree->addEntry($entry['dn']['string']); $entry['ldap'] = $tree->getEntry($entry['dn']['string']); } # Define the template of the entry if possible eval('$reader = new '.$_SESSION[APPCONFIG]->GetValue('appearance','entry_reader').'($ldapserver);'); $reader->visit('Start', $entry['ldap']); if (! $entry['ldap'] || $entry['ldap']->isReadOnly()) error(sprintf(_('The entry (%s) is in readonly mode.'),$entry['dn']['html']),'error','index.php'); /*********************/ /* attribute values */ /*********************/ eval('$writer = new '.$_SESSION[APPCONFIG]->GetValue('appearance','entry_writer').'($ldapserver);'); $ldap['attr'] = $entry['ldap']->getAttribute($entry['attr']['string']); if (!$ldap['attr']) { # Define a new attribute for the entry $attributefactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','attribute_factory'); eval('$attribute_factory = new '.$attributefactoryclass.'();'); $ldap['attr'] = $attribute_factory->newAttribute($entry['attr']['string'], array()); $ldap['attr']->setEntry($entry['ldap']); } $ldap['count'] = $ldap['attr']->getValueCount(); if ($ldap['attr']->isReadOnly()) error(sprintf(_('The attribute (%s) is in readonly mode.'),$entry['attr']['html']),'error','index.php'); if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value')) error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('add attribute value')),'error','index.php'); if (($ldap['attr']->getValueCount() == 0) && ! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add')) error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('add attribute')),'error','index.php'); $entry['attr']['oclass'] = (strcasecmp($entry['attr']['string'],'objectClass') == 0) ? true : false; if ($entry['attr']['oclass']) { # Fetch all available objectClasses and remove those from the list that are already defined in the entry $ldap['oclasses'] = $ldapserver->SchemaObjectClasses(); foreach($ldap['attr']->getValues() as $oclass) unset($ldap['oclasses'][strtolower($oclass)]); } else { $ldap['schema'] = $ldapserver->getSchemaAttribute($entry['attr']['string']); } printf('

%s %s %s %s

', _('Add new'),$entry['attr']['html'],_('value to'),$entry['rdn']['html']); printf('

%s %s     %s: %s

', _('Server'),$ldapserver->name,_('Distinguished Name'),$entry['dn']['html']); if ($entry['attr']['oclass']) { echo '
'; echo ''; } else { echo ''; echo ''; } printf('',$ldapserver->server_id); printf('',$entry['dn']['encode']); echo '
'; echo ''; echo ''; if ($ldap['count']) { printf('', _('Current list of'),$ldap['count'],_('values for attribute'),$ldap['attr']->getFriendlyName(),_(':')); } else { printf('', _('No current value for attribute'),$ldap['attr']->getFriendlyName()); } echo ''; echo ''; echo ''; printf('',_('Enter the value you would like to add:')); echo ''; echo ''; if ($_SESSION[APPCONFIG]->GetValue('appearance','show_hints')) printf('', IMGDIR,_('Note: You may be required to enter new attributes that these objectClass(es) require')); echo '
%s %s %s %s%s%s %s.'; if ($ldap['count']) { # Display current attribute values echo '
'; for ($i = 0; $i < $ldap['count']; $i++) { $writer->draw('OldValue', $ldap['attr'], $i); $writer->draw('ReadOnlyValue', $ldap['attr'], $i); } echo '
'; } else { echo '

'; } echo '
%s'; if ($entry['attr']['oclass']) { # Draw objectClass selection echo '
'; echo ''; echo '
'; echo '
'; printf('',_('Add new ObjectClass')); echo '
'; echo '

Hint%s
'; echo '
'; echo '
'; } else { # Draw a blank field echo '
'; $writer->draw('BlankValue',$ldap['attr'],$ldap['count'],$reader); echo '
'; if ($ldap['schema']->getDescription()) printf('%s: %s
',_('Description'),$ldap['schema']->getDescription()); if ($ldap['schema']->getType()) printf('%s: %s
',_('Syntax'),$ldap['schema']->getType()); if ($ldap['schema']->getMaxLength()) printf('%s: %s %s
', _('Maximum Length'),number_format($ldap['schema']->getMaxLength()),_('characters')); echo '
'; printf('',_('Add New Value')); echo '
'; echo ''; echo ''; echo ''; echo ''; # Javascript echo ''; echo ''; echo ''; echo ''; echo ''; $writer->draw('Javascript', $ldap['attr']); echo ''; } ?>