RELEASE 0.9.1
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
require 'config.php';
|
||||
require 'common.php';
|
||||
|
||||
// Common to all templates
|
||||
$rdn = stripslashes( $_POST['rdn'] );
|
||||
$container = stripslashes( $_POST['container'] );
|
||||
$rdn = isset( $_POST['rdn'] ) ? $_POST['rdn'] : null;
|
||||
$container = $_POST['container'];
|
||||
$server_id = $_POST['server_id'];
|
||||
|
||||
// Unique to this template
|
||||
$step = $_POST['step'];
|
||||
$step = isset( $_POST['step'] ) ? $_POST['step'] : null;
|
||||
if( ! $step )
|
||||
$step = 1;
|
||||
|
||||
@@ -34,7 +34,7 @@ if( $step == 1 )
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="heading">Container:</td>
|
||||
<td><input type="text" name="container" size="40" value="<?php echo htmlspecialchars($container); ?>" />
|
||||
<td><input type="text" name="container" size="40" value="<?php echo htmlspecialchars( $container ); ?>" />
|
||||
<?php draw_chooser_link( 'creation_form.container' ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -74,32 +74,55 @@ if( $step == 2 )
|
||||
|
||||
// build a list of required attributes:
|
||||
$dn = $rdn . ',' . $container;
|
||||
$schema = get_schema( $server_id );
|
||||
$attrs = $schema['attrs'];
|
||||
//$attrs = get_schema_attributes( $server_id );
|
||||
$schema_oclasses = get_schema_objectclasses( $server_id );
|
||||
$required_attrs = array();
|
||||
$all_attrs = array();
|
||||
foreach( $oclasses as $oclass ) {
|
||||
$required_attrs = array_merge( $required_attrs, $schema['oclasses'][strtolower($oclass)]['must_attrs'] );
|
||||
$all_attrs = array_merge( $all_attrs, $schema['oclasses'][strtolower($oclass)]['must_attrs'],
|
||||
$schema['oclasses'][strtolower($oclass)]['may_attrs'] );
|
||||
$required_attrs = array_merge( $required_attrs, $schema_oclasses[strtolower($oclass)]['must_attrs'] );
|
||||
$all_attrs = array_merge( $all_attrs, $schema_oclasses[strtolower($oclass)]['must_attrs'],
|
||||
$schema_oclasses[strtolower($oclass)]['may_attrs'] );
|
||||
}
|
||||
|
||||
$required_attrs = array_unique( $required_attrs );
|
||||
$all_attrs = array_unique( $all_attrs );
|
||||
sort( $required_attrs );
|
||||
sort( $all_attrs );
|
||||
|
||||
// remove binary attributes and add them to the binary_attrs array
|
||||
$binary_attrs = array();
|
||||
foreach( $all_attrs as $i => $attr_name ) {
|
||||
if( is_attr_binary( $server_id, $attr_name ) ) {
|
||||
unset( $all_attrs[ $i ] );
|
||||
$binary_attrs[] = $attr_name;
|
||||
}
|
||||
}
|
||||
|
||||
$attr_select_html = "";
|
||||
foreach( $all_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) . ")";
|
||||
htmlspecialchars($a) . ")";
|
||||
} else {
|
||||
$attr_display = htmlspecialchars( $a );
|
||||
}
|
||||
|
||||
echo $attr_display;
|
||||
$attr_select_html .= "<option>$attr_display</option>\n";
|
||||
$attr_select_html .= "<option value=\"$a\">$attr_display</option>\n";
|
||||
}
|
||||
|
||||
$binary_select_html = "";
|
||||
if( count( $binary_attrs ) > 0 ) {
|
||||
foreach( $binary_attrs as $a ) {
|
||||
if( isset( $friendly_attrs[ strtolower( $a ) ] ) ) {
|
||||
$attr_display = htmlspecialchars( $friendly_attrs[ strtolower( $a ) ] ) . " (" .
|
||||
htmlspecialchars( $a ) . ")";
|
||||
} else {
|
||||
$attr_display = htmlspecialchars( $a );
|
||||
}
|
||||
|
||||
$binary_attr_select_html .= "<option>$attr_display</option>\n";
|
||||
}
|
||||
}
|
||||
|
||||
// add the required attribute based on the RDN provided by the user
|
||||
@@ -107,29 +130,19 @@ if( $step == 2 )
|
||||
// in the list of required attributes.
|
||||
$rdn_attr = trim( substr( $rdn, 0, strpos( $rdn, '=' ) ) );
|
||||
$rdn_value = trim( substr( $rdn, strpos( $rdn, '=' ) + 1 ) );
|
||||
if( ! in_array( $rdn_attr, $required_attrs ) )
|
||||
if( in_array( $rdn_attr, $all_attrs ) && ! in_array( $rdn_attr, $required_attrs ) )
|
||||
$required_attrs[] = $rdn_attr;
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<h4>Step 2 of 2: Specify attributes and values</h4>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td style="padding-right:10px">
|
||||
<small>Creating entry with <acronym title="Distinguished Name">DN</acronym>:
|
||||
<b><?php echo htmlspecialchars( $dn ); ?></b></small></td>
|
||||
<small><b>Instructions</b>:
|
||||
Enter values for the <?php echo count($required_attrs); ?> required attributes.<br/>
|
||||
Then specify any optional attributes. <?php if( count( $binary_attrs ) > 0 ) { ?>
|
||||
Finally, you may<br />specify optional binary attributes from a file if needed. <?php } ?>
|
||||
</small>
|
||||
|
||||
<td>
|
||||
<small><b>Instrucions</b>: Enter values for the <?php echo count($required_attrs); ?>
|
||||
required attributes. Then create any optional attributes. You
|
||||
can specify multi-valued attributes as well.</small><br />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<form action="create.php" method="post">
|
||||
<form action="create.php" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="step" value="2" />
|
||||
<input type="hidden" name="new_dn" value="<?php echo htmlspecialchars( $dn ); ?>" />
|
||||
<input type="hidden" name="new_rdn" value="<?php echo htmlspecialchars( $rdn ); ?>" />
|
||||
@@ -139,7 +152,11 @@ if( $step == 2 )
|
||||
|
||||
<table class="edit_dn" cellspacing="0">
|
||||
<tr><th colspan="2">Required Attributes</th></tr>
|
||||
<?php foreach( $required_attrs as $count => $attr ) { ?>
|
||||
<?php if( count( $required_attrs ) == 0 ) {
|
||||
echo "<tr class=\"row1\"><td colspan=\"2\"><center>(none)</center></td></tr>\n";
|
||||
} else
|
||||
|
||||
foreach( $required_attrs as $count => $attr ) { ?>
|
||||
<?php if( $count % 2 == 0 ) { ?>
|
||||
<tr class="row1">
|
||||
<?php } else { ?>
|
||||
@@ -150,7 +167,7 @@ if( $step == 2 )
|
||||
// is there a user-friendly translation available for this attribute?
|
||||
if( isset( $friendly_attrs[ strtolower( $attr ) ] ) ) {
|
||||
$attr_display = "<acronym title=\"Alias for " . htmlspecialchars($attr) . "\">" .
|
||||
htmlspecialchars( $friendly_attrs[ strtolower( $attr ) ] ) . "</acronym>";
|
||||
htmlspecialchars( $friendly_attrs[ strtolower( $attr ) ] ) . "</acronym>";
|
||||
} else {
|
||||
$attr_display = htmlspecialchars( $attr );
|
||||
}
|
||||
@@ -158,7 +175,7 @@ if( $step == 2 )
|
||||
echo $attr_display;
|
||||
|
||||
?></b></td>
|
||||
<td class="val"><input type="text"
|
||||
<td class="val"><input type="<?php echo (is_attr_binary( $server_id, $attr ) ? "file" : "text"); ?>"
|
||||
name="required_attrs[<?php echo htmlspecialchars($attr); ?>]"
|
||||
value="<?php echo $attr == $rdn_attr ? $rdn_value : '' ?>" size="40" />
|
||||
</tr>
|
||||
@@ -166,16 +183,33 @@ if( $step == 2 )
|
||||
|
||||
<tr><th colspan="2">Optional Attributes</th></tr>
|
||||
|
||||
<?php for($i=0; $i<10; $i++ ) { ?>
|
||||
<?php if( count( $all_attrs ) == 0 ) { ?>
|
||||
<tr class="row1"><td colspan="2"><center>(none)</center></td></tr>
|
||||
<?php } else { ?>
|
||||
<?php for($i=0; $i<min( count( $all_attrs ), 10 ); $i++ ) { ?>
|
||||
<?php if( $i % 2 == 0 ) { ?>
|
||||
<tr class="row1">
|
||||
<?php } else { ?>
|
||||
<tr class="row2">
|
||||
<?php } ?>
|
||||
<td class="attr"><select name="attrs[<?php echo $i; ?>]"><?php echo $attr_select_html; ?></select></td>
|
||||
<td class="val"><input type="text" name="vals[<?php echo $i; ?>]" value="" size="40" />
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if( count( $binary_attrs ) > 0 ) { ?>
|
||||
<tr><th colspan="2">Optional Binary Attributes</th></tr>
|
||||
<?php for( $k=$i; $k<$i+count($binary_attrs); $k++ ) { $attr = $binary_attrs[$k]; ?>
|
||||
<?php if( $i % 2 == 0 ) { ?>
|
||||
<tr class="row1">
|
||||
<?php } else { ?>
|
||||
<tr class="row2">
|
||||
<?php } ?>
|
||||
<td class="attr"><select name="attrs[<?php echo $i; ?>]"><?php echo $attr_select_html; ?></select></td>
|
||||
<td class="val"><input type="text" name="vals[<?php echo $i; ?>]" value="" size="40" />
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<td class="attr"><select name="attrs[<?php echo $k; ?>]"><?php echo $binary_attr_select_html;?></select></td>
|
||||
<td class="val"><input type="file" name="vals[<?php echo $k; ?>]" value="" size="40" />
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<center>
|
||||
|
Reference in New Issue
Block a user