-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathsettings.php
More file actions
85 lines (70 loc) · 3.69 KB
/
Copy pathsettings.php
File metadata and controls
85 lines (70 loc) · 3.69 KB
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
<?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/>.
/**
* Generico settings
*
* @package filter_generico
* @subpackage generico
* @copyright 2014 Justin Hunt <poodllsupport@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
use filter_generico\constants;
$settings = null;
if (has_capability('filter/generico:managetemplates', context_system::instance())) {
global $PAGE;
// Add folder in property tree for settings pages.
$genericocategoryname = 'generico_category';
$genericocategory = new admin_category($genericocategoryname, 'Generico');
$ADMIN->add('filtersettings', $genericocategory);
$conf = get_config('filter_generico');
// Add the common settings page
// we changed this to use the default settings id for the top page. This way in the settings link on the manage filters
// page, we will arrive here. Else the link will show there, but it will error out if clicked.
$settingspage = new admin_settingpage('filtersettinggenerico', get_string('commonpageheading', 'filter_generico'));
$settingspage->add(new admin_setting_configtext('filter_generico/templatecount',
get_string('templatecount', 'filter_generico'),
get_string('templatecount_desc', 'filter_generico'),
\filter_generico\generico_utils::FILTER_GENERICO_TEMPLATE_COUNT, PARAM_INT, 20));
// Cloud poodll credentials.
$settingspage->add(new admin_setting_heading('filter_generico_cpapi_settings', get_string('cpapi_heading', 'filter_generico'),
get_string('cpapi_heading_desc', 'filter_generico')));
$settingspage->add(new admin_setting_configtext('filter_generico/cpapiuser', get_string('cpapiuser', 'filter_generico'),
get_string('cpapiuser_details', 'filter_generico'), ''));
// We show a summary of the users apps if we can get the info.
$apiuser = get_config(constants::MOD_FRANKY, 'cpapiuser');
$apisecret = get_config(constants::MOD_FRANKY, 'cpapisecret');
if ($apiuser && $apisecret) {
$gu = new \filter_generico\generico_utils();
$tokeninfo = $gu->fetch_token_for_display($apiuser, $apisecret);
} else {
$tokeninfo = get_string('cpapisecret_details', constants::MOD_FRANKY);
}
$settingspage->add(new admin_setting_configtext('filter_generico/cpapisecret', get_string('cpapisecret', 'filter_generico'),
$tokeninfo, ''));
// Add page to category.
$ADMIN->add($genericocategoryname, $settingspage);
$genericotemplatesadminsettings = new admin_externalpage('genericotemplatesadmin', get_string('templates', 'filter_generico'),
$CFG->wwwroot . '/filter/generico/genericotemplatesadmin.php', 'filter/generico:managetemplates');
$ADMIN->add($genericocategoryname, $genericotemplatesadminsettings);
// Templates.
if ($ADMIN->fulltree) {
$templatepages = \filter_generico\settingstools::fetch_template_pages($conf);
foreach ($templatepages as $templatepage) {
$ADMIN->add($genericocategoryname, $templatepage);
}
}
}