MDL-56463 tool_mobile: Apply text formatting to tool_mobile WS
This commit is contained in:
@@ -31,7 +31,7 @@ use moodle_url;
|
||||
use moodle_exception;
|
||||
|
||||
/**
|
||||
* API exposed by tool_mobile
|
||||
* API exposed by tool_mobile, to be used mostly by external functions.
|
||||
*
|
||||
* @copyright 2016 Juan Leyva
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
@@ -106,6 +106,8 @@ class api {
|
||||
// We need this to make work the format text functions.
|
||||
$PAGE->set_context($context);
|
||||
|
||||
list($authinstructions, $notusedformat) = external_format_text($CFG->auth_instructions, FORMAT_MOODLE, $context->id);
|
||||
list($maintenancemessage, $notusedformat) = external_format_text($CFG->maintenance_message, FORMAT_MOODLE, $context->id);
|
||||
$settings = array(
|
||||
'wwwroot' => $CFG->wwwroot,
|
||||
'httpswwwroot' => $CFG->httpswwwroot,
|
||||
@@ -115,12 +117,12 @@ class api {
|
||||
'authloginviaemail' => $CFG->authloginviaemail,
|
||||
'registerauth' => $CFG->registerauth,
|
||||
'forgottenpasswordurl' => $CFG->forgottenpasswordurl,
|
||||
'authinstructions' => format_text($CFG->auth_instructions),
|
||||
'authinstructions' => $authinstructions,
|
||||
'authnoneenabled' => (int) is_enabled_auth('none'),
|
||||
'enablewebservices' => $CFG->enablewebservices,
|
||||
'enablemobilewebservice' => $CFG->enablemobilewebservice,
|
||||
'maintenanceenabled' => $CFG->maintenance_enabled,
|
||||
'maintenancemessage' => format_text($CFG->maintenance_message),
|
||||
'maintenancemessage' => $maintenancemessage,
|
||||
);
|
||||
|
||||
$typeoflogin = get_config('tool_mobile', 'typeoflogin');
|
||||
@@ -162,9 +164,10 @@ class api {
|
||||
if (empty($section) or $section == 'frontpagesettings') {
|
||||
require_once($CFG->dirroot . '/course/format/lib.php');
|
||||
// First settings that anyone can deduce.
|
||||
$settings->fullname = $SITE->fullname;
|
||||
$settings->shortname = $SITE->shortname;
|
||||
$settings->summary = $SITE->summary;
|
||||
$settings->fullname = external_format_string($SITE->fullname, $context->id);
|
||||
$settings->shortname = external_format_string($SITE->shortname, $context->id);
|
||||
list($settings->summary, $settings->summaryformat) = external_format_text($SITE->summary, $SITE->summaryformat,
|
||||
$context->id);
|
||||
$settings->frontpage = $CFG->frontpage;
|
||||
$settings->frontpageloggedin = $CFG->frontpageloggedin;
|
||||
$settings->maxcategorydepth = $CFG->maxcategorydepth;
|
||||
|
||||
@@ -64,6 +64,9 @@ class tool_mobile_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
// Test default values.
|
||||
$context = context_system::instance();
|
||||
list($authinstructions, $notusedformat) = external_format_text($CFG->auth_instructions, FORMAT_MOODLE, $context->id);
|
||||
list($maintenancemessage, $notusedformat) = external_format_text($CFG->maintenance_message, FORMAT_MOODLE, $context->id);
|
||||
|
||||
$expected = array(
|
||||
'wwwroot' => $CFG->wwwroot,
|
||||
'httpswwwroot' => $CFG->httpswwwroot,
|
||||
@@ -73,12 +76,12 @@ class tool_mobile_external_testcase extends externallib_advanced_testcase {
|
||||
'authloginviaemail' => $CFG->authloginviaemail,
|
||||
'registerauth' => $CFG->registerauth,
|
||||
'forgottenpasswordurl' => $CFG->forgottenpasswordurl,
|
||||
'authinstructions' => format_text($CFG->auth_instructions),
|
||||
'authinstructions' => $authinstructions,
|
||||
'authnoneenabled' => (int) is_enabled_auth('none'),
|
||||
'enablewebservices' => $CFG->enablewebservices,
|
||||
'enablemobilewebservice' => $CFG->enablemobilewebservice,
|
||||
'maintenanceenabled' => $CFG->maintenance_enabled,
|
||||
'maintenancemessage' => format_text($CFG->maintenance_message),
|
||||
'maintenancemessage' => $maintenancemessage,
|
||||
'typeoflogin' => api::LOGIN_VIA_APP,
|
||||
'warnings' => array()
|
||||
);
|
||||
@@ -92,8 +95,9 @@ class tool_mobile_external_testcase extends externallib_advanced_testcase {
|
||||
set_config('logo', 'mock.png', 'core_admin');
|
||||
set_config('logocompact', 'mock.png', 'core_admin');
|
||||
|
||||
list($authinstructions, $notusedformat) = external_format_text($authinstructions, FORMAT_MOODLE, $context->id);
|
||||
$expected['registerauth'] = 'email';
|
||||
$expected['authinstructions'] = format_text($authinstructions);
|
||||
$expected['authinstructions'] = $authinstructions;
|
||||
$expected['typeoflogin'] = api::LOGIN_VIA_BROWSER;
|
||||
$expected['launchurl'] = "$CFG->wwwroot/$CFG->admin/tool/mobile/launch.php";
|
||||
|
||||
@@ -125,6 +129,7 @@ class tool_mobile_external_testcase extends externallib_advanced_testcase {
|
||||
$expected = array(
|
||||
array('name' => 'fullname', 'value' => $SITE->fullname),
|
||||
array('name' => 'shortname', 'value' => $SITE->shortname),
|
||||
array('name' => 'summaryformat', 'value' => FORMAT_HTML),
|
||||
array('name' => 'summary', 'value' => $SITE->summary),
|
||||
array('name' => 'frontpage', 'value' => $CFG->frontpage),
|
||||
array('name' => 'frontpageloggedin', 'value' => $CFG->frontpageloggedin),
|
||||
@@ -141,9 +146,9 @@ class tool_mobile_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
// Change a value and retrieve filtering by section.
|
||||
set_config('commentsperpage', 1);
|
||||
$expected[9]['value'] = 1;
|
||||
unset($expected[10]);
|
||||
$expected[10]['value'] = 1;
|
||||
unset($expected[11]);
|
||||
unset($expected[12]);
|
||||
|
||||
$result = external::get_config('frontpagesettings');
|
||||
$result = external_api::clean_returnvalue(external::get_config_returns(), $result);
|
||||
|
||||
Reference in New Issue
Block a user