private function save()
 {
     $this->config->set_title($this->form->get_value('title'));
     if ($this->form->get_value('informations_enabled')) {
         $this->config->enable_informations();
         $this->config->set_informations($this->form->get_value('informations'));
         $this->config->set_informations_position($this->form->get_value('informations_position')->get_raw_value());
     } else {
         $this->config->disable_informations();
     }
     if ($this->form->get_value('tracking_number_enabled')) {
         $this->config->enable_tracking_number();
         if ($this->form->get_value('date_in_tracking_number_enabled')) {
             $this->config->enable_date_in_tracking_number();
         } else {
             $this->config->disable_date_in_tracking_number();
         }
     } else {
         $this->config->disable_tracking_number();
     }
     if ($this->form->get_value('sender_acknowledgment_enabled')) {
         $this->config->enable_sender_acknowledgment();
     } else {
         $this->config->disable_sender_acknowledgment();
     }
     $this->config->set_authorizations($this->form->get_value('authorizations')->build_auth_array());
     ContactConfig::save();
 }
 public function synchronize()
 {
     $this->messages = array();
     $items_number_per_page = GuestbookConfig::load()->get_items_per_page();
     $result = PersistenceContext::get_querier()->select("SELECT g.id, g.login, g.contents, g.timestamp, m.user_id, m.display_name, m.level, m.groups\r\n\t\tFROM " . GuestbookSetup::$guestbook_table . " g\r\n\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\r\n\t\tGROUP BY g.id\r\n\t\tORDER BY RAND()\r\n\t\tLIMIT 50");
     $page = $i = 1;
     foreach ($result as $msg) {
         if ($i > $page * $items_number_per_page) {
             $page++;
         }
         $this->messages[$msg['id']] = array('id' => $msg['id'], 'contents' => strip_tags(FormatingHelper::second_parse($msg['contents'])), 'user_id' => $msg['user_id'], 'login' => $msg['display_name'] ? $msg['display_name'] : $msg['login'], 'level' => $msg['level'], 'groups' => $msg['groups'], 'timestamp' => $msg['timestamp'], 'page' => $page);
         $i++;
     }
     $result->dispose();
 }
 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;
 }
 private function save()
 {
     $this->config->set_items_per_page($this->form->get_value('items_per_page'));
     $forbidden_tags = array();
     foreach ($this->form->get_value('forbidden_tags') as $field => $option) {
         $forbidden_tags[] = $option->get_raw_value();
     }
     $this->config->set_forbidden_tags($forbidden_tags);
     if ($this->form->get_value('max_links_number_per_message_enabled')) {
         $this->config->enable_max_links_number_per_message();
         $this->config->set_maximum_links_message($this->form->get_value('max_links_number_per_message'));
     } else {
         $this->config->disable_max_links_number_per_message();
     }
     $this->config->set_authorizations($this->form->get_value('authorizations')->build_auth_array());
     GuestbookConfig::save();
     GuestbookMessagesCache::invalidate();
 }
 private function get_pagination($messages_number, $page)
 {
     $pagination = new ModulePagination($page, $messages_number, (int) GuestbookConfig::load()->get_items_per_page());
     $pagination->set_url(GuestbookUrlBuilder::home('%d'));
     if ($pagination->current_page_is_empty() && $page > 1) {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
     return $pagination;
 }
 private function get_authorizations($bit)
 {
     return AppContext::get_current_user()->check_auth(GuestbookConfig::load()->get_authorizations(), $bit);
 }