Commit 734491bc authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Bug 1841988: Making sure pieform is generated before smarty_core() call"

parents f5ab8825 22e4a2dd
......@@ -40,9 +40,16 @@ if (php_sapi_name() != 'cli' && get_config('urlsecret') !== null) {
}
}
$upgrades = check_upgrades();
// Remove the "settings" component, which is not a real component (see check_upgrades())
unset($upgrades['settings']);
if (!$upgrades) {
die_info('<p>' . get_string('noupgrades', 'admin') . '</p>');
}
$smarty = smarty();
$upgrades = check_upgrades();
if (!empty($upgrades['core']->install)) {
define('TITLE', get_string('installation', 'admin'));
$smarty->assign('upgradeheading', get_string('performinginstallation', 'admin'));
......@@ -59,13 +66,6 @@ else {
log_info(get_string('performingupgrades', 'admin'));
}
// Remove the "settings" component, which is not a real component (see check_upgrades())
unset($upgrades['settings']);
if (!$upgrades) {
die_info('<p>' . get_string('noupgrades', 'admin') . '</p>');
}
$start = time();
if (empty($upgrades['core']->install)) {
// Insert a record into config before the upgrade starts, to prevent subsequent hits
......
......@@ -22,10 +22,9 @@ $s = institution_selector_for_page(param_alphanum('institution', false),
get_config('wwwroot') . 'admin/users/institutionadmins.php');
$institution = $s['institution'];
$smarty = smarty();
setpageicon($smarty, 'icon-university');
if ($institution === false) {
$smarty = smarty();
setpageicon($smarty, 'icon-university');
$smarty->display('admin/users/noinstitutions.tpl');
exit;
}
......@@ -66,6 +65,13 @@ $form = array(
)
);
function adminusers_validate(Pieform $form, $values) {
// If the institution has no members show error
if (!(get_column('usr_institution', 'usr', 'institution', $values['institution']))) {
$form->set_error(null, get_string('nousersselected', 'admin'));
}
}
function adminusers_submit(Pieform $form, $values) {
global $SESSION, $USER;
......@@ -90,12 +96,14 @@ function adminusers_submit(Pieform $form, $values) {
$SESSION->add_ok_msg(get_string('adminusersupdated', 'admin'));
redirect('/admin/users/institutionadmins.php?institution=' . $inst);
}
$form = pieform($form);
$smarty = smarty();
setpageicon($smarty, 'icon-university');
$smarty->assign('institutionselector', $s['institutionselector']);
$smarty->assign('INLINEJAVASCRIPT', $s['institutionselectorjs'] . '
jQuery(function($) {
formchangemanager.add(\'adminusers\');
formchangemanager.unbindForm(\'adminusers\');
});');
$smarty->assign('adminusersform', pieform($form));
$smarty->assign('adminusersform', $form);
$smarty->display('admin/users/institutionadmins.tpl');
......@@ -22,11 +22,9 @@ $s = institution_selector_for_page(param_alphanum('institution', false),
get_config('wwwroot') . 'admin/users/institutionstaff.php');
$institution = $s['institution'];
$smarty = smarty();
setpageicon($smarty, 'icon-university');
if ($institution === false) {
$smarty = smarty();
setpageicon($smarty, 'icon-university');
$smarty->display('admin/users/noinstitutions.tpl');
exit;
}
......@@ -67,6 +65,13 @@ $form = array(
)
);
function staffusers_validate(Pieform $form, $values) {
// If the institution has no members show error
if (!(get_column('usr_institution', 'usr', 'institution', $values['institution']))) {
$form->set_error(null, get_string('nousersselected', 'admin'));
}
}
function staffusers_submit(Pieform $form, $values) {
global $SESSION, $USER;
......@@ -89,12 +94,14 @@ function staffusers_submit(Pieform $form, $values) {
$SESSION->add_ok_msg(get_string('staffusersupdated', 'admin'));
redirect('/admin/users/institutionstaff.php?institution=' . $inst);
}
$form = pieform($form);
$smarty = smarty();
setpageicon($smarty, 'icon-university');
$smarty->assign('institutionselector', $s['institutionselector']);
$smarty->assign('INLINEJAVASCRIPT', $s['institutionselectorjs'] . '
jQuery(function($) {
formchangemanager.add(\'staffusers\');
formchangemanager.unbindForm(\'staffusers\');
});');
$smarty->assign('staffusersform', pieform($form));
$smarty->assign('staffusersform', $form);
$smarty->display('admin/users/institutionstaff.tpl');
......@@ -77,13 +77,13 @@ class PluginBlocktypePeerassessment extends MaharaCoreBlocktype {
$options->block = $instance->get('id');
$feedback = ArtefactTypePeerassessment::get_assessments($options, $versioning);
$feedbackform = ArtefactTypePeerassessment::add_assessment_form(true, $instance->get('id'), 0);
$feedbackform = pieform($feedbackform);
$smarty = smarty_core();
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('exporter', ($exporter ? true : false));
$smarty->assign('instructions', $instructions);
$smarty->assign('allowfeedback', $feedback->canedit && !$versioning);
$smarty->assign('addassessmentfeedbackform', pieform($feedbackform));
$smarty->assign('addassessmentfeedbackform', $feedbackform);
if ($feedback && !$editing) {
$smarty->assign('feedback', $feedback);
}
......
......@@ -72,9 +72,9 @@ if ($SESSION->get('forgotpasskey')) {
)
)
);
$form = pieform($form);
$smarty = smarty();
$smarty->assign('forgotpasschange_form', pieform($form));
$smarty->assign('forgotpasschange_form', $form);
$smarty->assign('heading', get_string('changepassword'));
$smarty->display('forgotpass.tpl');
exit;
......@@ -214,8 +214,8 @@ function forgotpasschange_submit(Pieform $form, $values) {
throw new SystemException('User "' . $user->username
. ' tried to change their password, but the attempt failed');
}
$form = pieform($form);
$smarty = smarty();
$smarty->assign('forgotpass_form', pieform($form));
$smarty->assign('forgotpass_form', $form);
$smarty->assign('heading', get_string('forgotusernamepassword'));
$smarty->display('forgotpass.tpl');
......@@ -49,8 +49,10 @@ define('PIEFORM_CANCEL', -2);
* // definition of elements in the form
* )
* );
* $form = pieform($form);
*
* $smarty->assign('myform', pieform($form));
* $smarty = smarty_core();
* $smarty->assign('myform', $form);
*
* function myform_validate(Pieform $form, $values) {
* // perform validation agains form elements here
......
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