mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-49279-master' of git://github.com/jleyva/moodle
Conflicts: lib/classes/plugin_manager.php
This commit is contained in:
commit
9a1414c4d8
85
admin/tool/mobile/classes/api.php
Normal file
85
admin/tool/mobile/classes/api.php
Normal file
@ -0,0 +1,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/>.
|
||||
|
||||
/**
|
||||
* Class for Moodle Mobile tools.
|
||||
*
|
||||
* @package tool_mobile
|
||||
* @copyright 2016 Juan Leyva
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
namespace tool_mobile;
|
||||
|
||||
use core_component;
|
||||
use core_plugin_manager;
|
||||
|
||||
/**
|
||||
* API exposed by tool_mobile
|
||||
*
|
||||
* @copyright 2016 Juan Leyva
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
class api {
|
||||
|
||||
/**
|
||||
* Returns a list of Moodle plugins supporting the mobile app.
|
||||
*
|
||||
* @return array an array of objects containing the plugin information
|
||||
*/
|
||||
public static function get_plugins_supporting_mobile() {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$pluginsinfo = [];
|
||||
$plugintypes = core_component::get_plugin_types();
|
||||
|
||||
foreach ($plugintypes as $plugintype => $unused) {
|
||||
// We need to include files here.
|
||||
$pluginswithfile = core_component::get_plugin_list_with_file($plugintype, 'db' . DIRECTORY_SEPARATOR . 'mobile.php');
|
||||
foreach ($pluginswithfile as $plugin => $notused) {
|
||||
$path = core_component::get_plugin_directory($plugintype, $plugin);
|
||||
$component = $plugintype . '_' . $plugin;
|
||||
$version = get_component_version($component);
|
||||
|
||||
require_once("$path/db/mobile.php");
|
||||
foreach ($addons as $addonname => $addoninfo) {
|
||||
$plugininfo = array(
|
||||
'component' => $component,
|
||||
'version' => $version,
|
||||
'addon' => $addonname,
|
||||
'dependencies' => !empty($addon['dependencies']) ? $addoninfo['dependencies'] : array(),
|
||||
'fileurl' => '',
|
||||
'filehash' => '',
|
||||
'filesize' => 0
|
||||
);
|
||||
|
||||
// All the mobile packages must be under the plugin mobile directory.
|
||||
$package = $path . DIRECTORY_SEPARATOR . 'mobile' . DIRECTORY_SEPARATOR . $addonname . '.zip';
|
||||
if (file_exists($package)) {
|
||||
$plugininfo['fileurl'] = $CFG->wwwroot . '' . str_replace($CFG->dirroot, '', $package);
|
||||
$plugininfo['filehash'] = sha1_file($package);
|
||||
$plugininfo['filesize'] = filesize($package);
|
||||
}
|
||||
$pluginsinfo[] = $plugininfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $pluginsinfo;
|
||||
}
|
||||
|
||||
}
|
98
admin/tool/mobile/classes/external.php
Normal file
98
admin/tool/mobile/classes/external.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* This is the external API for this tool.
|
||||
*
|
||||
* @package tool_mobile
|
||||
* @copyright 2016 Juan Leyva
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_mobile;
|
||||
|
||||
require_once("$CFG->libdir/externallib.php");
|
||||
|
||||
use external_api;
|
||||
use external_function_parameters;
|
||||
use external_value;
|
||||
use external_single_structure;
|
||||
use external_multiple_structure;
|
||||
use external_warnings;
|
||||
|
||||
/**
|
||||
* This is the external API for this tool.
|
||||
*
|
||||
* @copyright 2016 Juan Leyva
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class external extends external_api {
|
||||
|
||||
/**
|
||||
* Returns description of get_plugins_supporting_mobile() parameters.
|
||||
*
|
||||
* @return external_function_parameters
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
public static function get_plugins_supporting_mobile_parameters() {
|
||||
return new external_function_parameters(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of Moodle plugins supporting the mobile app.
|
||||
*
|
||||
* @return array an array of warnings and objects containing the plugin information
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
public static function get_plugins_supporting_mobile() {
|
||||
return array(
|
||||
'plugins' => api::get_plugins_supporting_mobile(),
|
||||
'warnings' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of get_plugins_supporting_mobile() result value.
|
||||
*
|
||||
* @return external_description
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
public static function get_plugins_supporting_mobile_returns() {
|
||||
return new external_single_structure(
|
||||
array(
|
||||
'plugins' => new external_multiple_structure(
|
||||
new external_single_structure(
|
||||
array(
|
||||
'component' => new external_value(PARAM_COMPONENT, 'The plugin component name.'),
|
||||
'version' => new external_value(PARAM_NOTAGS, 'The plugin version number.'),
|
||||
'addon' => new external_value(PARAM_COMPONENT, 'The Mobile addon (package) name.'),
|
||||
'dependencies' => new external_multiple_structure(
|
||||
new external_value(PARAM_COMPONENT, 'Mobile addon name.'),
|
||||
'The list of Mobile addons this addon depends on.'
|
||||
),
|
||||
'fileurl' => new external_value(PARAM_URL, 'The addon package url for download
|
||||
or empty if it doesn\'t exist.'),
|
||||
'filehash' => new external_value(PARAM_RAW, 'The addon package hash or empty if it doesn\'t exist.'),
|
||||
'filesize' => new external_value(PARAM_INT, 'The addon package size or empty if it doesn\'t exist.')
|
||||
)
|
||||
)
|
||||
),
|
||||
'warnings' => new external_warnings(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
37
admin/tool/mobile/db/services.php
Normal file
37
admin/tool/mobile/db/services.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Moodle Mobile tools webservice definitions.
|
||||
*
|
||||
*
|
||||
* @package tool_mobile
|
||||
* @copyright 2016 Juan Leyva
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$functions = array(
|
||||
|
||||
'tool_mobile_get_plugins_supporting_mobile' => array(
|
||||
'classname' => 'tool_mobile\external',
|
||||
'methodname' => 'get_plugins_supporting_mobile',
|
||||
'description' => 'Returns a list of Moodle plugins supporting the mobile app.',
|
||||
'type' => 'read',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
)
|
||||
|
||||
);
|
||||
|
25
admin/tool/mobile/lang/en/tool_mobile.php
Normal file
25
admin/tool/mobile/lang/en/tool_mobile.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'tool_mobile', language 'en'
|
||||
*
|
||||
* @package tool_mobile
|
||||
* @copyright 2016 Juan Leyva
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['pluginname'] = 'Moodle Mobile tools';
|
56
admin/tool/mobile/tests/externallib_test.php
Normal file
56
admin/tool/mobile/tests/externallib_test.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Moodle Mobile admin tool external functions tests.
|
||||
*
|
||||
* @package tool_mobile
|
||||
* @category external
|
||||
* @copyright 2016 Juan Leyva
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
|
||||
require_once($CFG->dirroot . '/webservice/tests/helpers.php');
|
||||
|
||||
use tool_mobile\external;
|
||||
|
||||
/**
|
||||
* External learning plans webservice API tests.
|
||||
*
|
||||
* @package tool_mobile
|
||||
* @copyright 2016 Juan Leyva
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.1
|
||||
*/
|
||||
class tool_mobile_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test get_plugins_supporting_mobile.
|
||||
* This is a very basic test because currently there aren't plugins supporting Mobile in core.
|
||||
*/
|
||||
public function test_get_plugins_supporting_mobile() {
|
||||
$result = external::get_plugins_supporting_mobile();
|
||||
$result = external_api::clean_returnvalue(external::get_plugins_supporting_mobile_returns(), $result);
|
||||
$this->assertCount(0, $result['warnings']);
|
||||
$this->assertCount(0, $result['plugins']);
|
||||
}
|
||||
|
||||
}
|
28
admin/tool/mobile/version.php
Normal file
28
admin/tool/mobile/version.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Plugin version info
|
||||
*
|
||||
* @package tool_mobile
|
||||
* @copyright 2016 Juan Leyva
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
$plugin->version = 2016032401; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2016032400.00; // Requires this Moodle version.
|
||||
$plugin->component = 'tool_mobile'; // Full name of the plugin (used for diagnostics).
|
@ -1900,7 +1900,7 @@ class core_plugin_manager {
|
||||
'tool' => array(
|
||||
'assignmentupgrade', 'availabilityconditions', 'behat', 'capability', 'cohortroles', 'customlang',
|
||||
'dbtransfer', 'filetypes', 'generator', 'health', 'innodb', 'installaddon',
|
||||
'langimport', 'log', 'lp', 'lpmigrate', 'messageinbound', 'multilangupgrade', 'monitor',
|
||||
'langimport', 'log', 'lp', 'lpmigrate', 'messageinbound', 'mobile', 'multilangupgrade', 'monitor',
|
||||
'phpunit', 'profiling', 'recyclebin', 'replace', 'spamcleaner', 'task', 'templatelibrary',
|
||||
'unittest', 'uploadcourse', 'uploaduser', 'unsuproles', 'xmldb'
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user