コード例 #1
0
ファイル: AclTest.php プロジェクト: MenZil-Team/cms
 /**
  * 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());
 }
コード例 #2
0
ファイル: acl.php プロジェクト: MenZil-Team/cms
 /**
  * Setter/Getter for ACL cache
  *
  * If your perms will remain the same for a long period of time, use this
  * to reload the ACL from the cache rather than redefining them on every page load.
  *
  * Example:
  * ~~~
  *  if ( ! ACL::cache())
  *  {
  *    // Set perms here
  *    ACL::cache(TRUE);
  *  }
  * ~~~
  *
  * @param   boolean  $save    Cache the current perms [Optional]
  * @param   boolean  $append  Append, rather than replace, cached perms when loading [Optional]
  *
  * @return  boolean
  *
  * @uses    Cache::set
  * @uses    Cache::get
  * @uses    Arr::merge
  */
 public static function cache($save = FALSE, $append = FALSE)
 {
     $cache = Cache::instance();
     if ($save) {
         // set the cache for performance in production
         if (Kohana::$environment === Kohana::PRODUCTION) {
             // Cache all defined perms
             return $cache->set('ACL::cache()', self::$_all_perms);
         }
         return false;
     } else {
         if ($perms = $cache->get('ACL::cache()')) {
             if ($append) {
                 // Append cached perms
                 self::$_all_perms = Arr::merge(self::$_all_perms, $perms);
             } else {
                 // Replace existing perms
                 self::$_all_perms = $perms;
             }
             // perms were cached
             return self::$cache = TRUE;
         } else {
             // perms were not cached
             return self::$cache = FALSE;
         }
     }
 }
コード例 #3
0
ファイル: init.php プロジェクト: MenZil-Team/cms
 *
 * 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
 */
if (!Filter::cache()) {