From f765fb380aef3cfcd448675505d89c35e16cae4d Mon Sep 17 00:00:00 2001 From: Amaia Anabitarte Date: Wed, 22 Aug 2018 15:01:49 +0100 Subject: [PATCH] MDL-63153 admin: Adding Moodle services page to Site Administration --- admin/settings/moodleservices.php | 53 ++++++++++++++ admin/settings/top.php | 5 ++ admin/templates/setting_description.mustache | 45 ++++++++++++ admin/tool/mobile/settings.php | 8 +++ lang/en/admin.php | 14 ++++ lib/adminlib.php | 69 +++++++++++++++++++ .../core_admin/setting_description.mustache | 46 +++++++++++++ 7 files changed, 240 insertions(+) create mode 100644 admin/settings/moodleservices.php create mode 100644 admin/templates/setting_description.mustache create mode 100644 theme/boost/templates/core_admin/setting_description.mustache diff --git a/admin/settings/moodleservices.php b/admin/settings/moodleservices.php new file mode 100644 index 00000000000..2f34cfdb0e0 --- /dev/null +++ b/admin/settings/moodleservices.php @@ -0,0 +1,53 @@ +. + +/** + * This file gives information about Moodle Services + * + * @package core + * @copyright 2018 Amaia Anabitarte + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +if ($hassiteconfig) { + + // Create Moodle Services information. + $moodleservices->add(new admin_setting_heading('moodleservicesintro', '', + new lang_string('moodleservices_help', 'admin'))); + + // Moodle Partners information. + if (empty($CFG->disableserviceads_partner)) { + $moodleservices->add(new admin_setting_heading('moodlepartners', + new lang_string('moodlepartners', 'admin'), + new lang_string('moodlepartners_help', 'admin'))); + } + + // Moodle app information. + $moodleservices->add(new admin_setting_heading('moodleapp', + new lang_string('moodleapp', 'admin'), + new lang_string('moodleapp_help', 'admin'))); + + // Branded Moodle app information. + if (empty($CFG->disableserviceads_branded)) { + $moodleservices->add(new admin_setting_heading('moodlebrandedapp', + new lang_string('moodlebrandedapp', 'admin'), + new lang_string('moodlebrandedapp_help', 'admin'))); + } +} + + diff --git a/admin/settings/top.php b/admin/settings/top.php index 17621cbd671..102b75817d1 100644 --- a/admin/settings/top.php +++ b/admin/settings/top.php @@ -15,6 +15,11 @@ $ADMIN->add('root', new admin_externalpage('registrationmoodleorg', new lang_str // hidden upgrade script $ADMIN->add('root', new admin_externalpage('upgradesettings', new lang_string('upgradesettings', 'admin'), "$CFG->wwwroot/$CFG->admin/upgradesettings.php", 'moodle/site:config', true)); +// Adding Moodle Services information page. +$moodleservices = new admin_settingpage('moodleservices', new lang_string('moodleservices', + 'admin')); +$ADMIN->add('root', $moodleservices); + if ($hassiteconfig) { $optionalsubsystems = new admin_settingpage('optionalsubsystems', new lang_string('advancedfeatures', 'admin')); $ADMIN->add('root', $optionalsubsystems); diff --git a/admin/templates/setting_description.mustache b/admin/templates/setting_description.mustache new file mode 100644 index 00000000000..c6d0e57b1b2 --- /dev/null +++ b/admin/templates/setting_description.mustache @@ -0,0 +1,45 @@ +{{! + 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 . +}} +{{! + @template core_admin/setting_description + + Admin setting description template. + + Context variables required for this template: + * labelfor - id of the form element + * title - Setting title + * name - Setting name + + Example context (json): + { + "title": "Setting title", + "name": "Name", + "description": "Description goes here" + } +}} +{{! + Setting description. +}} +
+
+ + {{{name}}} +
+
{{{description}}}
+
\ No newline at end of file diff --git a/admin/tool/mobile/settings.php b/admin/tool/mobile/settings.php index 125a72a6929..5a313ed3b1a 100644 --- a/admin/tool/mobile/settings.php +++ b/admin/tool/mobile/settings.php @@ -73,6 +73,14 @@ if ($hassiteconfig) { $temp->add(new admin_setting_configtext('mobilecssurl', new lang_string('mobilecssurl', 'tool_mobile'), new lang_string('configmobilecssurl', 'tool_mobile'), '', PARAM_URL)); + // Reference to Branded Mobile App. + if (empty($CFG->disableserviceads_branded)) { + $temp->add(new admin_setting_description('moodlebrandedappreference', + new lang_string('moodlebrandedapp', 'admin'), + new lang_string('moodlebrandedappreference', 'admin') + )); + } + $temp->add(new admin_setting_heading('tool_mobile/smartappbanners', new lang_string('smartappbanners', 'tool_mobile'), '')); diff --git a/lang/en/admin.php b/lang/en/admin.php index dd31c0cc18a..9d7fc68d5dc 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -807,6 +807,20 @@ $string['nonexistentbookmark'] = 'The bookmark you requested does not exist.'; $string['nosupportedlogstore'] = 'No supported logstore found'; $string['maxtimelimit'] = 'Maximum time limit'; $string['maxtimelimit_desc'] = 'To restrict the maximum PHP execution time that Moodle will allow without any output being displayed, enter a value in seconds here. 0 means that Moodle default restrictions are used. If you have a front-end server with its own time limit, set this value lower to receive PHP errors in logs. Does not apply to CLI scripts.'; +$string['moodleapp'] = 'Moodle app'; +$string['moodleapp_help'] = '

If you have an account on a Moodle site, you can access all your courses on your mobile devices with our free mobile app for Moodle.

+Get the Moodle app'; +$string['moodlebrandedapp'] = 'Branded Moodle app'; +$string['moodlebrandedapp_help'] = '

The Branded Moodle app has all the functionality of our free mobile app for Moodle combined with your own custom branding.

+About the Branded Moodle app'; +$string['moodlebrandedappreference'] = '

Contact Moodle HQ for our Branded Moodle app service and customise the app with your own branding.

+About the Branded Moodle app'; +$string['moodlepartners'] = 'Moodle Partners'; +$string['moodlepartners_help'] = '

Moodle Partners are services providers that are certified by Moodle HQ to provide high quality Moodle services for your organisation\'s online learning environment.

+About our Partners
+Find a Partner'; +$string['moodleservices'] = 'Moodle services'; +$string['moodleservices_help'] = 'Make sure you get the best from your Moodle learning environment by using these Moodle services:'; $string['noreplyaddress'] = 'No-reply address'; $string['noreplydomain'] = 'No-reply and domain'; $string['noreplydomaindetail'] = 'Settings for No-reply and configured domains'; diff --git a/lib/adminlib.php b/lib/adminlib.php index d6cd9ace66e..c17efa4d558 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -2107,6 +2107,74 @@ class admin_setting_heading extends admin_setting { } } +/** + * No setting - just name and description in same row. + * + * @copyright 2018 onwards Amaia Anabitarte + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class admin_setting_description extends admin_setting { + + /** + * Not a setting, just text + * + * @param string $name + * @param string $visiblename + * @param string $description + */ + public function __construct($name, $visiblename, $description) { + $this->nosave = true; + parent::__construct($name, $visiblename, $description, ''); + } + + /** + * Always returns true + * + * @return bool Always returns true + */ + public function get_setting() { + return true; + } + + /** + * Always returns true + * + * @return bool Always returns true + */ + public function get_defaultsetting() { + return true; + } + + /** + * Never write settings + * + * @param mixed $data Gets converted to str for comparison against yes value + * @return string Always returns an empty string + */ + public function write_setting($data) { + // Do not write any setting. + return ''; + } + + /** + * Returns an HTML string + * + * @param string $data + * @param string $query + * @return string Returns an HTML string + */ + public function output_html($data, $query='') { + global $OUTPUT; + + $context = new stdClass(); + $context->title = $this->visiblename; + $context->description = $this->description; + + return $OUTPUT->render_from_template('core_admin/setting_description', $context); + } +} + + /** * The most flexible setting, the user enters text. @@ -8199,6 +8267,7 @@ function admin_search_settings_html($query) { $data = $adminroot->errors[$fullname]->data; } else { $data = $setting->get_setting(); + $data = $setting->get_setting(); // do not use defaults if settings not available - upgradesettings handles the defaults! } $sectionsettings[] = $setting->output_html($data, $query); diff --git a/theme/boost/templates/core_admin/setting_description.mustache b/theme/boost/templates/core_admin/setting_description.mustache new file mode 100644 index 00000000000..09bda33e17b --- /dev/null +++ b/theme/boost/templates/core_admin/setting_description.mustache @@ -0,0 +1,46 @@ +{{! + 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 . +}} +{{! + @template core_admin/setting_description + + Admin setting description template. + + Context variables required for this template: + * labelfor - id of the form element + * title - Setting title + * name - Setting name + + Example context (json): + { + "title": "Setting title", + "name": "Name", + "description": "Description goes here" + } +}} +{{! + Setting description. +}} +
+
+ +
+
+
{{{description}}}
+
+