Location: PHPKode > projects > Anahita Social Engine > dependencies/plg_system_socialengine/socialengine/model/anahita/anahita.php
<?php
/**
 * @version		1.0.0
 * @category	Anahita Social Engine™
 * @copyright	Copyright (C) 2008 - 2010 rmdStudio Inc. and Peerglobe Technology Inc. All rights reserved.
 * @license		GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
 * @link     	http://www.anahitapolis.com
 */

class AnModelAnahita extends KObject
{
	
	protected static $_viewer = null;
	
	const _VERSION = '0.9.4';
	
	static public function setSessionViewer(AnModelPerson $viewer)
	{				
		self::$_viewer = $viewer;
	}
	
	public static function getVersion()
    {
        return self::_VERSION;
    }
		
	static public function getSessionViewer()
	{		
		if ( is_null(self::$_viewer) ) {
			
			$query = KFactory::get('lib.anahita.domain.factory.query')->get('lib.anahita.model.person');
			
			$id = JFactory::getUser()->id;
			
			if ( !$id ) {
				$viewer = KFactory::get('lib.anahita.domain.factory.model')->get('lib.anahita.model.person', array('userType'=>'Guest'));
				$viewer->id = 0;
				$viewer->markClean();
			} else {
				
				$query->where('userId','=',$id)
				
				;
				
				$viewer = $query->fetch();
				
				if ( !$viewer )
				{ 
					$node_id = AnModelPersonHelper::createFromUser( JFactory::getUser() );
					$viewer  = KFactory::get('lib.anahita.domain.factory')->getRepository('lib.anahita.model.person')->getPerson( $node_id );
				}
									
			}
						
			$viewer->mixin( KFactory::tmp('lib.anahita.model.person.edge.mixin', array('mixer'=>$viewer)) );			
			
			self::$_viewer = $viewer;
		}
		
		return self::$_viewer;
	}
	
}
Return current item: Anahita Social Engine