2009-06-30 09:22:30 +00:00
|
|
|
<?php
|
2009-07-01 06:09:17 +00:00
|
|
|
// $Header$
|
2009-06-30 09:22:30 +00:00
|
|
|
|
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))) {
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '<center>';
|
|
|
|
echo _('Do you want to make these changes?');
|
|
|
|
echo '<br /><br />';
|
|
|
|
|
|
|
|
echo "\n\n";
|
2009-06-30 10:46:00 +00:00
|
|
|
echo '<form action="cmd.php" method="post">';
|
|
|
|
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());
|
|
|
|
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn']));
|
2009-06-30 10:26:08 +00:00
|
|
|
echo "\n";
|
2009-07-01 06:09:17 +00:00
|
|
|
|
|
|
|
$request['page']->drawHiddenAttributes();
|
|
|
|
|
2009-06-30 11:51:50 +00:00
|
|
|
echo '<table class="result_table">';
|
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.
|
|
|
|
$mustattrs = array();
|
|
|
|
foreach ($request['template']->getAttribute('objectclass')->getValues() as $value) {
|
|
|
|
$soc = $app['server']->getSchemaObjectClass($value);
|
|
|
|
|
2009-07-12 12:02:19 +00:00
|
|
|
if ($soc)
|
|
|
|
foreach ($soc->getMustAttrs() as $sma)
|
|
|
|
array_push($mustattrs,$sma->getName());
|
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
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
foreach ($attribute->getOldValues() as $key => $value) {
|
|
|
|
# For multiple values, we'll highlight the changed ones
|
|
|
|
if ((count($attribute->getOldValues()) > 5) && in_array($value,$attribute->getRemovedValues()) && count($attribute->getValues()))
|
|
|
|
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
|
|
|
|
if ((count($attribute->getOldValues()) > 5) && in_array($value,$attribute->getRemovedValues()) && count($attribute->getValues()))
|
|
|
|
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
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
foreach ($attribute->getValues() as $key => $value) {
|
|
|
|
# For multiple values, we'll highlight the changed ones
|
|
|
|
if ((count($attribute->getValues()) > 5) && in_array($value,$attribute->getAddedValues()))
|
|
|
|
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
|
|
|
|
if ((count($attribute->getValues()) > 5) && in_array($value,$attribute->getAddedValues()))
|
|
|
|
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-07-05 12:13:17 +00:00
|
|
|
if ($attribute->isForceDelete() || in_array($attribute->getName(),$mustattrs))
|
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 = '';
|
|
|
|
|
|
|
|
if (count($request['template']->getForceDeleteAttrs()) > 0) {
|
|
|
|
$input_onclick = 'onclick="if (this.checked) {';
|
|
|
|
|
|
|
|
foreach ($request['template']->getForceDeleteAttrs() as $ad_name) {
|
|
|
|
$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";
|
|
|
|
}
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2009-07-05 12:13:17 +00:00
|
|
|
$input_onclick .= '} else {';
|
|
|
|
|
|
|
|
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 ($input_onclick)
|
|
|
|
$input_onclick .= 'if (this.checked) {';
|
|
|
|
else
|
|
|
|
$input_onclick = 'onclick="if (this.checked) {';
|
|
|
|
|
|
|
|
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>';
|
|
|
|
|
2009-06-30 11:51:50 +00:00
|
|
|
echo '<br />';
|
|
|
|
printf('<input type="submit" value="%s" />',_('Commit'));
|
|
|
|
printf('<input type="submit" name="cancel" value="%s" />',_('Cancel'));
|
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) {
|
2009-06-30 11:51:50 +00:00
|
|
|
echo '<table class="result_table"><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
|
|
|
echo '</center>';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
echo '<center>';
|
|
|
|
echo _('You made no changes');
|
2009-06-30 10:46:00 +00:00
|
|
|
$href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',
|
2009-07-01 06:09:17 +00:00
|
|
|
$app['server']->getIndex(),rawurlencode($request['dn']));
|
2009-06-30 10:46:00 +00:00
|
|
|
|
|
|
|
printf(' <a href="%s">%s</a>.',htmlspecialchars($href),_('Go back'));
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '</center>';
|
|
|
|
}
|
|
|
|
?>
|