function process_request($request) { require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; require_once QA_INCLUDE_DIR . 'qa-db-post-create.php'; require_once QA_INCLUDE_DIR . 'mp-db-users.php'; // report that we entered this page qa_report_event('page_enter', qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), array('params' => $_SERVER['QUERY_STRING'])); // create the editor and update its content qa_get_post_content('editor', 'content', $ineditor, $incontent, $informat, $intext); $editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_qs'); $editor = qa_load_editor(@$incontent, @$informat, $editorname); // retrieve variable data $innotify = qa_post_text('notify') ? true : false; // handle creation of annoucement if (qa_post_text('docreate')) { //retrieve data $title = qa_post_text('title'); $content = $incontent; $format = $informat; // validate data // handle create work // actual create process is in file mp-app-posts.php $postid = qa_post_create('AN', null, $title, $content, $format, mp_get_categoryid(), null, qa_get_logged_in_userid(), $innotify); // redirect page qa_redirect('mp-announcements-page'); // our work is done here } $qa_content = qa_content_prepare(); // if the user is not logged in, request user to login if (!qa_get_logged_in_userid()) { $qa_content['error'] = qa_insert_login_links('Please ^1log in^2 or ^3register^4 first.', $request); return $qa_content; } $qa_content['title'] = 'Create Announcement'; $qa_content['form_newannouncement'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('title' => array('label' => qa_lang_html('announcements/a_title_label'), 'tags' => 'NAME="title"', 'value' => qa_html(qa_post_text('title')), 'error' => qa_html(@$errors['title'])), 'content' => array_merge($editor->get_field($qa_content, @$incontent, @$informat, 'content', 12, false), array('label' => qa_lang_html('announcements/a_content_label'), 'error' => qa_html(@$errors['content']))), 'notify' => array('label' => 'Send email notification to all registered students', 'tags' => 'NAME="notify"', 'type' => 'checkbox', 'value' => qa_html($innotify))), 'buttons' => array('ok' => array('tags' => 'NAME="docreate"', 'label' => 'Create Announcement', 'value' => '1')), 'hidden' => array('hiddenfield' => '1', 'editor' => qa_html($editorname))); // create the sub menu for navigation $qa_content['navigation']['sub'] = mp_announcements_sub_navigation(); $qa_content['navigation']['sub']['create']['selected'] = true; return $qa_content; }
} if (empty($errors)) { $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create(); // create a new cookie if necessary $questionid = qa_question_create($followanswer, $userid, qa_get_logged_in_handle(), $cookieid, $in['title'], $in['content'], $in['format'], $in['text'], qa_tags_to_tagstring($in['tags']), $in['notify'], $in['email'], $in['categoryid'], $in['extra'], $in['queued'], $in['name']); qa_redirect(qa_q_request($questionid, $in['title'])); // our work is done here } } } // Prepare content for theme $qa_content = qa_content_prepare(false, array_keys(qa_category_path($categories, @$in['categoryid']))); $qa_content['title'] = qa_lang_html(isset($followanswer) ? 'question/ask_follow_title' : 'question/ask_title'); $qa_content['error'] = @$errors['page']; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_qs'); $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname); $field = qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], 'content', 12, false); $field['label'] = qa_lang_html('question/q_content_label'); $field['error'] = qa_html(@$errors['content']); $custom = qa_opt('show_custom_ask') ? trim(qa_opt('custom_ask')) : ''; $qa_content['form'] = array('tags' => 'name="ask" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('custom' => array('type' => 'custom', 'note' => $custom), 'title' => array('label' => qa_lang_html('question/q_title_label'), 'tags' => 'name="title" id="title" autocomplete="off"', 'value' => qa_html(@$in['title']), 'error' => qa_html(@$errors['title'])), 'similar' => array('type' => 'custom', 'html' => '<span id="similar"></span>'), 'content' => $field), 'buttons' => array('ask' => array('tags' => 'onclick="qa_show_waiting_after(this, false); ' . (method_exists($editor, 'update_script') ? $editor->update_script('content') : '') . '"', 'label' => qa_lang_html('question/ask_button'))), 'hidden' => array('editor' => qa_html($editorname), 'code' => qa_get_form_security_code('ask'), 'doask' => '1')); if (!strlen($custom)) { unset($qa_content['form']['fields']['custom']); } if (qa_opt('do_ask_check_qs') || qa_opt('do_example_tags')) { $qa_content['script_rel'][] = 'qa-content/qa-ask.js?' . QA_VERSION; $qa_content['form']['fields']['title']['tags'] .= ' onchange="qa_title_change(this.value);"'; if (strlen(@$in['title'])) { $qa_content['script_onloads'][] = 'qa_title_change(' . qa_js($in['title']) . ');'; } }
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; }
function qa_page_q_edit_c_form(&$qa_content, $id, $comment, $in, $errors) { $commentid = $comment['postid']; $prefix = 'c' . $commentid . '_'; $content = isset($in['content']) ? $in['content'] : $comment['content']; $format = isset($in['format']) ? $in['format'] : $comment['format']; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs'); $editor = qa_load_editor($content, $format, $editorname); $form = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'id' => $id, 'title' => qa_lang_html('question/edit_c_title'), 'style' => 'tall', 'fields' => array('content' => array_merge(qa_editor_load_field($editor, $qa_content, $content, $format, $prefix . 'content', 4, true), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('save' => array('tags' => 'onclick="qa_show_waiting_after(this, false); ' . (method_exists($editor, 'update_script') ? $editor->update_script($prefix . 'content') : '') . '"', 'label' => qa_lang_html('main/save_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'dosave' => '1', $prefix . 'code' => qa_get_form_security_code('edit-' . $commentid))); if ($comment['isbyuser']) { if (!qa_is_logged_in()) { qa_set_up_name_field($qa_content, $form['fields'], isset($in['name']) ? $in['name'] : @$comment['name'], $prefix); } qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : !empty($comment['notify']), isset($in['email']) ? $in['email'] : @$comment['notify'], @$errors['email'], $prefix); } if (!qa_user_post_permit_error('permit_edit_silent', $comment)) { $form['fields']['silent'] = array('type' => 'checkbox', 'label' => qa_lang_html('question/save_silent_label'), 'tags' => 'name="' . $prefix . 'silent"', 'value' => qa_html(@$in['silent'])); } return $form; }
function qa_page_q_add_c_form(&$qa_content, $questionid, $parentid, $formid, $usecaptcha, $in, $errors, $loadfocusnow) { switch (qa_user_permit_error('permit_post_c')) { case 'login': $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request())); break; case 'confirm': $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), qa_request())); break; case 'limit': $form = array('title' => qa_lang_html('question/comment_limit')); break; default: $form = array('title' => qa_lang_html('users/no_permission')); break; case false: $prefix = 'c' . $parentid . '_'; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs'); $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname); if (method_exists($editor, 'update_script')) { $updatescript = $editor->update_script($prefix . 'content'); } else { $updatescript = ''; } $custom = qa_opt('show_custom_comment') ? trim(qa_opt('custom_comment')) : ''; $form = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '" NAME="c_form_' . qa_html($parentid) . '"', 'title' => qa_lang_html($questionid == $parentid ? 'question/your_comment_q' : 'question/your_comment_a'), 'fields' => array('custom' => array('type' => 'custom', 'note' => $custom), 'content' => array_merge(qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], $prefix . 'content', 4, $loadfocusnow, $loadfocusnow), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('comment' => array('tags' => 'onClick="' . $updatescript . ' return qa_submit_comment(' . qa_js($questionid) . ', ' . qa_js($parentid) . ', this);"', 'label' => qa_lang_html('question/add_comment_button')), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'doadd' => '1')); if (!strlen($custom)) { unset($form['fields']['custom']); } qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), $in['email'], @$errors['email'], $prefix); $onloads = array(); if ($usecaptcha) { $userid = qa_get_logged_in_userid(); $captchaloadscript = qa_set_up_captcha_field($qa_content, $form['fields'], $errors, qa_insert_login_links(qa_lang_html(isset($userid) ? 'misc/captcha_confirm_fix' : 'misc/captcha_login_fix'))); if (strlen($captchaloadscript)) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_show=function() { ' . $captchaloadscript . ' }'; } } if (!$loadfocusnow) { if (method_exists($editor, 'load_script')) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_load=function() { ' . $editor->load_script($prefix . 'content') . ' }'; } if (method_exists($editor, 'focus_script')) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_focus=function() { ' . $editor->focus_script($prefix . 'content') . ' }'; } $form['buttons']['cancel']['tags'] .= ' onClick="return qa_toggle_element()"'; } if (count($onloads)) { $qa_content['script_onloads'][] = $onloads; } } $form['id'] = $formid; $form['collapse'] = !$loadfocusnow; $form['style'] = 'tall'; return $form; }
function qa_get_request_content() { $qa_content = qa_get_request_content_base(); // displays signature form in user profile $qa_request = strtolower(qa_request()); $reqs = explode('/', $qa_request); if ($reqs[0] == 'user') { // permissions if (isset($qa_content['form_profile']['fields']['permits'])) { $ov = $qa_content['form_profile']['fields']['permits']['value']; $ov = str_replace('[profile/signature_allow]', qa_lang('signature_plugin/signature_allow'), $ov); $ov = str_replace('[profile/signature_edit_allow]', qa_lang('signature_plugin/signature_edit_allow'), $ov); $qa_content['form_profile']['fields']['permits']['value'] = $ov; } $qa_content['user_signature_form'] = array(); $userid = @$qa_content['raw']['userid']; if (!$userid) { return $qa_content; } $handles = qa_userids_to_handles(array($userid)); $handle = $handles[$userid]; if (qa_get_logged_in_handle() == $handle && !qa_user_permit_error('signature_allow') || !qa_user_permit_error('signature_edit_allow')) { $ok = null; $formats = qa_list_modules('editor'); $format = qa_opt('signatures_format'); $editorname = $formats[$format]; if (!strlen($editorname)) { $editorname = qa_lang_html('admin/basic_editor'); } $editor = qa_load_editor('', '', $editorname); qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^usersignatures (' . 'userid INT(11) NOT NULL,' . 'signature VARCHAR (1000) DEFAULT \'\',' . 'format VARCHAR (20) DEFAULT \'\',' . 'id INT(11) NOT NULL AUTO_INCREMENT,' . 'UNIQUE (userid),' . 'PRIMARY KEY (id)' . ') ENGINE=MyISAM DEFAULT CHARSET=utf8'); if (qa_clicked('signature_save')) { if (strlen(qa_post_text('signature_text')) > qa_opt('signatures_length')) { $error = 'Max possible signature length is 1000 characters'; } else { $readdata = $editor->read_post('signature_text'); $informat = $readdata['format']; $incontent = qa_post_text('signature_text'); qa_db_query_sub('INSERT INTO ^usersignatures (userid,signature,format) VALUES (#,$,$) ON DUPLICATE KEY UPDATE signature=$,format=$', $userid, $incontent, $informat, $incontent, $informat); $ok = 'Signature Saved.'; } } $content = qa_db_read_one_assoc(qa_db_query_sub('SELECT BINARY signature AS signature,format FROM ^usersignatures WHERE userid=#', $userid), true); $field = qa_editor_load_field($editor, $qa_content, $content['signature'], $content['format'], 'signature_text', 12, false); $field['label'] = qa_lang_html('signature_plugin/signature'); $fields['content'] = $field; if (!$editorname || $editorname == 'Markdown Editor') { $fields['elCount'] = array('label' => '<div id="elCount">' . qa_opt('signatures_length') . '</div>', 'type' => 'static'); } $form = array('ok' => $ok && !isset($error) ? $ok : null, 'error' => @$error, 'style' => 'tall', 'title' => '<a name="signature_text"></a>' . qa_lang_html('signature_plugin/signature'), 'tags' => 'action="' . qa_self_html() . '#signature_text" method="POST"', 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="signature_save"')), 'hidden' => array('editor' => qa_html($editorname), 'dosavesig' => '1')); $qa_content['user_signature_form'] = $form; } else { if (qa_opt('signatures_profile_enable')) { $content = qa_db_read_one_assoc(qa_db_query_sub('SELECT BINARY signature as signature, format FROM ^usersignatures WHERE userid=#', $userid), true); if (!$content) { return $qa_content; } $informat = $content['format']; $viewer = qa_load_viewer($content['signature'], $informat); global $options; $signature = qa_viewer_html($content['signature'], $informat, array('blockwordspreg' => @$options['blockwordspreg'], 'showurllinks' => @$options['showurllinks'], 'linksnewwindow' => @$options['linksnewwindow'])); $fields[] = array('label' => qa_opt('signatures_header') . $signature . qa_opt('signatures_footer'), 'type' => 'static'); $qa_content['user_signature_form'] = array('title' => 'Signature', 'fields' => $fields, 'style' => 'tall'); } } } return $qa_content; }
$qa_content['a_list']['title'] = qa_lang_html_sub('question/x_answers_title', $countanswers); } // Prepare content for form to add an answer if ($formtype == 'a_add') { // Form for adding answers $answerform = null; switch (qa_user_permit_error('permit_post_a')) { case 'login': $answerform = array('style' => 'tall', 'title' => qa_insert_login_links(qa_lang_html('question/answer_must_login'), $qa_request)); break; case 'confirm': $answerform = array('style' => 'tall', 'title' => qa_insert_login_links(qa_lang_html('question/answer_must_confirm'), $qa_request)); break; case false: $editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_as'); $editor = qa_load_editor(@$incontent, @$informat, $editorname); $answerform = array('title' => qa_lang_html('question/your_answer_title'), 'style' => 'tall', 'fields' => array('content' => array_merge($editor->get_field($qa_content, @$incontent, @$informat, 'content', 12, $formrequested), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('answer' => array('tags' => 'NAME="doansweradd"', 'label' => qa_lang_html('question/add_answer_button'))), 'hidden' => array('editor' => qa_html($editorname))); if ($formrequested) { // only show cancel button if user explicitly requested the form $answerform['buttons']['cancel'] = array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button')); } qa_set_up_notify_fields($qa_content, $answerform['fields'], 'A', qa_get_logged_in_email(), isset($innotify) ? $innotify : qa_opt('notify_users_default'), @$inemail, @$errors['email']); if ($usecaptcha) { qa_set_up_captcha_field($qa_content, $answerform['fields'], @$errors, qa_insert_login_links(qa_lang_html(isset($qa_login_userid) ? 'misc/captcha_confirm_fix' : 'misc/captcha_login_fix'))); } break; } if ($formrequested || empty($qa_content['a_list']['as'])) { $qa_content['q_view']['a_form'] = $answerform; } else { $answerkeys = array_keys($qa_content['a_list']['as']);
function qa_page_q_add_c_form(&$qa_content, $question, $parent, $formid, $captchareason, $in, $errors, $loadfocusnow) { // The 'approve', 'login', 'confirm', 'userblock', 'ipblock' permission errors are reported to the user here // The other option ('level') prevents the comment button being shown, in qa_page_q_post_rules(...) switch (qa_user_post_permit_error('permit_post_c', $parent, QA_LIMIT_COMMENTS)) { case 'login': $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request())); break; case 'confirm': $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), qa_request())); break; case 'approve': $form = array('title' => qa_lang_html('question/comment_must_be_approved')); break; case 'limit': $form = array('title' => qa_lang_html('question/comment_limit')); break; default: $form = array('title' => qa_lang_html('users/no_permission')); break; case false: $prefix = 'c' . $parent['postid'] . '_'; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs'); $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname); if (method_exists($editor, 'update_script')) { $updatescript = $editor->update_script($prefix . 'content'); } else { $updatescript = ''; } $custom = qa_opt('show_custom_comment') ? trim(qa_opt('custom_comment')) : ''; $form = array('tags' => 'method="post" action="' . qa_self_html() . '" name="c_form_' . qa_html($parent['postid']) . '"', 'title' => qa_lang_html($question['postid'] == $parent['postid'] ? 'question/your_comment_q' : 'question/your_comment_a'), 'fields' => array('custom' => array('type' => 'custom', 'note' => $custom), 'content' => array_merge(qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], $prefix . 'content', 4, $loadfocusnow, $loadfocusnow), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('comment' => array('tags' => 'onclick="' . $updatescript . ' return qa_submit_comment(' . qa_js($question['postid']) . ', ' . qa_js($parent['postid']) . ', this);"', 'label' => qa_lang_html('question/add_comment_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'doadd' => '1', $prefix . 'code' => qa_get_form_security_code('comment-' . $parent['postid']))); if (!strlen($custom)) { unset($form['fields']['custom']); } if (!qa_is_logged_in()) { qa_set_up_name_field($qa_content, $form['fields'], @$in['name'], $prefix); } qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), $in['email'], @$errors['email'], $prefix); $onloads = array(); if ($captchareason) { $captchaloadscript = qa_set_up_captcha_field($qa_content, $form['fields'], $errors, qa_captcha_reason_note($captchareason)); if (strlen($captchaloadscript)) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_show=function() { ' . $captchaloadscript . ' };'; } } if (!$loadfocusnow) { if (method_exists($editor, 'load_script')) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_load=function() { ' . $editor->load_script($prefix . 'content') . ' };'; } if (method_exists($editor, 'focus_script')) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_focus=function() { ' . $editor->focus_script($prefix . 'content') . ' };'; } $form['buttons']['cancel']['tags'] .= ' onclick="return qa_toggle_element()"'; } if (count($onloads)) { $qa_content['script_onloads'][] = $onloads; } } $form['id'] = $formid; $form['collapse'] = !$loadfocusnow; $form['style'] = 'tall'; return $form; }
function qa_page_q_edit_c_form(&$qa_content, $id, $comment, $in, $errors) { $commentid = $comment['postid']; $prefix = 'c' . $commentid . '_'; $content = isset($in['content']) ? $in['content'] : $comment['content']; $format = isset($in['format']) ? $in['format'] : $comment['format']; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs'); $editor = qa_load_editor($content, $format, $editorname); $form = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'id' => $id, 'title' => qa_lang_html('question/edit_c_title'), 'style' => 'tall', 'fields' => array('content' => array_merge(qa_editor_load_field($editor, $qa_content, $content, $format, $prefix . 'content', 4, true), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('save' => array('tags' => method_exists($editor, 'update_script') ? 'onClick="' . $editor->update_script($prefix . 'content') . '"' : '', 'label' => qa_lang_html('main/save_button')), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'dosave' => '1')); if ($comment['isbyuser']) { qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : !empty($comment['notify']), isset($in['email']) ? $in['email'] : @$comment['notify'], @$errors['email'], $prefix); } return $form; }
function qa_ajax_comment_form() { global $qa_content, $incomment, $informat, $errors, $questionid, $ineditor, $innotify, $inemail, $jumptoanchor, $focusonid, $usecaptcha, $qa_login_userid; $jumptoanchor = isset($answerid) ? qa_anchor('A', $answerid) : qa_anchor('Q', $questionid); $focusonid = 'comment'; $editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_cs'); $editor = qa_load_editor(@$incomment, @$informat, $editorname); $form = array('title' => qa_lang_html(isset($answerid) ? 'question/your_comment_a' : 'question/your_comment_q'), 'style' => 'tall', 'fields' => array('content' => array_merge($editor->get_field($qa_content, @$incomment, @$informat, 'comment', 4, true), array('error' => qa_html(@$errors['content']), 'rows' => 8))), 'buttons' => array('comment' => array('tags' => 'onclick="ajaxPostComment()"', 'label' => qa_lang_html('question/add_comment_button'), 'ajax_comment' => $this->idx2), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'), 'ajax_comment' => $this->idx2)), 'hidden' => array('editor' => qa_html($editorname))); $form['fields']['content']['tags'] = @$form['fields']['tags'] . ' id="comment" onkeydown="if(event.keyCode == 27) toggleComment(false);"'; // add reminder text if commenting on answer to own question $ourid = qa_get_logged_in_userid(); if (qa_opt('ajax_comment_answer_reminder') && !$this->content['q_view']['raw']['selchildid'] && isset($answerid) && $this->content['q_view']['raw']['userid'] == $ourid && @$this->content['a_list']['as'][$this->idx - 1]['raw']['userid'] != $ourid) { $form['fields']['custom_message'] = array('note' => '<div class="ajax-comment-reminder">' . qa_opt('ajax_comment_answer_reminder_text') . '</div>', 'type' => 'static'); } qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($innotify) ? $innotify : qa_opt('notify_users_default'), @$inemail, @$errors['email']); if ($usecaptcha) { qa_set_up_captcha_field($qa_content, $form['fields'], @$errors, qa_insert_login_links(qa_lang_html(isset($qa_login_userid) ? 'misc/captcha_confirm_fix' : 'misc/captcha_login_fix'))); } $form['ajax_comment'] = 0; $this->idx2++; return $form; }
public function process_request($request) { $qa_content = qa_content_prepare(); $category_1 = qa_opt('qa_blog_cat_1'); $category_2 = qa_opt('qa_blog_cat_2'); $category_3 = qa_opt('qa_blog_cat_3'); $category_4 = qa_opt('qa_blog_cat_4'); $category_5 = qa_opt('qa_blog_cat_5'); $html = ""; $postid = qa_request_part(1); if (isset($postid)) { $result = qa_db_query_sub('SELECT * FROM ^blog_posts WHERE `postid` LIKE #', $postid); if ($row = mysqli_fetch_array($result)) { $userid = $row['userid']; $author = handleLinkForID($row['userid']); $editor = qa_get_logged_in_userid(); if ($userid >= $editor) { if (qa_clicked('doedit')) { $in = array(); qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']); $in['title'] = qa_post_text('title'); $in['category'] = qa_post_text('category'); if (strlen($in['title']) < 10 || strlen($in['content']) < 50 || $in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { if (strlen($in['title']) < 10) { $errors['title'] = qa_lang('qa_blog_lang/error_title'); } if (strlen($in['content']) < 50) { $errors['content'] = qa_lang('qa_blog_lang/error_content'); } if ($in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { $errors['type'] = 'Invalid category'; } } else { $type = 0; if ($in['category'] === 'cat_1') { $type = 1; } else { if ($in['category'] === 'cat_2') { $type = 2; } else { if ($in['category'] === 'cat_3') { $type = 3; } else { if ($in['category'] === 'cat_4') { $type = 4; } else { if ($in['category'] === 'cat_5') { $type = 5; } } } } } $result = qa_db_query_sub('UPDATE ^blog_posts SET updated=NOW(), title=$, content=$, type=#, format=$ WHERE postid=#', $in['title'], $in['content'], $type, 'markdown', $postid); header('location:' . qa_path_to_root() . '/blog/' . $postid); } } else { if (qa_clicked('doresetoptions')) { $in = array(); qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']); $in['title'] = qa_post_text('title'); $in['category'] = qa_post_text('category'); if (strlen($in['title']) < 10 || strlen($in['content']) < 50 || $in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { if (strlen($in['title']) < 10) { $errors['title'] = qa_lang('qa_blog_lang/error_title'); } if (strlen($in['content']) < 50) { $errors['content'] = qa_lang('qa_blog_lang/error_content'); } if ($in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { $errors['type'] = 'Invalid category'; } } else { $type = 0; if ($in['category'] === 'cat_1') { $type = 1; } else { if ($in['category'] === 'cat_2') { $type = 2; } else { if ($in['category'] === 'cat_3') { $type = 3; } else { if ($in['category'] === 'cat_4') { $type = 4; } else { if ($in['category'] === 'cat_5') { $type = 5; } } } } } $result = qa_db_query_sub('UPDATE ^blog_posts SET updated=NOW(), title=$, content=$, type=#, format=$ WHERE postid=#', $in['title'], $in['content'], $type, 'draft', $postid); header('location:' . qa_path_to_root() . '/blog/' . $postid); } } else { if (qa_clicked('dogoback')) { qa_redirect('blog'); } else { if (qa_clicked('dosaveoptions')) { qa_redirect('blog'); } else { if (qa_clicked('docancel')) { qa_redirect('blog'); } } } } } } $qa_content['title'] = 'Editing: ' . $row['title']; $userpostslink = '/user/' . qa_get_logged_in_handle() . '/articles'; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_qs'); $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname); $field = qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], 'content', 12, false); $typeoptions = array('cat_1' => $category_1, 'cat_2' => $category_2, 'cat_3' => $category_3, 'cat_4' => $category_4, 'cat_5' => $category_5); $qa_content['form'] = array('tags' => 'name="edit" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('title' => array('label' => qa_lang('qa_blog_lang/post_title'), 'tags' => 'name="title" id="title" autocomplete="off"', 'value' => $row['title'], 'rows' => 2, 'error' => qa_html(@$errors['title'])), 'category' => array('label' => qa_lang('qa_blog_lang/post_cat'), 'type' => 'select', 'tags' => 'name="category"', 'options' => $typeoptions, 'error' => qa_html(@$errors['type'])), 'similar' => array('type' => 'custom', 'html' => '<span id="similar"></span>'), 'content' => array('value' => $row['content'], 'tags' => 'name="content"', 'error' => qa_html(@$errors['content']), 'rows' => 4)), 'buttons' => array('edit' => array('tags' => 'onclick="qa_show_waiting_after(this, false); ' . (method_exists($editor, 'update_script') ? $editor->update_script('content') : '') . '"', 'label' => qa_lang('qa_blog_lang/update_button')), 'save' => array('tags' => 'name="doresetoptions"', 'label' => qa_lang('qa_blog_lang/draft_button')), 'hide' => array('tags' => 'name="dosaveoptions"', 'label' => qa_lang('qa_blog_lang/hide_button')), 'goback' => array('tags' => 'name="dogoback"', 'label' => qa_lang('qa_blog_lang/cancel_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang('qa_blog_lang/delete_button'))), 'hidden' => array('editor' => qa_html($editorname), 'code' => qa_get_form_security_code('article'), 'doedit' => '1')); $html = "<h2>" . qa_lang('qa_blog_lang/past_post') . "</h2>"; $userid = qa_get_logged_in_userid(); $result = qa_db_query_sub("SELECT * FROM ^blog_posts WHERE userid = '{$userid}' ORDER BY posted DESC"); $i = 0; while ($blob = mysqli_fetch_array($result)) { $i++; $html .= '<ul><li><h3><a href="blog/' . $blob['postid'] . '/' . seoUrl3($blob['title']) . '">' . $blob['title'] . '</a><h3></li></ul>'; } if ($i == 0) { $html .= qa_lang('qa_blog_lang/post_null'); } $html .= ''; $qa_content['custom2'] = $html; } else { $site_url = qa_opt('site_url'); $qa_content['title'] = qa_lang('qa_blog_lang/title_error'); $qa_content['error'] = qa_lang('qa_blog_lang/edit_error') . '<a href=' . $site_url . '/blog/> ' . qa_lang('qa_blog_lang/edit_error1') . '</a>'; $qa_content['custom2'] = qa_lang('qa_blog_lang/edit_note'); } return $qa_content; } }
public function process_request($request) { $category_1 = qa_opt('qa_blog_cat_1'); $category_2 = qa_opt('qa_blog_cat_2'); $category_3 = qa_opt('qa_blog_cat_3'); $category_4 = qa_opt('qa_blog_cat_4'); $category_5 = qa_opt('qa_blog_cat_5'); $qa_content = qa_content_prepare(); $errors = array(); if (qa_clicked('docancel')) { qa_redirect('blog'); } else { if (qa_clicked('dosaveoptions')) { $in = array(); qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']); $in['title'] = qa_post_text('title'); $in['category'] = qa_post_text('category'); if (strlen($in['title']) < 10 || strlen($in['content']) < 50 || $in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { if (strlen($in['title']) < 10) { $errors['title'] = qa_lang('qa_blog_lang/error_title'); } if (strlen($in['content']) < 50) { $errors['content'] = qa_lang('qa_blog_lang/error_content'); } if ($in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { $errors['type'] = 'Invalid category'; } } else { $type = 0; if ($in['category'] === 'cat_1') { $type = 1; } else { if ($in['category'] === 'cat_2') { $type = 2; } else { if ($in['category'] === 'cat_3') { $type = 3; } else { if ($in['category'] === 'cat_4') { $type = 4; } else { if ($in['category'] === 'cat_5') { $type = 5; } } } } } qa_db_query_sub('INSERT INTO ^blog_posts (postid, userid, posted, title, type, content, views,format) VALUES (0,#,NOW(),$,#,$,0,$)', qa_get_logged_in_userid(), $in['title'], $type, $in['content'], 'draft'); header('location:' . qa_path_to_root() . '/user/' . qa_get_logged_in_handle() . ''); } } else { if (qa_clicked('doarticle')) { $in = array(); qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']); $in['title'] = qa_post_text('title'); $in['category'] = qa_post_text('category'); if (strlen($in['title']) < 10 || strlen($in['content']) < 50 || $in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { if (strlen($in['title']) < 10) { $errors['title'] = qa_lang('qa_blog_lang/error_title'); } if (strlen($in['content']) < 50) { $errors['content'] = qa_lang('qa_blog_lang/error_content'); } if ($in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { $errors['type'] = 'Invalid category'; } } else { $type = 0; if ($in['category'] === 'cat_1') { $type = 1; } else { if ($in['category'] === 'cat_2') { $type = 2; } else { if ($in['category'] === 'cat_3') { $type = 3; } else { if ($in['category'] === 'cat_4') { $type = 4; } else { if ($in['category'] === 'cat_5') { $type = 5; } } } } } $result = qa_db_query_sub('INSERT INTO ^blog_posts (postid, userid, posted, title, type, content, views,format) VALUES (0,#,NOW(),$,#,$,0,$)', qa_get_logged_in_userid(), $in['title'], $type, $in['content'], 'markdown'); header('location:' . qa_path_to_root() . '/blog/'); } } } } if (qa_is_logged_in()) { $qa_content['title'] = qa_lang('qa_blog_lang/articles_page'); $userpostslink = '/user/' . qa_get_logged_in_handle() . '/articles'; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_qs'); $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname); $field = qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], 'content', 12, false); $field['label'] = ''; $field['error'] = qa_html(@$errors['content']); $qa_content['custom'] = qa_lang('qa_blog_lang/default_blog_tagline'); $typeoptions = array('cat_1' => $category_1, 'cat_2' => $category_2, 'cat_3' => $category_3, 'cat_4' => $category_4, 'cat_5' => $category_5); $qa_content['form'] = array('tags' => 'name="blog" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('title' => array('label' => qa_lang('qa_blog_lang/post_title'), 'tags' => 'name="title" id="title" autocomplete="off"', 'value' => qa_html(@$in['title']), 'error' => qa_html(@$errors['title'])), 'category' => array('label' => qa_lang('qa_blog_lang/post_cat'), 'type' => 'select', 'tags' => 'name="category"', 'options' => $typeoptions, 'error' => qa_html(@$errors['type'])), 'similar' => array('type' => 'custom', 'html' => '<span id="similar"></span>'), 'content' => $field), 'buttons' => array('post' => array('tags' => 'onclick="qa_show_waiting_after(this, false); ' . (method_exists($editor, 'update_script') ? $editor->update_script('content') : '') . '"', 'label' => qa_lang('qa_blog_lang/post_button')), 'save' => array('tags' => 'name="dosaveoptions"', 'label' => qa_lang('qa_blog_lang/draft_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang('qa_blog_lang/cancel_button'))), 'hidden' => array('editor' => qa_html($editorname), 'code' => qa_get_form_security_code('article'), 'doarticle' => '1')); $html = "<h2>" . qa_lang('qa_blog_lang/past_post') . "</h2>"; $userid = qa_get_logged_in_userid(); $result = qa_db_query_sub("SELECT * FROM ^blog_posts WHERE userid = '{$userid}' ORDER BY posted DESC"); $i = 0; while ($blob = mysqli_fetch_array($result)) { $i++; $html .= '<ul><li><h3><a href="blog/' . $blob['postid'] . '/' . seoUrl3($blob['title']) . '">' . $blob['title'] . '</a><h3></li></ul>'; } if ($i == 0) { $html .= qa_lang('qa_blog_lang/post_null'); } $html .= ''; $qa_content['custom2'] = $html; } else { $qa_content['title'] = qa_lang('qa_blog_lang/title_error'); $qa_content['error'] = qa_insert_login_links(qa_lang('qa_blog_lang/access_error'), $request); } return $qa_content; }
function qa_page_q_edit_c_form($commentid, $answerid) { global $commentsfollows, $qa_content, $errors, $incomment, $informat, $ineditor, $questionid, $jumptoanchor, $focusonid, $innotify, $inemail; $comment = $commentsfollows[$commentid]; $content = isset($incomment) ? $incomment : $comment['content']; $format = isset($informat) ? $informat : $comment['format']; $editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_cs'); $editor = qa_load_editor($content, $format, $editorname); $jumptoanchor = isset($answerid) ? qa_anchor('A', $answerid) : qa_anchor('Q', $questionid); $form = array('title' => '<A NAME="edit">' . qa_lang_html('question/edit_c_title') . '</A>', 'style' => 'tall', 'fields' => array('content' => array_merge($editor->get_field($qa_content, $content, $format, 'comment', 4, true), array('error' => qa_html($errors['content'])))), 'buttons' => array('save' => array('label' => qa_lang_html('main/save_button')), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array('editor' => qa_html($editorname), 'dosavec_' . qa_html($commentid) => '1')); if ($comment['isbyuser']) { qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($innotify) ? $innotify : !empty($comment['notify']), isset($inemail) ? $inemail : @$comment['notify'], @$errors['email']); } return $form; }