private function check_authorizations()
 {
     $article = $this->get_article();
     $not_authorized = !ArticlesAuthorizationsService::check_authorizations($article->get_id_category())->write() && (!ArticlesAuthorizationsService::check_authorizations($article->get_id_category())->moderation() && $article->get_author_user()->get_id() != AppContext::get_current_user()->get_id());
     switch ($article->get_publishing_state()) {
         case Article::PUBLISHED_NOW:
             if (!ArticlesAuthorizationsService::check_authorizations()->read() && $not_authorized) {
                 $error_controller = PHPBoostErrors::user_not_authorized();
                 DispatchManager::redirect($error_controller);
             }
             break;
         case Article::NOT_PUBLISHED:
             if ($not_authorized) {
                 $error_controller = PHPBoostErrors::user_not_authorized();
                 DispatchManager::redirect($error_controller);
             }
             break;
         case Article::PUBLISHED_DATE:
             if (!$article->is_published() && $not_authorized) {
                 $error_controller = PHPBoostErrors::user_not_authorized();
                 DispatchManager::redirect($error_controller);
             }
             break;
         default:
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
             break;
     }
 }
 public function get_actions_tree_links()
 {
     $lang = LangLoader::get('common', 'articles');
     $tree = new ModuleTreeLinks();
     $manage_categories_link = new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), ArticlesUrlBuilder::manage_categories());
     $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), ArticlesUrlBuilder::manage_categories()));
     $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('category.add', 'categories-common'), ArticlesUrlBuilder::add_category()));
     $tree->add_link($manage_categories_link);
     $manage_articles_link = new AdminModuleLink($lang['articles_management'], ArticlesUrlBuilder::manage_articles());
     $manage_articles_link->add_sub_link(new AdminModuleLink($lang['articles_management'], ArticlesUrlBuilder::manage_articles()));
     $manage_articles_link->add_sub_link(new AdminModuleLink($lang['articles.add'], ArticlesUrlBuilder::add_article(AppContext::get_request()->get_getint('id_category', Category::ROOT_CATEGORY))));
     $tree->add_link($manage_articles_link);
     $tree->add_link(new AdminModuleLink(LangLoader::get_message('configuration', 'admin-common'), ArticlesUrlBuilder::configuration()));
     if (!AppContext::get_current_user()->check_level(User::ADMIN_LEVEL)) {
         $tree->add_link(new ModuleLink($lang['articles.add'], ArticlesUrlBuilder::add_article(AppContext::get_request()->get_getint('id_category', Category::ROOT_CATEGORY)), ArticlesAuthorizationsService::check_authorizations()->write() || ArticlesAuthorizationsService::check_authorizations()->contribution()));
     }
     $tree->add_link(new ModuleLink($lang['articles.pending_articles'], ArticlesUrlBuilder::display_pending_articles(), ArticlesAuthorizationsService::check_authorizations()->write() || ArticlesAuthorizationsService::check_authorizations()->contribution() || ArticlesAuthorizationsService::check_authorizations()->moderation()));
     return $tree;
 }
 private function is_contributor_member()
 {
     return !ArticlesAuthorizationsService::check_authorizations()->write() && ArticlesAuthorizationsService::check_authorizations()->contribution();
 }
 private function check_authorizations()
 {
     if (!(ArticlesAuthorizationsService::check_authorizations()->write() || ArticlesAuthorizationsService::check_authorizations()->contribution() || ArticlesAuthorizationsService::check_authorizations()->moderation())) {
         $error_controller = PHPBoostErrors::user_not_authorized();
         DispatchManager::redirect($error_controller);
     }
 }
 public function get_authorizations()
 {
     $authorizations = new CommentsAuthorizations();
     $authorizations->set_authorized_access_module(ArticlesAuthorizationsService::check_authorizations($this->get_article()->get_id_category())->read());
     return $authorizations;
 }
예제 #6
0
 public function is_authorized_to_delete()
 {
     return ArticlesAuthorizationsService::check_authorizations($this->id_category)->moderation() || (ArticlesAuthorizationsService::check_authorizations($this->get_id_category())->write() || ArticlesAuthorizationsService::check_authorizations($this->get_id_category())->contribution() && !$this->is_published()) && $this->get_author_user()->get_id() == AppContext::get_current_user()->get_id() && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL);
 }
 private function check_authorizations()
 {
     if (AppContext::get_current_user()->is_guest()) {
         if ($this->config->are_descriptions_displayed_to_guests() && !Authorizations::check_auth(RANK_TYPE, User::MEMBER_LEVEL, $this->get_category()->get_authorizations(), Category::READ_AUTHORIZATIONS) || !$this->config->are_descriptions_displayed_to_guests() && !ArticlesAuthorizationsService::check_authorizations($this->get_category()->get_id())->read()) {
             $error_controller = PHPBoostErrors::user_not_authorized();
             DispatchManager::redirect($error_controller);
         }
     } else {
         if (!ArticlesAuthorizationsService::check_authorizations($this->get_category()->get_id())->read()) {
             $error_controller = PHPBoostErrors::user_not_authorized();
             DispatchManager::redirect($error_controller);
         }
     }
 }
 private function check_authorizations()
 {
     if (!ArticlesAuthorizationsService::check_authorizations()->read()) {
         $error_controller = PHPBoostErrors::user_not_authorized();
         DispatchManager::redirect($error_controller);
     }
 }