- md5
- 81f5a5eac8e88bb8985b0d896d2e6e45
- sha1
- 1f25def36f497348a5e43806146022c49b81fe79
- sha256
- 78a3713063e7183cf008ef13e97910901166a8e0f0b120627705d0b2d081eca0
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
<?php
/**
* @version $Id: example.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @subpackage JFramework
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );
jimport('joomla.plugin.plugin');
/**
* Example User Plugin
*
* @package Joomla
* @subpackage JFramework
* @since 1.5
*/
class plgUserExample extends JPlugin {
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.5
*/
function plgUserExample(& $subject, $config)
{
parent::__construct($subject, $config);
}
/**
* 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
*/
function onBeforeStoreUser($user, $isnew)
{
global $mainframe;
}
/**
* Example 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
*/
function onAfterStoreUser($user, $isnew, $succes, $msg)
{
global $mainframe;
// 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 holds the user data
*/
function onBeforeDeleteUser($user)
{
global $mainframe;
}
/**
* Example 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
*/
function onAfterDeleteUser($user, $succes, $msg)
{
global $mainframe;
// 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
*
* @access public
* @param array holds the user data
* @param array extra options
* @return boolean True on success
* @since 1.5
*/
function onLoginUser($user, $options)
{
// Initialize 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
*
* @access public
* @param array holds the user data
* @return boolean True on success
* @since 1.5
*/
function onLogoutUser($user)
{
// Initialize 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 6 releases, Joomla 1.5.4 to 1.5.9. See them all, or every version of this file.