コード例 #1
0
ファイル: topic.php プロジェクト: janus57/PHPBoost_v3c
$rewrited_title = $CONFIG['rewrite'] == 1 ? '+' . url_encode_rewrite($topic['title']) : '';
if (!empty($_POST['change_cat'])) {
    redirect(HOST . DIR . '/forum/forum' . url('.php?id=' . $_POST['change_cat'], '-' . $_POST['change_cat'] . $rewrited_cat_title . '.php', '&'));
}
if (!$User->check_auth($CAT_FORUM[$topic['idcat']]['auth'], READ_CAT_FORUM) || !empty($CAT_FORUM[$topic['idcat']]['url'])) {
    $Errorh->handler('e_auth', E_USER_REDIRECT);
}
$Template->set_filenames(array('forum_topic' => 'forum/forum_topic.tpl', 'forum_top' => 'forum/forum_top.tpl', 'forum_bottom' => 'forum/forum_bottom.tpl'));
$module_data_path = $Template->get_module_data_path('forum');
$check_group_edit_auth = $User->check_auth($CAT_FORUM[$topic['idcat']]['auth'], EDIT_CAT_FORUM);
if ($check_group_edit_auth) {
    $Template->assign_vars(array('C_FORUM_MODERATOR' => true, 'C_FORUM_LOCK_TOPIC' => $topic['status'] == '1' ? true : false, 'U_TOPIC_LOCK' => url('.php?id=' . $id_get . '&lock=true&token=' . $Session->get_token()), 'U_TOPIC_UNLOCK' => url('.php?id=' . $id_get . '&lock=false&token=' . $Session->get_token()), 'U_TOPIC_MOVE' => url('.php?id=' . $id_get), 'L_TOPIC_LOCK' => $topic['status'] == '1' ? $LANG['forum_lock'] : $LANG['forum_unlock'], 'L_TOPIC_MOVE' => $LANG['forum_move'], 'L_ALERT_DELETE_TOPIC' => $LANG['alert_delete_topic'], 'L_ALERT_LOCK_TOPIC' => $LANG['alert_lock_topic'], 'L_ALERT_UNLOCK_TOPIC' => $LANG['alert_unlock_topic'], 'L_ALERT_MOVE_TOPIC' => $LANG['alert_move_topic'], 'L_ALERT_CUT_TOPIC' => $LANG['alert_cut_topic']));
} else {
    $Template->assign_vars(array('C_FORUM_MODERATOR' => false));
}
mark_topic_as_read($id_get, $topic['last_msg_id'], $topic['last_timestamp']);
$idm = retrieve(GET, 'idm', 0);
if (!empty($idm)) {
    $nbr_msg_before = $Sql->query("SELECT COUNT(*) as nbr_msg_before FROM " . PREFIX . "forum_msg WHERE idtopic = " . $id_get . " AND id < '" . $idm . "'", __LINE__, __FILE__);
    if (is_int(($nbr_msg_before + 1) / $CONFIG_FORUM['pagination_msg'])) {
        if ($topic['nbr_msg'] != $nbr_msg_before + 1) {
            $nbr_msg_before++;
        }
    }
    $_GET['pt'] = ceil(($nbr_msg_before + 1) / $CONFIG_FORUM['pagination_msg']);
}
import('util/pagination');
$Pagination = new Pagination();
$i = 0;
$forum_cats = '';
$Bread_crumb->remove_last();
コード例 #2
0
ファイル: Forum.class.php プロジェクト: AroundPBT/PHPBoost
 function Del_msg($idmsg, $idtopic, $idcat, $first_msg_id, $last_msg_id, $last_timestamp, $msg_user_id)
 {
     $config = ForumConfig::load();
     if ($first_msg_id != $idmsg) {
         //On compte le nombre de messages du topic avant l'id supprimé.
         $nbr_msg = PersistenceContext::get_querier()->count(PREFIX . "forum_msg", 'WHERE idtopic = :idtopic AND id < :id', array('idtopic' => $idtopic, 'id' => $idmsg));
         //On supprime le message demandé.
         PersistenceContext::get_querier()->delete(PREFIX . 'forum_msg', 'WHERE id=:id', array('id' => $idmsg));
         //On met à jour la table forum_topics.
         PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "forum_topics SET nbr_msg = nbr_msg - 1 WHERE id = '" . $idtopic . "'");
         //Récupération du message précédent celui supprimé afin de rediriger vers la bonne ancre.
         $previous_msg_id = 0;
         try {
             $previous_msg_id = PersistenceContext::get_querier()->get_column_value(PREFIX . "forum_msg", 'id', 'WHERE idtopic = :idtopic AND id < :id ORDER BY timestamp DESC', array('idtopic' => $idtopic, 'id' => $idmsg));
         } catch (RowNotFoundException $e) {
         }
         if ($last_msg_id == $idmsg) {
             //On cherche les infos à propos de l'avant dernier message afin de mettre la table forum_topics à jour.
             try {
                 $id_before_last = PersistenceContext::get_querier()->select_single_row(PREFIX . 'forum_msg', array('user_id', 'timestamp'), 'WHERE id=:id', array('id' => $previous_msg_id));
             } catch (RowNotFoundException $e) {
                 $error_controller = PHPBoostErrors::unexisting_element();
                 DispatchManager::redirect($error_controller);
             }
             PersistenceContext::get_querier()->update(PREFIX . 'forum_topics', array('last_user_id' => $id_before_last['user_id'], 'last_msg_id' => $previous_msg_id, 'last_timestamp' => $id_before_last['timestamp']), 'WHERE id=:id', array('id' => $idtopic));
             //On met maintenant a jour le last_topic_id dans les catégories.
             $this->Update_last_topic_id($idcat);
         }
         //On retire un msg au membre.
         PersistenceContext::get_querier()->inject("UPDATE " . DB_TABLE_MEMBER . " SET posted_msg = posted_msg - 1 WHERE user_id = '" . $msg_user_id . "'");
         //Mise à jour du dernier message lu par les membres.
         PersistenceContext::get_querier()->update(PREFIX . 'forum_view', array('last_view_id' => $previous_msg_id), 'WHERE last_view_id=:id', array('id' => $idmsg));
         //On marque le topic comme lu, si c'est le dernier du message du topic.
         if ($last_msg_id == $idmsg) {
             mark_topic_as_read($idtopic, $previous_msg_id, $last_timestamp);
         }
         //Insertion de l'action dans l'historique.
         if ($msg_user_id != AppContext::get_current_user()->get_id()) {
             //Calcul de la page sur laquelle se situe le message.
             $msg_page = ceil($nbr_msg / $config->get_number_messages_per_page());
             $msg_page_rewrite = $msg_page > 1 ? '-' . $msg_page : '';
             $msg_page = $msg_page > 1 ? '&pt=' . $msg_page : '';
             forum_history_collector(H_DELETE_MSG, $msg_user_id, 'topic' . url('.php?id=' . $idtopic . $msg_page, '-' . $idtopic . $msg_page_rewrite . '.php', '&') . '#m' . $previous_msg_id);
         }
         forum_generate_feeds();
         //Regénération des flux flux
         return array($nbr_msg, $previous_msg_id);
     }
     return array(false, false);
 }
コード例 #3
0
ファイル: forum.class.php プロジェクト: janus57/PHPBoost_v3c
 function Del_msg($idmsg, $idtopic, $idcat, $first_msg_id, $last_msg_id, $last_timestamp, $msg_user_id)
 {
     global $Sql, $User, $CAT_FORUM, $CONFIG_FORUM;
     if ($first_msg_id != $idmsg) {
         $nbr_msg = $Sql->query("SELECT COUNT(*) FROM " . PREFIX . "forum_msg WHERE idtopic = '" . $idtopic . "' AND id < '" . $idmsg . "'", __LINE__, __FILE__);
         $Sql->query_inject("DELETE FROM " . PREFIX . "forum_msg WHERE id = '" . $idmsg . "'", __LINE__, __FILE__);
         $Sql->query_inject("UPDATE " . PREFIX . "forum_topics SET nbr_msg = nbr_msg - 1 WHERE id = '" . $idtopic . "'", __LINE__, __FILE__);
         $Sql->query_inject("UPDATE " . PREFIX . "forum_cats SET nbr_msg = nbr_msg - 1 WHERE id_left <= '" . $CAT_FORUM[$idcat]['id_left'] . "' AND id_right >= '" . $CAT_FORUM[$idcat]['id_right'] . "' AND level <= '" . $CAT_FORUM[$idcat]['level'] . "'", __LINE__, __FILE__);
         $previous_msg_id = $Sql->query("SELECT id FROM " . PREFIX . "forum_msg WHERE idtopic = '" . $idtopic . "' AND id < '" . $idmsg . "' ORDER BY timestamp DESC " . $Sql->limit(0, 1), __LINE__, __FILE__);
         if ($last_msg_id == $idmsg) {
             $id_before_last = $Sql->query_array(PREFIX . 'forum_msg', 'user_id', 'timestamp', "WHERE id = '" . $previous_msg_id . "'", __LINE__, __FILE__);
             $last_timestamp = $id_before_last['timestamp'];
             $Sql->query_inject("UPDATE " . PREFIX . "forum_topics SET last_user_id = '" . $id_before_last['user_id'] . "', last_msg_id = '" . $previous_msg_id . "', last_timestamp = '" . $last_timestamp . "' WHERE id = '" . $idtopic . "'", __LINE__, __FILE__);
             $this->Update_last_topic_id($idcat);
         }
         $Sql->query_inject("UPDATE " . DB_TABLE_MEMBER . " SET user_msg = user_msg - 1 WHERE user_id = '" . $msg_user_id . "'", __LINE__, __FILE__);
         $Sql->query_inject("UPDATE " . PREFIX . "forum_view SET last_view_id = '" . $previous_msg_id . "' WHERE last_view_id = '" . $idmsg . "'", __LINE__, __FILE__);
         if ($last_msg_id == $idmsg) {
             mark_topic_as_read($idtopic, $previous_msg_id, $last_timestamp);
         }
         if ($msg_user_id != $User->get_attribute('user_id')) {
             $msg_page = ceil($nbr_msg / $CONFIG_FORUM['pagination_msg']);
             $msg_page_rewrite = $msg_page > 1 ? '-' . $msg_page : '';
             $msg_page = $msg_page > 1 ? '&pt=' . $msg_page : '';
             forum_history_collector(H_DELETE_MSG, $msg_user_id, 'topic' . url('.php?id=' . $idtopic . $msg_page, '-' . $idtopic . $msg_page_rewrite . '.php', '&') . '#m' . $previous_msg_id);
         }
         forum_generate_feeds();
         return array($nbr_msg, $previous_msg_id);
     }
     return array(false, false);
 }