function qa_question_set_selchildid($userid, $handle, $cookieid, $oldquestion, $selchildid, $answers) { $oldselchildid = $oldquestion['selchildid']; qa_db_post_set_selchildid($oldquestion['postid'], isset($selchildid) ? $selchildid : null); qa_db_points_update_ifuser($oldquestion['userid'], 'aselects'); if (isset($oldselchildid)) { if (isset($answers[$oldselchildid])) { qa_db_points_update_ifuser($answers[$oldselchildid]['userid'], 'aselecteds'); qa_report_event('a_unselect', $userid, $handle, $cookieid, array('parentid' => $oldquestion['postid'], 'postid' => $oldselchildid)); } } if (isset($selchildid)) { $answer = $answers[$selchildid]; qa_db_points_update_ifuser($answer['userid'], 'aselecteds'); if (isset($answer['notify']) && !qa_post_is_by_user($answer, $userid, $cookieid)) { require_once QA_INCLUDE_DIR . 'qa-app-emails.php'; require_once QA_INCLUDE_DIR . 'qa-app-options.php'; require_once QA_INCLUDE_DIR . 'qa-util-string.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $blockwordspreg = qa_get_block_words_preg(); $sendtitle = qa_block_words_replace($oldquestion['title'], $blockwordspreg); $sendcontent = qa_viewer_text($answer['content'], $answer['format'], array('blockwordspreg' => $blockwordspreg)); qa_send_notification($answer['userid'], $answer['notify'], @$answer['handle'], qa_lang('emails/a_selected_subject'), qa_lang('emails/a_selected_body'), array('^s_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'), '^q_title' => $sendtitle, '^a_content' => $sendcontent, '^url' => qa_path(qa_q_request($oldquestion['postid'], $sendtitle), null, qa_opt('site_url'), null, qa_anchor('A', $selchildid)))); } qa_report_event('a_select', $userid, $handle, $cookieid, array('parentid' => $oldquestion['postid'], 'postid' => $selchildid)); } }
function q_list($q_list) { if (count(@$q_list['qs']) && qa_opt('mouseover_content_on')) { // first check it is not an empty list and the feature is turned on // Collect the question ids of all items in the question list (so we can do this in one DB query) $postids = array(); foreach ($q_list['qs'] as $question) { if (isset($question['raw']['postid'])) { $postids[] = $question['raw']['postid']; } } if (count($postids)) { // Retrieve the content for these questions from the database and put into an array $result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids); $postinfo = qa_db_read_all_assoc($result, 'postid'); // Get the regular expression fragment to use for blocked words and the maximum length of content to show $blockwordspreg = qa_get_block_words_preg(); $maxlength = qa_opt('mouseover_content_max_len'); // Now add the popup to the title for each question foreach ($q_list['qs'] as $index => $question) { $thispost = @$postinfo[$question['raw']['postid']]; if (isset($thispost)) { $text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg)); $text = qa_shorten_string_line($text, $maxlength); $q_list['qs'][$index]['title'] = '<SPAN TITLE="' . qa_html($text) . '">' . @$question['title'] . '</SPAN>'; } } } } qa_html_theme_base::q_list($q_list); // call back through to the default function }
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { require_once QA_INCLUDE_DIR . 'db/selects.php'; $populartags = qa_db_single_select(qa_db_popular_tags_selectspec(0, (int) qa_opt('tag_cloud_count_tags'))); $maxcount = reset($populartags); // $themeobject->output(sprintf('<h2 style="margin-top: 0; padding-top: 0;">%s</h2>', qa_lang_html('main/popular_tags'))); // $themeobject->output('<div style="font-size: 10px;">'); $themeobject->output(sprintf('<div class="panel panel-primary" style="padding: 0;"><div class="panel-heading"><h3 class="panel-title">%s</h3></div>', qa_lang_html('main/popular_tags'))); $themeobject->output('<div class="panel-body">'); $maxsize = qa_opt('tag_cloud_font_size'); $minsize = qa_opt('tag_cloud_minimal_font_size'); $scale = qa_opt('tag_cloud_size_popular'); $blockwordspreg = qa_get_block_words_preg(); foreach ($populartags as $tag => $count) { $matches = qa_block_words_match_all($tag, $blockwordspreg); if (empty($matches)) { if ($scale) { $size = number_format($maxsize * $count / $maxcount, 1); if ($size < $minsize) { $size = $minsize; } } else { $size = $maxsize; } $themeobject->output(sprintf('<a href="%s" style="font-size: %dpx; vertical-align: baseline;">%s</a>', qa_path_html('tag/' . $tag), $size, qa_html($tag))); } } // $themeobject->output('</div>'); $themeobject->output('</div></div>'); }
public function q_list($q_list) { if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) { // first check it is not an empty list and the feature is turned on // Collect the question ids of all items in the question list (so we can do this in one DB query) $postids = array(); foreach ($q_list['qs'] as $question) { if (isset($question['raw']['postid'])) { $postids[] = $question['raw']['postid']; } } if (!empty($postids)) { // Retrieve the content for these questions from the database and put into an array fetching // the minimal amount of characters needed to determine the string should be shortened or not $maxlength = qa_opt('mouseover_content_max_len'); $result = qa_db_query_sub('SELECT postid, LEFT(content, #) content, format FROM ^posts WHERE postid IN (#)', $maxlength + 1, $postids); $postinfo = qa_db_read_all_assoc($result, 'postid'); // Get the regular expression fragment to use for blocked words and the maximum length of content to show $blockwordspreg = qa_get_block_words_preg(); // Now add the popup to the title for each question foreach ($q_list['qs'] as $index => $question) { if (isset($postinfo[$question['raw']['postid']])) { $thispost = $postinfo[$question['raw']['postid']]; $text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg)); $text = qa_shorten_string_line($text, $maxlength); $title = isset($question['title']) ? $question['title'] : ''; $q_list['qs'][$index]['title'] = sprintf('<span title="%s">%s</span>', qa_html($text), $title); } } } } qa_html_theme_base::q_list($q_list); // call back through to the default function }
public function q_list($q_list) { if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) { // first check it is not an empty list and the feature is turned on // Collect the question ids of all items in the question list (so we can do this in one DB query) $postids = array(); foreach ($q_list['qs'] as $question) { if (isset($question['raw']['postid'])) { $postids[] = $question['raw']['postid']; } } if (!empty($postids)) { // Retrieve the content for these questions from the database $maxlength = qa_opt('mouseover_content_max_len'); $result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids); $postinfo = qa_db_read_all_assoc($result, 'postid'); // Get the regular expression fragment to use for blocked words and the maximum length of content to show $blockwordspreg = qa_get_block_words_preg(); // Now add the popup to the title for each question foreach ($q_list['qs'] as $index => $question) { if (isset($postinfo[$question['raw']['postid']])) { $thispost = $postinfo[$question['raw']['postid']]; $text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg)); $text = preg_replace('/\\s+/', ' ', $text); // Remove duplicated blanks, new line characters, tabs, etc $text = qa_shorten_string_line($text, $maxlength); $title = isset($question['title']) ? $question['title'] : ''; $q_list['qs'][$index]['title'] = $this->getHtmlTitle(qa_html($text), $title); } } } } parent::q_list($q_list); // call back through to the default function }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; $widget_opt = @$themeobject->current_widget['param']['options']; if (@$themeobject->current_widget['param']['locations']['show_title']) { $themeobject->output('<h3 class="widget-title">' . qa_lang('cleanstrap/tags') . '<a href="' . qa_path_html('tags') . '">' . qa_lang('cleanstrap/view_all') . '</a></h3>'); } $to_show = (int) $widget_opt['cs_tags_count']; $populartags = qa_db_single_select(qa_db_popular_tags_selectspec(0, !empty($to_show) ? $to_show : 20)); reset($populartags); $themeobject->output('<div class="ra-tags-widget clearfix">'); $blockwordspreg = qa_get_block_words_preg(); foreach ($populartags as $tag => $count) { if (count(qa_block_words_match_all($tag, $blockwordspreg))) { continue; } // skip censored tags $themeobject->output('<a href="' . qa_path_html('tag/' . $tag) . '" class="widget-tag">' . qa_html($tag) . '<span>' . $count . '</span></a>'); } $themeobject->output('</div>'); }
function qa_q_request($questionid, $title) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } require_once QA_INCLUDE_DIR . 'qa-app-options.php'; require_once QA_INCLUDE_DIR . 'qa-util-string.php'; $title = qa_block_words_replace($title, qa_get_block_words_preg()); $words = qa_string_to_words($title, true, false, false); $wordlength = array(); foreach ($words as $index => $word) { $wordlength[$index] = qa_strlen($word); } $remaining = qa_opt('q_urls_title_length'); if (array_sum($wordlength) > $remaining) { arsort($wordlength, SORT_NUMERIC); // sort with longest words first foreach ($wordlength as $index => $length) { if ($remaining > 0) { $remaining -= $length; } else { unset($words[$index]); } } } $title = implode('-', $words); if (qa_opt('q_urls_remove_accents')) { $title = qa_string_remove_accents($title); } return (int) $questionid . '/' . $title; }
function qa_page_q_question_view($question, $parentquestion, $closepost, $usershtml, $formrequested) { $questionid = $question['postid']; $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); $htmloptions = qa_post_html_defaults('Q', true); $htmloptions['answersview'] = false; // answer count is displayed separately so don't show it here $htmloptions['avatarsize'] = qa_opt('avatar_q_page_q_size'); $q_view = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, $htmloptions); $q_view['main_form_tags'] = 'METHOD="POST" ACTION="' . qa_self_html() . '"'; // Buttons for operating on the question if (!$formrequested) { // don't show if another form is currently being shown on page $clicksuffix = ' onClick="qa_show_waiting_after(this, false);"'; // add to operations that write to database $buttons = array(); if ($question['editbutton']) { $buttons['edit'] = array('tags' => 'NAME="q_doedit"', 'label' => qa_lang_html('question/edit_button'), 'popup' => qa_lang_html('question/edit_q_popup')); } $hascategories = qa_using_categories(); if ($question['retagcatbutton']) { $buttons['retagcat'] = array('tags' => 'NAME="q_doedit"', 'label' => qa_lang_html($hascategories ? 'question/recat_button' : 'question/retag_button'), 'popup' => qa_lang_html($hascategories ? qa_using_tags() ? 'question/retag_cat_popup' : 'question/recat_popup' : 'question/retag_popup')); } if ($question['flagbutton']) { $buttons['flag'] = array('tags' => 'NAME="q_doflag"' . $clicksuffix, 'label' => qa_lang_html($question['flagtohide'] ? 'question/flag_hide_button' : 'question/flag_button'), 'popup' => qa_lang_html('question/flag_q_popup')); } if ($question['unflaggable']) { $buttons['unflag'] = array('tags' => 'NAME="q_dounflag"' . $clicksuffix, 'label' => qa_lang_html('question/unflag_button'), 'popup' => qa_lang_html('question/unflag_popup')); } if ($question['clearflaggable']) { $buttons['clearflags'] = array('tags' => 'NAME="q_doclearflags"' . $clicksuffix, 'label' => qa_lang_html('question/clear_flags_button'), 'popup' => qa_lang_html('question/clear_flags_popup')); } if ($question['closeable']) { $buttons['close'] = array('tags' => 'NAME="q_doclose"', 'label' => qa_lang_html('question/close_button'), 'popup' => qa_lang_html('question/close_q_popup')); } if ($question['reopenable']) { $buttons['reopen'] = array('tags' => 'NAME="q_doreopen"' . $clicksuffix, 'label' => qa_lang_html('question/reopen_button')); } if ($question['moderatable']) { $buttons['approve'] = array('tags' => 'NAME="q_doapprove"' . $clicksuffix, 'label' => qa_lang_html('question/approve_button')); $buttons['reject'] = array('tags' => 'NAME="q_doreject"' . $clicksuffix, 'label' => qa_lang_html('question/reject_button')); } if ($question['hideable']) { $buttons['hide'] = array('tags' => 'NAME="q_dohide"' . $clicksuffix, 'label' => qa_lang_html('question/hide_button'), 'popup' => qa_lang_html('question/hide_q_popup')); } if ($question['reshowable']) { $buttons['reshow'] = array('tags' => 'NAME="q_doreshow"' . $clicksuffix, 'label' => qa_lang_html('question/reshow_button')); } if ($question['deleteable']) { $buttons['delete'] = array('tags' => 'NAME="q_dodelete"' . $clicksuffix, 'label' => qa_lang_html('question/delete_button'), 'popup' => qa_lang_html('question/delete_q_popup')); } if ($question['claimable']) { $buttons['claim'] = array('tags' => 'NAME="q_doclaim"' . $clicksuffix, 'label' => qa_lang_html('question/claim_button')); } if ($question['answerbutton']) { // don't show if shown by default $buttons['answer'] = array('tags' => 'NAME="q_doanswer" ID="q_doanswer" onClick="return qa_toggle_element(\'anew\')"', 'label' => qa_lang_html('question/answer_button'), 'popup' => qa_lang_html('question/answer_q_popup')); } if ($question['commentbutton']) { $buttons['comment'] = array('tags' => 'NAME="q_docomment" onClick="return qa_toggle_element(\'c' . $questionid . '\')"', 'label' => qa_lang_html('question/comment_button'), 'popup' => qa_lang_html('question/comment_q_popup')); } $q_view['form'] = array('style' => 'light', 'buttons' => $buttons, 'hidden' => array('qa_click' => '')); } // Information about the question of the answer that this question follows on from (or a question directly) if (isset($parentquestion)) { $q_view['follows'] = array('label' => qa_lang_html($question['parentid'] == $parentquestion['postid'] ? 'question/follows_q' : 'question/follows_a'), 'title' => qa_html(qa_block_words_replace($parentquestion['title'], qa_get_block_words_preg())), 'url' => qa_q_path_html($parentquestion['postid'], $parentquestion['title'], false, $question['parentid'] == $parentquestion['postid'] ? 'Q' : 'A', $question['parentid'])); } // Information about the question that this question is a duplicate of (if appropriate) if (isset($closepost)) { if ($closepost['basetype'] == 'Q') { $q_view['closed'] = array('label' => qa_lang_html('question/closed_as_duplicate'), 'content' => qa_html(qa_block_words_replace($closepost['title'], qa_get_block_words_preg())), 'url' => qa_q_path_html($closepost['postid'], $closepost['title'])); } elseif ($closepost['type'] == 'NOTE') { $viewer = qa_load_viewer($closepost['content'], $closepost['format']); $q_view['closed'] = array('label' => qa_lang_html('question/closed_with_note'), 'content' => $viewer->get_html($closepost['content'], $closepost['format'], array('blockwordspreg' => qa_get_block_words_preg()))); } } // Extra value display if (strlen(@$question['extra']) && qa_opt('extra_field_active') && qa_opt('extra_field_display')) { $q_view['extra'] = array('label' => qa_html(qa_opt('extra_field_label')), 'content' => qa_html(qa_block_words_replace($question['extra'], qa_get_block_words_preg()))); } return $q_view; }
$field['error'] = qa_html(@$errors['content']); $custom = qa_opt('show_custom_ask') ? trim(qa_opt('custom_ask')) : ''; $qa_content['form'] = array('tags' => 'name="ask" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('custom' => array('type' => 'custom', 'note' => $custom), 'title' => array('label' => qa_lang_html('question/q_title_label'), 'tags' => 'name="title" id="title" autocomplete="off"', 'value' => qa_html(@$in['title']), 'error' => qa_html(@$errors['title'])), 'similar' => array('type' => 'custom', 'html' => '<span id="similar"></span>'), 'content' => $field), 'buttons' => array('ask' => array('tags' => 'onclick="qa_show_waiting_after(this, false); ' . (method_exists($editor, 'update_script') ? $editor->update_script('content') : '') . '"', 'label' => qa_lang_html('question/ask_button'))), 'hidden' => array('editor' => qa_html($editorname), 'code' => qa_get_form_security_code('ask'), 'doask' => '1')); if (!strlen($custom)) { unset($qa_content['form']['fields']['custom']); } if (qa_opt('do_ask_check_qs') || qa_opt('do_example_tags')) { $qa_content['script_rel'][] = 'qa-content/qa-ask.js?' . QA_VERSION; $qa_content['form']['fields']['title']['tags'] .= ' onchange="qa_title_change(this.value);"'; if (strlen(@$in['title'])) { $qa_content['script_onloads'][] = 'qa_title_change(' . qa_js($in['title']) . ');'; } } if (isset($followanswer)) { $viewer = qa_load_viewer($followanswer['content'], $followanswer['format']); $field = array('type' => 'static', 'label' => qa_lang_html('question/ask_follow_from_a'), 'value' => $viewer->get_html($followanswer['content'], $followanswer['format'], array('blockwordspreg' => qa_get_block_words_preg()))); qa_array_insert($qa_content['form']['fields'], 'title', array('follows' => $field)); } if (qa_using_categories() && count($categories)) { $field = array('label' => qa_lang_html('question/q_category_label'), 'error' => qa_html(@$errors['categoryid'])); qa_set_up_category_field($qa_content, $field, 'category', $categories, $in['categoryid'], true, qa_opt('allow_no_sub_category')); if (!qa_opt('allow_no_category')) { // don't auto-select a category even though one is required $field['options'][''] = ''; } qa_array_insert($qa_content['form']['fields'], 'content', array('category' => $field)); } if (qa_opt('extra_field_active')) { $field = array('label' => qa_html(qa_opt('extra_field_prompt')), 'tags' => 'name="extra"', 'value' => qa_html(@$in['extra']), 'error' => qa_html(@$errors['extra'])); qa_array_insert($qa_content['form']['fields'], null, array('extra' => $field)); }
function qa_message_html_defaults() { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } return array('whenview' => qa_opt('show_when_created'), 'whoview' => true, 'avatarsize' => qa_opt('avatar_message_list_size'), 'blockwordspreg' => qa_get_block_words_preg(), 'showurllinks' => qa_opt('show_url_links'), 'linksnewwindow' => qa_opt('links_in_new_window'), 'fulldatedays' => qa_opt('show_full_date_days')); }
function q_list($q_list) { if (isset($q_list['qs'])) { if (qa_opt('cs_enable_except')) { // first check it is not an empty list and the feature is turned on // Collect the question ids of all items in the question list (so we can do this in one DB query) $postids = array(); foreach ($q_list['qs'] as $question) { if (isset($question['raw']['postid'])) { $postids[] = $question['raw']['postid']; } } if (count($postids)) { // Retrieve the content for these questions from the database and put into an array //$result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids); //$postinfo = qa_db_read_all_assoc($result, 'postid'); //cache and apply keys to array now that I can't use array key argument in qa_db_read_all_assoc $posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids)); $postinfo = array(); foreach ($posts as $qitem) { $postinfo[$qitem['postid']] = $qitem; } // Get the regular expression fragment to use for blocked words and the maximum length of content to show $blockwordspreg = qa_get_block_words_preg(); $maxlength = qa_opt('cs_except_len'); // Now add the popup to the title for each question foreach ($q_list['qs'] as $index => $question) { $thispost = @$postinfo[$question['raw']['postid']]; if (isset($thispost)) { $text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg)); $text = qa_shorten_string_line($text, $maxlength); $q_list['qs'][$index]['content'] = '<SPAN>' . qa_html($text) . '</SPAN>'; } } } } $this->output('<div class="qa-q-list' . ($this->list_vote_disabled($q_list['qs']) ? ' qa-q-list-vote-disabled' : '') . ((bool) qa_opt('cs_enable_clean_qlist') ? ' clean' : '') . '">', ''); $this->q_list_items($q_list['qs']); $this->output('</div> <!-- END qa-q-list -->', ''); } else { $this->output(' <div class="no-items"> <h3 class="icon-sad">' . qa_lang_html('cleanstrap/no_users') . '</h3> <p>' . qa_lang_html('cleanstrap/no_results_detail') . '.</p> </div>'); } }
function qa_comment_create($userid, $handle, $cookieid, $content, $format, $text, $notify, $email, $question, $answer, $commentsfollows) { require_once QA_INCLUDE_DIR . 'qa-app-emails.php'; require_once QA_INCLUDE_DIR . 'qa-app-options.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-util-string.php'; $parent = isset($answer) ? $answer : $question; $postid = qa_db_post_create('C', $parent['postid'], $userid, isset($userid) ? null : $cookieid, qa_remote_ip_address(), null, $content, $format, null, qa_combine_notify_email($userid, $notify, $email), $question['categoryid']); qa_db_posts_calc_category_path($postid); if (!($question['hidden'] || @$answer['hidden'])) { // don't index comment if parent or parent of parent is hidden qa_post_index($postid, 'C', $question['postid'], null, $text, null); } qa_db_points_update_ifuser($userid, 'cposts'); qa_db_ccount_update(); // $senttoemail and $senttouserid ensure each user or email gets only one notification about an added comment, // even if they have several previous comments in the same thread and asked for notifications for the parent. // Still, if a person posted some comments as a registered user and some others anonymously, // they could get two emails about a subsequent comment. Shouldn't be much of a problem in practice. $senttoemail = array(); $senttouserid = array(); switch ($parent['basetype']) { case 'Q': $subject = qa_lang('emails/q_commented_subject'); $body = qa_lang('emails/q_commented_body'); $context = $parent['title']; break; case 'A': $subject = qa_lang('emails/a_commented_subject'); $body = qa_lang('emails/a_commented_body'); $context = qa_viewer_text($parent['content'], $parent['format']); break; } $blockwordspreg = qa_get_block_words_preg(); $sendhandle = isset($handle) ? $handle : qa_lang('main/anonymous'); $sendcontext = qa_block_words_replace($context, $blockwordspreg); $sendtext = qa_block_words_replace($text, $blockwordspreg); $sendtitle = qa_block_words_replace($question['title'], $blockwordspreg); $sendurl = qa_path(qa_q_request($question['postid'], $sendtitle), null, qa_opt('site_url'), null, qa_anchor($parent['basetype'], $parent['postid'])); if (isset($parent['notify']) && !qa_post_is_by_user($parent, $userid, $cookieid)) { $senduserid = $parent['userid']; $sendemail = @$parent['notify']; if (qa_email_validate($sendemail)) { $senttoemail[$sendemail] = true; } elseif (isset($senduserid)) { $senttouserid[$senduserid] = true; } qa_send_notification($senduserid, $sendemail, @$parent['handle'], $subject, $body, array('^c_handle' => $sendhandle, '^c_context' => $sendcontext, '^c_content' => $sendtext, '^url' => $sendurl)); } foreach ($commentsfollows as $comment) { if ($comment['basetype'] == 'C' && $comment['parentid'] == $parent['postid'] && !$comment['hidden']) { // find just those for this parent if (isset($comment['notify']) && !qa_post_is_by_user($comment, $userid, $cookieid)) { $senduserid = $comment['userid']; $sendemail = @$comment['notify']; if (qa_email_validate($sendemail)) { if (@$senttoemail[$sendemail]) { continue; } $senttoemail[$sendemail] = true; } elseif (isset($senduserid)) { if (@$senttouserid[$senduserid]) { continue; } $senttouserid[$senduserid] = true; } qa_send_notification($senduserid, $sendemail, @$comment['handle'], qa_lang('emails/c_commented_subject'), qa_lang('emails/c_commented_body'), array('^c_handle' => $sendhandle, '^c_context' => $sendcontext, '^c_content' => $sendtext, '^url' => $sendurl)); } } } qa_report_event('c_post', $userid, $handle, $cookieid, array('postid' => $postid, 'parentid' => $parent['postid'], 'parenttype' => $parent['basetype'], 'questionid' => $question['postid'], 'content' => $content, 'format' => $format, 'text' => $text, 'categoryid' => $question['categoryid'], 'notify' => $notify, 'email' => $email)); return $postid; }
function ra_post_list($type, $limit) { require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; $post = qa_db_query_sub('SELECT * FROM ^posts WHERE ^posts.type=$ ORDER BY ^posts.created DESC LIMIT #', $type, $limit); $output = '<ul class="question-list">'; while ($p = mysql_fetch_array($post)) { $p['title'] = qa_block_words_replace($p['title'], qa_get_block_words_preg(), '*'); $p['content'] = qa_block_words_replace($p['content'], qa_get_block_words_preg(), '*'); if ($type == 'Q') { $what = _ra_lang('asked'); } elseif ($type == 'A') { $what = _ra_lang('answered'); } elseif ('C') { $what = _ra_lang('commented'); } $handle = qa_post_userid_to_handle($p['userid']); $output .= '<li id="q-list-' . $p['postid'] . '" class="question-item">'; $output .= '<div class="pull-left avatar" data-handle="' . $handle . '" data-id="' . qa_handle_to_userid($handle) . '">' . ra_get_avatar($handle, 40) . '</div>'; $output .= '<div class="list-right">'; $output .= '<h5><a href="' . qa_path_html('user/' . $handle) . '">' . ra_name($handle) . '</a> ' . $what . '</h5>'; if ($type == 'Q') { $output .= '<p><a href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . qa_html($p['title']) . '</a></p>'; } elseif ($type == 'A') { $output .= '<p><a href="' . ra_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . substr(strip_tags($p['content']), 0, 50) . '</a></p>'; } else { $output .= '<p><a href="' . ra_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . substr(strip_tags($p['content']), 0, 50) . '</a></p>'; } if ($type == 'Q') { $output .= '<div class="counts"><div class="vote-count icon-chevron-up"><span>' . $p['netvotes'] . '</span></div>'; $output .= '<div class="ans-count icon-chat-4"><span>' . $p['acount'] . '</span></div></div>'; } elseif ($type == 'A') { $output .= '<div class="counts"><div class="vote-count icon-chevron-up"><span>' . $p['netvotes'] . '</span></div>'; } $output .= '</div>'; $output .= '</li>'; } $output .= '</ul>'; echo $output; }
function qw_notify_users_by_email($event, $postid, $userid, $effecteduserid, $params) { if (!!$effecteduserid) { //get the working user data $logged_in_handle = qa_get_logged_in_handle(); $logged_in_user_name = qw_get_name_from_userid($userid); $logged_in_user_name = !!$logged_in_user_name ? $logged_in_user_name : $logged_in_handle; $name = qw_get_name_from_userid($effecteduserid); switch ($event) { case 'a_post': case 'related': $parent = isset($params['parent']) ? $params['parent'] : ""; if (!!$parent) { $name = !!$name ? $name : $parent['handle']; $email = $parent['email']; $handle = $parent['handle']; } else { //seems proper values are not available return; } break; case 'c_post': case 'q_reshow': case 'a_reshow': case 'c_reshow': case 'a_select': case 'q_vote_up': case 'q_vote_down': case 'a_vote_up': case 'a_vote_down': case 'q_favorite': case 'u_favorite': case 'u_message': case 'u_wall_post': case 'u_level': case 'q_post_user_fl': case 'q_post_tag_fl': case 'q_post_cat_fl': //this is because we wont have the $parent['email'] for each effected userids when a these selected events occurs $user_details = qw_get_user_details_from_userid($effecteduserid); $handle = $user_details['handle']; $name = !!$name ? $name : $user_details['handle']; $email = $user_details['email']; break; case 'q_approve': case 'q_reject': $oldquestion = $params['oldquestion']; $handle = $oldquestion['handle']; $name = !!$name ? $name : $oldquestion['handle']; $email = $oldquestion['email']; break; case 'a_approve': case 'a_reject': $oldanswer = $params['oldanswer']; $handle = $oldquestion['handle']; $name = !!$name ? $name : $oldanswer['handle']; $email = $oldanswer['email']; break; case 'c_approve': case 'c_reject': $oldcomment = $params['oldcomment']; $handle = $oldcomment['handle']; $name = !!$name ? $name : $oldcomment['handle']; $email = $oldcomment['email']; break; default: break; } include_once QA_INCLUDE_DIR . 'qa-util-string.php'; $notifying_user['userid'] = $effecteduserid; $notifying_user['name'] = $name; $notifying_user['email'] = $email; $notifying_user['handle'] = isset($handle) ? $handle : qa_lang('main/anonymous'); //consider only first 50 characters for saving notification if ($event === 'u_message') { $content = isset($params['message']) && !empty($params['message']) ? $params['message'] : ""; $title = ""; $canreply = !(qa_get_logged_in_flags() & QA_USER_FLAGS_NO_MESSAGES); $url = qa_path_absolute($canreply ? 'message/' . $logged_in_handle : 'user/' . $logged_in_handle); } else { if ($event === 'u_wall_post') { $content = isset($params['text']) && !empty($params['text']) ? $params['text'] : ""; if (!!$content) { $blockwordspreg = qa_get_block_words_preg(); $content = qa_block_words_replace($content, $blockwordspreg); } $title = ""; $url = qa_path_absolute('user/' . $params['handle'] . '/wall', null, null); } else { if ($event === 'u_level') { $title = ""; $url = qa_path_absolute('user/' . $params['handle']); $old_level = $params['oldlevel']; $new_level = $params['level']; if ($new_level < $old_level) { return; } $approved_only = ""; if ($new_level == QA_USER_LEVEL_APPROVED && $old_level < QA_USER_LEVEL_APPROVED) { $approved_only = true; } else { $approved_only = false; } if ($approved_only === false) { $new_designation = qw_get_user_desg($new_level); } $content = strtr(qa_lang($approved_only ? 'notification/u_level_approved_body_email' : 'notification/u_level_improved_body_email'), array('^done_by' => isset($logged_in_user_name) ? $logged_in_user_name : isset($logged_in_handle) ? $logged_in_handle : qa_lang('main/anonymous'), '^new_designation' => @$new_designation)); } else { if ($event === "q_post_user_fl" || $event === "q_post_tag_fl" || $event === "q_post_cat_fl") { $content = isset($params['text']) && !empty($params['text']) ? $params['text'] : ""; //shrink the email body content if (!!$content && strlen($content) > 50) { $content = qw_shrink_email_body($content, 50); } $title = isset($params['title']) && !empty($params['title']) ? $params['title'] : ""; $url = qa_q_path($params['postid'], $title, true); } else { $content = isset($params['text']) && !empty($params['text']) ? $params['text'] : ""; //shrink the email body content if (!!$content && strlen($content) > 50) { $content = qw_shrink_email_body($content, 50); } $title = isset($params['qtitle']) && !empty($params['qtitle']) ? $params['qtitle'] : ""; $url = qa_q_path($params['qid'], $title, true); } } } } $q_handle = isset($logged_in_user_name) ? $logged_in_user_name : isset($logged_in_handle) ? $logged_in_handle : qa_lang('main/anonymous'); qw_save_email_notification(null, $notifying_user, $logged_in_handle, $event, array('^q_handle' => $q_handle, '^q_title' => $title, '^q_content' => $content, '^url' => !!$url ? $url : "", '^done_by' => $q_handle, '^author_link' => qa_path_absolute('user/' . $q_handle), '^author_pic' => qa_path_absolute('user/' . $q_handle), '^handle' => $handle)); } }
} elseif (isset($result['url'])) { $questions[] = $setarray; } } break; } // Remove duplicate questions (perhaps referenced in an answer and a comment) and cut down to size require_once QA_INCLUDE_DIR . 'app/format.php'; require_once QA_INCLUDE_DIR . 'app/updates.php'; require_once QA_INCLUDE_DIR . 'util/string.php'; if ($feedtype != 'search' && $feedtype != 'hot') { // leave search results and hot questions sorted by relevance $questions = qa_any_sort_and_dedupe($questions); } $questions = array_slice($questions, 0, $count); $blockwordspreg = qa_get_block_words_preg(); // Prepare the XML output $lines = array(); $lines[] = '<?xml version="1.0" encoding="utf-8"?>'; $lines[] = '<rss version="2.0">'; $lines[] = '<channel>'; $lines[] = '<title>' . qa_xml($sitetitle . ' - ' . $title) . '</title>'; $lines[] = '<link>' . qa_xml(qa_path($linkrequest, $linkparams, $siteurl)) . '</link>'; $lines[] = '<description>Powered by Question2Answer</description>'; foreach ($questions as $question) { // Determine whether this is a question, answer or comment, and act accordingly $options = array('blockwordspreg' => @$blockwordspreg, 'showurllinks' => $showurllinks); $time = null; $htmlcontent = null; if (isset($question['opostid'])) { $time = $question['otime'];
function q_list($q_list) { if (qa_opt('it_layout_lists') == 'qlist') { qa_html_theme_base::q_list($q_list); return; } if (count(@$q_list['qs'])) { // first check it is not an empty list and the feature is turned on // Collect the question ids of all items in the question list (so we can do this in one DB query) $postids = array(); foreach ($q_list['qs'] as $question) { if (isset($question['raw']['postid'])) { $postids[] = $question['raw']['postid']; } } if (count($postids)) { // Retrieve favourite count $userid = qa_get_logged_in_userid(); $result = qa_db_query_sub('SELECT userid,entityid FROM ^userfavorites WHERE entitytype=$ AND entityid IN (#)', 'Q', $postids); while ($row = mysqli_fetch_row($result)) { if ($row[0] == $userid) { // loged in user favorited this post $faved_post[$row[1]] = 1; } if (isset($favs[$row[1]])) { $favs[$row[1]] = $favs[$row[1]] + 1; } else { $favs[$row[1]] = 1; } } // Retrieve comment count $result = qa_db_query_sub('SELECT postid,parentid FROM ^posts WHERE type=$ AND parentid IN (#)', 'C', $postids); $comment_list = qa_db_read_all_assoc($result, 'postid'); foreach ($comment_list as $key => $value) { if (isset($comments[$value['parentid']])) { $comments[$value['parentid']] = $comments[$value['parentid']] + 1; } else { $comments[$value['parentid']] = 1; } } if (qa_opt('it_excerpt_field_enable') or qa_opt('it_enable_except')) { // Get the regular expression fragment to use for blocked words and the maximum length of content to show $blockwordspreg = qa_get_block_words_preg(); if (qa_opt('it_excerpt_field_enable')) { $maxlength = qa_opt('it_excerpt_field_length'); // Retrieve Excerpt Text for all questions $result = qa_db_query_sub('SELECT postid,content FROM ^postmetas WHERE postid IN (#) AND title=$', $postids, 'et_excerpt_text'); $excerpt_text = qa_db_read_all_assoc($result, 'postid'); // set excerpt from field info foreach ($q_list['qs'] as $index => $question) { // from field if (!empty($excerpt_text[$question['raw']['postid']]['content'])) { $text = qa_viewer_text($excerpt_text[$question['raw']['postid']]['content'], '', array('blockwordspreg' => $blockwordspreg)); $text = qa_shorten_string_line($text, $maxlength); $q_list['qs'][$index]['excerpt'] = qa_html($text); // from post content } elseif (qa_opt('it_enable_except')) { // Retrieve the content for these questions from the database and put into an array $result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids); $postinfo = qa_db_read_all_assoc($result, 'postid'); $thispost = @$postinfo[$question['raw']['postid']]; if (isset($thispost)) { $text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg)); $text = qa_shorten_string_line($text, $maxlength); $q_list['qs'][$index]['excerpt'] = qa_html($text); } } } } else { // qa_opt('it_enable_except') ==> excerpt from question content instead of excerpt field $maxlength = qa_opt('it_except_len'); $result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids); $postinfo = qa_db_read_all_assoc($result, 'postid'); foreach ($q_list['qs'] as $index => $question) { $thispost = @$postinfo[$question['raw']['postid']]; if (isset($thispost)) { $text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg)); $text = qa_shorten_string_line($text, $maxlength); $q_list['qs'][$index]['excerpt'] = qa_html($text); } } } } // Retrieve featured images for all list questions if (qa_opt('it_feature_img_enable')) { $result = qa_db_query_sub('SELECT postid,content FROM ^postmetas WHERE postid IN (#) AND title=$', $postids, 'et_featured_image'); $featured_images = qa_db_read_all_assoc($result, 'postid'); } // Now meta information for each question foreach ($q_list['qs'] as $index => $question) { if (qa_opt('it_feature_img_enable')) { $featured_image = @$featured_images[$question['raw']['postid']]['content']; if (isset($featured_image)) { $q_list['qs'][$index]['featured'] = qa_opt('it_featured_url_abs') . 'featured/' . $featured_image; } } if (isset($comments[$question['raw']['postid']])) { $q_list['qs'][$index]['comments'] = $comments[$question['raw']['postid']]; } else { $q_list['qs'][$index]['comments'] = 0; } $q_list['qs'][$index]['favourited'] = 0; if (isset($favs[$question['raw']['postid']])) { $q_list['qs'][$index]['favourites'] = $favs[$question['raw']['postid']]; if (isset($faved_post[$question['raw']['postid']])) { $q_list['qs'][$index]['favourited'] = 1; } } else { $q_list['qs'][$index]['favourites'] = 0; } } } } if (isset($q_list['qs'])) { $this->output('<div class="qa-q-list row' . ($this->list_vote_disabled($q_list['qs']) ? ' qa-q-list-vote-disabled' : '') . '">', ''); $this->q_list_items($q_list['qs']); $this->output('</div> <!-- END qa-q-list -->', ''); } }
$qa_content['q_view']['form']['buttons']['delete'] = array('tags' => 'NAME="dodeleteq"', 'label' => qa_lang_html('question/delete_button'), 'popup' => qa_lang_html('question/delete_q_popup')); } if ($question['claimable']) { $qa_content['q_view']['form']['buttons']['claim'] = array('tags' => 'NAME="doclaimq"', 'label' => qa_lang_html('question/claim_button')); } if ($question['answerbutton'] && $formtype != 'a_add') { // don't show if shown by default $qa_content['q_view']['form']['buttons']['answer'] = array('tags' => 'NAME="doanswerq"', 'label' => qa_lang_html('question/answer_button'), 'popup' => qa_lang_html('question/answer_q_popup')); } if ($question['commentbutton']) { $qa_content['q_view']['form']['buttons']['comment'] = array('tags' => 'NAME="docommentq"', 'label' => qa_lang_html('question/comment_button'), 'popup' => qa_lang_html('question/comment_q_popup')); } } // Information about the question of the answer that this question follows on from (or a question directly) if (isset($parentquestion)) { $parentquestion['title'] = qa_block_words_replace($parentquestion['title'], qa_get_block_words_preg()); $qa_content['q_view']['follows'] = array('label' => qa_lang_html($question['parentid'] == $parentquestion['postid'] ? 'question/follows_q' : 'question/follows_a'), 'title' => qa_html($parentquestion['title']), 'url' => qa_path_html(qa_q_request($parentquestion['postid'], $parentquestion['title']), null, null, null, $question['parentid'] == $parentquestion['postid'] ? null : qa_anchor('A', $question['parentid']))); } } // Prepare content for an answer being edited (if any) if ($formtype == 'a_edit') { $qa_content['q_view']['a_form'] = qa_page_q_edit_a_form($formpostid); } // Prepare content for comments on the question, plus add or edit comment forms $qa_content['q_view']['c_list'] = qa_page_q_comment_follow_list($question); // ...for viewing if ($formtype == 'c_add' && $formpostid == $questionid) { // ...to be added $qa_content['q_view']['c_form'] = qa_page_q_add_c_form(null); } elseif ($formtype == 'c_edit' && @$commentsfollows[$formpostid]['parentid'] == $questionid) { // ...being edited
function qa_post_html_defaults($basetype, $full = false) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } require_once QA_INCLUDE_DIR . 'qa-app-users.php'; return array('tagsview' => $basetype == 'Q' && qa_using_tags(), 'categoryview' => $basetype == 'Q' && qa_using_categories(), 'contentview' => $full, 'voteview' => qa_get_vote_view($basetype, $full), 'flagsview' => qa_opt('flagging_of_posts') && $full, 'answersview' => $basetype == 'Q', 'viewsview' => $basetype == 'Q' && qa_opt('do_count_q_views') && qa_opt('show_view_counts'), 'whatview' => true, 'whatlink' => qa_opt('show_a_c_links'), 'whenview' => qa_opt('show_when_created'), 'ipview' => !qa_user_permit_error('permit_anon_view_ips'), 'whoview' => true, 'avatarsize' => qa_opt('avatar_q_list_size'), 'pointsview' => qa_opt('show_user_points'), 'pointstitle' => qa_opt('show_user_titles') ? qa_get_points_to_titles() : array(), 'updateview' => true, 'blockwordspreg' => qa_get_block_words_preg(), 'showurllinks' => qa_opt('show_url_links'), 'linksnewwindow' => qa_opt('links_in_new_window'), 'microformats' => $full, 'fulldatedays' => qa_opt('show_full_date_days')); }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; $populartags = qa_db_single_select(qa_db_popular_tags_selectspec(0, (int) qa_opt('tag_cloud_count_tags'))); reset($populartags); $maxcount = current($populartags); $themeobject->output('<h2 style="margin-top:0; padding-top:0;">', qa_lang_html('main/popular_tags'), '</h2>'); $themeobject->output('<div style="font-size:10px;">'); $maxsize = qa_opt('tag_cloud_font_size'); $scale = qa_opt('tag_cloud_size_popular'); $blockwordspreg = qa_get_block_words_preg(); foreach ($populartags as $tag => $count) { if (count(qa_block_words_match_all($tag, $blockwordspreg))) { continue; } // skip censored tags $size = number_format($scale ? $maxsize * $count / $maxcount : $maxsize, 1); if ($size >= 5 || !$scale) { $themeobject->output('<a href="' . qa_path_html('tag/' . $tag) . '" style="font-size:' . $size . 'px; vertical-align:baseline;">' . qa_html($tag) . '</a>'); } } $themeobject->output('</div>'); }
function process_event($event, $userid, $handle, $cookieid, $params) { require_once QA_INCLUDE_DIR . 'qa-app-emails.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-util-string.php'; switch ($event) { case 'q_post': $followanswer = @$params['followanswer']; $sendhandle = isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : qa_lang('main/anonymous')); if (isset($followanswer['notify']) && !qa_post_is_by_user($followanswer, $userid, $cookieid)) { $blockwordspreg = qa_get_block_words_preg(); $sendtext = qa_viewer_text($followanswer['content'], $followanswer['format'], array('blockwordspreg' => $blockwordspreg)); qa_send_notification($followanswer['userid'], $followanswer['notify'], @$followanswer['handle'], qa_lang('emails/a_followed_subject'), qa_lang('emails/a_followed_body'), array('^q_handle' => $sendhandle, '^q_title' => qa_block_words_replace($params['title'], $blockwordspreg), '^a_content' => $sendtext, '^url' => qa_q_path($params['postid'], $params['title'], true))); } if (qa_opt('notify_admin_q_post')) { qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/q_posted_subject'), qa_lang('emails/q_posted_body'), array('^q_handle' => $sendhandle, '^q_title' => $params['title'], '^q_content' => $params['text'], '^url' => qa_q_path($params['postid'], $params['title'], true))); } break; case 'a_post': $question = $params['parent']; if (isset($question['notify']) && !qa_post_is_by_user($question, $userid, $cookieid)) { qa_send_notification($question['userid'], $question['notify'], @$question['handle'], qa_lang('emails/q_answered_subject'), qa_lang('emails/q_answered_body'), array('^a_handle' => isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : qa_lang('main/anonymous')), '^q_title' => $question['title'], '^a_content' => qa_block_words_replace($params['text'], qa_get_block_words_preg()), '^url' => qa_q_path($question['postid'], $question['title'], true, 'A', $params['postid']))); } break; case 'c_post': $parent = $params['parent']; $question = $params['question']; $senttoemail = array(); // to ensure each user or email gets only one notification about an added comment $senttouserid = array(); switch ($parent['basetype']) { case 'Q': $subject = qa_lang('emails/q_commented_subject'); $body = qa_lang('emails/q_commented_body'); $context = $parent['title']; break; case 'A': $subject = qa_lang('emails/a_commented_subject'); $body = qa_lang('emails/a_commented_body'); $context = qa_viewer_text($parent['content'], $parent['format']); break; } $blockwordspreg = qa_get_block_words_preg(); $sendhandle = isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : qa_lang('main/anonymous')); $sendcontext = qa_block_words_replace($context, $blockwordspreg); $sendtext = qa_block_words_replace($params['text'], $blockwordspreg); $sendurl = qa_q_path($question['postid'], $question['title'], true, 'C', $params['postid']); if (isset($parent['notify']) && !qa_post_is_by_user($parent, $userid, $cookieid)) { $senduserid = $parent['userid']; $sendemail = @$parent['notify']; if (qa_email_validate($sendemail)) { $senttoemail[$sendemail] = true; } elseif (isset($senduserid)) { $senttouserid[$senduserid] = true; } qa_send_notification($senduserid, $sendemail, @$parent['handle'], $subject, $body, array('^c_handle' => $sendhandle, '^c_context' => $sendcontext, '^c_content' => $sendtext, '^url' => $sendurl)); } foreach ($params['thread'] as $comment) { if (isset($comment['notify']) && !qa_post_is_by_user($comment, $userid, $cookieid)) { $senduserid = $comment['userid']; $sendemail = @$comment['notify']; if (qa_email_validate($sendemail)) { if (@$senttoemail[$sendemail]) { continue; } $senttoemail[$sendemail] = true; } elseif (isset($senduserid)) { if (@$senttouserid[$senduserid]) { continue; } $senttouserid[$senduserid] = true; } qa_send_notification($senduserid, $sendemail, @$comment['handle'], qa_lang('emails/c_commented_subject'), qa_lang('emails/c_commented_body'), array('^c_handle' => $sendhandle, '^c_context' => $sendcontext, '^c_content' => $sendtext, '^url' => $sendurl)); } } break; case 'q_queue': case 'q_requeue': if (qa_opt('moderate_notify_admin')) { qa_send_notification(null, qa_opt('feedback_email'), null, $event == 'q_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'q_requeue' ? qa_lang('emails/remoderate_body') : qa_lang('emails/moderate_body'), array('^p_handle' => isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : (strlen(@$oldquestion['name']) ? $oldquestion['name'] : qa_lang('main/anonymous'))), '^p_context' => trim(@$params['title'] . "\n\n" . $params['text']), '^url' => qa_q_path($params['postid'], $params['title'], true), '^a_url' => qa_path_absolute('admin/moderate'))); } break; case 'a_queue': case 'a_requeue': if (qa_opt('moderate_notify_admin')) { qa_send_notification(null, qa_opt('feedback_email'), null, $event == 'a_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'a_requeue' ? qa_lang('emails/remoderate_body') : qa_lang('emails/moderate_body'), array('^p_handle' => isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : (strlen(@$oldanswer['name']) ? $oldanswer['name'] : qa_lang('main/anonymous'))), '^p_context' => $params['text'], '^url' => qa_q_path($params['parentid'], $params['parent']['title'], true, 'A', $params['postid']), '^a_url' => qa_path_absolute('admin/moderate'))); } break; case 'c_queue': case 'c_requeue': if (qa_opt('moderate_notify_admin')) { qa_send_notification(null, qa_opt('feedback_email'), null, $event == 'c_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'c_requeue' ? qa_lang('emails/remoderate_body') : qa_lang('emails/moderate_body'), array('^p_handle' => isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : (strlen(@$oldcomment['name']) ? $oldcomment['name'] : (strlen(@$oldanswer['name']) ? $oldanswer['name'] : qa_lang('main/anonymous')))), '^p_context' => $params['text'], '^url' => qa_q_path($params['questionid'], $params['question']['title'], true, 'C', $params['postid']), '^a_url' => qa_path_absolute('admin/moderate'))); } break; case 'q_flag': case 'a_flag': case 'c_flag': $flagcount = $params['flagcount']; $oldpost = $params['oldpost']; $notifycount = $flagcount - qa_opt('flagging_notify_first'); if ($notifycount >= 0 && $notifycount % qa_opt('flagging_notify_every') == 0) { qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/flagged_subject'), qa_lang('emails/flagged_body'), array('^p_handle' => isset($oldpost['handle']) ? $oldpost['handle'] : (strlen($oldpost['name']) ? $oldpost['name'] : qa_lang('main/anonymous')), '^flags' => $flagcount == 1 ? qa_lang_html_sub('main/1_flag', '1', '1') : qa_lang_html_sub('main/x_flags', $flagcount), '^p_context' => trim(@$oldpost['title'] . "\n\n" . qa_viewer_text($oldpost['content'], $oldpost['format'])), '^url' => qa_q_path($params['questionid'], $params['question']['title'], true, $oldpost['basetype'], $oldpost['postid']), '^a_url' => qa_path_absolute('admin/flagged'))); } break; case 'a_select': $answer = $params['answer']; if (isset($answer['notify']) && !qa_post_is_by_user($answer, $userid, $cookieid)) { $blockwordspreg = qa_get_block_words_preg(); $sendcontent = qa_viewer_text($answer['content'], $answer['format'], array('blockwordspreg' => $blockwordspreg)); qa_send_notification($answer['userid'], $answer['notify'], @$answer['handle'], qa_lang('emails/a_selected_subject'), qa_lang('emails/a_selected_body'), array('^s_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'), '^q_title' => qa_block_words_replace($params['parent']['title'], $blockwordspreg), '^a_content' => $sendcontent, '^url' => qa_q_path($params['parentid'], $params['parent']['title'], true, 'A', $params['postid']))); } break; case 'u_register': if (qa_opt('register_notify_admin')) { qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/u_registered_subject'), qa_opt('moderate_users') ? qa_lang('emails/u_to_approve_body') : qa_lang('emails/u_registered_body'), array('^u_handle' => $handle, '^url' => qa_path_absolute('user/' . $handle), '^a_url' => qa_path_absolute('admin/approve'))); } break; case 'u_level': if ($params['level'] >= QA_USER_LEVEL_APPROVED && $params['oldlevel'] < QA_USER_LEVEL_APPROVED) { qa_send_notification($params['userid'], null, $params['handle'], qa_lang('emails/u_approved_subject'), qa_lang('emails/u_approved_body'), array('^url' => qa_path_absolute('user/' . $params['handle']))); } break; case 'u_wall_post': if ($userid != $params['userid']) { $blockwordspreg = qa_get_block_words_preg(); qa_send_notification($params['userid'], null, $params['handle'], qa_lang('emails/wall_post_subject'), qa_lang('emails/wall_post_body'), array('^f_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'), '^post' => qa_block_words_replace($params['text'], $blockwordspreg), '^url' => qa_path_absolute('user/' . $params['handle'], null, 'wall'))); } break; } }
private function format_message($msg) { // censor bad words require_once QA_INCLUDE_DIR . 'qa-util-string.php'; $blockwordspreg = qa_get_block_words_preg(); $msg = qa_block_words_replace($msg, $blockwordspreg); $msg = qa_html($msg); return qa_html_convert_urls($msg); }