forked from WebPA/WebPA
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodule.php
101 lines (83 loc) · 2.55 KB
/
module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
*
* Change module page
*
*
* @copyright 2007 Loughborough University
* @license http://www.gnu.org/licenses/gpl.txt
* @version 1.0.0.0
*
*/
require_once("includes/inc_global.php");
if (($_source_id != '') && !$_user->is_admin()) {
header('Location:'. APP__WWW .'/logout.php?msg=denied');
exit;
}
$module_id = fetch_POST('module_id');
if ($module_id) {
// Update last module
$sql_last_module = 'UPDATE ' . APP__DB_TABLE_PREFIX . "user SET last_module_id = '{$module_id}' WHERE user_id = '{$_user_id}'";
$DB->execute($sql_last_module);
// Update session
$sql_module = 'SELECT module_code FROM ' . APP__DB_TABLE_PREFIX . "module WHERE module_id = {$module_id}";
$module = $DB->fetch_row($sql_module);
$_SESSION['_module_id'] = $module_id;
$_SESSION['_user_context_id'] = $module['module_code'];
logEvent('Leave module', $_module_id);
logEvent('Enter module', $module_id);
header('Location: ' . APP__WWW . "/");
exit;
}
//set the page information
$UI->page_title = gettext('Change Module');
$UI->menu_selected = gettext('change module');
$UI->breadcrumbs = array ('home' => './', gettext('change source') => null);
$UI->help_link = '?q=node/237';
$UI->head();
$UI->body();
$UI->content_start();
//build the content to be written to the screen
$page_intro = gettext('Use this page to change the currently selected module.');
?>
<p><?php echo $page_intro; ?></p>
<form action="" method="post" name="select_module">
<div class="content_box">
<table class="option_list" style="width: 100%;">
<?php
//get the modules associated with the user being edited
if ($_user->is_admin()) {
$modules = $CIS->get_user_modules(NULL, NULL, 'name');
} else {
$modules = $CIS->get_user_modules($_user->id, NULL, 'name');
}
echo "<table>";
if (count($modules) > 0) {
foreach ($modules as $id => $module) {
$checked_str = (isset($_module_id) && ($id == $_module_id)) ? ' checked="checked"' : '' ;
echo('<tr>');
echo(" <td><input type=\"radio\" name=\"module_id\" id=\"module_{$id}\" value=\"{$id}\"{$checked_str} /></td>");
echo(" <td><label style=\"font-weight: normal;\" for=\"module_{$id}\">{$module['module_title']} [{$module['module_code']}]</label></td>");
echo('</tr>');
}
} else {
echo('<tr>');
echo(' <td colspan="2">'.gettext('No modules').'</td>');
echo('</tr>');
}
?>
</table>
</div>
<?php
if (count($modules) > 0) {
?>
<p>
<input type="submit" value="<?php echo gettext('Select module');?>" />
</p>
<?php
}
?>
</form>
<?php
$UI->content_end();
?>