This commit is contained in:
David Monllao 2017-04-21 10:03:59 +08:00
commit 8e96553708
4 changed files with 47 additions and 2 deletions

View File

@ -58,6 +58,13 @@ class api {
global $CFG; global $CFG;
require_once($CFG->libdir . '/adminlib.php'); require_once($CFG->libdir . '/adminlib.php');
// Check if we can return this from cache.
$cache = \cache::make('tool_mobile', 'plugininfo');
$pluginsinfo = $cache->get('mobileplugins');
if ($pluginsinfo !== false) {
return (array)$pluginsinfo;
}
$pluginsinfo = []; $pluginsinfo = [];
$plugintypes = core_component::get_plugin_types(); $plugintypes = core_component::get_plugin_types();
@ -69,7 +76,7 @@ class api {
$component = $plugintype . '_' . $plugin; $component = $plugintype . '_' . $plugin;
$version = get_component_version($component); $version = get_component_version($component);
require_once("$path/db/mobile.php"); require("$path/db/mobile.php");
foreach ($addons as $addonname => $addoninfo) { foreach ($addons as $addonname => $addoninfo) {
$plugininfo = array( $plugininfo = array(
'component' => $component, 'component' => $component,
@ -92,6 +99,9 @@ class api {
} }
} }
} }
$cache->set('mobileplugins', $pluginsinfo);
return $pluginsinfo; return $pluginsinfo;
} }

View File

@ -0,0 +1,34 @@
<?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/>.
/**
* Mobile cache definitions.
*
* @package tool_mobile
* @copyright 2017 Skylar Kelty <S.Kelty@kent.ac.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$definitions = array(
'plugininfo' => array(
'mode' => cache_store::MODE_APPLICATION,
'simplekeys' => true,
'staticacceleration' => true,
'staticaccelerationsize' => 1
)
);

View File

@ -26,6 +26,7 @@ $string['androidappid'] = 'Android app\'s unique identifier';
$string['androidappid_desc'] = 'This setting may be left as default unless you have a custom Android app.'; $string['androidappid_desc'] = 'This setting may be left as default unless you have a custom Android app.';
$string['autologinkeygenerationlockout'] = 'Auto-login key generation is blocked because of too many requests within an hour.'; $string['autologinkeygenerationlockout'] = 'Auto-login key generation is blocked because of too many requests within an hour.';
$string['autologinnotallowedtoadmins'] = 'Auto-login is not allowed for site admins.'; $string['autologinnotallowedtoadmins'] = 'Auto-login is not allowed for site admins.';
$string['cachedef_plugininfo'] = 'This stores the list of plugins with mobile addons';
$string['clickheretolaunchtheapp'] = 'Click here if the app does not open automatically.'; $string['clickheretolaunchtheapp'] = 'Click here if the app does not open automatically.';
$string['configmobilecssurl'] = 'A CSS file to customise your mobile app interface.'; $string['configmobilecssurl'] = 'A CSS file to customise your mobile app interface.';
$string['customlangstrings'] = 'Custom language strings'; $string['customlangstrings'] = 'Custom language strings';

View File

@ -23,7 +23,7 @@
*/ */
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 2016120505; // The current plugin version (Date: YYYYMMDDXX). $plugin->version = 2017041200; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2016112900; // Requires this Moodle version. $plugin->requires = 2016112900; // Requires this Moodle version.
$plugin->component = 'tool_mobile'; // Full name of the plugin (used for diagnostics). $plugin->component = 'tool_mobile'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = array( $plugin->dependencies = array(