function qa_page_q_edit_c_submit($comment, $question, $parent, &$in, &$errors)
{
    $commentid = $comment['postid'];
    $prefix = 'c' . $commentid . '_';
    $in = array();
    if ($comment['isbyuser']) {
        $in['name'] = qa_post_text($prefix . 'name');
        $in['notify'] = qa_post_text($prefix . 'notify') ? true : false;
        $in['email'] = qa_post_text($prefix . 'email');
    }
    if (!qa_user_post_permit_error('permit_edit_silent', $comment)) {
        $in['silent'] = qa_post_text($prefix . 'silent');
    }
    qa_get_post_content($prefix . 'editor', $prefix . 'content', $in['editor'], $in['content'], $in['format'], $in['text']);
    // here the $in array only contains values for parts of the form that were displayed, so those are only ones checked by filters
    $errors = array();
    if (!qa_check_form_security_code('edit-' . $commentid, qa_post_text($prefix . 'code'))) {
        $errors['content'] = qa_lang_html('misc/form_security_again');
    } else {
        $in['queued'] = qa_opt('moderate_edited_again') && qa_user_moderation_reason(qa_user_level_for_post($comment));
        $filtermodules = qa_load_modules_with('filter', 'filter_comment');
        foreach ($filtermodules as $filtermodule) {
            $oldin = $in;
            $filtermodule->filter_comment($in, $errors, $question, $parent, $comment);
            qa_update_post_text($in, $oldin);
        }
        if (empty($errors)) {
            $userid = qa_get_logged_in_userid();
            $handle = qa_get_logged_in_handle();
            $cookieid = qa_cookie_get();
            if (!isset($in['silent'])) {
                $in['silent'] = false;
            }
            $setnotify = $comment['isbyuser'] ? qa_combine_notify_email($comment['userid'], $in['notify'], $in['email']) : $comment['notify'];
            qa_comment_set_content($comment, $in['content'], $in['format'], $in['text'], $setnotify, $userid, $handle, $cookieid, $question, $parent, @$in['name'], $in['queued'], $in['silent']);
            return true;
        }
    }
    return false;
}
function qa_page_q_edit_c_submit($comment, $question, $parent, &$in, &$errors)
{
    $commentid = $comment['postid'];
    $prefix = 'c' . $commentid . '_';
    $in = array();
    if ($comment['isbyuser']) {
        $in['notify'] = qa_post_text($prefix . 'notify') ? true : false;
        $in['email'] = qa_post_text($prefix . 'email');
    }
    qa_get_post_content($prefix . 'editor', $prefix . 'content', $in['editor'], $in['content'], $in['format'], $in['text']);
    $errors = array();
    $filtermodules = qa_load_modules_with('filter', 'filter_comment');
    foreach ($filtermodules as $filtermodule) {
        $oldin = $in;
        $filtermodule->filter_comment($in, $errors, $question, $parent, $comment);
        qa_update_post_text($in, $oldin);
    }
    if (empty($errors)) {
        $userid = qa_get_logged_in_userid();
        $handle = qa_get_logged_in_handle();
        $cookieid = qa_cookie_get();
        qa_comment_set_content($comment, $in['content'], $in['format'], $in['text'], $comment['isbyuser'] ? qa_combine_notify_email($comment['userid'], $in['notify'], $in['email']) : $comment['notify'], $userid, $handle, $cookieid, $question, $parent);
        return true;
    }
    return false;
}
Exemple #3
0
function qa_post_set_content($postid, $title, $content, $format = null, $tags = null, $notify = null, $email = null, $byuserid = null, $extravalue = null)
{
    $oldpost = qa_post_get_full($postid, 'QAC');
    if (!isset($title)) {
        $title = $oldpost['title'];
    }
    if (!isset($content)) {
        $content = $oldpost['content'];
    }
    if (!isset($format)) {
        $format = $oldpost['format'];
    }
    if (!isset($tags)) {
        $tags = qa_tagstring_to_tags($oldpost['tags']);
    }
    if (isset($notify) || isset($email)) {
        $setnotify = qa_combine_notify_email($oldpost['userid'], isset($notify) ? $notify : isset($oldpost['notify']), isset($email) ? $email : $oldpost['notify']);
    } else {
        $setnotify = $oldpost['notify'];
    }
    $byhandle = qa_post_userid_to_handle($byuserid);
    $text = qa_post_content_to_text($content, $format);
    switch ($oldpost['basetype']) {
        case 'Q':
            $tagstring = qa_post_tags_to_tagstring($tags);
            qa_question_set_content($oldpost, $title, $content, $format, $text, $tagstring, $setnotify, $byuserid, $byhandle, null, $extravalue);
            break;
        case 'A':
            $question = qa_post_get_full($oldpost['parentid'], 'Q');
            qa_answer_set_content($oldpost, $content, $format, $text, $setnotify, $byuserid, $byhandle, null, $question);
            break;
        case 'C':
            $parent = qa_post_get_full($oldpost['parentid'], 'QA');
            $question = qa_post_parent_to_question($parent);
            qa_comment_set_content($oldpost, $content, $format, $text, $setnotify, $byuserid, $byhandle, null, $question, $parent);
            break;
    }
}
            qa_flags_clear_all($comment, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid);
            qa_redirect($qa_request, null, null, null, qa_anchor($commentparenttype, $comment['parentid']));
        }
        if ($comment['editbutton']) {
            if (qa_clicked('docancel')) {
                qa_redirect($qa_request);
            } elseif (qa_clicked('doeditc_' . $commentid)) {
                qa_redirect($qa_request, array('state' => 'edit-' . $commentid));
            } elseif (qa_clicked('dosavec_' . $commentid) && qa_page_q_permit_edit($comment, 'permit_edit_c')) {
                $innotify = qa_post_text('notify') ? true : false;
                $inemail = qa_post_text('email');
                qa_get_post_content('editor', 'comment', $ineditor, $incomment, $informat, $intext);
                $errors = qa_comment_validate($incomment, $informat, $intext, $innotify, $inemail);
                if (empty($errors)) {
                    $setnotify = $comment['isbyuser'] ? qa_combine_notify_email($comment['userid'], $innotify, $inemail) : $comment['notify'];
                    qa_comment_set_content($comment, $incomment, $informat, $intext, $setnotify, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $question, $commentanswer);
                    qa_report_write_action($qa_login_userid, $qa_cookieid, 'c_edit', $questionid, $commentanswerid, $commentid);
                    qa_redirect($qa_request, null, null, null, qa_anchor($commentparenttype, $comment['parentid']));
                } else {
                    $formtype = 'c_edit';
                    $formpostid = $commentid;
                    // keep editing if an error
                }
            } elseif ($qa_state == 'edit-' . $commentid && qa_page_q_permit_edit($comment, 'permit_edit_c')) {
                $formtype = 'c_edit';
                $formpostid = $commentid;
            }
        }
    }
}
function qa_page_q_permit_edit($post, $permitoption)