Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CAccessControlFilter
  • CAccessRule
  • CAuthAssignment
  • CAuthItem
  • CAuthManager
  • CBaseUserIdentity
  • CDbAuthManager
  • CPhpAuthManager
  • CUserIdentity
  • CWebUser
  • X2WebUser
  • Overview
  • Package
  • Class
  • Tree

Class CPhpAuthManager

CPhpAuthManager represents an authorization manager that stores authorization information in terms of a PHP script file.

The authorization data will be saved to and loaded from a file specified by CPhpAuthManager::$authFile, which defaults to 'protected/data/auth.php'.

CPhpAuthManager is mainly suitable for authorization data that is not too big (for example, the authorization data for a personal blog system). Use CDbAuthManager for more complex authorization data.

CComponent
Extended by CApplicationComponent implements IApplicationComponent
Extended by CAuthManager implements IAuthManager
Extended by CPhpAuthManager
Package: system\web\auth
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/web/auth/CPhpAuthManager.php
Methods summary
public
# init( )

Initializes the application component. This method overrides parent implementation by loading the authorization data from PHP script.

Initializes the application component. This method overrides parent implementation by loading the authorization data from PHP script.

Overrides

CApplicationComponent::init()
public boolean
# checkAccess( string $itemName, mixed $userId, array $params = array() )

Performs access check for the specified user.

Performs access check for the specified user.

Parameters

$itemName
string
$itemName the name of the operation that need access check
$userId
mixed
$userId the user ID. This can be either an integer or a string representing the unique identifier of a user. See IWebUser::getId().
$params
array
$params name-value pairs that would be passed to biz rules associated with the tasks and roles assigned to the user. Since version 1.1.11 a param with name 'userId' is added to this array, which holds the value of <span class="php-var">$userId</span>.

Returns

boolean
whether the operations can be performed by the user.
public boolean
# addItemChild( string $itemName, string $childName )

Adds an item as a child of another item.

Adds an item as a child of another item.

Parameters

$itemName
string
$itemName the parent item name
$childName
string
$childName the child item name

Returns

boolean
whether the item is added successfully

Throws

CException
if either parent or child doesn't exist or if a loop has been detected.
public boolean
# removeItemChild( string $itemName, string $childName )

Removes a child from its parent. Note, the child item is not deleted. Only the parent-child relationship is removed.

Removes a child from its parent. Note, the child item is not deleted. Only the parent-child relationship is removed.

Parameters

$itemName
string
$itemName the parent item name
$childName
string
$childName the child item name

Returns

boolean
whether the removal is successful
public boolean
# hasItemChild( string $itemName, string $childName )

Returns a value indicating whether a child exists within a parent.

Returns a value indicating whether a child exists within a parent.

Parameters

$itemName
string
$itemName the parent item name
$childName
string
$childName the child item name

Returns

boolean
whether the child exists
public array
# getItemChildren( mixed $names )

Returns the children of the specified item.

Returns the children of the specified item.

Parameters

$names
mixed
$names the parent item name. This can be either a string or an array. The latter represents a list of item names.

Returns

array
all child items of the parent
public CAuthAssignment
# assign( string $itemName, mixed $userId, string $bizRule = null, mixed $data = null )

Assigns an authorization item to a user.

Assigns an authorization item to a user.

Parameters

$itemName
string
$itemName the item name
$userId
mixed
$userId the user ID (see IWebUser::getId())
$bizRule
string
$bizRule the business rule to be executed when CPhpAuthManager::checkAccess() is called for this particular authorization item.
$data
mixed
$data additional data associated with this assignment

Returns

CAuthAssignment
the authorization assignment information.

Throws

CException
if the item does not exist or if the item has already been assigned to the user
public boolean
# revoke( string $itemName, mixed $userId )

Revokes an authorization assignment from a user.

Revokes an authorization assignment from a user.

Parameters

$itemName
string
$itemName the item name
$userId
mixed
$userId the user ID (see IWebUser::getId())

Returns

boolean
whether removal is successful
public boolean
# isAssigned( string $itemName, mixed $userId )

Returns a value indicating whether the item has been assigned to the user.

Returns a value indicating whether the item has been assigned to the user.

Parameters

$itemName
string
$itemName the item name
$userId
mixed
$userId the user ID (see IWebUser::getId())

Returns

boolean
whether the item has been assigned to the user.
public CAuthAssignment
# getAuthAssignment( string $itemName, mixed $userId )

Returns the item assignment information.

Returns the item assignment information.

Parameters

$itemName
string
$itemName the item name
$userId
mixed
$userId the user ID (see IWebUser::getId())

Returns

CAuthAssignment
the item assignment information. Null is returned if the item is not assigned to the user.
public array
# getAuthAssignments( mixed $userId )

Returns the item assignments for the specified user.

Returns the item assignments for the specified user.

Parameters

$userId
mixed
$userId the user ID (see IWebUser::getId())

Returns

array
the item assignment information for the user. An empty array will be returned if there is no item assigned to the user.
public array
# getAuthItems( integer $type = null, mixed $userId = null )

Returns the authorization items of the specific type and user.

Returns the authorization items of the specific type and user.

Parameters

$type
integer
$type the item type (0: operation, 1: task, 2: role). Defaults to null, meaning returning all items regardless of their type.
$userId
mixed
$userId the user ID. Defaults to null, meaning returning all items even if they are not assigned to a user.

Returns

array
the authorization items of the specific type.
public CAuthItem
# createAuthItem( string $name, integer $type, string $description = '', string $bizRule = null, mixed $data = null )

Creates an authorization item. An authorization item represents an action permission (e.g. creating a post). It has three types: operation, task and role. Authorization items form a hierarchy. Higher level items inherit permissions representing by lower level items.

Creates an authorization item. An authorization item represents an action permission (e.g. creating a post). It has three types: operation, task and role. Authorization items form a hierarchy. Higher level items inherit permissions representing by lower level items.

Parameters

$name
string
$name the item name. This must be a unique identifier.
$type
integer
$type the item type (0: operation, 1: task, 2: role).
$description
string
$description description of the item
$bizRule
string
$bizRule business rule associated with the item. This is a piece of PHP code that will be executed when CPhpAuthManager::checkAccess() is called for the item.
$data
mixed
$data additional data associated with the item.

Returns

CAuthItem
the authorization item

Throws

CException
if an item with the same name already exists
public boolean
# removeAuthItem( string $name )

Removes the specified authorization item.

Removes the specified authorization item.

Parameters

$name
string
$name the name of the item to be removed

Returns

boolean
whether the item exists in the storage and has been removed
public CAuthItem
# getAuthItem( string $name )

Returns the authorization item with the specified name.

Returns the authorization item with the specified name.

Parameters

$name
string
$name the name of the item

Returns

CAuthItem
the authorization item. Null if the item cannot be found.
public
# saveAuthItem( CAuthItem $item, string $oldName = null )

Saves an authorization item to persistent storage.

Saves an authorization item to persistent storage.

Parameters

$item
CAuthItem
$item the item to be saved.
$oldName
string
$oldName the old item name. If null, it means the item name is not changed.
public
# saveAuthAssignment( CAuthAssignment $assignment )

Saves the changes to an authorization assignment.

Saves the changes to an authorization assignment.

Parameters

$assignment
CAuthAssignment
$assignment the assignment that has been changed.
public
# save( )

Saves authorization data into persistent storage. If any change is made to the authorization data, please make sure you call this method to save the changed data into persistent storage.

Saves authorization data into persistent storage. If any change is made to the authorization data, please make sure you call this method to save the changed data into persistent storage.

public
# load( )

Loads authorization data.

Loads authorization data.

public
# clearAll( )

Removes all authorization data.

Removes all authorization data.

public
# clearAuthAssignments( )

Removes all authorization assignments.

Removes all authorization assignments.

protected boolean
# detectLoop( string $itemName, string $childName )

Checks whether there is a loop in the authorization item hierarchy.

Checks whether there is a loop in the authorization item hierarchy.

Parameters

$itemName
string
$itemName parent item name
$childName
string
$childName the name of the child item that is to be added to the hierarchy

Returns

boolean
whether a loop exists
protected array
# loadFromFile( string $file )

Loads the authorization data from a PHP script file.

Loads the authorization data from a PHP script file.

Parameters

$file
string
$file the file path.

Returns

array
the authorization data

See

CPhpAuthManager::saveToFile()
protected
# saveToFile( array $data, string $file )

Saves the authorization data to a PHP script file.

Saves the authorization data to a PHP script file.

Parameters

$data
array
$data the authorization data
$file
string
$file the file path.

See

CPhpAuthManager::loadFromFile()
Methods inherited from CAuthManager
checkItemChildType(), createOperation(), createRole(), createTask(), executeBizRule(), getOperations(), getRoles(), getTasks()
Methods inherited from CApplicationComponent
getIsInitialized()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Properties summary
public string $authFile
#

the path of the PHP script that contains the authorization data. If not set, it will be using 'protected/data/auth.php' as the data file. Make sure this file is writable by the Web server process if the authorization needs to be changed.

the path of the PHP script that contains the authorization data. If not set, it will be using 'protected/data/auth.php' as the data file. Make sure this file is writable by the Web server process if the authorization needs to be changed.

See

CPhpAuthManager::loadFromFile()
CPhpAuthManager::saveToFile()
Properties inherited from CAuthManager
$defaultRoles, $showErrors
Properties inherited from CApplicationComponent
$behaviors
Magic properties summary
public array $authItems
#

The authorization items of the specific type.

The authorization items of the specific type.

Magic properties inherited from CAuthManager
$operations, $roles, $tasks
Magic properties inherited from CApplicationComponent
$isInitialized
API documentation generated by ApiGen 2.8.0