RELEASE 1.0.2
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_attr_form.php,v 1.14 2005/12/10 10:34:54 wurley Exp $
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_attr_form.php,v 1.15 2006/10/28 07:22:39 wurley Exp $
|
||||
|
||||
/**
|
||||
* Displays a form for adding an attribute/value to an LDAP entry.
|
||||
@@ -16,166 +16,163 @@
|
||||
|
||||
require './common.php';
|
||||
|
||||
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.') );
|
||||
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.'));
|
||||
|
||||
$dn = $_GET['dn'];
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$rdn = get_rdn( $dn );
|
||||
$encoded_dn = rawurlencode($dn);
|
||||
$rdn = get_rdn($dn);
|
||||
|
||||
$friendly_attrs = process_friendly_attr_table();
|
||||
|
||||
include './header.php'; ?>
|
||||
include './header.php';
|
||||
|
||||
<body>
|
||||
echo '<body>';
|
||||
|
||||
<h3 class="title"><?php echo sprintf( _('Add new attribute'), htmlspecialchars( $rdn ) ); ?></b></h3>
|
||||
<h3 class="subtitle"><?php echo _('Server'); ?>: <b><?php echo $ldapserver->name; ?></b> <?php echo _('Distinguished Name'); ?>: <b><?php echo htmlspecialchars( ( $dn ) ); ?></b></h3>
|
||||
printf('<h3 class="title">%s <b>%s</b></h3>',_('Add new attribute'),htmlspecialchars($rdn));
|
||||
printf('<h3 class="subtitle">%s: <b>%s</b> %s: <b>%s</b></h3>',
|
||||
_('Server'),$ldapserver->name,_('Distinguished Name'),htmlspecialchars($dn));
|
||||
|
||||
<?php $attrs = $ldapserver->getDNAttrs($dn);
|
||||
$attrs = $ldapserver->getDNAttrs($dn);
|
||||
|
||||
$oclasses = $ldapserver->getDNAttr($dn,'objectClass');
|
||||
if( ! is_array( $oclasses ) )
|
||||
$oclasses = array( $oclasses );
|
||||
if (! is_array($oclasses))
|
||||
$oclasses = array($oclasses);
|
||||
|
||||
$avail_attrs = array();
|
||||
|
||||
$schema_oclasses = $ldapserver->SchemaObjectClasses($dn);
|
||||
foreach( $oclasses as $oclass ) {
|
||||
$schema_oclass = $ldapserver->getSchemaObjectClass($oclass,$dn);
|
||||
if (array_search('extensibleObject',$oclasses) !== FALSE) {
|
||||
$schema_attrs = $ldapserver->SchemaAttributes();
|
||||
|
||||
if( $schema_oclass && 0 == strcasecmp( 'objectclass', get_class( $schema_oclass ) ) )
|
||||
$avail_attrs = array_merge( $schema_oclass->getMustAttrNames( $schema_oclasses ),
|
||||
$schema_oclass->getMayAttrNames( $schema_oclasses ),
|
||||
$avail_attrs );
|
||||
foreach ($schema_attrs as $attr)
|
||||
$avail_attrs[]=$attr->getName();
|
||||
|
||||
} else {
|
||||
$schema_oclasses = $ldapserver->SchemaObjectClasses($dn);
|
||||
|
||||
foreach ($oclasses as $oclass) {
|
||||
$schema_oclass = $ldapserver->getSchemaObjectClass($oclass,$dn);
|
||||
|
||||
if ($schema_oclass && strcasecmp('objectclass',get_class($schema_oclass)) == 0)
|
||||
$avail_attrs = array_merge($schema_oclass->getMustAttrNames($schema_oclasses),
|
||||
$schema_oclass->getMayAttrNames($schema_oclasses),
|
||||
$avail_attrs);
|
||||
}
|
||||
}
|
||||
|
||||
$avail_attrs = array_unique( $avail_attrs );
|
||||
$avail_attrs = array_filter( $avail_attrs, "not_an_attr" );
|
||||
sort( $avail_attrs );
|
||||
$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 ) {
|
||||
|
||||
foreach ($avail_attrs as $i => $attr) {
|
||||
|
||||
if ($ldapserver->isAttrBinary($attr)) {
|
||||
$avail_binary_attrs[] = $attr;
|
||||
unset( $avail_attrs[ $i ] );
|
||||
unset($avail_attrs[$i]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<br />
|
||||
echo '<center>';
|
||||
|
||||
<center>
|
||||
if (is_array($avail_attrs) && count($avail_attrs) > 0) {
|
||||
echo '<br />';
|
||||
echo _('Add new attribute');
|
||||
echo '<br />';
|
||||
echo '<br />';
|
||||
|
||||
<?php echo _('Add new attribute');
|
||||
echo '<form action="add_attr.php" method="post">';
|
||||
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
|
||||
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($dn));
|
||||
|
||||
if( is_array( $avail_attrs ) && count( $avail_attrs ) > 0 ) { ?>
|
||||
echo '<select name="attr">';
|
||||
|
||||
<br />
|
||||
<br />
|
||||
$attr_select_html = '';
|
||||
usort($avail_attrs,'sortAttrs');
|
||||
|
||||
<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); ?>" />
|
||||
foreach ($avail_attrs as $a) {
|
||||
|
||||
<select name="attr">
|
||||
|
||||
<?php $attr_select_html = '';
|
||||
usort($avail_attrs,"sortAttrs");
|
||||
foreach( $avail_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 ) ] ) . " (" .
|
||||
htmlspecialchars($a) . ")";
|
||||
# is there a user-friendly translation available for this attribute?
|
||||
if (isset($friendly_attrs[strtolower($a)])) {
|
||||
$attr_display = sprintf('%s (%s)',
|
||||
htmlspecialchars($friendly_attrs[strtolower($a)]),
|
||||
htmlspecialchars($a));
|
||||
|
||||
} else {
|
||||
$attr_display = htmlspecialchars( $a );
|
||||
$attr_display = htmlspecialchars($a);
|
||||
}
|
||||
|
||||
echo $attr_display;
|
||||
$attr_select_html .= "<option>$attr_display</option>\n";
|
||||
echo "<option value=\"" . htmlspecialchars($a) . "\">$attr_display</option>";
|
||||
} ?>
|
||||
printf('<option value="%s">%s</option>',htmlspecialchars($a),$attr_display);
|
||||
}
|
||||
|
||||
</select>
|
||||
echo '</select>';
|
||||
|
||||
<input type="text" name="val" size="20" />
|
||||
<input type="submit" name="submit" value="<?php echo _('Add'); ?>" class="update_dn" />
|
||||
</form>
|
||||
echo '<input type="text" name="val" size="20" />';
|
||||
printf('<input type="submit" name="submit" value="%s" class="update_dn" />',_('Add'));
|
||||
echo '</form>';
|
||||
|
||||
<?php } else { ?>
|
||||
} else {
|
||||
echo '<br />';
|
||||
printf('<small>(%s)</small>',_('no new attributes available for this entry'));
|
||||
}
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<small>(<?php echo _('no new attributes available for this entry'); ?>)</small>
|
||||
<br />
|
||||
<br />
|
||||
if (count($avail_binary_attrs) > 0) {
|
||||
echo '<br />';
|
||||
echo _('Add new binary attribute');
|
||||
echo '<br />';
|
||||
echo '<br />';
|
||||
|
||||
<?php } ?>
|
||||
echo '<!-- Form to add a new BINARY attribute to this entry -->';
|
||||
echo '<form action="add_attr.php" method="post" enctype="multipart/form-data">';
|
||||
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
|
||||
printf('<input type="hidden" name="dn" value="%s" />',$dn);
|
||||
echo '<input type="hidden" name="binary" value="true" />';
|
||||
|
||||
<?php echo _('Add new binary attribute');
|
||||
if( count( $avail_binary_attrs ) > 0 ) { ?>
|
||||
echo '<select name="attr">';
|
||||
|
||||
<!-- Form to add a new BINARY attribute to this entry -->
|
||||
<form action="add_attr.php" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="server_id" value="<?php echo $ldapserver->server_id; ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo $dn; ?>" />
|
||||
<input type="hidden" name="binary" value="true" />
|
||||
<br />
|
||||
$attr_select_html = '';
|
||||
usort($avail_binary_attrs,'sortAttrs');
|
||||
|
||||
<select name="attr">
|
||||
foreach ($avail_binary_attrs as $a) {
|
||||
|
||||
<?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 ) ] ) . " (" .
|
||||
htmlspecialchars($a) . ")";
|
||||
# is there a user-friendly translation available for this attribute?
|
||||
if (isset($friendly_attrs[strtolower($a)])) {
|
||||
$attr_display = sprintf('%s (%s)',
|
||||
htmlspecialchars($friendly_attrs[strtolower($a)]),
|
||||
htmlspecialchars($a));
|
||||
|
||||
} else {
|
||||
$attr_display = htmlspecialchars( $a );
|
||||
$attr_display = htmlspecialchars($a);
|
||||
}
|
||||
|
||||
echo $attr_display;
|
||||
$attr_select_html .= "<option>$attr_display</option>\n";
|
||||
echo "<option value=\"" . htmlspecialchars($a) . "\">$attr_display</option>";
|
||||
} ?>
|
||||
printf('<option value="%s">%s</option>',htmlspecialchars($a),$attr_display);
|
||||
}
|
||||
|
||||
</select>
|
||||
echo '</select>';
|
||||
|
||||
<input type="file" name="val" size="20" />
|
||||
<input type="submit" name="submit" value="<?php echo _('Add'); ?>" class="update_dn" />
|
||||
echo '<input type="file" name="val" size="20" />';
|
||||
printf('<input type="submit" name="submit" value="%s" class="update_dn" />',_('Add'));
|
||||
|
||||
<?php if( ! ini_get( 'file_uploads' ) )
|
||||
echo "<br><small><b>" . _('Your PHP configuration has disabled file uploads. Please check php.ini before proceeding.') . "</b></small><br>";
|
||||
if (! ini_get('file_uploads'))
|
||||
printf('<br /><small><b>%s</b></small><br />',
|
||||
_('Your PHP configuration has disabled file uploads. Please check php.ini before proceeding.'));
|
||||
|
||||
else
|
||||
echo "<br><small><b>" . sprintf( _('Maximum file size: %s'), ini_get( 'upload_max_filesize' ) ) . "</b></small><br>";
|
||||
?>
|
||||
printf('<br /><small><b>%s: %s</b></small><br />',_('Maximum file size'),ini_get('upload_max_filesize'));
|
||||
|
||||
</form>
|
||||
echo '</form>';
|
||||
|
||||
<?php } else { ?>
|
||||
} else {
|
||||
echo '<br />';
|
||||
printf('<small>(%s)</small>',_('no new binary attributes available for this entry'));
|
||||
}
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<small>(<?php echo _('no new binary attributes available for this entry'); ?>)</small>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
echo '</center>';
|
||||
echo '</body>';
|
||||
echo '</html>';
|
||||
|
||||
/**
|
||||
* Given an attribute $x, this returns true if it is NOT already specified
|
||||
@@ -185,13 +182,13 @@ if( count( $avail_binary_attrs ) > 0 ) { ?>
|
||||
* @return bool
|
||||
* @ignore
|
||||
*/
|
||||
function not_an_attr( $x ) {
|
||||
function not_an_attr($x) {
|
||||
global $attrs;
|
||||
|
||||
//return ! isset( $attrs[ strtolower( $x ) ] );
|
||||
foreach( $attrs as $attr => $values )
|
||||
if( 0 == strcasecmp( $attr, $x ) )
|
||||
foreach($attrs as $attr => $values)
|
||||
if (strcasecmp($attr,$x) == 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user