Location: PHPKode > projects > Anahita Social Engine > site/controllers/account.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 ComSocialengineControllerAccount extends ComSocialengineControllerBase
{
	public function __construct($options=array())
	{
		parent::__construct($options);
		$this->registerAuthentication();
	}
	
	/**
	 * 
	 * @return 
	 */
	public function _actionRead()
	{
		$layout = KRequest::get('get.layout', 'cmd', 'default');

		if( !in_array($layout, array('default', 'edit', 'account')) )
		{
			JError::raiseError(404, 'AN-SE-404');
			return false;
		}
		
		$this->view()->setLayout($layout)->display();
	}
	
	/**
	 * 
	 * @return 
	 */
	public function _actionEdit()
	{
		$data = array();
		
		$givenName 	= KRequest::get('post.givenName', 'string');
		$familyName	= KRequest::get('post.familyName', 'string');
		
		$data['name'] = $givenName.' '.$familyName;
		
		$data['email'] = KRequest::get('post.email', 'email');
		$data['params']	= KRequest::get('post.params', 'string');
		
		$password	= KRequest::get('post.password', 'string');
		$password2	= KRequest::get('post.password2', 'string');
		
		if($password && $password != $password2) {
			print KFactory::get('lib.anahita.uikit.prompt.error')->setBody(JText::_('AN-SE-ACCOUNT-PROMPT-PASSWORDS-DO-NOT-MATCH'));
			KRequest::set('get.view', 'account');
			KRequest::set('get.layout', 'edit');
			$this->execute('read');
			return;
		} else if($password && $password == $password2) {
			$data['password']  = $password;
			$data['password2'] = $password2;
		}
			
		$user = KFactory::get('lib.joomla.user');	
		
		$user->bind($data);
		
		if(!$user->save()) {
			return false;
		}	
		
		$viewer = AnModelAnahita::getSessionViewer();
			
		$viewer->information->setInfo('givenName',  $givenName);
		
		$viewer->information->setInfo('familyName', $familyName);
		
		$viewer->save();
		
		print KFactory::get('lib.anahita.uikit.prompt.message')->setBody(JText::_('AN-SE-PROMPT-SAVED-SUCCESS'));
		
		KRequest::set('get.view', 'account');
		
		KRequest::set('get.layout', 'account');
		
		$this->execute('read');
	}
}
Return current item: Anahita Social Engine