[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/ -> pre_check.php (source)

   1  <?php
   2  //
   3  // SOFTWARE NAME: eZ publish
   4  // SOFTWARE RELEASE: 3.9.0
   5  // BUILD VERSION: 17785
   6  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
   7  // SOFTWARE LICENSE: GNU General Public License v2.0
   8  // NOTICE: >
   9  //   This program is free software; you can redistribute it and/or
  10  //   modify it under the terms of version 2.0  of the GNU General
  11  //   Public License as published by the Free Software Foundation.
  12  //
  13  //   This program is distributed in the hope that it will be useful,
  14  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  15  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16  //   GNU General Public License for more details.
  17  //
  18  //   You should have received a copy of version 2.0 of the GNU General
  19  //   Public License along with this program; if not, write to the Free
  20  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  21  //   MA 02110-1301, USA.
  22  //
  23  //
  24  
  25  include_once ( "lib/ezutils/classes/ezhttptool.php" );
  26  
  27  /*!
  28   Checks if the installation is valid and returns a module redirect if required.
  29   If CheckValidity in SiteAccessSettings is false then no check is done.
  30  */
  31  
  32  function eZCheckValidity( &$siteBasics, &$uri )
  33  {
  34  //     eZDebug::writeDebug( "Checking validity" );
  35      $ini =& eZINI::instance();
  36      $checkValidity = ( $ini->variable( "SiteAccessSettings", "CheckValidity" ) == "true" );
  37      $check = null;
  38      if ( $checkValidity )
  39      {
  40  //         eZDebug::writeDebug( "Setup required" );
  41          $check = array( "module" => "setup",
  42                          'function' => 'init' );
  43          // Turn off some features that won't bee needed yet
  44  //        $siteBasics['policy-check-required'] = false;
  45          $siteBasics['policy-check-omit-list'][] = 'setup';
  46          $siteBasics['url-translator-allowed'] = false;
  47          $siteBasics['show-page-layout'] = $ini->variable( 'SetupSettings', 'PageLayout' );
  48          $siteBasics['validity-check-required'] = true;
  49          $siteBasics['user-object-required'] = false;
  50          $siteBasics['session-required'] = false;
  51          $siteBasics['db-required'] = false;
  52          $siteBasics['no-cache-adviced'] = true;
  53          $siteBasics['site-design-override'] = $ini->variable( 'SetupSettings', 'OverrideSiteDesign' );
  54          $access = array( 'name' => 'setup',
  55                           'type' => EZ_ACCESS_TYPE_URI );
  56          $access = changeAccess( $access );
  57          $GLOBALS['eZCurrentAccess'] = $access;
  58      }
  59      return $check;
  60  }
  61  
  62  /*!
  63   \return an array with items to run a check on, each items
  64   is an associative array. The item must contain:
  65   - function - name of the function to run
  66  */
  67  function eZCheckList()
  68  {
  69      $checks = array();
  70      $checks["validity"] = array( "function" => "eZCheckValidity" );
  71      $checks["user"] = array( "function" => "eZCheckUser" );
  72      return $checks;
  73  }
  74  
  75  /*!
  76   Check if user login is required. If so, use login handler to redirect user.
  77  */
  78  function eZCheckUser( &$siteBasics, &$uri )
  79  {
  80      if ( !$siteBasics['user-object-required'] )
  81      {
  82          return null;
  83      }
  84  
  85      if( !include_once ( 'kernel/classes/datatypes/ezuser/ezuserloginhandler.php' ) )
  86          return null;
  87  
  88      $http =& eZHTTPTool::instance();
  89      $ini =& eZINI::instance();
  90      $requireUserLogin = ( $ini->variable( "SiteAccessSettings", "RequireUserLogin" ) == "true" );
  91      $forceLogin = $http->hasSessionVariable( EZ_LOGIN_HANDLER_FORCE_LOGIN );
  92      if ( !$requireUserLogin &&
  93           !$forceLogin )
  94      {
  95          return null;
  96      }
  97  
  98      return eZUserLoginHandler::checkUser( $siteBasics, $uri );
  99  }
 100  
 101  /*!
 102   \return an array with check items in the order they should be checked.
 103  */
 104  function eZCheckOrder()
 105  {
 106      $checkOrder = array( 'validity', 'user' );
 107      return $checkOrder;
 108  }
 109  
 110  /*!
 111   Does pre checks and returns a structure with redirection information,
 112   returns null if nothing should be done.
 113  */
 114  function eZHandlePreChecks( &$siteBasics, &$uri )
 115  {
 116      $checks = eZCheckList();
 117      precheckAllowed( $checks );
 118      $checkOrder = eZCheckOrder();
 119      foreach( $checkOrder as $checkItem )
 120      {
 121          if ( !isset( $checks[$checkItem] ) )
 122              continue;
 123          $check = $checks[$checkItem];
 124          if ( !isset( $check["allow"] ) or $check["allow"] )
 125          {
 126              $func = $check["function"];
 127              $check = $func( $siteBasics, $uri );
 128              if ( $check !== null )
 129                  return $check;
 130          }
 131      }
 132      return null;
 133  }
 134  
 135  
 136  ?>


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