2009-06-30 09:22:30 +00:00
|
|
|
<?php
|
2009-06-30 09:29:51 +00:00
|
|
|
// $Header: /cvsroot/phpldapadmin/phpldapadmin/add_value_form.php,v 1.32 2005/07/22 06:34:55 wurley Exp $
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
/**
|
2009-06-30 08:05:37 +00:00
|
|
|
* Displays a form to allow the user to enter a new value to add
|
|
|
|
* to the existing list of values for a multi-valued attribute.
|
2009-06-30 09:29:51 +00:00
|
|
|
*
|
|
|
|
* Variables that come in via common.php
|
|
|
|
* - server_id
|
2009-06-30 08:05:37 +00:00
|
|
|
* Variables that come in as GET vars:
|
|
|
|
* - dn (rawurlencoded)
|
2009-06-30 09:29:51 +00:00
|
|
|
* - attr (rawurlencoded) the attribute to which we are adding a value
|
2009-06-30 08:05:37 +00:00
|
|
|
*
|
2009-06-30 09:29:51 +00:00
|
|
|
* @package phpLDAPadmin
|
|
|
|
*/
|
|
|
|
/**
|
2009-06-30 08:05:37 +00:00
|
|
|
*/
|
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
require './common.php';
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
if( $ldapserver->isReadOnly() )
|
|
|
|
pla_error( $lang['no_updates_in_read_only_mode'] );
|
|
|
|
if( ! $ldapserver->haveAuthInfo())
|
|
|
|
pla_error( $lang['not_enough_login_info'] );
|
|
|
|
|
|
|
|
$attr = $_GET['attr'];
|
2009-06-30 09:22:30 +00:00
|
|
|
$dn = isset( $_GET['dn'] ) ? $_GET['dn'] : null;
|
2009-06-30 08:05:37 +00:00
|
|
|
$encoded_dn = rawurlencode( $dn );
|
|
|
|
$encoded_attr = rawurlencode( $attr );
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
if (! is_null($dn))
|
|
|
|
$rdn = get_rdn( $dn );
|
2009-06-30 08:07:14 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
else
|
|
|
|
$rdn = null;
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
$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;
|
|
|
|
|
|
|
|
if( $is_object_class ) {
|
2009-06-30 08:05:37 +00:00
|
|
|
// fetch all available objectClasses and remove those from the list that are already defined in the entry
|
2009-06-30 09:29:51 +00:00
|
|
|
$schema_oclasses = get_schema_objectclasses( $ldapserver );
|
|
|
|
|
2009-06-30 08:05:37 +00:00
|
|
|
foreach( $current_values as $oclass )
|
|
|
|
unset( $schema_oclasses[ strtolower( $oclass ) ] );
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 08:05:37 +00:00
|
|
|
} else {
|
2009-06-30 09:29:51 +00:00
|
|
|
$schema_attr = get_schema_attribute( $ldapserver, $attr );
|
2009-06-30 08:05:37 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
include './header.php'; ?>
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
<body>
|
|
|
|
|
2009-06-30 08:07:14 +00:00
|
|
|
<h3 class="title">
|
|
|
|
<?php echo $lang['add_new']; ?>
|
2009-06-30 09:29:51 +00:00
|
|
|
<b><?php echo htmlspecialchars($attr); ?></b>
|
2009-06-30 08:07:14 +00:00
|
|
|
<?php echo $lang['value_to']; ?>
|
2009-06-30 09:22:30 +00:00
|
|
|
<b><?php echo htmlspecialchars($rdn); ?></b></h3>
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 08:07:14 +00:00
|
|
|
<h3 class="subtitle">
|
2009-06-30 09:29:51 +00:00
|
|
|
<?php echo $lang['server']; ?>:
|
|
|
|
<b><?php echo $ldapserver->name; ?></b>
|
2009-06-30 08:07:14 +00:00
|
|
|
<?php echo $lang['distinguished_name']; ?>: <b><?php echo htmlspecialchars( $dn ); ?></b></h3>
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<?php echo $lang['current_list_of']; ?> <b><?php echo $num_current_values; ?></b>
|
2009-06-30 08:07:14 +00:00
|
|
|
<?php echo $lang['values_for_attribute']; ?> <b><?php echo htmlspecialchars($attr); ?></b>:
|
2009-06-30 09:29:51 +00:00
|
|
|
|
|
|
|
<?php if ($num_current_values) { ?>
|
2009-06-30 08:05:37 +00:00
|
|
|
<?php if( $is_jpeg_photo ) { ?>
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<table><tr><td>
|
|
|
|
<?php draw_jpeg_photos( $ldapserver, $dn, $attr, false ); ?>
|
|
|
|
</td></tr></table>
|
|
|
|
|
|
|
|
<!-- Temporary warning until we find a way to add jpegPhoto values without an INAPROPRIATE_MATCHING error -->
|
2009-06-30 08:05:37 +00:00
|
|
|
<p><small>
|
2009-06-30 08:07:14 +00:00
|
|
|
<?php echo $lang['inappropriate_matching_note']; ?>
|
|
|
|
</small></p>
|
|
|
|
<!-- End of temporary warning -->
|
2009-06-30 09:29:51 +00:00
|
|
|
|
|
|
|
<?php } else if( is_attr_binary( $ldapserver, $attr ) ) { ?>
|
2009-06-30 08:07:14 +00:00
|
|
|
<ul>
|
2009-06-30 09:29:51 +00:00
|
|
|
|
|
|
|
<?php 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); ?>
|
|
|
|
|
|
|
|
<li><a href="<?php echo $href; ?>"><img src="images/save.png" /> <?php echo $lang['download_value'] . ' ' . $i; ?>)</a></li>
|
|
|
|
<?php }
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$href = sprintf('download_binary_attr.php?server_id=%s&dn=%s&attr=%s',$ldapserver->server_id,$encoded_dn,$attr); ?>
|
2009-06-30 08:07:14 +00:00
|
|
|
<li><a href="<?php echo $href; ?>"><img src="images/save.png" /> <?php echo $lang['download_value']; ?></a></li>
|
|
|
|
<?php } ?>
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 08:07:14 +00:00
|
|
|
</ul>
|
2009-06-30 09:29:51 +00:00
|
|
|
<!-- Temporary warning until we find a way to add jpegPhoto values without an INAPROPRIATE_MATCHING error -->
|
2009-06-30 08:07:14 +00:00
|
|
|
<p><small>
|
|
|
|
<?php echo $lang['inappropriate_matching_note']; ?>
|
2009-06-30 08:05:37 +00:00
|
|
|
</small></p>
|
|
|
|
<!-- End of temporary warning -->
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 08:05:37 +00:00
|
|
|
<?php } else { ?>
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<ul class="current_values">
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<?php if( is_array( $current_values ) ) /*$num_current_values > 1 )*/ {
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
foreach( $current_values as $val ) { ?>
|
|
|
|
<li><nobr><?php echo htmlspecialchars(($val)); ?></nobr></li>
|
|
|
|
<?php } ?>
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<?php } else { ?>
|
2009-06-30 08:09:20 +00:00
|
|
|
<li><nobr><?php echo htmlspecialchars(($current_values)); ?></nobr></li>
|
2009-06-30 09:29:51 +00:00
|
|
|
<?php } ?>
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
</ul>
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
<?php } ?>
|
2009-06-30 09:29:51 +00:00
|
|
|
<?php } else { ?>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<?php } ?>
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 08:07:14 +00:00
|
|
|
<?php echo $lang['enter_value_to_add']; ?>
|
|
|
|
<br />
|
2009-06-30 08:05:37 +00:00
|
|
|
<br />
|
|
|
|
|
|
|
|
<?php if( $is_object_class ) { ?>
|
|
|
|
|
|
|
|
<form action="add_oclass_form.php" method="post" class="new_value">
|
2009-06-30 09:29:51 +00:00
|
|
|
<input type="hidden" name="server_id" value="<?php echo $ldapserver->server_id; ?>" />
|
2009-06-30 08:05:37 +00:00
|
|
|
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
|
2009-06-30 09:29:51 +00:00
|
|
|
<select name="new_oclass[]" multiple="true" size="15">
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
<?php foreach( $schema_oclasses as $name => $oclass ) {
|
|
|
|
|
|
|
|
// exclude any structural ones, as they'll only generate an LDAP_OBJECT_CLASS_VIOLATION
|
2009-06-30 09:29:51 +00:00
|
|
|
if ($oclass->type == "structural") continue; ?>
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 08:09:20 +00:00
|
|
|
<option value="<?php echo $oclass->getName(); ?>"><?php echo $oclass->getName(); ?></option>
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
<?php } ?>
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
</select>
|
|
|
|
<br />
|
|
|
|
<input type="submit" value="<?php echo $lang['add_new_objectclass']; ?>" />
|
|
|
|
|
2009-06-30 08:09:20 +00:00
|
|
|
<br />
|
2009-06-30 09:29:51 +00:00
|
|
|
<?php if ($config->GetValue('appearance','show_hints')) { ?>
|
2009-06-30 08:09:20 +00:00
|
|
|
<small>
|
|
|
|
<br />
|
2009-06-30 09:22:30 +00:00
|
|
|
<img src="images/light.png" /><span class="hint"><?php echo $lang['new_required_attrs_note']; ?></span>
|
2009-06-30 08:09:20 +00:00
|
|
|
</small>
|
2009-06-30 09:29:51 +00:00
|
|
|
<?php }
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
} else { ?>
|
|
|
|
|
|
|
|
<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\""; ?>>
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<input type="hidden" name="server_id" value="<?php echo $ldapserver->server_id; ?>" />
|
2009-06-30 08:05:37 +00:00
|
|
|
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
|
|
|
|
<input type="hidden" name="attr" value="<?php echo $encoded_attr; ?>" />
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<?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 }
|
|
|
|
} ?>
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
<input type="submit" name="submit" value="<?php echo $lang['add_new_value']; ?>" />
|
2009-06-30 08:05:37 +00:00
|
|
|
<br />
|
2009-06-30 08:09:20 +00:00
|
|
|
|
|
|
|
<?php if( $schema_attr->getDescription() ) { ?>
|
2009-06-30 09:22:30 +00:00
|
|
|
<small><b><?php echo $lang['desc']; ?>:</b> <?php echo $schema_attr->getDescription(); ?></small><br />
|
2009-06-30 08:09:20 +00:00
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php if( $schema_attr->getType() ) { ?>
|
|
|
|
<small><b><?php echo $lang['syntax']; ?>:</b> <?php echo $schema_attr->getType(); ?></small><br />
|
|
|
|
<?php } ?>
|
|
|
|
|
2009-06-30 08:07:14 +00:00
|
|
|
<?php if( $schema_attr->getMaxLength() ) { ?>
|
2009-06-30 09:29:51 +00:00
|
|
|
<small><b><?php echo $lang['maximum_length']; ?>:</b> <?php echo number_format( $schema_attr->getMaxLength() ); ?> <?php echo $lang['characters']; ?></small><br />
|
2009-06-30 08:07:14 +00:00
|
|
|
<?php } ?>
|
|
|
|
|
2009-06-30 08:05:37 +00:00
|
|
|
</form>
|
|
|
|
|
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|