1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-02 22:02:07 +02:00

ACP usability

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10450 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Henry Sudhof 2010-01-26 10:57:00 +00:00
parent b4d6b1e980
commit b4c87cc504
3 changed files with 64 additions and 13 deletions

View File

@ -1,5 +1,5 @@
<dl>
<dt><label for="answer">{L_CONFIRM_QUESTION}:</label><br /><span>{L_CONFIRM_QUESTION_EXPLAIN}</span></dt>
<dt><label for="answer"><!-- IF QA_CONFIRM_QUESTION --> {QA_CONFIRM_QUESTION} <!-- ELSE --> {L_CONFIRM_QUESTION} <!-- ENDIF -->:</label><br /><span>{L_CONFIRM_QUESTION_EXPLAIN}</span></dt>
<dd>
<input type="text" tabindex="10" name="answer" id="answer" size="45" class="inputbox autowidth" title="{L_ANSWER}" />

View File

@ -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;
}
}
}
?>

View File

@ -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.',
));
?>