Example #1
0
 function post_delete($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id)
 {
     global $db, $cache, $config, $lang, $user;
     $poll_deleted = false;
     $bin_mode = false;
     $bin_forum_id = intval($config['bin_forum']);
     if ($mode == 'delete' && !empty($bin_forum_id) && $bin_forum_id != $forum_id) {
         $bin_mode = true;
     }
     if ($mode != 'poll_delete') {
         // MG Cash MOD For IP - BEGIN
         if (!empty($config['plugins']['cash']['enabled'])) {
             $GLOBALS['cm_posting']->update_delete($mode, $post_data, $forum_id, $topic_id, $post_id);
         }
         // MG Cash MOD For IP - END
         if ($post_data['first_post'] && $post_data['last_post']) {
             if (!empty($bin_mode)) {
                 $this->topic_recycle(array($topic_id), $forum_id);
             } else {
                 $this->topic_delete($topic_id, $forum_id);
                 $poll_deleted = true;
             }
         } else {
             if (!empty($bin_mode)) {
                 $new_topic_id = $this->post_recycle($post_id, $forum_id, $topic_id, $post_data['topic_title'], false);
             } else {
                 $sql = "DELETE FROM " . POSTS_TABLE . " WHERE post_id = {$post_id}";
                 $db->sql_query($sql);
                 // Event Registration - BEGIN
                 if ($post_data['first_post']) {
                     $sql = "DELETE FROM " . REGISTRATION_TABLE . " WHERE topic_id = {$topic_id}";
                     $db->sql_query($sql);
                     $sql = "DELETE FROM " . REGISTRATION_DESC_TABLE . " WHERE topic_id = {$topic_id}";
                     $db->sql_query($sql);
                 }
                 // Event Registration - END
                 // UPI2DB - BEGIN
                 $sql = "DELETE FROM " . UPI2DB_LAST_POSTS_TABLE . " WHERE post_id = {$post_id}";
                 $db->sql_query($sql);
                 $sql = "DELETE FROM " . UPI2DB_UNREAD_POSTS_TABLE . " WHERE post_id = {$post_id}";
                 $db->sql_query($sql);
                 // UPI2DB - END
                 $sql = "DELETE FROM " . POSTS_LIKES_TABLE . " WHERE post_id = {$post_id}";
                 $db->sql_query($sql);
                 if (!function_exists('remove_search_post')) {
                     include IP_ROOT_PATH . 'includes/functions_search.' . PHP_EXT;
                 }
                 remove_search_post($post_id);
             }
         }
     }
     if ($post_data['has_poll'] && $post_data['edit_poll'] && ($mode == 'poll_delete' || $mode == 'delete' && $post_data['first_post'] && $post_data['last_post'])) {
         if (empty($bin_mode) && empty($poll_deleted)) {
             $this->topic_poll_delete($topic_id);
         }
     }
     if ($mode == 'delete' && $post_data['first_post'] && $post_data['last_post']) {
         $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $forum_id) . '">';
         $message = $lang['Deleted'];
     } else {
         $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id) . '">';
         $message = ($mode == 'poll_delete' ? $lang['Poll_delete'] : $lang['Deleted']) . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id) . '">', '</a>');
     }
     $message .= '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $forum_id) . '">', '</a>');
     if (!empty($forum_id)) {
         $this->sync('forum', $forum_id);
     }
     // LIKES - BEGIN
     @(include_once IP_ROOT_PATH . 'includes/class_topics.' . PHP_EXT);
     $class_topics = new class_topics();
     $class_topics->topics_posts_likes_resync();
     // LIKES - END
     $this->sync_cache(0, 0);
     board_stats();
     cache_tree(true);
     return true;
 }