2009-06-30 09:22:30 +00:00
|
|
|
<?php
|
2009-06-30 09:29:51 +00:00
|
|
|
/**
|
2009-07-01 06:09:17 +00:00
|
|
|
* Takes the results of clicking "Save" in template_engine.php and determines
|
|
|
|
* which attributes need to be updated (ie, which ones actually changed). Then,
|
|
|
|
* we present a confirmation table to the user outlining the changes they are
|
|
|
|
* about to make. That form submits directly to update.php, which makes the
|
|
|
|
* change.
|
2009-06-30 09:22:30 +00:00
|
|
|
*
|
2009-06-30 09:29:51 +00:00
|
|
|
* @package phpLDAPadmin
|
2009-07-01 06:09:17 +00:00
|
|
|
* @subpackage Page
|
|
|
|
* @see update.php
|
2009-06-30 09:29:51 +00:00
|
|
|
*/
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
/**
|
2009-06-30 09:22:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
require './common.php';
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$request = array();
|
|
|
|
$request['dn'] = get_request('dn','REQUEST',true);
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
|
|
|
|
error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php');
|
2009-06-30 10:40:33 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$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();
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$request['page']->drawTitle(get_rdn($request['template']->getDN()));
|
|
|
|
$request['page']->drawSubTitle();
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
# Confirm the updates
|
|
|
|
if (count($request['template']->getLDAPmodify(true))) {
|
2010-02-24 15:03:10 +00:00
|
|
|
echo '<div style="text-align: center;">';
|
2009-06-30 10:26:08 +00:00
|
|
|
echo _('Do you want to make these changes?');
|
|
|
|
echo '<br /><br />';
|
2010-02-24 15:03:10 +00:00
|
|
|
echo '</div>';
|
2009-06-30 10:26:08 +00:00
|
|
|
|
|
|
|
echo "\n\n";
|
2010-03-13 09:45:40 +00:00
|
|
|
echo '<form action="cmd.php" method="post" id="update_form">';
|
2010-02-24 15:03:10 +00:00
|
|
|
echo '<div>';
|
2009-06-30 10:46:00 +00:00
|
|
|
echo '<input type="hidden" name="cmd" value="update" />';
|
2009-07-01 06:09:17 +00:00
|
|
|
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
|
2011-04-29 02:08:38 +00:00
|
|
|
printf('<input type="hidden" name="dn" value="%s" />',$request['template']->getDNEncode(false));
|
2009-06-30 10:26:08 +00:00
|
|
|
echo "\n";
|
2009-07-01 06:09:17 +00:00
|
|
|
|
|
|
|
$request['page']->drawHiddenAttributes();
|
2010-02-24 15:03:10 +00:00
|
|
|
echo '</div>';
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2010-02-24 15:03:10 +00:00
|
|
|
echo '<table class="result_table" style="margin-left: auto; margin-right: auto;">';
|
2009-06-30 10:26:08 +00:00
|
|
|
echo "\n";
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
printf('<tr class="heading"><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
|
2009-06-30 10:26:08 +00:00
|
|
|
_('Attribute'),_('Old Value'),_('New Value'),_('Skip'));
|
|
|
|
echo "\n\n";
|
|
|
|
|
2009-07-05 12:13:17 +00:00
|
|
|
# If we skip objectclass changes, but there are new must/may attrs provided by the new objectclass, they need to be skip.
|
2009-08-22 11:30:50 +00:00
|
|
|
$mustattrs = getMustAttrs($request['template']->getAttribute('objectclass')->getValues());
|
2009-07-05 12:13:17 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$counter = 0;
|
|
|
|
foreach ($request['template']->getLDAPmodify(true) as $attribute) {
|
2009-06-30 09:29:51 +00:00
|
|
|
$counter++;
|
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
printf('<tr class="%s">',$counter%2 ? 'even' : 'odd');
|
2009-07-01 06:09:17 +00:00
|
|
|
printf('<td><b>%s</b></td>',$attribute->getFriendlyName());
|
|
|
|
|
|
|
|
# Show OLD Values
|
2009-06-30 10:41:18 +00:00
|
|
|
echo '<td><span style="white-space: nowrap;">';
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (! $attribute->getOldValues())
|
|
|
|
printf('<span style="color: green">[%s]</span>',_('attribute doesnt exist'));
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2011-04-28 14:19:53 +00:00
|
|
|
$dv = $attribute->getRemovedValues();
|
2009-07-01 06:09:17 +00:00
|
|
|
foreach ($attribute->getOldValues() as $key => $value) {
|
|
|
|
# For multiple values, we'll highlight the changed ones
|
2011-04-28 14:19:53 +00:00
|
|
|
if ($x = ((count($attribute->getOldValues()) > 5) && count($attribute->getValues()) && in_array($value,$dv)))
|
2009-07-01 06:09:17 +00:00
|
|
|
echo '<span style="color:#880000; background:#FFFFA0">';
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$request['page']->draw('OldValue',$attribute,$key);
|
|
|
|
|
|
|
|
# For multiple values, close the highlighting
|
2011-04-28 14:19:53 +00:00
|
|
|
if ($x)
|
2009-07-01 06:09:17 +00:00
|
|
|
echo '</span>';
|
|
|
|
|
|
|
|
echo '<br />';
|
|
|
|
}
|
2009-06-30 10:26:08 +00:00
|
|
|
|
2009-06-30 10:41:18 +00:00
|
|
|
echo '</span></td>';
|
2009-07-01 06:09:17 +00:00
|
|
|
|
|
|
|
# Show NEW Values
|
2009-06-30 10:41:18 +00:00
|
|
|
echo '<td><span style="white-space: nowrap;">';
|
2009-06-30 10:26:08 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (! $attribute->getValueCount() || $attribute->isForceDelete())
|
|
|
|
printf('<span style="color: red">[%s]</span>',_('attribute deleted'));
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2011-04-28 14:19:53 +00:00
|
|
|
$dv = $attribute->getAddedValues();
|
2009-07-01 06:09:17 +00:00
|
|
|
foreach ($attribute->getValues() as $key => $value) {
|
|
|
|
# For multiple values, we'll highlight the changed ones
|
2011-04-28 14:19:53 +00:00
|
|
|
if ($x = ((count($attribute->getValues()) > 5) && count($attribute->getOldValues()) && in_array($value,$dv)))
|
2009-07-01 06:09:17 +00:00
|
|
|
echo '<span style="color:#004400; background:#FFFFA0">';
|
|
|
|
|
|
|
|
$request['page']->draw('CurrentValue',$attribute,$key);
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
# For multiple values, close the highlighting
|
2011-04-28 14:19:53 +00:00
|
|
|
if ($x)
|
2009-07-01 06:09:17 +00:00
|
|
|
echo '</span>';
|
|
|
|
|
|
|
|
echo '<br />';
|
|
|
|
}
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-06-30 10:41:18 +00:00
|
|
|
echo '</span></td>';
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
# Show SKIP Option
|
2009-06-30 10:46:00 +00:00
|
|
|
$input_disabled = '';
|
|
|
|
$input_onclick = '';
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2009-08-28 10:07:56 +00:00
|
|
|
if ($attribute->isForceDelete() || (in_array($attribute->getName(),$mustattrs)) && $request['template']->getAttribute('objectclass')->justModified())
|
2009-07-01 06:09:17 +00:00
|
|
|
$input_disabled = 'disabled="disabled"';
|
|
|
|
|
2009-07-05 12:13:17 +00:00
|
|
|
if ($attribute->getName() == 'objectclass') {
|
|
|
|
$input_onclick = '';
|
|
|
|
|
2009-08-22 11:30:50 +00:00
|
|
|
# If there are attributes being force deleted...
|
2009-07-05 12:13:17 +00:00
|
|
|
if (count($request['template']->getForceDeleteAttrs()) > 0) {
|
|
|
|
$input_onclick = 'onclick="if (this.checked) {';
|
|
|
|
|
2009-08-22 11:30:50 +00:00
|
|
|
# And this OC is being skipped, then these attributes can be optionally deleted.
|
2009-07-05 12:13:17 +00:00
|
|
|
foreach ($request['template']->getForceDeleteAttrs() as $ad_name) {
|
2009-08-22 11:30:50 +00:00
|
|
|
# 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());
|
|
|
|
|
2009-07-05 12:13:17 +00:00
|
|
|
$input_onclick .= sprintf("document.getElementById('skip_array_%s').checked = true;",$ad_name->getName());
|
|
|
|
$input_onclick .= "\n";
|
|
|
|
}
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2009-07-05 12:13:17 +00:00
|
|
|
$input_onclick .= '} else {';
|
|
|
|
|
2009-08-22 11:30:50 +00:00
|
|
|
# Otherwise the attributes must be deleted.
|
2009-07-05 12:13:17 +00:00
|
|
|
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";
|
|
|
|
}
|
|
|
|
|
2009-08-22 11:30:50 +00:00
|
|
|
$input_onclick .= '};';
|
2009-07-05 12:13:17 +00:00
|
|
|
}
|
|
|
|
|
2009-08-22 11:30:50 +00:00
|
|
|
# If the attributes arent force deleted...
|
2009-07-05 12:13:17 +00:00
|
|
|
if ($input_onclick)
|
|
|
|
$input_onclick .= 'if (this.checked) {';
|
|
|
|
else
|
|
|
|
$input_onclick = 'onclick="if (this.checked) {';
|
|
|
|
|
2009-08-22 11:30:50 +00:00
|
|
|
# IE: There are new objectclasses that result in new values.
|
2009-07-05 12:13:17 +00:00
|
|
|
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";
|
|
|
|
}
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
$input_onclick .= '} else {';
|
2009-07-05 12:13:17 +00:00
|
|
|
|
|
|
|
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";
|
|
|
|
}
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
2009-07-05 12:13:17 +00:00
|
|
|
|
|
|
|
$input_onclick .= '};"';
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
printf('<td><input name="skip_array[%s]" id="skip_array_%s" type="checkbox" %s %s/></td>',
|
|
|
|
htmlspecialchars($attribute->getName()),htmlspecialchars($attribute->getName()),$input_disabled,$input_onclick);
|
|
|
|
echo '</tr>';
|
|
|
|
echo "\n\n";
|
2009-06-30 10:26:08 +00:00
|
|
|
}
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
echo '</table>';
|
|
|
|
|
2010-02-24 15:03:10 +00:00
|
|
|
echo '<div style="text-align: center;">';
|
2009-06-30 11:51:50 +00:00
|
|
|
echo '<br />';
|
2011-04-28 13:20:06 +00:00
|
|
|
// @todo cant use AJAX here, it affects file uploads.
|
|
|
|
printf('<input type="submit" value="%s" />',
|
|
|
|
_('Update Object'));
|
2010-03-13 09:45:40 +00:00
|
|
|
|
|
|
|
printf('<input type="submit" name="cancel" value="%s" %s/>',
|
|
|
|
_('Cancel'),
|
|
|
|
(isAjaxEnabled() ? sprintf('onclick="return ajDISPLAY(\'BODY\',\'cmd=template_engine&dn=%s\',\'%s\');"',htmlspecialchars($request['dn']),_('Retrieving DN')) : ''));
|
|
|
|
|
2010-02-24 15:03:10 +00:00
|
|
|
echo '</div>';
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '</form>';
|
2009-07-01 06:09:17 +00:00
|
|
|
echo '<br />';
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (count($request['template']->getForceDeleteAttrs()) > 0) {
|
2010-03-13 09:45:40 +00:00
|
|
|
echo '<table class="result_table" style="margin-left: auto; margin-right: auto;"><tr>';
|
2009-07-01 06:09:17 +00:00
|
|
|
printf('<td class="heading">%s:</td>',_('The deletion of objectClass(es)'));
|
|
|
|
printf('<td class="value"><b>%s</b></td>',implode('</b>, <b>',$request['template']->getAttribute('objectclass')->getRemovedValues()));
|
2009-06-30 11:51:50 +00:00
|
|
|
echo '</tr><tr>';
|
2009-07-01 06:09:17 +00:00
|
|
|
printf('<td class="heading">%s:</td>',_('will delete the attribute(s)'));
|
2009-06-30 11:51:50 +00:00
|
|
|
echo '<td class="value"><b>';
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
$i = 0;
|
2009-07-01 06:09:17 +00:00
|
|
|
foreach ($request['template']->getForceDeleteAttrs() as $attribute) {
|
|
|
|
if ($i++ != 0)
|
|
|
|
echo '</b>, <b>';
|
|
|
|
|
|
|
|
echo $_SESSION[APPCONFIG]->getFriendlyHTML($attribute);
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
echo '</b></td></tr></table>';
|
|
|
|
}
|
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
} else {
|
2010-03-13 09:45:40 +00:00
|
|
|
$href = sprintf('cmd=template_engine&server_id=%s&dn=%s',
|
2011-04-29 02:08:38 +00:00
|
|
|
$app['server']->getIndex(),$request['template']->getDNEncode());
|
2010-03-13 09:45:40 +00:00
|
|
|
|
2010-02-24 15:03:10 +00:00
|
|
|
echo '<div style="text-align: center;">';
|
2009-06-30 10:26:08 +00:00
|
|
|
echo _('You made no changes');
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2010-03-13 09:45:40 +00:00
|
|
|
if (isAjaxEnabled())
|
|
|
|
printf(' <a href="cmd.php?%s" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">%s</a>.',
|
|
|
|
htmlspecialchars($href),htmlspecialchars($href),_('Retrieving DN'),_('Go back'));
|
|
|
|
else
|
|
|
|
printf(' <a href="cmd.php?%s">%s</a>.',htmlspecialchars($href),_('Go back'));
|
|
|
|
|
2010-02-24 15:03:10 +00:00
|
|
|
echo '</div>';
|
2009-06-30 10:26:08 +00:00
|
|
|
}
|
2009-08-22 11:30:50 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2009-06-30 10:26:08 +00:00
|
|
|
?>
|