dnExists($request['dn'])) error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php'); $request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,null)); $request['page']->setDN($request['dn']); $request['page']->accept(true); $request['template'] = $request['page']->getTemplate(); $attribute_factory = new AttributeFactory(); # Grab the required attributes for the new objectClass $ldap = array(); $ldap['attrs']['must'] = array(); foreach ($request['template']->getAttribute('objectclass')->getValues() as $oclass_name) { # Exclude "top" if its there. if (! strcasecmp('top',$oclass_name)) continue; if ($soc = $app['server']->getSchemaObjectClass($oclass_name)) $ldap['attrs']['must'] = array_merge($ldap['attrs']['must'],$soc->getMustAttrNames(true)); } $ldap['attrs']['must'] = array_unique($ldap['attrs']['must']); /* Build a list of the attributes that this new objectClass requires, * but that the object does not currently contain */ $ldap['attrs']['need'] = array(); foreach ($ldap['attrs']['must'] as $attr) if (is_null($request['template']->getAttribute($attr))) array_push($ldap['attrs']['need'],$attribute_factory->newAttribute($attr,array('values'=>array()),$app['server']->getIndex())); # Mark all the need attributes as shown foreach ($ldap['attrs']['need'] as $index => $values) $ldap['attrs']['need'][$index]->show(); if (count($ldap['attrs']['need']) > 0) { $request['page']->drawTitle(sprintf('%s %s',_('Add new objectClass to'),get_rdn($request['dn']))); $request['page']->drawSubTitle(); echo '
'; printf('%s: %s %s %s %s', _('Instructions'), _('In order to add these objectClass(es) to this entry, you must specify'), count($ldap['attrs']['need']),_('new attributes'), _('that this objectClass requires.')); echo '

'; echo '
'; echo '
'; if ($_SESSION[APPCONFIG]->getValue('confirm','update')) echo ''; else echo ''; printf('',$app['server']->getIndex()); printf('',htmlspecialchars($request['dn'])); echo '
'; echo ''; printf('',_('New Required Attributes')); $counter = 0; echo ''; foreach ($ldap['attrs']['need'] as $count => $attr) $request['page']->draw('Template',$attr); echo '
%s
'; foreach ($request['template']->getAttribute('objectclass')->getValues() as $value) $request['page']->draw('HiddenValue',$request['template']->getAttribute('objectclass'),$counter++); echo '
'; printf('

',_('Add ObjectClass and Attributes')); echo '
'; echo '
'; # There are no other required attributes, so we just need to add the objectclass to the DN. } else { $result = $app['server']->modify($request['dn'],$request['template']->getLDAPmodify()); if ($result) { $href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s&modified_attrs[]=objectclass', $app['server']->getIndex(),rawurlencode($request['dn'])); if (get_request('meth','REQUEST') == 'ajax') $href .= '&meth=ajax'; header(sprintf('Location: %s',$href)); die(); } }