mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-32581 support additional format field with all text field in extrnal lib function + new possible ws params to decide how format is returned (which are stored in a singleton)
This commit is contained in:
parent
4631e39533
commit
93ce0e8296
11 changed files with 382 additions and 88 deletions
|
@ -52,6 +52,7 @@ class core_group_external extends external_api {
|
|||
'courseid' => new external_value(PARAM_INT, 'id of course'),
|
||||
'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
|
||||
'description' => new external_value(PARAM_RAW, 'group description text'),
|
||||
'descriptionformat' => new external_format_value('description', VALUE_DEFAULT),
|
||||
'enrolmentkey' => new external_value(PARAM_RAW, 'group enrol secret phrase'),
|
||||
)
|
||||
), 'List of group object. A group has a courseid, a name, a description and an enrolment key.'
|
||||
|
@ -99,6 +100,9 @@ class core_group_external extends external_api {
|
|||
}
|
||||
require_capability('moodle/course:managegroups', $context);
|
||||
|
||||
// Validate format.
|
||||
$group->descriptionformat = external_validate_format($group->descriptionformat);
|
||||
|
||||
// finally create the group
|
||||
$group->id = groups_create_group($group, false);
|
||||
$groups[] = (array)$group;
|
||||
|
@ -123,6 +127,7 @@ class core_group_external extends external_api {
|
|||
'courseid' => new external_value(PARAM_INT, 'id of course'),
|
||||
'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
|
||||
'description' => new external_value(PARAM_RAW, 'group description text'),
|
||||
'descriptionformat' => new external_format_value('description'),
|
||||
'enrolmentkey' => new external_value(PARAM_RAW, 'group enrol secret phrase'),
|
||||
)
|
||||
), 'List of group object. A group has an id, a courseid, a name, a description and an enrolment key.'
|
||||
|
@ -157,7 +162,7 @@ class core_group_external extends external_api {
|
|||
$groups = array();
|
||||
foreach ($params['groupids'] as $groupid) {
|
||||
// validate params
|
||||
$group = groups_get_group($groupid, 'id, courseid, name, description, enrolmentkey', MUST_EXIST);
|
||||
$group = groups_get_group($groupid, 'id, courseid, name, description, descriptionformat, enrolmentkey', MUST_EXIST);
|
||||
|
||||
// now security checks
|
||||
$context = get_context_instance(CONTEXT_COURSE, $group->courseid);
|
||||
|
@ -171,6 +176,10 @@ class core_group_external extends external_api {
|
|||
}
|
||||
require_capability('moodle/course:managegroups', $context);
|
||||
|
||||
list($group->description, $group->descriptionformat) =
|
||||
external_format_text($group->description, $group->descriptionformat,
|
||||
$context->id, 'group', 'description', $group->id);
|
||||
|
||||
$groups[] = (array)$group;
|
||||
}
|
||||
|
||||
|
@ -191,6 +200,7 @@ class core_group_external extends external_api {
|
|||
'courseid' => new external_value(PARAM_INT, 'id of course'),
|
||||
'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
|
||||
'description' => new external_value(PARAM_RAW, 'group description text'),
|
||||
'descriptionformat' => new external_format_value('description'),
|
||||
'enrolmentkey' => new external_value(PARAM_RAW, 'group enrol secret phrase'),
|
||||
)
|
||||
)
|
||||
|
@ -233,10 +243,14 @@ class core_group_external extends external_api {
|
|||
}
|
||||
require_capability('moodle/course:managegroups', $context);
|
||||
|
||||
$gs = groups_get_all_groups($params['courseid'], 0, 0, 'g.id, g.courseid, g.name, g.description, g.enrolmentkey');
|
||||
$gs = groups_get_all_groups($params['courseid'], 0, 0,
|
||||
'g.id, g.courseid, g.name, g.description, g.descriptionformat, g.enrolmentkey');
|
||||
|
||||
$groups = array();
|
||||
foreach ($gs as $group) {
|
||||
list($group->description, $group->descriptionformat) =
|
||||
external_format_text($group->description, $group->descriptionformat,
|
||||
$context->id, 'group', 'description', $group->id);
|
||||
$groups[] = (array)$group;
|
||||
}
|
||||
|
||||
|
@ -257,6 +271,7 @@ class core_group_external extends external_api {
|
|||
'courseid' => new external_value(PARAM_INT, 'id of course'),
|
||||
'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
|
||||
'description' => new external_value(PARAM_RAW, 'group description text'),
|
||||
'descriptionformat' => new external_format_value('description'),
|
||||
'enrolmentkey' => new external_value(PARAM_RAW, 'group enrol secret phrase'),
|
||||
)
|
||||
)
|
||||
|
@ -557,7 +572,8 @@ class core_group_external extends external_api {
|
|||
array(
|
||||
'courseid' => new external_value(PARAM_INT, 'id of course'),
|
||||
'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
|
||||
'description' => new external_value(PARAM_RAW, 'grouping description text')
|
||||
'description' => new external_value(PARAM_RAW, 'grouping description text'),
|
||||
'descriptionformat' => new external_format_value('descripiton', VALUE_DEFAULT)
|
||||
)
|
||||
), 'List of grouping object. A grouping has a courseid, a name and a description.'
|
||||
)
|
||||
|
@ -604,8 +620,7 @@ class core_group_external extends external_api {
|
|||
}
|
||||
require_capability('moodle/course:managegroups', $context);
|
||||
|
||||
// We must force allways FORMAT_HTML.
|
||||
$grouping->descriptionformat = FORMAT_HTML;
|
||||
$grouping->descriptionformat = external_validate_format($grouping->descriptionformat);
|
||||
|
||||
// Finally create the grouping.
|
||||
$grouping->id = groups_create_grouping($grouping);
|
||||
|
@ -630,7 +645,8 @@ class core_group_external extends external_api {
|
|||
'id' => new external_value(PARAM_INT, 'grouping record id'),
|
||||
'courseid' => new external_value(PARAM_INT, 'id of course'),
|
||||
'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
|
||||
'description' => new external_value(PARAM_CLEANHTML, 'grouping description text')
|
||||
'description' => new external_value(PARAM_RAW, 'grouping description text'),
|
||||
'descriptionformat' => new external_format_value('description')
|
||||
)
|
||||
), 'List of grouping object. A grouping has an id, a courseid, a name and a description.'
|
||||
);
|
||||
|
@ -650,7 +666,8 @@ class core_group_external extends external_api {
|
|||
array(
|
||||
'id' => new external_value(PARAM_INT, 'id of grouping'),
|
||||
'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
|
||||
'description' => new external_value(PARAM_RAW, 'grouping description text')
|
||||
'description' => new external_value(PARAM_RAW, 'grouping description text'),
|
||||
'descriptionformat' => new external_format_value('description', VALUE_DEFAULT)
|
||||
)
|
||||
), 'List of grouping object. A grouping has a courseid, a name and a description.'
|
||||
)
|
||||
|
@ -705,7 +722,7 @@ class core_group_external extends external_api {
|
|||
require_capability('moodle/course:managegroups', $context);
|
||||
|
||||
// We must force allways FORMAT_HTML.
|
||||
$grouping->descriptionformat = FORMAT_HTML;
|
||||
$grouping->descriptionformat = external_validate_format($grouping->descriptionformat);
|
||||
|
||||
// Finally update the grouping.
|
||||
groups_update_grouping($grouping);
|
||||
|
@ -772,12 +789,9 @@ class core_group_external extends external_api {
|
|||
}
|
||||
require_capability('moodle/course:managegroups', $context);
|
||||
|
||||
$grouping->description = file_rewrite_pluginfile_urls($grouping->description, 'webservice/pluginfile.php', $context->id, 'grouping', 'description', $grouping->id);
|
||||
|
||||
$options = new stdClass;
|
||||
$options->noclean = true;
|
||||
$options->para = false;
|
||||
$grouping->description = format_text($grouping->description, FORMAT_HTML, $options);
|
||||
list($grouping->description, $grouping->descriptionformat) =
|
||||
external_format_text($grouping->description, $grouping->descriptionformat,
|
||||
$context->id, 'grouping', 'description', $grouping->id);
|
||||
|
||||
$groupings[] = (array)$grouping;
|
||||
}
|
||||
|
@ -798,7 +812,8 @@ class core_group_external extends external_api {
|
|||
'id' => new external_value(PARAM_INT, 'grouping record id'),
|
||||
'courseid' => new external_value(PARAM_INT, 'id of course'),
|
||||
'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
|
||||
'description' => new external_value(PARAM_CLEANHTML, 'grouping description text')
|
||||
'description' => new external_value(PARAM_RAW, 'grouping description text'),
|
||||
'descriptionformat' => new external_format_value('description')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -849,13 +864,9 @@ class core_group_external extends external_api {
|
|||
|
||||
$groupings = array();
|
||||
foreach ($gs as $grouping) {
|
||||
$grouping->description = file_rewrite_pluginfile_urls($grouping->description, 'webservice/pluginfile.php', $context->id, 'grouping', 'description', $grouping->id);
|
||||
|
||||
$options = new stdClass;
|
||||
$options->noclean = true;
|
||||
$options->para = false;
|
||||
$grouping->description = format_text($grouping->description, FORMAT_HTML, $options);
|
||||
|
||||
list($grouping->description, $grouping->descriptionformat) =
|
||||
external_format_text($grouping->description, $grouping->descriptionformat,
|
||||
$context->id, 'grouping', 'description', $grouping->id);
|
||||
$groupings[] = (array)$grouping;
|
||||
}
|
||||
|
||||
|
@ -875,7 +886,8 @@ class core_group_external extends external_api {
|
|||
'id' => new external_value(PARAM_INT, 'grouping record id'),
|
||||
'courseid' => new external_value(PARAM_INT, 'id of course'),
|
||||
'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
|
||||
'description' => new external_value(PARAM_CLEANHTML, 'grouping description text')
|
||||
'description' => new external_value(PARAM_RAW, 'grouping description text'),
|
||||
'descriptionformat' => new external_format_value('description')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue