protected function build_new_config() { $config = $this->get_old_config(); $forum_config = ForumConfig::load(); $forum_config->set_forum_name($config['forum_name']); $forum_config->set_number_topics_per_page($config['pagination_topic']); $forum_config->set_number_messages_per_page($config['pagination_msg']); $forum_config->set_read_messages_storage_duration($config['view_time']); $forum_config->set_max_topic_number_in_favorite($config['topic_track']); if (!empty($config['topic_track'])) { $forum_config->enable_edit_mark(); } else { $forum_config->disable_edit_mark(); } if (!empty($config['no_left_column'])) { $forum_config->enable_left_column(); } else { $forum_config->disable_left_column(); } if (!empty($config['no_right_column'])) { $forum_config->enable_right_column(); } else { $forum_config->disable_right_column(); } if (!empty($config['activ_display_msg'])) { $forum_config->display_message_before_topic_title(); } else { $forum_config->hide_message_before_topic_title(); } $forum_config->set_message_before_topic_title($config['display_msg']); $forum_config->set_message_when_topic_is_unsolved($config['explain_display_msg']); $forum_config->set_message_when_topic_is_solved($config['explain_display_msg_bis']); if (!empty($config['icon_activ_display_msg'])) { $forum_config->display_message_before_topic_title_icon(); } else { $forum_config->hide_message_before_topic_title_icon(); } if (!empty($config['display_connexion'])) { $forum_config->display_connexion_form(); } else { $forum_config->hide_connexion_form(); } $forum_config->set_authorizations($this->build_authorizations(unserialize($config['auth']))); ForumConfig::save(); return true; }
public function get_feed_data_struct($idcat = 0, $name = '') { $config = ForumConfig::load(); $category = ForumService::get_categories_manager()->get_categories_cache()->get_category($idcat); $data = new FeedData(); $data->set_title(LangLoader::get_message('xml_forum_desc', 'common', 'forum')); $data->set_date(new Date()); $data->set_link(DispatchManager::get_url('/syndication', '/rss/forum/' . $idcat . '/')); $data->set_host(HOST); $data->set_desc(LangLoader::get_message('xml_forum_desc', 'common', 'forum')); $data->set_lang(LangLoader::get_message('xml_lang', 'main')); $data->set_auth_bit(Category::READ_AUTHORIZATIONS); $categories = ForumService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true); $ids_categories = array_keys($categories); $results = PersistenceContext::get_querier()->select('SELECT t.id, t.idcat, t.title, t.last_timestamp, t.last_msg_id, t.display_msg, t.nbr_msg AS t_nbr_msg, msg.id mid, msg.contents FROM ' . PREFIX . 'forum_topics t LEFT JOIN ' . PREFIX . 'forum_msg msg ON msg.id = t.last_msg_id WHERE t.idcat IN :ids_categories ORDER BY t.last_timestamp DESC LIMIT :limit OFFSET 0', array('ids_categories' => $ids_categories, 'limit' => 2 * $config->get_number_messages_per_page())); foreach ($results as $row) { $item = new FeedItem(); //Link $last_page = ceil($row['t_nbr_msg'] / $config->get_number_messages_per_page()); $last_page_rewrite = $last_page > 1 ? '-' . $last_page : ''; $last_page = $last_page > 1 ? 'pt=' . $last_page . '&' : ''; $link = new Url('/forum/topic' . url('.php?' . $last_page . 'id=' . $row['id'], '-' . $row['id'] . $last_page_rewrite . '+' . Url::encode_rewrite($row['title']) . '.php') . '#m' . $row['last_msg_id']); $item->set_title(($config->is_message_before_topic_title_displayed() && !empty($row['display_msg']) ? TextHelper::html_entity_decode($config->get_message_before_topic_title(), ENT_NOQUOTES) . ' ' : '') . stripslashes($row['title'])); $item->set_link($link); $item->set_guid($link); $item->set_desc(FormatingHelper::second_parse($row['contents'])); $item->set_date(new Date($row['last_timestamp'], Timezone::SERVER_TIMEZONE)); $item->set_auth(ForumService::get_categories_manager()->get_heritated_authorizations($row['idcat'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY)); $data->add_item($item); } $results->dispose(); return $data; }
* it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ if (defined('PHPBOOST') !== true) { exit; } load_module_lang('forum'); //Chargement de la langue du module. $config = ForumConfig::load(); require_once PATH_TO_ROOT . '/forum/forum_defines.php'; //Supprime les menus suivant configuration du site. $columns_disabled = ThemesManager::get_theme(AppContext::get_current_user()->get_theme())->get_columns_disabled(); if ($config->is_left_column_disabled()) { $columns_disabled->set_disable_left_columns(true); } if ($config->is_right_column_disabled()) { $columns_disabled->set_disable_right_columns(true); } //Fonction du forum. require_once PATH_TO_ROOT . '/forum/forum_functions.php';
public function get_root_category() { $root = new ForumCategory(); $root->set_authorizations(ForumConfig::load()->get_authorizations()); return $root; }
private function get_authorizations($bit) { return AppContext::get_current_user()->check_auth(ForumConfig::load()->get_authorizations(), $bit); }
function Track_topic($idtopic, $tracking_type = 0) { $config = ForumConfig::load(); list($mail, $pm, $track) = array(0, 0, 0); if ($tracking_type == 0) { //Suivi par email. $track = '1'; } elseif ($tracking_type == 1) { //Suivi par email. $mail = '1'; } elseif ($tracking_type == 2) { //Suivi par email. $pm = '1'; } $exist = PersistenceContext::get_querier()->count(PREFIX . 'forum_track', 'WHERE user_id = :user_id AND idtopic = :idtopic', array('user_id' => AppContext::get_current_user()->get_id(), 'idtopic' => $idtopic)); if ($exist == 0) { PersistenceContext::get_querier()->insert(PREFIX . "forum_track", array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id(), 'track' => $track, 'pm' => $pm, 'mail' => $mail)); } elseif ($tracking_type == 0) { PersistenceContext::get_querier()->update(PREFIX . "forum_track", array('track' => 1), 'WHERE idtopic = :idtopic AND user_id = :user_id', array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id())); } elseif ($tracking_type == 1) { PersistenceContext::get_querier()->update(PREFIX . "forum_track", array('mail' => 1), 'WHERE idtopic = :idtopic AND user_id = :user_id', array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id())); } elseif ($tracking_type == 2) { PersistenceContext::get_querier()->update(PREFIX . "forum_track", array('pm' => 1), 'WHERE idtopic = :idtopic AND user_id = :user_id', array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id())); } //Limite de sujets suivis? if (!ForumAuthorizationsService::check_authorizations()->unlimited_topics_tracking()) { //Récupère l'id du topic le plus vieux autorisé par la limite de sujet suivis. $tracked_topics_number = PersistenceContext::get_querier()->select_single_row_query("SELECT COUNT(*) as number\n\t\t\tFROM " . PREFIX . "forum_track\n\t\t\tWHERE user_id = :user_id\n\t\t\tORDER BY id DESC\n\t\t\tLIMIT " . $config->get_max_topic_number_in_favorite(), array('user_id' => AppContext::get_current_user()->get_id())); //Suppression des sujets suivis dépassant le nbr maximum autorisé. PersistenceContext::get_querier()->delete(PREFIX . 'forum_track', 'WHERE user_id=:id AND id < :number', array('id' => AppContext::get_current_user()->get_id(), 'number' => $tracked_topics_number['number'])); } }
/** * {@inheritDoc} */ public function on_changeday(Date $yesterday, Date $today) { //Suppression des marqueurs de vue du forum trop anciens. PersistenceContext::get_querier()->delete(PREFIX . 'forum_view', 'WHERE timestamp < :limit', array('limit' => time() - ForumConfig::load()->get_read_messages_storage_duration() * 3600 * 24)); }
private function init() { $this->config = ForumConfig::load(); $this->lang = LangLoader::get('common', 'forum'); $this->admin_common_lang = LangLoader::get('admin-common'); }
function mark_topic_as_read($idtopic, $last_msg_id, $last_timestamp) { //Calcul du temps de péremption, ou de dernière vue des messages par à rapport à la configuration. $last_view_forum = AppContext::get_session()->get_cached_data('last_view_forum', 0); $max_time = time() - ForumConfig::load()->get_read_messages_storage_duration() * 3600 * 24; $max_time_msg = $last_view_forum > $max_time ? $last_view_forum : $max_time; if (AppContext::get_current_user()->get_id() !== -1 && $last_timestamp >= $max_time_msg) { $check_view_id = 0; try { $check_view_id = PersistenceContext::get_querier()->get_column_value(PREFIX . "forum_view", 'last_view_id', 'WHERE user_id = :user_id AND idtopic = :idtopic', array('user_id' => AppContext::get_current_user()->get_id(), 'idtopic' => $idtopic)); } catch (RowNotFoundException $e) { } if (!empty($check_view_id) && $check_view_id != $last_msg_id) { PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "forum_topics SET nbr_views = nbr_views + 1 WHERE id = '" . $idtopic . "'"); PersistenceContext::get_querier()->update(PREFIX . "forum_view", array('last_view_id' => $last_msg_id, 'timestamp' => time()), 'WHERE idtopic = :idtopic AND user_id = :user_id', array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id())); } elseif (empty($check_view_id)) { PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "forum_topics SET nbr_views = nbr_views + 1 WHERE id = '" . $idtopic . "'"); PersistenceContext::get_querier()->insert(PREFIX . "forum_view", array('idtopic' => $idtopic, 'last_view_id' => $last_msg_id, 'user_id' => AppContext::get_current_user()->get_id(), 'timestamp' => time())); } else { PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "forum_topics SET nbr_views = nbr_views + 1 WHERE id = '" . $idtopic . "'"); } } else { PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "forum_topics SET nbr_views = nbr_views + 1 WHERE id = '" . $idtopic . "'"); } }