当前位置: 首页>>代码示例>>PHP>>正文


PHP Acl类代码示例

本文整理汇总了PHP中Acl的典型用法代码示例。如果您正苦于以下问题:PHP Acl类的具体用法?PHP Acl怎么用?PHP Acl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Acl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveAcls

 protected function saveAcls($acls, $role)
 {
     foreach ($acls as $acl) {
         $acl = explode("/", $acl);
         $dbAcl = new Acl();
         $dbAcl->setIdRole($role);
         $dbAcl->setController($acl[0]);
         $dbAcl->setAction($acl[1]);
         $dbAcl->save();
     }
 }
开发者ID:aleboisselier,项目名称:Increase,代码行数:11,代码来源:RolesController.php

示例2: addSongbookPrivileges

 /**
  * Sets up permissions for the module
  *
  * @param \Acl $acl
  */
 public static function addSongbookPrivileges($acl)
 {
     $acl->addRole('songbook - vstup');
     $acl->addRole('songbook - vytváření/editace', 'songbook - vstup');
     $acl->addRole('songbook - mazání', 'songbook - vytváření/editace');
     $acl->addResource("Oddil:Songbook");
     $acl->allow("base - člen", "Oddil:Songbook", "display");
     $acl->allow("songbook - vstup", "Oddil:Songbook", "default");
     $acl->allow("songbook - vytváření/editace", "Oddil:Songbook", ["add", "edit"]);
     $acl->allow("songbook - mazání", "Oddil:Songbook", "delete");
 }
开发者ID:patrickkusebauch,项目名称:27skauti,代码行数:16,代码来源:OddilModule.php

示例3: 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');
     }
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:13,代码来源:acl_listeners.php

示例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;
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:25,代码来源:feedstream.php

示例5: auth

 private function auth($user, $pass)
 {
     $error = '';
     $t = Variable::get('host_ban_time');
     if ($t > 0) {
         $fails = DB::GetOne('SELECT count(*) FROM user_login_ban WHERE failed_on>%d AND from_addr=%s', array(time() - $t, $_SERVER['REMOTE_ADDR']));
         if ($fails >= 3) {
             $error = 'Host banned.';
         }
     }
     if ($error === '') {
         $ret = Base_User_LoginCommon::check_login($user, $pass);
         if (!$ret) {
             $error = 'Login failed.';
             if ($t > 0) {
                 DB::Execute('DELETE FROM user_login_ban WHERE failed_on<=%d', array(time() - $t));
                 DB::Execute('INSERT INTO user_login_ban(failed_on,from_addr) VALUES(%d,%s)', array(time(), $_SERVER['REMOTE_ADDR']));
                 $fails = DB::GetOne('SELECT count(*) FROM user_login_ban WHERE failed_on>%d AND from_addr=%s', array(time() - $t, $_SERVER['REMOTE_ADDR']));
                 if ($fails >= 3) {
                     $error .= ' Host banned.';
                 }
             }
         } else {
             $uid = Base_UserCommon::get_user_id($user);
             Acl::set_user($uid, true);
         }
     }
     return $error;
 }
开发者ID:cretzu89,项目名称:EPESI,代码行数:29,代码来源:soap.php

示例6: menu

 public static function menu()
 {
     if (!Acl::is_user() || !Base_AclCommon::check_permission('Fax - Browse')) {
         return array();
     }
     return array(_M('CRM') => array('__submenu__' => 1, _M('Fax') => array()));
 }
开发者ID:cretzu89,项目名称:EPESI,代码行数:7,代码来源:FaxCommon_0.php

示例7: canAccessPage

 public function canAccessPage($id, $action)
 {
     $acl = Acl::getResourceData(Acl::RESOURCE_GROUP_PAGES, $id);
     if ($acl !== false) {
         return Acl::canAccess(Acl::RESOURCE_GROUP_PAGES, $id, $action);
     } else {
         $finished = false;
         $ret = false;
         $next_id = $id;
         $safety_counter = 0;
         do {
             if ($next_id == Pages::ROOT_ID) {
                 $ret = Acl::canAccess(Acl::RESOURCE_GROUP_PAGES, Pages::ROOT_ID, $action);
                 $finished = true;
             } else {
                 $res = $this->pages->getProperties($next_id);
                 if ($res !== false) {
                     $acl = Acl::getResourceData(Acl::RESOURCE_GROUP_PAGES, $next_id);
                     if ($acl !== false) {
                         $ret = Acl::canAccess(Acl::RESOURCE_GROUP_PAGES, $next_id, $action);
                         $finished = true;
                     }
                     $next_id = $res['parent-id'];
                 } else {
                     $finished = true;
                 }
             }
             $safety_counter++;
         } while (!$finished && $safety_counter < 50);
         return $ret;
     }
 }
开发者ID:pixelproduction,项目名称:PixelManagerCMS,代码行数:32,代码来源:ControllerHelpers.php

示例8: 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

示例9: modules

	public static function modules()
	{
		$session = UserSession::get();
		if ($session)
		{
			$user = $session->user();
			if (!Acl::isAllowed($user->username, 'admin'))
			{
				return null;
			}
		}
		else
		{
			return null;
		}	
		
		CoOrg::loadPluginInfo('admin');
		$modules = array();
		foreach (self::$_modules as $m)
		{
			if ($m->isAllowed($user))
			{
				$modules[] = $m;
			}
		}
		usort($modules, array('Admin', 'cmpModule'));
		return $modules;
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:28,代码来源:admin.model.php

示例10: instance

 /**
  * @return Acl
  */
 public static function instance()
 {
     if (self::$_instance === null) {
         self::$_instance = new Acl();
     }
     return self::$_instance;
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:10,代码来源:acl.php

示例11: get_options

 public static function get_options()
 {
     static $user;
     if (isset(self::$options) && $user == Acl::get_user()) {
         return self::$options;
     }
     $user = Acl::get_user();
     self::$options = array();
     $modules_menu = array();
     $menus = Base_MenuCommon::get_menus();
     //ksort($menus);
     foreach ($menus as $name => $ret) {
         if ($name == 'Base_Admin') {
             continue;
         }
         if ($name == Base_Menu_QuickAccessCommon::module_name()) {
             continue;
         }
         Base_MenuCommon::add_default_menu($ret, $name);
         $modules_menu = array_merge($modules_menu, self::check_for_links('', $ret, $name));
     }
     usort($modules_menu, function ($a, $b) {
         return strcmp($a['label'], $b['label']);
     });
     self::$options =& $modules_menu;
     return self::$options;
 }
开发者ID:cretzu89,项目名称:EPESI,代码行数:27,代码来源:QuickAccessCommon_0.php

示例12: CT_Start_Default

function CT_Start_Default($target)
{
    requireModel("blog.attachment");
    requireComponent("Eolin.PHP.Core");
    requireComponent("Textcube.Function.misc");
    global $blogid, $blogURL, $database, $service;
    $target .= '<ul>';
    $target .= '<li><a href="' . $blogURL . '/owner/entry/post">' . _t('새 글을 씁니다') . '</a></li>' . CRLF;
    $latestEntryId = Setting::getBlogSettingGlobal('LatestEditedEntry_user' . getUserId(), 0);
    if ($latestEntryId !== 0) {
        $latestEntry = CT_Start_Default_getEntry($blogid, $latestEntryId);
        if ($latestEntry != false) {
            $target .= '<li><a href="' . $blogURL . '/owner/entry/edit/' . $latestEntry['id'] . '">' . _f('최근글(%1) 수정', htmlspecialchars(Utils_Unicode::lessenAsEm($latestEntry['title'], 10))) . '</a></li>';
        }
    }
    if (Acl::check('group.administrators')) {
        $target .= '<li><a href="' . $blogURL . '/owner/skin">' . _t('스킨을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/skin/sidebar">' . _t('사이드바 구성을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/skin/setting">' . _t('블로그에 표시되는 값들을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/entry/category">' . _t('카테고리를 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/plugin">' . _t('플러그인을 켜거나 끕니다') . '</a></li>' . CRLF;
    }
    if ($service['reader'] != false) {
        $target .= '<li><a href="' . $blogURL . '/owner/network/reader">' . _t('RSS 리더를 봅니다') . '</a></li>' . CRLF;
    }
    $target .= '</ul>';
    return $target;
}
开发者ID:ragi79,项目名称:Textcube,代码行数:28,代码来源:index.php

示例13: addOpenID

function addOpenID()
{
    global $openid_list;
    $context = Model_Context::getInstance();
    if (empty($_GET['openid_identifier']) || strstr($_GET['openid_identifier'], ".") === false) {
        exitWithError(_t('오픈아이디를 입력하지 않았거나, 도메인 없는 오픈아이디를 입력하였습니다.'));
    }
    $currentOpenID = Acl::getIdentity('openid_temp');
    $fc = new OpenIDConsumer();
    $claimedOpenID = $fc->fetch($_GET['openid_identifier']);
    if (in_array($claimedOpenID, $openid_list)) {
        exitWithError(_t('이미 연결된 오픈아이디 입니다') . " : " . $claimedOpenID);
    }
    if ($_GET['authenticated'] === "0") {
        header("Location: " . $context->getProperty('uri.blog') . "/owner/setting/account");
        exit(0);
    }
    if (empty($currentOpenID) || $claimedOpenID != $currentOpenID) {
        loginOpenIDforAdding($claimedOpenID);
        return;
    }
    if (!in_array($currentOpenID, $openid_list)) {
        for ($i = 0; $i < OPENID_REGISTERS; $i++) {
            $openid = Setting::getUserSetting("openid." . $i, null, true);
            if (empty($openid)) {
                Setting::setUserSetting("openid." . $i, $currentOpenID, true);
                break;
            }
        }
    }
    echo "<html><head><script type=\"text/javascript\">//<![CDATA[" . CRLF . "alert('" . _t('연결하였습니다.') . " : " . $currentOpenID . "'); document.location.href='" . $context->getProperty('uri.blog') . "/owner/setting/account'; //]]></script></head></html>";
}
开发者ID:Avantians,项目名称:Textcube,代码行数:32,代码来源:index.php

示例14: add_tracing_notes

 public static function add_tracing_notes($dest_rset, $dest_id, $dest_label, $linkto_rset, $linkto_id, $linkto_label)
 {
     $after = __('Follow-up after') . ': ';
     $follow = __('Follow-up') . ': ';
     switch ($dest_rset) {
         case 'phonecall':
             $fwd_note_path = 'phonecall/' . $dest_id;
             $bck_note = $after . '[phone=' . $dest_id . ']' . $dest_label . '[/phone]';
             break;
         case 'meeting':
             $fwd_note_path = 'crm_meeting/' . $dest_id;
             $bck_note = $after . '[meeting=' . $dest_id . ']' . $dest_label . '[/meeting]';
             break;
         case 'task':
             $fwd_note_path = 'task/' . $dest_id;
             $bck_note = $after . '[task=' . $dest_id . ']' . $dest_label . '[/task]';
             break;
     }
     switch ($linkto_rset) {
         case 'phonecall':
             $bck_note_path = 'phonecall/' . $linkto_id;
             $fwd_note = $follow . '[phone=' . $linkto_id . ']' . $linkto_label . '[/phone]';
             break;
         case 'meeting':
             $bck_note_path = 'crm_meeting/' . $linkto_id;
             $fwd_note = $follow . '[meeting=' . $linkto_id . ']' . $linkto_label . '[/meeting]';
             break;
         case 'task':
             $bck_note_path = 'task/' . $linkto_id;
             $fwd_note = $follow . '[task=' . $linkto_id . ']' . $linkto_label . '[/task]';
             break;
     }
     Utils_AttachmentCommon::add($fwd_note_path, 0, Acl::get_user(), $fwd_note);
     Utils_AttachmentCommon::add($bck_note_path, 0, Acl::get_user(), $bck_note);
 }
开发者ID:cretzu89,项目名称:EPESI,代码行数:35,代码来源:FollowupCommon_0.php

示例15: 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


注:本文中的Acl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。