Location: PHPKode > projects > LDAP Navigator > ldapnavigator-0.9.6/modules/entry/properties.php
<?php

include_once( "config.php" );

// a set of plugins to customize the attributes display
include_once( 'attribute.plugins.php' );


$system_attributes = array(
	"creatorsname", "modifiersname",
	"createtimestamp", "modifytimestamp"
);



if( ! isset($dn) || trim($dn) == ""  )
	ErrorPage(  "Error", "Missing parameter : dn", "javascript:history.go(-1)" );


$sr = @ldap_read( $ds, $dn, "objectclass=*" );
if( ! $sr )
	ErrorPage(  "Error",
		"Entry not found : "	. ldap_error($ds) . "<br>Maybe someone has just deleted this entry ?",
		"page.default.php"
	);

$tmpEntries = ldap_get_entries($ds, $sr);
$attrs = $tmpEntries[0];


$rdn = ldap_explode_dn( $dn, 0 );
$encdn = rawurlencode($dn);

debug($attrs);

include_once( "./page.header.php" );

// build a nice caption
// get icon representing this type of object
$icon = smartIcon( $attrs['objectclass'] );

$pageTitle = "<img src=\"img/$icon\" border=0 valign=bottom> ";
$pageTitle .= utf8_decode( $rdn[0] ); // relative DN , eg. "cn=Mark Riot"



html::form( @$PHP_SELF, "post" );

html::hidden( "A", $A );
html::hidden( "dn", $dn );

echo '<div align=center>';
echo '<table cellspacing=0 style="border: 1px solid gray;" cols="80,300">';
echo '<caption>', $pageTitle, "</caption>\n";

// output DN field
echo "<tr><td class=form align=right>",
	"DN", 
	"</td><td class=form>",
	utf8_decode($dn),
	"</td></tr>\n";

$known_attributes = array();

for( $i = 0; $i < $attrs["count"]; $i++ ) {

	$attribute = $attrs[$i];

	// we do not display "system" attributes for now
	if( in_array( $attribute, $system_attributes) )
		continue;
			
//	$attributevalue = ldap_get_values_len( $ds, $es, $attribute);
	$attributevalue = $attrs[$attribute];
	
	$data = "";
	$attributePlugin = @$attributesPluginsMap[$attribute];
	
	for ($j = 0; $j < $attrs[$attribute]["count"]; $j++) {

		$value = $attributevalue[$j];

		// a plugin is defined for this attribute, let's call it
		if( $attributePlugin ) {
			$data .= $attributePlugin( $value, $j );
			continue;

		} else {
					
			$value = utf8_decode( $value );
			$valuelen = strlen( $value );
			// reduce long values
			if( $valuelen > 200 )
				$value = substr( $value, 0, 200 );
		}
		$data .= "$value<br>\n";
	}

	echo "<tr><td class=form align=right>",
		$attribute, 
		"</td><td class=form>",
		$data,
		"</td></tr>\n";
	
}


if( isset($attrs['createtimestamp']) ) {
	Formline( "Created ", 
		$attrs['createtimestamp'][0] . " by " . DNLink( $attrs['creatorsname'][0] ) 
	);

}

if( isset($attrs['modifytimestamp']) ) {
	Formline( "Last modified ", 
		$attrs['modifytimestamp'][0] . " by " . DNLink( $attrs['modifiersname'][0] )
	);
}

	
// create button bar elements
$wEdit = new Button( "Edit", "formAction(this.form, 'entry.edit' )", '', $btM );
$wDelete = new Button( "Delete", "deleteConfirm(this.form)", '', $btS );
$wAci = new Button( "Permissions", "formAction(this.form, 'aci.edit' )", "aci", $btM );
$wBack = new Button( "Cancel", "history.go(-1)", '', $btM );
$wNewChild = new Button( "New...", "formAction(this.form, 'entry.new' )", "new", $btM );

// display button bar
echo "<tr><td class=form colspan=2 align=right>",
	$wEdit->toString(),
	$wAci->toString(),
	$wDelete->toString(),
	$wBack->toString(),
	$wNewChild->toString(),
	"</td></tr>";


echo "</TABLE>\n",
	"</FORM>\n";

// JS invoqued by form buttons

?>
<script language="javascript1.2">
<!--
function dumpObject( obj )
{
	var msg = "dumpObject( " + obj + "):\n";
	for( prop in document ) {
		msg = msg + prop + "\n";
	}
	alert( msg );
}

function deleteConfirm( formObj )
{
	if( confirm( "Delete entry?\nPlease confirm by clicking OK" ) ) {
		formAction( formObj, 'entry.delete' );
	}
}
 
function formAction( formObj, actionStr )
{ 
	formObj.A.value = actionStr;
	formObj.submit();
}
// -->
</script>
<?php

include("./page.footer.php");


?> 
Return current item: LDAP Navigator