function display_post($pm = false, $pm_links = null) { global $tplt; # awc_pdie($this); static $mem_Info = array(); static $word = array(); static $avatarwidth; $height_stuff = array('advar' => 0, 'memtitle' => 0, 'wikicount' => 0, 'postcount' => 0, 'threadcount' => 0); # awc_pdie($this); static $time_func_called = 0; ++$time_func_called; if ($time_func_called == 1) { $word = self::get_words(); if (isset($this->cf_AvatraSize)) { $spl = explode('x', $this->cf_AvatraSize); $avatarwidth = $spl[1] + '20'; } else { $avatarwidth = '135'; } } if ($pm == false) { // wfRunHooks( 'awcsforum_rawpost', array( &$this ) ); if ($time_func_called == 1) { $tplt_info['LimitJump'] = isset($extras['LimitJump_top']) ? $extras['LimitJump_top'] : null; $tplt_info['options_menu'] = isset($extras['options_menu']) ? $extras['options_menu'] : null; } } else { $edit_buttons['edit_buttons'] = $this->pm_links; $tplt_info['edit_buttons'] = $edit_buttons['edit_buttons']; $tplt_info['post_edited_on'] = null; } $tplt_info['avatarwidth'] = $avatarwidth; # Cache... Create array of Members info then check, cut down on queires on Sig and Group $HaveMemInfo = false; if (!empty($mem_Info)) { foreach ($mem_Info as $id => $value) { if ($mem_Info[$id]['m_id'] == $this->p_userid) { $HaveMemInfo = true; } } if (!$HaveMemInfo) { $mem_Info[$this->p_userid] = GetMemInfo($this->p_userid, $this->user_info_cols); } } else { $mem_Info[$this->p_userid] = GetMemInfo($this->p_userid, $this->user_info_cols); } # awc_pdie($mem_Info); $hook_user_info = array(); $hook_user_info['name'] = $this->p_user; $hook_user_info['id'] = $this->p_userid; foreach ($mem_Info as $id => $value) { // if($id != 2) awc_pdie(">". $id); //die("kk"); // if($id == 0){ if ($this->p_userid == 0) { // die(); $AvatraSize = explode('x', $this->cf_AvatraSize); $mem_Info[0]['m_adv'] = "{$this->wgScriptPath}" . awcForumPath . "/images/avatars/avatar_guest.gif"; $mem_Info[0]['m_advw'] = $AvatraSize[0]; $mem_Info[0]['m_advh'] = $AvatraSize[1]; $mem_Info[0]['edit_count'] = 0; $mem_Info[0]['m_posts'] = 0; $mem_Info[0]['m_topics'] = 0; $mem_Info[0]['edit_count'] = 0; $mem_Info[0]['member_title'] = ''; $to_skin['member_title'] = ''; $to_skin['edit_count'] = 0; $to_skin['m_posts'] = 0; $to_skin['m_topics'] = 0; $to_skin['m_advh'] = $mem_Info[0]['m_advh']; $to_skin['m_advw'] = $mem_Info[0]['m_advw']; $to_skin['m_adv'] = $mem_Info[0]['m_adv']; $tplt_info['group'] = ''; $to_skin['m_sig'] = ''; $mem_Info[0]['group'] = isset($mem_Info[$this->p_userid]['group']) ? $mem_Info[$this->p_userid]['group'] : ''; $mem_Info[0]['m_sig'] = ''; // if($this->p_post != 'guest') die($this->p_userid); } else { if (!isset($mem_Info[$id]['cached'])) { $mem_Info[$id]['cached'] = true; if ($mem_Info[$id]['m_id'] == $this->p_userid) { //$mem_Info[0]['member_title'] = ''; mem_post_title // die($this->p_userid); if ($this->viewing_mem_info['displaysigs'] == 1 or $awcUser->guest == '0' and $this->cf_SigGuestView) { $m_sig = $mem_Info[$id]['m_sig']; $m_sig = self::phase_post($m_sig, '', false); $to_skin['m_sig'] = $m_sig; if (isset($mem_Info[$id]['m_sig'])) { $to_skin['m_sig'] = str_replace('<a href=', '<a target="blank" href=', $m_sig); } if ($this->viewing_mem_info['displaysigonce'] == 1 and !isset($mem_Info[$id]['show_sig'])) { $mem_Info[$id]['show_sig'] = true; } elseif ($this->viewing_mem_info['displaysigonce'] == 1) { $to_skin['m_sig'] = null; } } else { $to_skin['m_sig'] = null; } $to_skin['m_adv'] = null; if ($this->viewing_mem_info['viewaadv'] == 1 || ($awcUser->guest == '0' and $this->cf_AdvatarGuestView)) { if (isset($mem_Info[$id]['m_adv']) and !empty($mem_Info[$id]['m_adv'])) { $to_skin['m_adv'] = $mem_Info[$id]['m_adv']; $to_skin['m_advw'] = $mem_Info[$id]['m_advw']; $to_skin['m_advh'] = $mem_Info[$id]['m_advh']; } elseif ($mem_Info[$id]['m_topics'] == '0' and $mem_Info[$id]['m_posts'] == '0') { $AvatraSize = explode('x', $this->cf_AvatraSize); $to_skin['m_adv'] = "{$this->wgScriptPath}" . awcForumPath . "images/avatars/avatar_guest.gif"; $to_skin['m_advw'] = $AvatraSize[0]; $to_skin['m_advh'] = $AvatraSize[1]; } else { $AvatraSize = explode('x', $this->cf_AvatraSize); $to_skin['m_adv'] = "{$this->wgScriptPath}" . awcForumPath . "images/avatars/avatar_default.gif"; $to_skin['m_advw'] = $AvatraSize[0]; $to_skin['m_advh'] = $AvatraSize[1]; } } $mem_Info[$id]['m_adv'] = $to_skin['m_adv']; // flip for caching $mem_Info[$id]['m_advw'] = $to_skin['m_advw']; // flip for caching $mem_Info[$id]['m_advh'] = $to_skin['m_advh']; // flip for caching $mem_Info[$id]['m_sig'] = $to_skin['m_sig']; // flip for caching if (!isset($mem_Info[$id]['m_topics']) or empty($mem_Info[$id]['m_topics'])) { $mem_Info[$id]['m_topics'] = '0'; } $to_skin['m_topics'] = $mem_Info[$id]['m_topics']; if (!isset($mem_Info[$id]['m_posts']) or empty($mem_Info[$id]['m_posts'])) { $mem_Info[$id]['m_posts'] = '0'; } $to_skin['m_posts'] = $mem_Info[$id]['m_posts']; if (!isset($mem_Info[$id]['edit_count']) or empty($mem_Info[$id]['edit_count'])) { $mem_Info[$id]['edit_count'] = '0'; } $to_skin['edit_count'] = $mem_Info[$id]['edit_count']; $tplt_info['group'] = $mem_Info[$id]['group']; // @added 2.5.8 if (!isset($this->mem_post_title[0])) { foreach ($this->mem_post_title as $memPostTitleID) { if ($mem_Info[$id]['m_posts'] >= $memPostTitleID['count']) { $tplt_info['member_title'] = $memPostTitleID['title']; $tplt_info['member_title_css'] = $memPostTitleID['css']; } } } else { $tplt_info['member_title'] = ''; $tplt_info['member_title_css'] = ''; } $mem_Info[$id]['member_title'] = $tplt_info['member_title']; $mem_Info[$id]['member_title_css'] = $tplt_info['member_title_css']; $to_skin['member_title'] = $tplt_info['member_title']; $to_skin['member_title_css'] = $tplt_info['member_title_css']; //- @added / 2.5.8 } } else { $to_skin['edit_count'] = isset($mem_Info[$this->p_userid]['edit_count']) ? $mem_Info[$this->p_userid]['edit_count'] : 0; $to_skin['m_posts'] = $mem_Info[$this->p_userid]['m_posts']; $to_skin['m_topics'] = $mem_Info[$this->p_userid]['m_topics']; $to_skin['m_advh'] = $mem_Info[$this->p_userid]['m_advh']; $to_skin['m_advw'] = $mem_Info[$this->p_userid]['m_advw']; $to_skin['m_adv'] = $mem_Info[$this->p_userid]['m_adv']; $tplt_info['group'] = $mem_Info[$this->p_userid]['group']; $tplt_info['member_title'] = isset($mem_Info[$this->p_userid]['member_title']) ? $mem_Info[$this->p_userid]['member_title'] : ''; $tplt_info['member_title_css'] = isset($mem_Info[$this->p_userid]['member_title_css']) ? $mem_Info[$this->p_userid]['member_title_css'] : ''; # die(); $to_skin['member_title'] = $tplt_info['member_title']; $to_skin['member_title_css'] = $tplt_info['member_title_css']; if ($this->viewing_mem_info['displaysigonce'] == 1) { $to_skin['m_sig'] = ''; } else { $to_skin['m_sig'] = $mem_Info[$this->p_userid]['m_sig']; } } } } $height_stuff['advar'] = $mem_Info[$this->p_userid]['m_advh'] + 15; $height_stuff['memtitle'] = $to_skin['member_title'] == '' ? 0 : 20; $height_stuff['wikicount'] = 20; $height_stuff['postcount'] = 20; $height_stuff['threadcount'] = 20; if (!isset($mem_Info[$this->p_userid]['m_topics']) or empty($mem_Info[$this->p_userid]['m_topics'])) { $height_stuff['threadcount'] = 0; } if (!isset($mem_Info[$this->p_userid]['m_posts']) or empty($mem_Info[$this->p_userid]['m_posts'])) { $height_stuff['postcount'] = 0; } if (!isset($mem_Info[$this->p_userid]['edit_count']) or empty($mem_Info[$this->p_userid]['edit_count'])) { $height_stuff['wikicount'] = 0; } $tplt_info['sig_display'] = $tplt->phase($word, $to_skin, 'sig_display'); $tplt_info['post_avatar'] = $tplt->phase($word, $to_skin, 'post_avatar'); $to_skin['url'] = awcsf_wiki_url . "Special:Contributions/{$this->p_user}"; $tplt_info['wikiedits_count_link'] = $this->showWEcount == '1' ? $tplt->phase($word, $to_skin, 'link_wikiedits') : null; $to_skin['url'] = awc_url . "search/memtopics/" . urlencode($this->p_user) . '/' . $this->p_userid; // $to_skin['url'] = awc_url ."search/memtopics/".$this->p_userid ; $tplt_info['topics_count_link'] = $this->showTcount == '1' ? $tplt->phase($word, $to_skin, 'link_threads') : null; $to_skin['url'] = awc_url . "search/memposts/" . urlencode($this->p_user) . '/' . $this->p_userid; // $to_skin['url'] = awc_url ."search/memposts/".$this->p_userid ; $tplt_info['post_count_link'] = $this->showPcount == '1' ? $tplt->phase($word, $to_skin, 'link_posts') : null; $tplt_info['mem_drop_num'] = $time_func_called; $tplt_info['user_name'] = "<a href=\"" . awc_url . "mem_profile/{$this->p_user}/{$this->p_userid}\" onmouseover=\"mopen('mem{$tplt_info['mem_drop_num']}')\" onmouseout=\"mclosetime()\">{$this->p_user}</a>"; $tplt_info['admin_lookup'] = (UserPerm == 10 and !$this->preview) ? '<a target="blank" href="' . awc_url . 'admin/mem_lookup/' . $this->p_user . '/' . $this->p_userid . '">*</a>' : ''; $to_skin['url'] = awc_url . "mem_profile/{$this->p_user}/{$this->p_userid}"; $tplt_info['profile_link'] = $tplt->phase($word, $to_skin, 'link_profile'); $tplt_info['user_options'] = isset($to_skin['user_options']) ? $to_skin['user_options'] . '<br />' : null; if ($this->p_userid == 0) { //if($this->show_guest_ip == 0) if (UserPerm == 10 and !$this->preview) { $tplt_info['user_name'] = "<a href='" . awcsf_wiki_url . "Special:Contributions/{$this->p_user}'>{$this->p_user}</a>"; } elseif ($this->show_guest_ip == 0) { $tplt_info['user_name'] = get_awcsforum_word('word_guest'); } $tplt_info['post_count_link'] = null; $tplt_info['profile_link'] = null; $tplt_info['user_options'] = null; $tplt_info['topics_count_link'] = null; $tplt_info['group'] = null; $tplt_info['member_title'] = ''; $tplt_info['member_title_css'] = ''; if (UserPerm == 10 and !$this->preview) { } elseif ($this->show_guest_ip == 0) { $tplt_info['wikiedits_count_link'] = null; } } if (!isset($tplt_info['member_title'])) { $tplt_info['member_title'] = ''; $tplt_info['member_title_css'] = ''; } $m_pm = ($this->pm_enable == '1' and $this->guest == false) ? $word['word_send'] . ' <a href="' . awc_url . 'member_options/pmnew/' . $this->p_user . '/' . $this->p_id . '">' . $word['word_pm'] . '</a>' : null; $to_skin['url'] = awc_url . 'member_options/pmnew/' . $this->p_user . '/' . $this->p_id; $tplt_info['m_pm'] = $tplt->phase($word, $to_skin, 'link_send_pm_to'); $tplt_info['date'] = null; $info['date'] = awcsforum_funcs::convert_date($this->p_date, "l") . " "; if (!$this->preview) { $tplt_info['date'] = $tplt->phase($word, $info, 'post_date_link'); } if ($this->single_post or $pm or $this->preview) { $tplt_info['date'] = $info['date']; } $info['post_title'] = awcsforum_funcs::awc_html_entity_decode($this->p_title); #$info['post_title'] = $this->p_title ; $tplt_info['post_title'] = (!empty($this->p_title) and $this->p_title != $this->t_name) ? $tplt->phase($word, $info, 'post_title_row') : ''; if ($time_func_called % 2) { $tplt_info['row_class'] = 'post0'; } else { $tplt_info['row_class'] = 'post1'; } /* if ($this->bcmod) { //$tplt_info['row_class'] = 'post' . bcmod($time_func_called, '2') ; } else { //$tplt_info['row_class'] = 'post' ; } */ if ($pm == false) { if (!empty($this->p_editwho)) { $info['p_editdate'] = awcsforum_funcs::convert_date($this->p_editdate, "l"); $info['p_editwho'] = $this->p_editwho; $tplt_info['post_edited_on'] = $tplt->phase($word, $info, 'post_edited_on'); } else { $tplt_info['post_edited_on'] = null; } $edit_buttons['edit_buttons'] = null; if (UserPerm >= 2 and !$this->preview || CanDelete($this->p_user)) { if ($this->t_ann != "1" || UserPerm == 10) { $url = awc_url . 'mod/mod_post/delete/' . $this->p_id; #$url = awc_url .'post/delete_post/id' . $this->p_id ; $t = $word['thread_deletepost'] . ' ? '; $t = str_replace(array(chr(10), chr(13), "'"), '', $t); $info['url'] = $url; $info['msg'] = $t; $edit_buttons['edit_buttons'] .= $tplt->phase($word, $info, 'post:delete_post'); } } #if ( (UserPerm >= 2 || (CanDelete($this->p_user)) AND # $this->only_one_post == false) ) { # die(">". $this->only_one_post); if (UserPerm >= 2 and !$this->preview and !$this->single_post || CanDelete($this->p_user) and $time_func_called == 1 and !$this->has_limit) { if ($this->t_ann != "1" || UserPerm == 10) { $url = awc_url . 'mod/mod_thread/delete/' . $this->t_id; $t = $word['thread_deletethread'] . ' ? \\n' . $word['deleteThread']; $t = str_replace(array(chr(10), chr(13), "'"), '', $t); $info['url'] = $url; $info['msg'] = $t; $edit_buttons['edit_buttons'] .= $tplt->phase($word, $info, 'post:delete_thread'); } } // die(">". $this->t_pollopen); if (!$this->preview and $time_func_called == 1 and !$this->single_post) { if ($this->polls_enabled == '1' and $this->p_userid != '0' and (!$this->t_poll or $this->multi_polls == '1') and UserPerm >= 10 || $this->uID == $this->p_userid) { $word['poll'] = get_awcsforum_word('word_add_poll'); $info['url'] = awc_url . "post/add_poll/{$this->t_id}/{$this->f_id}"; $edit_buttons['edit_buttons'] .= $tplt->phase($word, $info, 'post:poll'); } } if (UserPerm >= 2 and !$this->preview and $time_func_called != 1) { $info['url'] = awc_url . 'mod/mod_thread/splitmerge_get/' . $this->p_id; $edit_buttons['edit_buttons'] .= $tplt->phase($word, $info, 'post:spltmerge_button'); } if (!$this->preview and $time_func_called == 1 and CanEdit($this->p_user) || UserPerm >= 2) { $info['url'] = awc_url . 'post/GetEditThread/id' . $this->p_id; $edit_buttons['edit_buttons'] .= $tplt->phase($word, $info, 'post:edit_button'); } if (!$this->preview and $time_func_called != 1 and CanEdit($this->p_user) || UserPerm >= 2) { $info['url'] = awc_url . 'post/GetEdit/id' . $this->p_id; $edit_buttons['edit_buttons'] .= $tplt->phase($word, $info, 'post:edit_button'); } // forum-wiki-perm if (($this->canPost and !$this->preview and $this->t_status == "0" and $this->forum_perm_can_post) || UserPerm >= 2) { $info['url'] = awc_url . "post/quote/id" . $this->p_id; $edit_buttons['edit_buttons'] .= $tplt->phase($word, $info, 'post:quote_button'); } # $tplt_info['edit_buttons'] = $tplt->phase($word, $edit_buttons, 'edit_buttons_row'); } $tplt_info['edit_buttons'] = $tplt->phase($word, $edit_buttons, 'edit_buttons_row'); /* if($this->preview){ $tplt_info['edit_buttons'] = null; } else { $tplt_info['edit_buttons'] = $tplt->phase($word, $edit_buttons, 'edit_buttons_row'); } */ # crap! need to find a way to fill the height of the post-text, work-around $add = 0; // 2.5.8 foreach ($height_stuff as $item => $number) { $add = $add + $number; } $tplt_info['table_height'] = $add; //($to_skin['m_adv'] == null) ? '65' : ($to_skin['m_advh'] + 65); // 2.5.8 $tplt_info['post_height'] = $tplt_info['table_height'] - 10; $tplt_info['colspan'] = strlen($edit_buttons['edit_buttons']) > 0 ? ' ' : ' width="100%" colspan="2" '; $post = $this->p_post; $tplt_info['post'] = self::phase_post($post, $this->p_id); $tplt_info['p_id'] = $this->p_id; $tplt_info['pID'] = $this->p_id; wfRunHooks('awcsforum_post_render_display', array(&$tplt_info, $hook_user_info)); // 2.5.6 $post_table = $tplt->phase($word, $tplt_info, 'post_table'); // if($time_func_called == 5) $post_table = '<a name="last"></a>' . $post_table; return $post_table; }
function delete_thread() { global $wgOut, $awc_tables, $ForumStat, $awcs_forum_config; if (!CanDelete()) { $wgOut->loginToUse(); return; } if (isset($awcs_forum_config->cf_add_post_text_to_wiki) and $awcs_forum_config->cf_add_post_text_to_wiki == '1') { require_once awc_dir . 'includes/to_wiki_dbase.php'; $ws = new awcs_forum_wikisearch_cls(); } $dbw = wfGetDB(DB_MASTER); $dbr = wfGetDB(DB_SLAVE); $fID = null; $threads = 0; $posts = 0; foreach ($this->tID as $id) { ++$threads; $sql = "SELECT t.t_ann, t.t_forumid, t.t_topics, t.t_starterid, t.t_wiki_pageid \n FROM {$awc_tables['awc_f_threads']} t\n WHERE t.t_id={$id} LIMIT 1"; $res = $dbr->query($sql); $r = $dbr->fetchRow($res); $dbr->freeResult($res); $fID = $r['t_forumid']; $page_ID = $r['t_wiki_pageid']; $t_starterid = $r['t_starterid']; $t_ann = $r['t_ann']; if ($t_ann == "1" and UserPerm != 10) { $wgOut->loginToUse(); return; } if ($fID == null or $fID == '') { return awcs_forum_error('problem_deleting_thread'); } $user_get = array(); $user_get[] = 'm_topics'; $user_get[] = 'm_idname'; $n = GetMemInfo($t_starterid, $user_get); unset($user_get); $m_name = $n['name']; if ($m_name) { $dbw->update('awc_f_mems', array('m_topics' => $n['m_topics'] - 1), array('m_id' => $t_starterid), ''); } unset($user_get, $n); $user_get = array(); $user_get[] = 'm_posts'; $user_get[] = 'm_idname'; # get members how created a post in thread... this is abit half-assed, but it works - $sql = "SELECT p_userid FROM {$awc_tables['awc_f_posts']} WHERE p_threadid={$id} LIMIT 1"; $res = $dbr->query($sql); while ($r = $dbr->fetchObject($res)) { if (isset($r->p_userid)) { if (isset($ForumStat)) { $ForumStat->stat_posts(false); } ++$posts; // use this for the forums post count math... $p_userid = $r->p_userid; $n = GetMemInfo($p_userid, $user_get); $name = $n['name']; if ($name) { $dbw->update('awc_f_mems', array('m_posts' => $n['m_posts'] - 1), array('m_id' => $p_userid), ''); } } } $posts = $posts - 1; // half/assed - top loop create one too many if (isset($ForumStat)) { $ForumStat->stat_posts(1); } // half/assed - top loop create one too many $dbr->freeResult($res); unset($user_get, $n); if (isset($awcs_forum_config->cf_add_post_text_to_wiki) and $awcs_forum_config->cf_add_post_text_to_wiki == '1') { $ws->pageID = $page_ID; $ws->delete_thread(); } if (isset($ForumStat)) { $ForumStat->stat_threads(false); } } $dbw->query("DELETE FROM {$awc_tables['awc_f_posts']} WHERE p_threadid IN (" . implode(',', $this->tID) . ")"); $dbw->query("DELETE FROM {$awc_tables['awc_f_threads']} WHERE t_id IN (" . implode(',', $this->tID) . ")"); $dbw->query("DELETE FROM {$awc_tables['awc_f_anns']} WHERE ann_id IN (" . implode(',', $this->tID) . ")"); $dbw->query("DELETE FROM {$awc_tables['awc_f_watchthreads']} WHERE wtcht_thread_id IN (" . implode(',', $this->tID) . ")"); // polls ??? $dbw->query("UPDATE {$awc_tables['awc_f_forums']} \n SET f_threads = f_threads - {$threads},\n f_replies = f_replies - {$posts}\n WHERE f_id={$fID}"); unset($dbr, $r, $res); $this->update_forum_last_thread($fID); $info['msg'] = 'thread_has_been_deleted'; $info['url'] = awc_url . "sf/id" . $fID; return awcf_redirect($info); }