Commit 0aac7383 authored by Penny Leach's avatar Penny Leach
Browse files

added support for section (arbitrary) contextual help, added help call

back to pieform configure function, fixed up param_retrieve to not
use REQUEST (as it reads cookies), but instead to read post and get
directly. added contextual help for login box
parent c7f39eed
......@@ -76,7 +76,10 @@ if (!$USER->is_logged_in()) {
'required' => true
),
'ignore' => count($institutions) == 1
)
),
'chelp' => array(
'value' => get_help_icon('core', 'login', null, null, null, 'loginbox'),
),
)
),
......
......@@ -249,7 +249,7 @@ contextualHelpSelected = null;
contextualHelpContainer = null;
contextualHelpDeferrable = null;
function contextualHelp(formName, helpName, pluginType, pluginName, page, ref) {
function contextualHelp(formName, helpName, pluginType, pluginName, page, section, ref) {
var key;
var target = $(formName + '_' + helpName + '_container');
var url = config.wwwroot + 'json/help.php';
......@@ -263,6 +263,10 @@ function contextualHelp(formName, helpName, pluginType, pluginName, page, ref) {
key = pluginType + '/' + pluginName + '/' + page;
url_params.page = page;
}
else if (section) {
key = pluginType + '/' + pluginName + '/' + section;
url_params.section = section;
}
else {
key = pluginType + '/' + pluginName + '/' + helpName;
url_params.form = formName;
......@@ -290,7 +294,7 @@ function contextualHelp(formName, helpName, pluginType, pluginName, page, ref) {
'style': 'position: absolute',
'class': 'contextualHelp'
},
'spinner'
IMG({'src': config.theme['images/loading.gif']})
);
var position = getElementPosition(ref);
position.x += 10;
......
......@@ -35,6 +35,7 @@ json_headers();
$plugintype = param_alpha('plugintype');
$pluginname = param_alpha('pluginname');
$page = param_variable('page', null);
$section = param_variable('section', null);
$form = param_alphanum('form', null);
$element = param_alphanum('element', null);
......@@ -51,6 +52,9 @@ if ($page) {
$page = str_replace('-', '/', $page);
$file .= 'pages/' . $page . '.html';
}
else if ($section) {
$file .= 'sections/' . $section . '.html';
}
else if (!empty($form) && !empty($element)) {
$file .= 'forms/' . $form . '.' . $element . '.html';
}
......
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login</title>
</head>
<body>
<h3>Login</h3>
<p>Your login details will be the username and password you entered during registration or as assigned by the Site Administrator.&nbsp; Where relevant, you will also need to select the institution with which you are associated.&nbsp; If you have forgotten your login details you can request a password reset at any time.</p>
<p>For your security, you will be automatically logged out of the system after a certain period of inactivity on the site, as set by the Site Administrator.</p>
<p><strong><em>Note</em></strong> - This site requires a minimum web browser of Internet Explorer 6.0 or higher, Firefox 1.5 or higher, Safari 2 or higher, Opera 9 or higher or any other browser compatible with these standards.&nbsp; You can usually determine the version of your browser software by selecting About via the Help menu.</p>
<p>You must also have cookies enabled on your browser in order to use this site. </p>
</body>
</html>
......@@ -887,6 +887,7 @@ function pieform_configure() {
'postsubmitcallback' => 'formStopProcessing',
'jserrormessage' => get_string('errorprocessingform'),
'configdirs' => get_config('libroot') . 'form/',
'helpcallback' => 'pieform_get_help',
'elements' => array(
'sesskey' => array(
'type' => 'hidden',
......
......@@ -454,17 +454,23 @@ function json_check_sesskey() {
}
function _param_retrieve($name) {
// if it's not set and we have a default
if (!isset($_REQUEST[$name]) && func_num_args() == 2) {
// prefer post
if (isset($_POST[$name])) {
$value = $_POST[$name];
}
else if (isset($_GET[$name])) {
$value = $_GET[$name];
}
if (empty($value) && func_num_args() == 2) {
$php_work_around = func_get_arg(1);
return array($php_work_around, true);
}
if (!isset($_REQUEST[$name])) {
if (empty($value)) {
throw new ParameterException("Missing parameter '$name' and no default supplied");
}
return array($_REQUEST[$name], false);
return array($value, false);
}
/**
......@@ -910,15 +916,23 @@ function getoptions_country() {
*
*/
function get_help_icon($plugintype, $pluginname, $form, $element, $page='') {
return ' <span class="help"><a href="" onclick="' .
function get_help_icon($plugintype, $pluginname, $form, $element, $page='', $section='') {
return ' <span class="help"><a href="" onclick="'.
hsc(
'contextualHelp(' . json_encode($form) . ',' .
json_encode($element) . ',' . json_encode($plugintype) . ',' .
json_encode($pluginname) . ',' . json_encode($page) . ',this); return false;'
json_encode($pluginname) . ',' . json_encode($page) . ',' .
json_encode($section)
. ',this); return false;'
) . '">?</a></span>';
}
function pieform_get_help(Pieform $form, $element) {
return get_help_icon($form->get_property('plugintype'),
$form->get_property('pluginname'),
$form->get_name(), $element['name']);
}
function make_link($url) {
return '<a href="' . $url . '">' . $url . '</a>';
}
......
......@@ -53,10 +53,10 @@ if (!empty($_SESSION['registered'])) {
die_info(get_string('registeredok', 'auth.internal'));
}
$key = param_alphanum('key', null);
// Step three of registration - given a key, fill out mandatory profile fields,
// optional profile icon, and register the user
if (isset($_REQUEST['key'])) {
if (isset($key)) {
function profileform_submit(Pieform $form, $values) {
global $registration, $SESSION, $USER;
......@@ -151,7 +151,7 @@ if (isset($_REQUEST['key'])) {
// Begin the registration form buliding
if (!$registration = get_record_select('usr_registration', 'key = ? AND expiry >= ?', array($_REQUEST['key'], db_format_timestamp(time())))) {
if (!$registration = get_record_select('usr_registration', 'key = ? AND expiry >= ?', array($key, db_format_timestamp(time())))) {
die_info(get_string('registrationnosuchkey', 'auth.internal'));
}
......@@ -209,7 +209,7 @@ if (isset($_REQUEST['key'])) {
$elements['key'] = array(
'type' => 'hidden',
'name' => 'key',
'value' => $_REQUEST['key']
'value' => $key
);
$elements['submit'] = array(
'type' => 'submit',
......@@ -338,6 +338,8 @@ $elements['submit'] = array(
$form = array(
'name' => 'register',
'method' => 'post',
'plugintype' => 'core',
'pluginname' => 'register',
'action' => '',
'renderer' => 'table',
'elements' => $elements
......
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