RELEASE 0.9.1
This commit is contained in:
577
edit.php
577
edit.php
@@ -7,20 +7,22 @@
|
||||
* Variables that come in as GET vars:
|
||||
* - dn (rawurlencoded)
|
||||
* - server_id
|
||||
* - modified_attrs (optional) an array of attributes to highlight as
|
||||
* they were changed by the last operation
|
||||
*/
|
||||
|
||||
/** If an entry has more children than this, stop searching and display this amount with a '+' */
|
||||
$max_children = 100;
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
require 'common.php';
|
||||
|
||||
$dn = stripslashes( rawurldecode( $_GET['dn'] ) );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$updated_attr = stripslashes( $_GET['updated_attr'] );
|
||||
$dn= $_GET['dn'];
|
||||
$decoded_dn = rawurldecode( $dn );
|
||||
$encoded_dn = rawurlencode( $decoded_dn );
|
||||
$modified_attrs = isset( $_GET['modified_attrs'] ) ? $_GET['modified_attrs'] : false;
|
||||
$server_id = $_GET['server_id'];
|
||||
$show_internal_attrs = isset( $_GET['show_internal_attrs'] ) ? true : false;
|
||||
$rdn = ldap_explode_dn( $dn, 0 );
|
||||
$rdn = pla_explode_dn( $dn );
|
||||
$rdn = $rdn[0];
|
||||
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
||||
@@ -42,19 +44,24 @@ if( ! is_array( $oclasses ) )
|
||||
$oclasses = array( $oclasses );
|
||||
$avail_attrs = array();
|
||||
$schema_oclasses = get_schema_objectclasses( $server_id, true );
|
||||
foreach( $oclasses as $oclass )
|
||||
$avail_attrs = array_merge( $schema_oclasses[ strtolower( $oclass ) ]['must_attrs'],
|
||||
$schema_oclasses[ strtolower( $oclass ) ]['may_attrs'],
|
||||
$avail_attrs );
|
||||
|
||||
$schema_attrs = get_schema_attributes( $server_id );
|
||||
foreach( $oclasses as $oclass ) {
|
||||
$avail_attrs = array_merge(
|
||||
$schema_oclasses[ strtolower( $oclass ) ]['must_attrs'],
|
||||
$schema_oclasses[ strtolower( $oclass ) ]['may_attrs'],
|
||||
$avail_attrs );
|
||||
}
|
||||
$avail_attrs = array_unique( $avail_attrs );
|
||||
$avail_attrs = array_filter( $avail_attrs, "not_an_attr" );
|
||||
|
||||
sort( $avail_attrs );
|
||||
|
||||
/* A boolean flag to indicate whether this entry has a jpegPhoto associated with it.
|
||||
* TODO If it does, the jpegPhotos will be drawn at the bottom of the form */
|
||||
$has_jpeg_photo = false;
|
||||
$avail_binary_attrs = array();
|
||||
foreach( $avail_attrs as $i => $attr ) {
|
||||
if( is_attr_binary( $server_id, $attr ) ) {
|
||||
$avail_binary_attrs[] = $attr;
|
||||
unset( $avail_attrs[ $i ] );
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -71,36 +78,42 @@ $has_jpeg_photo = false;
|
||||
<td><img src="images/refresh.png" /></td>
|
||||
<td><a href="edit.php?server_id=<?php echo $server_id; ?>&dn=<?php echo $encoded_dn; ?>&random=<?php
|
||||
echo $random_junk; ?>"
|
||||
title="Refresh this entry">Refresh</a></td>
|
||||
title="<?php echo $lang['refresh_this_entry']; ?>"><?php echo $lang['refresh']; ?></a></td>
|
||||
</tr>
|
||||
|
||||
<?php if( 0 != strcasecmp( $dn, $servers[$server_id]['base'] ) ) { ?>
|
||||
<?php if( ! is_server_read_only( $server_id ) && 0 != strcasecmp( $dn, $servers[$server_id]['base'] ) ) { ?>
|
||||
<?php /* We won't allow them to delete the base dn of the server */ ?>
|
||||
<tr>
|
||||
<td><img src="images/trash.png" /></td>
|
||||
<td><a href="delete_form.php?server_id=<?php echo $server_id; ?>&dn=<?php echo $encoded_dn; ?>"
|
||||
title="You will be prompted to confirm this decision">Delete this entry</a></td>
|
||||
title="<?php echo $lang['delete_this_entry_tooltip']; ?>"><?php echo $lang['delete_this_entry']; ?></a></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
<tr>
|
||||
<td><img src="images/cut.png" /></td>
|
||||
<td><a href="copy_form.php?server_id=<?php echo $server_id; ?>&dn=<?php echo $encoded_dn?>"
|
||||
title="Copy this object to another location, a new DN, or another server">Copy this entry</a></td>
|
||||
title="<?php echo $lang['copy_this_entry_tooltip']; ?>"><?php echo $lang['copy_this_entry']; ?></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images/save.png" /></td>
|
||||
<?php $ldif_url = "ldif_export.php?server_id=$server_id&dn=$encoded_dn&scope=base"; ?>
|
||||
<td><a href="<?php echo $ldif_url; ?>" title="Save an LDIF dump of this object">Export to LDIF</a>
|
||||
(<a href="<?php echo $ldif_url; ?>&format=mac" title="Macintosh style carriage returns">mac</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=win" title="Windows style carriage returns">win</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=unix" title="Unix style carriage returns">unix</a>)
|
||||
<td><a href="<?php echo $ldif_url; ?>" title="<?php echo $lang['export_to_ldif_tooltip']; ?>"><?php echo $lang['export_to_ldif']; ?></a>
|
||||
(<a href="<?php echo $ldif_url; ?>&format=mac"
|
||||
title="<?php echo $lang['export_to_ldif_mac']; ?>">mac</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=win"
|
||||
title="<?php echo $lang['export_to_ldif_win']; ?>">win</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=unix"
|
||||
title="<?php echo $lang['export_to_ldif_unix']; ?>">unix</a>)
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php if( ! is_server_read_only( $server_id ) ) { ?>
|
||||
<tr>
|
||||
<td><img src="images/star.png" /></td>
|
||||
<td><a href="<?php echo "create_form.php?server_id=$server_id&container=$encoded_dn"; ?>">Create a child entry</a></td>
|
||||
<td><a href="<?php echo "create_form.php?server_id=$server_id&container=$encoded_dn"; ?>"><?php echo $lang['create_a_child_entry']; ?></a></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
<?php flush(); ?>
|
||||
<?php $children = get_container_contents( $server_id, $dn, $max_children );
|
||||
@@ -113,68 +126,74 @@ if( ($children_count = count( $children ) ) > 0 ) {
|
||||
|
||||
<tr>
|
||||
<td><img src="images/children.png" /></td>
|
||||
<td><a href="search.php?search=true&server_id=<?php echo $server_id; ?>&filter=<?php echo rawurlencode('objectClass=*'); ?>&base_dn=<?php echo $encoded_dn; ?>&form=advanced&scope=one">View <?php echo $children_count; ?> <?php echo ($children_count==1?'child':'children');?></a></td>
|
||||
<td><a href="search.php?search=true&server_id=<?php echo $server_id; ?>&filter=<?php echo rawurlencode('objectClass=*'); ?>&base_dn=<?php echo $encoded_dn; ?>&form=advanced&scope=one"><?php echo $lang['view']; ?> <?php echo $children_count; ?> <?php echo ($children_count==1?'child':'children');?></a></td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php if( $children_count > 0 ) { ?>
|
||||
|
||||
<tr>
|
||||
<td><img src="images/save.png" /></td>
|
||||
<?php $ldif_url = "ldif_export.php?server_id=$server_id&dn=$encoded_dn&scope=sub"; ?>
|
||||
<td><a href="<?php echo $ldif_url; ?>" title="Save an LDIF dump of this object and all of its children">Export subtree to LDIF</a>
|
||||
(<a href="<?php echo $ldif_url; ?>&format=mac" title="Macintosh style carriage returns">mac</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=win" title="Windows style carriage returns">win</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=unix" title="Unix style carriage returns">unix</a>)
|
||||
<td><a href="<?php echo $ldif_url; ?>"
|
||||
title="<?php echo $lang['export_subtree_to_ldif_tooltip']; ?>"><?php echo $lang['export_subtree_to_ldif']; ?></a>
|
||||
(<a href="<?php echo $ldif_url; ?>&format=mac" title="<?php echo $lang['export_to_ldif_mac'];?>">mac</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=win" title="<?php echo $lang['export_to_ldif_win'];?>">win</a>)
|
||||
(<a href="<?php echo $ldif_url; ?>&format=unix" title="<?php echo $lang['export_to_ldif_unix'];?>">unix</a>)
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
<?php if( in_array( 'jpegPhoto', $avail_attrs ) ) { ?>
|
||||
|
||||
<?php $new_jpeg_href = "new_jpeg_photo_form.php?server_id=$server_id&dn=$encoded_dn&attr=jpegPhoto"; ?>
|
||||
<?php if( ! is_server_read_only( $server_id ) ) { ?>
|
||||
<tr>
|
||||
<td><img src="images/photo.png" /></td>
|
||||
<td><a href="<?php echo $new_jpeg_href; ?>">Add a jpegPhoto</a></td>
|
||||
<td><img src="images/light.png" /></td>
|
||||
<td><?php echo $lang['delete_hint']; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php if( is_server_read_only( $server_id ) ) { ?>
|
||||
<tr>
|
||||
<td><img src="images/light.png" /></td>
|
||||
<td><?php echo $lang['viewing_read_only']; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
</table>
|
||||
<br />
|
||||
|
||||
<table class="edit_dn" cellspacing="0">
|
||||
|
||||
|
||||
<!-- Form to rename this entry -->
|
||||
<tr class="row1">
|
||||
<td class="heading"><acronym title="Change this entry's RDN">Rename Entry</acronym></td>
|
||||
<td class="heading" align="right">
|
||||
<?php if( ! is_server_read_only( $server_id ) ) { ?>
|
||||
<!-- Form to rename this entry -->
|
||||
<tr class="row1">
|
||||
<td class="heading"><acronym title="<?php echo $lang['change_entry_rdn']; ?> "><?php echo $lang['rename_entry']; ?></acronym></td>
|
||||
<td class="heading" align="right">
|
||||
<nobr>
|
||||
<form action="rename.php" method="post" class="edit_dn" />
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
|
||||
<input type="text" name="new_rdn" size="40" value="<?php echo htmlspecialchars( utf8_decode( $rdn ) ); ?>" />
|
||||
<input class="update_dn" type="submit" value="Rename" />
|
||||
<input type="text" name="new_rdn" size="30" value="<?php echo htmlspecialchars( utf8_decode( $rdn ) ); ?>" />
|
||||
<input class="update_dn" type="submit" value="<?php echo $lang['rename']; ?>" />
|
||||
</form>
|
||||
</nobr>
|
||||
</td>
|
||||
</td>
|
||||
<?php } ?>
|
||||
|
||||
<tr class="spacer"><td colspan="2"></td></tr>
|
||||
<?php if( ! is_server_read_only( $server_id ) ) { ?>
|
||||
<!-- Form to add a new attribute to this entry -->
|
||||
<tr class="spacer"><td colspan="2"></td></tr>
|
||||
<form action="new_attr.php" method="post">
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
|
||||
<tr class="row1">
|
||||
<td class="heading">
|
||||
<nobr>
|
||||
<acronym title="<?php echo $lang['add_new_attribute_tooltip']; ?>"><?php echo $lang['add_new_attribute']; ?></acronym>
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="heading" align="right"><nobr>
|
||||
|
||||
<form action="new_attr.php" method="post">
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
|
||||
|
||||
<!-- Form to add a new attribute to this entry -->
|
||||
<tr class="row1">
|
||||
<td class="heading">
|
||||
<nobr>
|
||||
<acronym title="Add a new attribute/value to this entry">Add New Attribute</acronym>
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="heading" align="right"><nobr>
|
||||
<?php if( is_array( $avail_attrs ) && count( $avail_attrs ) > 0 ) { ?>
|
||||
<?php if( is_array( $avail_attrs ) && count( $avail_attrs ) > 0 ) { ?>
|
||||
|
||||
<select name="attr">
|
||||
<?php foreach( $avail_attrs as $a ) {
|
||||
@@ -192,35 +211,75 @@ if( ($children_count = count( $children ) ) > 0 ) {
|
||||
} ?>
|
||||
</select>
|
||||
<input type="text" name="val" size="20" />
|
||||
<input type="submit" name="submit" value="Add" class="update_dn" />
|
||||
<input type="submit" name="submit" value="<?php echo $lang['add']; ?>" class="update_dn" />
|
||||
|
||||
<?php } else { ?>
|
||||
<?php } else { ?>
|
||||
|
||||
<small>(no new attributes available for this entry)</small>
|
||||
<small>(<?php echo $lang['no_new_attrs_available']; ?>)</small>
|
||||
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</nobr></td>
|
||||
</form>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
<?php flush(); ?>
|
||||
<tr class="spacer"><td colspan="2"></td></tr>
|
||||
|
||||
<?php if( ! is_server_read_only( $server_id ) && count( $avail_binary_attrs ) > 0 ) { ?>
|
||||
<!-- Form to add a new BINARY attribute to this entry -->
|
||||
<tr class="spacer"><td colspan="2"></td></tr>
|
||||
<form action="new_attr.php" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
|
||||
<input type="hidden" name="binary" value="true" />
|
||||
<tr class="row1">
|
||||
<td class="heading">
|
||||
<nobr>
|
||||
<acronym title="<?php echo $lang['add_new_binary_attr_tooltip']; ?>">
|
||||
<?php echo $lang['add_new_binary_attr']; ?></acronym>
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="heading" align="right"><nobr>
|
||||
|
||||
<select name="attr">
|
||||
<?php 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) . ")";
|
||||
} 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="file" name="val" size="20" />
|
||||
<input type="submit" name="submit" value="<?php echo $lang['add']; ?>" class="update_dn" />
|
||||
|
||||
</nobr></td>
|
||||
</form>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
<tr class="spacer"><td colspan="2"></td></tr>
|
||||
<tr class="row1">
|
||||
<td class="heading" colspan="2">
|
||||
<nobr>
|
||||
<?php if( $show_internal_attrs ) { ?>
|
||||
|
||||
<a href="edit.php?server_id=<?php echo $server_id; ?>&dn=<?php echo $encoded_dn; ?>"
|
||||
><img src="images/minus.png" title="Hide internal attributes" /></a>
|
||||
<acronym title="Attributes set automatically by the system">Internal Attriubtes</acronym>
|
||||
><img src="images/minus.png" title="<?php echo $lang['hide_internal_attrs']; ?>" /></a>
|
||||
<acronym title="<?php echo $lang['internal_attrs_tooltip'];?>"><?php echo $lang['internal_attributes']; ?></acronym>
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
<a href="edit.php?server_id=<?php echo $server_id; ?>&dn=<?php echo $encoded_dn; ?>&show_internal_attrs=true">
|
||||
<img src="images/plus.png" title="Show internal attributes" /></a>
|
||||
<acronym title="Attributes set automatically by the system (click + to display)">Internal Attriubtes</acronym>
|
||||
<small>(hidden)</small>
|
||||
<img src="images/plus.png" title="<?php echo $lang['show_internal_attrs']; ?>" /></a>
|
||||
<acronym title="<?php echo $lang['internal_attrs_tooltip']; ?> (<?php echo $lang['click_to_display']; ?>)"><?php echo $lang['internal_attributes']; ?></acronym>
|
||||
<small>(<?php echo $lang['hidden']; ?>)</small>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
@@ -230,16 +289,20 @@ if( ($children_count = count( $children ) ) > 0 ) {
|
||||
<?php
|
||||
if( $show_internal_attrs ) {
|
||||
$counter = 0;
|
||||
foreach( get_entry_system_attrs( $server_id, $dn ) as $attr => $val ) {
|
||||
$counter++
|
||||
?>
|
||||
<tr class="<?php echo ($counter%2==0?'row1':'row2');?>">
|
||||
<td class="attr"><b><?php echo htmlspecialchars( $attr ); ?></b></td>
|
||||
<td class="val"><?php echo htmlspecialchars( $val ); ?></td>
|
||||
</tr>
|
||||
foreach( get_entry_system_attrs( $server_id, $dn ) as $attr => $vals ) {
|
||||
$counter++
|
||||
?>
|
||||
<tr class="<?php echo ($counter%2==0?'row1':'row2');?>">
|
||||
<td class="attr"><b><?php echo htmlspecialchars( $attr ); ?></b></td>
|
||||
<td class="val">
|
||||
<?php foreach( $vals as $v ) {?>
|
||||
<?php echo htmlspecialchars( $v ); ?><br />
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }
|
||||
if( $counter == 0 )
|
||||
echo "<tr class=\"row2\"><td colspan=\"2\"><center>(none)</center></td></tr>\n";
|
||||
echo "<tr class=\"row2\"><td colspan=\"2\"><center>(" . $lang['none'] . ")</center></td></tr>\n";
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -250,35 +313,49 @@ if( $show_internal_attrs ) {
|
||||
<!-- Table of attributes/values to edit -->
|
||||
<tr class="row1">
|
||||
<td class="heading" colspan="2">
|
||||
<nobr>
|
||||
<acronym title="Edit the contents of the form below and click Save.">Modify Attributes</acronym>
|
||||
</nobr>
|
||||
<nobr><?php echo $lang['entry_attributes']; ?></nobr>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<form action="update_confirm.php" method="post">
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo rawurlencode($dn); ?>" />
|
||||
|
||||
<?php if( $edit_dn_schema_lookup ) $schema_attrs = get_schema_attributes( $server_id ); ?>
|
||||
<?php if( ! is_server_read_only( $server_id ) ) { ?>
|
||||
<form action="update_confirm.php" method="post">
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo $dn; ?>" />
|
||||
<?php } ?>
|
||||
|
||||
<?php $counter=0; ?>
|
||||
<?php foreach( $attrs as $attr => $vals ) {
|
||||
flush();
|
||||
if( $attr == 'dn' )
|
||||
continue;
|
||||
|
||||
// is there a user-friendly translation available for this attribute?
|
||||
if( isset( $friendly_attrs[ strtolower( $attr ) ] ) ) {
|
||||
$attr_display = "<acronym title=\"Alias for $attr\">" .
|
||||
$friendly_attrs[ strtolower( $attr ) ] . "</acronym>";
|
||||
} else {
|
||||
$attr_display = $attr;
|
||||
}
|
||||
<?php /* Prepare the hidden_attrs array by lower-casing it. */
|
||||
if( isset( $hidden_attrs ) && is_array( $hidden_attrs ) && count( $hidden_attrs ) > 0 )
|
||||
foreach( $hidden_attrs as $i => $attr_name )
|
||||
$hidden_attrs[$i] = strtolower( $attr_name );
|
||||
else
|
||||
$hidden_attrs = array();
|
||||
?>
|
||||
|
||||
<?php foreach( $attrs as $attr => $vals ) {
|
||||
|
||||
if( isset( $schema_attrs[ strtolower($attr) ] ) )
|
||||
$attr_syntax = $schema_attrs[ strtolower( $attr ) ]->getSyntaxOID();
|
||||
flush();
|
||||
if( 0 == strcasecmp( $attr, 'dn' ) )
|
||||
continue;
|
||||
|
||||
// has the config.php specified that this attribute is to be hidden?
|
||||
if( in_array( strtolower( $attr ), $hidden_attrs ) )
|
||||
continue;
|
||||
|
||||
// is there a user-friendly translation available for this attribute?
|
||||
if( isset( $friendly_attrs[ strtolower( $attr ) ] ) ) {
|
||||
$attr_display = "<acronym title=\"" . $lang['alias_for'] . "$attr\">" .
|
||||
$friendly_attrs[ strtolower( $attr ) ] . "</acronym>";
|
||||
} else {
|
||||
$attr_display = $attr;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php if( $attr == $updated_attr ) { ?>
|
||||
<?php if( is_array( $modified_attrs ) && in_array( $attr, $modified_attrs ) ) { ?>
|
||||
<tr class="updated_attr">
|
||||
<?php } else { ?>
|
||||
<?php if( $counter++ % 2 == 0 ) { ?>
|
||||
@@ -288,152 +365,208 @@ if( $show_internal_attrs ) {
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php $add_href = "add_value_form.php?server_id=$server_id&dn=$encoded_dn&attr=" . rawurlencode( $attr ); ?>
|
||||
<?php
|
||||
if( ! is_server_read_only( $server_id ) ) {
|
||||
$add_href = "add_value_form.php?server_id=$server_id&dn=$encoded_dn&attr=" . rawurlencode( $attr );
|
||||
} ?>
|
||||
|
||||
<td class="attr">
|
||||
<b><?php echo $attr_display; ?></b><br />
|
||||
<small>(<a href="<?php echo $add_href; ?>"
|
||||
title="Add an additional value to this attribute">add value</a>)</small>
|
||||
|
||||
<?php if( ! is_server_read_only( $server_id ) ) { ?>
|
||||
<small>(<a href="<?php echo $add_href; ?>"
|
||||
title="<?php echo $lang['add_value_tooltip']; ?>"><?php echo $lang['add_value']; ?></a>)</small>
|
||||
<?php } ?>
|
||||
</td>
|
||||
|
||||
<td class="val">
|
||||
|
||||
<?php if( 0==strcasecmp( $attr, 'jpegPhoto' ) ) {
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Is this attribute a jpegPhoto?
|
||||
*/
|
||||
if( is_jpeg_photo( $server_id, $attr ) ) {
|
||||
|
||||
$has_jpeg_photo = true;
|
||||
|
||||
// Don't draw the delete buttons if there is more than one jpegPhoto
|
||||
// (phpLDAPAdmin can't handle this case yet)
|
||||
if( is_array( $vals ) )
|
||||
// (phpLDAPadmin can't handle this case yet)
|
||||
if( is_server_read_only( $server_id ) )
|
||||
draw_jpeg_photos( $server_id, $dn, false );
|
||||
else
|
||||
draw_jpeg_photos( $server_id, $dn, true );
|
||||
|
||||
// proceed to the next attribute
|
||||
continue;
|
||||
}
|
||||
|
||||
} ?>
|
||||
|
||||
<?php /*
|
||||
* This is next IF statement is a KLUGE!! If anyone knows a better way to check for
|
||||
* binary data that works with UTF-8 encoded strings, please help
|
||||
*/
|
||||
?>
|
||||
/*
|
||||
* Is this attribute binary?
|
||||
*/
|
||||
if( is_attr_binary( $server_id, $attr ) ) {
|
||||
$href = "download_binary_attr.php?server_id=$server_id&dn=$encoded_dn&attr=$attr";
|
||||
?>
|
||||
|
||||
<?php if( 0==strcasecmp( $attr, 'networkAddress' ) ) { ?>
|
||||
<small>
|
||||
<?php echo $lang['binary_value']; ?><br />
|
||||
<?php if( count( $vals ) > 1 ) { for( $i=1; $i<=count($vals); $i++ ) { ?>
|
||||
<a href="<?php echo $href . "&value_num=$i"; ?>"><img
|
||||
src="images/save.png" /> <?php echo $lang['download_value']; ?>(<?php echo $i; ?>)</a><br />
|
||||
<?php } } else { ?>
|
||||
<a href="<?php echo $href; ?>"><img src="images/save.png" /> <?php echo $lang['download_value']; ?></a><br />
|
||||
<?php } ?>
|
||||
|
||||
<small>This attribute contains binary data,<br />
|
||||
which cannot be safely displayed<br />
|
||||
or edited in a web-browser.</small>
|
||||
<?php if( ! is_server_read_only( $server_id ) ) { ?>
|
||||
<a href="javascript:deleteAttribute( '<?php echo $attr; ?>' );"
|
||||
style="color:red;"><img src="images/trash.png" /> <?php echo $lang['delete_attribute']; ?></a>
|
||||
<?php } ?>
|
||||
|
||||
</small>
|
||||
</td>
|
||||
|
||||
<?php continue; ?>
|
||||
<?php continue;
|
||||
}
|
||||
|
||||
<?php } ?>
|
||||
/*
|
||||
* Note: at this point, the attribute must be text-based (not binary or jpeg)
|
||||
*/
|
||||
|
||||
<?php /* is this a multi-valued attribute? */ ?>
|
||||
<?php if( is_array( $vals ) ) { ?>
|
||||
<?php foreach( $vals as $i => $val ) { ?>
|
||||
/*
|
||||
* If we are in read-only mode, simply draw the attribute values and continue.
|
||||
*/
|
||||
if( is_server_read_only( $server_id ) ) {
|
||||
if( is_array( $vals ) ) {
|
||||
foreach( $vals as $i => $val ) {
|
||||
$val = utf8_decode( $val );
|
||||
echo $val . "<br />";
|
||||
}
|
||||
} else {
|
||||
echo utf8_decode( $vals ) . "<br />";
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is this a userPassword attribute?
|
||||
*/
|
||||
if( 0 == strcasecmp( $attr, 'userpassword' ) ) {
|
||||
$user_password = $vals[0];
|
||||
|
||||
/* Capture the stuff in the { } to determine if this is crypt, md5, etc. */
|
||||
preg_match( "/{([^}]+)}/", $user_password, $enc_type);
|
||||
$enc_type = strtolower($enc_type[1]);
|
||||
|
||||
<?php $val = utf8_decode( $val ); ?>
|
||||
// Set the default hashing type if the password is blank (must be newly created)
|
||||
if( $val == '' ) {
|
||||
$enc_type = $servers[$server_id]['default_hash'];
|
||||
} ?>
|
||||
|
||||
<nobr>
|
||||
<!-- The old_values array will let update.php know if the entry contents changed
|
||||
between the time the user loaded this page and saved their changes. -->
|
||||
<input type="hidden"
|
||||
name="old_values[<?php echo htmlspecialchars( $attr ); ?>][<?php echo $i; ?>]"
|
||||
value="<?php echo htmlspecialchars($val); ?>" />
|
||||
|
||||
<input type="text"
|
||||
size="60"
|
||||
name="new_values[<?php echo htmlspecialchars( $attr ); ?>][<?php echo $i; ?>]"
|
||||
value="<?php echo htmlspecialchars($val); ?>" /></nobr><br />
|
||||
<?php } ?>
|
||||
<?php /* this a single-valued attribute */ ?>
|
||||
<?php } else { ?>
|
||||
<?php $val = $vals; ?>
|
||||
<?php /* handle crypt types */
|
||||
if($enc_type == "crypt") {
|
||||
preg_match( "/{[^}]+}\\$(.)\\$/", $user_password, $salt);
|
||||
switch( $salt[1] ) {
|
||||
case '': // CRYPT_STD_DES
|
||||
$enc_type = "crypt";
|
||||
break;
|
||||
case '1': // CRYPT_MD5
|
||||
$enc_type = "md5crypt";
|
||||
break;
|
||||
case '2': // CRYPT_BLOWFISH
|
||||
$enc_type = "blowfish";
|
||||
break;
|
||||
default:
|
||||
$enc_type = "crypt";
|
||||
}
|
||||
} ?>
|
||||
|
||||
<?php $val = utf8_decode( $val ); ?>
|
||||
<input type="hidden"
|
||||
name="old_values[userpassword]"
|
||||
value="<?php echo htmlspecialchars($user_password); ?>" />
|
||||
|
||||
<nobr>
|
||||
<?php /* This series of if/elseif/else is for special cases of attributes (userPassword, boolean, etc) */ ?>
|
||||
<?php if( 0 == strcasecmp( $attr, 'userpassword' ) ) { ?>
|
||||
<!-- Special case of enc_type to detect changes when user changes enc_type but not the password value -->
|
||||
<input size="38"
|
||||
type="hidden"
|
||||
name="old_enc_type"
|
||||
value="<?php echo ($enc_type==''?'clear':$enc_type); ?>" />
|
||||
|
||||
<?php /* Capture the stuff in the { } if any */
|
||||
preg_match( "/{([^}]+)}/", $val, $enc_type); $enc_type = strtolower($enc_type[1]); ?>
|
||||
<input size="38"
|
||||
type="text"
|
||||
name="new_values[userpassword]"
|
||||
value="<?php echo htmlspecialchars($user_password); ?>" />
|
||||
|
||||
<?php /* handle crypt types */
|
||||
if($enc_type == "crypt") {
|
||||
preg_match( '/{[^}]+}\$(.)\$/', $val, $salt);
|
||||
switch( $salt[1] ) {
|
||||
case '': // CRYPT_STD_DES
|
||||
$enc_type = "crypt";
|
||||
break;
|
||||
case '1': // CRYPT_MD5
|
||||
$enc_type = "md5crypt";
|
||||
break;
|
||||
case '2': // CRYPT_BLOWFISH
|
||||
$enc_type = "blowfish";
|
||||
break;
|
||||
default:
|
||||
$enc_type = "crypt";
|
||||
}
|
||||
} ?>
|
||||
|
||||
|
||||
<input type="hidden"
|
||||
name="old_values[userpassword]"
|
||||
value="<?php echo htmlspecialchars($val); ?>" />
|
||||
|
||||
<input size="48"
|
||||
type="text"
|
||||
name="new_values[userpassword]"
|
||||
value="<?php echo htmlspecialchars($val); ?>" />
|
||||
|
||||
<select name="enc_type">
|
||||
<option>clear</option>
|
||||
<option<?php echo $enc_type=='crypt'?' selected':''; ?>>crypt</option>
|
||||
<option<?php echo $enc_type=='md5'?' selected':''; ?>>md5</option>
|
||||
<option<?php echo $enc_type=='md5crypt'?' selected':''; ?>>md5crypt</option>
|
||||
<option<?php echo $enc_type=='blowfish'?' selected':''; ?>>blowfish</option>
|
||||
<option<?php echo $enc_type=='sha'?' selected':''; ?>>sha</option>
|
||||
<select name="enc_type">
|
||||
<option>clear</option>
|
||||
<option<?php echo $enc_type=='crypt'?' selected':''; ?>>crypt</option>
|
||||
<option<?php echo $enc_type=='md5'?' selected':''; ?>>md5</option>
|
||||
<option<?php echo $enc_type=='md5crypt'?' selected':''; ?>>md5crypt</option>
|
||||
<option<?php echo $enc_type=='blowfish'?' selected':''; ?>>blowfish</option>
|
||||
<option<?php echo $enc_type=='sha'?' selected':''; ?>>sha</option>
|
||||
</select>
|
||||
|
||||
<?php } elseif( $edit_dn_schema_lookup &&
|
||||
'Boolean' == $schema_attrs[ strtolower($attr) ]['type'] ) { ?>
|
||||
<?php continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is this a boolean attribute?
|
||||
*/
|
||||
if( 0 == strcasecmp( 'boolean', $schema_attrs[ strtolower($attr) ]->getType() ) ) {
|
||||
$val = $vals[0];
|
||||
?>
|
||||
|
||||
<input type="hidden"
|
||||
name="old_values[<?php echo htmlspecialchars( $attr ); ?>]"
|
||||
value="<?php echo htmlspecialchars($val); ?>" />
|
||||
<input type="hidden"
|
||||
name="old_values[<?php echo htmlspecialchars( $attr ); ?>]"
|
||||
value="<?php echo htmlspecialchars($val); ?>" />
|
||||
|
||||
<select name="new_values[<?php echo htmlspecialchars( $attr ); ?>]">
|
||||
<option value="TRUE"<?php echo ($val=='TRUE' ? ' selected' : ''); ?>>TRUE</option>
|
||||
<option value="FALSE"<?php echo ($val=='FALSE' ? ' selected' : ''); ?>>FALSE</option>
|
||||
<option value="">(none -- remove value)</option>
|
||||
</select>
|
||||
<option value="TRUE"<?php echo ($val=='TRUE' ? ' selected' : ''); ?>>
|
||||
<?php echo $lang['true']; ?></option>
|
||||
<option value="FALSE"<?php echo ($val=='FALSE' ? ' selected' : ''); ?>>
|
||||
<?php echo $lang['false']; ?></option>
|
||||
<option value="">(<?php echo $lang['none_remove_value']; ?>)</option>
|
||||
</select>
|
||||
|
||||
<?php } else { ?>
|
||||
<?php
|
||||
continue;
|
||||
}
|
||||
|
||||
<input type="hidden"
|
||||
name="old_values[<?php echo htmlspecialchars( $attr ); ?>]"
|
||||
value="<?php echo htmlspecialchars($val); ?>" />
|
||||
/*
|
||||
* End of special case attributes.
|
||||
*/
|
||||
|
||||
<input size="60"
|
||||
type="text"
|
||||
name="new_values[<?php echo htmlspecialchars( $attr ); ?>]"
|
||||
value="<?php echo htmlspecialchars($val); ?>" />
|
||||
/*
|
||||
* This is a normal attribute, to be displayed and edited in plain text.
|
||||
*/
|
||||
foreach( $vals as $i => $val ) {
|
||||
$val = utf8_decode( $val ); ?>
|
||||
|
||||
<?php } ?>
|
||||
</nobr>
|
||||
|
||||
<?php } ?>
|
||||
<nobr>
|
||||
<!-- The old_values array will let update.php know if the entry contents changed
|
||||
between the time the user loaded this page and saved their changes. -->
|
||||
<input type="hidden"
|
||||
name="old_values[<?php echo htmlspecialchars( $attr ); ?>][<?php echo $i; ?>]"
|
||||
value="<?php echo htmlspecialchars($val); ?>" />
|
||||
|
||||
<?php if( $attr_syntax == '1.3.6.1.4.1.1466.115.121.1.40' ) { ?>
|
||||
<textarea
|
||||
cols="37" rows="3"
|
||||
name="new_values[<?php echo htmlspecialchars( $attr ); ?>][<?php echo $i; ?>]"
|
||||
><?php echo htmlspecialchars($val); ?></textarea><br />
|
||||
<?php } else { ?>
|
||||
<input type="text"
|
||||
size="50"
|
||||
name="new_values[<?php echo htmlspecialchars( $attr ); ?>][<?php echo $i; ?>]"
|
||||
value="<?php echo htmlspecialchars($val); ?>" /></nobr><br />
|
||||
<?php } ?>
|
||||
<?php } /* end foreach value */ ?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
<?php } /* End foreach( $attrs as $attr => $vals ) */ ?>
|
||||
|
||||
<tr><td colspan="2"><center><input type="submit" value="Save Changes" /></center></form></td></tr>
|
||||
<?php if( ! is_server_read_only( $server_id ) ) { ?>
|
||||
<tr><td colspan="2"><center><input type="submit" value="<?php echo $lang['save_changes']; ?>" /></center></form></td></tr>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
?>
|
||||
@@ -441,32 +574,40 @@ if( $show_internal_attrs ) {
|
||||
|
||||
</table>
|
||||
|
||||
<?php /* If this entry has a jpegPhoto, we need to provide a form for it to submit when deleting it. */ ?>
|
||||
<?php if( $has_jpeg_photo ) { ?>
|
||||
<script language="javascript">
|
||||
<!--
|
||||
function deleteJpegPhoto()
|
||||
{
|
||||
if( confirm( "Really delete jpegPhoto?" ) )
|
||||
document.delete_jpeg_photo_form.submit();
|
||||
<?php /* If this entry has a binary attribute, we need to provide a form for it to submit when deleting it. */ ?>
|
||||
<script language="javascript">
|
||||
//<!--
|
||||
function deleteAttribute( attrName )
|
||||
{
|
||||
if( confirm( "<?php echo $lang['really_delete_attribute']; ?> '" + attrName + "'?" ) ) {
|
||||
document.delete_attribute_form.attr.value = attrName;
|
||||
document.delete_attribute_form.submit();
|
||||
}
|
||||
|
||||
-->
|
||||
</script>
|
||||
<!-- TODO: Go to update_confirm.php instead of directly to update.php -->
|
||||
<form name="delete_jpeg_photo_form" action="update.php" method="post">
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
|
||||
<input type="hidden" name="update_array[jpegPhoto]" value="" />
|
||||
</form>
|
||||
<?php } ?>
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
<!-- This form is submitted by JavaScript when the user clicks "Delete attribute" on a binary attribute -->
|
||||
<form name="delete_attribute_form" action="delete_attr.php" method="post">
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
|
||||
<input type="hidden" name="attr" value="FILLED IN BY JAVASCRIPT" />
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Given an attribute $x, this returns true if it is NOT already specified
|
||||
* in the current entry, returns false otherwise.
|
||||
*/
|
||||
function not_an_attr( $x )
|
||||
{
|
||||
global $attrs;
|
||||
return ! isset( $attrs[ strtolower( $x ) ] );
|
||||
//return ! isset( $attrs[ strtolower( $x ) ] );
|
||||
foreach( $attrs as $attr => $values )
|
||||
if( 0 == strcasecmp( $attr, $x ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user