private function build_view(HTTPRequestCustom $request)
 {
     $year = $request->get_getint('year', date('Y'));
     $month = $request->get_getint('month', date('n'));
     $day = $request->get_getint('day', date('j'));
     if (!checkdate($month, $day, $year)) {
         $this->tpl->put('MSG', MessageHelper::display($this->lang['calendar.error.e_invalid_date'], MessageHelper::ERROR));
         $year = date('Y');
         $month = date('n');
         $day = date('j');
     }
     $this->tpl->put_all(array('CALENDAR' => CalendarAjaxCalendarController::get_view(false, $year, $month), 'EVENTS' => CalendarAjaxEventsController::get_view($year, $month, $day)));
     return $this->tpl;
 }
    public function execute(HTTPRequestCustom $request)
    {
        $id = $request->get_getint('id');
        $this->init();
        $extended_field = new ExtendedField();
        $extended_field->set_id($id);
        $exist_field = ExtendedFieldsDatabaseService::check_field_exist_by_id($extended_field);
        if ($exist_field) {
            $this->extended_field = ExtendedFieldsCache::load()->get_extended_field($id);
            $this->build_form($request);
        } else {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        $this->tpl = new StringTemplate('# INCLUDE MSG #
				# INCLUDE FORM #
				<script>
				jQuery(document).ready(function() {
				' . $this->get_events_select_type() . '});
				</script>');
        $this->tpl->add_lang($this->lang);
        $this->tpl->put_all(array('FIELD_TYPE' => $this->extended_field['field_type']));
        if ($this->submit_button->has_been_submited() && $this->form->validate()) {
            $extended_field = $this->save($id);
            $error = ExtendedFieldsService::get_error();
            if (!empty($error)) {
                $this->tpl->put('MSG', MessageHelper::display($error, MessageHelper::ERROR, 5));
            } else {
                AppContext::get_response()->redirect($this->form->get_value('referrer') ? $this->form->get_value('referrer') : AdminExtendedFieldsUrlBuilder::fields_list(), StringVars::replace_vars($this->lang['message.success.edit'], array('name' => $extended_field->get_name())));
            }
        }
        $this->tpl->put('FORM', $this->form->display());
        return new AdminExtendedFieldsDisplayResponse($this->tpl, $this->lang['extended-field-edit']);
    }
 public function execute(HTTPRequestCustom $request)
 {
     $id = $request->get_getint('id', 0);
     if (!empty($id)) {
         try {
             $this->weblink = WebService::get_weblink('WHERE web.id = :id', array('id' => $id));
         } catch (RowNotFoundException $e) {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
     if ($this->weblink !== null && !DownloadAuthorizationsService::check_authorizations($this->weblink->get_id_category())->read()) {
         $error_controller = PHPBoostErrors::user_not_authorized();
         DispatchManager::redirect($error_controller);
     } else {
         if ($this->weblink !== null && $this->weblink->is_visible()) {
             $this->weblink->set_number_views($this->weblink->get_number_views() + 1);
             WebService::update_number_views($this->weblink);
             WebCache::invalidate();
             AppContext::get_response()->redirect($this->weblink->get_url()->absolute());
         } else {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
 }
 private function init(HTTPRequestCustom $request)
 {
     $this->lang = LangLoader::get('common', 'contact');
     $this->admin_user_common_lang = LangLoader::get('admin-user-common');
     $this->config = ContactConfig::load();
     $this->id = $request->get_getint('id', 0);
 }
 private function build_view(HTTPRequestCustom $request)
 {
     $current_page = $request->get_getint('page', 1);
     $config = ArticlesConfig::load();
     $this->category = $this->article->get_category();
     $article_contents = $this->article->get_contents();
     //If article doesn't begin with a page, we insert one
     if (substr(trim($article_contents), 0, 6) != '[page]') {
         $article_contents = '[page]&nbsp;[/page]' . $article_contents;
     }
     //Removing [page] bbcode
     $article_contents_clean = preg_split('`\\[page\\].+\\[/page\\](.*)`Us', $article_contents, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
     //Retrieving pages
     preg_match_all('`\\[page\\]([^[]+)\\[/page\\]`U', $article_contents, $array_page);
     $nbr_pages = count($array_page[1]);
     if ($nbr_pages > 1) {
         $this->build_form($array_page, $current_page);
     }
     $this->build_sources_view();
     $this->build_keywords_view();
     $page_name = isset($array_page[1][$current_page - 1]) && $array_page[1][$current_page - 1] != '&nbsp;' ? $array_page[1][$current_page - 1] : '';
     $this->tpl->put_all(array_merge($this->article->get_tpl_vars(), array('C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $config->is_notation_enabled(), 'KERNEL_NOTATION' => NotationService::display_active_image($this->article->get_notation()), 'CONTENTS' => isset($article_contents_clean[$current_page - 1]) ? FormatingHelper::second_parse($article_contents_clean[$current_page - 1]) : '', 'PAGE_NAME' => $page_name, 'U_EDIT_ARTICLE' => $page_name !== '' ? ArticlesUrlBuilder::edit_article($this->article->get_id(), $current_page)->rel() : ArticlesUrlBuilder::edit_article($this->article->get_id())->rel())));
     $this->build_pages_pagination($current_page, $nbr_pages, $array_page);
     //Affichage commentaires
     if ($config->are_comments_enabled()) {
         $comments_topic = new ArticlesCommentsTopic($this->article);
         $comments_topic->set_id_in_module($this->article->get_id());
         $comments_topic->set_url(ArticlesUrlBuilder::display_article($this->category->get_id(), $this->category->get_rewrited_name(), $this->article->get_id(), $this->article->get_rewrited_title()));
         $this->tpl->put('COMMENTS', $comments_topic->display());
     }
 }
 public function execute(HTTPRequestCustom $request)
 {
     $module_id = $request->get_getstring('module_id', '');
     if (empty($module_id)) {
         AppContext::get_response()->redirect(Environment::get_home_page());
     }
     $this->init();
     $module_category_id = $request->get_getint('module_category_id', 0);
     $feed_name = $request->get_getstring('feed_name', Feed::DEFAULT_FEED_NAME);
     $feed = new ATOM($module_id, $feed_name, $module_category_id);
     if ($feed !== null && $feed->is_in_cache()) {
         $this->tpl->put('SYNDICATION', $feed->read());
     } else {
         $eps = AppContext::get_extension_provider_service();
         if ($eps->provider_exists($module_id, FeedProvider::EXTENSION_POINT)) {
             $provider = $eps->get_provider($module_id);
             $feeds = $provider->feeds();
             $data = $feeds->get_feed_data_struct($module_category_id, $feed_name);
             if ($data === null) {
                 AppContext::get_response()->set_header('content-type', 'text/html');
                 DispatchManager::redirect(PHPBoostErrors::unexisting_element());
             } else {
                 $feed->load_data($data);
                 $feed->cache();
                 $this->tpl->put('SYNDICATION', $feed->export());
             }
         } else {
             DispatchManager::redirect(PHPBoostErrors::module_not_installed());
         }
     }
     return $this->build_response($this->tpl);
 }
 public function execute(HTTPRequestCustom $request)
 {
     $id = $request->get_getint('id', 0);
     if (!empty($id) && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
         try {
             $this->downloadfile = DownloadService::get_downloadfile('WHERE download.id = :id', array('id' => $id));
         } catch (RowNotFoundException $e) {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
     if ($this->downloadfile !== null && $this->downloadfile->is_visible()) {
         if (!PersistenceContext::get_querier()->row_exists(PREFIX . 'events', 'WHERE id_in_module=:id_in_module AND module=\'download\' AND current_status = 0', array('id_in_module' => $this->downloadfile->get_id()))) {
             $contribution = new Contribution();
             $contribution->set_id_in_module($this->downloadfile->get_id());
             $contribution->set_entitled(StringVars::replace_vars(LangLoader::get_message('contribution.deadlink', 'common'), array('link_name' => $this->downloadfile->get_name())));
             $contribution->set_fixing_url(DownloadUrlBuilder::edit($this->downloadfile->get_id())->relative());
             $contribution->set_description(LangLoader::get_message('contribution.deadlink_explain', 'common'));
             $contribution->set_poster_id(AppContext::get_current_user()->get_id());
             $contribution->set_module('download');
             $contribution->set_type('alert');
             $contribution->set_auth(Authorizations::capture_and_shift_bit_auth(DownloadService::get_categories_manager()->get_heritated_authorizations($this->downloadfile->get_id_category(), Category::MODERATION_AUTHORIZATIONS, Authorizations::AUTH_CHILD_PRIORITY), Category::MODERATION_AUTHORIZATIONS, Contribution::CONTRIBUTION_AUTH_BIT));
             ContributionService::save_contribution($contribution);
         }
         DispatchManager::redirect(new UserContributionSuccessController());
     } else {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
 }
 public function execute(HTTPRequestCustom $request)
 {
     $id = $request->get_getint('id', 0);
     PersistenceContext::get_querier()->delete(DB_TABLE_SMILEYS, 'WHERE idsmiley = :id', array('id' => $id));
     ###### Régénération du cache des smileys #######
     SmileysCache::invalidate();
     AppContext::get_response()->redirect(AdminSmileysUrlBuilder::management());
 }
 public function execute(HTTPRequestCustom $request)
 {
     $group_id = $request->get_getint('id', 0);
     $this->init();
     if ($group_id !== 0 && !$this->groups_cache->group_exists($group_id)) {
         AppContext::get_response()->redirect(UserUrlBuilder::home());
     }
     $this->build_view($group_id);
     return $this->build_response();
 }
 private function get_downloadfile(HTTPRequestCustom $request)
 {
     $id = $request->get_getint('id', 0);
     if (!empty($id)) {
         try {
             $this->downloadfile = DownloadService::get_downloadfile('WHERE download.id=:id', array('id' => $id));
         } catch (RowNotFoundException $e) {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
 }
 private function get_message(HTTPRequestCustom $request)
 {
     $id = $request->get_getint('id', 0);
     if (!empty($id)) {
         try {
             return ShoutboxService::get_message('WHERE id=:id', array('id' => $id));
         } catch (RowNotFoundException $e) {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->init();
     $user_id = $request->get_getint('user_id', AppContext::get_current_user()->get_id());
     try {
         $this->user_infos = PersistenceContext::get_querier()->select_single_row(PREFIX . 'member', array('*'), 'WHERE user_id=:user_id', array('user_id' => $user_id));
     } catch (RowNotFoundException $e) {
         $error_controller = PHPBoostErrors::unexisting_element();
         DispatchManager::redirect($error_controller);
     }
     $this->build_form($this->user_infos['user_id']);
     $this->tpl->put('FORM', $this->form->display());
     return $this->build_response($this->tpl, $user_id);
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->init();
     $user_id = $request->get_getint('user_id', 0);
     if (empty($user_id)) {
         AppContext::get_response()->redirect(UserUrlBuilder::home());
     }
     try {
         $this->user = UserService::get_user($user_id);
     } catch (RowNotFoundException $e) {
         $error_controller = PHPBoostErrors::unexisting_element();
         DispatchManager::redirect($error_controller);
     }
     $this->build_form();
     return $this->build_response($this->tpl);
 }
 public function execute(HTTPRequestCustom $request)
 {
     $event_id = $request->get_getint('event_id', 0);
     $current_user_id = AppContext::get_current_user()->get_id();
     if (!empty($event_id)) {
         $this->get_event($event_id);
         $this->check_authorizations();
         if (in_array($current_user_id, array_keys($this->event->get_participants()))) {
             CalendarService::delete_participant($event_id, $current_user_id);
             CalendarCurrentMonthEventsCache::invalidate();
         }
         $category = $this->event->get_content()->get_category();
         AppContext::get_response()->redirect($request->get_url_referrer() ? $request->get_url_referrer() : CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name(), $event_id, $this->event->get_content()->get_rewrited_title()));
     } else {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
 }
 public function execute(HTTPRequestCustom $request)
 {
     $module_id = $request->get_getstring('module_id', '');
     $user_id = $request->get_getint('user_id', 0);
     if (!empty($user_id)) {
         try {
             $this->user = UserService::get_user($user_id);
         } catch (Exception $e) {
             $error_controller = PHPBoostErrors::unexisting_element();
             DispatchManager::redirect($error_controller);
         }
     }
     if (!empty($module_id)) {
         $this->module = ModulesManager::get_module($module_id);
     }
     $this->init($request);
     return $this->build_response();
 }
 public function execute(HTTPRequestCustom $request)
 {
     $id = $request->get_getint('id', 0);
     if (!empty($id)) {
         try {
             $this->downloadfile = DownloadService::get_downloadfile('WHERE download.id = :id', array('id' => $id));
         } catch (RowNotFoundException $e) {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
     if ($this->downloadfile !== null && !DownloadAuthorizationsService::check_authorizations($this->downloadfile->get_id_category())->read()) {
         $error_controller = PHPBoostErrors::user_not_authorized();
         DispatchManager::redirect($error_controller);
     } else {
         if ($this->downloadfile !== null && $this->downloadfile->is_visible()) {
             $this->downloadfile->set_number_downloads($this->downloadfile->get_number_downloads() + 1);
             DownloadService::update_number_downloads($this->downloadfile);
             DownloadCache::invalidate();
             $status = 200;
             $file_headers = get_headers($this->downloadfile->get_url()->absolute(), true);
             if (is_array($file_headers)) {
                 if (preg_match('/^HTTP\\/[12]\\.[01] (\\d\\d\\d)/', $file_headers[0], $matches)) {
                     $status = (int) $matches[1];
                 }
             }
             if ($status == 200) {
                 header('Content-Disposition: attachment; filename="' . urldecode(basename($this->downloadfile->get_url()->absolute())) . '"');
                 header('Content-Description: File Transfer');
                 header('Content-Transfer-Encoding: binary');
                 header('Accept-Ranges: bytes');
                 header('Content-Type: application/force-download');
                 set_time_limit(0);
                 readfile($this->downloadfile->get_url()->absolute());
             } else {
                 $error_controller = new UserErrorController(LangLoader::get_message('error', 'status-messages-common'), LangLoader::get_message('download.message.error.file_not_found', 'common', 'download'), UserErrorController::WARNING);
                 DispatchManager::redirect($error_controller);
             }
         } else {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->init();
     $user_id = $request->get_getint('user_id', AppContext::get_current_user()->get_id());
     try {
         $this->user = UserService::get_user($user_id);
     } catch (RowNotFoundException $e) {
         $error_controller = PHPBoostErrors::unexisting_element();
         DispatchManager::redirect($error_controller);
     }
     try {
         $this->internal_auth_infos = PHPBoostAuthenticationMethod::get_auth_infos($user_id);
     } catch (RowNotFoundException $e) {
     }
     $this->user_auth_types = AuthenticationService::get_user_types_authentication($user_id);
     if (!$this->check_authorizations($user_id)) {
         $error_controller = PHPBoostErrors::user_not_authorized();
         DispatchManager::redirect($error_controller);
     }
     $associate_type = $request->get_getvalue('associate', false);
     if ($associate_type) {
         if (!in_array($associate_type, $this->user_auth_types)) {
             $authentication_method = AuthenticationService::get_authentication_method($associate_type);
             AuthenticationService::associate($authentication_method, $user_id);
             AppContext::get_response()->redirect(UserUrlBuilder::edit_profile($user_id));
         }
     }
     $dissociate_type = $request->get_getvalue('dissociate', false);
     if ($dissociate_type) {
         if (in_array($dissociate_type, $this->user_auth_types) && count($this->user_auth_types) > 1) {
             $authentication_method = AuthenticationService::get_authentication_method($dissociate_type);
             AuthenticationService::dissociate($authentication_method, $user_id);
             AppContext::get_response()->redirect(UserUrlBuilder::edit_profile($user_id));
         }
     }
     $this->build_form();
     if ($this->submit_button->has_been_submited() && $this->form->validate()) {
         $this->save($request);
     }
     $this->tpl->put('FORM', $this->form->display());
     return $this->build_response();
 }
 public function execute(HTTPRequestCustom $request)
 {
     if (!NewsletterAuthorizationsService::default_authorizations()->moderation_subscribers()) {
         NewsletterAuthorizationsService::get_errors()->moderation_subscribers();
     }
     $id = $request->get_getint('id', 0);
     $this->init();
     $verificate_is_edit = PersistenceContext::get_querier()->count(NewsletterSetup::$newsletter_table_subscribers, "WHERE id = '" . $id . "' AND user_id = -1") > 0;
     if (!$this->subscriber_exist($id) || !$verificate_is_edit) {
         $controller = new UserErrorController(LangLoader::get_message('error', 'status-messages-common'), LangLoader::get_message('error-subscriber-not-existed', 'common', 'newsletter'));
         DispatchManager::redirect($controller);
     }
     $this->build_form($id);
     $tpl = new StringTemplate('# INCLUDE MSG # # INCLUDE FORM #');
     $tpl->add_lang($this->lang);
     if ($this->submit_button->has_been_submited() && $this->form->validate()) {
         $this->save($id);
         $tpl->put('MSG', MessageHelper::display(LangLoader::get_message('process.success', 'status-messages-common'), MessageHelper::SUCCESS, 4));
     }
     $tpl->put('FORM', $this->form->display());
     return $this->build_response($tpl);
 }
 public function execute(HTTPRequestCustom $request)
 {
     AppContext::get_session()->csrf_get_protect();
     AdminError404Service::delete_404_error($request->get_getint('id'));
     AppContext::get_response()->redirect(AdminErrorsUrlBuilder::list_404_errors());
 }
 private function build_form(HTTPRequestCustom $request)
 {
     $config = GuestbookConfig::load();
     $formatter = AppContext::get_content_formatting_service()->get_default_factory();
     $formatter->set_forbidden_tags($config->get_forbidden_tags());
     $form = new HTMLForm(__CLASS__);
     $fieldset = new FormFieldsetHTML('message', $this->is_new_message ? $this->lang['guestbook.add'] : $this->lang['guestbook.edit']);
     $form->add_fieldset($fieldset);
     if (!AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
         $fieldset->add_field(new FormFieldTextEditor('pseudo', LangLoader::get_message('form.name', 'common'), $this->get_message()->get_login(), array('required' => true, 'maxlength' => 25)));
     }
     $fieldset->add_field(new FormFieldRichTextEditor('contents', LangLoader::get_message('message', 'main'), $this->get_message()->get_contents(), array('formatter' => $formatter, 'rows' => 10, 'cols' => 47, 'required' => true), array(new FormFieldConstraintMaxLinks($config->get_maximum_links_message(), true), new FormFieldConstraintAntiFlood(GuestbookService::get_last_message_timestamp_from_user($this->get_message()->get_author_user()->get_id())))));
     $fieldset->add_field(new FormFieldHidden('page', $request->get_getint('page', 1)));
     $this->submit_button = new FormButtonDefaultSubmit();
     $form->add_button($this->submit_button);
     $form->add_button(new FormButtonReset());
     $this->form = $form;
 }