RELEASE 0.9.8
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_value_form.php,v 1.32.2.2 2005/10/16 20:19:16 wurley Exp $
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_value_form.php,v 1.34.2.4 2005/12/11 08:59:08 wurley Exp $
|
||||
|
||||
/**
|
||||
* Displays a form to allow the user to enter a new value to add
|
||||
@@ -18,194 +18,182 @@
|
||||
|
||||
require './common.php';
|
||||
|
||||
if( $ldapserver->isReadOnly() )
|
||||
pla_error( $lang['no_updates_in_read_only_mode'] );
|
||||
if( ! $ldapserver->haveAuthInfo())
|
||||
pla_error( $lang['not_enough_login_info'] );
|
||||
if ($ldapserver->isReadOnly())
|
||||
pla_error(_('You cannot perform updates while server is in read-only mode'));
|
||||
if (! $ldapserver->haveAuthInfo())
|
||||
pla_error(_('Not enough information to login to server. Please check your configuration.'));
|
||||
|
||||
$attr = $_GET['attr'];
|
||||
$dn = isset( $_GET['dn'] ) ? $_GET['dn'] : null;
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$encoded_attr = rawurlencode( $attr );
|
||||
$dn = isset($_GET['dn']) ? $_GET['dn'] : null;
|
||||
$encoded_dn = rawurlencode($dn);
|
||||
$encoded_attr = rawurlencode($attr);
|
||||
|
||||
if (! is_null($dn))
|
||||
$rdn = get_rdn( $dn );
|
||||
|
||||
$rdn = get_rdn($dn);
|
||||
else
|
||||
$rdn = null;
|
||||
|
||||
$current_values = get_object_attr( $ldapserver, $dn, $attr );
|
||||
$num_current_values = ( is_array($current_values) ? count($current_values) : 0 );
|
||||
$is_object_class = ( 0 == strcasecmp( $attr, 'objectClass' ) ) ? true : false;
|
||||
$is_jpeg_photo = is_jpeg_photo( $ldapserver, $attr ); //( 0 == strcasecmp( $attr, 'jpegPhoto' ) ) ? true : false;
|
||||
$current_values = $ldapserver->getDNAttr($dn,$attr);
|
||||
if ($current_values)
|
||||
$num_current_values = (is_array($current_values) ? count($current_values) : 1);
|
||||
else
|
||||
$num_current_values = 0;
|
||||
|
||||
if( $is_object_class ) {
|
||||
// fetch all available objectClasses and remove those from the list that are already defined in the entry
|
||||
$is_object_class = (strcasecmp($attr, 'objectClass') == 0) ? true : false;
|
||||
|
||||
if ($is_object_class) {
|
||||
# fetch all available objectClasses and remove those from the list that are already defined in the entry
|
||||
$schema_oclasses = $ldapserver->SchemaObjectClasses();
|
||||
|
||||
foreach( $current_values as $oclass )
|
||||
unset( $schema_oclasses[ strtolower( $oclass ) ] );
|
||||
foreach($current_values as $oclass)
|
||||
unset($schema_oclasses[strtolower($oclass)]);
|
||||
|
||||
} else {
|
||||
$schema_attr = $ldapserver->getSchemaAttribute($attr);
|
||||
}
|
||||
|
||||
include './header.php'; ?>
|
||||
include './header.php';
|
||||
|
||||
<body>
|
||||
echo '<body>';
|
||||
printf('<h3 class="title">%s <b>%s</b> %s <b>%s</b></h3>',
|
||||
_('Add new'),htmlspecialchars($attr),_('value to'),htmlspecialchars($rdn));
|
||||
printf('<h3 class="subtitle">%s <b>%s</b> %s: <b>%s</b></h3>',
|
||||
_('Server'),$ldapserver->name,_('Distinguished Name'),htmlspecialchars($dn));
|
||||
|
||||
<h3 class="title">
|
||||
<?php echo $lang['add_new']; ?>
|
||||
<b><?php echo htmlspecialchars($attr); ?></b>
|
||||
<?php echo $lang['value_to']; ?>
|
||||
<b><?php echo htmlspecialchars($rdn); ?></b></h3>
|
||||
printf('%s <b>%s</b> %s <b>%s</b>:',
|
||||
_('Current list of'),$num_current_values,_('values for attribute'),htmlspecialchars($attr));
|
||||
|
||||
<h3 class="subtitle">
|
||||
<?php echo $lang['server']; ?>:
|
||||
<b><?php echo $ldapserver->name; ?></b>
|
||||
<?php echo $lang['distinguished_name']; ?>: <b><?php echo htmlspecialchars( $dn ); ?></b></h3>
|
||||
if ($num_current_values) {
|
||||
if ($ldapserver->isJpegPhoto($attr)) {
|
||||
|
||||
<?php echo $lang['current_list_of']; ?> <b><?php echo $num_current_values; ?></b>
|
||||
<?php echo $lang['values_for_attribute']; ?> <b><?php echo htmlspecialchars($attr); ?></b>:
|
||||
echo '<table><tr><td>';
|
||||
draw_jpeg_photos($ldapserver, $dn, $attr, false);
|
||||
echo '</td></tr></table>';
|
||||
|
||||
<?php if ($num_current_values) { ?>
|
||||
<?php if( $is_jpeg_photo ) { ?>
|
||||
# <!-- Temporary warning until we find a way to add jpegPhoto values without an INAPROPRIATE_MATCHING error -->
|
||||
printf('<p><small>%s</small></p>',
|
||||
_('Note: You will get an "inappropriate matching" error if you have not setup an EQUALITY rule on your LDAP server for this attribute.'));
|
||||
# <!-- End of temporary warning -->
|
||||
|
||||
<table><tr><td>
|
||||
<?php draw_jpeg_photos( $ldapserver, $dn, $attr, false ); ?>
|
||||
</td></tr></table>
|
||||
} elseif ($ldapserver->isAttrBinary($attr)) {
|
||||
echo '<ul>';
|
||||
|
||||
<!-- Temporary warning until we find a way to add jpegPhoto values without an INAPROPRIATE_MATCHING error -->
|
||||
<p><small>
|
||||
<?php echo $lang['inappropriate_matching_note']; ?>
|
||||
</small></p>
|
||||
<!-- End of temporary warning -->
|
||||
if (is_array($vals)) {
|
||||
for ($i=1; $i<=count($vals); $i++) {
|
||||
$href = sprintf('download_binary_attr.php?server_id=%s&dn=%s&attr=%s&value_num=%s',
|
||||
$ldapserver->server_id,$encoded_dn,$attr,$i-1);
|
||||
|
||||
<?php } else if( is_attr_binary( $ldapserver, $attr ) ) { ?>
|
||||
<ul>
|
||||
printf('<li><a href="%s"><img src="images/save.png" />%s (%s)</a></li>',
|
||||
$href,_('download value'),$i);
|
||||
}
|
||||
|
||||
<?php if( is_array( $vals ) ) {
|
||||
} else {
|
||||
$href = sprintf('download_binary_attr.php?server_id=%s&dn=%s&attr=%s',
|
||||
$ldapserver->server_id,$encoded_dn,$attr);
|
||||
printf('<li><a href="%s"><img src="images/save.png" />%s</a></li>',
|
||||
$href,_('download value'));
|
||||
}
|
||||
|
||||
for( $i=1; $i<=count($vals); $i++ ) {
|
||||
|
||||
$href = sprintf('download_binary_attr.php?server_id=%s&dn=%s&attr=%s&value_num=%s',
|
||||
$ldapserver->server_id,$encoded_dn,$attr,$i-1); ?>
|
||||
|
||||
<li><a href="<?php echo $href; ?>"><img src="images/save.png" /> <?php echo $lang['download_value'] . ' ' . $i; ?>)</a></li>
|
||||
<?php }
|
||||
echo '</ul>';
|
||||
# <!-- Temporary warning until we find a way to add jpegPhoto values without an INAPROPRIATE_MATCHING error -->
|
||||
printf('<p><small>%s</small></p>',
|
||||
_('Note: You will get an "inappropriate matching" error if you have not setup an EQUALITY rule on your LDAP server for this attribute.'));
|
||||
# <!-- End of temporary warning -->
|
||||
|
||||
} else {
|
||||
$href = sprintf('download_binary_attr.php?server_id=%s&dn=%s&attr=%s',$ldapserver->server_id,$encoded_dn,$attr); ?>
|
||||
<li><a href="<?php echo $href; ?>"><img src="images/save.png" /> <?php echo $lang['download_value']; ?></a></li>
|
||||
<?php } ?>
|
||||
echo '<ul class="current_values">';
|
||||
|
||||
</ul>
|
||||
<!-- Temporary warning until we find a way to add jpegPhoto values without an INAPROPRIATE_MATCHING error -->
|
||||
<p><small>
|
||||
<?php echo $lang['inappropriate_matching_note']; ?>
|
||||
</small></p>
|
||||
<!-- End of temporary warning -->
|
||||
if (is_array($current_values)) {
|
||||
if (strcasecmp($attr,'userPassword') == 0) {
|
||||
foreach ($current_values as $key => $value) {
|
||||
if (obfuscate_password_display(get_enc_type($value)))
|
||||
echo '<li><nobr>'.preg_replace('/./','*',$value).'<br /></li>';
|
||||
else
|
||||
echo '<li><nobr>'.htmlspecialchars($value).'<br /></li>';
|
||||
}
|
||||
|
||||
<?php } else { ?>
|
||||
} else {
|
||||
foreach ($current_values as $val)
|
||||
printf('<li><nobr>%s</nobr></li>',htmlspecialchars($val));
|
||||
}
|
||||
|
||||
<ul class="current_values">
|
||||
} else {
|
||||
printf('<li><nobr>%s</nobr></li>',htmlspecialchars($current_values));
|
||||
}
|
||||
|
||||
<?php if( is_array( $current_values ) ) /*$num_current_values > 1 )*/ {
|
||||
echo '</ul>';
|
||||
}
|
||||
} else {
|
||||
echo '<br /><br />';
|
||||
}
|
||||
|
||||
foreach( $current_values as $val ) { ?>
|
||||
<li><nobr><?php echo htmlspecialchars(($val)); ?></nobr></li>
|
||||
<?php } ?>
|
||||
echo _('Enter the value you would like to add:');
|
||||
echo '<br /><br />';
|
||||
|
||||
<?php } else { ?>
|
||||
<li><nobr><?php echo htmlspecialchars(($current_values)); ?></nobr></li>
|
||||
<?php } ?>
|
||||
if ($is_object_class) {
|
||||
echo '<form action="add_oclass_form.php" method="post" class="new_value">';
|
||||
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
|
||||
printf('<input type="hidden" name="dn" value="%s" />',$encoded_dn);
|
||||
|
||||
</ul>
|
||||
echo '<select name="new_oclass[]" multiple="true" size="15">';
|
||||
foreach ($schema_oclasses as $name => $oclass) {
|
||||
# exclude any structural ones, as they'll only generate an LDAP_OBJECT_CLASS_VIOLATION
|
||||
if ($oclass->getType() == 'structural')
|
||||
continue;
|
||||
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<br />
|
||||
<br />
|
||||
<?php } ?>
|
||||
printf('<option value="%s">%s</option>',$oclass->getName(),$oclass->getName());
|
||||
}
|
||||
echo '</select>';
|
||||
|
||||
<?php echo $lang['enter_value_to_add']; ?>
|
||||
<br />
|
||||
<br />
|
||||
echo '<br />';
|
||||
printf('<input type="submit" value="%s" />',_('Add new ObjectClass'));
|
||||
echo '<br />';
|
||||
|
||||
<?php if( $is_object_class ) { ?>
|
||||
if ($config->GetValue('appearance','show_hints'))
|
||||
printf('<small><br /><img src="images/light.png" /><span class="hint">%s</span></small>',
|
||||
_('Note: You may be required to enter new attributes that these objectClass(es) require'));
|
||||
|
||||
<form action="add_oclass_form.php" method="post" class="new_value">
|
||||
<input type="hidden" name="server_id" value="<?php echo $ldapserver->server_id; ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
|
||||
<select name="new_oclass[]" multiple="true" size="15">
|
||||
} else {
|
||||
echo '<form action="add_value.php" method="post" class="new_value" name="new_value_form">';
|
||||
|
||||
<?php foreach( $schema_oclasses as $name => $oclass ) {
|
||||
if ($ldapserver->isAttrBinary($attr))
|
||||
echo 'enctype="multipart/form-data"';
|
||||
|
||||
// exclude any structural ones, as they'll only generate an LDAP_OBJECT_CLASS_VIOLATION
|
||||
if ($oclass->getType() == "structural") continue; ?>
|
||||
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
|
||||
printf('<input type="hidden" name="dn" value="%s" />',$encoded_dn);
|
||||
printf('<input type="hidden" name="attr" value="%s" />',$encoded_attr);
|
||||
|
||||
<option value="<?php echo $oclass->getName(); ?>"><?php echo $oclass->getName(); ?></option>
|
||||
if ($ldapserver->isAttrBinary($attr)) {
|
||||
echo '<input type="file" name="new_value" />';
|
||||
echo '<input type="hidden" name="binary" value="true" />';
|
||||
|
||||
<?php } ?>
|
||||
} else {
|
||||
if ($ldapserver->isMultiLineAttr($attr)) {
|
||||
echo '<textarea name="new_value" rows="3" cols="30"></textarea>';
|
||||
} else {
|
||||
printf('<input type="text"%s name="new_value" size="40" value="" />',
|
||||
($schema_attr->getMaxLength() ? sprintf(' maxlength="%s"',$schema_attr->getMaxLength()) : ''));
|
||||
|
||||
</select>
|
||||
<br />
|
||||
<input type="submit" value="<?php echo $lang['add_new_objectclass']; ?>" />
|
||||
# draw the "browse" button next to this input box if this attr houses DNs:
|
||||
if ($ldapserver->isDNAttr($attr))
|
||||
draw_chooser_link("new_value_form.new_value", false);
|
||||
}
|
||||
}
|
||||
|
||||
<br />
|
||||
<?php if ($config->GetValue('appearance','show_hints')) { ?>
|
||||
<small>
|
||||
<br />
|
||||
<img src="images/light.png" /><span class="hint"><?php echo $lang['new_required_attrs_note']; ?></span>
|
||||
</small>
|
||||
<?php }
|
||||
printf('<input type="submit" name="submit" value="%s" />',_('Add New Value'));
|
||||
echo '<br />';
|
||||
|
||||
} else { ?>
|
||||
if ($schema_attr->getDescription())
|
||||
printf('<small><b>%s:</b> %s</small><br />',_('Description'),$schema_attr->getDescription());
|
||||
|
||||
<form action="add_value.php" method="post" class="new_value" name="new_value_form"<?php
|
||||
if( is_attr_binary( $ldapserver, $attr ) ) echo "enctype=\"multipart/form-data\""; ?>>
|
||||
if ($schema_attr->getType())
|
||||
printf('<small><b>%s:</b> %s</small><br />',_('Syntax'),$schema_attr->getType());
|
||||
|
||||
<input type="hidden" name="server_id" value="<?php echo $ldapserver->server_id; ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
|
||||
<input type="hidden" name="attr" value="<?php echo $encoded_attr; ?>" />
|
||||
if ($schema_attr->getMaxLength())
|
||||
printf('<small><b>%s:</b> %s %s</small><br />',
|
||||
_('Maximum Length'),number_format($schema_attr->getMaxLength()),_('characters'));
|
||||
|
||||
<?php if( is_attr_binary( $ldapserver, $attr ) ) { ?>
|
||||
<input type="file" name="new_value" />
|
||||
<input type="hidden" name="binary" value="true" />
|
||||
|
||||
<?php } else {
|
||||
if( is_multi_line_attr( $attr, $ldapserver->server_id ) ) { ?>
|
||||
|
||||
<textarea name="new_value" rows="3" cols="30"></textarea>
|
||||
|
||||
<?php } else { ?>
|
||||
<input type="text" <?php if( $schema_attr->getMaxLength() ) echo "maxlength=\"" . $schema_attr->getMaxLength() . "\" "; ?>name="new_value" size="40" value="" />
|
||||
|
||||
<?php // draw the "browse" button next to this input box if this attr houses DNs:
|
||||
if( is_dn_attr( $ldapserver, $attr ) )
|
||||
draw_chooser_link( "new_value_form.new_value", false ); ?>
|
||||
|
||||
<?php }
|
||||
} ?>
|
||||
|
||||
<input type="submit" name="submit" value="<?php echo $lang['add_new_value']; ?>" />
|
||||
<br />
|
||||
|
||||
<?php if( $schema_attr->getDescription() ) { ?>
|
||||
<small><b><?php echo $lang['desc']; ?>:</b> <?php echo $schema_attr->getDescription(); ?></small><br />
|
||||
<?php } ?>
|
||||
|
||||
<?php if( $schema_attr->getType() ) { ?>
|
||||
<small><b><?php echo $lang['syntax']; ?>:</b> <?php echo $schema_attr->getType(); ?></small><br />
|
||||
<?php } ?>
|
||||
|
||||
<?php if( $schema_attr->getMaxLength() ) { ?>
|
||||
<small><b><?php echo $lang['maximum_length']; ?>:</b> <?php echo number_format( $schema_attr->getMaxLength() ); ?> <?php echo $lang['characters']; ?></small><br />
|
||||
<?php } ?>
|
||||
|
||||
</form>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
echo '</form>';
|
||||
}
|
||||
echo '</body></html>';
|
||||
?>
|
||||
|
Reference in New Issue
Block a user