Location: PHPKode > projects > LDAP Navigator > ldapnavigator-0.9.6/attribute.plugins.php
<?php


/*
	Sample function to display a picture from a image url or filename $val
	you may set the image's baseurl in global variable $photo_baseurl
*/

function showImage( $val )
{
	global $photo_baseurl;
	return "<img src=\"$photo_baseurl" . $val . "\">\n";
}

/*
	Display a nice postal address
	convert $ signs to line breaks (<br>)
*/

function formatPostalAddress( &$val )
{
	return str_replace( "$", "<br>\n", utf8_decode( $val ) );
}


/*
	Display a "binary data not displayed" message
	use it for binary fields that may messup the page
*/

function binaryDataNotDisplayed( &$val )
{
	return "<i>Binary data not displayed</i>";
}

/*
	Display a "download" button that will allow user to download attribute in a file
	BUG FIXME
*/
function downloadButton( &$val, $idx )
{
	$url = "submit.php?A=attribute.download&dn=$encdn&attribute=$encattribute&idx=$j&$randomdata";
	$btn = new Button( "Download", "document.location='$url'", "btn" );
	return $btn->toString();
}

/*
	Display a link to the objectclass properties page
*/
function objectclassLink( $ocname )
{

	$url = "submit.php?A=objectclass.info&oc=" . $ocname;
	$info = '<a href="' . $url . '">' . $ocname . '</a> &nbsp;';
	return $info;
	
}

function mailtoLink( $email )
{
	if( $email != "" )
		return '<a href="mailto:' . $email . '">' . $email . '</a> &nbsp;';
	else
		return '';	
}

function javaDocLink( $javaclassname )
{
	$url = "http://java.sun.com/j2se/1.4/docs/api/" . strtr( $javaclassname, ".", "/" ) . ".html";
	return '<a target=\"_new\" href="' . $url . '">' . $javaclassname . '</a><br>';
}

/*
	Display Plugin to display informations about an aci attribute
*/
function aciInfo( $aciattribute )
{
	$aciHash = parse_aci( $aciattribute );
	if( ! $aciHash ) {
		FormLine( "Access permissions", "unable to parse aci" );
		return;
	}
	
	// generate a "user friendly" aci description such as 
	// ACI name : allow write,read for cn=Toto Bitonio,ou=People,o=acme.com
	$info = $aciHash['name'] . " : ";
	$info .= $aciHash['grant'] . " " . implode( ",", $aciHash['permissions'] );
	$info .= " for <i>" . $aciHash['bindingdn'] . "</i>";
	
	if( is_array($aciHash['targetattr']) && $aciHash['targetattr'][0] != "*" )
			$info .= " on attributes " . implode( ",", $aciHash['targetattr'] );
	
	$info .= "<br>";
	
	return $info;
}

/*
	Display Plugin for a DN-type attribute
	outputs a DN along with link to the Entry Properties page
	
*/
function &DNLink( $dnattribute )
{
	$url = "submit.php?A=entry.properties&dn=" . urlencode($dnattribute);
	
	$info = '<a href="' . $url . '">' . utf8_decode( $dnattribute) . '</a><br>';
		
	return $info;
}


/* 
	Generates a link that when clicked, runs a global search on this attribute.
*/
function &uidLookup( $uid ) 
{
	global $ldapmanager;
	
	$url = "submit.php?A=search".
		"&dn=" . urlencode( $ldapmanager['basedn'] ) . 
		"&customfield=uid&query=" . urlencode($uid) .
		"&operator=" . urlencode("=");
	
	$info = '<a href="' . $url . '">' . utf8_decode( $uid ) . '</a><br>';
	return $info;
}

/*
	Display a box to permit a quick "change password" feature
	Not wired yet to submit.php?A=attribute.modify
*/
function &passwordChangeBox( $password )
{
	global $encdn;
//	$url = "submit.php?A=attribute.modify&dn=" . $encdn . "&attribute=userpassword&idx=0";
// $url = "document.location='$url'";
	$url = "dumpObject(history)";
	$btn = new Button( "Change", $url, "" );
	$info = "****** " . $btn->toString();
	return $info;
}

?>
Return current item: LDAP Navigator