/** * If Route::cache() was able to restore routes from the cache then * it should return TRUE and load the cached routes * * @test * @covers Route::cache */ public function test_cache_stores_route_objects() { $acls = ACL::all(); // First we create the cache ACL::cache(TRUE); // Now lets modify the "current" routes ACL::set('contact', array('sending mail' => array('title' => __('Sending Mails'), 'restrict access' => FALSE, 'description' => __('Ability to send messages for administrators from your site')))); // Then try and load said cache $this->assertTrue(ACL::cache()); // Check the route cache flag $this->assertTrue(ACL::$cache); // And if all went ok the nonsensical route should be gone... $this->assertEquals($acls, ACL::all()); }
/** * Define Module specific Permissions * * Definition of user privileges by default if the ACL is present in the system. * Note: Parameter `restrict access` indicates that these privileges have serious * implications for safety. * * @uses ACL::cache * @uses ACL::set */ if (!ACL::cache()) { ACL::set('comment', array('administer comment' => array('title' => __('Administer Comments'), 'restrict access' => TRUE, 'description' => __('Administer comments and comments settings')), 'access comment' => array('title' => __('Access comments'), 'restrict access' => FALSE, 'description' => __('Access to any published comments')), 'post comment' => array('title' => __('Post comments'), 'restrict access' => FALSE, 'description' => __('Ability to publish comments')), 'skip comment approval' => array('title' => __('Skip comment approval'), 'restrict access' => FALSE, 'description' => __('Ability to publish comments without approval by the moderator')), 'edit own comment' => array('title' => __('Edit own comments'), 'restrict access' => FALSE, 'description' => __('Ability to editing own comments')))); ACL::set('content', array('administer content' => array('title' => __('Administer content'), 'restrict access' => TRUE, 'description' => __('Most of the tasks associated with the administration of the contents of this website associated with this permission')), 'access content' => array('title' => __('Access content'), 'restrict access' => FALSE, 'description' => __('')), 'view own unpublished content' => array('title' => __('View own unpublished content'), 'restrict access' => FALSE, 'description' => __('')), 'administer page' => array('title' => __('Administer pages'), 'restrict access' => TRUE, 'description' => __('')), 'create page' => array('title' => __('Create pages'), 'restrict access' => FALSE, 'description' => __('The ability to create pages')), 'edit own page' => array('title' => __('Edit own pages'), 'restrict access' => FALSE, 'description' => __('')), 'edit any page' => array('title' => __('Edit any pages'), 'restrict access' => FALSE, 'description' => __('')), 'delete own page' => array('title' => __('Delete own pages'), 'restrict access' => FALSE, 'description' => __('')), 'delete any page' => array('title' => __('Delete any pages'), 'restrict access' => FALSE, 'description' => __('')))); ACL::set('site', array('administer menu' => array('title' => __('Administer Menus'), 'restrict access' => TRUE, 'description' => __('')), 'administer paths' => array('title' => __('Administer Paths'), 'restrict access' => FALSE, 'description' => __('')), 'administer site' => array('title' => __('Administer Site'), 'restrict access' => TRUE, 'description' => __('')), 'administer tags' => array('title' => __('Administer Tags'), 'restrict access' => FALSE, 'description' => __('')), 'administer terms' => array('title' => __('Administer Terms'), 'restrict access' => FALSE, 'description' => __('')), 'administer formats' => array('title' => __('Administer Formats'), 'restrict access' => TRUE, 'description' => __('Managing the text formats of editor')))); ACL::set('contact', array('sending mail' => array('title' => __('Sending Mails'), 'restrict access' => FALSE, 'description' => __('Ability to send messages for administrators from your site')))); ACL::set('blog', array('administer blog' => array('title' => __('Administer Blog'), 'restrict access' => TRUE, 'description' => __('Administer Blog and Blog settings')), 'create blog' => array('title' => __('Create Blog post'), 'restrict access' => FALSE, 'description' => ''), 'edit own blog' => array('title' => __('Edit own Blog post'), 'restrict access' => FALSE, 'description' => ''), 'edit any blog' => array('title' => __('Edit any Blog posts'), 'restrict access' => FALSE, 'description' => ''), 'delete own blog' => array('title' => __('Delete own Blog post'), 'restrict access' => FALSE, 'description' => ''), 'delete any blog' => array('title' => __('Delete any Blog posts'), 'restrict access' => FALSE, 'description' => ''))); /** Cache the module specific permissions in production */ ACL::cache(Kohana::$environment === Kohana::PRODUCTION); } /** * Load the filter cache * * @uses Filter::cache * @uses Filter::set * @uses Text::html * @uses Text::htmlcorrector * @uses Text::autop * @uses Text::plain * @uses Text::autolink * @uses Text::initialcaps * @uses Text::markdown
* @package Gleez\User\Routing * @author Gleez Team * @copyright (c) 2011-2014 Gleez Technologies * @license http://gleezcms.org/license Gleez CMS License */ if (!Route::cache()) { //User Backend routes Route::set('admin/permission', 'admin/permissions(/<action>)(/<id>)', array('id' => '\\d+', 'action' => 'list|role|user'))->defaults(array('directory' => 'admin', 'controller' => 'permission', 'action' => 'list')); Route::set('admin/role', 'admin/roles(/<action>(/<id>))(/p<page>)', array('id' => '\\d+', 'page' => '\\d+', 'action' => 'list|add|edit|delete'))->defaults(array('directory' => 'admin', 'controller' => 'role', 'action' => 'list')); Route::set('admin/user', 'admin/users(/<action>(/<id>))(/p<page>)', array('id' => '\\d+', 'page' => '\\d+', 'action' => 'list|add|edit|delete'))->defaults(array('directory' => 'admin', 'controller' => 'user', 'action' => 'list')); //User Frontend routes Route::set('user', 'user(/<action>)(/<id>)(/<token>)', array('action' => 'edit|login|logout|view|register|confirm|password|profile|photo', 'id' => '\\d+'))->defaults(array('controller' => 'user', 'action' => 'view', 'token' => NULL)); Route::set('user/oauth', 'oauth/<controller>(/<action>)')->defaults(array('directory' => 'oauth', 'action' => 'index')); Route::set('user/reset', 'user/reset(/<action>)(/<id>)(/<token>)(/<time>)', array('action' => 'password|confirm_password', 'id' => '\\d+', 'time' => '\\d+'))->defaults(array('controller' => 'user', 'action' => 'confirm_password', 'token' => NULL, 'time' => NULL)); Route::set('user/buddy', 'buddy(/<action>)(/<id>)(/p<page>)', array('action' => 'index|add|accept|reject|delete|sent|pending', 'id' => '\\d+', 'page' => '\\d+'))->defaults(array('controller' => 'buddy', 'action' => 'index')); Route::set('user/message', 'message(/<action>)(/<id>)', array('id' => '\\d+', 'action' => 'index|inbox|outbox|drafts|list|view|edit|compose|delete|bulk'))->defaults(array('controller' => 'message', 'action' => 'index')); } /** * Define Module specific Permissions * * Definition of user privileges by default if the ACL is present in the system. * Note: Parameter `restrict access` indicates that these privileges have serious * implications for safety. * * @uses ACL Used to define the privileges */ if (!ACL::cache()) { ACL::set('user', array('administer permissions' => array('title' => __('Administer permissions'), 'restrict access' => TRUE, 'description' => __('Managing user authority')), 'administer users' => array('title' => __('Administer users'), 'restrict access' => TRUE, 'description' => __('Users management')), 'access profiles' => array('title' => __('Access profiles'), 'restrict access' => FALSE, 'description' => __('Access to all profiles')), 'edit profile' => array('title' => __('Editing profile'), 'restrict access' => FALSE, 'description' => __('The ability to change profile')), 'change own username' => array('title' => __('Change own username'), 'restrict access' => TRUE, 'description' => __('The ability to change own username')))); /** Cache the module specific permissions in production */ ACL::cache(FALSE, Kohana::$environment === Kohana::PRODUCTION); }
/** * Изменение прав на разделы. * @route POST//api/taxonomy/access.rpc */ public static function on_post_access(Context $ctx) { $ctx->user->checkAccess(ACL::UPDATE, 'tag'); if ($sections = (array) $ctx->post('sections')) { $publishers = $ctx->post('publishers'); $owners = $ctx->post('owners'); $ctx->db->beginTransaction(); ACL::resetNode($sections); foreach ($sections as $nid) { if ($publishers == $owners) { ACL::set($nid, $owners, ACL::CREATE | ACL::READ | ACL::UPDATE | ACL::DELETE | ACL::PUBLISH); } else { ACL::set($nid, $publishers, ACL::PUBLISH); ACL::set($nid, $owners, ACL::CREATE | ACL::READ | ACL::UPDATE | ACL::DELETE); } } $ctx->db->commit(); } return $ctx->getRedirect('admin/access/taxonomy'); }
/** * Изменение прав. * @route POST//admin/structure/access */ public static function on_post_access(Context $ctx) { if (!Node::create('type')->checkPermission(ACL::UPDATE)) { throw new ForbiddenException(); } // Если объект не существует, выбросится 404. $node = Node::load(array('class' => 'type', 'name' => $ctx->get('type'), 'deleted' => 0)); $ctx->db->beginTransaction(); foreach ($ctx->post as $gid => $data) { ACL::set($node->id, intval($gid), ACL::asint($data)); } $ctx->db->commit(); return $ctx->getRedirect(); }
* @package Gleez\Oauth2\Routing * @author Gleez Team * @copyright (c) 2011-2014 Gleez Technologies * @license http://gleezcms.org/license Gleez CMS License */ if (!Route::cache()) { //User Backend routes Route::set('admin/oauth2', 'admin/oauth2(/<action>(/<id>))(/p<page>)', array('id' => '\\d+', 'page' => '\\d+', 'action' => 'list|add|edit|delete'))->defaults(array('directory' => 'admin', 'controller' => 'oauth2', 'action' => 'list')); Route::set('oauth2/provider', 'oauth2/<provider>(/<action>)', array('provider' => 'gleez|google|facebook|live|github'))->defaults(array('controller' => 'provider', 'action' => 'index')); //oAuth2 Frontend routes Route::set('oauth2/auth', 'oauth2/auth')->defaults(array('controller' => 'authorize', 'action' => 'index')); Route::set('oauth2/token', 'oauth2/token')->defaults(array('controller' => 'token', 'action' => 'index')); Route::set('oauth2/revoke', 'oauth2/revoke')->defaults(array('controller' => 'revoke', 'action' => 'index')); Route::set('oauth2/test', 'oauth2/test(/<action>)')->defaults(array('controller' => 'oauthtest', 'action' => 'coderequest')); Route::set('oauth2/me', 'oauth2/me(/<action>)')->defaults(array('controller' => 'me', 'action' => 'index')); Route::set('oauth2/client', 'oauth2/client(/<action>)(/<id>)', array('id' => '\\d+', 'action' => 'list|register|edit|view|delete'))->defaults(array('controller' => 'client', 'action' => 'list')); } /** * Define Module specific Permissions * * Definition of user privileges by default if the ACL is present in the system. * Note: Parameter `restrict access` indicates that these privileges have serious * implications for safety. * * @uses ACL Used to define the privileges */ if (!ACL::cache()) { ACL::set('oauth2', array('administer oauth2' => array('title' => __('Administer oAuth2'), 'restrict access' => TRUE, 'description' => __('oAUth Management')), 'access oaclient2' => array('title' => __('Access Clients'), 'restrict access' => FALSE, 'description' => __('Access to all oAuth2 Clients')), 'edit oaclient2' => array('title' => __('Edit Client'), 'restrict access' => FALSE, 'description' => __('The ability to change oAuth2 Client')), 'edit own oaclient2' => array('title' => __('Change own Client'), 'restrict access' => TRUE, 'description' => __('The ability to change own oAuth2 Client')), 'delete oaclient2' => array('title' => __('Delete Client'), 'restrict access' => FALSE, 'description' => __('The ability to delete oAuth2 Client')), 'delete own oaclient2' => array('title' => __('Delete own Client'), 'restrict access' => TRUE, 'description' => __('The ability to delete own oAuth2 Client')))); /** Cache the module specific permissions in production */ ACL::cache(FALSE, Kohana::$environment === Kohana::PRODUCTION); }