From f7beb2df0b606227099a1df50a6e8d76eb9b4ecd Mon Sep 17 00:00:00 2001 From: Dongsheng Cai Date: Thu, 23 Jul 2015 17:49:23 +1000 Subject: [PATCH] EQ-2277 Add capability requirements to equella web service definition --- ChangeLog | 12 ++++++++++++ db/services.php | 19 +++++++++++++------ settings.php | 13 +++++++------ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3607385..359f161 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2015-07-23 Dongsheng Cai + + EQ-2277 Add capability requirements to equella web service definition + +2015-07-20 Dongsheng Cai + + EQ-2269 Add filename to module db record + +2015-06-11 Dongsheng Cai + + Ability to disable self signed ssl certificate check + 2015-05-13 Dongsheng Cai New release requires 2.7 and up. diff --git a/db/services.php b/db/services.php index e9ed2c6..c58a849 100644 --- a/db/services.php +++ b/db/services.php @@ -20,6 +20,7 @@ 'classpath' => 'mod/equella/externallib.php', 'description' => 'List the courses for the given user.', 'type' => 'read', + 'capabilities' => 'moodle/course:view' ), 'equella_list_sections_for_course' => array( 'classname' => 'equella_external', @@ -27,6 +28,7 @@ 'classpath' => 'mod/equella/externallib.php', 'description' => 'List the sections for the given course.', 'type' => 'read', + 'capabilities' => 'moodle/course:view' ), 'equella_add_item_to_course' => array( 'classname' => 'equella_external', @@ -34,6 +36,7 @@ 'classpath' => 'mod/equella/externallib.php', 'description' => 'Add an EQUELLA item to a given course by a given user.', 'type' => 'write', + 'capabilities' => 'moodle/course:manageactivities' ), 'equella_test_connection' => array( 'classname' => 'equella_external', @@ -48,6 +51,7 @@ 'classpath' => 'mod/equella/externallib.php', 'description' => 'List all the locations that the supplied item is used.', 'type' => 'read', + 'capabilities' => 'moodle/course:view' ), 'equella_find_all_usage' => array( 'classname' => 'equella_external', @@ -55,6 +59,7 @@ 'classpath' => 'mod/equella/externallib.php', 'description' => 'List all the locations that Equella content is used.', 'type' => 'read', + 'capabilities' => 'moodle/course:view' ), 'equella_unfiltered_usage_count' => array( 'classname' => 'equella_external', @@ -62,6 +67,7 @@ 'classpath' => 'mod/equella/externallib.php', 'description' => 'Get the number of results that would be returned by equella_find_all_usages without a course ID and folder ID value, and with an unlimited count', 'type' => 'read', + 'capabilities' => 'moodle/course:view' ), 'equella_get_course_code' => array( 'classname' => 'equella_external', @@ -69,6 +75,7 @@ 'classpath' => 'mod/equella/externallib.php', 'description' => 'Returns the course code for the supplied course id', 'type' => 'read', + 'capabilities' => 'moodle/course:view' ), 'equella_edit_item' => array( 'classname' => 'equella_external', @@ -76,6 +83,7 @@ 'classpath' => 'mod/equella/externallib.php', 'description' => 'Modify an item in moodle', 'type' => 'write', + 'capabilities' => 'moodle/course:manageactivities' ), 'equella_move_item' => array( 'classname' => 'equella_external', @@ -83,6 +91,7 @@ 'classpath' => 'mod/equella/externallib.php', 'description' => 'Move an item in moodle', 'type' => 'write', + 'capabilities' => 'moodle/course:manageactivities' ), 'equella_delete_item' => array( 'classname' => 'equella_external', @@ -90,19 +99,17 @@ 'classpath' => 'mod/equella/externallib.php', 'description' => 'Deletes an item in moodle', 'type' => 'write', + 'capabilities' => 'moodle/course:manageactivities' ) ); +$functionnames = array_keys($functions); + $services = array( 'equellaservice' => array( - 'functions' => array ('equella_list_courses_for_user', 'equella_list_sections_for_course', - 'equella_add_item_to_course', 'equella_test_connection', - 'equella_find_usage_for_item', 'equella_find_all_usage', 'equella_unfiltered_usage_count', - 'equella_get_course_code', 'equella_edit_item', 'equella_delete_item', 'equella_move_item'), + 'functions' => $functionnames, 'requiredcapability' => 'moodle/course:manageactivities', 'restrictedusers' => 1, 'enabled' => 1, ) ); - -?> diff --git a/settings.php b/settings.php index 944dde6..d9ce3e5 100644 --- a/settings.php +++ b/settings.php @@ -76,19 +76,20 @@ function ecs($configoption, $params = null) { $rolearchetypes = get_role_archetypes(); foreach(get_all_editing_roles() as $role) { - $sectionname = 'equella_' . $role->shortname . '_role_group'; - if (in_array($role->shortname, $rolearchetypes)) { - $heading = ecs('group.' . $role->shortname); + $shortname = clean_param($role->shortname, PARAM_ALPHANUM); + if (in_array($shortname, $rolearchetypes)) { + $heading = ecs('group.' . $shortname); } else { - $heading = ecs('group.noname', $role->shortname); + $heading = ecs('group.noname', $shortname); if (!empty($role->name)) { $heading = ecs('group', $role->name); } } + $sectionname = 'equella_' . $shortname . '_role_group'; $settings->add(new equella_setting_left_heading($sectionname, $heading, '')); - $settings->add(new admin_setting_configtext("equella_{$role->shortname}_shareid", ecs('sharedid.title'), $description, $defaultvalue, PARAM_TEXT)); - $settings->add(new admin_setting_configtext("equella_{$role->shortname}_sharedsecret", ecs('sharedsecret.title'), $description, $defaultvalue, PARAM_TEXT)); + $settings->add(new admin_setting_configtext("equella_{$shortname}_shareid", ecs('sharedid.title'), $description, $defaultvalue, PARAM_TEXT)); + $settings->add(new admin_setting_configtext("equella_{$shortname}_sharedsecret", ecs('sharedsecret.title'), $description, $defaultvalue, PARAM_TEXT)); } // /////////////////////////////////////////////////////////////////////////////// //