Example #1
0
 function doctype()
 {
     if ($this->request == 'admin/permissions' && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
         $permits[] = 'signature_allow';
         $permits[] = 'signature_edit_allow';
         foreach ($permits as $optionname) {
             $value = qa_opt($optionname);
             $optionfield = array('id' => $optionname, 'label' => qa_lang_html('signature_plugin/' . $optionname) . ':', 'tags' => 'NAME="option_' . $optionname . '" ID="option_' . $optionname . '"', 'value' => $value, 'error' => qa_html(@$errors[$optionname]));
             $widest = QA_PERMIT_USERS;
             $narrowest = QA_PERMIT_ADMINS;
             $permitoptions = qa_admin_permit_options($widest, $narrowest, !QA_FINAL_EXTERNAL_USERS && qa_opt('confirm_user_emails'));
             if (count($permitoptions) > 1) {
                 qa_optionfield_make_select($optionfield, $permitoptions, $value, $value == QA_PERMIT_CONFIRMED ? QA_PERMIT_USERS : min(array_keys($permitoptions)));
             }
             $this->content['form']['fields'][$optionname] = $optionfield;
             $this->content['form']['fields'][$optionname . '_points'] = array('id' => $optionname . '_points', 'tags' => 'NAME="option_' . $optionname . '_points" ID="option_' . $optionname . '_points"', 'type' => 'number', 'value' => qa_opt($optionname . '_points'), 'prefix' => qa_lang_html('admin/users_must_have') . ' ', 'note' => qa_lang_html('admin/points'));
             $checkboxtodisplay[$optionname . '_points'] = '(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS) . ') ||(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS_CONFIRMED) . ')';
         }
         qa_set_display_rules($this->content, $checkboxtodisplay);
     }
     if (qa_opt('signatures_enable')) {
         // add user signature
         if ($this->template == 'user' && isset($this->content['form_activity']) && !qa_get('tab')) {
             $sig_form = $this->content['user_signature_form'];
             // from overrides
             // insert our form
             if (isset($this->content['q_list'])) {
                 // array splicing kungfu thanks to Stack Exchange
                 // This adds form-signature before q_list
                 $keys = array_keys($this->content);
                 $vals = array_values($this->content);
                 $insertBefore = array_search('q_list', $keys);
                 $keys2 = array_splice($keys, $insertBefore);
                 $vals2 = array_splice($vals, $insertBefore);
                 $keys[] = 'form-signature';
                 $vals[] = $sig_form;
                 $this->content = array_merge(array_combine($keys, $vals), array_combine($keys2, $vals2));
             } else {
                 $this->content['form-signature'] = $sig_form;
             }
         }
     }
     qa_html_theme_base::doctype();
 }
Example #2
0
 function doctype()
 {
     if ($this->request == 'admin/permissions' && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
         $permits[] = 'xmlrpc_access';
         foreach ($permits as $optionname) {
             $value = qa_opt($optionname);
             $optionfield = array('id' => $optionname, 'label' => qa_lang_html('xmlrpc/' . $optionname) . ':', 'tags' => 'NAME="option_' . $optionname . '" ID="option_' . $optionname . '"', 'value' => $value, 'error' => qa_html(@$errors[$optionname]));
             $widest = QA_PERMIT_USERS;
             $narrowest = QA_PERMIT_ADMINS;
             $permitoptions = qa_admin_permit_options($widest, $narrowest, !QA_FINAL_EXTERNAL_USERS && qa_opt('confirm_user_emails'));
             if (count($permitoptions) > 1) {
                 qa_optionfield_make_select($optionfield, $permitoptions, $value, $value == QA_PERMIT_CONFIRMED ? QA_PERMIT_USERS : min(array_keys($permitoptions)));
             }
             $this->content['form']['fields'][$optionname] = $optionfield;
             $this->content['form']['fields'][$optionname . '_points'] = array('id' => $optionname . '_points', 'tags' => 'NAME="option_' . $optionname . '_points" ID="option_' . $optionname . '_points"', 'type' => 'number', 'value' => qa_opt($optionname . '_points'), 'prefix' => qa_lang_html('admin/users_must_have') . ' ', 'note' => qa_lang_html('admin/points'));
             $checkboxtodisplay[$optionname . '_points'] = '(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS) . ') ||(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS_CONFIRMED) . ')';
         }
         qa_set_display_rules($this->content, $checkboxtodisplay);
     }
     qa_html_theme_base::doctype();
 }
     break;
 case 'captcha_module':
     $captchaoptions = array();
     foreach ($captchamodules as $modulename) {
         $captchaoptions[qa_html($modulename)] = qa_html($modulename);
         if ($modulename == $value) {
             $module = qa_load_module('captcha', $modulename);
             if (method_exists($module, 'admin_form')) {
                 $optionfield['note'] = '<a href="' . qa_admin_module_options_path('captcha', $modulename) . '">' . qa_lang_html('admin/options') . '</a>';
             }
         }
     }
     qa_optionfield_make_select($optionfield, $captchaoptions, $value, '');
     break;
 case 'moderate_update_time':
     qa_optionfield_make_select($optionfield, array('0' => qa_lang_html('options/time_written'), '1' => qa_lang_html('options/time_approved')), $value, '0');
     break;
 case 'max_rate_ip_as':
 case 'max_rate_ip_cs':
 case 'max_rate_ip_flags':
 case 'max_rate_ip_logins':
 case 'max_rate_ip_messages':
 case 'max_rate_ip_qs':
 case 'max_rate_ip_registers':
 case 'max_rate_ip_uploads':
 case 'max_rate_ip_votes':
     $optionfield['note'] = qa_lang_html('admin/per_ip_hour');
     break;
 case 'max_rate_user_as':
 case 'max_rate_user_cs':
 case 'max_rate_user_flags':
Example #4
0
 case 'feed_for_search':
     $feedrequest = 'search/why do birds sing';
     $feedisexample = true;
     break;
 case 'captcha_module':
     $captchaoptions = array();
     foreach ($captchamodules as $modulename) {
         $captchaoptions[qa_html($modulename)] = qa_html($modulename);
         if ($modulename == $value) {
             $module = qa_load_module('captcha', $modulename);
             if (method_exists($module, 'admin_form')) {
                 $optionfield['note'] = '<A HREF="' . qa_path_html('admin/plugins', null, null, null, md5('captcha/' . $modulename)) . '">' . qa_lang_html('admin/options') . '</A>';
             }
         }
     }
     qa_optionfield_make_select($optionfield, $captchaoptions, $value, '');
     break;
 case 'max_rate_ip_as':
 case 'max_rate_ip_cs':
 case 'max_rate_ip_flags':
 case 'max_rate_ip_logins':
 case 'max_rate_ip_messages':
 case 'max_rate_ip_qs':
 case 'max_rate_ip_registers':
 case 'max_rate_ip_uploads':
 case 'max_rate_ip_votes':
     $optionfield['note'] = qa_lang_html('admin/per_ip_hour');
     break;
 case 'max_rate_user_as':
 case 'max_rate_user_cs':
 case 'max_rate_user_flags':
Example #5
0
 function doctype()
 {
     qa_html_theme_base::doctype();
     //qa_error_log($this->content);
     if (qa_post_text('poll_vote')) {
         return;
     }
     if ($this->request == 'admin/permissions' && function_exists('qa_register_plugin_phrases') && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
         $permits[] = 'permit_vote_poll';
         $permits[] = 'permit_post_poll';
         $permits[] = 'permit_close_poll';
         $permits[] = 'permit_delete_poll';
         foreach ($permits as $optionname) {
             $value = qa_opt($optionname);
             $optionfield = array('id' => $optionname, 'label' => qa_lang_html('polls/' . $optionname) . ':', 'tags' => 'NAME="option_' . $optionname . '" ID="option_' . $optionname . '"', 'error' => qa_html(@$errors[$optionname]));
             $widest = QA_PERMIT_USERS;
             $narrowest = QA_PERMIT_ADMINS;
             $permitoptions = qa_admin_permit_options($widest, $narrowest, !QA_FINAL_EXTERNAL_USERS && qa_opt('confirm_user_emails'));
             if (count($permitoptions) > 1) {
                 qa_optionfield_make_select($optionfield, $permitoptions, $value, $value == QA_PERMIT_CONFIRMED ? QA_PERMIT_USERS : min(array_keys($permitoptions)));
             }
             $this->content['form']['fields'][$optionname] = $optionfield;
             $this->content['form']['fields'][$optionname . '_points'] = array('id' => $optionname . '_points', 'tags' => 'NAME="option_' . $optionname . '_points" ID="option_' . $optionname . '_points"', 'type' => 'number', 'value' => qa_opt($optionname . '_points'), 'prefix' => qa_lang_html('admin/users_must_have') . '&nbsp;', 'note' => qa_lang_html('admin/points'));
             $checkboxtodisplay[$optionname . '_points'] = '(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS) . ') ||(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS_CONFIRMED) . ')';
         }
         qa_set_display_rules($this->content, $checkboxtodisplay);
     }
     if (qa_opt('poll_enable')) {
         global $qa_request;
         if ($qa_request == 'polls') {
             $this->content['navigation']['sub'] = array('special' => 1);
         } else {
             if ($this->template == 'ask' && !qa_user_permit_error('permit_post_q') && !qa_opt('site_maintenance') && qa_permit_check('permit_post_poll')) {
                 $this->content['form']['tags'] .= ' onSubmit="pollSubmit(event)"';
                 $this->content['form']['fields'][] = array('label' => qa_lang('polls/checkbox_text'), 'tags' => 'NAME="is_poll" ID="is_poll" onclick="jQuery(\'#qa-poll-ask-div\').toggle()"', 'type' => 'checkbox');
                 $this->content['form']['fields'][] = array('note' => '<div id="qa-poll-ask-div" style="display:none"><p class="qa-form-tall-label"><input type="checkbox" name="poll_multiple">' . qa_lang('polls/multiple_text') . '</p><p class="qa-form-tall-label">' . qa_lang('polls/answers_text') . '</p><input type="input" class="qa-poll-answer-text" class="qa-poll-answer-text" name="poll_answer_1" id="poll_answer_1">&nbsp;<input type="button" class="qa-poll-answer-add" value="+" onclick="addPollAnswer(poll_answer_index)"></div>', 'type' => 'static');
             }
         }
         $poll = array();
         //Find all polls only for non blog pages
         if (strpos($this->template, 'blog') !== 0) {
             $poll_array = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^postmeta WHERE meta_key=$', 'is_poll'));
             foreach ($poll_array as $q) {
                 $poll[(int) $q['post_id']] = $q['meta_value'];
             }
         }
         if ($this->template == 'question') {
             if (isset($this->content['q_view'])) {
                 $qid = $this->content['q_view']['raw']['postid'];
                 $author = $this->content['q_view']['raw']['userid'];
                 if (isset($poll[$qid])) {
                     // is a poll
                     $this->poll = $poll[$qid];
                     if (qa_post_text('poll_delete') && (!qa_user_permit_error('permit_delete_poll') || qa_get_logged_in_userid() == $author)) {
                         $this->deletePoll($qid);
                         $this->content['error'] = 'Poll deleted.';
                         return;
                     } else {
                         if (qa_post_text('poll_close') && (!qa_user_permit_error('permit_close_poll') || qa_get_logged_in_userid() == $author)) {
                             $this->closePoll($qid);
                         } else {
                             if (qa_post_text('poll_reopen') && (!qa_user_permit_error('permit_close_poll') || qa_get_logged_in_userid() == $author)) {
                                 $this->reopenPoll($qid);
                             }
                         }
                     }
                     // add post elements
                     // title
                     $this->content['title'] .= ' ' . qa_lang('polls/question_title');
                     // poll div
                     $this->content['q_view']['content'] = @$this->content['q_view']['content'] . '<div id="qa-poll-div">' . $this->getPollDiv($qid, qa_get_logged_in_userid()) . '</div>';
                     // css class
                     $this->content['q_view']['main_form_tags'] = @$this->content['q_view']['main_form_tags'] . ' class="qa-poll"';
                 }
             }
         }
         //Mark the questions only as polls , discard the blog pages
         if (isset($this->content['q_list']) && strpos($this->template, 'blog') !== 0) {
             foreach ($this->content['q_list']['qs'] as $idx => $question) {
                 if (isset($poll[$question['raw']['postid']])) {
                     $this->content['q_list']['qs'][$idx]['title'] .= ' ' . qa_lang('polls/question_title');
                 }
             }
         }
     }
 }
 function doctype()
 {
     //qa_error_log($this->content);
     if ($this->request == 'admin/permissions' && function_exists('qa_register_plugin_phrases') && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
         $permits[] = 'expert_question_ask';
         $permits[] = 'expert_question_roles';
         foreach ($permits as $optionname) {
             $value = qa_opt($optionname);
             $optionfield = array('id' => $optionname, 'label' => qa_lang_html('expert_question/' . $optionname) . ':', 'tags' => 'NAME="option_' . $optionname . '" ID="option_' . $optionname . '"', 'error' => qa_html(@$errors[$optionname]));
             $widest = QA_PERMIT_USERS;
             $narrowest = QA_PERMIT_ADMINS;
             $permitoptions = qa_admin_permit_options($widest, $narrowest, !QA_FINAL_EXTERNAL_USERS && qa_opt('confirm_user_emails'));
             if (count($permitoptions) > 1) {
                 qa_optionfield_make_select($optionfield, $permitoptions, $value, $value == QA_PERMIT_CONFIRMED ? QA_PERMIT_USERS : min(array_keys($permitoptions)));
             }
             $this->content['form']['fields'][$optionname] = $optionfield;
             $this->content['form']['fields'][$optionname . '_points'] = array('id' => $optionname . '_points', 'tags' => 'NAME="option_' . $optionname . '_points" ID="option_' . $optionname . '_points"', 'type' => 'number', 'value' => qa_opt($optionname . '_points'), 'prefix' => qa_lang_html('admin/users_must_have') . '&nbsp;', 'note' => qa_lang_html('admin/points'));
             $checkboxtodisplay[$optionname . '_points'] = '(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS) . ') ||(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS_CONFIRMED) . ')';
         }
         qa_set_display_rules($this->content, $checkboxtodisplay);
     }
     $this->expert_user = $this->is_expert_user();
     if (!$this->expert_user) {
         foreach ($this->content['navigation']['main'] as $key => $nav) {
             if ($nav['url'] == qa_path_html(qa_opt('expert_question_page_url'))) {
                 unset($this->content['navigation']['main'][$key]);
             }
         }
     }
     if (qa_clicked('do_expert_answeradd') && ($this->expert_user || $this->content['q_view']['raw']['userid'] === qa_get_logged_in_userid())) {
         global $qa_login_userid, $questionid, $question, $answers, $question, $qa_request;
         $innotify = qa_post_text('notify') ? true : false;
         $inemail = qa_post_text('email');
         qa_get_post_content('editor', 'content', $ineditor, $incontent, $informat, $intext);
         $isduplicate = false;
         foreach ($answers as $answer) {
             if (!$answer['hidden']) {
                 if (implode(' ', qa_string_to_words($answer['content'])) == implode(' ', qa_string_to_words($incontent))) {
                     $isduplicate = true;
                 }
             }
         }
         if (!$isduplicate) {
             if (!isset($qa_login_userid)) {
                 $qa_cookieid = qa_cookie_get_create();
             }
             // create a new cookie if necessary
             $answerid = qa_answer_create($qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $incontent, $informat, $intext, $innotify, $inemail, $question);
             qa_report_write_action($qa_login_userid, $qa_cookieid, 'a_post', $questionid, $answerid, null);
             qa_redirect($qa_request, null, null, null, qa_anchor('A', $answerid));
         } else {
             $pageerror = qa_lang_html('question/duplicate_content');
         }
         qa_page_q_load_q();
         // reload since we may have changed something
     }
     if (qa_opt('expert_question_enable')) {
         if ($this->expert_user && qa_opt('expert_question_show_count')) {
             $this->expertcount = qa_db_read_one_value(qa_db_query_sub("SELECT COUNT(postid) FROM ^postmeta, ^posts WHERE ^postmeta.meta_key='is_expert_question' AND ^postmeta.post_id=^posts.postid AND ^posts.acount=0" . (is_array($this->expert_user) ? " AND ^posts.categoryid IN (#)" : " AND \$"), $this->expert_user), true);
             if ($this->expertcount) {
                 foreach ($this->content['navigation']['main'] as $key => $nav) {
                     if ($nav['url'] == qa_path_html(qa_opt('expert_question_page_url'))) {
                         $this->content['navigation']['main'][$key]['label'] .= ' (' . $this->expertcount . ')';
                     }
                 }
             }
         }
         global $qa_request;
         if ($qa_request == qa_opt('expert_question_page_url')) {
             $this->content['navigation']['sub'] = array('special' => 1);
         }
         if ($this->template == 'ask' && in_array(qa_opt('expert_question_type'), array(0, 2)) && !qa_user_permit_error('permit_post_q') && !qa_permit_value_error(qa_opt('expert_question_ask'), qa_get_logged_in_userid(), qa_get_logged_in_level(), qa_get_logged_in_flags()) && !qa_opt('site_maintenance')) {
             $this->content['form']['fields'][] = array('tags' => 'NAME="is_expert_question" ID="is_expert_question"', 'value' => qa_get(qa_opt('expert_question_page_url')) == 'true' ? qa_opt('expert_question_yes') : qa_opt('expert_question_no'), 'type' => 'select-radio', 'options' => array('no' => qa_opt('expert_question_no'), 'yes' => qa_opt('expert_question_yes')));
         }
         if ($this->template == 'user' && qa_get_logged_in_handle() === $this->_user_handle()) {
             if (!isset($this->content['navigation']['sub'])) {
                 $this->content['navigation']['sub'] = array('profile' => array('url' => qa_path_html('user/' . $this->_user_handle(), null, qa_opt('site_url')), 'label' => $this->_user_handle(), 'selected' => !qa_get('tab') ? true : false), qa_opt('expert_question_page_url') => array('url' => qa_path_html('user/' . $this->_user_handle(), array('tab' => qa_opt('expert_question_page_url')), qa_opt('site_url')), 'label' => qa_opt('expert_question_page_title'), 'selected' => qa_get('tab') == qa_opt('expert_question_page_url') ? true : false));
             } else {
                 $this->content['navigation']['sub'][qa_opt('expert_question_page_url')] = array('url' => qa_path_html('user/' . $this->_user_handle(), array('tab' => qa_opt('expert_question_page_url')), qa_opt('site_url')), 'label' => qa_opt('expert_question_page_title'), 'selected' => qa_get('tab') == qa_opt('expert_question_page_url') ? true : false);
             }
         }
         if ($this->template == 'question') {
             $qid = $this->content['q_view']['raw']['postid'];
             $expert = qa_db_read_one_value(qa_db_query_sub("SELECT meta_value FROM ^postmeta WHERE meta_key='is_expert_question' AND post_id=#", $qid), true);
             if ($expert) {
                 // is expert question
                 $this->expert_question = 1;
                 // modify post elements
                 // title
                 $this->content['title'] .= ' ' . qa_opt('expert_question_title');
                 // css class
                 $this->content['q_view']['tags'] .= ' class="qa-expert-question"';
                 // remove hidden stuff
                 unset($this->content['q_view']['hidden']);
                 unset($this->content['hidden']);
             }
         }
     }
     qa_html_theme_base::doctype();
 }
     if ($optionname == 'permit_view_q_page') {
         $narrowest = QA_PERMIT_CONFIRMED;
     } elseif ($optionname == 'permit_edit_c' || $optionname == 'permit_select_a' || $optionname == 'permit_hide_show' || $optionname == 'permit_anon_view_ips') {
         $narrowest = QA_PERMIT_MODERATORS;
     } elseif ($optionname == 'permit_post_c' || $optionname == 'permit_edit_q' || $optionname == 'permit_edit_a' || $optionname == 'permit_flag') {
         $narrowest = QA_PERMIT_EDITORS;
     } elseif ($optionname == 'permit_vote_q' || $optionname == 'permit_vote_a') {
         $narrowest = QA_PERMIT_POINTS_CONFIRMED;
     } elseif ($optionname == 'permit_delete_hidden') {
         $narrowest = QA_PERMIT_ADMINS;
     } else {
         $narrowest = QA_PERMIT_EXPERTS;
     }
     $permitoptions = qa_admin_permit_options($widest, $narrowest, !QA_FINAL_EXTERNAL_USERS && qa_opt('confirm_user_emails'));
     if (count($permitoptions) > 1) {
         qa_optionfield_make_select($optionfield, $permitoptions, $value, $value == QA_PERMIT_CONFIRMED ? QA_PERMIT_USERS : min(array_keys($permitoptions)));
     } else {
         $optionfield['type'] = 'static';
         $optionfield['value'] = reset($permitoptions);
     }
     break;
 case 'permit_post_q_points':
 case 'permit_post_a_points':
 case 'permit_post_c_points':
 case 'permit_vote_q_points':
 case 'permit_vote_a_points':
 case 'permit_flag_points':
 case 'permit_edit_q_points':
 case 'permit_edit_a_points':
 case 'permit_edit_c_points':
 case 'permit_select_a_points':