Created
February 25, 2013 01:37
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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