- md5
- a88c13d0b8bb1acb539d878337e34813
- sha1
- 64c40059abba690a9f5bde091875a63e3f84d77a
- sha256
- de5dbc569974a69720f4ff6dfbfa4a96789676ab571c44fb50fad7158f706934
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
<?php
/**
* @version $Id: example.php 19526 2010-11-17 13:56:39Z chdemko $
* @package Joomla
* @subpackage JFramework
* @copyright Copyright (C) 2005 - 2009 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access
defined('_JEXEC') or die;
jimport('joomla.plugin.plugin');
/**
* Example User Plugin
*
* @package Joomla
* @subpackage JFramework
* @since 1.5
*/
class plgUserExample extends JPlugin
{
/**
* Example store user method
*
* Method is called before user data is stored in the database
*
* @param array $user Holds the old user data.
* @param boolean $isnew True if a new user is stored.
* @param array $new Holds the new user data.
*
* @return void
* @since 1.6
* @throws Exception on error.
*/
public function onUserBeforeSave($user, $isnew, $new)
{
$app = JFactory::getApplication();
// throw new Exception('Some error occurred. Please do not save me');
}
/**
* Example store user method
*
* Method is called after user data is stored in the database
*
* @param array $user Holds the new user data.
* @param boolean $isnew True if a new user is stored.
* @param boolean $success True if user was succesfully stored in the database.
* @param string $msg Message.
*
* @return void
* @since 1.6
* @throws Exception on error.
*/
public function onUserAfterSave($user, $isnew, $success, $msg)
{
$app = JFactory::getApplication();
// convert the user parameters passed to the event
// to a format the external application
$args = array();
$args['username'] = $user['username'];
$args['email'] = $user['email'];
$args['fullname'] = $user['name'];
$args['password'] = $user['password'];
if ($isnew) {
// Call a function in the external app to create the user
// ThirdPartyApp::createUser($user['id'], $args);
}
else {
// Call a function in the external app to update the user
// ThirdPartyApp::updateUser($user['id'], $args);
}
}
/**
* Example store user method
*
* Method is called before user data is deleted from the database
*
* @param array $user Holds the user data.
*
* @return void
* @since 1.6
*/
public function onUserBeforeDelete($user)
{
$app = JFactory::getApplication();
}
/**
* Example store user method
*
* Method is called after user data is deleted from the database
*
* @param array $user Holds the user data.
* @param boolean $succes True if user was succesfully stored in the database.
* @param string $msg Message.
*
* @return void
* @since 1.6
*/
public function onUserAfterDelete($user, $succes, $msg)
{
$app = JFactory::getApplication();
// only the $user['id'] exists and carries valid information
// Call a function in the external app to delete the user
// ThirdPartyApp::deleteUser($user['id']);
}
/**
* This method should handle any login logic and report back to the subject
*
* @param array $user Holds the user data.
* @param array $options Extra options.
*
* @return boolean True on success
* @since 1.5
*/
public function onUserLogin($user, $options)
{
// Initialise variables.
$success = false;
// Here you would do whatever you need for a login routine with the credentials
//
// Remember, this is not the authentication routine as that is done separately.
// The most common use of this routine would be logging the user into a third party
// application.
//
// In this example the boolean variable $success would be set to true
// if the login routine succeeds
// ThirdPartyApp::loginUser($user['username'], $user['password']);
return $success;
}
/**
* This method should handle any logout logic and report back to the subject
*
* @param array $user Holds the user data.
*
* @return boolean True on success
* @since 1.5
*/
public function onUserLogout($user)
{
// Initialise variables.
$success = false;
// Here you would do whatever you need for a logout routine with the credentials
//
// In this example the boolean variable $success would be set to true
// if the logout routine succeeds
// ThirdPartyApp::loginUser($user['username'], $user['password']);
return $success;
}
}
The same content is in 2 releases, Joomla 1.6.0 to 1.6.1. See them all, or every version of this file.