Пример #1
1
 /**
  * Execute the controller.
  *
  * @throws \Exception
  * @return  mixed Return executed result.
  */
 public function execute()
 {
     $id = $this->input->get('id');
     $authorMapper = new DataMapper('authors');
     $return = $this->input->getBase64('return');
     $return = $return ? base64_decode($return) : Router::buildHttp('admin:authors');
     try {
         if (!$id) {
             throw new \Exception('Delete fail');
         }
         $author = $authorMapper->findOne($id);
         $blog = Blog::get();
         $user = User::get();
         if ($author->owner) {
             throw new ValidFailException('You cannot delete owner.');
         }
         if ($user->id != $author->user && $blog->id != $author->blog) {
             throw new ValidFailException('You cannot delete authors of other blog.');
         }
         $authorMapper->delete(['id' => $id]);
     } catch (ValidFailException $e) {
         $this->setRedirect($return, $e->getMessage(), 'danger');
         return false;
     } catch (\Exception $e) {
         if (WINDWALKER_DEBUG) {
             throw $e;
         }
         $this->setRedirect($return, 'Delete fail', 'danger');
         return false;
     }
     $this->setRedirect($return, 'Remove Author success', 'success');
     return true;
 }
Пример #2
0
 /**
  * Execute the controller.
  *
  * @throws \Exception
  * @return  mixed Return executed result.
  */
 public function execute()
 {
     $id = $this->input->get('id');
     $user = User::get();
     $blog = Blog::get();
     $type = $this->input->get('type');
     $route = $type == 'static' ? 'statics' : 'posts';
     try {
         if (!$id) {
             throw new ValidFailException('Where is your post ID?');
         }
         if (!Author::isAdmin()) {
             throw new ValidFailException('Access deny');
         }
         $postMapper = new DataMapper('posts');
         $post = $postMapper->findOne($id);
         if ($post->blog != $blog->id) {
             throw new ValidFailException('You cannot change post of other blog.');
         }
         $post['state'] = $this->input->get('state', 1);
         $postMapper->updateOne($post);
     } catch (ValidFailException $e) {
         $this->setRedirect(Router::buildHttp('admin:' . $route), $e->getMessage(), 'danger');
         return false;
     } catch (\Exception $e) {
         if (WINDWALKER_DEBUG) {
             throw $e;
         }
         $this->setRedirect(Router::buildHttp('admin:' . $route), 'Fail', 'danger');
         return false;
     }
     $this->setRedirect(Router::buildHttp('admin:' . $route), 'Success', 'success');
     return true;
 }
Пример #3
0
 /**
  * Execute the controller.
  *
  * @throws \Exception
  * @return  mixed Return executed result.
  */
 public function execute()
 {
     $id = $this->input->get('id');
     $user = User::get();
     $blog = Blog::get();
     try {
         if (!$id) {
             throw new ValidFailException('No ID');
         }
         if (!Author::isAdmin()) {
             throw new ValidFailException('Access deny');
         }
         $postMapper = new DataMapper('posts');
         $post = $postMapper->findOne($id);
         if ($post->blog != $blog->id) {
             throw new ValidFailException('You cannot delete post of other blog.');
         }
         $postMapper->delete(['id' => $id]);
     } catch (ValidFailException $e) {
         $this->setRedirect(Router::buildHttp('admin:posts'), $e->getMessage(), 'danger');
         return false;
     } catch (\Exception $e) {
         if (WINDWALKER_DEBUG) {
             throw $e;
         }
         $this->setRedirect(Router::buildHttp('admin:posts'), 'Delete fail', 'danger');
         return false;
     }
     $this->setRedirect(Router::buildHttp('admin:posts'), 'Delete success', 'success');
     return true;
 }
Пример #4
0
 /**
  * Execute the controller.
  *
  * @throws \Exception
  * @return  mixed Return executed result.
  */
 public function execute()
 {
     $id = $this->input->get('id');
     $blogMapper = new DataMapper('blogs');
     $authorMapper = new DataMapper('authors');
     $catMapper = new DataMapper('categories');
     $postMapper = new DataMapper('posts');
     try {
         if (!$id) {
             throw new \Exception('Delete fail');
         }
         $author = $authorMapper->findOne(['blog' => $id, 'user' => User::get()->id]);
         if (!$author->owner) {
             throw new ValidFailException('Only owner can remove blog.');
         }
         $blogMapper->delete(['id' => $id]);
         $authorMapper->delete(['blog' => $id]);
         $catMapper->delete(['blog' => $id]);
         $postMapper->delete(['blog' => $id]);
     } catch (ValidFailException $e) {
         $this->setRedirect(Router::buildHttp('admin:blogs'), $e->getMessage(), 'danger');
         return false;
     } catch (\Exception $e) {
         if (WINDWALKER_DEBUG) {
             throw $e;
         }
         $this->setRedirect(Router::buildHttp('admin:blogs'), 'Delete fail', 'danger');
         return false;
     }
     $this->setRedirect(Router::buildHttp('admin:blogs'), 'Delete Blog success', 'success');
     return true;
 }
Пример #5
0
 /**
  * Execute the controller.
  *
  * @throws \Exception
  * @return  mixed Return executed result.
  */
 public function execute()
 {
     $user = $this->input->getVar('registration');
     $user = new Data($user);
     $session = Ioc::getSession();
     $session['register.form.data'] = $user;
     $trans = Ioc::getDatabase()->getTransaction()->start();
     try {
         $this->validate($user);
         // User
         $user = $this->createUser($user);
         // Blog
         $blogCtrl = $this->createBlog($user);
         // Articles
         $this->createDefaultArticle($blogCtrl);
     } catch (ValidFailException $e) {
         $trans->rollback();
         $this->setRedirect(Router::buildHttp('user:registration'), $e->getMessage(), 'danger');
         return false;
     } catch (\Exception $e) {
         $trans->rollback();
         if (WINDWALKER_DEBUG) {
             throw $e;
         }
         $this->setRedirect(Router::buildHttp('user:registration'), 'Register fail', 'danger');
         return false;
     }
     $trans->commit();
     $session->remove('register.form.data');
     // OK let's login
     User::makeUserLogin($user->id);
     $this->setRedirect(Router::buildHttp('user:login'), 'Register success.', 'success');
     return true;
 }
Пример #6
0
 /**
  * register
  *
  * @param Data $user
  *
  * @return  Data
  */
 public function register(Data $user)
 {
     $password = new Password();
     $user->password = $password->create($user->password);
     unset($user->password2);
     $user = User::save($user);
     return $user;
 }
Пример #7
0
 public function logout($username)
 {
     $credential = new Credential(array('username' => $username));
     if (User::logout($credential)) {
         return false;
     }
     return true;
 }
Пример #8
0
 /**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $model = new BlogsModel();
     $view = new WidgetHtmlView();
     $model['user.id'] = User::get()->id;
     $view['blog'] = Blog::get();
     $view['blogs'] = $model->getItems();
     $view['activeMenu'] = $this->input->get('activeMenu', 'dashboard');
     return $view->setLayout('sidebar')->render();
 }
Пример #9
0
 /**
  * doExecute
  *
  * @return  string
  */
 protected function doExecute()
 {
     $view = new ProfileHtmlView($this->data);
     $model = new ProfileModel();
     $session = Ioc::getSession();
     $user = $session->get('profile.edit.data') ?: User::get();
     $view['item'] = $user;
     $view['form'] = $model->getForm($user);
     return $view->setLayout('edit')->render();
 }
Пример #10
0
 /**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $model = new LoginModel();
     $user = User::get();
     if ($user->isNull()) {
         $this->setRedirect('login', 'Already logout', 'success');
     }
     $model->logout($user->username);
     $this->setRedirect('login', 'Logout success', 'success');
     return true;
 }
Пример #11
0
 /**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $user = User::get();
     if (!$user->isNull()) {
         Ioc::getApplication()->redirect(Router::build('admin:dashboard'));
     }
     $model = new LoginModel();
     $view = new LoginHtmlView();
     $view['form'] = $model->getForm();
     return $view->render();
 }
Пример #12
0
 /**
  * doExecute
  *
  * @return  boolean
  */
 protected function doExecute()
 {
     $model = new BlogsModel();
     $view = new BlogsHtmlView($this->data);
     $model['user.id'] = User::get()->id;
     // $model['list.start']  = $this->input->getInt('start');
     $model['list.limit'] = 100;
     $model['list.search'] = $this->input->getString('q');
     $cats = $model->getItems();
     $view['items'] = $cats;
     return $view->render();
 }
Пример #13
0
 /**
  * register
  *
  * @param array $user
  *
  * @throws \Exception
  * @return  bool
  */
 public function register($user)
 {
     $user = new Data($user);
     if ($user->password != $user->password2) {
         throw new \Exception('Password not match.');
     }
     $password = new Password();
     $user->password = $password->create($user->password);
     unset($user->password2);
     User::save($user);
     return true;
 }
Пример #14
0
 /**
  * get
  *
  * @param int $pk
  *
  * @return  \Windwalker\Data\Data
  */
 public static function get($pk = null)
 {
     if (!$pk) {
         return User::get();
     }
     $cache = CacheFactory::getCache('user');
     $key = 'user.' . $pk;
     if ($cache->exists($key)) {
         return $cache->get($key);
     }
     $user = User::get($pk);
     $cache->set($key, $user);
     return $user;
 }
Пример #15
0
 /**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $model = new LoginModel();
     $user = User::get();
     if ($user->isNull()) {
         $this->setRedirect('login', 'Already logout', 'success');
     }
     $model->logout($user->username);
     // Session
     $session = Ioc::getSession();
     $session->remove('current.blog');
     $this->setRedirect(Router::buildHttp('front:home'), 'Logout success', 'success');
     return true;
 }
 /**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $model = new BlogsModel();
     $model['user.id'] = User::get()->id;
     $data['activeMenu'] = $this->input->get('activeMenu', 'none');
     $data['hideMenu'] = $this->input->get('hideMenu', 0);
     $data['widget'] = new Data();
     // $data['widget']['sidebar'] = (new SidebarController($this->input, $this->app))->execute();
     $data['blog'] = Blog::get();
     $data['blogs'] = $model->getItems();
     $data['user'] = User::get();
     $data['profiler'] = WINDWALKER_DEBUG ? Ioc::getProfiler() : null;
     $this->data = $data;
     return $this->doExecute();
 }
Пример #17
0
 /**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $id = $this->input->get('id');
     $return = $this->input->get('return');
     $return = $return ? base64_decode($return) : Router::build('admin:dashboard');
     $user = User::get();
     $blogModel = new BlogModel();
     $blogModel['user.isAdmin'] = false;
     $blog = $blogModel->getCurrentBlog($user->id, $id);
     $session = Ioc::getSession();
     if (!$blog->isNull()) {
         $session->set('current.blog', $blog->id);
     }
     $this->setRedirect($return);
     return true;
 }
Пример #18
0
 /**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $files = $this->input->files;
     $field = $this->input->get('field', 'file');
     $id = $this->input->get('id');
     $author = Author::getAuthor($id);
     $user = User::get();
     $blog = Blog::get();
     try {
         if (!Author::isAdmin($blog, $user)) {
             throw new ValidFailException('You cannot edit this author.');
         }
         $src = $files->getByPath($field . '.tmp_name', null, InputFilter::STRING);
         $name = $files->getByPath($field . '.name', null, InputFilter::STRING);
         if (!$src) {
             throw new \Exception('File not upload');
         }
         $ext = pathinfo($name, PATHINFO_EXTENSION);
         $uuid = $author->uuid ?: Uuid::v4();
         $src = Thumb::createThumb($src);
         $dest = sprintf('author/%s/%s.%s', sha1($uuid), md5($uuid), $ext);
         $result = S3Helper::put($src, $dest);
         File::delete($src);
         if (!$result) {
             throw new \Exception('Upload fail.');
         }
     } catch (\Exception $e) {
         $response = new Response();
         $response->setBody(json_encode(['error' => $e->getMessage()]));
         $response->setMimeType('text/json');
         $response->respond();
         exit;
     }
     $return = new Registry();
     $return['filename'] = 'https://windspeaker.s3.amazonaws.com/' . $dest;
     $return['file'] = 'https://windspeaker.s3.amazonaws.com/' . $dest;
     $return['uuid'] = $uuid;
     if ($author->id) {
         $author->image = $return['filename'];
         (new DataMapper('authors'))->updateOne($author);
     }
     $response = new Response();
     $response->setBody((string) $return);
     $response->setMimeType('text/json');
     $response->respond();
     exit;
 }
Пример #19
0
 /**
  * getBlog
  *
  * @return  Data
  */
 public static function get()
 {
     if (static::$blog) {
         return static::$blog;
     }
     $session = Ioc::getSession();
     $blogId = $session->get('current.blog');
     $blogModel = new BlogModel();
     $user = User::get();
     if ($user->isNull()) {
         throw new \RuntimeException('No user');
     }
     $blog = $blogModel->getCurrentBlog($user->id, $blogId);
     $blog->params = json_decode($blog->params);
     $session->set('current.blog', $blog->id);
     return static::$blog = $blog;
 }
Пример #20
0
 /**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $model = new PostModel();
     $data = $this->input->getVar('post');
     $data['text'] = $this->input->getByPath('post.text', null, InputFilter::RAW);
     $data = new Data($data);
     $isNew = !$data['id'];
     try {
         $model->validate($data);
         if (!$isNew) {
             $oldData = (new DataMapper('posts'))->findOne($data['id']);
             $oldData->bind($data);
             $data = $oldData;
             $data->modified = (new Date())->format('Y-m-d H:i:s');
         } else {
             $data->blog = Blog::get()->id;
             $data->type = $this->input->get('type', 'post');
             $data->type = $data->type == 'post' ? $data->type : 'static';
             $data->created = (new Date())->format('Y-m-d H:i:s');
         }
         $data->author = $data->author ?: Author::get(User::get()->id, Blog::get()->id)->id;
         $text = preg_split('/(\\<\\!--\\s*\\{READMORE\\}\\s*--\\>)/', $data['text'], 2);
         $data->introtext = isset($text[0]) ? $text[0] : null;
         $data->fulltext = isset($text[1]) ? $text[1] : null;
         $data = $model->save($data);
     } catch (ValidFailException $e) {
         $return['msg'] = $e->getMessage();
         $return['success'] = false;
         $this->respond($return, 500);
         return false;
     } catch (\Exception $e) {
         if (WINDWALKER_DEBUG) {
             throw $e;
         }
         $return['msg'] = 'Save fail';
         $return['success'] = false;
         $this->respond($return, 500);
         return false;
     }
     $return['msg'] = 'Save success';
     $return['success'] = true;
     $return['item'] = $data;
     $this->respond($return, 200);
     return true;
 }
Пример #21
0
 /**
  * getDest
  *
  * @param string $name
  * @param string $type
  *
  * @return  string
  */
 protected function getDest($name, $type = 'post')
 {
     $user = User::get();
     $date = new Date();
     $year = $date->year;
     $month = $date->month;
     $day = $date->day;
     $ext = pathinfo($name, PATHINFO_EXTENSION);
     switch ($type) {
         case 'post':
             return sprintf('post/%s/%s/%s/%s/%s.%s', $user->username, $year, $month, $day, uniqid(), $ext);
             break;
         case 'profile':
             return sprintf('user/%s/%s.%s', sha1('user-profile-' . $user->id), md5('user-profile-' . $user->id), $ext);
         default:
             return sprintf('images/%s/%s/%s/%s/%s.%s', $user->username, $year, $month, $day, uniqid(), $ext);
     }
 }
Пример #22
0
 /**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $user = User::get();
     try {
         $user->image = "0";
         User::save($user);
     } catch (\Exception $e) {
         $response = new Response();
         $response->setBody(json_encode(['error' => $e->getMessage()]));
         $response->setMimeType('text/json');
         $response->respond();
         exit;
     }
     $return = new Registry();
     $return['success'] = true;
     $return['image'] = UserHelper::getAvatar($user->id, 650);
     $response = new Response();
     $response->setBody((string) $return);
     $response->setMimeType('text/json');
     $response->respond();
     exit;
 }
Пример #23
0
 /**
  * Execute the controller.
  *
  * @throws \Exception
  * @return  mixed Return executed result.
  */
 public function execute()
 {
     $session = Ioc::getSession();
     $user = $this->input->getVar('user', array());
     $user = new Data($user);
     $user->id = User::get()->id;
     $user->username = User::get()->username;
     // Store Session
     $temp = clone $user;
     unset($temp->password);
     unset($temp->password2);
     $session->set('profile.edit.data', $temp);
     try {
         if (!$this->validate($user)) {
             return false;
         }
         $record = new Record('users');
         $record->load($user->id);
         $record->bind($user);
         $record->check()->store(true);
     } catch (ValidFailException $e) {
         $this->setRedirect(Router::buildHttp('admin:profile', ['id' => $user->id ?: '']), $e->getMessage(), 'danger');
         return true;
     } catch (\Exception $e) {
         if (WINDWALKER_DEBUG) {
             throw $e;
         }
         $this->setRedirect(Router::buildHttp('admin:profile', ['id' => $user->id ?: '']), 'Save fail', 'danger');
         return true;
     }
     // Save success, reset user session
     unset($user->password);
     unset($user->password2);
     $session->set('user', $user);
     $session->remove('profile.edit.data');
     $this->setRedirect(Router::buildHttp('admin:profile'), 'Save Success', 'success');
     return true;
 }
Пример #24
0
 /**
  * Execute the controller.
  *
  * @throws \Exception
  * @return  mixed Return executed result.
  */
 public function execute()
 {
     $user = User::get($this->input->get('user_id'));
     $blog = $this->input->getVar('blog');
     $blog = new Data($blog);
     $blog->params = $this->input->getByPath('blog.params', array(), null);
     $isNew = !$blog->id;
     $blog->state = 1;
     $blog->alias = OutputFilter::stringURLSafe($blog->alias);
     if ($isNew) {
         $blog->params['css'] = $this->getDefaultCss();
     }
     if (!$this->validate($blog)) {
         return false;
     }
     $trans = Ioc::getDatabase()->getTransaction()->start();
     try {
         $blog->params = json_encode($blog->params);
         $this->blog = (new DataMapper('blogs'))->saveOne($blog, 'id');
         if ($isNew) {
             $author['user'] = $user->id;
             $author['blog'] = $this->blog->id;
             $author['owner'] = 1;
             $author['admin'] = 1;
             $this->author = (new DataMapper('authors'))->createOne($author);
         }
         $trans->commit();
     } catch (\Exception $e) {
         $trans->rollback();
         if (WINDWALKER_DEBUG) {
             throw $e;
         }
         $this->setRedirect(Router::buildHttp('admin:blog', ['id' => $blog->id ?: '']), 'Save fail', 'danger');
         return true;
     }
     $this->setRedirect(Router::buildHttp('admin:blogs'), 'Save Success', 'success');
     return true;
 }
Пример #25
0
 /**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $files = $this->input->files;
     $field = $this->input->get('field', 'file');
     $user = User::get();
     try {
         $src = $files->getByPath($field . '.tmp_name', null, InputFilter::STRING);
         $name = $files->getByPath($field . '.name', null, InputFilter::STRING);
         if (!$src) {
             throw new \Exception('File not upload');
         }
         $ext = pathinfo($name, PATHINFO_EXTENSION);
         $src = Thumb::createThumb($src);
         $dest = sprintf('user/%s/%s.%s', sha1('user-profile-' . $user->id), md5('user-profile-' . $user->id), $ext);
         $result = S3Helper::put($src, $dest);
         File::delete($src);
         if (!$result) {
             throw new \Exception('Upload fail.');
         }
     } catch (\Exception $e) {
         $response = new Response();
         $response->setBody(json_encode(['error' => $e->getMessage()]));
         $response->setMimeType('text/json');
         $response->respond();
         exit;
     }
     $return = new Registry();
     $return['filename'] = 'https://windspeaker.s3.amazonaws.com/' . $dest;
     $return['file'] = 'https://windspeaker.s3.amazonaws.com/' . $dest;
     $user->image = $return['filename'];
     User::save($user);
     $response = new Response();
     $response->setBody((string) $return);
     $response->setMimeType('text/json');
     $response->respond();
     exit;
 }
 /**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $model = new PostsModel();
     $blog = Ioc::get('current.blog', 'front');
     $author = (new DataMapper('authors'))->findOne(['blog' => $blog->id, 'owner' => 1]);
     $user = (new DataMapper('users'))->findOne(['id' => $author->user]);
     $this->data['blog'] = $blog;
     $this->data['ownerUser'] = $user;
     $this->data['ownerAuthor'] = $author;
     $this->data['user'] = User::get();
     $this->data['author'] = Author::get($user->id, $blog->id);
     // Statics
     $model['blog.id'] = $blog->id;
     $model['list.start'] = null;
     $model['list.limit'] = null;
     $model['blog.published'] = true;
     $model['post.type'] = 'static';
     $model['post.ordering'] = 'id asc';
     $this->data['statics'] = $model->getItems();
     $this->data['blog']->link = 'http://' . $this->data['blog']->alias . '.windspeaker.co';
     $this->data['blog']->params = new Registry($this->data['blog']->params);
     $this->data['meta'] = new Data();
     return $this->doExecute();
 }
Пример #27
0
 public function initialise()
 {
     parent::initialise();
     User::setHandler(new UserHandler());
 }
Пример #28
0
 /**
  * create
  *
  * @param string $username
  *
  * @throws  ValidFailException
  * @throws  \Exception
  * @return  boolean
  */
 protected function createUser($username)
 {
     $authorMapper = new DataMapper('authors');
     if (!$username) {
         throw new ValidFailException('Please enter username');
     }
     $blog = Blog::get();
     $user = User::get(['username' => $username]);
     if ($user->isNull()) {
         throw new ValidFailException('User not exists');
     }
     if (!$authorMapper->findOne(['user' => $user->id, 'blog' => $blog->id])->isNull()) {
         $this->setRedirect(Router::buildHttp('admin:authors'), 'Author already exists', 'success');
         return true;
     }
     $data['user'] = $user->id;
     $data['blog'] = $blog->id;
     (new DataMapper('authors'))->saveOne($data);
     $this->setRedirect(Router::buildHttp('admin:authors'), 'Save success', 'success');
     return true;
 }
Пример #29
0
 /**
  * prepareData
  *
  * @param \Windwalker\Data\Data $data
  *
  * @return  void
  */
 protected function prepareData($data)
 {
     $data['avatar'] = UserHelper::getAvatar(User::get()->id, 650);
 }
Пример #30
0
 /**
  * checkPermission
  *
  * @param string $type
  * @param Data   $blog
  * @param Data   $user
  *
  * @return  boolean
  */
 public static function checkPermission($type = self::ADMIN, Data $blog = null, Data $user = null)
 {
     $user = $user ?: User::get();
     $blog = $blog ?: Blog::get();
     // TODO: cache it.
     $author = (new DataMapper('authors'))->findOne(['user' => $user->id, 'blog' => $blog->id]);
     if ($author->isNull()) {
         return false;
     }
     switch ($type) {
         case static::OWNER:
             return (bool) $author->owner;
             break;
         case static::ADMIN:
             return (bool) $author->owner || (bool) $author->admin;
             break;
         default:
         case static::MEMBER:
             return !$author->owner && !$author->admin;
             break;
     }
 }