private function check_authorizations()
 {
     if (!(CalendarAuthorizationsService::check_authorizations()->write() || CalendarAuthorizationsService::check_authorizations()->contribution() || CalendarAuthorizationsService::check_authorizations()->moderation())) {
         $error_controller = PHPBoostErrors::user_not_authorized();
         DispatchManager::redirect($error_controller);
     }
 }
 private function check_authorizations()
 {
     if (!CalendarAuthorizationsService::check_authorizations()->read()) {
         $error_controller = PHPBoostErrors::user_not_authorized();
         DispatchManager::redirect($error_controller);
     }
 }
Ejemplo n.º 3
0
 public function get_actions_tree_links()
 {
     $request = AppContext::get_request();
     $year = $request->get_getint('year', date('Y'));
     $month = $request->get_getint('month', date('n'));
     $day = $request->get_getint('day', date('j'));
     $lang = LangLoader::get('common', 'calendar');
     $tree = new ModuleTreeLinks();
     $manage_categories_link = new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), CalendarUrlBuilder::manage_categories());
     $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), CalendarUrlBuilder::manage_categories()));
     $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('category.add', 'categories-common'), CalendarUrlBuilder::add_category()));
     $tree->add_link($manage_categories_link);
     $manage_events_link = new AdminModuleLink($lang['calendar.manage'], CalendarUrlBuilder::manage_events());
     $manage_events_link->add_sub_link(new AdminModuleLink($lang['calendar.manage'], CalendarUrlBuilder::manage_events()));
     $manage_events_link->add_sub_link(new AdminModuleLink($lang['calendar.titles.add_event'], CalendarUrlBuilder::add_event($year, $month, $day)));
     $tree->add_link($manage_events_link);
     $tree->add_link(new AdminModuleLink(LangLoader::get_message('configuration', 'admin-common'), CalendarUrlBuilder::configuration()));
     if (!AppContext::get_current_user()->check_level(User::ADMIN_LEVEL)) {
         $tree->add_link(new ModuleLink($lang['calendar.titles.add_event'], CalendarUrlBuilder::add_event($year, $month, $day), CalendarAuthorizationsService::check_authorizations()->write() || CalendarAuthorizationsService::check_authorizations()->contribution()));
     }
     $tree->add_link(new ModuleLink($lang['calendar.events_list'], CalendarUrlBuilder::events_list($year, $month, $day), CalendarAuthorizationsService::check_authorizations()->read()));
     $tree->add_link(new ModuleLink($lang['calendar.pending'], CalendarUrlBuilder::display_pending_events(), CalendarAuthorizationsService::check_authorizations()->write() || CalendarAuthorizationsService::check_authorizations()->contribution() || CalendarAuthorizationsService::check_authorizations()->moderation()));
     return $tree;
 }
 public function is_displayed()
 {
     return !Url::is_current_url('/calendar/') && CalendarAuthorizationsService::check_authorizations()->read();
 }
 private function check_authorizations()
 {
     $event = $this->get_event();
     if (!CalendarAuthorizationsService::check_authorizations($event->get_content()->get_category_id())->read() && (!(CalendarAuthorizationsService::check_authorizations($event->get_content()->get_category_id())->write() || CalendarAuthorizationsService::check_authorizations($event->get_content()->get_category_id())->contribution() && !$event->get_content()->is_approved()) && $event->get_content()->get_author_user()->get_id() != AppContext::get_current_user()->get_id())) {
         $error_controller = PHPBoostErrors::user_not_authorized();
         DispatchManager::redirect($error_controller);
     }
 }
Ejemplo n.º 6
0
 public function is_authorized_to_delete()
 {
     return CalendarAuthorizationsService::check_authorizations($this->content->get_category_id())->moderation() || (CalendarAuthorizationsService::check_authorizations($this->content->get_category_id())->write() || CalendarAuthorizationsService::check_authorizations($this->content->get_category_id())->contribution() && !$this->content->is_approved()) && $this->content->get_author_user()->get_id() == AppContext::get_current_user()->get_id() && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL);
 }
 public function init_default_properties($category_id = Category::ROOT_CATEGORY)
 {
     $this->category_id = $category_id;
     $this->author_user = AppContext::get_current_user();
     $this->creation_date = new Date();
     $this->registration_authorized = false;
     $this->max_registered_members = 0;
     $this->last_registration_date_enabled = false;
     $this->register_authorizations = array('r0' => 3, 'r1' => 3);
     if (CalendarAuthorizationsService::check_authorizations()->write()) {
         $this->approve();
     } else {
         $this->unapprove();
     }
     $this->repeat_number = 1;
     $this->repeat_type = self::NEVER;
 }
 public function get_authorizations()
 {
     $authorizations = new CommentsAuthorizations();
     $authorizations->set_authorized_access_module(CalendarAuthorizationsService::check_authorizations($this->get_event()->get_content()->get_category_id())->read());
     return $authorizations;
 }
 private function is_contributor_member()
 {
     return !CalendarAuthorizationsService::check_authorizations()->write() && CalendarAuthorizationsService::check_authorizations()->contribution();
 }