ezuser.php

00001 <?php
00002 //
00003 // Definition of eZUser class
00004 //
00005 // Created on: <10-Jun-2002 17:03:15 bf>
00006 //
00007 // Copyright (C) 1999-2003 Exponential. All rights reserved.
00008 //
00009 // This source file is part of the Exponential (tm) Open Source Content
00010 // Management System.
00011 //
00012 // This file may be distributed and/or modified under the terms of the
00013 // "GNU General Public License" version 2 as published by the Free
00014 // Software Foundation and appearing in the file LICENSE.GPL included in
00015 // the packaging of this file.
00016 //
00017 // Licencees holding valid "Exponential professional licences" may use this
00018 // file in accordance with the "Exponential professional licence" Agreement
00019 // provided with the Software.
00020 //
00021 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
00022 // THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00023 // PURPOSE.
00024 //
00025 // The "Exponential professional licence" is available at
00026 // http://ez.no/products/licences/professional/. For pricing of this licence
00027 // please contact us via e-mail to licence@ez.no. Further contact
00028 // information is available at http://ez.no/home/contact/.
00029 //
00030 // The "GNU General Public License" (GPL) is available at
00031 // http://www.gnu.org/copyleft/gpl.html.
00032 //
00033 // Contact licence@ez.no if any conditions of this licencing isn't clear to
00034 // you.
00035 //
00036 
00044 include_once( 'kernel/classes/ezpersistentobject.php' );
00045 include_once( 'kernel/classes/ezrole.php' );
00046 include_once( 'lib/ezutils/classes/ezhttptool.php' );
00047 include_once( "kernel/classes/datatypes/ezuser/ezusersetting.php" );
00048 include_once( "kernel/classes/ezcontentobject.php" );
00049 
00050 $ini =& eZINI::instance();
00051 define( 'EZ_USER_ANONYMOUS_ID', $ini->variable( 'UserSettings', 'AnonymousUserID' ) );
00052 
00054 define( 'EZ_USER_PASSWORD_HASH_MD5_PASSWORD', 1 );
00056 define( 'EZ_USER_PASSWORD_HASH_MD5_USER', 2 );
00058 define( 'EZ_USER_PASSWORD_HASH_MD5_SITE', 3 );
00060 define( 'EZ_USER_PASSWORD_HASH_MYSQL', 4 );
00062 define( 'EZ_USER_PASSWORD_HASH_PLAINTEXT', 5 );
00063 
00065 define( 'EZ_USER_AUTHENTICATE_LOGIN', 1 << 0 );
00067 define( 'EZ_USER_AUTHENTICATE_EMAIL', 1 << 1 );
00068 
00069 define( 'EZ_USER_AUTHENTICATE_ALL', EZ_USER_AUTHENTICATE_LOGIN | EZ_USER_AUTHENTICATE_EMAIL );
00070 
00071 $GLOBALS['eZUserBuiltins'] = array( EZ_USER_ANONYMOUS_ID );
00072 
eZPersistentObject
00074 {
00075     function eZUser( $row )
00076     {
00077         $this->eZPersistentObject( $row );
00078         $this->OriginalPassword = false;
00079         $this->OriginalPasswordConfirm = false;
00080     }
00081 
definition()
00083     {
00084         return array( 'fields' => array( 'contentobject_id' => 'ContentObjectID',
00085                                          'login' => 'Login',
00086                                          'email' => 'Email',
00087                                          'password_hash' => 'PasswordHash',
00088                                          'password_hash_type' => 'PasswordHashType'
00089                                          ),
00090                       'keys' => array( 'contentobject_id' ),
00091                       'function_attributes' => array( 'contentobject' => 'contentObject',
00092                                                       'groups',
00093                                                       'has_stored_login' => 'hasStoredLogin',
00094                                                       'original_password' => 'originalPassword',
00095                                                       'original_password_confirm' => 'originalPasswordConfirm',
00096                                                       'roles',
00097                                                       'is_logged_in' => 'isLoggedIn'
00098                                                       ),
00099                       'relations' => array( 'contentobject_id' => array( 'class' => 'ezcontentobject',
00100                                                                          'field' => 'id' ) ),
00101                       'class_name' => 'eZUser',
00102                       'name' => 'ezuser' );
00103     }
00104 
attribute( $name )
00106     {
00107         if ( $name == 'groups')
00108         {
00109             return $this->groups();
00110         }
00111         else if ( $name == 'is_logged_in')
00112         {
00113             return $this->isLoggedIn();
00114         }
00115         else if ( $name == 'roles')
00116         {
00117             return $this->roles();
00118         }
00119         else if ( $name == 'has_stored_login')
00120         {
00121             return $this->hasStoredLogin();
00122         }
00123         else if ( $name == 'original_password' )
00124         {
00125             return $this->originalPassword();
00126         }
00127         else if ( $name == 'original_password_confirm' )
00128         {
00129             return $this->originalPasswordConfirm();
00130         }
00131         else if ( $name == 'contentobject' )
00132         {
00133             if ( $this->ContentObjectID == 0 )
00134                 return null;
00135             include_once( 'kernel/classes/ezcontentobject.php' );
00136             return eZContentObject::fetch( $this->ContentObjectID );
00137         }
00138         else
00139             return eZPersistentObject::attribute( $name );
00140     }
00141 
00142     function &create( $contentObjectID )
00143     {
00144         $row = array(
00145             'contentobject_id' => $contentObjectID,
00146             'login' => null,
00147             'email' => null,
00148             'password_hash' => null,
00149             'password_hash_type' => null
00150             );
00151         return new eZUser( $row );
00152     }
00153 
00154     function store()
00155     {
00156         $this->Email = trim( $this->Email );
00157         include_once( 'lib/ezutils/classes/ezexpiryhandler.php' );
00158         $handler =& eZExpiryHandler::instance();
00159         $handler->setTimestamp( 'user-info-cache', mktime() );
00160         $handler->setTimestamp( 'user-groups-cache', mktime() );
00161         $handler->store();
00162         eZPersistentObject::store();
00163     }
00164 
00165     function &originalPassword()
00166     {
00167         return $this->OriginalPassword;
00168     }
00169 
00170     function setOriginalPassword( $password )
00171     {
00172         $this->OriginalPassword = $password;
00173     }
00174 
00175     function &originalPasswordConfirm()
00176     {
00177         return $this->OriginalPasswordConfirm;
00178     }
00179 
00180     function setOriginalPasswordConfirm( $password )
00181     {
00182         $this->OriginalPasswordConfirm = $password;
00183     }
00184 
00185     function hasStoredLogin()
00186     {
00187         $db =& eZDB::instance();
00188         $contentObjectID = $this->attribute( 'contentobject_id' );
00189         $sql = "SELECT * FROM ezuser WHERE contentobject_id='$contentObjectID' AND login!=''";
00190         $rows = $db->arrayQuery( $sql );
00191         $hasStoredLogin = count( $rows ) > 0;
00192         eZDebug::writeDebug( $hasStoredLogin, 'hasStoredLogin' );
00193         return $hasStoredLogin;
00194     }
00195 
id, $login, $email, $password, $passwordConfirm = false )
00201     {
00202         $this->id );
00203         $this->setAttribute( "email", $email );
00204         $this->setAttribute( "login", $login );
00205         if ( $password !== false and
00206              $password !== null and
00207              $password == $passwordConfirm and
00208              strlen( $password ) >= 3 ) // Cannot change login or password_hash without login and password
00209         {
00210             $this->eZUser::site(),
00211                                                                       eZUser::hashType() ) );
00212             $this->eZUser::hashType() );
00213         }
00214         else
00215         {
00216             $this->setOriginalPassword( $password );
00217             $this->setOriginalPasswordConfirm( $passwordConfirm );
00218         }
00219     }
00220 
00221     function &fetch( $id, $asObject = true )
00222     {
00223         $user =& eZUser::definition(),
00224                                                   null,
00225                                                   array( 'contentobject_id' => $id ),
00226                                                   $asObject );
00227         return $user;
00228     }
00229 
00230     function &fetchByName( $login, $asObject = true )
00231     {
00232         $user =& eZUser::definition(),
00233                                                   null,
00234                                                   array( 'login' => $login ),
00235                                                   $asObject );
00236         return $user;
00237     }
00238 
00239     function &fetchByEmail( $email, $asObject = true )
00240     {
00241         $user =& eZUser::definition(),
00242                                                   null,
00243                                                   array( 'email' => $email ),
00244                                                   $asObject );
00245         return $user;
00246     }
00247 
00248     function &removeUser( $userID )
00249     {
00250         eZUser::definition(),
00251                                           array( 'contentobject_id' => $userID ) );
00252     }
00253 
hashType()
00259     {
00260         include_once( 'lib/ezutils/classes/ezini.php' );
00261         $ini =& eZINI::instance();
00262         $type = strtolower( $ini->variable( 'UserSettings', 'HashType' ) );
00263         if ( $type == 'md5_site' )
00264             return EZ_USER_PASSWORD_HASH_MD5_SITE;
00265         else if ( $type == 'md5_user' )
00266             return EZ_USER_PASSWORD_HASH_MD5_USER;
00267         else if ( $type == 'plaintext' )
00268             return EZ_USER_PASSWORD_HASH_PLAINTEXT;
00269         else
00270             return EZ_USER_PASSWORD_HASH_MD5_PASSWORD;
00271     }
00272 
site()
00278     {
00279         include_once( 'lib/ezutils/classes/ezini.php' );
00280         $ini =& eZINI::instance();
00281         return $ini->variable( 'UserSettings', 'SiteName' );
00282     }
00283 
id )
00289     {
00290         if ( !in_array( $id, $GLOBALS['eZUserBuiltins'] ) )
00291             $id = EZ_USER_ANONYMOUS_ID;
00292         $builtinInstance =& $GLOBALS["eZUserBuilitinInstance-$id"];
00293         if ( get_class( $builtinInstance ) != 'ezuser' )
00294         {
00295             include_once( 'lib/ezutils/classes/ezini.php' );
00296             $builtinInstance =  eZUser::fetch( EZ_USER_ANONYMOUS_ID );
00297         }
00298         return $builtinInstance;
00299     }
00300 
00301 
id()
00306     {
00307         return $this->ContentObjectID;
00308     }
00309 
authenticationMatch()
00314     {
00315         include_once( 'lib/ezutils/classes/ezini.php' );
00316         $ini =& eZINI::instance();
00317         $matchArray = $ini->variableArray( 'UserSettings', 'AuthenticateMatch' );
00318         $match = 0;
00319         foreach ( $matchArray as $matchItem )
00320         {
00321             switch ( $matchItem )
00322             {
00323                 case "login":
00324                 {
00325                     $match = ( $match | EZ_USER_AUTHENTICATE_LOGIN );
00326                 } break;
00327                 case "email":
00328                 {
00329                     $match = ( $match | EZ_USER_AUTHENTICATE_EMAIL );
00330                 } break;
00331             }
00332         }
00333         return $match;
00334     }
00335 
authenticationMatch = false )
00342     {
00343         $http =& eZHTTPTool::instance();
00344         $db =& eZDB::instance();
00345 
00346         if ( $authenticationMatch === false )
00347             $eZUser::authenticationMatch();
00348 
00349         $loginEscaped = $db->escapeString( $login );
00350 
00351         $loginArray = array();
00352         if ( $authenticationMatch & EZ_USER_AUTHENTICATE_LOGIN )
00353             $loginArray[] = "login='$loginEscaped'";
00354         if ( $authenticationMatch & EZ_USER_AUTHENTICATE_EMAIL )
00355             $loginArray[] = "email='$loginEscaped'";
00356         if ( count( $loginArray ) == 0 )
00357             $loginArray[] = "login='$loginEscaped'";
00358         $loginText = implode( ' OR ', $loginArray );
00359 
00360         $contentObjectStatus = EZ_CONTENT_OBJECT_STATUS_PUBLISHED;
00361 
00362         $ini =& eZINI::instance();
00363         $databaseImplementation = $ini->variable( 'DatabaseSettings', 'DatabaseImplementation' );
00364         // if mysql
00365         if ( $databaseImplementation == "ezmysql" )
00366         {
00367             $query = "SELECT contentobject_id, password_hash, password_hash_type, email, login
00368                       FROM ezuser, ezcontentobject
00369                       WHERE ( $loginText ) AND
00370                         ezcontentobject.status='$contentObjectStatus' AND
00371                         ( ezcontentobject.id=contentobject_id OR ( password_hash_type=4 AND ( $loginText ) AND password_hash=PASSWORD('$password') ) )";
00372         }
00373         else
00374         {
00375             $query = "SELECT contentobject_id, password_hash, password_hash_type, email, login
00376                       FROM ezuser, ezcontentobject
00377                       WHERE ( $loginText ) AND
00378                             ezcontentobject.status='$contentObjectStatus' AND
00379                             ezcontentobject.id=contentobject_id";
00380         }
00381 
00382         $users =& $db->arrayQuery( $query );
00383         $exists = false;
00384         if ( count( $users ) >= 1 )
00385         {
00386             include_once( 'lib/ezutils/classes/ezini.php' );
00387             $ini =& eZINI::instance();
00388             foreach ( array_keys( $users ) as $key )
00389             {
00390                 $userRow =& $users[$key];
00391                 $userID = $userRow['contentobject_id'];
00392                 $hashType = $userRow['password_hash_type'];
00393                 $hash = $userRow['password_hash'];
00394                 $exists = eZUser::site(),
00395                                                     $hashType,
00396                                                     $hash );
00397 
00398                 // If hash type is MySql
00399                 if ( $hashType == EZ_USER_PASSWORD_HASH_MYSQL and $databaseImplementation == "ezmysql" )
00400                 {
00401                     $queryMysqlUser = "SELECT contentobject_id, password_hash, password_hash_type, email, login
00402                               FROM ezuser, ezcontentobject
00403                               WHERE ezcontentobject.status='$contentObjectStatus' AND
00404                                     password_hash_type=4 AND ( $loginText ) AND password_hash=PASSWORD('$password') ";
00405                     $mysqlUsers =& $db->arrayQuery( $queryMysqlUser );
00406                     if ( count( $mysqlUsers ) >= 1 )
00407                         $exists = true;
00408                 }
00409 
00410                 eZUser::site(),
00411                                                                                $hashType ), "check hash" );
00412                 eZDebugSetting::writeDebug( 'kernel-user', $hash, "stored hash" );
00413                 if ( $exists )
00414                 {
00415                     $userSetting = eZUserSetting::fetch( $userID );
00416                     $isEnabled = $userSetting->attribute( "is_enabled" );
00417                     if ( $eZUser::hashType() and
00418                          strtolower( $ini->variable( 'UserSettings', 'UpdateHash' ) ) == 'true' )
00419                     {
00420                         $eZUser::hashType();
00421                         $hash = eZUser::site(),
00422                                                     $hashType );
00423                         $db->query( "UPDATE ezuser SET password_hash='$hash', password_hash_type='$hashType' WHERE contentobject_id='$userID'" );
00424                     }
00425                     break;
00426                 }
00427             }
00428         }
00429         if ( $exists and $isEnabled )
00430         {
00431             eZDebugSetting::writeDebug( 'kernel-user', $userRow, 'user row' );
00432             $user =& new eZUser( $userRow );
00433             eZDebugSetting::writeDebug( 'kernel-user', $user, 'user' );
00434             $GLOBALS["eZUserGlobalInstance"] =& $user;
00435             $http->setSessionVariable( 'eZUserLoggedInID', $userRow['contentobject_id'] );
00436             return $user;
00437         }
00438         else
00439             return false;
00440     }
00441 
00442 
loginCurrent()
00447     {
00448         eZHTTPTool::setSessionVariable( 'eZUserLoggedInID', $this->ContentObjectID );
00449     }
00450 
logoutCurrent()
00455     {
00456         $http =& eZHTTPTool::instance();
00457         $http->removeSessionVariable( "eZUserLoggedInID" );
00458     }
00459 
id = false )
00469     {
00470         $currentUser =& $GLOBALS["eZUserGlobalInstance"];
00471         if ( get_class( $currentUser ) == 'ezuser' )
00472         {
00473             return $currentUser;
00474         }
00475 
00476         $http =& eZHTTPTool::instance();
00477         // If not specified get the current user
00478         if ( $id === false )
00479         {
00480             $id = $http->sessionVariable( 'eZUserLoggedInID' );
00481 
00482             if ( !is_numeric( $id ) )
00483                 $id = EZ_USER_ANONYMOUS_ID;
00484         }
00485 
00486         // Check cache
00487         $fetchFromDB = true;
00488 
00489         include_once( 'lib/ezutils/classes/ezexpiryhandler.php' );
00490         $handler =& eZExpiryHandler::instance();
00491         $expiredTimeStamp = 0;
00492         if ( $handler->hasTimestamp( 'user-info-cache' ) )
00493             $expiredTimeStamp = $handler->timestamp( 'user-info-cache' );
00494 
00495         $userArrayTimestamp =& $http->sessionVariable( 'eZUserInfoCache_Timestamp' );
00496 
00497         if ( $userArrayTimestamp > $expiredTimeStamp )
00498         {
00499 
00500             $userArray =& $http->sessionVariable( 'eZUserInfoCache_' . $id );
00501 
00502             if ( is_numeric( $userArray['contentobject_id'] ) )
00503             {
00504                 $eZUser( $userArray );
00505                 $fetchFromDB = false;
00506             }
00507         }
00508 
00509         if ( $fetchFromDB == true )
00510         {
00511             $id );
00512             // store cache
00513 
00514             if ( $currentUser )
00515             {
00516                 $http->setSessionVariable( 'eZUserInfoCache_' . $id,
00517                                            array( 'contentobject_id' => $currentUser->attribute( 'contentobject_id' ),
00518                                                   'login' => $currentUser->attribute( 'login' ),
00519                                                   'email' => $currentUser->attribute( 'email' ),
00520                                                   'password_hash' => $currentUser->attribute( 'password_hash' ),
00521                                                   'password_hash_type' => $currentUser->attribute( 'password_hash_type' )
00522                                                   ) );
00523                 $http->setSessionVariable( 'eZUserInfoCache_Timestamp', mktime()  );
00524             }
00525         }
00526 
00527         if ( !$currentUser )
00528         {
00529             $id' => -1, 'login' => 'NoUser' ) );
00530 
00531             eZDebug::writeWarning( 'User not found, returning anonymous' );
00532         }
00533 
00534         return $currentUser;
00535     }
00536 
currentUser()
00542     {
00543         $user =& eZUser::instance();
00544         return $user;
00545     }
00546 
currentUserID()
00552     {
00553         $user =& eZUser::instance();
00554         if ( !$user )
00555             return 0;
00556         return $user->attribute( 'contentobject_id' );
00557     }
00558 
site, $type, $hash )
00565     {
00566         return site, $type ) == $hash;
00567     }
00568 
passwordCharacterTable()
00574     {
00575         $table =& $GLOBALS['eZUserPasswordCharacterTable'];
00576         if ( isset( $table ) )
00577             return $table;
00578         $table = array();
00579         for ( $i = ord( 'a' ); $i <= ord( 'z' ); ++$i )
00580         {
00581             $char = chr( $i );
00582             $table[] = $char;
00583             $table[] = strtoupper( $char );
00584         }
00585         for ( $i = 0; $i <= 9; ++$i )
00586         {
00587             $table[] = "$i";
00588         }
00589         $ini =& eZINI::instance();
00590         if ( $ini->variable( 'UserSettings', 'UseSpecialCharacters' ) == true )
00591         {
00592             $specialCharacters = '!#%&{[]}+?;:*';
00593             for ( $i = 0; $i < strlen( $specialCharacters ); ++$i )
00594             {
00595                 $table[] = $specialCharacters[$i];
00596             }
00597         }
00598         // Remove some characters that are too similar visually
00599         $table = array_diff( $table, array( 'I', 'l', 'o', 'O', '0' ) );
00600         $tableTmp = $table;
00601         $table = array();
00602         foreach ( $tableTmp as $item )
00603         {
00604             $table[] = $item;
00605         }
00606         return $table;
00607     }
00608 
createPassword( $passwordLength, $seed = false )
00618     {
00619         $chars = 0;
00620         $password = '';
00621         if ( $passwordLength < 1 )
00622             $passwordLength = 1;
00623         $decimal = 0;
00624         while ( $chars < $passwordLength )
00625         {
00626             if ( $seed == false )
00627                 $seed = mktime();
00628             $text = md5( $seed );
00629             $characterTable = eZUser::passwordCharacterTable();
00630             $tableCount = count( $characterTable );
00631             for ( $i = 0; ( $chars < $passwordLength ) and $i < 32; ++$chars, $i += 2 )
00632             {
00633                 $decimal += hexdec( substr( $text, $i, 2 ) );
00634                 $index = ( $decimal % $tableCount );
00635                 $character = $characterTable[$index];
00636                 $password .= $character;
00637             }
00638             $seed = false;
00639         }
00640         return $password;
00641     }
00642 
site, $type )
00648     {
00649         $str = '';
00650 //         eZDebugSetting::writeDebug( 'kernel-user', "'$user' '$password' '$site'", "ezuser($type)" );
00651         if( $type == EZ_USER_PASSWORD_HASH_MD5_USER )
00652         {
00653             $str = md5( "$user\n$password" );
00654         }
00655         else if ( $type == EZ_USER_PASSWORD_HASH_MD5_SITE )
00656         {
00657             $str = md5( "$user\n$password\n$site" );
00658         }
00659         else if ( $type == EZ_USER_PASSWORD_HASH_MYSQL )
00660         {
00661             // Do some MySQL stuff here
00662         }
00663         else if ( $type == EZ_USER_PASSWORD_HASH_PLAINTEXT )
00664         {
00665             $str = $password;
00666         }
00667         else // EZ_USER_PASSWORD_HASH_MD5_PASSWORD
00668         {
00669             $str = md5( $password );
00670         }
00671         eZDebugSetting::writeDebug( 'kernel-user', $str, "ezuser($type)" );
00672         return $str;
00673     }
00674 
00675     function &hasAccessTo( $module, $function )
00676     {
00677         $roles' );
00678         $access = 'no';
00679         $limitationPolicyList = array();
00680         reset( $roles );
00681         foreach ( array_keys( $roles ) as $key )
00682         {
00683             $role =& $roles[$key];
00684             $policies =& $role->attribute( 'policies');
00685             foreach ( array_keys( $policies ) as $policy_key )
00686             {
00687                 $policy =& $policies[$policy_key];
00688                 if ( $policy->attribute( 'module_name' ) == '*' )
00689                 {
00690                     return array( 'accessWord' => 'yes' );
00691                 }
00692                 elseif ( $policy->attribute( 'module_name' ) == $module )
00693                 {
00694                     if ( $policy->attribute( 'function_name' ) == '*' )
00695                     {
00696                         return array( 'accessWord' => 'yes' );
00697                     }
00698                     elseif ( $policy->attribute( 'function_name' ) == $function )
00699                     {
00700                         if ( $policy->attribute( 'limitation' ) == '*' )
00701                         {
00702                             return array( 'accessWord' => 'yes' );
00703                         }
00704                         else
00705                         {
00706                             $access = 'limited';
00707                             $limitationPolicyList[] =& $policy;
00708                         }
00709                     }
00710                 }
00711             }
00712         }
00713         return array( 'accessWord' => $access, 'policies' => $limitationPolicyList );
00714     }
00715 
roles()
00720     {
00721         if ( !isset( $this->Roles ) )
00722         {
00723             $groups' );
00724             $attribute( 'contentobject_id' );
00725             $groups );
00726             $this->Roles =& $roles;
00727         }
00728         return $this->Roles;
00729     }
00730 
roleIDList()
00735     {
00736         $groups' );
00737         $attribute( 'contentobject_id' );
00738         $roleList = groups );
00739         return $roleList;
00740     }
00741 
isLoggedIn()
00747     {
00748         $return = true;
00749         if ( $this->ContentObjectID == EZ_USER_ANONYMOUS_ID or
00750              $this->ContentObjectID == -1
00751              )
00752             $return = false;
00753         return $return;
00754     }
00755 
groups( $asObject = false, $userID = false )
00760     {
00761         $db =& eZDB::instance();
00762         $http =& eZHTTPTool::instance();
00763 
00764         if ( $asObject == true )
00765         {
00766             $this->Groups = array();
00767             if ( !isset( $this->GroupsAsObjects ) )
00768             {
00769                 if ( $userID )
00770                 {
00771                     $contentobjectID = $userID;
00772                 }
00773                 else
00774                 {
00775                     $contentobjectID = $this->attribute( 'contentobject_id' );
00776                 }
00777                 $userGroups =& $db->arrayQuery( "SELECT d.*
00778                                                 FROM ezcontentobject_tree  b,
00779                                                      ezcontentobject_tree  c,
00780                                                      ezcontentobject d
00781                                                 WHERE b.contentobject_id='$contentobjectID' AND
00782                                                       b.parent_node_id = c.node_id AND
00783                                                       d.id = c.contentobject_id
00784                                                 ORDER BY c.contentobject_id  ");
00785                 $userGroupArray = array();
00786 
00787                 foreach ( $userGroups as $group )
00788                 {
00789                     $userGroupArray[] = new eZContentObject( $group );
00790                 }
00791                 $this->GroupsAsObjects =& $userGroupArray;
00792             }
00793             return $this->GroupsAsObjects;
00794         }
00795         else
00796         {
00797             if ( !isset( $this->Groups ) )
00798             {
00799                 if ( $userID )
00800                 {
00801                     $contentobjectID = $userID;
00802                 }
00803                 else
00804                 {
00805                     $contentobjectID = $this->attribute( 'contentobject_id' );
00806                 }
00807 
00808                 $userGroups = false;
00809 
00810                 $userGroupTimestamp =& $http->sessionVariable( 'eZUserGroupsCache_Timestamp' );
00811 
00812                 include_once( 'lib/ezutils/classes/ezexpiryhandler.php' );
00813                 $handler =& eZExpiryHandler::instance();
00814                 $expiredTimeStamp = 0;
00815                 if ( $handler->hasTimestamp( 'user-info-cache' ) )
00816                     $expiredTimeStamp = $handler->timestamp( 'user-info-cache' );
00817 
00818                 // check for cached version
00819                 if ( $userGroupTimestamp > $expiredTimeStamp )
00820                 {
00821                     $userGroupsTmp =& $http->sessionVariable( 'eZUserGroupsCache_' . $contentobjectID );
00822 
00823                     if ( count( $userGroupsTmp ) > 0 )
00824                     {
00825                         $userGroups =& $userGroupsTmp;
00826                     }
00827                 }
00828 
00829                 if ( $userGroups === false or
00830                      count( $userGroups ) == 0 )
00831                 {
00832                     $userGroups =& $db->arrayQuery( "SELECT  c.contentobject_id as id
00833                                                 FROM ezcontentobject_tree  b,
00834                                                      ezcontentobject_tree  c
00835                                                 WHERE b.contentobject_id='$contentobjectID' AND
00836                                                       b.parent_node_id = c.node_id
00837                                                 ORDER BY c.contentobject_id  ");
00838 
00839                     $http->setSessionVariable( 'eZUserGroupsCache_' . $contentobjectID, $userGroups );
00840                     $http->setSessionVariable( 'eZUserGroupsCache_Timestamp', mktime() );
00841                 }
00842 
00843                 $userGroupArray = array();
00844 
00845                 foreach ( $userGroups as $group )
00846                 {
00847                     $userGroupArray[] = $group['id'];
00848                 }
00849                 $this->Groups =& $userGroupArray;
00850             }
00851             return $this->Groups;
00852         }
00853     }
00854 
Login;
00857     var $Email;
00858     var $PasswordHash;
00859     var $PasswordHashType;
00860     var $Groups;
00861     var $Roles;
00862     var $OriginalPassword;
00863     var $OriginalPasswordConfirm;
00864 }
00865 
00866 ?>
 

Exponential