本文整理汇总了PHP中Acl::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Acl::instance方法的具体用法?PHP Acl::instance怎么用?PHP Acl::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Acl
的用法示例。
在下文中一共展示了Acl::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fail
/**
* listener version of redirect on fail acl validity check method
*
* @return void
* @author Andy Bennett
*/
public static function fail()
{
// redirect if user doesn't have correct permissions
if (!Acl::instance()->check(Event::$data['role'], Event::$data['name'], Event::$data['action'])) {
throw new Kohana_403_Exception(Event::$data['name'], 'common/error_403');
}
}
示例2: init
/**
* init: check if user is logged in
*
* if not: redirect to login
*/
public function init()
{
// call parent before first
parent::init();
// only check if the controller is not auth
if (Request::initial()->controller() != 'Auth') {
// url to loginpage
$url = URL::to('Auth@login');
// init identity
$identity = Identity::instance();
//revert identity to original user (maybe assume was called somewhere else)
$identity->revert();
// check authentication
if (!$identity->authenticated()) {
// if user is not allready authenticated, redirect to login page
$this->redirect($url);
} else {
$website = Website::instance();
// else: initialise acl
Acl::init($identity, new Model_Rights($website->websites()));
// set current environment
Acl::environment($website->id());
// if user is not entitled to access backend
if (!Acl::instance()->allowed('Backend', 'access')) {
$this->redirect($url);
}
// if user is not entitled to access controller
if (!Acl::instance()->allowed(Request::initial()->controller(), 'access')) {
$this->redirect($url);
}
}
}
}
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:38,代码来源:Auth.php
示例3: getInstance
/**
* Returns an instance of Acl object
*
* @return Acl
*/
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
示例4: user_streams
public static function user_streams($user = null, $course_id = null, $batch_id = null)
{
// first get the relevant user, if not the current user
if ($user === null) {
$user = Acl::instance()->relevant_user();
if (!$user) {
$user = Auth::instance()->get_user();
}
}
$role = $user->role();
if ($course_id === null) {
$courses = $user->courses->find_all()->as_array(null, 'id');
$courses[] = 0;
} else {
$courses = array($course_id);
}
if ($batch_id === null) {
$batches = $user->batches->find_all()->as_array(null, 'id');
$batches[] = 0;
} else {
$batches = array($batch_id);
}
$streams = ORM::factory('feedstream')->where('user_id', ' IN', array($user->id, 0))->and_where('role_id', ' IN ', array($role->id, 0))->and_where('course_id', ' IN ', $courses)->and_where('batch_id', ' IN ', $batches)->find_all();
return $streams;
}
示例5: action_index
/**
* Default action in default controller
*/
public function action_index()
{
// get acl
$acl = Acl::instance();
// get first allowed module
// get modules
$modules = Settings::factory('modules')->as_array();
$modules = array_keys($modules);
$module = State::instance()->get('active.module');
if ($module !== FALSE && $module !== 'Default') {
if ($acl->allowed($module, 'access', FALSE, $this->_website) === TRUE) {
$url = URL::to($module, array('website' => $this->_website));
$this->redirect($url);
exit;
}
}
// find the first allowed module & redirect
foreach ($modules as $module) {
if ($acl->allowed($module, 'access', FALSE, $this->_website) === TRUE) {
$url = URL::to($module, array('website' => $this->_website));
$this->redirect($url);
exit;
}
}
}
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:28,代码来源:Default.php
示例6: action_index
public function action_index()
{
// get acl
$acl = Acl::instance();
// get modules
$modules = Settings::factory('modules')->as_array();
// get navigation
$settings = Settings::factory('navigation', array('settings' . DIRECTORY_SEPARATOR . Website::instance()->id() . DIRECTORY_SEPARATOR, 'settings'));
$navigation = $settings->get('menu');
// filter out allowed modules
$allowedModules = array();
foreach ($modules as $module => $data) {
if ($acl->allowed($module, 'access')) {
$allowedModules[$module] = $data;
}
}
// fill up sections
$sections = array();
foreach ($navigation as $section => $modules) {
foreach ($modules as $module) {
if (isset($allowedModules[$module])) {
// section has a allowed module, so include it
if (!isset($sections[$section])) {
$sections[$section] = array();
}
// add module to section
$sections[$section][$module] = $allowedModules[$module];
}
}
}
$view = View::factory('start', array('sections' => $sections));
$this->response->body($view->render());
}
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:33,代码来源:Start.php
示例7: action_details
public function action_details()
{
$relevant_user = Acl::instance()->relevant_user();
// check if admin in which _case_ a user_id in the get param is required
if (!$relevant_user) {
$user_id = $this->request->param('user_id');
$relevant_user = ORM::factory('user', $user_id);
}
if (!$relevant_user) {
echo 'Not allowed';
exit;
}
$user_id = $relevant_user->id;
$examgroup_id = $this->request->param('examgroup_id');
$marksheet = ORM::factory('exam');
$marksheet->select('marks')->join('examresults', 'left')->on('examresults.exam_id', '=', 'id');
$marksheet->and_where_open()->where('examresults.user_id', '=', $user_id)->or_where('examresults.user_id', 'IS', NULL)->and_where_close()->and_where_open()->and_where('exams.examgroup_id', '=', $examgroup_id)->and_where_close();
$marksheet = $marksheet->find_all();
$flg = 0;
foreach ($marksheet as $mark) {
if ($mark->marks != NULL) {
$flg++;
}
//echo "<br>";
}
$view = View::factory('examresult/exammarksheet')->bind('marksheets', $marksheet)->bind('flg', $flg)->bind('relevant_user', $relevant_user);
$this->content = $view;
}
示例8: acl
/**
* acl single point of entry.
*
* @static
* @access public
* @return Acl
*/
public static function acl()
{
if (empty(self::$instance)) {
self::$instance = new Acl();
}
return self::$instance;
}
示例9: create
/**
* upload files
*/
protected function create($model, $form)
{
// check rights
if (!Acl::instance()->allowed($this->_controller, 'create')) {
throw HTTP_Exception::factory(403, 'Create not allowed on :controller', array(':controller' => $this->_controller));
}
$hash = FALSE;
Event::raise($this, Event::BEFORE_CREATE_FORM_PARSE, array('model' => NULL, 'form' => $form));
if ($form->valid()) {
$hash = Upload::process('file', $this->_settings->get('path_temp'), $this->_settings->get('extensions'), $this->_settings->get('unzip'));
}
if ($hash !== FALSE) {
return $hash;
} else {
if ($form->submitted()) {
// set error in form
$form->element('file', 0)->error('not_empty');
}
// create viewer
$viewer = Viewer::factory('Form', $form)->text(Text::instance());
// render form
$view = View::factory($this->_settings->get('view.create'), array('viewer' => $viewer));
// event
Event::raise($this, Event::BEFORE_CREATE_RENDER, array('model' => NULL, 'form' => $form, 'viewer' => $viewer, 'view' => $view));
// render
$this->response->body($view->render());
return FALSE;
}
}
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:32,代码来源:File.php
示例10: __construct
/**
* constructor, acl check
*
* @author Andy Bennett
*/
function __construct()
{
parent::__construct();
parent::init();
Acl::instance()->redirect(steamauth_helper::get_role(), 'admin');
Display::instance()->set_template('template-admin');
}
示例11: __construct
/**
* constructor; set display template
*
* @author Andy Bennett
*/
function __construct()
{
Acl::instance()->redirect(Steamauth::instance()->get_role(), 'edit', null, '../');
parent::__construct();
parent::init();
$tpl = request::is_ajax() || isset($_GET['ajax']) ? 'template-ajax' : 'template-admin';
Display::instance()->set_template($tpl);
}
示例12: __construct
/**
* constructor, check acl
*
* @author Andy Bennett
*/
function __construct()
{
parent::__construct();
parent::init();
Acl::instance()->redirect(steamauth_helper::get_role(), 'admin');
Display::instance()->append_data('page_id', 'containers-admin');
Display::instance()->set_template('template-admin');
}
示例13: __construct
/**
* constructor; check ACL
*
* @author Dan Chadwick
*/
function __construct()
{
if (!User::instance()->id) {
url::redirect('/auth/login');
}
Acl::instance()->redirect(User::instance()->get_role(), 'admin', null, '/auth/login');
parent::__construct();
}
示例14: editLink
public function editLink()
{
if (Acl::instance()->is_allowed('document_edit')) {
return '[<a href="#" onclick="KODELEARN.modules.get(\'document\').edit(' . $this->id . ')"> Edit </a>]';
//send link if permission is there
}
return '';
}
示例15: filter_add_link
/**
* In the add link filter we check if the role of the current user
* can access this url
* @param String url
* @param String title
* @return Boolean
*/
protected function filter_add_link($args)
{
$url = $args[0];
$controller = explode("/", $url);
if ($url === 'auth/logout') {
return True;
}
return Acl::instance()->has_access($controller[0]);
}