本文整理汇总了PHP中ACL::check方法的典型用法代码示例。如果您正苦于以下问题:PHP ACL::check方法的具体用法?PHP ACL::check怎么用?PHP ACL::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACL
的用法示例。
在下文中一共展示了ACL::check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_page
/**
* Add page to section.
*
* @param Navigation_Abstract $page
* @param int $priority
* @return $this
*/
public function add_page(Navigation_Abstract &$page, $priority = 1)
{
$priority = (int) $priority;
// Check permissions
if (!ACL::check($page->permissions)) {
return $this;
}
// Priority
if (isset($page->priority)) {
$priority = (int) $page->priority;
}
// Typeof
if ($page instanceof Navigation_Section) {
$this->_sections[] = $page;
$page->set_section($this);
} else {
// Change priority
if (isset($this->_pages[$priority])) {
while (isset($this->_pages[$priority])) {
$priority++;
}
}
// Store page
$this->_pages[$priority] = $page;
}
// Add page buttons
if (isset($page->buttons)) {
$page->add_buttons($page->buttons);
}
//
$page->set_section($this);
return $this->update()->sort();
}
示例2: action_view
/**
* List of pages (blogs/posts/etc.) with a specific tag
*
* @throws HTTP_Exception_404
*
* @uses Log::add
* @uses Text::ucfirst
* @uses ACL::check
* @uses Meta::links
* @uses URL::canonical
* @uses Route::url
*/
public function action_view()
{
$id = (int) $this->request->param('id', 0);
$tag = ORM::factory('tag', $id);
if (!$tag->loaded()) {
throw HTTP_Exception::factory(404, 'Tag :tag not found!', array(':tag' => $id));
}
$this->title = __(':title', array(':title' => Text::ucfirst($tag->name)));
$view = View::factory('tag/view')->set('teaser', TRUE)->bind('pagination', $pagination)->bind('posts', $posts);
$posts = $tag->posts;
if (!ACL::check('administer tags') and !ACL::check('administer content')) {
$posts->where('status', '=', 'publish');
}
$total = $posts->reset(FALSE)->count_all();
if ($total == 0) {
Log::info('No posts found.');
$this->response->body(View::factory('page/none'));
return;
}
$pagination = Pagination::factory(array('current_page' => array('source' => 'cms', 'key' => 'page'), 'total_items' => $total, 'items_per_page' => 15, 'uri' => $tag->url));
$posts = $posts->order_by('created', 'DESC')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
$this->response->body($view);
// Set the canonical and shortlink for search engines
if ($this->auto_render === TRUE) {
Meta::links(URL::canonical($tag->url, $pagination), array('rel' => 'canonical'));
Meta::links(Route::url('tag', array('action' => 'view', 'id' => $tag->id)), array('rel' => 'shortlink'));
}
}
示例3: testacl_check
/**
* @dataProvider providerPerms
*/
public function testacl_check($perm, $user_id)
{
$user = ORM::factory('user', $user_id);
if ($user_id == 1) {
$this->assertFalse(ACL::check($perm, $user));
} else {
$this->assertTrue(ACL::check($perm, $user));
}
}
示例4: before
public function before()
{
parent::before();
if ($this->auth_required === TRUE and !Auth::is_logged_in() and !in_array($this->request->action(), $this->public_actions)) {
$this->_deny_access();
}
if ($this->auth_required === TRUE and !in_array($this->request->action(), $this->allowed_actions) and !ACL::check($this->request)) {
$this->_deny_access();
}
}
示例5: rest_delete
public function rest_delete()
{
if (!ACL::check('dshboard.empty')) {
throw HTTP_API_Exception::factory(API::ERROR_PERMISSIONS, 'You don\'t have permission to :permission', array(':permission' => __('Empty dashboard')));
}
Dashboard::remove_data();
Cache::register_shutdown_function();
Kohana::$log->add(Log::INFO, ':user empty dashboard')->write();
$this->message('Dashboard is empty!');
}
示例6: get_clear
public function get_clear()
{
if (!ACL::check('system.session.clear')) {
throw HTTP_API_Exception::factory(API::ERROR_PERMISSIONS, 'You don\'t have permission to :permission', array(':permission' => __('Сlear user sessions')));
}
if (Session::$default == 'database') {
DB::delete('sessions')->execute();
Kohana::$log->add(Log::INFO, ':user clear user sessions')->write();
$this->message('User sessions has been cleared!');
}
}
示例7: rest_delete
public function rest_delete()
{
if (!ACL::check('system.cache.clear')) {
throw HTTP_API_Exception::factory(API::ERROR_PERMISSIONS, 'You don\'t have permission to :permission', array(':permission' => __('Сlear cache')));
}
if (Kohana::$caching === TRUE) {
Cache::register_shutdown_function();
}
Kohana::$log->add(Log::INFO, ':user clear cache')->write();
$this->message('Cache has been cleared!');
}
示例8: before
/**
* Before the controller execute an action, check security access.
* @throws HTTP_Exception
*/
public function before()
{
parent::before();
// Check public actions
if ($this->auth_required === true && !Auth::is_logged_in() && !in_array($this->request->action(), $this->public_actions)) {
$this->_deny_access();
}
// Check allowed actions
if ($this->auth_required === true && !in_array($this->request->action(), $this->allowed_actions) && !ACL::check($this->request)) {
$this->_deny_access();
}
}
示例9: rest_put
public function rest_put()
{
if (!ACL::check('plugins.change_status')) {
throw HTTP_API_Exception::factory(API::ERROR_PERMISSIONS, 'You don\'t have permission to :permission', array(':permission' => __('Install or uninstall plugin')));
}
Plugins::find_all();
$plugin = Plugins::get_registered($this->param('id', NULL, TRUE));
if (!$plugin->is_activated() and (bool) $this->param('installed') === TRUE) {
$plugin->activate();
} else {
$plugin->deactivate((bool) $this->param('remove_data'));
}
Kohana::$log->add(Log::INFO, ':user :action plugin :name', array(':action' => $plugin->is_activated() ? 'activate' : 'deactivate', ':name' => $plugin->title()))->write();
$this->response($this->_get_info($plugin));
}
示例10: post_refresh
public function post_refresh()
{
if (!ACL::check('system.api.refresh_key')) {
throw HTTP_API_Exception::factory(API::ERROR_PERMISSIONS, 'You don\'t have permission to :permission', array(':permission' => __('Refresh API key')));
}
$key_exists = Config::get('api', 'key') !== NULL;
$key = $this->param('key', NULL, $key_exists);
if ($key_exists === TRUE) {
$key = ORM::factory('api_key')->refresh($key);
} else {
$key = ORM::factory('api_key')->generate('KodiCMS API key');
}
Config::set('api', 'key', $key);
$this->response($key);
}
示例11: before
public function before()
{
if ($this->request->action() != 'create') {
$ds_id = (int) $this->request->param('id');
$this->section($ds_id);
if ($this->section()->has_access_edit()) {
$this->allowed_actions[] = 'edit';
}
if ($this->section()->has_access_remove()) {
$this->allowed_actions[] = 'remove';
}
} else {
$type = strtolower($this->request->param('id'));
if (ACL::check($type . '.section.create')) {
$this->allowed_actions[] = 'create';
}
}
parent::before();
}
示例12: action_edit
public function action_edit()
{
$layout_name = $this->request->param('id');
$layout = new Model_File_Layout($layout_name);
if (!$layout->is_exists()) {
if (($found_file = $layout->find_file()) !== FALSE) {
$layout = new Model_File_Layout($found_file);
} else {
Messages::errors(__('Layout not found!'));
$this->go();
}
}
$this->set_title($layout_name);
// check if trying to save
if (Request::current()->method() == Request::POST and ACL::check('layout.edit')) {
return $this->_edit($layout);
}
Assets::package('ace');
$this->template->content = View::factory('layout/edit', array('action' => 'edit', 'layout' => $layout));
}
示例13: get_database
public function get_database()
{
if (!ACL::check('update.database_apply')) {
throw HTTP_API_Exception::factory(API::ERROR_PERMISSIONS, 'You don\'t have permission to :permission', array(':permission' => __('Update database')));
}
$db_sql = Database_Helper::schema();
$file_sql = Database_Helper::install_schema();
$compare = new Database_Helper();
$diff = $compare->get_updates($db_sql, $file_sql, TRUE);
try {
Database_Helper::insert_sql($diff);
$this->message('Database schema updated successfully!');
Cache::instance()->delete(Update::CACHE_KEY_DB_SHEMA);
$this->response(TRUE);
} catch (Exception $ex) {
$this->message('Something went wrong!');
$this->response(FALSE);
}
Kohana::$log->add(Log::INFO, ':user update database')->write();
}
示例14: action_edit
public function action_edit()
{
$snippet_name = $this->request->param('id');
$snippet = new Model_File_Snippet($snippet_name);
if (!$snippet->is_exists()) {
if (($found_file = $snippet->find_file()) !== FALSE) {
$snippet = new Model_File_Snippet($found_file);
} else {
Messages::errors(__('Snippet not found!'));
$this->go();
}
}
$this->template->title = __('Edit snippet');
$this->breadcrumbs->add($snippet_name);
// check if trying to save
if (Request::current()->method() == Request::POST and ACL::check('snippet.edit')) {
return $this->_edit($snippet_name);
}
Assets::package('ace');
$this->template->content = View::factory('snippet/edit', array('action' => 'edit', 'filters' => WYSIWYG::findAll(), 'snippet' => $snippet));
}
示例15: add_page
/**
*
* @param Model_Navigation_Page $page
* @param integer $priority
* @return \Model_Navigation_Section
*/
public function add_page(Model_Navigation_Abstract &$page, $priority = 1)
{
$priority = (int) $priority;
if (!ACL::check($page->permissions)) {
return $this;
}
if (isset($page->priority)) {
$priority = (int) $page->priority;
}
if ($page instanceof Model_Navigation_Section) {
$this->_sections[] = $page;
$page->set_section($this);
} else {
if (isset($this->_pages[$priority])) {
while (isset($this->_pages[$priority])) {
$priority++;
}
}
$this->_pages[$priority] = $page;
}
$page->set_section($this);
return $this->update()->sort();
}