Skip to content

Instantly share code, notes, and snippets.

@paranoidxc
Created February 25, 2013 01:37
Show Gist options
  • Save paranoidxc/5026786 to your computer and use it in GitHub Desktop.
Save paranoidxc/5026786 to your computer and use it in GitHub Desktop.
Yii srbac Helper.php file add a static method called isAccess check is allow the current user to access the particual method return true if allow
<?php
public static function isAccess($access) {
Yii::import("srbac.components.Helper");
$allows = Helper::findModule('srbac')->getAlwaysAllowed();
if (in_array( strtolower($access) ,array_map('strtolower', $allows ) ) ) {
return true;
}
return user()->checkAccess($access,Yii::app()->getUser()->id);
//return user()->checkAccess($access,user()->id);
}
# how to user?
#if( !Helper::isAccess( 'console@ArticleCheckPermit' ) ) {
# if not allow running this code
#}else {
# if allow running this code
#}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment