MDL-66229 tool_mobile: New return field "disabled" in get_content WS
This commit is contained in:
@@ -369,12 +369,12 @@ class external extends external_api {
|
||||
|
||||
/**
|
||||
* Returns a piece of content to be displayed in the Mobile app, it usually returns a template, javascript and
|
||||
* other structured data that will be used to render a view in the Mobile app..
|
||||
* other structured data that will be used to render a view in the Mobile app.
|
||||
*
|
||||
* Callbacks (placed in \$component\output\mobile) that are called by this web service are responsible for doing the
|
||||
* appropriate security checks to access the information to be returned.
|
||||
*
|
||||
* @param string $component fame of the component.
|
||||
* @param string $component name of the component.
|
||||
* @param string $method function method name in class \$component\output\mobile.
|
||||
* @param array $args optional arguments for the method.
|
||||
* @return array HTML, JavaScript and other required data and information to create a view in the app.
|
||||
@@ -423,6 +423,7 @@ class external extends external_api {
|
||||
'otherdata' => $otherdata,
|
||||
'files' => !empty($result['files']) ? $result['files'] : array(),
|
||||
'restrict' => !empty($result['restrict']) ? $result['restrict'] : array(),
|
||||
'disabled' => !empty($result['disabled']) ? true : false,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -465,7 +466,8 @@ class external extends external_api {
|
||||
),
|
||||
),
|
||||
'Restrict this content to certain users or courses.'
|
||||
)
|
||||
),
|
||||
'disabled' => new external_value(PARAM_BOOL, 'Whether we consider this disabled or not.', VALUE_OPTIONAL),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -371,6 +371,19 @@ class tool_mobile_external_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEquals(array(1, 2), $result['restrict']['users']);
|
||||
$this->assertEquals(array(3, 4), $result['restrict']['courses']);
|
||||
$this->assertEmpty($result['files']);
|
||||
$this->assertFalse($result['disabled']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_content disabled.
|
||||
*/
|
||||
public function test_get_content_disabled() {
|
||||
|
||||
$paramval = 16;
|
||||
$result = external::get_content('tool_mobile', 'test_view_disabled',
|
||||
array(array('name' => 'param1', 'value' => $paramval)));
|
||||
$result = external_api::clean_returnvalue(external::get_content_returns(), $result);
|
||||
$this->assertTrue($result['disabled']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+23
-1
@@ -38,7 +38,6 @@ class mobile {
|
||||
/**
|
||||
* Returns a test view.
|
||||
* @param array $args Arguments from tool_mobile_get_content WS
|
||||
*
|
||||
* @return array HTML, javascript and otherdata
|
||||
*/
|
||||
public static function test_view($args) {
|
||||
@@ -57,4 +56,27 @@ class mobile {
|
||||
'files' => array()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a test view disabled.
|
||||
* @param array $args Arguments from tool_mobile_get_content WS
|
||||
* @return array HTML, javascript and otherdata
|
||||
*/
|
||||
public static function test_view_disabled($args) {
|
||||
$args = (object) $args;
|
||||
|
||||
return array(
|
||||
'templates' => array(
|
||||
array(
|
||||
'id' => 'main',
|
||||
'html' => 'The HTML code',
|
||||
),
|
||||
),
|
||||
'javascript' => 'alert();',
|
||||
'otherdata' => array('otherdata1' => $args->param1),
|
||||
'restrict' => array('users' => array(1, 2), 'courses' => array(3, 4)),
|
||||
'files' => array(),
|
||||
'disabled' => true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user