Commit 4060d1fe by Scott

Handle allow_anonymous_naming option

Show/hide field and handle security on backend.
parent 267c11b9
......@@ -109,7 +109,7 @@ if (qa_clicked('doask')) {
$categoryids = array_keys(qa_category_path($categories, @$in['categoryid']));
$userlevel = qa_user_level_for_categories($categoryids);
$in['name'] = qa_post_text('name');
$in['name'] = qa_opt('allow_anonymous_naming') ? qa_post_text('name') : null;
$in['notify'] = strlen(qa_post_text('notify')) > 0;
$in['email'] = qa_post_text('email');
$in['queued'] = qa_user_moderation_reason($userlevel) !== false;
......@@ -292,7 +292,7 @@ if (qa_using_tags()) {
qa_array_insert($qa_content['form']['fields'], null, array('tags' => $field));
}
if (!isset($userid)) {
if (!isset($userid) && qa_opt('allow_anonymous_naming')) {
qa_set_up_name_field($qa_content, $qa_content['form']['fields'], @$in['name']);
}
......
......@@ -390,7 +390,7 @@ function qa_page_q_edit_q_form(&$qa_content, $question, $in, $errors, $completet
}
if ($question['isbyuser']) {
if (!qa_is_logged_in())
if (!qa_is_logged_in() && qa_opt('allow_anonymous_naming'))
qa_set_up_name_field($qa_content, $form['fields'], isset($in['name']) ? $in['name'] : @$question['name'], 'q_');
qa_set_up_notify_fields($qa_content, $form['fields'], 'Q', qa_get_logged_in_email(),
......@@ -441,7 +441,7 @@ function qa_page_q_edit_q_submit($question, $answers, $commentsfollows, $closepo
$userlevel = null;
if ($question['isbyuser']) {
$in['name'] = qa_post_text('q_name');
$in['name'] = qa_opt('allow_anonymous_naming') ? qa_post_text('q_name') : null;
$in['notify'] = qa_post_text('q_notify') !== null;
$in['email'] = qa_post_text('q_email');
}
......@@ -730,7 +730,7 @@ function qa_page_q_edit_a_form(&$qa_content, $id, $answer, $question, $answers,
// Show name and notification field if appropriate
if ($answer['isbyuser']) {
if (!qa_is_logged_in())
if (!qa_is_logged_in() && qa_opt('allow_anonymous_naming'))
qa_set_up_name_field($qa_content, $form['fields'], isset($in['name']) ? $in['name'] : @$answer['name'], $prefix);
qa_set_up_notify_fields($qa_content, $form['fields'], 'A', qa_get_logged_in_email(),
......@@ -765,7 +765,7 @@ function qa_page_q_edit_a_submit($answer, $question, $answers, $commentsfollows,
);
if ($answer['isbyuser']) {
$in['name'] = qa_post_text($prefix . 'name');
$in['name'] = qa_opt('allow_anonymous_naming') ? qa_post_text($prefix . 'name') : null;
$in['notify'] = qa_post_text($prefix . 'notify') !== null;
$in['email'] = qa_post_text($prefix . 'email');
}
......@@ -936,7 +936,7 @@ function qa_page_q_edit_c_form(&$qa_content, $id, $comment, $in, $errors)
);
if ($comment['isbyuser']) {
if (!qa_is_logged_in())
if (!qa_is_logged_in() && qa_opt('allow_anonymous_naming'))
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(),
......@@ -968,7 +968,7 @@ function qa_page_q_edit_c_submit($comment, $question, $parent, &$in, &$errors)
$in = array();
if ($comment['isbyuser']) {
$in['name'] = qa_post_text($prefix . 'name');
$in['name'] = qa_opt('allow_anonymous_naming') ? qa_post_text($prefix . 'name') : null;
$in['notify'] = qa_post_text($prefix . 'notify') !== null;
$in['email'] = qa_post_text($prefix . 'email');
}
......
......@@ -352,7 +352,7 @@ function qa_page_q_click_check_form_code($post, &$error)
function qa_page_q_add_a_submit($question, $answers, $usecaptcha, &$in, &$errors)
{
$in = array(
'name' => qa_post_text('a_name'),
'name' => qa_opt('allow_anonymous_naming') ? qa_post_text('a_name') : null,
'notify' => qa_post_text('a_notify') !== null,
'email' => qa_post_text('a_email'),
'queued' => qa_user_moderation_reason(qa_user_level_for_post($question)) !== false,
......@@ -440,7 +440,7 @@ function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptch
$prefix = 'c' . $parentid . '_';
$in = array(
'name' => qa_post_text($prefix . 'name'),
'name' => qa_opt('allow_anonymous_naming') ? qa_post_text($prefix . 'name') : null,
'notify' => qa_post_text($prefix . 'notify') !== null,
'email' => qa_post_text($prefix . 'email'),
'queued' => qa_user_moderation_reason(qa_user_level_for_post($parent)) !== false,
......
......@@ -959,7 +959,7 @@ function qa_page_q_add_a_form(&$qa_content, $formid, $captchareason, $question,
'label' => qa_lang_html('main/cancel_button'),
);
if (!qa_is_logged_in())
if (!qa_is_logged_in() && qa_opt('allow_anonymous_naming'))
qa_set_up_name_field($qa_content, $form['fields'], @$in['name'], 'a_');
qa_set_up_notify_fields($qa_content, $form['fields'], 'A', qa_get_logged_in_email(),
......@@ -1104,7 +1104,7 @@ function qa_page_q_add_c_form(&$qa_content, $question, $parent, $formid, $captch
if (!strlen($custom))
unset($form['fields']['custom']);
if (!qa_is_logged_in())
if (!qa_is_logged_in() && qa_opt('allow_anonymous_naming'))
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(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment