function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favoritemap) { foreach ($navigation as $key => $navlink) { $category = $categories[$navlink['categoryid']]; if (!$category['childcount']) { unset($navigation[$key]['url']); } elseif ($navlink['selected']) { $navigation[$key]['state'] = 'open'; $navigation[$key]['url'] = qa_path_html('categories/' . qa_category_path_request($categories, $category['parentid'])); } else { $navigation[$key]['state'] = 'closed'; } if (@$favoritemap[$navlink['categoryid']]) { $navigation[$key]['favorited'] = true; } $navigation[$key]['note'] = ''; $navigation[$key]['note'] .= ' - <a href="' . qa_path_html('questions/' . implode('/', array_reverse(explode('/', $category['backpath'])))) . '">' . ($category['qcount'] == 1 ? qa_lang_html_sub('main/1_question', '1', '1') : qa_lang_html_sub('main/x_questions', qa_format_number($category['qcount'], 0, true))) . '</a>'; if (strlen($category['content'])) { $navigation[$key]['note'] .= qa_html(' - ' . $category['content']); } if (isset($navlink['subnav'])) { qa_category_nav_to_browse($navigation[$key]['subnav'], $categories, $categoryid, $favoritemap); } } }
function output_count($themeobject, $value, $langsingular, $langplural) { if ($value == 1) { $themeobject->output(qa_lang_html_sub($langsingular, '<B>1</B>', '1')); } else { $themeobject->output(qa_lang_html_sub($langplural, '<B>' . number_format($value) . '</B>')); } }
function logged_in() { qa_html_theme_base::logged_in(); if (qa_is_logged_in()) { $userpoints = qa_get_logged_in_points(); $pointshtml = $userpoints == 1 ? qa_lang_html_sub('main/1_point', '1', '1') : qa_lang_html_sub('main/x_points', qa_html(number_format($userpoints))); $this->output('<SPAN CLASS="qa-logged-in-points">', '(' . $pointshtml . ')', '</SPAN>'); } }
function output_count($themeobject, $value, $langsingular, $langplural) { $themeobject->output('<P CLASS="qa-activity-count-item">'); if ($value == 1) { $themeobject->output(qa_lang_html_sub($langsingular, '<SPAN CLASS="qa-activity-count-data">1</SPAN>', '1')); } else { $themeobject->output(qa_lang_html_sub($langplural, '<SPAN CLASS="qa-activity-count-data">' . number_format((int) $value) . '</SPAN>')); } $themeobject->output('</P>'); }
public function output_count($themeobject, $value, $langsingular, $langplural) { $themeobject->output('<p class="qa-activity-count-item">'); if ($value == 1) { $themeobject->output(qa_lang_html_sub($langsingular, '<span class="qa-activity-count-data">1</span>', '1')); } else { $themeobject->output(qa_lang_html_sub($langplural, '<span class="qa-activity-count-data">' . number_format((int) $value) . '</span>')); } $themeobject->output('</p>'); }
public function output_count($themeobject, $value, $langsingular, $langplural) { require_once QA_INCLUDE_DIR . 'app/format.php'; $themeobject->output('<p class="qa-activity-count-item">'); if ($value == 1) { $themeobject->output(qa_lang_html_sub($langsingular, '<span class="qa-activity-count-data">1</span>', '1')); } else { $themeobject->output(qa_lang_html_sub($langplural, '<span class="qa-activity-count-data">' . qa_format_number((int) $value, 0, true) . '</span>')); } $themeobject->output('</p>'); }
function logged_in() { if (qa_is_logged_in()) { // output user avatar to login bar $this->output('<div class="qa-logged-in-avatar">', QA_FINAL_EXTERNAL_USERS ? qa_get_external_avatar_html(qa_get_logged_in_userid(), 24, true) : qa_get_user_avatar_html(qa_get_logged_in_flags(), qa_get_logged_in_email(), qa_get_logged_in_handle(), qa_get_logged_in_user_field('avatarblobid'), qa_get_logged_in_user_field('avatarwidth'), qa_get_logged_in_user_field('avatarheight'), 24, true), '</div>'); } qa_html_theme_base::logged_in(); if (qa_is_logged_in()) { // adds points count after logged in username $userpoints = qa_get_logged_in_points(); $pointshtml = $userpoints == 1 ? qa_lang_html_sub('main/1_point', '1', '1') : qa_lang_html_sub('main/x_points', qa_html(number_format($userpoints))); $this->output('<span class="qa-logged-in-points">', '(' . $pointshtml . ')', '</span>'); } }
function head_title() { if (qa_opt('buddypress_integration_enable') && qa_opt('buddypress_display_names') && $this->template == 'user' && @$this->content['title']) { $rest = str_replace('^', '(\\S+)', qa_lang_html('profile/user_x')); $handle = preg_replace('|' . $rest . '|', '$1', $this->content['title']); $name = bp_core_get_user_displayname($handle); if ($name) { $this->content['title'] = qa_lang_html_sub('profile/user_x', $name) . ' (@' . $handle . ')'; if (isset($this->content['form_activity'])) { $this->content['form_activity']['title'] = qa_lang_html_sub('profile/activity_by_x', $name); } } } qa_html_theme_base::head_title(); }
public function process_request($request) { $requestparts = explode('/', qa_request()); $slugs = array_slice($requestparts, 1); $countslugs = count($slugs); $userid = qa_get_logged_in_userid(); $start = qa_get_start(); $count = qa_opt_if_loaded('page_size_activity'); $totalcount = qa_opt('cache_qcount'); $qspec = qa_db_posts_basic_selectspec($userid, false); qa_db_add_selectspec_opost($qspec, 'ra', false, false); qa_db_add_selectspec_ousers($qspec, 'rau', 'raup'); $qspec['source'] .= " JOIN (SELECT questionid, childid FROM ^homepage ORDER BY ^homepage.updated DESC) AS rcaq ON ^posts.postid=rcaq.questionid" . " LEFT JOIN ^posts AS ra ON childid=ra.postid" . (QA_FINAL_EXTERNAL_USERS ? "" : " LEFT JOIN ^users AS rau ON ra.userid=rau.userid") . " LEFT JOIN ^userpoints AS raup ON ra.userid=raup.userid LIMIT #,#"; array_push($qspec['columns'], 'childid'); array_push($qspec['arguments'], $start, $count); $qspec['sortdesc'] = 'otime'; $query = 'SELECT '; foreach ($qspec['columns'] as $columnas => $columnfrom) { $query .= $columnfrom . (is_int($columnas) ? '' : ' AS ' . $columnas) . ', '; } $query = qa_db_apply_sub(substr($query, 0, -2) . (strlen(@$qspec['source']) ? ' FROM ' . $qspec['source'] : ''), @$qspec['arguments']); $results = qa_db_read_all_assoc(qa_db_query_raw($query)); qa_db_post_select($results, $qspec); list($categories, $categoryid) = qa_db_select_with_pending(qa_db_category_nav_selectspec($slugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null); $questions = qa_any_sort_and_dedupe($results); // $questions=qa_any_sort_and_dedupe(array_merge($recentquestions,$recentanswers)); $pagesize = qa_opt('page_size_home'); if ($countslugs) { if (!isset($categoryid)) { return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } $categorytitlehtml = qa_html($categories[$categoryid]['title']); $sometitle = qa_lang_html_sub('main/recent_qs_as_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml); } else { $sometitle = qa_lang_html('main/recent_qs_as_title'); $nonetitle = qa_lang_html('main/no_questions_found'); } require_once QA_INCLUDE_DIR . 'qa-app-q-list.php'; $qa_content = qa_q_list_page_content($questions, $pagesize, $start, $totalcount, $sometitle, $nonetitle, $categories, $categoryid, true, qa_opt('eql_homepage_url'), qa_opt('feed_for_qa') ? qa_opt('eql_homepage_url') : null, count($questions) < $pagesize ? qa_html_suggest_ask($categoryid) : qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)), null, null); return $qa_content; }
function send_default_emails($event, $userid, $handle, $cookieid, $params) { switch ($event) { case 'q_queue': case 'q_requeue': if (qa_opt('moderate_notify_admin')) { qw_send_notification(null, qa_opt('feedback_email'), null, $event == 'q_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'q_requeue' ? nl2br(qa_lang('emails/remoderate_body')) : nl2br(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')) { qw_send_notification(null, qa_opt('feedback_email'), null, $event == 'a_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'a_requeue' ? nl2br(qa_lang('emails/remoderate_body')) : nl2br(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')) { qw_send_notification(null, qa_opt('feedback_email'), null, $event == 'c_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'c_requeue' ? nl2br(qa_lang('emails/remoderate_body')) : nl2br(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) { qw_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/flagged_subject'), nl2br(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 'u_register': if (qa_opt('register_notify_admin')) { qw_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/u_registered_subject'), qa_opt('moderate_users') ? nl2br(qa_lang('emails/u_to_approve_body')) : nl2br(qa_lang('emails/u_registered_body')), array('^u_handle' => $handle, '^url' => qa_path_absolute('user/' . $handle), '^a_url' => qa_path_absolute('admin/approve'))); } break; } }
function process_request($request) { $parts = explode('/', $request); $tag = $parts[1]; $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html_sub('useo/edit_desc_for_x', qa_html($tag)); if (qa_user_permit_error('useo_tag_desc_permit_edit')) { $qa_content['error'] = qa_lang_html('users/no_permission'); return $qa_content; } require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; if (qa_clicked('dosave')) { require_once QA_INCLUDE_DIR . 'qa-util-string.php'; $taglc = qa_strtolower($tag); qa_db_tagmeta_set($taglc, 'title', qa_post_text('tagtitle')); qa_db_tagmeta_set($taglc, 'description', qa_post_text('tagdesc')); qa_db_tagmeta_set($taglc, 'icon', qa_post_text('tagicon')); qa_redirect('tag/' . $tag); } $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array(array('label' => 'Title:', 'type' => 'text', 'rows' => 2, 'tags' => 'NAME="tagtitle" ID="tagtitle"', 'value' => qa_html(qa_db_tagmeta_get($tag, 'title'))), array('label' => 'Description:', 'type' => 'text', 'rows' => 4, 'tags' => 'NAME="tagdesc" ID="tagdesc"', 'value' => qa_html(qa_db_tagmeta_get($tag, 'description'))), array('label' => 'Icon image:', 'type' => 'text', 'rows' => 1, 'tags' => 'NAME="tagicon" ID="tagicon"', 'value' => qa_html(qa_db_tagmeta_get($tag, 'icon')))), 'buttons' => array(array('tags' => 'NAME="dosave"', 'label' => qa_lang_html('useo/save_desc_button')))); $qa_content['focusid'] = 'tagdesc'; return $qa_content; }
function process_request($request) { $parts = explode('/', $request); $categoryid = $parts[1]; $fullcategory = qa_db_select_with_pending(qa_db_full_category_selectspec($categoryid, true)); $slugs = explode('/', $fullcategory['backpath']); $new_request = implode('/', array_reverse($slugs)); $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html_sub('useo/edit_desc_for_x', qa_html($fullcategory['title'])); if (qa_user_permit_error('useo_cat_desc_permit_edit')) { $qa_content['error'] = qa_lang_html('users/no_permission'); return $qa_content; } require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; if (qa_clicked('dosave')) { require_once QA_INCLUDE_DIR . 'qa-util-string.php'; qa_db_categorymeta_set($categoryid, 'useo_cat_title', qa_post_text('useo_cat_title')); qa_db_categorymeta_set($categoryid, 'useo_cat_description', qa_post_text('useo_cat_description')); qa_redirect($new_request); } $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array(array('label' => 'Link Title:', 'type' => 'text', 'rows' => 2, 'tags' => 'NAME="useo_cat_title" ID="useo_cat_title"', 'value' => qa_html(qa_db_categorymeta_get($categoryid, 'useo_cat_title'))), array('label' => 'Description:', 'type' => 'text', 'rows' => 4, 'tags' => 'NAME="useo_cat_description" ID="useo_cat_description"', 'value' => qa_html(qa_db_categorymeta_get($categoryid, 'useo_cat_description')))), 'buttons' => array(array('tags' => 'NAME="dosave"', 'label' => qa_lang_html('useo/save_desc_button')))); $qa_content['focusid'] = 'tagtitle'; return $qa_content; }
$answerid = qa_page_q_add_a_submit($question, $answers, $usecaptcha, $in, $errors); $countanswers = $question['acount'] + 1; if (isset($answerid)) { // If successful, page content will be updated via Ajax $answer = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $answerid)); $question = $question + qa_page_q_post_rules($question, null, null, $childposts); // array union $answer = $answer + qa_page_q_post_rules($answer, $question, $answers, null); $usershtml = qa_userids_handles_html(array($answer), true); $a_view = qa_page_q_answer_view($question, $answer, false, $usershtml, false); $themeclass = qa_load_theme_class(qa_get_site_theme(), 'ajax-answer', null, null); echo "QA_AJAX_RESPONSE\n1\n"; // Send back whether the 'answer' button should still be visible echo (int) qa_opt('allow_multi_answers') . "\n"; // Send back the count of answers if ($countanswers == 1) { echo qa_lang_html('question/1_answer_title') . "\n"; } else { echo qa_lang_html_sub('question/x_answers_title', $countanswers) . "\n"; } // Send back the HTML $themeclass->a_list_item($a_view); return; } } } echo "QA_AJAX_RESPONSE\n0\n"; // fall back to non-Ajax submission if there were any problems /* Omit PHP closing tag to help avoid accidental output */
function qa_default_option($name) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } $fixed_defaults = array('allow_change_usernames' => 1, 'allow_close_questions' => 1, 'allow_multi_answers' => 1, 'allow_private_messages' => 1, 'allow_self_answer' => 1, 'allow_view_q_bots' => 1, 'avatar_allow_gravatar' => 1, 'avatar_allow_upload' => 1, 'avatar_profile_size' => 200, 'avatar_q_list_size' => 0, 'avatar_q_page_a_size' => 40, 'avatar_q_page_c_size' => 20, 'avatar_q_page_q_size' => 50, 'avatar_store_size' => 400, 'avatar_users_size' => 30, 'captcha_on_anon_post' => 1, 'captcha_on_feedback' => 1, 'captcha_on_register' => 1, 'captcha_on_reset_password' => 1, 'captcha_on_unconfirmed' => 0, 'columns_tags' => 3, 'columns_users' => 2, 'comment_on_as' => 1, 'comment_on_qs' => 0, 'confirm_user_emails' => 1, 'do_ask_check_qs' => 0, 'do_complete_tags' => 1, 'do_count_q_views' => 1, 'do_example_tags' => 1, 'feed_for_activity' => 1, 'feed_for_qa' => 1, 'feed_for_questions' => 1, 'feed_for_unanswered' => 1, 'feed_full_text' => 1, 'feed_number_items' => 50, 'feed_per_category' => 1, 'feedback_enabled' => 1, 'flagging_hide_after' => 5, 'flagging_notify_every' => 2, 'flagging_notify_first' => 1, 'flagging_of_posts' => 1, 'follow_on_as' => 1, 'hot_weight_a_age' => 100, 'hot_weight_answers' => 100, 'hot_weight_q_age' => 100, 'hot_weight_views' => 100, 'hot_weight_votes' => 100, 'mailing_per_minute' => 500, 'match_ask_check_qs' => 3, 'match_example_tags' => 3, 'match_related_qs' => 3, 'max_copy_user_updates' => 10, 'max_len_q_title' => 120, 'max_num_q_tags' => 5, 'max_rate_ip_as' => 50, 'max_rate_ip_cs' => 40, 'max_rate_ip_flags' => 10, 'max_rate_ip_logins' => 20, 'max_rate_ip_messages' => 10, 'max_rate_ip_qs' => 20, 'max_rate_ip_registers' => 5, 'max_rate_ip_uploads' => 20, 'max_rate_ip_votes' => 600, 'max_rate_user_as' => 25, 'max_rate_user_cs' => 20, 'max_rate_user_flags' => 5, 'max_rate_user_messages' => 5, 'max_rate_user_qs' => 10, 'max_rate_user_uploads' => 10, 'max_rate_user_votes' => 300, 'max_store_user_updates' => 50, 'min_len_a_content' => 12, 'min_len_c_content' => 12, 'min_len_q_content' => 0, 'min_len_q_title' => 12, 'min_num_q_tags' => 0, 'moderate_notify_admin' => 1, 'moderate_points_limit' => 150, 'nav_ask' => 1, 'nav_qa_not_home' => 1, 'nav_questions' => 1, 'nav_tags' => 1, 'nav_unanswered' => 1, 'nav_users' => 1, 'neat_urls' => QA_URL_FORMAT_SAFEST, 'notify_users_default' => 1, 'page_size_activity' => 20, 'page_size_ask_check_qs' => 5, 'page_size_ask_tags' => 5, 'page_size_home' => 20, 'page_size_hot_qs' => 20, 'page_size_q_as' => 10, 'page_size_qs' => 20, 'page_size_related_qs' => 5, 'page_size_search' => 10, 'page_size_tag_qs' => 20, 'page_size_tags' => 30, 'page_size_una_qs' => 20, 'page_size_user_posts' => 20, 'page_size_users' => 20, 'pages_prev_next' => 3, 'permit_anon_view_ips' => QA_PERMIT_EDITORS, 'permit_close_q' => QA_PERMIT_EDITORS, 'permit_delete_hidden' => QA_PERMIT_MODERATORS, 'permit_edit_a' => QA_PERMIT_EXPERTS, 'permit_edit_c' => QA_PERMIT_EDITORS, 'permit_edit_q' => QA_PERMIT_EDITORS, 'permit_flag' => QA_PERMIT_CONFIRMED, 'permit_hide_show' => QA_PERMIT_EDITORS, 'permit_moderate' => QA_PERMIT_EXPERTS, 'permit_select_a' => QA_PERMIT_EXPERTS, 'permit_view_q_page' => QA_PERMIT_ALL, 'permit_vote_a' => QA_PERMIT_USERS, 'permit_vote_down' => QA_PERMIT_USERS, 'permit_vote_q' => QA_PERMIT_USERS, 'points_a_selected' => 30, 'points_a_voted_max_gain' => 20, 'points_a_voted_max_loss' => 5, 'points_base' => 100, 'points_multiple' => 10, 'points_post_a' => 4, 'points_post_q' => 2, 'points_q_voted_max_gain' => 10, 'points_q_voted_max_loss' => 3, 'points_select_a' => 3, 'q_urls_title_length' => 50, 'show_a_c_links' => 1, 'show_a_form_immediate' => 'if_no_as', 'show_c_reply_buttons' => 1, 'show_custom_welcome' => 1, 'show_fewer_cs_count' => 5, 'show_fewer_cs_from' => 10, 'show_full_date_days' => 7, 'show_message_history' => 1, 'show_selected_first' => 1, 'show_url_links' => 1, 'show_user_points' => 1, 'show_user_titles' => 1, 'show_when_created' => 1, 'site_theme' => 'Snow', 'smtp_port' => 25, 'sort_answers_by' => 'created', 'tags_or_categories' => 'tc', 'voting_on_as' => 1, 'voting_on_qs' => 1); if (isset($fixed_defaults[$name])) { $value = $fixed_defaults[$name]; } else { switch ($name) { case 'site_url': $value = 'http://' . @$_SERVER['HTTP_HOST'] . strtr(dirname($_SERVER['SCRIPT_NAME']), '\\', '/') . '/'; break; case 'site_title': $value = qa_default_site_title(); break; case 'site_theme_mobile': $value = qa_opt('site_theme'); break; case 'from_email': // heuristic to remove short prefix (e.g. www. or qa.) $parts = explode('.', @$_SERVER['HTTP_HOST']); if (count($parts) > 2 && strlen($parts[0]) < 5 && !is_numeric($parts[0])) { unset($parts[0]); } $value = 'no-reply@' . (count($parts) > 1 ? implode('.', $parts) : 'example.com'); break; case 'email_privacy': $value = qa_lang_html('options/default_privacy'); break; case 'show_custom_sidebar': $value = strlen(qa_opt('custom_sidebar')) ? true : false; break; case 'show_custom_header': $value = strlen(qa_opt('custom_header')) ? true : false; break; case 'show_custom_footer': $value = strlen(qa_opt('custom_footer')) ? true : false; break; case 'show_custom_in_head': $value = strlen(qa_opt('custom_in_head')) ? true : false; break; case 'custom_sidebar': $value = qa_lang_html_sub('options/default_sidebar', qa_html(qa_opt('site_title'))); break; case 'editor_for_qs': case 'editor_for_as': require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $value = '-'; // to match none by default, i.e. choose based on who is best at editing HTML qa_load_editor('', 'html', $value); break; case 'permit_post_q': // convert from deprecated option if available $value = qa_opt('ask_needs_login') ? QA_PERMIT_USERS : QA_PERMIT_ALL; break; case 'permit_post_a': // convert from deprecated option if available $value = qa_opt('answer_needs_login') ? QA_PERMIT_USERS : QA_PERMIT_ALL; break; case 'permit_post_c': // convert from deprecated option if available $value = qa_opt('comment_needs_login') ? QA_PERMIT_USERS : QA_PERMIT_ALL; break; case 'permit_retag_cat': // convert from previous option that used to contain it too $value = qa_opt('permit_edit_q'); break; case 'points_vote_up_q': case 'points_vote_down_q': $oldvalue = qa_opt('points_vote_on_q'); $value = is_numeric($oldvalue) ? $oldvalue : 1; break; case 'points_vote_up_a': case 'points_vote_down_a': $oldvalue = qa_opt('points_vote_on_a'); $value = is_numeric($oldvalue) ? $oldvalue : 1; break; case 'points_per_q_voted_up': case 'points_per_q_voted_down': $oldvalue = qa_opt('points_per_q_voted'); $value = is_numeric($oldvalue) ? $oldvalue : 1; break; case 'points_per_a_voted_up': case 'points_per_a_voted_down': $oldvalue = qa_opt('points_per_a_voted'); $value = is_numeric($oldvalue) ? $oldvalue : 2; break; case 'captcha_module': $captchamodules = qa_list_modules('captcha'); if (count($captchamodules)) { $value = reset($captchamodules); } else { $value = ''; } break; case 'mailing_from_name': $value = qa_opt('site_title'); break; case 'mailing_from_email': $value = qa_opt('from_email'); break; case 'mailing_subject': $value = qa_lang_sub('options/default_subject', qa_opt('site_title')); break; case 'mailing_body': $value = "\n\n\n--\n" . qa_opt('site_title') . "\n" . qa_opt('site_url'); break; default: // call option_default method in any registered modules $moduletypes = qa_list_module_types(); foreach ($moduletypes as $moduletype) { $modules = qa_load_modules_with($moduletype, 'option_default'); foreach ($modules as $module) { $value = $module->option_default($name); if (strlen($value)) { return $value; } } } $value = ''; break; } } return $value; }
if (qa_opt('show_home_description')) { $qa_content['description'] = qa_html(qa_opt('home_description')); } $qa_content['custom'] = qa_opt('custom_home_content'); return $qa_content; } // If we got this far, it's a good old-fashioned Q&A listing page require_once QA_INCLUDE_DIR . 'app/q-list.php'; qa_set_template('qa'); $questions = qa_any_sort_and_dedupe(array_merge($questions1, $questions2)); $pagesize = qa_opt('page_size_home'); if ($countslugs) { if (!isset($categoryid)) { return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } $categorytitlehtml = qa_html($categories[$categoryid]['title']); $sometitle = qa_lang_html_sub('main/recent_qs_as_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml); } else { $sometitle = qa_lang_html('main/recent_qs_as_title'); $nonetitle = qa_lang_html('main/no_questions_found'); } // Prepare and return content for theme for Q&A listing page $qa_content = qa_q_list_page_content($questions, $pagesize, 0, null, $sometitle, $nonetitle, $categories, $categoryid, true, $explicitqa ? 'qa/' : '', qa_opt('feed_for_qa') ? 'qa' : null, count($questions) < $pagesize ? qa_html_suggest_ask($categoryid) : qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)), null, null); if (!$explicitqa && !$countslugs && qa_opt('show_home_description')) { $qa_content['description'] = qa_html(qa_opt('home_description')); } return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
$authorhtml = qa_html($metadata['author']); if (strlen(@$metadata['author_uri'])) { $authorhtml = '<A HREF="' . qa_html($metadata['author_uri']) . '">' . $authorhtml . '</A>'; } $authorhtml = qa_lang_html_sub('main/by_x', $authorhtml); } else { $authorhtml = ''; } if (strlen(@$metadata['description'])) { $deschtml = qa_html($metadata['description']) . '<BR>'; } else { $deschtml = ''; } $pluginhtml = $namehtml . ' ' . $authorhtml . '<BR>' . $deschtml . '<SMALL STYLE="color:#666">' . qa_html(dirname($pluginfile) . '/') . '</SMALL>'; if (is_numeric($metadata['min_q2a']) && (double) QA_VERSION > 0 && $metadata['min_q2a'] > (double) QA_VERSION) { $pluginhtml = '<STRIKE STYLE="color:#999">' . $pluginhtml . '</STRIKE><BR><SPAN STYLE="color:#f00">' . qa_lang_html_sub('admin/requires_q2a_version', qa_html($metadata['min_q2a'])) . '</SPAN>'; } $qa_content['form']['fields'][] = array('type' => 'custom', 'html' => $pluginhtml); } } $formadded = false; $moduletypes = qa_list_module_types(); foreach ($moduletypes as $type) { $modulenames = qa_list_modules($type); foreach ($modulenames as $name) { $module = qa_load_module($type, $name); if (method_exists($module, 'admin_form')) { $form = $module->admin_form($qa_content); if (!isset($form['title'])) { $form['title'] = qa_html($name); }
if (@$userpoints['aselects']) { $qa_content['form_activity']['fields']['questions']['value'] .= $userpoints['aselects'] == 1 ? qa_lang_html_sub('profile/1_with_best_chosen', '<SPAN CLASS="qa-uf-user-q-selects">1</SPAN>', '1') : qa_lang_html_sub('profile/x_with_best_chosen', '<SPAN CLASS="qa-uf-user-q-selects">' . number_format($userpoints['aselects']) . '</SPAN>'); } if (@$userpoints['aselecteds']) { $qa_content['form_activity']['fields']['answers']['value'] .= $userpoints['aselecteds'] == 1 ? qa_lang_html_sub('profile/1_chosen_as_best', '<SPAN CLASS="qa-uf-user-a-selecteds">1</SPAN>', '1') : qa_lang_html_sub('profile/x_chosen_as_best', '<SPAN CLASS="qa-uf-user-a-selecteds">' . number_format($userpoints['aselecteds']) . '</SPAN>'); } // For plugin layers to access $qa_content['raw']['userid'] = $userid; $qa_content['raw']['points'] = $userpoints; $qa_content['raw']['rank'] = $userrank; // Recent posts by this user if ($pagesize > 0) { if (count($questions)) { $qa_content['q_list']['title'] = qa_lang_html_sub('profile/recent_activity_by_x', $userhtml); } else { $qa_content['q_list']['title'] = qa_lang_html_sub('profile/no_posts_by_x', $userhtml); } $qa_content['q_list']['form_profile'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"'); $qa_content['q_list']['qs'] = array(); $htmloptions = qa_post_html_defaults('Q'); $htmloptions['whoview'] = true; //false; $htmloptions['avatarsize'] = 0; foreach ($questions as $question) { $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $loginuserid, qa_cookie_get(), $usershtml, null, $htmloptions); } } return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
More about this license: http://www.question2answer.org/license.php */ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser header('Location: ../'); exit; } require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-q-list.php'; $categoryslugs = qa_request_parts(1); $countslugs = count($categoryslugs); $userid = qa_get_logged_in_userid(); // Get list of comments with related questions, plus category information list($questions, $categories, $categoryid) = qa_db_select_with_pending(qa_db_recent_c_qs_selectspec($userid, 0, $categoryslugs), qa_db_category_nav_selectspec($categoryslugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null); if ($countslugs) { if (!isset($categoryid)) { return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } $categorytitlehtml = qa_html($categories[$categoryid]['title']); $sometitle = qa_lang_html_sub('main/recent_cs_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_comments_in_x', $categorytitlehtml); } else { $sometitle = qa_lang_html('main/recent_cs_title'); $nonetitle = qa_lang_html('main/no_comments_found'); } // Prepare and return content for theme return qa_q_list_page_content(qa_any_sort_and_dedupe($questions), qa_opt('page_size_activity'), 0, null, $sometitle, $nonetitle, $categories, $categoryid, false, 'comments/', qa_opt('feed_for_activity') ? 'comments' : null, qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid))); /* Omit PHP closing tag to help avoid accidental output */
} } if (qa_clicked('dowallpost')) { $inmessage = qa_post_text('message'); if (!strlen($inmessage)) { $errors['message'] = qa_lang('profile/post_wall_empty'); } elseif (!qa_check_form_security_code('wall-' . $useraccount['handle'], qa_post_text('code'))) { $errors['message'] = qa_lang_html('misc/form_security_again'); } elseif (!$wallposterrorhtml) { qa_wall_add_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $useraccount['userid'], $useraccount['handle'], $inmessage, ''); qa_redirect(qa_request()); } } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html_sub('profile/wall_for_x', $userhtml); $qa_content['error'] = @$errors['page']; $qa_content['script_rel'][] = 'qa-content/qa-user.js?' . QA_VERSION; $qa_content['message_list'] = array('tags' => 'id="wallmessages"', 'form' => array('tags' => 'name="wallpost" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'hidden' => array('qa_click' => '', 'handle' => qa_html($useraccount['handle']), 'start' => qa_html($start), 'code' => qa_get_form_security_code('wall-' . $useraccount['handle']))), 'messages' => array()); if ($start == 0) { // only allow posting on first page if ($wallposterrorhtml) { $qa_content['message_list']['error'] = $wallposterrorhtml; } else { $qa_content['message_list']['form']['fields'] = array('message' => array('tags' => 'name="message" id="message"', 'value' => qa_html(@$inmessage, false), 'rows' => 2, 'error' => qa_html(@$errors['message']))); $qa_content['message_list']['form']['buttons'] = array('post' => array('tags' => 'name="dowallpost" onclick="return qa_submit_wall_post(this, false);"', 'label' => qa_lang_html('profile/post_wall_button'))); } } foreach ($usermessages as $message) { $qa_content['message_list']['messages'][] = qa_wall_post_view($message); }
function display_duplicates(&$qa_content, $useraccount, $otherlogins) { $userid = $useraccount['userid']; $disp_conf = qa_get('confirm'); if (!empty($otherlogins)) { // display other logins which could be linked to this user account if ($disp_conf) { $title = ''; $p = '<br />' . ($disp_conf == 1 ? qa_lang_html('plugin_open/other_logins_conf_text') : qa_lang_html_sub('plugin_open/link_exists', '<strong>' . ucfirst(qa_get('link')) . '</strong>')); } else { $title = '<h2>' . qa_lang_html('plugin_open/other_logins') . '</h2>'; $p = qa_lang_html('plugin_open/other_logins_conf_text'); } $qa_content['custom_merge'] = "{$title} <p>{$p}</p>"; $qa_content['form_merge'] = array('tags' => 'ENCTYPE="multipart/form-data" METHOD="POST" ACTION="' . qa_self_html() . '" CLASS="open-login-others"', 'style' => 'wide', 'buttons' => array('save' => array('tags' => 'onClick="qa_show_waiting_after(this, false);" style="display: none"', 'note' => qa_lang_html('plugin_open/action_info_1'), 'label' => qa_lang_html('plugin_open/continue'))), 'hidden' => array('domerge' => '1', 'confirm' => $disp_conf, 'to' => qa_get('to'))); $data = array(); $select = '<option value="0">' . qa_lang_html('plugin_open/select_base') . '</option>' . '<option value="' . $userid . '" title="' . qa_html($useraccount['handle']) . '">' . qa_html($useraccount['handle']) . ' (' . $useraccount['points'] . ' ' . qa_lang_html('admin/points') . ' - ' . qa_lang_html('plugin_open/current_account') . ')</option>'; foreach ($otherlogins as $i => $login) { $type = 'login'; $name = qa_html($login['details']['handle']); $points = $login['details']['points']; if (count($login['logins']) == 0) { // this is a regular site login, not an openid login $type = 'user'; } $login_providers = $type == 'user' ? strtolower(qa_lang_html('plugin_open/password')) : '<strong>' . implode(', ', $login['logins']) . '</strong>'; $data["f{$i}"] = array('label' => '<strong>' . $name . '</strong> (' . $points . ' ' . qa_lang_html('admin/points') . ', ' . strtolower(qa_lang_html_sub('plugin_open/login_using', '')) . $login_providers . ')', 'tags' => 'name="user_' . $login['details']['userid'] . '" value="' . $login['details']['userid'] . '" style="visibility: hidden" checked="checked" rel="' . $i . '" onchange="OP_checkClicked(this)"', 'type' => 'checkbox', 'style' => 'tall'); $select .= '<option value="' . $login['details']['userid'] . '" title="' . $name . '">' . $name . ' (' . $points . ' ' . qa_lang_html('admin/points') . ')</option>'; } $data['space'] = array('label' => '<br>' . qa_lang_html('plugin_open/choose_action'), 'type' => 'static', 'style' => 'tall'); $ac1html = '<div class="opacxhtml qa-form-tall-buttons" id="ac1html" style="display: none;">' . qa_lang_html('plugin_open/merge_all_first') . ' ' . qa_lang_html('plugin_open/merge_note') . '<br /><br />' . qa_lang_html('plugin_open/select_base_note') . '<br /><select name="base1" onchange="OP_baseSelected(this)">' . $select . '</select></div>'; $ac2html = '<div class="opacxhtml qa-form-tall-buttons" id="ac2html" style="display: none;">' . qa_lang_html('plugin_open/select_merge_first') . ' ' . qa_lang_html('plugin_open/merge_note') . '<br /><br />' . qa_lang_html('plugin_open/select_base_note') . '<br /><select name="base2" onchange="OP_baseSelected(this)">' . $select . '</select></div>'; $ac3html = '<div class="opacxhtml qa-form-tall-buttons" id="ac3html" style="display: none;">' . qa_lang_html('plugin_open/cancel_merge_note') . '</div>'; if ($disp_conf == null || $disp_conf == 1) { $data['actions1'] = array('label' => ' <strong><a href="javascript:;" onclick="OP_actionSelected(1, \'#ac1html\')">» ' . qa_lang_html('plugin_open/merge_all') . '</a></strong>' . $ac1html, 'type' => 'static', 'style' => 'tall'); $data['actions2'] = array('label' => ' <strong><a href="javascript:;" onclick="OP_actionSelected(2, \'#ac2html\')">» ' . qa_lang_html('plugin_open/select_merge') . '</a></strong>' . $ac2html, 'type' => 'static', 'style' => 'tall'); if ($disp_conf == 1) { $data['actions3'] = array('label' => ' <strong><a href="javascript:;" onclick="OP_actionSelected(0, \'#ac3html\')">» ' . qa_lang_html('plugin_open/cancel_merge') . '</a></strong>' . $ac3html, 'type' => 'static', 'style' => 'tall'); } } else { if ($disp_conf == 2) { $data['actions1'] = array('label' => ' <strong><a href="javascript:;" onclick="OP_actionSelected(1, \'#ac1html\')">» ' . qa_lang_html('plugin_open/link_all') . '</a></strong>' . $ac1html, 'type' => 'static', 'style' => 'tall'); $data['actions3'] = array('label' => ' <strong><a href="javascript:;" onclick="OP_actionSelected(0, \'#ac3html\')">» ' . qa_lang_html('plugin_open/cancel_link') . '</a></strong>' . $ac3html, 'type' => 'static', 'style' => 'tall'); } } $qa_content['form_merge']['fields'] = $data; $qa_content['customscript'] = '<script type="text/javascript"> function OP_actionSelected(i, divid) { $(".opacxhtml").slideUp(); if(i != 2 || op_last_action == 2) { $(".qa-main form.open-login-others input[type=checkbox]").css("visibility", "hidden"); } if(op_last_action == i) { OP_baseSelected(); op_last_action = -1; return; } op_last_action = i; $(divid).slideDown(); $(".qa-main form.open-login-others>input[name=domerge]").attr("value", i); if(i > 0) { $(".qa-main form.open-login-others input[type=checkbox]").attr("checked", "checked"); if(i == 2) { $(".qa-main form.open-login-others input[type=checkbox]").css("visibility", "visible"); $(".qa-main form.open-login-others select[name=base2]").html( $(".qa-main form.open-login-others select[name=base1]").html() ); } sel = $(".qa-main form.open-login-others select[name=base" + i +"]").get(0); sel.selectedIndex = 0; OP_baseSelected(sel); } else { $(".qa-main form.open-login-others span.qa-form-wide-note").html("' . qa_lang_html('plugin_open/action_info_2') . '"); $(".qa-main form.open-login-others input[type=submit]").show(); $(".qa-main form.open-login-others input[type=submit]").attr("disabled", false); } } function OP_baseSelected(sel) { if(!sel || sel.selectedIndex == 0) { if(sel) { $(".qa-main form.open-login-others span.qa-form-wide-note").html("' . qa_lang_html('plugin_open/action_info_3') . '") } else { $(".qa-main form.open-login-others span.qa-form-wide-note").html("' . qa_lang_html('plugin_open/action_info_1') . '") } $(".qa-main form.open-login-others input[type=submit]").hide() $(".qa-main form.open-login-others input[type=submit]").attr("disabled", "disabled") } else { if(OP_accValid()) { nam = $("option:selected", sel).attr("title") $(".qa-main form.open-login-others span.qa-form-wide-note").html("<strong>" + nam + "</strong> ' . qa_lang_html('plugin_open/action_info_4') . '") $(".qa-main form.open-login-others input[type=submit]").show() $(".qa-main form.open-login-others input[type=submit]").attr("disabled", false) } } } function OP_checkClicked(check) { ' . ($disp_conf == 2 ? '/* empty */' : ' var rel = $(check).attr("rel") var id = $(check).attr("value") var chk = $(check).attr("checked") $(".qa-main form.open-login-others select[name=base2]").get(0).selectedIndex = 0 if(chk) { $(".qa-main form.open-login-others select[name=base2] option[value=" + id + "]").show() } else { $(".qa-main form.open-login-others select[name=base2] option[value=" + id + "]").hide() } OP_accValid() ') . ' } function OP_accValid() { if(op_last_action != 2) { $(".qa-main form.open-login-others input[type=checkbox]").attr("checked", "checked") return true } someSel = false $(".qa-main form.open-login-others input[type=checkbox]").each(function(i, o) { someSel = someSel || $(o).attr("checked") == "checked" }); $(".qa-main form.open-login-others input[type=submit]").hide(); $(".qa-main form.open-login-others input[type=submit]").attr("disabled", "disabled"); if(!someSel) { // nothing selected $(".qa-main form.open-login-others span.qa-form-wide-note").html("' . qa_lang_html('plugin_open/action_info_5') . '"); return false; } else { $(".qa-main form.open-login-others span.qa-form-wide-note").html("' . qa_lang_html('plugin_open/action_info_3') . '"); return true; } } </script>'; $qa_content['script_onloads'][] = '$(function(){ OP_baseSelected() });'; $qa_content['script_var']['op_last_action'] = -1; return true; } return false; }
$qa_content['form_message'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('message' => array('type' => $messagesent ? 'static' : '', 'label' => qa_lang_html_sub('misc/message_for_x', qa_get_one_user_html($handle, false)), 'tags' => 'name="message" id="message"', 'value' => qa_html(@$inmessage, $messagesent), 'rows' => 8, 'note' => qa_lang_html_sub('misc/message_explanation', qa_html(qa_opt('site_title'))), 'error' => qa_html(@$errors['message']))), 'buttons' => array('send' => array('tags' => 'onclick="qa_show_waiting_after(this, false);"', 'label' => qa_lang_html('main/send_button'))), 'hidden' => array('domessage' => '1', 'code' => qa_get_form_security_code('message-' . $handle))); $qa_content['focusid'] = 'message'; if ($messagesent) { $qa_content['form_message']['ok'] = qa_lang_html('misc/message_sent'); unset($qa_content['form_message']['buttons']); if (qa_opt('show_message_history')) { unset($qa_content['form_message']['fields']['message']); } else { unset($qa_content['form_message']['fields']['message']['note']); unset($qa_content['form_message']['fields']['message']['label']); } } // If relevant, show recent message history if (qa_opt('show_message_history')) { $recent = array_merge($torecent, $fromrecent); qa_sort_by($recent, 'created'); $showmessages = array_slice(array_reverse($recent, true), 0, QA_DB_RETRIEVE_MESSAGES); if (count($showmessages)) { $qa_content['message_list'] = array('title' => qa_lang_html_sub('misc/message_recent_history', qa_html($toaccount['handle']))); $options = qa_message_html_defaults(); foreach ($showmessages as $message) { $qa_content['message_list']['messages'][] = qa_message_html_fields($message, $options); } } } $qa_content['raw']['account'] = $toaccount; // for plugin layers to access return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
} else { $updatehtml = ''; } if (strlen(@$metadata['description'])) { $deschtml = qa_html($metadata['description']); } else { $deschtml = ''; } if (isset($pluginoptionmodules[$plugindirectory]) && !$showthisform) { $deschtml .= (strlen($deschtml) ? ' - ' : '') . '<a href="' . qa_admin_plugin_options_path($plugindirectory) . '">' . qa_lang_html('admin/options') . '</a>'; } $pluginhtml = $namehtml . ' ' . $authorhtml . ' ' . $updatehtml . '<br>' . $deschtml . (strlen($deschtml) ? '<br>' : '') . '<small style="color:#666">' . qa_html($plugindirectory) . '</small>'; if (qa_qa_version_below(@$metadata['min_q2a'])) { $pluginhtml = '<strike style="color:#999">' . $pluginhtml . '</strike><br><span style="color:#f00">' . qa_lang_html_sub('admin/requires_q2a_version', qa_html($metadata['min_q2a'])) . '</span>'; } elseif (qa_php_version_below(@$metadata['min_php'])) { $pluginhtml = '<strike style="color:#999">' . $pluginhtml . '</strike><br><span style="color:#f00">' . qa_lang_html_sub('admin/requires_php_version', qa_html($metadata['min_php'])) . '</span>'; } $qa_content['form_plugin_' . $pluginindex] = array('tags' => 'id="' . qa_html($hash) . '"', 'style' => 'tall', 'fields' => array(array('type' => 'custom', 'html' => $pluginhtml))); if ($showthisform && isset($pluginoptionmodules[$plugindirectory])) { foreach ($pluginoptionmodules[$plugindirectory] as $pluginoptionmodule) { $type = $pluginoptionmodule['type']; $name = $pluginoptionmodule['name']; $module = qa_load_module($type, $name); $form = $module->admin_form($qa_content); if (!isset($form['tags'])) { $form['tags'] = 'method="post" action="' . qa_admin_plugin_options_path($plugindirectory) . '"'; } if (!isset($form['style'])) { $form['style'] = 'tall'; } $form['boxed'] = true;
function qa_favorite_categories_view($categories) { require_once QA_INCLUDE_DIR . 'app/format.php'; $nav_list_categories = array('nav' => array(), 'type' => 'browse-cat'); foreach ($categories as $category) { $cat_url = qa_path_html('questions/' . implode('/', array_reverse(explode('/', $category['backpath'])))); $cat_anchor = $category['qcount'] == 1 ? qa_lang_html_sub('main/1_question', '1', '1') : qa_lang_html_sub('main/x_questions', qa_format_number($category['qcount'], 0, true)); $cat_descr = strlen($category['content']) ? qa_html(' - ' . $category['content']) : ''; $nav_list_categories['nav'][$category['categoryid']] = array('label' => qa_html($category['title']), 'state' => 'open', 'favorited' => true, 'note' => ' - <a href="' . $cat_url . '">' . $cat_anchor . '</a>' . $cat_descr); } return $nav_list_categories; }
function qa_page_q_comment_follow_list($parent, $commentsfollows, $alwaysfull, $usershtml, $formrequested, $formpostid) { $parentid = $parent['postid']; $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); $commentlist = array('tags' => 'ID="c' . qa_html($parentid) . '_list"', 'cs' => array()); $showcomments = array(); foreach ($commentsfollows as $commentfollowid => $commentfollow) { if ($commentfollow['parentid'] == $parentid && $commentfollow['viewable'] && $commentfollowid != $formpostid) { $showcomments[$commentfollowid] = $commentfollow; } } $countshowcomments = count($showcomments); if (!$alwaysfull && $countshowcomments > qa_opt('show_fewer_cs_from')) { $skipfirst = $countshowcomments - qa_opt('show_fewer_cs_count'); } else { $skipfirst = 0; } if ($skipfirst == $countshowcomments) { // showing none if ($skipfirst == 1) { $expandtitle = qa_lang_html('question/show_1_comment'); } else { $expandtitle = qa_lang_html_sub('question/show_x_comments', $skipfirst); } } else { if ($skipfirst == 1) { $expandtitle = qa_lang_html('question/show_1_previous_comment'); } else { $expandtitle = qa_lang_html_sub('question/show_x_previous_comments', $skipfirst); } } if ($skipfirst > 0) { $commentlist['cs'][$parentid] = array('url' => qa_html('?state=showcomments-' . $parentid . '&show=' . $parentid . '#' . urlencode(qa_anchor($parent['basetype'], $parentid))), 'expand_tags' => 'onClick="return qa_show_comments(' . qa_js($parentid) . ', this);"', 'title' => $expandtitle); } foreach ($showcomments as $commentfollowid => $commentfollow) { if ($skipfirst > 0) { $skipfirst--; } elseif ($commentfollow['basetype'] == 'C') { $commentlist['cs'][$commentfollowid] = qa_page_q_comment_view($parent, $commentfollow, $usershtml, $formrequested); } elseif ($commentfollow['basetype'] == 'Q') { $htmloptions = qa_post_html_defaults('Q'); $htmloptions['avatarsize'] = qa_opt('avatar_q_page_c_size'); $commentlist['cs'][$commentfollowid] = qa_post_html_fields($commentfollow, $userid, $cookieid, $usershtml, null, $htmloptions); } } if (!count($commentlist['cs'])) { $commentlist['hidden'] = true; } return $commentlist; }
} foreach ($results as $result) { if (isset($result['question'])) { $fields = qa_post_html_fields($result['question'], $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($result['question'], $qdefaults)); } elseif (isset($result['url'])) { $fields = array('what' => qa_html($result['url']), 'meta_order' => qa_lang_html('main/meta_order')); } else { continue; } // nothing to show here if (isset($qdefaults['blockwordspreg'])) { $result['title'] = qa_block_words_replace($result['title'], $qdefaults['blockwordspreg']); } $fields['title'] = qa_html($result['title']); $fields['url'] = qa_html($result['url']); $qa_content['q_list']['qs'][] = $fields; } $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $start + $gotcount, qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount >= $count); if (qa_opt('feed_for_search')) { $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request('search/' . $inquery)), 'label' => qa_lang_html_sub('main/results_for_x', qa_html($inquery))); } if (empty($qa_content['page_links'])) { $qa_content['suggest_next'] = qa_html_suggest_qs_tags(qa_using_tags()); } } else { $qa_content['error'] = qa_lang_html('main/search_explanation'); } return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
if (@$userpoints['points']) { $qa_content['form_activity']['fields']['points']['value'] .= qa_lang_html_sub('profile/ranked_x', '<span class="qa-uf-user-rank">' . number_format($userrank) . '</span>'); } if (@$userpoints['aselects']) { $qa_content['form_activity']['fields']['questions']['value'] .= $userpoints['aselects'] == 1 ? qa_lang_html_sub('profile/1_with_best_chosen', '<span class="qa-uf-user-q-selects">1</span>', '1') : qa_lang_html_sub('profile/x_with_best_chosen', '<span class="qa-uf-user-q-selects">' . number_format($userpoints['aselects']) . '</span>'); } if (@$userpoints['aselecteds']) { $qa_content['form_activity']['fields']['answers']['value'] .= $userpoints['aselecteds'] == 1 ? qa_lang_html_sub('profile/1_chosen_as_best', '<span class="qa-uf-user-a-selecteds">1</span>', '1') : qa_lang_html_sub('profile/x_chosen_as_best', '<span class="qa-uf-user-a-selecteds">' . number_format($userpoints['aselecteds']) . '</span>'); } // For plugin layers to access $qa_content['raw']['userid'] = $userid; $qa_content['raw']['points'] = $userpoints; $qa_content['raw']['rank'] = $userrank; // Wall posts if (!QA_FINAL_EXTERNAL_USERS && qa_opt('allow_user_walls')) { $qa_content['message_list'] = array('title' => '<a name="wall">' . qa_lang_html_sub('profile/wall_for_x', $userhtml) . '</a>', 'tags' => 'id="wallmessages"', 'form' => array('tags' => 'name="wallpost" method="post" action="' . qa_self_html() . '#wall"', 'style' => 'tall', 'hidden' => array('qa_click' => '', 'handle' => qa_html($useraccount['handle']), 'start' => 0, 'code' => qa_get_form_security_code('wall-' . $useraccount['handle']))), 'messages' => array()); if ($wallposterrorhtml) { $qa_content['message_list']['error'] = $wallposterrorhtml; } else { $qa_content['message_list']['form']['fields'] = array('message' => array('tags' => 'name="message" id="message"', 'value' => qa_html(@$inmessage, false), 'rows' => 2, 'error' => qa_html(@$errors['message']))); $qa_content['message_list']['form']['buttons'] = array('post' => array('tags' => 'name="dowallpost" onclick="return qa_submit_wall_post(this, true);"', 'label' => qa_lang_html('profile/post_wall_button'))); } foreach ($usermessages as $message) { $qa_content['message_list']['messages'][] = qa_wall_post_view($message); } if ($useraccount['wallposts'] > count($usermessages)) { $qa_content['message_list']['messages'][] = qa_wall_view_more_link($handle, count($usermessages)); } } // Sub menu for navigation in user pages $qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'profile', isset($loginuserid) && $loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid']));
function qa_flag_set_tohide($post, $userid, $handle, $cookieid, $question) { require_once QA_INCLUDE_DIR . 'qa-db-votes.php'; require_once QA_INCLUDE_DIR . 'qa-app-limits.php'; qa_db_userflag_set($post['postid'], $userid, true); qa_db_post_recount_flags($post['postid']); switch ($post['basetype']) { case 'Q': $action = 'q_flag'; break; case 'A': $action = 'a_flag'; break; case 'C': $action = 'c_flag'; break; } qa_report_write_action($userid, null, $action, $post['basetype'] == 'Q' ? $post['postid'] : null, $post['basetype'] == 'A' ? $post['postid'] : null, $post['basetype'] == 'C' ? $post['postid'] : null); qa_report_event($action, $userid, $handle, $cookieid, array('postid' => $post['postid'])); $post = qa_db_select_with_pending(qa_db_full_post_selectspec(null, $post['postid'])); $flagcount = $post['flagcount']; $notifycount = $flagcount - qa_opt('flagging_notify_first'); if ($notifycount >= 0 && $notifycount % qa_opt('flagging_notify_every') == 0) { require_once QA_INCLUDE_DIR . 'qa-app-emails.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $anchor = $post['basetype'] == 'Q' ? null : qa_anchor($post['basetype'], $post['postid']); qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/flagged_subject'), qa_lang('emails/flagged_body'), array('^p_handle' => isset($post['handle']) ? $post['handle'] : 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(@$post['title'] . "\n\n" . qa_viewer_text($post['content'], $post['format'])), '^url' => qa_path(qa_q_request($question['postid'], $question['title']), null, qa_opt('site_url'), null, $anchor))); } if ($flagcount >= qa_opt('flagging_hide_after') && !$post['hidden']) { return true; } return false; }
function head_title() { // Title Customization Options $title = ''; switch ($this->template) { case 'qa': $title_template = qa_opt('useo_title_qa'); if (!empty($title_template)) { $search = array('%site-title%'); $replace = array(qa_opt('site_title')); $title = str_replace($search, $replace, $title_template); } break; case 'question': $category_name = ''; if (isset($this->content["categoryids"]) && !empty($this->content["categoryids"])) { $category_name = $this->content["q_view"]["raw"]["categoryname"]; } if (empty($this->meta_title)) { // title customization $title_template = qa_opt('useo_title_qa_item'); if (!empty($title_template)) { $search = array('%site-title%', '%question-title%', '%category-name%'); $replace = array(qa_opt('site_title'), @$this->content['q_view']['raw']['title'], $category_name); $title = str_replace($search, $replace, $title_template); } } else { // meta editor $title = $this->meta_title; } break; case 'questions': $category_name = ''; if (count(explode('/', $this->request)) > 1) { $category_name = $this->content["q_list"]["qs"][0]["raw"]["categoryname"]; } $sort = qa_get('sort'); if (empty($sort)) { $title_template = qa_opt('useo_title_recent'); if (!empty($title_template)) { $search = array('%site-title%', '%recent-qs-title%', '%category-name%'); $replace = array(qa_opt('site_title'), qa_lang_html('main/recent_qs_title'), $category_name); $title = str_replace($search, $replace, $title_template); } } elseif ($sort == 'hot') { $title_template = qa_opt('useo_title_hot'); if (!empty($title_template)) { $search = array('%site-title%', '%hot-qs-title%'); $replace = array(qa_opt('site_title'), qa_lang_html('main/hot_qs_title')); $title = str_replace($search, $replace, $title_template); } } elseif ($sort == 'votes') { $title_template = qa_opt('useo_title_voted'); if (!empty($title_template)) { $search = array('%site-title%', '%voted-qs-title%'); $replace = array(qa_opt('site_title'), qa_lang_html('main/voted_qs_title')); $title = str_replace($search, $replace, $title_template); } } elseif ($sort == 'answers') { $title_template = qa_opt('useo_title_answered'); if (!empty($title_template)) { $search = array('%site-title%', '%answered-qs-title%'); $replace = array(qa_opt('site_title'), qa_lang_html('main/answered_qs_title')); $title = str_replace($search, $replace, $title_template); } } elseif ($sort == 'views') { $title_template = qa_opt('useo_title_viewed'); if (!empty($title_template)) { $search = array('%site-title%', '%viewed-qs-title%'); $replace = array(qa_opt('site_title'), qa_lang_html('main/viewed_qs_title')); $title = str_replace($search, $replace, $title_template); } } case 'unanswered': $sort = qa_get('by'); $category_name = ''; if (count(explode('/', $this->request)) > 1) { $category_name = $this->content["q_list"]["qs"][0]["raw"]["categoryname"]; } if (empty($sort)) { $title_template = qa_opt('useo_title_unanswered'); if (!empty($title_template)) { $search = array('%site-title%', '%unanswered-qs-title%', '%category-name%'); $replace = array(qa_opt('site_title'), qa_lang_html('main/unanswered_qs_title'), $category_name); $title = str_replace($search, $replace, $title_template); } } elseif ($sort == 'selected') { $title_template = qa_opt('useo_title_unselected'); if (!empty($title_template)) { $search = array('%site-title%', '%unselected-qs-title%'); $replace = array(qa_opt('site_title'), qa_lang_html('main/unselected_qs_title')); $title = str_replace($search, $replace, $title_template); } } elseif ($sort == 'upvotes') { $title_template = qa_opt('useo_title_unupvoted'); if (!empty($title_template)) { $search = array('%site-title%', '%unupvoteda-qs-title%'); $replace = array(qa_opt('site_title'), qa_lang_html('main/unupvoteda_qs_title')); $title = str_replace($search, $replace, $title_template); } } break; case 'activity': $title_template = qa_opt('useo_title_activity'); if (!empty($title_template)) { $category_name = ''; if (count(explode('/', $this->request)) > 1) { $category_name = $this->content["q_list"]["qs"][0]["raw"]["categoryname"]; } $search = array('%site-title%', '%recent-activity-title%', '%category-name%'); $replace = array(qa_opt('site_title'), qa_lang_html('main/recent_activity_title'), $category_name); $title = str_replace($search, $replace, $title_template); } break; case 'ask': $title_template = qa_opt('useo_title_ask'); if (!empty($title_template)) { $search = array('%site-title%', '%ask-title%'); $replace = array(qa_opt('site_title'), qa_lang_html('question/ask_title')); $title = str_replace($search, $replace, $title_template); } break; case 'categories': $title_template = qa_opt('useo_title_categories'); if (!empty($title_template)) { $search = array('%site-title%', '%browse-categories%'); $replace = array(qa_opt('site_title'), qa_lang_html('misc/browse_categories')); $title = str_replace($search, $replace, $title_template); } break; case 'tags': $title_template = qa_opt('useo_title_tags'); if (!empty($title_template)) { $search = array('%site-title%', '%popular-tags%'); $replace = array(qa_opt('site_title'), qa_lang_html('main/popular_tags')); $title = str_replace($search, $replace, $title_template); } break; case 'tag': $title_template = qa_opt('useo_title_tag'); if (!empty($title_template)) { $req = explode('/', $this->request); $tag = $req[1]; $search = array('%site-title%', '%questions-tagged-x%', '%current-tag%'); $replace = array(qa_opt('site_title'), qa_lang_html_sub('main/questions_tagged_x', qa_html($tag)), $tag); $title = str_replace($search, $replace, $title_template); } break; case 'search': $title_template = qa_opt('useo_title_search'); if (!empty($title_template)) { $term = qa_get('q'); $search = array('%site-title%', '%results-for-x%', '%current-term%'); $replace = array(qa_opt('site_title'), qa_lang_html_sub('main/results_for_x', qa_html($term)), $term); $title = str_replace($search, $replace, $title_template); } break; case 'users': $title_template = qa_opt('useo_title_users'); if (!empty($title_template)) { $search = array('%site-title%', '%highest-users%'); $replace = array(qa_opt('site_title'), qa_lang_html('main/highest_users')); $title = str_replace($search, $replace, $title_template); } break; case 'user': $title_template = qa_opt('useo_title_user'); if (!empty($title_template)) { $req = explode('/', $this->request); $user = $req[1]; $search = array('%site-title%', '%user-x%', '%current-user%'); $replace = array(qa_opt('site_title'), qa_lang_html_sub('main/results_for_x', qa_html($user)), $user); $title = str_replace($search, $replace, $title_template); } break; } if (empty($title)) { qa_html_theme_base::head_title(); } else { $this->output('<title>' . $title . '</title>'); } // Page Meta Tags $noindex = qa_opt('useo_access_noindex'); $nofollow = qa_opt('useo_access_nofollow'); if ($noindex and $nofollow) { $this->output('<meta name="robots" content="noindex, nofollow" />'); } elseif ($noindex) { $this->output('<meta name="robots" content="noindex" />'); } else { // if page is not already noindex, check if it needs to be noindex. also add nofollow if necessary $status = 1; // content is long enough if ($this->template == 'question' and qa_opt('useo_access_length_enable') and (int) qa_opt('useo_access_length') > 0) { $status = 0; $minimum_words = (int) qa_opt('useo_access_length'); $word_count = str_word_count($this->content['q_view']['raw']['title']) + str_word_count($this->content['q_view']['raw']['content']); if ($word_count >= $minimum_words) { $status = 1; } else { foreach ($this->content['q_view']['c_list']['cs'] as $comment) { $word_count += str_word_count($comment['raw']['content']); } if ($word_count >= $minimum_words) { $status = 1; } else { foreach ($this->content['a_list']['as'] as $answer) { $word_count += str_word_count($answer['raw']['content']); } if ($word_count >= $minimum_words) { $status = 1; } else { foreach ($this->content['a_list']['as'] as $answer) { foreach ($answer['c_list']['cs'] as $comment) { $word_count += str_word_count($comment['raw']['content']); } } if ($word_count >= $minimum_words) { $status = 1; } } } } } if ($nofollow && $status == 1) { $this->output('<meta name="robots" content="nofollow" />'); } elseif ($nofollow && $status == 0) { $this->output('<meta name="robots" content="noindex, nofollow" />'); } elseif ($status == 0) { $this->output('<meta name="robots" content="noindex" />'); } } // Question Meta tags if ($this->template == 'question') { // setup custom meta keyword if (!empty($this->meta_keywords)) { $this->content['keywords'] = $this->meta_keywords; } // setup custom meta description if (!empty($this->meta_description)) { $this->content['description'] = $this->meta_description; } elseif (qa_opt('useo_meta_desc_ans_enable')) { $lenght = (int) qa_opt('useo_meta_desc_length'); if ($lenght <= 0) { $lenght = 160; } $text = ''; if ($this->content['q_view']['raw']['acount'] > 0 and qa_opt('useo_meta_desc_ans_enable')) { // get Selected Answer's content if (isset($this->content["q_view"]["raw"]["selchildid"]) and qa_opt('useo_meta_desc_sel_ans_enable')) { foreach ($this->content['a_list']['as'] as $answer) { if ($answer['raw']['isselected']) { $text = $answer['raw']['content']; } } } else { // get most voted Answer's content $max_vote = 0; // don't use answers with negative votes. foreach ($this->content['a_list']['as'] as $answer) { if ($answer['raw']['netvotes'] > $max_vote) { $text = $answer['raw']['content']; $max_vote = $answer['raw']['netvotes']; } } } } if (!empty($text)) { $excerpt = useo_get_excerpt($text, 0, $lenght); $this->content['description'] = $excerpt; } } // Meta Tags and social meta tags if ($this->template == 'question') { if (qa_opt('useo_social_enable_editor')) { foreach ($this->metas as $key => $value) { if (isset($this->social_metas[$key])) { $this->output('<meta ' . $value['type'] . ' content="' . $this->social_metas[$key] . '" />'); } else { $this->output('<meta ' . $value['type'] . ($value['content'] ? ' content="' . $value['content'] . '"' : '') . ' /> '); } } } elseif (qa_opt('useo_social_og_enable_auto')) { foreach ($this->metas as $key => $value) { $this->output('<meta ' . $value['type'] . ($value['content'] ? ' content="' . $value['content'] . '"' : '') . ' /> '); } } } } }
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; } }
$htmloptions = qa_post_html_options($question); $htmloptions['tagsview'] = false; $htmloptions['voteview'] = false; $htmloptions['ipview'] = false; $htmloptions['answersview'] = false; $htmloptions['viewsview'] = false; $htmloptions['updateview'] = false; $htmlfields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions); if (isset($htmlfields['what_url'])) { // link directly to relevant content $htmlfields['url'] = $htmlfields['what_url']; } $hasother = isset($question['opostid']); if ($question[$hasother ? 'ohidden' : 'hidden'] && !isset($question[$hasother ? 'oupdatetype' : 'updatetype'])) { $htmlfields['what_2'] = qa_lang_html('main/hidden'); if (@$htmloptions['whenview']) { $updated = @$question[$hasother ? 'oupdated' : 'updated']; if (isset($updated)) { $htmlfields['when_2'] = qa_when_to_html($updated, @$htmloptions['fulldatedays']); } } } $qa_content['q_list']['qs'][] = $htmlfields; } } else { $qa_content['q_list']['title'] = qa_lang_html_sub('misc/no_activity_from_x', qa_html($ip)); } return $qa_content; /* Omit PHP closing tag to help avoid accidental output */