<?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
*/
defined('_JEXEC') or die();
jimport('joomla.plugin.plugin');
/**
* Anahita User Plugin
*
* @author Rastin Mehr <hide@address.com>
* @package Joomla
* @subpackage Anahita
* @since 1.5
*/
class plgUserSocialEngine extends JPlugin {
private $db;
/**
* Constructor
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.5
*/
function __construct(& $subject, $config)
{
parent::__construct($subject, $config);
$this->db =& JFactory::getDBO();
}
public function onAfterRender()
{
}
/**
* Example store user method
*
* Method is called before user data is stored in the database
*
* @param array holds the old user data
* @param boolean true if a new user is stored
*/
public function onBeforeStoreUser(&$user, $isnew)
{
}
/**
* store user method
*
* Method is called after user data is stored in the database
*
* @param array holds the new user data
* @param boolean true if a new user is stored
* @param boolean true if user was succesfully stored in the database
* @param string message
*/
public function onAfterStoreUser($user, $isnew, $succes, $msg)
{
global $mainframe;
if( !$succes )
return false;
$name = $user['name'];
$id = $user['id'];
$query = KFactory::get('lib.anahita.domain.factory')->getQuery('lib.anahita.model.person')->where('userId','=',$id);
$person = $query->fetch();
if ( $person ) {
//@TODO save given name and family name
list($givenName, $familyName) = explode(' ',$name, 2);
$person->information['givenName'] = $givenName;
$person->information['familyName'] = $familyName;
$person->save();
} else {
AnModelPersonHelper::createFromUser( JFactory::getUser($user['id']) );
}
}
/**
* store user method
*
* Method is called before user data is deleted from the database
*
* @param array holds the user data
*/
public function onBeforeDeleteUser($user)
{
}
/**
* store user method
*
* Method is called after user data is deleted from the database
*
* @param array holds the user data
* @param boolean true if user was succesfully stored in the database
* @param string message
*/
public function onAfterDeleteUser($user, $succes, $msg)
{
}
public function onAuthenticate($cred=array())
{
}
/**
* This method should handle any login logic and report back to the subject
*
* @access public
* @param array holds the user data
* @param array extra options
* @return boolean True on success
* @since 1.5
*/
public function onLoginUser($user, $options)
{
}
/**
* This method should handle any logout logic and report back to the subject
*
* @access public
* @param array holds the user data
* @return boolean True on success
* @since 1.5
*/
public function onLogoutUser($user)
{
}
}