Translations of this page:

My Photo Component

This component was designed to display your photo anywhere on the homepage

1. Create file called ComponentMyPhoto.php and paste in the following code.

 
<?php
/*
 * Created on 24 Jun 2009 17:04:17
 *
 * @description: Displays user profile photo in a component
 *
 * @author: David Sanders
 *
 */
class ComponentMyPhoto implements TemplaterComponent
{
	public $user; // Hold user logged on info
 
	public function __construct()
	{
		$this->user = $_SESSION['SESSION_UID'];
		//if (!$this->user)
		//	throw new Exception("Invalid User ID");			
	}
 
	public function Show($attributes)
	{
		global $INTRANET;
 
		$file = $this->user ? $this->user : 'no_photo';
 
		if (!file_exists($INTRANET.'/people/photos/'.$file.'.jpg'))
			$file = 'no_photo';
		
		// probably it's reasonable to use $cfg_user_profile_image_width and $cfg_user_profile_image_height here
		return '<img name="myimg" src="/intranet/people/photos/'.$file.'.jpg" alt="" width="40" height="40" align="absmiddle">';
	}
}
 
?>

2. Copy this file into

/intranet/common/classes/

3. Paste the following component code anywhere on templater file

<component class="ComponentMyPhoto">
 
components/myphoto.txt · Last modified: 07/06/2011 10:49 by mike
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki