[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/user/ -> ezuserfunctioncollection.php (source)

   1  <?php
   2  //
   3  // Definition of eZUserFunctionCollection class
   4  //
   5  // Created on: <06-Oct-2002 16:19:31 amos>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  /*! \file ezuserfunctioncollection.php
  30  */
  31  
  32  /*!
  33    \class eZUserFunctionCollection ezuserfunctioncollection.php
  34    \brief The class eZUserFunctionCollection does
  35  
  36  */
  37  
  38  include_once ( 'kernel/error/errors.php' );
  39  
  40  class eZUserFunctionCollection
  41  {
  42      /*!
  43       Constructor
  44      */
  45      function eZUserFunctionCollection()
  46      {
  47      }
  48  
  49      function fetchCurrentUser()
  50      {
  51          include_once ( 'kernel/classes/datatypes/ezuser/ezuser.php' );
  52          $user =& eZUser::currentUser();
  53          if ( $user === null )
  54          {
  55              $result = array( 'error' => array( 'error_type' => 'kernel',
  56                                                 'error_code' => EZ_ERROR_KERNEL_NOT_FOUND ) );
  57          }
  58          else
  59          {
  60              $result = array( 'result' => $user );
  61          }
  62          return $result;
  63      }
  64  
  65      function fetchIsLoggedIn( $userID )
  66      {
  67          include_once ( 'kernel/classes/datatypes/ezuser/ezuser.php' );
  68          $isLoggedIn = eZUser::isUserLoggedIn( $userID );
  69          return array( 'result' => $isLoggedIn );
  70      }
  71  
  72      function fetchLoggedInCount()
  73      {
  74          include_once ( 'kernel/classes/datatypes/ezuser/ezuser.php' );
  75          $count = eZUser::fetchLoggedInCount();
  76          return array( 'result' => $count );
  77      }
  78  
  79      function fetchAnonymousCount()
  80      {
  81          include_once ( 'kernel/classes/datatypes/ezuser/ezuser.php' );
  82          $count = eZUser::fetchAnonymousCount();
  83          return array( 'result' => $count );
  84      }
  85  
  86      function fetchLoggedInList( $sortBy, $offset, $limit )
  87      {
  88          include_once ( 'kernel/classes/datatypes/ezuser/ezuser.php' );
  89          $list = eZUser::fetchLoggedInList( false, $offset, $limit, $sortBy );
  90          return array( 'result' => $list );
  91      }
  92  
  93      function fetchLoggedInUsers( $sortBy, $offset, $limit )
  94      {
  95          include_once ( 'kernel/classes/datatypes/ezuser/ezuser.php' );
  96          $list = eZUser::fetchLoggedInList( true, $offset, $limit, $sortBy );
  97          return array( 'result' => $list );
  98      }
  99  
 100      function fetchUserRole( $userID )
 101      {
 102          include_once ( 'kernel/classes/datatypes/ezuser/ezuser.php' );
 103          include_once ( 'kernel/classes/ezrole.php' );
 104          include_once ( "kernel/classes/ezpolicylimitation.php" );
 105          $userGroupObjects =& eZUser::groups( true, $userID );
 106          $userGroupArray = array();
 107          foreach ( $userGroupObjects as $userGroupObject )
 108          {
 109              $userGroupArray[] = $userGroupObject->attribute( 'id' );
 110          }
 111          $userGroupArray[] = $userID;
 112          $roleList = eZRole::fetchByUser( $userGroupArray );
 113  
 114          $accessArray = array();
 115          foreach ( array_keys ( $roleList ) as $roleKey )
 116          {
 117              $role = $roleList[$roleKey];
 118              $accessArray = array_merge_recursive( $accessArray, $role->accessArray( true ) );
 119          }
 120          $resultArray = array();
 121          foreach ( array_keys( $accessArray ) as $moduleKey )
 122          {
 123              $module =& $accessArray[$moduleKey];
 124              $moduleName = $moduleKey;
 125              if ( $moduleName != '*' )
 126              {
 127                  foreach ( array_keys( $module ) as $functionKey )
 128                  {
 129                      $function =& $module[$functionKey];
 130                      $functionName = $functionKey;
 131                      if ( $functionName != '*' )
 132                      {
 133                          $hasLimitation = true;
 134                          foreach ( array_keys( $function ) as $limitationKey )
 135                          {
 136                              if ( $limitationKey == '*' )
 137                              {
 138                                  $hasLimitation = false;
 139                                  $limitationValue = '*';
 140                                  $resultArray[] = array( 'moduleName' => $moduleName, 'functionName' => $functionName, 'limitation' =>  $limitationValue );
 141                              }
 142                          }
 143                          if ( $hasLimitation )
 144                          {
 145                              foreach ( array_keys( $function ) as $limitationKey )
 146                              {
 147                                  $limitation =& $module[$limitationKey];
 148                                  if ( $limitationKey != '*' )
 149                                  {
 150                                      $policyID = str_replace( 'p_', '', $limitationKey );
 151                                      $limitationValue = eZPolicyLimitation::fetchByPolicyID( $policyID );
 152                                      $resultArray[] = array( 'moduleName' => $moduleName, 'functionName' => $functionName, 'limitation' =>  $limitationValue );
 153                                  }
 154                                  else
 155                                  {
 156                                      $limitationValue = '*';
 157                                      $resultArray[] = array( 'moduleName' => $moduleName, 'functionName' => $functionName, 'limitation' =>  $limitationValue );
 158                                      break;
 159                                  }
 160                              }
 161                          }
 162                      }
 163                      else
 164                      {
 165                          $limitationValue = '*';
 166                          $resultArray[] = array( 'moduleName' => $moduleName, 'functionName' => $functionName, 'limitation' =>  $limitationValue );
 167                          break;
 168                      }
 169                  }
 170              }
 171              else
 172              {
 173                  $functionName = '*';
 174                  $resultArray[] = array( 'moduleName' => '*', 'functionName' => $functionName, 'limitation' => '*' );
 175                  break;
 176              }
 177          }
 178          return array( 'result' => $resultArray );
 179      }
 180  
 181      function fetchMemberOf( $id )
 182      {
 183          include_once ( 'kernel/classes/ezrole.php' );
 184          return array( 'result' => eZRole::fetchByUser( array( $id ), true ) );
 185      }
 186  
 187      function hasAccessTo( $module, $view, $userID )
 188      {
 189          include_once ( 'kernel/classes/datatypes/ezuser/ezuser.php' );
 190          if ( $userID )
 191          {
 192              $user = eZUser::fetch( $userID );
 193          }
 194          else
 195          {
 196              $user =& eZUser::currentUser();
 197          }
 198          $result = $user->hasAccessTo( $module, $view );
 199          return array( 'result' => $result['accessWord'] != 'no' );
 200      }
 201  }
 202  
 203  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7