-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathlib.php
83 lines (68 loc) · 2.88 KB
/
lib.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
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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 3 of the License, or
// (at your option) any later version.
//
// Moodle 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 Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Atto text editor integration version file.
*
* @package atto_panoptobutton
* @copyright Panopto 2009 - 2016
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Initialize this plugin
*/
function atto_panoptobutton_strings_for_js() {
global $PAGE;
$PAGE->requires->strings_for_js(array('insert',
'cancel',
'dialogtitle'),
'atto_panoptobutton');
}
/**
* Return the js params required for this module.
*
* @param int $elementid
* @param array $options
* @param array $fpoptions
* @return array of additional params to pass to javascript init function for this module.
*/
function atto_panoptobutton_params_for_js($elementid, $options, $fpoptions) {
global $USER, $COURSE, $DB;
$coursecontext = context_course::instance($COURSE->id);
// Gets Panopto folder ID and for course from database on the server to which the course was provisioned.
// If the course has not been provisioned, this will not return a value and the user will be able to select
// folders and videos from the server specified as default during the plugin setup.
$panoptoid = $DB->get_field('block_panopto_foldermap', 'panopto_id', array('moodleid' => $coursecontext->instanceid));
$servername = $DB->get_field('block_panopto_foldermap', 'panopto_server', array('moodleid' => $coursecontext->instanceid));
$instancename = get_config('block_panopto', 'instance_name');
$usercontextid = context_user::instance($USER->id)->id;
$disabled = false;
// Config array.
$params = array();
$params['usercontextid'] = $usercontextid;
$params['coursecontext'] = $panoptoid;
$params['servename'] = $servername;
$params['instancename'] = $instancename;
// If they don't have permission don't show it.
if (!has_capability('atto/panoptobutton:visible', $coursecontext) ) {
$disabled = true;
}
// Add disabled param.
$params['disabled'] = $disabled;
// Add our default server.
$params['defaultserver'] = get_config('atto_panoptobutton', 'defaultserver');
return $params;
}