function security_questions_list_form in Security Questions 7.2
Same name and namespace in other branches
- 6.2 security_questions.admin.inc \security_questions_list_form()
- 6 security_questions.module \security_questions_list_form()
- 7 security_questions.module \security_questions_list_form()
Questions list page with add form.
1 string reference to 'security_questions_list_form'
- security_questions_menu in ./
security_questions.module - Implements hook_menu().
File
- ./
security_questions.admin.inc, line 10 - Administrative UI for the security questions module.
Code
function security_questions_list_form($form, &$form_state) {
$form = array();
// Add a new global question.
$form['add'] = array(
'#type' => 'container',
);
$form['add']['question'] = array(
'#title' => t('Add a question'),
'#type' => 'textfield',
'#description' => t('Enter the question text.'),
);
$form['add']['actions'] = array(
'#type' => 'actions',
);
$form['add']['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Add'),
);
// List global questions.
$form['list'] = array(
'#type' => 'container',
);
$form['list'][] = array(
'#prefix' => '<h3>',
'#markup' => t('Global questions'),
'#suffix' => '</h3>',
);
$form['list'][] = array(
'#prefix' => '<p>',
'#markup' => t('The questions shown below are available for use by all users. Optionally, users may also be allowed to create their own questions.'),
'#suffix' => '</p>',
);
$rows = array();
$questions = security_questions_question_load_multiple(array(
'uid' => 0,
));
foreach ($questions as $question) {
$rows[] = array(
check_plain($question->question),
check_plain($question->machine_name),
l(t('delete'), 'admin/config/people/security_questions/questions/delete/' . $question->sqid),
);
}
$table = array(
'header' => array(
t('Question'),
t('Machine name'),
t('Operations'),
),
'rows' => $rows,
'empty' => t('No global questions available. Use the form above to create one.'),
);
// See if any other modules want to add anything to the table.
drupal_alter('security_questions_list', $table);
$output = theme('table', $table);
$form['list'][] = array(
'#markup' => $output,
);
return $form;
}