Files
@ c7d7e38b2269
Branch filter:
Location: hot67beta/plugins/user/example.php
c7d7e38b2269
4.6 KiB
text/x-php
Initial import of the site.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | <?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;
}
}
|