Commit f23e9b6b authored by Cameron Ball's avatar Cameron Ball
Browse files

MDL-49414 webservices: Remove deprecated functions

parent 6bd3ab07
This diff is collapsed.
......@@ -2495,108 +2495,3 @@ class core_course_external extends external_api {
}
}
/**
* Deprecated course external functions
*
* @package core_course
* @copyright 2009 Petr Skodak
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not use this class any more.
* @see core_course_external
*/
class moodle_course_external extends external_api {
/**
* Returns description of method parameters
*
* @return external_function_parameters
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_course_external::get_courses_parameters()
*/
public static function get_courses_parameters() {
return core_course_external::get_courses_parameters();
}
/**
* Get courses
*
* @param array $options
* @return array
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_course_external::get_courses()
*/
public static function get_courses($options) {
return core_course_external::get_courses($options);
}
/**
* Returns description of method result value
*
* @return external_description
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_course_external::get_courses_returns()
*/
public static function get_courses_returns() {
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
*
* @return external_function_parameters
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_course_external::create_courses_parameters()
*/
public static function create_courses_parameters() {
return core_course_external::create_courses_parameters();
}
/**
* Create courses
*
* @param array $courses
* @return array courses (id and shortname only)
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_course_external::create_courses()
*/
public static function create_courses($courses) {
return core_course_external::create_courses($courses);
}
/**
* Returns description of method result value
*
* @return external_description
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_course_external::create_courses_returns()
*/
public static function create_courses_returns() {
return core_course_external::create_courses_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function create_courses_is_deprecated() {
return true;
}
}
......@@ -839,303 +839,3 @@ class core_role_external extends external_api {
return null;
}
}
/**
* Deprecated enrol and role external functions
*
* @package core_enrol
* @copyright 2010 Jerome Mouneyrac
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not use this class any more.
* @see core_enrol_external
* @see core_role_external
*/
class moodle_enrol_external extends external_api {
/**
* Returns description of method parameters
*
* @return external_function_parameters
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_enrol_external::get_enrolled_users_parameters()
*/
public static function get_enrolled_users_parameters() {
return new external_function_parameters(
array(
'courseid' => new external_value(PARAM_INT, 'Course id'),
'withcapability' => new external_value(PARAM_CAPABILITY, 'User should have this capability', VALUE_DEFAULT, null),
'groupid' => new external_value(PARAM_INT, 'Group id, null means all groups', VALUE_DEFAULT, null),
'onlyactive' => new external_value(PARAM_INT, 'True means only active, false means all participants', VALUE_DEFAULT, 0),
)
);
}
/**
* Get list of course participants.
*
* @param int $courseid
* @param text $withcapability
* @param int $groupid
* @param bool $onlyactive
* @return array of course participants
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_enrol_external::get_enrolled_users()
*/
public static function get_enrolled_users($courseid, $withcapability = null, $groupid = null, $onlyactive = false) {
global $DB, $CFG, $USER;
// Do basic automatic PARAM checks on incoming data, using params description
// If any problems are found then exceptions are thrown with helpful error messages
$params = self::validate_parameters(self::get_enrolled_users_parameters(), array(
'courseid'=>$courseid,
'withcapability'=>$withcapability,
'groupid'=>$groupid,
'onlyactive'=>$onlyactive)
);
$coursecontext = context_course::instance($params['courseid'], IGNORE_MISSING);
if ($courseid == SITEID) {
$context = context_system::instance();
} else {
$context = $coursecontext;
}
try {
self::validate_context($context);
} catch (Exception $e) {
$exceptionparam = new stdClass();
$exceptionparam->message = $e->getMessage();
$exceptionparam->courseid = $params['courseid'];
throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
}
if ($courseid == SITEID) {
require_capability('moodle/site:viewparticipants', $context);
} else {
require_capability('moodle/course:viewparticipants', $context);
}
if ($withcapability) {
require_capability('moodle/role:review', $coursecontext);
}
if ($groupid && groups_is_member($groupid)) {
require_capability('moodle/site:accessallgroups', $coursecontext);
}
if ($onlyactive) {
require_capability('moodle/course:enrolreview', $coursecontext);
}
list($sqlparams, $params) = get_enrolled_sql($coursecontext, $withcapability, $groupid, $onlyactive);
$sql = "SELECT ue.userid, e.courseid, u.firstname, u.lastname, u.username, c.id as usercontextid
FROM {user_enrolments} ue
JOIN {enrol} e ON (e.id = ue.enrolid)
JOIN {user} u ON (ue.userid = u.id)
JOIN {context} c ON (u.id = c.instanceid AND contextlevel = " . CONTEXT_USER . ")
WHERE e.courseid = :courseid AND ue.userid IN ($sqlparams)
GROUP BY ue.userid, e.courseid, u.firstname, u.lastname, u.username, c.id";
$params['courseid'] = $courseid;
$enrolledusers = $DB->get_records_sql($sql, $params);
$result = array();
$isadmin = is_siteadmin($USER);
$canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
foreach ($enrolledusers as $enrolleduser) {
$profilimgurl = moodle_url::make_pluginfile_url($enrolleduser->usercontextid, 'user', 'icon', NULL, '/', 'f1');
$profilimgurlsmall = moodle_url::make_pluginfile_url($enrolleduser->usercontextid, 'user', 'icon', NULL, '/', 'f2');
$resultuser = array(
'courseid' => $enrolleduser->courseid,
'userid' => $enrolleduser->userid,
'fullname' => fullname($enrolleduser),
'profileimgurl' => $profilimgurl->out(false),
'profileimgurlsmall' => $profilimgurlsmall->out(false)
);
// check if we can return username
if ($isadmin) {
$resultuser['username'] = $enrolleduser->username;
}
// check if we can return first and last name
if ($isadmin or $canviewfullnames) {
$resultuser['firstname'] = $enrolleduser->firstname;
$resultuser['lastname'] = $enrolleduser->lastname;
}
$result[] = $resultuser;
}
return $result;
}
/**
* Returns description of method result value
*
* @return external_description
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_enrol_external::get_enrolled_users_returns()
*/
public static function get_enrolled_users_returns() {
return new external_multiple_structure(
new external_single_structure(
array(
'courseid' => new external_value(PARAM_INT, 'id of course'),
'userid' => new external_value(PARAM_INT, 'id of user'),
'firstname' => new external_value(PARAM_RAW, 'first name of user', VALUE_OPTIONAL),
'lastname' => new external_value(PARAM_RAW, 'last name of user', VALUE_OPTIONAL),
'fullname' => new external_value(PARAM_RAW, 'fullname of user'),
'username' => new external_value(PARAM_RAW, 'username of user', VALUE_OPTIONAL),
'profileimgurl' => new external_value(PARAM_URL, 'url of the profile image'),
'profileimgurlsmall' => new external_value(PARAM_URL, 'url of the profile image (small version)')
)
)
);
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function get_enrolled_users_is_deprecated() {
return true;
}
/**
* Returns description of method parameters
*
* @return external_function_parameters
* @since Moodle 2.1
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_enrol_external::get_users_courses_parameters()
*/
public static function get_users_courses_parameters() {
return core_enrol_external::get_users_courses_parameters();
}
/**
* Get list of courses user is enrolled in (only active enrolments are returned).
* Please note the current user must be able to access the course, otherwise the course is not included.
*
* @param int $userid
* @return array of courses
* @since Moodle 2.1
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see use core_enrol_external::get_users_courses()
*/
public static function get_users_courses($userid) {
return core_enrol_external::get_users_courses($userid);
}
/**
* Returns description of method result value
*
* @return external_description
* @since Moodle 2.1
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_enrol_external::get_users_courses_returns()
*/
public static function get_users_courses_returns() {
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
*
* @return external_function_parameters
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_role_external::assign_roles_parameters()
*/
public static function role_assign_parameters() {
return core_role_external::assign_roles_parameters();
}
/**
* Manual role assignments to users
*
* @param array $assignments An array of manual role assignment
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_role_external::assign_roles()
*/
public static function role_assign($assignments) {
return core_role_external::assign_roles($assignments);
}
/**
* Returns description of method result value
*
* @return null
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_role_external::assign_roles_returns()
*/
public static function role_assign_returns() {
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
*
* @return external_function_parameters
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_role_external::unassign_roles_parameters()
*/
public static function role_unassign_parameters() {
return core_role_external::unassign_roles_parameters();
}
/**
* Unassign roles from users
*
* @param array $unassignments An array of unassignment
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_role_external::unassign_roles()
*/
public static function role_unassign($unassignments) {
return core_role_external::unassign_roles($unassignments);
}
/**
* Returns description of method result value
*
* @return null
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_role_external::unassign_roles_returns()
*/
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;
}
}
......@@ -26,15 +26,6 @@
$functions = array(
// === enrol related functions ===
'moodle_enrol_manual_enrol_users' => array(
'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',
'type' => 'write',
),
'enrol_manual_enrol_users' => array(
'classname' => 'enrol_manual_external',
'methodname' => 'enrol_users',
......
......@@ -226,62 +226,3 @@ class enrol_manual_external extends external_api {
}
}
/**
* Deprecated manual enrolment external functions.
*
* @package enrol_manual
* @copyright 2011 Jerome Mouneyrac
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not use this class any more.
* @see enrol_manual_external
*/
class moodle_enrol_manual_external extends external_api {
/**
* Returns description of method parameters.
*
* @return external_function_parameters
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see enrol_manual_external::enrol_users_parameters()
*/
public static function manual_enrol_users_parameters() {
return enrol_manual_external::enrol_users_parameters();
}
/**
* Enrolment of users
* Function throw an exception at the first error encountered.
*
* @param array $enrolments An array of user enrolment
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see enrol_manual_external::enrol_users()
*/
public static function manual_enrol_users($enrolments) {
return enrol_manual_external::enrol_users($enrolments);
}
/**
* Returns description of method result value.
*
* @return nul
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see enrol_manual_external::enrol_users_returns()
*/
public static function manual_enrol_users_returns() {
return enrol_manual_external::enrol_users_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function manual_enrol_users_is_deprecated() {
return true;
}
}
......@@ -307,9 +307,9 @@ class core_files_external extends external_api {
$filepath = '/';
}
// Only allow uploads to draft or private areas (private is deprecated but still supported)
if (!($fileinfo['component'] == 'user' and in_array($fileinfo['filearea'], array('private', 'draft')))) {
throw new coding_exception('File can be uploaded to user private or draft areas only');
// Only allow uploads to draft area
if (!($fileinfo['component'] == 'user' and $fileinfo['filearea'] == 'draft')) {
throw new coding_exception('File can be uploaded to user draft area only');
} else {
$component = 'user';
$filearea = $fileinfo['filearea'];
......@@ -336,8 +336,7 @@ class core_files_external extends external_api {
$context = self::get_context_from_params($fileinfo);
self::validate_context($context);
if (($fileinfo['component'] == 'user' and $fileinfo['filearea'] == 'private')) {
require_capability('moodle/user:manageownfiles', $context);
debugging('Uploading directly to user private files area is deprecated. Upload to a draft area and then move the files with core_user::add_user_private_files');
throw new moodle_exception('privatefilesupload');
}
$browser = get_file_browser();
......@@ -386,128 +385,3 @@ class core_files_external extends external_api {
);
}
}
/**
* Deprecated files external functions
*
* @package core_files
* @copyright 2010 Dongsheng Cai
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not use this class any more.
* @see core_files_external
*/
class moodle_file_external extends external_api {
/**
* Returns description of get_files parameters
*
* @return external_function_parameters
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_files_external::get_files_parameters()
*/
public static function get_files_parameters() {
return core_files_external::get_files_parameters();
}
/**
* Return moodle files listing
*
* @param int $contextid
* @param int $component
* @param int $filearea
* @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, $modified = null,
$contextlevel = null, $instanceid = null) {
return core_files_external::get_files($contextid, $component, $filearea, $itemid, $filepath, $filename,
$modified, $contextlevel, $instanceid);
}
/**
* Returns description of get_files returns
*
* @return external_single_structure
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_files_external::get_files_returns()
*/
public static function get_files_returns() {
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
*
* @return external_function_parameters
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @see core_files_external::upload_parameters()
*/
public static function upload_parameters() {
return core_files_external::upload_parameters();
}
/**
* Uploading a file to moodle
*
* @param int $contextid
* @param string $component
* @param string $filearea
* @param int $itemid
* @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, $contextlevel, $instanceid) {
return core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath, $filename,
$filecontent, $contextlevel, $instanceid);
}
/**
* Returns description of upload returns
*