RELEASE 1.0.2
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/template_engine.php,v 1.33 2006/05/13 12:52:26 wurley Exp $
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/template_engine.php,v 1.44 2007/01/18 21:03:58 wurley Exp $
|
||||
|
||||
/**
|
||||
* Template render engine.
|
||||
@@ -30,7 +30,6 @@ $shadow_format_attrs = array_merge($shadow_before_today_attrs,$shadow_after_toda
|
||||
|
||||
# If we have a DN, then this is to edit the entry.
|
||||
if (isset($_REQUEST['dn'])) {
|
||||
|
||||
$dn = $_GET['dn'];
|
||||
$decoded_dn = rawurldecode($dn);
|
||||
$encoded_dn = rawurlencode($decoded_dn);
|
||||
@@ -63,7 +62,7 @@ if (isset($_REQUEST['dn'])) {
|
||||
|
||||
} else {
|
||||
$templates = new Templates($ldapserver->server_id);
|
||||
$template = $templates->GetTemplate($_REQUEST['template']);
|
||||
$template = $templates->getCreationTemplate($_REQUEST['template']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,9 +83,25 @@ if (isset($template['empty_attrs'])) {
|
||||
echo "\n\n";
|
||||
|
||||
if (isset($_REQUEST['nextpage']) && ! $_REQUEST['nextpage']) {
|
||||
$new_dn = sprintf('%s=%s,%s',$template['rdn'],$_REQUEST['form'][$template['rdn']],$_REQUEST['container']);
|
||||
|
||||
echo '<form action="create.php" method="post">';
|
||||
/*
|
||||
* destinationcontainer is an otherride of dn.
|
||||
* needed for such "actions" other than create.php
|
||||
*/
|
||||
if (!isset($template['destinationcontainer']))
|
||||
$new_dn = sprintf('%s=%s,%s',$template['rdn'],$_REQUEST['form'][$template['rdn']],$_REQUEST['container']);
|
||||
else
|
||||
$new_dn = sprintf('%s',$template['destinationcontainer']);
|
||||
|
||||
/*
|
||||
* default action is create.php
|
||||
* you can change this behavior by setting <action>myscript.php</action> in template header
|
||||
*/
|
||||
if (!isset($template['action']))
|
||||
echo '<form action="create.php" method="post">';
|
||||
else
|
||||
printf ('<form action="%s" method="post">',rawurlencode($template['action']));
|
||||
|
||||
printf('<input type="hidden" name="new_dn" value="%s" />',htmlspecialchars($new_dn));
|
||||
|
||||
} else {
|
||||
@@ -255,7 +270,9 @@ if (isset($template['empty_attrs'])) {
|
||||
|
||||
# Some conditional checking.
|
||||
# $detail['must'] & $detail['disable'] cannot be set at the same time.
|
||||
if (isset($detail['must']) && $detail['must'] && isset($detail['disable']) && $detail['disable'])
|
||||
# except when "action" is other than create.php
|
||||
if (isset($detail['must']) && $detail['must'] && isset($detail['disable']) && $detail['disable']
|
||||
&& (!isset($template['action']) || ($template['action']) == 'create.php'))
|
||||
pla_error(sprintf(_('Attribute [%s] is a MUST attribute, so it cannot be disabled.'),$attr));
|
||||
|
||||
# If this attribute is disabled, go to the next one.
|
||||
@@ -439,7 +456,7 @@ if (isset($template['empty_attrs'])) {
|
||||
|
||||
printf('<td><input type="%s" name="form[%s][]" id="%s" value="%s" %s %s />',
|
||||
$type,$attr,$attr.$i,(isset($detail['value']) ? $detail['value'] : ''),
|
||||
"onBlur=\"fill('$attr', this.value);\"",
|
||||
'',
|
||||
isset($detail['disable']) ? 'disabled' : '');
|
||||
|
||||
if (isset($detail['helper']) && isset($detail['helper']['location'])
|
||||
@@ -507,21 +524,32 @@ if (isset($template['empty_attrs'])) {
|
||||
printf('<tr class="%s"><td colspan=2>',($counter++%2==0?'even':'odd'));
|
||||
printf('<input type="hidden" name="attrs[]" value="%s" />',$attr);
|
||||
|
||||
$countitems = false;
|
||||
if (is_array($value))
|
||||
foreach ($value as $item) {
|
||||
if ($item && ! isset($unique[$item])) {
|
||||
|
||||
if (($item || $item == '0') && ! isset($unique[$item])) {
|
||||
$unique[$item] = 1;
|
||||
if ($countitems)
|
||||
printf ('<tr class="%s"><td colspan=2>',($counter++%2==0?'even':'odd'));
|
||||
|
||||
$countitems = true;
|
||||
|
||||
printf('<input type="hidden" name="vals[%s][]" value="%s" />',
|
||||
array_search($attr,$attrs),$item);
|
||||
|
||||
printf('%s</td><td><b>%s</b></td></tr>',$attr,htmlspecialchars($item));
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$display = $value;
|
||||
if (isset($template['attribute'][$attr]['type']) && $template['attribute'][$attr]['type'] == 'password')
|
||||
if (obfuscate_password_display($_REQUEST['enc']))
|
||||
if (isset($template['attribute'][$attr]['type']) && $template['attribute'][$attr]['type'] == 'password') {
|
||||
|
||||
$enc = (isset($_REQUEST['enc'])) ? $_REQUEST['enc'] : get_enc_type($value);
|
||||
if (obfuscate_password_display($enc))
|
||||
$display = '********';
|
||||
}
|
||||
|
||||
printf('<input type="hidden" name="vals[]" value="%s" />',$value);
|
||||
printf('%s</td><td><b>%s</b></td></tr>',$attr,htmlspecialchars($display));
|
||||
@@ -619,7 +647,11 @@ if (isset($template['empty_attrs'])) {
|
||||
return;
|
||||
else {
|
||||
attrTrace[id] = 1;
|
||||
document.getElementById(id).value = value;
|
||||
// disable value setting in case of "select multiple"
|
||||
if ((document.getElementById(id).tagName != "SELECT"
|
||||
&& document.getElementById(id).tagName != "select")
|
||||
|| document.getElementById(id).getAttribute("multiple") == "")
|
||||
document.getElementById(id).value = value;
|
||||
// here comes template-specific implementation, generated by php
|
||||
if (false) {}';
|
||||
|
||||
@@ -738,21 +770,25 @@ foreach ($template['attrs'] as $attr => $vals) {
|
||||
echo '<tr>';
|
||||
|
||||
echo '<td class="attr">';
|
||||
|
||||
$schema_href = sprintf('schema.php?server_id=%s&view=attributes&viewvalue=%s',
|
||||
if ($config->GetValue('appearance','show_schema_link')) {
|
||||
$schema_href = sprintf('schema.php?server_id=%s&view=attributes&viewvalue=%s',
|
||||
$ldapserver->server_id,real_attr_name($attr));
|
||||
|
||||
printf('<b><a title="'._('Click to view the schema defintion for attribute type \'%s\'').'" href="%s">%s</a></b>',$attr,$schema_href,$attr_display);
|
||||
printf('<b><a title="'._('Click to view the schema definition for attribute type \'%s\'').'" href="%s">%s</a></b>',$attr,$schema_href,$attr_display);
|
||||
} else {
|
||||
printf('<b>%s</s>',$attr_display);
|
||||
}
|
||||
echo '</td>';
|
||||
|
||||
echo '<td class="attr_note">';
|
||||
if ($attr_note)
|
||||
printf('<sup><small>%s</small></sup>',$attr_note);
|
||||
if ($config->GetValue('appearance','show_attribute_notes')) {
|
||||
echo '<td class="attr_note">';
|
||||
if ($attr_note)
|
||||
printf('<sup><small>%s</small></sup>',$attr_note);
|
||||
|
||||
if ($ldapserver->isAttrReadOnly($attr))
|
||||
printf('<small>(<acronym title="%s">%s</acronym>)</small>',_('This attribute has been flagged as read only by the phpLDAPadmin administrator'),_('read only'));
|
||||
if ($ldapserver->isAttrReadOnly($attr))
|
||||
printf('<small>(<acronym title="%s">%s</acronym>)</small>',_('This attribute has been flagged as read only by the phpLDAPadmin administrator'),_('read only'));
|
||||
|
||||
echo '</td>';
|
||||
echo '</td>';
|
||||
}
|
||||
echo '</tr>';
|
||||
|
||||
if ($is_modified_attr)
|
||||
@@ -968,13 +1004,17 @@ foreach ($template['attrs'] as $attr => $vals) {
|
||||
$val = $vals[0];
|
||||
|
||||
printf('<input type="hidden" name="old_values[%s][]" value="%s" />',htmlspecialchars($attr),htmlspecialchars($val));
|
||||
printf('<nobr><input type="text" size="30" id="f_date_%s" name="new_values[%s][0]" value="%s" /> ',
|
||||
printf('<span style="white-space: nowrap;"><input type="text" size="30" id="f_date_%s" name="new_values[%s][0]" value="%s" /> ',
|
||||
$attr,htmlspecialchars($attr),htmlspecialchars($val));
|
||||
draw_date_selector_link($attr);
|
||||
echo '</nobr></td>';
|
||||
echo '</span></td>';
|
||||
echo '</tr>';
|
||||
$js[] = sprintf('<script type="text/javascript" language="javascript">defaults[\'f_date_%s\'] = \'%s\';</script>',$attr,$js_date_attrs[$attr]);
|
||||
|
||||
$js_datetime_attrs = $config->GetValue('appearance','date_attrs_showtime');
|
||||
if (in_array_ignore_case($attr,array_keys($js_datetime_attrs)) && ($js_datetime_attrs[$attr]))
|
||||
$js[] = sprintf('<script type="text/javascript" language="javascript">defaults[\'f_time_%s\'] = \'%s\';</script>',$attr,'true');
|
||||
|
||||
if ($is_modified_attr)
|
||||
echo '<tr class="updated_attr"><td class="bottom" colspan="2"></td></tr>';
|
||||
|
||||
@@ -1005,7 +1045,7 @@ foreach ($template['attrs'] as $attr => $vals) {
|
||||
if (! strcasecmp($attr,'objectClass')) {
|
||||
|
||||
printf('<a title="%s" href="schema.php?server_id=%s&view=objectClasses&viewvalue=%s"><img src="images/info.png" alt="Info" /></a> ',
|
||||
_('View the schema description for this objectClass'),$ldapserver->server_id,htmlspecialchars($val));
|
||||
_('View the schema description for this objectClass'),$ldapserver->server_id,strtolower(htmlspecialchars($val)));
|
||||
|
||||
$schema_object = $ldapserver->getSchemaObjectClass($val);
|
||||
|
||||
@@ -1022,10 +1062,10 @@ foreach ($template['attrs'] as $attr => $vals) {
|
||||
if (is_dn_string($val) || $ldapserver->isDNAttr($attr))
|
||||
|
||||
if ($ldapserver->dnExists($val)) {
|
||||
printf('<a title="'._('Go to %s').'" href="template_engine.php?server_id=%s&dn=%s"><img style="vertical-align: top" src="images/go.png" /></a> ',
|
||||
printf('<a title="'._('Go to %s').'" href="template_engine.php?server_id=%s&dn=%s"><img style="vertical-align: top" src="images/go.png" alt="Go" /></a> ',
|
||||
htmlspecialchars($val),$ldapserver->server_id,rawurlencode($val));
|
||||
} else {
|
||||
printf('<a title="'._('DN not available %s').'"><img style="vertical-align: top" src="images/nogo.png" /></a> ',
|
||||
printf('<a title="'._('DN not available %s').'"><img style="vertical-align: top" src="images/nogo.png" alt="N/E" /></a> ',
|
||||
htmlspecialchars($val),$ldapserver->server_id,rawurlencode($val));
|
||||
}
|
||||
|
||||
@@ -1104,6 +1144,14 @@ foreach ($template['attrs'] as $attr => $vals) {
|
||||
|
||||
printf('<div class="add_value">(<a href="%s" title="%s">%s</a>)</div>',
|
||||
$add_href,sprintf(_('Add an additional value to attribute \'%s\''),$attr),_('add value'));
|
||||
|
||||
if (in_array($schema_attr->name,$config->GetValue('modify_member','groupattr'))) {
|
||||
$add_href = sprintf('modify_member_form.php?server_id=%s&dn=%s&attr=%s',
|
||||
$ldapserver->server_id,$encoded_dn,rawurlencode($attr));
|
||||
|
||||
printf('<div class="add_value">(<a href="%s" title="%s">%s</a>)</div>',
|
||||
$add_href,sprintf('%s %s',_('Modify members for'),$dn),_('modify group members'));
|
||||
}
|
||||
}
|
||||
|
||||
echo '</td>';
|
||||
|
Reference in New Issue
Block a user