[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/kernel/role/ -> view.php (source)

   1  <?php
   2  //
   3  // Created on: <22-Aug-2002 16:38:41 sp>
   4  //
   5  // SOFTWARE NAME: eZ publish
   6  // SOFTWARE RELEASE: 3.9.0
   7  // BUILD VERSION: 17785
   8  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
   9  // SOFTWARE LICENSE: GNU General Public License v2.0
  10  // NOTICE: >
  11  //   This program is free software; you can redistribute it and/or
  12  //   modify it under the terms of version 2.0  of the GNU General
  13  //   Public License as published by the Free Software Foundation.
  14  //
  15  //   This program is distributed in the hope that it will be useful,
  16  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  17  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18  //   GNU General Public License for more details.
  19  //
  20  //   You should have received a copy of version 2.0 of the GNU General
  21  //   Public License along with this program; if not, write to the Free
  22  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  23  //   MA 02110-1301, USA.
  24  //
  25  //
  26  
  27  /*! \file view.php
  28  */
  29  
  30  include_once ( 'kernel/classes/ezmodulemanager.php' );
  31  include_once ( 'kernel/classes/ezrole.php' );
  32  include_once ( 'kernel/classes/ezsearch.php' );
  33  include_once ( 'kernel/classes/ezcontentbrowse.php' );
  34  include_once ( 'lib/ezutils/classes/ezhttptool.php' );
  35  include_once ( 'lib/ezutils/classes/ezhttppersistence.php' );
  36  include_once ( 'lib/ezutils/classes/ezmodule.php' );
  37  include_once ( 'kernel/classes/ezcontentobjecttreenode.php' );
  38  
  39  include_once ( 'kernel/common/template.php' );
  40  
  41  $http =& eZHTTPTool::instance();
  42  $Module =& $Params['Module'];
  43  $roleID =& $Params['RoleID'];
  44  
  45  $role = eZRole::fetch( $roleID );
  46  
  47  if ( !$role )
  48  {
  49      $Module->redirectTo( '/role/list/' );
  50      return;
  51  }
  52  
  53  // Redirect to role edit
  54  if ( $http->hasPostVariable( 'EditRoleButton' ) )
  55  {
  56      $Module->redirectTo( '/role/edit/' . $roleID );
  57      return;
  58  }
  59  
  60  // Redirect to content node browse in the user tree
  61  if ( $http->hasPostVariable( 'AssignRoleButton' ) )
  62  {
  63      include_once ( 'kernel/classes/ezcontentbrowse.php' );
  64      eZContentBrowse::browse( array( 'action_name' => 'AssignRole',
  65                                      'from_page' => '/role/assign/' . $roleID,
  66                                      'cancel_page' => '/role/view/'. $roleID ),
  67                               $Module );
  68  
  69      return;
  70  }
  71  else if ( $http->hasPostVariable( 'AssignRoleLimitedButton' ) )
  72  {
  73      $Module->redirectTo( '/role/assign/' . $roleID . '/' . $http->postVariable( 'AssignRoleType' ) );
  74      return;
  75  }
  76  
  77  // Assign the role for a user or group
  78  if ( $Module->isCurrentAction( 'AssignRole' ) )
  79  {
  80      $selectedObjectIDArray = eZContentBrowse::result( 'AssignRole' );
  81  
  82      $assignedUserIDArray =& $role->fetchUserID();
  83  
  84      $db =& eZDB::instance();
  85      $db->begin();
  86      foreach ( $selectedObjectIDArray as $objectID )
  87      {
  88          if ( !in_array(  $objectID, $assignedUserIDArray ) )
  89          {
  90              $role->assignToUser( $objectID );
  91          }
  92      }
  93      /* Clean up policy cache */
  94      include_once ( 'kernel/classes/datatypes/ezuser/ezuser.php' );
  95      eZUser::cleanupCache();
  96  
  97      // Clear role caches.
  98      eZRole::expireCache();
  99  
 100      // Clear all content cache.
 101      include_once ( 'kernel/classes/ezcontentcachemanager.php' );
 102      eZContentCacheManager::clearAllContentCache();
 103  
 104      $db->commit();
 105  }
 106  
 107  // Remove the role assignment
 108  if ( $http->hasPostVariable( 'RemoveRoleAssignmentButton' ) )
 109  {
 110      $idArray = $http->postVariable( "IDArray" );
 111  
 112      $db =& eZDB::instance();
 113      $db->begin();
 114      foreach ( $idArray as $id )
 115      {
 116          $role->removeUserAssignmentByID( $id );
 117      }
 118      /* Clean up policy cache */
 119      include_once ( 'kernel/classes/datatypes/ezuser/ezuser.php' );
 120      eZUser::cleanupCache();
 121   
 122      // Clear role caches.
 123      eZRole::expireCache();
 124  
 125      // Clear all content cache.
 126      include_once ( 'kernel/classes/ezcontentcachemanager.php' );
 127      eZContentCacheManager::clearAllContentCache();
 128  
 129      $db->commit();
 130  }
 131  
 132  $tpl =& templateInit();
 133  
 134  $userArray =& $role->fetchUserByRole();
 135  
 136  $policies = $role->attribute( 'policies' );
 137  $tpl->setVariable( 'policies', $policies );
 138  $tpl->setVariable( 'module', $Module );
 139  $tpl->setVariable( 'role', $role );
 140  
 141  $tpl->setVariable( 'user_array', $userArray );
 142  
 143  $Module->setTitle( 'View role - ' . $role->attribute( 'name' ) );
 144  
 145  $Result = array();
 146  $Result['content'] =& $tpl->fetch( 'design:role/view.tpl' );
 147  $Result['path'] = array( array( 'text' => 'Role',
 148                                  'url' => 'role/list' ),
 149                           array( 'text' => $role->attribute( 'name' ),
 150                                  'url' => false ) );
 151  
 152  ?>


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