コード例 #1
0
ファイル: permission.php プロジェクト: MenZil-Team/cms
 public function action_user()
 {
     $id = (int) $this->request->param('id', 0);
     $post = ORM::factory('user', $id);
     if (!$post->loaded() or $id === 1) {
         Message::error(__("User doesn't exists!"));
         Log::error('Attempt to access non-existent user.');
         $this->request->redirect(Route::get('admin/user')->uri(array('action' => 'list')), 404);
     }
     $this->title = __(':user Permissions', array(":user" => $post->name));
     $action = Route::get('admin/permission')->uri(array('action' => 'user', 'id' => isset($post->id) ? $post->id : 0));
     $view = View::factory('admin/permission/user')->set('post', $post)->set('oldperms', $post->perms())->set('permissions', ACL::all())->set('action', $action)->bind('errors', $this->_errors);
     if ($this->valid_post('permissions')) {
         $perms = array_filter($_POST['perms']);
         $post->data = array('permissions' => $perms);
         try {
             $post->save();
             Message::success(__('Permissions: saved successful!'));
             $this->request->redirect(Route::get('admin/permission')->uri(array('action' => 'user', 'id' => $post->id)));
         } catch (ORM_Validation_Exception $e) {
             Message::error(__('Permissions save failed!'));
             $this->_errors = $e->errors('models', TRUE);
         } catch (Exception $e) {
             Message::error(__('Permissions save failed!'));
             $this->_errors = array($e->getMessage());
         }
     }
     $this->response->body($view);
 }
コード例 #2
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());
 }
コード例 #3
0
 /**
  * (non-PHPdoc)
  * @see Page::permissions()
  */
 public function permissions()
 {
     $this->addPermissao(ACL::all());
     //Everybody
 }
コード例 #4
0
 public function permissions()
 {
     $this->allow(ACL::all());
 }