Commit 3c1aa6fd authored by David Monllaó's avatar David Monllaó
Browse files

MDL-43535 webservices: Marking functions as deprecated

Also:
- We don't allow users to add deprecated functions to WS
- We show a debugging message when deprecated functions
  are already being used in web services.
parent 88cd577e
......@@ -190,7 +190,12 @@ class external_service_functions_form extends moodleform {
foreach ($functions as $functionid => $functionname) {
//retrieve full function information (including the description)
$function = external_function_info($functionname);
$functions[$functionid] = $function->name . ':' . $function->description;
if (empty($function->deprecated)) {
$functions[$functionid] = $function->name . ':' . $function->description;
} else {
// Exclude the deprecated ones.
unset($functions[$functionid]);
}
}
$mform->addElement('searchableselector', 'fids', get_string('name'),
......
......@@ -1982,6 +1982,15 @@ class moodle_course_external extends external_api {
return core_course_external::get_courses_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_courses_is_deprecated() {
return true;
}
/**
* Returns description of method parameters
*
......@@ -2019,4 +2028,12 @@ class moodle_course_external extends external_api {
return core_course_external::create_courses_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function create_courses_is_deprecated() {
return true;
}
}
......@@ -922,6 +922,15 @@ class moodle_enrol_external extends external_api {
);
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_enrolled_users_is_deprecated() {
return true;
}
/**
* Returns description of method parameters
*
......@@ -960,6 +969,14 @@ class moodle_enrol_external extends external_api {
return core_enrol_external::get_users_courses_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_users_courses_is_deprecated() {
return true;
}
/**
* Returns description of method parameters
......@@ -997,6 +1014,14 @@ class moodle_enrol_external extends external_api {
return core_role_external::assign_roles_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function role_assign_is_deprecated() {
return true;
}
/**
* Returns description of method parameters
......@@ -1033,4 +1058,13 @@ class moodle_enrol_external extends external_api {
public static function role_unassign_returns() {
return core_role_external::unassign_roles_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function role_unassign_is_deprecated() {
return true;
}
}
......@@ -27,8 +27,8 @@ $functions = array(
// === enrol related functions ===
'moodle_enrol_manual_enrol_users' => array(
'classname' => 'enrol_manual_external',
'methodname' => 'enrol_users',
'classname' => 'moodle_enrol_manual_external',
'methodname' => 'manual_enrol_users',
'classpath' => 'enrol/manual/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as enrol_manual_enrol_users()',
'capabilities'=> 'enrol/manual:enrol',
......
......@@ -207,4 +207,12 @@ class moodle_enrol_manual_external extends external_api {
return enrol_manual_external::enrol_users_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function manual_enrol_users_is_deprecated() {
return true;
}
}
......@@ -404,13 +404,18 @@ class moodle_file_external extends external_api {
* @param int $itemid
* @param string $filepath
* @param string $filename
* @param int $modified timestamp to return files changed after this time.
* @param string $contextlevel The context level for the file location.
* @param int $instanceid The instance id for where the file is located.
* @return array
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_files_external::get_files()
*/
public static function get_files($contextid, $component, $filearea, $itemid, $filepath, $filename) {
return core_files_external::get_files($contextid, $component, $filearea, $itemid, $filepath, $filename);
public static function get_files($contextid, $component, $filearea, $itemid, $filepath, $filename, $modified = null,
$contextlevel = null, $instanceid = null) {
return core_files_external::get_files($contextid, $component, $filearea, $itemid, $filepath, $filename,
$modified, $contextlevel, $instanceid);
}
/**
......@@ -425,6 +430,15 @@ class moodle_file_external extends external_api {
return core_files_external::get_files_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_files_is_deprecated() {
return true;
}
/**
* Returns description of upload parameters
*
......@@ -447,13 +461,16 @@ class moodle_file_external extends external_api {
* @param string $filepath
* @param string $filename
* @param string $filecontent
* @param string $contextlevel Context level (block, course, coursecat, system, user or module)
* @param int $instanceid Instance id of the item associated with the context level
* @return array
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_files_external::upload()
*/
public static function upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent) {
return core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent);
public static function upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent, $contextlevel, $instanceid) {
return core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath, $filename,
$filecontent, $contextlevel, $instanceid);
}
/**
......@@ -467,4 +484,14 @@ class moodle_file_external extends external_api {
public static function upload_returns() {
return core_files_external::upload_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function upload_is_deprecated() {
return true;
}
}
......@@ -41,11 +41,19 @@ class core_grade_external extends external_api {
}
public static function get_definitions($cmids, $areaname, $activeonly = false) {
return core_grading_external::get_definitions($cmids, $areaname, $activeonly = false);
return core_grading_external::get_definitions($cmids, $areaname, $activeonly);
}
public static function get_definitions_returns() {
return core_grading_external::get_definitions_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_definitions_is_deprecated() {
return true;
}
}
......@@ -1205,6 +1205,15 @@ class moodle_group_external extends external_api {
return core_group_external::create_groups_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function create_groups_is_deprecated() {
return true;
}
/**
* Returns description of method parameters
*
......@@ -1242,6 +1251,15 @@ class moodle_group_external extends external_api {
return core_group_external::get_groups_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_groups_is_deprecated() {
return true;
}
/**
* Returns description of method parameters
*
......@@ -1279,6 +1297,15 @@ class moodle_group_external extends external_api {
return core_group_external::get_course_groups_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_course_groups_is_deprecated() {
return true;
}
/**
* Returns description of method parameters
*
......@@ -1288,7 +1315,7 @@ class moodle_group_external extends external_api {
* @see core_group_external::delete_group_members_parameters()
*/
public static function delete_groups_parameters() {
return core_group_external::delete_group_members_parameters();
return core_group_external::delete_groups_parameters();
}
/**
......@@ -1312,9 +1339,17 @@ class moodle_group_external extends external_api {
* @see core_group_external::delete_group_members_returns()
*/
public static function delete_groups_returns() {
return core_group_external::delete_group_members_returns();
return core_group_external::delete_groups_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function delete_groups_is_deprecated() {
return true;
}
/**
* Returns description of method parameters
......@@ -1353,6 +1388,14 @@ class moodle_group_external extends external_api {
return core_group_external::get_group_members_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_groupmembers_is_deprecated() {
return true;
}
/**
* Returns description of method parameters
......@@ -1390,6 +1433,14 @@ class moodle_group_external extends external_api {
return core_group_external::add_group_members_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function add_groupmembers_is_deprecated() {
return true;
}
/**
* Returns description of method parameters
......@@ -1427,4 +1478,13 @@ class moodle_group_external extends external_api {
return core_group_external::delete_group_members_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function delete_groupmembers_is_deprecated() {
return true;
}
}
......@@ -122,10 +122,10 @@ $functions = array(
// === group related functions ===
'moodle_group_create_groups' => array(
'classname' => 'core_group_external',
'classname' => 'moodle_group_external',
'methodname' => 'create_groups',
'classpath' => 'group/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_group_create_groups(). ',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_group_create_groups(). ',
'type' => 'write',
'capabilities'=> 'moodle/course:managegroups',
),
......@@ -140,10 +140,10 @@ $functions = array(
),
'moodle_group_get_groups' => array(
'classname' => 'core_group_external',
'classname' => 'moodle_group_external',
'methodname' => 'get_groups',
'classpath' => 'group/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_group_get_groups()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_group_get_groups()',
'type' => 'read',
'capabilities'=> 'moodle/course:managegroups',
),
......@@ -158,10 +158,10 @@ $functions = array(
),
'moodle_group_get_course_groups' => array(
'classname' => 'core_group_external',
'classname' => 'moodle_group_external',
'methodname' => 'get_course_groups',
'classpath' => 'group/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_group_get_course_groups()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_group_get_course_groups()',
'type' => 'read',
'capabilities'=> 'moodle/course:managegroups',
),
......@@ -176,10 +176,10 @@ $functions = array(
),
'moodle_group_delete_groups' => array(
'classname' => 'core_group_external',
'classname' => 'moodle_group_external',
'methodname' => 'delete_groups',
'classpath' => 'group/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_group_delete_groups()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_group_delete_groups()',
'type' => 'delete',
'capabilities'=> 'moodle/course:managegroups',
),
......@@ -194,10 +194,10 @@ $functions = array(
),
'moodle_group_get_groupmembers' => array(
'classname' => 'core_group_external',
'methodname' => 'get_group_members',
'classname' => 'moodle_group_external',
'methodname' => 'get_groupmembers',
'classpath' => 'group/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_group_get_group_members()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_group_get_group_members()',
'type' => 'read',
'capabilities'=> 'moodle/course:managegroups',
),
......@@ -212,10 +212,10 @@ $functions = array(
),
'moodle_group_add_groupmembers' => array(
'classname' => 'core_group_external',
'methodname' => 'add_group_members',
'classname' => 'moodle_group_external',
'methodname' => 'add_groupmembers',
'classpath' => 'group/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_group_add_group_members()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_group_add_group_members()',
'type' => 'write',
'capabilities'=> 'moodle/course:managegroups',
),
......@@ -230,10 +230,10 @@ $functions = array(
),
'moodle_group_delete_groupmembers' => array(
'classname' => 'core_group_external',
'methodname' => 'delete_group_members',
'classname' => 'moodle_group_external',
'methodname' => 'delete_groupmembers',
'classpath' => 'group/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_group_delete_group_members()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_group_delete_group_members()',
'type' => 'delete',
'capabilities'=> 'moodle/course:managegroups',
),
......@@ -306,9 +306,9 @@ $functions = array(
// === file related functions ===
'moodle_file_get_files' => array(
'classname' => 'core_files_external',
'classname' => 'moodle_file_external',
'methodname' => 'get_files',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_files_get_files()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_files_get_files()',
'type' => 'read',
'classpath' => 'files/externallib.php',
),
......@@ -322,9 +322,9 @@ $functions = array(
),
'moodle_file_upload' => array(
'classname' => 'core_files_external',
'classname' => 'moodle_file_external',
'methodname' => 'upload',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_files_upload()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_files_upload()',
'type' => 'write',
'classpath' => 'files/externallib.php',
),
......@@ -340,10 +340,10 @@ $functions = array(
// === user related functions ===
'moodle_user_create_users' => array(
'classname' => 'core_user_external',
'classname' => 'moodle_user_external',
'methodname' => 'create_users',
'classpath' => 'user/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_user_create_users()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_user_create_users()',
'type' => 'write',
'capabilities'=> 'moodle/user:create',
),
......@@ -367,10 +367,10 @@ $functions = array(
),
'moodle_user_get_users_by_id' => array(
'classname' => 'core_user_external',
'classname' => 'moodle_user_external',
'methodname' => 'get_users_by_id',
'classpath' => 'user/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_user_get_users_by_id()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. Use core_user_get_users_by_field service instead',
'type' => 'read',
'capabilities'=> 'moodle/user:viewdetails, moodle/user:viewhiddendetails, moodle/course:useremail, moodle/user:update',
),
......@@ -394,19 +394,19 @@ $functions = array(
),
'moodle_user_get_users_by_courseid' => array(
'classname' => 'core_enrol_external',
'methodname' => 'get_enrolled_users',
'classpath' => 'enrol/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_enrol_get_enrolled_users()',
'classname' => 'moodle_user_external',
'methodname' => 'get_users_by_courseid',
'classpath' => 'user/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_enrol_get_enrolled_users()',
'type' => 'read',
'capabilities'=> 'moodle/user:viewdetails, moodle/user:viewhiddendetails, moodle/course:useremail, moodle/user:update, moodle/site:accessallgroups',
),
'moodle_user_get_course_participants_by_id' => array(
'classname' => 'core_user_external',
'methodname' => 'get_course_user_profiles',
'classname' => 'moodle_user_external',
'methodname' => 'get_course_participants_by_id',
'classpath' => 'user/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_user_get_course_user_profiles()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_user_get_course_user_profiles()',
'type' => 'read',
'capabilities'=> 'moodle/user:viewdetails, moodle/user:viewhiddendetails, moodle/course:useremail, moodle/user:update, moodle/site:accessallgroups',
),
......@@ -421,10 +421,10 @@ $functions = array(
),
'moodle_user_delete_users' => array(
'classname' => 'core_user_external',
'classname' => 'moodle_user_external',
'methodname' => 'delete_users',
'classpath' => 'user/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_user_delete_users()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_user_delete_users()',
'type' => 'write',
'capabilities'=> 'moodle/user:delete',
),
......@@ -439,10 +439,10 @@ $functions = array(
),
'moodle_user_update_users' => array(
'classname' => 'core_user_external',
'classname' => 'moodle_user_external',
'methodname' => 'update_users',
'classpath' => 'user/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_user_update_users()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_user_update_users()',
'type' => 'write',
'capabilities'=> 'moodle/user:update',
),
......@@ -496,10 +496,10 @@ $functions = array(
),
'moodle_enrol_get_users_courses' => array(
'classname' => 'core_enrol_external',
'classname' => 'moodle_enrol_external',
'methodname' => 'get_users_courses',
'classpath' => 'enrol/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_enrol_get_users_courses()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_enrol_get_users_courses()',
'type' => 'read',
'capabilities'=> 'moodle/course:viewparticipants',
),
......@@ -524,10 +524,10 @@ $functions = array(
// === Role related functions ===
'moodle_role_assign' => array(
'classname' => 'core_role_external',
'methodname' => 'assign_roles',
'classname' => 'moodle_enrol_external',
'methodname' => 'role_assign',
'classpath' => 'enrol/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_role_assign_role()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_role_assign_role()',
'type' => 'write',
'capabilities'=> 'moodle/role:assign',
),
......@@ -542,10 +542,10 @@ $functions = array(
),
'moodle_role_unassign' => array(
'classname' => 'core_role_external',
'methodname' => 'unassign_roles',
'classname' => 'moodle_enrol_external',
'methodname' => 'role_unassign',
'classpath' => 'enrol/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_role_unassign_role()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_role_unassign_role()',
'type' => 'write',
'capabilities'=> 'moodle/role:assign',
),
......@@ -571,10 +571,10 @@ $functions = array(
),
'moodle_course_get_courses' => array(
'classname' => 'core_course_external',
'classname' => 'moodle_course_external',
'methodname' => 'get_courses',
'classpath' => 'course/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_course_get_courses()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_course_get_courses()',
'type' => 'read',
'capabilities'=> 'moodle/course:view,moodle/course:update,moodle/course:viewhiddencourses',
),
......@@ -589,10 +589,10 @@ $functions = array(
),
'moodle_course_create_courses' => array(
'classname' => 'core_course_external',
'classname' => 'moodle_course_external',
'methodname' => 'create_courses',
'classpath' => 'course/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_course_create_courses()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_course_create_courses()',
'type' => 'write',
'capabilities'=> 'moodle/course:create,moodle/course:visibility',
),
......@@ -692,10 +692,10 @@ $functions = array(
// === message related functions ===
'moodle_message_send_instantmessages' => array(
'classname' => 'core_message_external',
'methodname' => 'send_instant_messages',
'classname' => 'moodle_message_external',
'methodname' => 'send_instantmessages',
'classpath' => 'message/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_message_send_instant_messages()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_message_send_instant_messages()',
'type' => 'write',
'capabilities'=> 'moodle/site:sendmessage',
),
......@@ -784,10 +784,10 @@ $functions = array(
// === notes related functions ===
'moodle_notes_create_notes' => array(
'classname' => 'core_notes_external',
'classname' => 'moodle_notes_external',
'methodname' => 'create_notes',
'classpath' => 'notes/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_notes_create_notes()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_notes_create_notes()',
'type' => 'write',
'capabilities'=> 'moodle/notes:manage',
),
......@@ -862,10 +862,10 @@ $functions = array(
// === webservice related functions ===
'moodle_webservice_get_siteinfo' => array(
'classname' => 'core_webservice_external',
'methodname' => 'get_site_info',
'classname' => 'moodle_webservice_external',
'methodname' => 'get_siteinfo',
'classpath' => 'webservice/externallib.php',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has be renamed as core_webservice_get_site_info()',
'description' => 'DEPRECATED: this deprecated function will be removed in a future version. This function has been renamed as core_webservice_get_site_info()',
'type' => 'read',
),
......
......@@ -58,6 +58,7 @@ function external_function_info($function, $strictness=MUST_EXIST) {
$function->parameters_method = $function->methodname.'_parameters';
$function->returns_method = $function->methodname.'_returns';
$function->deprecated_method = $function->methodname.