2009-06-30 09:22:30 +00:00
|
|
|
<?php
|
2009-06-30 09:29:51 +00:00
|
|
|
// $Header: /cvsroot/phpldapadmin/phpldapadmin/add_attr_form.php,v 1.12 2005/07/22 05:42:18 wurley Exp $
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
/**
|
2009-06-30 09:22:30 +00:00
|
|
|
* Displays a form for adding an attribute/value to an LDAP entry.
|
|
|
|
*
|
2009-06-30 09:29:51 +00:00
|
|
|
* Variables that come in via common.php
|
|
|
|
* - server_id
|
2009-06-30 09:22:30 +00:00
|
|
|
* Variables that come in as GET vars:
|
|
|
|
* - dn (rawurlencoded)
|
2009-06-30 09:29:51 +00:00
|
|
|
*
|
|
|
|
* @package phpLDAPadmin
|
|
|
|
*/
|
|
|
|
/**
|
2009-06-30 09:22:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
require './common.php';
|
|
|
|
|
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'] );
|
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
$dn = $_GET['dn'];
|
|
|
|
$encoded_dn = rawurlencode( $dn );
|
|
|
|
$rdn = get_rdn( $dn );
|
|
|
|
|
|
|
|
$friendly_attrs = process_friendly_attr_table();
|
|
|
|
|
|
|
|
include './header.php'; ?>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<h3 class="title"><?php echo sprintf( $lang['add_new_attribute'], htmlspecialchars( $rdn ) ); ?></b></h3>
|
2009-06-30 09:29:51 +00:00
|
|
|
<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>
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<?php $attrs = get_object_attrs( $ldapserver, $dn );
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
$oclasses = get_object_attr( $ldapserver, $dn, 'objectClass' );
|
2009-06-30 09:22:30 +00:00
|
|
|
if( ! is_array( $oclasses ) )
|
|
|
|
$oclasses = array( $oclasses );
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
$avail_attrs = array();
|
2009-06-30 09:29:51 +00:00
|
|
|
|
|
|
|
$schema_oclasses = get_schema_objectclasses( $ldapserver, $dn );
|
2009-06-30 09:22:30 +00:00
|
|
|
foreach( $oclasses as $oclass ) {
|
2009-06-30 09:29:51 +00:00
|
|
|
$schema_oclass = get_schema_objectclass( $ldapserver, $oclass, $dn );
|
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
if( $schema_oclass && 0 == strcasecmp( 'objectclass', get_class( $schema_oclass ) ) )
|
|
|
|
$avail_attrs = array_merge( $schema_oclass->getMustAttrNames( $schema_oclasses ),
|
2009-06-30 09:29:51 +00:00
|
|
|
$schema_oclass->getMayAttrNames( $schema_oclasses ),
|
|
|
|
$avail_attrs );
|
2009-06-30 09:22:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$avail_attrs = array_unique( $avail_attrs );
|
|
|
|
$avail_attrs = array_filter( $avail_attrs, "not_an_attr" );
|
|
|
|
sort( $avail_attrs );
|
|
|
|
|
|
|
|
$avail_binary_attrs = array();
|
|
|
|
foreach( $avail_attrs as $i => $attr ) {
|
2009-06-30 09:29:51 +00:00
|
|
|
|
|
|
|
if( is_attr_binary( $ldapserver, $attr ) ) {
|
2009-06-30 09:22:30 +00:00
|
|
|
$avail_binary_attrs[] = $attr;
|
|
|
|
unset( $avail_attrs[ $i ] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
<br />
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
<center>
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<?php echo $lang['add_new_attribute'];
|
|
|
|
|
|
|
|
if( is_array( $avail_attrs ) && count( $avail_attrs ) > 0 ) { ?>
|
|
|
|
|
|
|
|
<br />
|
|
|
|
<br />
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<form action="add_attr.php" method="post">
|
|
|
|
<input type="hidden" name="server_id" value="<?php echo $ldapserver->server_id; ?>" />
|
|
|
|
<input type="hidden" name="dn" value="<?php echo htmlspecialchars($dn); ?>" />
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<select name="attr">
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<?php $attr_select_html = '';
|
|
|
|
usort($avail_attrs,"sortAttrs");
|
|
|
|
foreach( $avail_attrs as $a ) {
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
// is there a user-friendly translation available for this attribute?
|
|
|
|
if( isset( $friendly_attrs[ strtolower( $a ) ] ) ) {
|
|
|
|
$attr_display = htmlspecialchars( $friendly_attrs[ strtolower( $a ) ] ) . " (" .
|
2009-06-30 09:22:30 +00:00
|
|
|
htmlspecialchars($a) . ")";
|
2009-06-30 09:29:51 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
$attr_display = htmlspecialchars( $a );
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $attr_display;
|
|
|
|
$attr_select_html .= "<option>$attr_display</option>\n";
|
|
|
|
echo "<option value=\"" . htmlspecialchars($a) . "\">$attr_display</option>";
|
|
|
|
} ?>
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<input type="text" name="val" size="20" />
|
|
|
|
<input type="submit" name="submit" value="<?php echo $lang['add']; ?>" class="update_dn" />
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<?php } else { ?>
|
|
|
|
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<small>(<?php echo $lang['no_new_attrs_available']; ?>)</small>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
|
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php echo $lang['add_new_binary_attr'];
|
|
|
|
if( count( $avail_binary_attrs ) > 0 ) { ?>
|
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
<!-- Form to add a new BINARY attribute to this entry -->
|
|
|
|
<form action="add_attr.php" method="post" enctype="multipart/form-data">
|
2009-06-30 09:29:51 +00:00
|
|
|
<input type="hidden" name="server_id" value="<?php echo $ldapserver->server_id; ?>" />
|
2009-06-30 09:22:30 +00:00
|
|
|
<input type="hidden" name="dn" value="<?php echo $dn; ?>" />
|
|
|
|
<input type="hidden" name="binary" value="true" />
|
|
|
|
<br />
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
<select name="attr">
|
2009-06-30 09:29:51 +00:00
|
|
|
|
|
|
|
<?php $attr_select_html = '';
|
|
|
|
|
|
|
|
usort($avail_binary_attrs,"sortAttrs");
|
|
|
|
|
|
|
|
foreach( $avail_binary_attrs as $a ) {
|
|
|
|
|
|
|
|
// is there a user-friendly translation available for this attribute?
|
|
|
|
if( isset( $friendly_attrs[ strtolower( $a ) ] ) ) {
|
|
|
|
$attr_display = htmlspecialchars( $friendly_attrs[ strtolower( $a ) ] ) . " (" .
|
2009-06-30 09:22:30 +00:00
|
|
|
htmlspecialchars($a) . ")";
|
2009-06-30 09:29:51 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
$attr_display = htmlspecialchars( $a );
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $attr_display;
|
|
|
|
$attr_select_html .= "<option>$attr_display</option>\n";
|
|
|
|
echo "<option value=\"" . htmlspecialchars($a) . "\">$attr_display</option>";
|
|
|
|
} ?>
|
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
</select>
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
<input type="file" name="val" size="20" />
|
|
|
|
<input type="submit" name="submit" value="<?php echo $lang['add']; ?>" class="update_dn" />
|
2009-06-30 09:29:51 +00:00
|
|
|
|
|
|
|
<?php if( ! ini_get( 'file_uploads' ) )
|
|
|
|
echo "<br><small><b>" . $lang['warning_file_uploads_disabled'] . "</b></small><br>";
|
|
|
|
|
|
|
|
else
|
|
|
|
echo "<br><small><b>" . sprintf( $lang['max_file_size'], ini_get( 'upload_max_filesize' ) ) . "</b></small><br>";
|
|
|
|
?>
|
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
</form>
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
<?php } else { ?>
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<small>(<?php echo $lang['no_new_binary_attrs_available']; ?>)</small>
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
</center>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given an attribute $x, this returns true if it is NOT already specified
|
|
|
|
* in the current entry, returns false otherwise.
|
2009-06-30 09:29:51 +00:00
|
|
|
*
|
|
|
|
* @param attr $x
|
|
|
|
* @return bool
|
|
|
|
* @ignore
|
2009-06-30 09:22:30 +00:00
|
|
|
*/
|
2009-06-30 09:29:51 +00:00
|
|
|
function not_an_attr( $x ) {
|
2009-06-30 09:22:30 +00:00
|
|
|
global $attrs;
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 09:22:30 +00:00
|
|
|
//return ! isset( $attrs[ strtolower( $x ) ] );
|
|
|
|
foreach( $attrs as $attr => $values )
|
|
|
|
if( 0 == strcasecmp( $attr, $x ) )
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
?>
|