Location: PHPKode > projects > Anahita Social Engine > dependencies/plg_system_socialengine/socialengine/model/person/helper.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 AnModelPersonHelper extends KObject
{
	/**
	 * create a person actor node from the user object
	 * @return 
	 * @param $user Object
	 */
	static function createFromUser($user)
	{
		if ( !$user->id )
			return null;

		$node = KFactory::tmp(KFactory::get('site::com.socialengine.table.nodes')->getRow());

		$node->actor_type	   = 'lib.anahita.model.person';
		$node->actor_title	   = $user->name;
		$node->actor_component = 'com_socialengine';

		$node->save();
		
		$node->actor_profile_url = 'index.php?option=com_socialengine&view=person&id='.$node->id;
		
		KFactory::get($node->getTable())->update($node);
		
		$parts = explode(' ',$user->name, 2);
		$familyName = '';
		$givenName  = '';
		if ( isset($parts[0]) )
			$givenName = $parts[0];

		if ( isset($parts[1]) )
			$familyName = $parts[1];
			
		$person = KFactory::tmp(KFactory::get('site::com.socialengine.table.people')->getRow());
		
		$person->socialengine_actor_id = $node->id;
		$person->user_id			   = $user->id;
		$person->given_name  = $givenName;
		$person->family_name = $familyName;
		$person->date_of_birth = 0;
		$person->save();
		
		return $node->id;
	}
}
Return current item: Anahita Social Engine