-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmenu.php
101 lines (94 loc) · 3.27 KB
/
menu.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
/*
* webpa-lti - WebPA module to add LTI support
* Copyright (C) 2020 Stephen P Vickers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Contact: [email protected]
*/
###
### Update WebPA menu when accessing an LTI module
###
use ceLTIc\LTI\DataConnector\DataConnector;
use ceLTIc\LTI\Platform;
use ceLTIc\LTI\ResourceLink;
require_once(__DIR__ . '/vendor/autoload.php');
require_once(__DIR__ . '/includes.php');
require_once(__DIR__ . '/setting.php');
global $DB, $dataconnector, $lti_platform, $user_resource_link;
if (!property_exists($this, 'sourceId')) { // Prior to 3.1.0 release
$this->sourceId = $_source_id;
$this->user = $this->_user;
}
#
### Check if this is an LTI connection
#
if (method_exists($DB, 'open')) {
$DB->open();
}
$dataconnector = DataConnector::getDataConnector(lti_getConnection(), APP__DB_TABLE_PREFIX);
if ($this->sourceId) {
$lti_platform = Platform::fromConsumerKey($_SESSION['_user_source_id'], $dataconnector);
$user_resource_link = ResourceLink::fromPlatform($lti_platform, $_SESSION['_user_context_id']);
if ($this->user->is_staff()) {
#
### Update upload option if Memberships service is available
#
$menu = $this->get_menu('Admin');
if ($user_resource_link->hasMembershipsService()) {
$menu['sync data'] = APP__WWW . "/mod/{$mod}/admin/manage/";
}
unset($menu['upload data']);
#
### Add upload option if Outcomes service is available
#
if ($user_resource_link->hasOutcomesService()) {
$menu['transfer grades'] = APP__WWW . "/mod/{$mod}/admin/grade/";
}
#
### Add sharing option if enabled
#
if (ALLOW_SHARING && ($this->sourceId == $_SESSION['_user_source_id'])) {
$menu['sharing'] = APP__WWW . "/mod/{$mod}/admin/share/";
}
$this->set_menu('Admin', $menu);
}
}
#
### Add sources menu for administrators
#
if ($this->user->is_admin()) {
$this->set_menu('LTI Admin',
array('lti sources' => APP__WWW . "/mod/{$mod}/admin/source/",
'change source' => APP__WWW . "/mod/{$mod}/admin/source.php"));
} else {
#
### Add message to logout option
#
$menu = $this->get_menu(' ');
if (isset($_SESSION['logout_url'])) {
$text = 'return to VLE';
if (isset($_SESSION['branding_return_menu_text'])) {
$text = $_SESSION['branding_return_menu_text'];
}
$menu[$text] = APP__WWW . '/logout.php';
unset($menu['logout']);
} else {
$menu['logout'] = APP__WWW . '/logout.php?lti_msg=' . urlencode('You have been logged out of ' . APP__NAME);
}
$this->set_menu(' ', $menu);
}
?>