Commit 67c0f96a authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Institution files page

parent d453da42
......@@ -32,12 +32,13 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('adminusers', 'admin'));
require_once('pieforms/pieform.php');
define('MENUITEM', 'manageinstitutions/institutionadmins');
$smarty = smarty();
require_once('institution.php');
$institution = add_institution_selector_to_page($smarty, param_alphanum('institution', false),
get_config('wwwroot') . 'admin/users/institutionadmins.php');
$s = institution_selector_for_page(param_alphanum('institution', false),
get_config('wwwroot') . 'admin/users/institutionadmins.php');
$institution = $s['institution'];
$smarty = smarty();
if ($institution === false) {
$smarty->display('admin/users/noinstitutions.tpl');
exit;
......@@ -100,6 +101,8 @@ function adminusers_submit(Pieform $form, $values) {
redirect('/admin/users/institutionadmins.php?institution=' . $inst);
}
$smarty->assign('institutionselector', $s['institutionselector']);
$smarty->assign('INLINEJAVASCRIPT', $s['institutionselectorjs']);
$smarty->assign('adminusersform', pieform($form));
$smarty->display('admin/users/institutionadmins.tpl');
......
......@@ -32,12 +32,13 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('staffusers', 'admin'));
require_once('pieforms/pieform.php');
define('MENUITEM', 'manageinstitutions/institutionstaff');
$smarty = smarty();
require_once('institution.php');
$institution = add_institution_selector_to_page($smarty, param_alphanum('institution', false),
get_config('wwwroot') . 'admin/users/institutionstaff.php');
$s = institution_selector_for_page(param_alphanum('institution', false),
get_config('wwwroot') . 'admin/users/institutionstaff.php');
$institution = $s['institution'];
$smarty = smarty();
if ($institution === false) {
$smarty->display('admin/users/noinstitutions.tpl');
exit;
......@@ -99,6 +100,8 @@ function staffusers_submit(Pieform $form, $values) {
redirect('/admin/users/institutionstaff.php?institution=' . $inst);
}
$smarty->assign('institutionselector', $s['institutionselector']);
$smarty->assign('INLINEJAVASCRIPT', $s['institutionselectorjs']);
$smarty->assign('staffusersform', pieform($form));
$smarty->display('admin/users/institutionstaff.tpl');
......
......@@ -467,14 +467,13 @@ function get_institution_selector($includedefault = true) {
/* The institution selector does exactly the same thing in both
institutionadmins.php and institutionstaff.php (in /admin/users/).
This function creates the form for the page, setting
$institutionselector and $INLINEJAVASCRIPT in the smarty object. */
function add_institution_selector_to_page(&$smarty, $institution, $page) {
This function creates the form for the page. */
function institution_selector_for_page($institution, $page) {
require_once('pieforms/pieform.php');
$institutionelement = get_institution_selector(false);
if (empty($institutionelement)) {
return false;
return array('institution' => false, 'institutionselector' => null, 'institutionselectorjs' => '');
}
global $USER;
......@@ -507,9 +506,10 @@ addLoadEvent(function() {
});
EOF;
$smarty->assign('institutionselector', $institutionselector);
$smarty->assign('INLINEJAVASCRIPT', $js);
return $institution;
return array(
'institution' => $institution,
'institutionselector' => $institutionselector,
'institutionselectorjs' => $js
);
}
?>
......@@ -45,10 +45,12 @@ if ($institution == 'mahara') {
redirect('/admin/site/views.php');
}
$smarty = smarty();
$institution = add_institution_selector_to_page($smarty, $institution,
get_config('wwwroot') . 'view/institutionviews.php');
$s = institution_selector_for_page($institution,
get_config('wwwroot') . 'view/institutionviews.php');
$institution = $s['institution'];
$smarty = smarty();
if ($institution === false) {
$smarty->display('admin/users/noinstitutions.tpl');
exit;
......@@ -70,6 +72,8 @@ $pagination = build_pagination(array(
'resultcounttextplural' => get_string('views', 'view')
));
$smarty->assign('institutionselector', $s['institutionselector']);
$smarty->assign('INLINEJAVASCRIPT', $s['institutionselectorjs']);
$smarty->assign('views', $data->data);
$smarty->assign('institution', $institution);
$smarty->assign('pagination', $pagination['html']);
......
Supports Markdown
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