dnExists($request['dn'])) error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php'); $request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none')); $request['page']->setDN($request['dn']); $request['page']->accept(); $request['template'] = $request['page']->getTemplate(); $request['page']->drawTitle(get_rdn($request['template']->getDN())); $request['page']->drawSubTitle(); # Confirm the updates if (count($request['template']->getLDAPmodify(true))) { echo '
'; echo _('Do you want to make these changes?'); echo '

'; echo '
'; echo "\n\n"; echo '
'; echo '
'; echo ''; printf('',$app['server']->getIndex()); printf('',$request['template']->getDNEncode(false)); echo "\n"; $request['page']->drawHiddenAttributes(); echo '
'; echo ''; echo "\n"; printf('', _('Attribute'),_('Old value'),_('New value'),_('Skip')); echo "\n\n"; # If we skip objectclass changes, but there are new must/may attrs provided by the new objectclass, they need to be skip. $mustattrs = getMustAttrs($request['template']->getAttribute('objectclass')->getValues()); $counter = 0; foreach ($request['template']->getLDAPmodify(true) as $attribute) { $counter++; printf('',$counter%2 ? 'even' : 'odd'); printf('',$attribute->getFriendlyName()); # Show OLD Values echo ''; # Show NEW Values echo ''; # Show SKIP Option $input_disabled = ''; $input_onclick = ''; if ($attribute->isForceDelete() || (in_array($attribute->getName(),$mustattrs)) && $request['template']->getAttribute('objectclass')->justModified()) $input_disabled = 'disabled="disabled"'; if ($attribute->getName() == 'objectclass') { $input_onclick = ''; # If there are attributes being force deleted... if (count($request['template']->getForceDeleteAttrs()) > 0) { $input_onclick = 'onclick="if (this.checked) {'; # And this OC is being skipped, then these attributes can be optionally deleted. foreach ($request['template']->getForceDeleteAttrs() as $ad_name) { # Only if it is not a must attr by this objectclass now staying if (! in_array($ad_name->getName(),getMustAttrs($attribute->getOldValues()))) $input_onclick .= sprintf("document.getElementById('skip_array_%s').disabled = false;",$ad_name->getName()); $input_onclick .= sprintf("document.getElementById('skip_array_%s').checked = true;",$ad_name->getName()); $input_onclick .= "\n"; } $input_onclick .= '} else {'; # Otherwise the attributes must be deleted. foreach ($request['template']->getForceDeleteAttrs() as $ad_name) { $input_onclick .= sprintf("document.getElementById('skip_array_%s').checked = false;",$ad_name->getName()); $input_onclick .= sprintf("document.getElementById('skip_array_%s').disabled = true;",$ad_name->getName()); $input_onclick .= "\n"; } $input_onclick .= '};'; } # If the attributes arent force deleted... if ($input_onclick) $input_onclick .= 'if (this.checked) {'; else $input_onclick = 'onclick="if (this.checked) {'; # IE: There are new objectclasses that result in new values. foreach ($request['template']->getLDAPmodify(true) as $skipattr) { if (! $skipattr->getOldValues()) { if (! in_array($skipattr->getName(),$mustattrs)) $input_onclick .= sprintf("document.getElementById('skip_array_%s').disabled = true;",$skipattr->getName()); $input_onclick .= sprintf("document.getElementById('skip_array_%s').checked = true;",$skipattr->getName()); $input_onclick .= "\n"; } } $input_onclick .= '} else {'; foreach ($request['template']->getLDAPmodify(true) as $skipattr) { if (! $skipattr->getOldValues()) { if (! in_array($skipattr->getName(),$mustattrs)) $input_onclick .= sprintf("document.getElementById('skip_array_%s').disabled = false;",$skipattr->getName()); $input_onclick .= sprintf("document.getElementById('skip_array_%s').checked = false;",$skipattr->getName()); $input_onclick .= "\n"; } } $input_onclick .= '};"'; } printf('', htmlspecialchars($attribute->getName()),htmlspecialchars($attribute->getName()),$input_disabled,$input_onclick); echo ''; echo "\n\n"; } echo '
%s%s%s%s
%s'; if (! $attribute->getOldValues()) printf('[%s]',_('Attribute doesn\'t exist')); $dv = $attribute->getRemovedValues(); foreach ($attribute->getOldValues() as $key => $value) { # For multiple values, we'll highlight the changed ones if ($x = ((count($attribute->getOldValues()) > 5) && count($attribute->getValues()) && in_array($value,$dv))) echo ''; $request['page']->draw('OldValue',$attribute,$key); # For multiple values, close the highlighting if ($x) echo ''; echo '
'; } echo '
'; if (! $attribute->getValueCount() || $attribute->isForceDelete()) printf('[%s]',_('attribute deleted')); $dv = $attribute->getAddedValues(); foreach ($attribute->getValues() as $key => $value) { # For multiple values, we'll highlight the changed ones if ($x = ((count($attribute->getValues()) > 5) && count($attribute->getOldValues()) && in_array($value,$dv))) echo ''; $request['page']->draw('CurrentValue',$attribute,$key); # For multiple values, close the highlighting if ($x) echo ''; echo '
'; } echo '
'; echo '
'; echo '
'; // @todo cant use AJAX here, it affects file uploads. printf('', _('Update object')); printf('', _('Cancel'), (isAjaxEnabled() ? sprintf('onclick="return ajDISPLAY(\'BODY\',\'cmd=template_engine&dn=%s\',\'%s\');"',htmlspecialchars($request['dn']),_('Retrieving DN')) : '')); echo '
'; echo '
'; echo '
'; } else { $href = sprintf('cmd=template_engine&server_id=%s&dn=%s', $app['server']->getIndex(),$request['template']->getDNEncode()); echo '
'; echo _('You made no changes'); if (isAjaxEnabled()) printf(' %s.', htmlspecialchars($href),htmlspecialchars($href),_('Retrieving DN'),_('Go back')); else printf(' %s.',htmlspecialchars($href),_('Go back')); echo '
'; } function getMustAttrs($oclasses) { global $app; $mustattrs = array(); foreach ($oclasses as $value) { $soc = $app['server']->getSchemaObjectClass($value); if ($soc) foreach ($soc->getMustAttrs() as $sma) array_push($mustattrs,$sma->getName()); } return $mustattrs; } ?>