diff --git a/phpBB/adm/style/captcha_qa_acp_demo.html b/phpBB/adm/style/captcha_qa_acp_demo.html
index 57bed8af53..0ea2d6a024 100644
--- a/phpBB/adm/style/captcha_qa_acp_demo.html
+++ b/phpBB/adm/style/captcha_qa_acp_demo.html
@@ -1,5 +1,5 @@
-
{L_CONFIRM_QUESTION_EXPLAIN}
+
{L_CONFIRM_QUESTION_EXPLAIN}
-
diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php
index 45811c5d26..7526cb67cf 100644
--- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php
@@ -214,6 +214,22 @@ class phpbb_captcha_qa
*/
function get_demo_template()
{
+ global $config, $db, $template;
+
+ if ($this->is_available())
+ {
+ $sql = 'SELECT question_text
+ FROM ' . CAPTCHA_QUESTIONS_TABLE . "
+ WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'";
+ $result = $db->sql_query_limit($sql, 1);
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $template->assign_vars(array(
+ 'QA_CONFIRM_QUESTION' => $row['question_text'],
+ ));
+ }
+ $db->sql_freeresult($result);
+ }
return 'captcha_qa_acp_demo.html';
}
@@ -393,7 +409,6 @@ class phpbb_captcha_qa
{
global $db, $user;
-
if (!sizeof($this->question_ids))
{
return false;
@@ -617,21 +632,28 @@ class phpbb_captcha_qa
}
else if ($question_id && $action == 'delete')
{
- if (confirm_box(true))
+ if ($this->get_class_name() !== $config['captcha_plugin'] || !$this->acp_is_last($question_id))
{
- $this->acp_delete_question($question_id);
+ if (confirm_box(true))
+ {
+ $this->acp_delete_question($question_id);
- trigger_error($user->lang['QUESTION_DELETED'] . adm_back_link($list_url));
+ trigger_error($user->lang['QUESTION_DELETED'] . adm_back_link($list_url));
+ }
+ else
+ {
+ confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
+ 'question_id' => $question_id,
+ 'action' => $action,
+ 'configure' => 1,
+ 'select_captcha' => $this->get_class_name(),
+ ))
+ );
+ }
}
else
{
- confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
- 'question_id' => $question_id,
- 'action' => $action,
- 'configure' => 1,
- 'select_captcha' => $this->get_class_name(),
- ))
- );
+ trigger_error($user->lang['QA_LAST_QUESTION'] . adm_back_link($list_url), E_USER_WARNING);
}
}
else
@@ -711,7 +733,7 @@ class phpbb_captcha_qa
}
else if ($submit)
{
- trigger_error($user->lang['FORM_INVALID'] . adm_back_link($list_url));
+ trigger_error($user->lang['FORM_INVALID'] . adm_back_link($list_url), E_USER_WARNING);
}
}
}
@@ -942,6 +964,33 @@ class phpbb_captcha_qa
return $langs;
}
+
+
+
+ /**
+ * See if there is a question other than the one we have
+ */
+ function acp_is_last($question_id)
+ {
+ global $config, $db;
+
+ if ($question_id)
+ {
+ $sql = 'SELECT question_id
+ FROM ' . CAPTCHA_QUESTIONS_TABLE . "
+ WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'
+ AND question_id <> " . (int) $question_id;
+ $result = $db->sql_query_limit($sql, 1);
+ $question = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ if (!$question)
+ {
+ return true;
+ }
+ return false;
+ }
+ }
}
?>
\ No newline at end of file
diff --git a/phpBB/language/en/captcha_qa.php b/phpBB/language/en/captcha_qa.php
index 1d443e995a..5cd822b3c4 100644
--- a/phpBB/language/en/captcha_qa.php
+++ b/phpBB/language/en/captcha_qa.php
@@ -58,6 +58,8 @@ $lang = array_merge($lang, array(
'QUESTION_TEXT_EXPLAIN' => 'The question that will be asked on registration.',
'QA_ERROR_MSG' => 'Please fill in all fields and enter at least one answer.',
+ 'QA_LAST_QUESTION' => 'You cannot delete all questions while the plugin is active.',
+
));
?>
\ No newline at end of file