Source for file user.ext.php
Documentation is available at user.ext.php
/***********************************************\
* Copyright (c) 2009 Zibings Incorporated *
* You should have received a copy of the *
* Microsoft Reciprocal License along with *
* this program. If not, see: *
* <http://opensource.org/licenses/ms-rl.html> *
\***********************************************/
* $Id: user.ext.php 56 2009-12-23 20:34:50Z amale $
global $n2f, $user, $strings;
// Register the extension
'http://n2framework.com/'
// Hook the N2F_EVT_CORE_LOADED event
// Create the user extension warning constant
define('N2F_WARN_USER_TIMEOUT', 'U001');
// Create the user extension notice constant
define('N2F_NOTICE_USER_INIT', 'U001');
// English warning strings
$strings['en']['N2F_WARN_USER_TIMEOUT'] =
"The user has timed out.";
// German warning strings
$strings['de']['N2F_WARN_USER_TIMEOUT'] =
"The user has timed out.";
// Spanish warning strings
$strings['es']['N2F_WARN_USER_TIMEOUT'] =
"The user has timed out.";
// Swedish warning strings
$strings['se']['N2F_WARN_USER_TIMEOUT'] =
"The user has timed out.";
// English notice strings
$strings['en']['N2F_NOTICE_USER_INIT'] =
"The user object has been initialized.";
$strings['de']['N2F_NOTICE_USER_INIT'] =
"The user object has been initialized.";
// Spanish notice strings
$strings['es']['N2F_NOTICE_USER_INIT'] =
"The user object has been initialized.";
// Swedish notice strings
$strings['se']['N2F_NOTICE_USER_INIT'] =
"The user object has been initialized.";
* Function that tries to initialize the $user global.
* @param n2f_cls $n2f The object who is calling this function
* @param mixed $results The results returned from the system loading its core
function init_user(n2f_cls &$n2f, $results) {
// Check if there was a massive failure or if the session extension isn't loaded
if ($results ===
false ||
$n2f->hasExtension('session') ===
false) {
// And if either is the case, just stop here
// Pull in global variable(s)
// Initialize the timeout stamp
$timeout =
(time() -
300);
// Check if there is a session user
if ($sess->exists('n2f_sess_user')) {
// There is, so pull them out
$user =
$sess->get('n2f_sess_user');
// Just check if they've timed out
if ($user->lasttime <
$timeout) {
// And if so, reset their properties
$user->lasttime =
time();
// If we're supposed to track warnings..
// Throw a warning to the main debug object
$n2f->debug->throwWarning(N2F_WARN_USER_TIMEOUT, S('N2F_WARN_USER_TIMEOUT'), 'system/extensions/user.ext.php');
// Otherwise, initialize a new user and add them to the session
$sess->set('n2f_sess_user', $user);
// If we're supposed to track notices..
// Throw a notice to the main debug object
$n2f->debug->throwNotice(N2F_NOTICE_USER_INIT, S('N2F_NOTICE_USER_INIT'), 'system/extensions/user.ext.php');
// And stop processing, we've got nothing left to do!
* Example n2f_user class.
* User identifier property.
* Last timestamp when user was active.
* Initializes a new n2f_user object.
// Initialize the properties
// Return ourself for chaining
Documentation generated on Sat, 23 Jan 2010 11:13:51 -0500 by phpDocumentor 1.4.1