return $this->output->render_from_template('core_course/activity_navigation', $data);
}
- /**
- * Display the selector to advertise or publish a course
- * @param int $courseid
- */
- public function publicationselector($courseid) {
- $text = '';
-
- $advertiseurl = new moodle_url("/course/publish/metadata.php",
- array('sesskey' => sesskey(), 'id' => $courseid, 'advertise' => true));
- $advertisebutton = new single_button($advertiseurl, get_string('advertise', 'hub'));
- $text .= $this->output->render($advertisebutton);
- $text .= html_writer::tag('div', get_string('advertisepublication_help', 'hub'),
- array('class' => 'publishhelp'));
-
- $text .= html_writer::empty_tag('br'); // TODO Delete.
-
- $uploadurl = new moodle_url("/course/publish/metadata.php",
- array('sesskey' => sesskey(), 'id' => $courseid, 'share' => true));
- $uploadbutton = new single_button($uploadurl, get_string('share', 'hub'));
- $text .= $this->output->render($uploadbutton);
- $text .= html_writer::tag('div', get_string('sharepublication_help', 'hub'),
- array('class' => 'publishhelp'));
-
- return $text;
- }
-
- /**
- * Display the listing of hub where a course is registered on
- * @param int $courseid
- * @param array $publications
- */
- public function registeredonhublisting($courseid, $publications) {
- global $CFG;
- $table = new html_table();
- $table->head = array(get_string('type', 'hub'),
- get_string('date'), get_string('status', 'hub'), get_string('operation', 'hub'));
- $table->size = array('20%', '30%', '%20', '%25');
-
- $brtag = html_writer::empty_tag('br');
-
- foreach ($publications as $publication) {
-
- $params = array('id' => $publication->courseid, 'publicationid' => $publication->id);
- $cancelurl = new moodle_url("/course/publish/index.php", $params);
- $cancelbutton = new single_button($cancelurl, get_string('removefromhub', 'hub'));
- $cancelbutton->class = 'centeredbutton';
- $cancelbuttonhtml = $this->output->render($cancelbutton);
-
- if ($publication->enrollable) {
- $params = array('sesskey' => sesskey(), 'id' => $publication->courseid, 'publicationid' => $publication->id);
- $updateurl = new moodle_url("/course/publish/metadata.php", $params);
- $updatebutton = new single_button($updateurl, get_string('update', 'hub'));
- $updatebutton->class = 'centeredbutton';
- $updatebuttonhtml = $this->output->render($updatebutton);
-
- $operations = $updatebuttonhtml . $brtag . $cancelbuttonhtml;
- } else {
- $operations = $cancelbuttonhtml;
- }
-
- // If the publication check time if bigger than May 2010, it has been checked.
- if ($publication->timechecked > 1273127954) {
- if ($publication->status == 0) {
- $status = get_string('statusunpublished', 'hub');
- } else {
- $status = get_string('statuspublished', 'hub');
- if (!empty($publication->link)) {
- $status = html_writer::link($publication->link, $status);
- }
- }
-
- $status .= $brtag . html_writer::tag('a', get_string('updatestatus', 'hub'),
- array('href' => $CFG->wwwroot . '/course/publish/index.php?id='
- . $courseid . "&updatestatusid=" . $publication->id
- . "&sesskey=" . sesskey())) .
- $brtag . get_string('lasttimechecked', 'hub') . ": "
- . format_time(time() - $publication->timechecked);
- } else {
- $status = get_string('neverchecked', 'hub') . $brtag
- . html_writer::tag('a', get_string('updatestatus', 'hub'),
- array('href' => $CFG->wwwroot . '/course/publish/index.php?id='
- . $courseid . "&updatestatusid=" . $publication->id
- . "&sesskey=" . sesskey()));
- }
- // Add button cells.
- $cells = array($publication->enrollable ?
- get_string('advertised', 'hub') : get_string('shared', 'hub'),
- userdate($publication->timepublished,
- get_string('strftimedatetimeshort')), $status, $operations);
- $row = new html_table_row($cells);
- $table->data[] = $row;
- }
-
- $contenthtml = html_writer::table($table);
-
- return $contenthtml;
- }
-
- /**
- * Display unpublishing confirmation page
- * @param stdClass $publication
- * $publication->courseshortname
- * $publication->courseid
- * $publication->hubname
- * $publication->huburl
- * $publication->id
- */
- public function confirmunpublishing($publication) {
- $optionsyes = array('sesskey' => sesskey(), 'id' => $publication->courseid,
- 'hubcourseid' => $publication->hubcourseid,
- 'cancel' => true, 'publicationid' => $publication->id, 'confirm' => true);
- $optionsno = array('sesskey' => sesskey(), 'id' => $publication->courseid);
- $publication->hubname = html_writer::tag('a', 'Moodle.net',
- array('href' => HUB_MOODLEORGHUBURL));
- $formcontinue = new single_button(new moodle_url("/course/publish/index.php",
- $optionsyes), get_string('unpublish', 'hub'), 'post');
- $formcancel = new single_button(new moodle_url("/course/publish/index.php",
- $optionsno), get_string('cancel'), 'get');
- return $this->output->confirm(get_string('unpublishconfirmation', 'hub', $publication),
- $formcontinue, $formcancel);
- }
-
/**
* Display waiting information about backup size during uploading backup process
* @param object $backupfile the backup stored_file
return $html;
}
- /**
- * Display upload successfull message and a button to the publish index page
- * @param int $id the course id
- * @return $html string
- */
- public function sentbackupinfo($id) {
- $html = html_writer::tag('div', get_string('sent', 'hub'),
- array('class' => 'courseuploadtextinfo'));
- $publishindexurl = new moodle_url('/course/publish/index.php',
- array('sesskey' => sesskey(), 'id' => $id,
- 'published' => true));
- $continue = $this->output->render(
- new single_button($publishindexurl, get_string('continue')));
- $html .= html_writer::tag('div', $continue, array('class' => 'sharecoursecontinue'));
- return $html;
- }
-
/**
* Hub information (logo - name - description - link)
* @param object $hubinfo
purgestoresuccess,core_cache
eventrolecapabilitiesupdated,core_role
configuserquota,core_admin
+addscreenshots,core_hub
+advertise,core_hub
+advertised,core_hub
+advertiseon,core_hub
+readvertiseon,core_hub
+advertisepublication_help,core_hub
+courseunpublished,core_hub
+courseurl,core_hub
+courseurl_help,core_hub
+creatorname,core_hub
+creatorname_help,core_hub
+creatornotes,core_hub
+creatornotes_help,core_hub
+contributornames,core_hub
+contributornames_help,core_hub
+deletescreenshots,core_hub
+deletescreenshots_help,core_hub
+description,core_hub
+description_help,core_hub
+detectednotexistingpublication,core_hub
+errorcoursepublish,core_hub
+errorcourseinfo,core_hub
+errorcoursewronglypublished,core_hub
+errorbadimageheightwidth,core_hub
+errorregistration,core_hub
+errorunpublishcourses,core_hub
+existingscreenshotnumber,core_hub
+existingscreenshots,core_hub
+nosearch,core_hub
+notregisteredonhub,core_hub
+publicationinfo,core_hub
+publish,core_hub
+publishcourse,core_hub
+publishcourseon,core_hub
+publishedon,core_hub
+publisheremail,core_hub
+publisheremail_help,core_hub
+publishername,core_hub
+publishername_help,core_hub
+removefromhub,core_hub
+screenshots,core_hub
+screenshots_help,core_hub
+sendingcourse,core_hub
+share,core_hub
+shared,core_hub
+shareon,core_hub
+sharepublication_help,core_hub
+status,core_hub
+statuspublished,core_hub
+statusunpublished,core_hub
+tags,core_hub
+tags_help,core_hub
+unpublish,core_hub
+unpublishalladvertisedcourses,core_hub
+unpublishalluploadedcourses,core_hub
+unpublishconfirmation,core_hub
+unpublishcourse,core_hub
+updatestatus,core_hub
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-
-$string['addscreenshots'] = 'Add screenshots';
-$string['advertise'] = 'Share this course for people to join';
-$string['advertised'] = 'For people to join';
-$string['advertiseon'] = 'Share this course on {$a}';
-$string['readvertiseon'] = 'Update advertising information on {$a}';
-$string['advertisepublication_help'] = 'This course will be listed on Moodle.net as a course that people can enrol in and participate. Email-based self-registration should be enabled on the site and you need to enable self enrolment in this course.';
$string['analyticsactions'] = 'Number of actions taken on generated predictions ({$a})';
$string['analyticsactionsnotuseful'] = 'Number of actions marking a prediction as not useful ({$a})';
$string['analyticsenabledmodels'] = 'Number of enabled prediction models ({$a})';
$string['communityremoved'] = 'That course link has been removed from your list';
$string['completeregistration'] = 'Complete registration with Moodle.net';
$string['confirmregistration'] = 'Confirm registration';
-$string['contributornames'] = 'Other contributors';
-$string['contributornames_help'] = 'You can use this field to list the names of anyone else who contributed to this course.';
$string['coursename'] = 'Name';
$string['coursepublished'] = 'This course has been shared successfully on \'{$a}\'.';
$string['courseshortname'] = 'Shortname';
$string['courseshortname_help'] = 'Enter a short name for your course. It does not need to be unique.';
$string['coursesnumber'] = 'Number of courses ({$a})';
-$string['courseunpublished'] = 'The course {$a->courseshortname} is no longer shared on {$a->hubname}.';
-$string['courseurl'] = 'Course URL';
-$string['courseurl_help'] = 'It is the URL of your course. This URL is displayed as a link in a search result.';
-$string['creatorname'] = 'Creator';
-$string['creatorname_help'] = 'The creator is the course creator.';
-$string['creatornotes'] = 'Creator notes';
-$string['creatornotes_help'] = 'Creator notes are a guide for teachers on how to use the course.';
-$string['deletescreenshots'] = 'Delete these screenshots';
-$string['deletescreenshots_help'] = 'Delete all the currently uploaded screenshots.';
$string['demourl'] = 'Demo URL';
$string['demourl_help'] = 'Enter the demo URL of your course. By default it is the URL of your course. The demo URL is displayed as a link in a search result.';
-$string['description'] = 'Description';
-$string['description_help'] = 'This description text will be showing in the course listing on Moodle.net.';
-$string['detectednotexistingpublication'] = '{$a->hubname} is listing a course that does not exist any more. Alert {$a->hubname} administrator that the publication number {$a->id} should be removed.';
$string['downloadable'] = 'Downloadable';
$string['educationallevel'] = 'Educational level';
$string['educationallevel_help'] = 'Select the most appropriate educational level that the course fits into.';
$string['emailalert'] = 'Email notifications';
$string['emailalert_help'] = 'If this is enabled the hub administrator will send you emails about security issues and other important news.';
$string['enrollable'] = 'Enrollable';
-$string['errorbadimageheightwidth'] = 'The image should have a maximum size of {$a->width} X {$a->height}';
-$string['errorcourseinfo'] = 'An error occurred when retrieving course metadata from {$a}. Please try again to retrieve the course metadata by reloading this page later. Otherwise you can decide to continue the registration process with the following default metadata. ';
-$string['errorcoursepublish'] = 'An error occurred during the course publication ({$a}). Please try again later.';
-$string['errorcoursewronglypublished'] = 'A publication error has been returned by Moodle.net. Please try again later.';
$string['errorotherhubsnotsupported'] = 'This page can no longer be used for registration with sites other than Moodle.net';
-$string['errorregistration'] = 'An error occurred during registration, please try again later. ({$a})';
-$string['errorunpublishcourses'] = 'Due to an unexpected error, the courses could not be deleted from Moodle.net. Try again later (recommended) or contact Moodle.net administrator.';
$string['errorws'] = '{$a}';
$string['errorwstokenreset'] = '{$a}. Registration token on this site has been reset. You can now register your site again.';
-$string['existingscreenshotnumber'] = '{$a} existing screenshots. You will be able to see these screenshots on this page, only once the Moodle.net administrator enables your course.';
$string['errorregistrationupdate'] = 'An error occurred during registration update ({$a})';
-$string['existingscreenshots'] = 'Existing screenshots';
$string['geolocation'] = 'Geolocation';
$string['geolocation_help'] = 'In future we may provide location-based searching. If you want to specify the location for your course use a latitude/longitude value here (eg: -31.947884,115.871285). One way to find this is to use Google Maps.';
$string['imageurl'] = 'Image URL';
$string['nocheckstatusfromunreghub'] = 'The site is not registered on the hub so the status can not be checked.';
$string['nohubselected'] = 'No hub selected';
$string['none'] = 'None';
-$string['nosearch'] = 'Don\'t publish hub or courses';
-$string['notregisteredonhub'] = 'Your administrator needs to register this site with Moodle.net before you can share a course.';
$string['operation'] = 'Actions';
$string['participantnumberaverage'] = 'Average number of participants ({$a})';
$string['policyagreed'] = 'Privacy notice and data processing agreement';
$string['postaladdress_help'] = 'Postal address of this site, or of the entity represented by this site.';
$string['postsnumber'] = 'Number of posts ({$a})';
$string['previousregistrationdeleted'] = 'The previous registration has been deleted from {$a}. You can restart the registration process. Thank you.';
-$string['publicationinfo'] = 'Course publication information';
-$string['publish'] = 'Share';
-$string['publishcourse'] = 'Share {$a}';
-$string['publishcourseon'] = 'Share on {$a}';
-$string['publishedon'] = 'Course sharing';
-$string['publisheremail'] = 'Publisher email';
-$string['publisheremail_help'] = 'The publisher email address allows the hub administrator to alert the publisher about any changes to the status of the published course.';
-$string['publishername'] = 'Publisher';
-$string['publishername_help'] = 'The publisher is the person or organisation that is the official publisher of the course. Unless you are publishing it on behalf of someone else, it will usually be you.';
$string['questionsnumber'] = 'Number of questions ({$a})';
$string['registeredcourses'] = 'Registered courses';
$string['registeredsites'] = 'Registered sites';
$string['registersite'] = 'Register with {$a}';
$string['registrationconfirmed'] = 'Site registration confirmed';
$string['registrationconfirmedon'] = 'Thank you for registering your site. Registration information will be kept up to date by the \'Site registration\' scheduled task.';
-$string['removefromhub'] = 'Remove from Moodle.net';
$string['renewregistration'] = 'Renew registration';
$string['resourcesnumber'] = 'Number of resources ({$a})';
$string['restartregistration'] = 'Restart registration';
$string['roleassignmentsnumber'] = 'Number of role assignments ({$a})';
-$string['screenshots'] = 'Screenshots';
-$string['screenshots_help'] = 'Any screenshots of the course will be displayed in search results.';
$string['search'] = 'Search';
-$string['sendingcourse'] = 'Sending course';
$string['sendingsize'] = 'Please wait the course file is uploading ({$a->total}Mb)...';
$string['sendfollowinginfo'] = 'More information';
$string['sendfollowinginfo_help'] = 'The following information will be sent to contribute to overall statistics only. It will not be made public on any site listing.';
$string['sent'] = '...finished';
-$string['share'] = 'Share this course for people to download';
-$string['shared'] = 'For people to download';
-$string['shareon'] = 'Upload this course to {$a}';
-$string['sharepublication_help'] = 'A backup of this course will be available on Moodle.net for people to restore and use on their own site.';
$string['siteadmin'] = 'Administrator';
$string['siteadmin_help'] = 'The full name of the site administrator.';
$string['sitecommnews'] = 'Updates about Moodle news and features';
$string['skipregistration'] = 'Skip';
$string['subject'] = 'Subject';
$string['subject_help'] = 'Select the main subject area which the course covers.';
-$string['status'] = 'Listing status';
-$string['statuspublished'] = 'Listed';
-$string['statusunpublished'] = 'Not listed';
-$string['tags'] = 'Tags';
-$string['tags_help'] = 'Tags help to further categorise your course and help it to be found. Please use simple, meaningful words and separate them with a comma. Example: math, algebra, geometry';
$string['type'] = 'Shared';
-$string['unpublish'] = 'Stop sharing';
-$string['unpublishalladvertisedcourses'] = 'Remove all courses that were shared on Moodle.net for people to join';
-$string['unpublishalluploadedcourses'] = 'Remove all courses that were shared on Moodle.net for people to download';
-$string['unpublishconfirmation'] = 'Do you really want to remove the course "{$a->courseshortname}" from "{$a->hubname}"';
-$string['unpublishcourse'] = 'Stop sharing {$a}';
$string['unregister'] = 'Unregister';
$string['unregisterfrom'] = 'Unregister from {$a}';
$string['unregistrationerror'] = 'An error occurred when the site tried to unregister from Moodle.net: {$a}';
$string['update'] = 'Update';
$string['updatesite'] = 'Update registration on {$a}';
-$string['updatestatus'] = 'Check it now.';
$string['usedifferentemail'] = 'Use different email';
$string['unregisterexplained'] = 'If the site with URL {$a} is registered on Moodle.net its registration will be removed.';
$string['urlalreadyregistered'] = 'Your site seems to be already registered on Moodle.net, which means something has gone wrong. Please contact the Moodle.net administrator to reset your registration so you can try again.';
$string['usersnumber'] = 'Number of users ({$a})';
$string['wrongtoken'] = 'The registration failed for some unknown reason (network?). Please try again.';
+
+// Deprecated since Moodle 3.8.
+$string['addscreenshots'] = 'Add screenshots';
+$string['advertise'] = 'Share this course for people to join';
+$string['advertised'] = 'For people to join';
+$string['advertiseon'] = 'Share this course on {$a}';
+$string['readvertiseon'] = 'Update advertising information on {$a}';
+$string['advertisepublication_help'] = 'This course will be listed on Moodle.net as a course that people can enrol in and participate. Email-based self-registration should be enabled on the site and you need to enable self enrolment in this course.';
+$string['courseunpublished'] = 'The course {$a->courseshortname} is no longer shared on {$a->hubname}.';
+$string['courseurl'] = 'Course URL';
+$string['courseurl_help'] = 'It is the URL of your course. This URL is displayed as a link in a search result.';
+$string['creatorname'] = 'Creator';
+$string['creatorname_help'] = 'The creator is the course creator.';
+$string['creatornotes'] = 'Creator notes';
+$string['creatornotes_help'] = 'Creator notes are a guide for teachers on how to use the course.';
+$string['contributornames'] = 'Other contributors';
+$string['contributornames_help'] = 'You can use this field to list the names of anyone else who contributed to this course.';
+$string['deletescreenshots'] = 'Delete these screenshots';
+$string['deletescreenshots_help'] = 'Delete all the currently uploaded screenshots.';
+$string['description'] = 'Description';
+$string['description_help'] = 'This description text will be showing in the course listing on Moodle.net.';
+$string['detectednotexistingpublication'] = '{$a->hubname} is listing a course that does not exist any more. Alert {$a->hubname} administrator that the publication number {$a->id} should be removed.';
+$string['errorcoursepublish'] = 'An error occurred during the course publication ({$a}). Please try again later.';
+$string['errorcourseinfo'] = 'An error occurred when retrieving course metadata from {$a}. Please try again to retrieve the course metadata by reloading this page later. Otherwise you can decide to continue the registration process with the following default metadata. ';
+$string['errorcoursewronglypublished'] = 'A publication error has been returned by Moodle.net. Please try again later.';
+$string['errorbadimageheightwidth'] = 'The image should have a maximum size of {$a->width} X {$a->height}';
+$string['errorregistration'] = 'An error occurred during registration, please try again later. ({$a})';
+$string['errorunpublishcourses'] = 'Due to an unexpected error, the courses could not be deleted from Moodle.net. Try again later (recommended) or contact Moodle.net administrator.';
+$string['existingscreenshotnumber'] = '{$a} existing screenshots. You will be able to see these screenshots on this page, only once the Moodle.net administrator enables your course.';
+$string['existingscreenshots'] = 'Existing screenshots';
+$string['nosearch'] = 'Don\'t publish hub or courses';
+$string['notregisteredonhub'] = 'Your administrator needs to register this site with Moodle.net before you can share a course.';
+$string['publicationinfo'] = 'Course publication information';
+$string['publish'] = 'Share';
+$string['publishcourse'] = 'Share {$a}';
+$string['publishcourseon'] = 'Share on {$a}';
+$string['publishedon'] = 'Course sharing';
+$string['publisheremail'] = 'Publisher email';
+$string['publisheremail_help'] = 'The publisher email address allows the hub administrator to alert the publisher about any changes to the status of the published course.';
+$string['publishername'] = 'Publisher';
+$string['publishername_help'] = 'The publisher is the person or organisation that is the official publisher of the course. Unless you are publishing it on behalf of someone else, it will usually be you.';
+$string['removefromhub'] = 'Remove from Moodle.net';
+$string['screenshots'] = 'Screenshots';
+$string['screenshots_help'] = 'Any screenshots of the course will be displayed in search results.';
+$string['sendingcourse'] = 'Sending course';
+$string['share'] = 'Share this course for people to download';
+$string['shared'] = 'For people to download';
+$string['shareon'] = 'Upload this course to {$a}';
+$string['sharepublication_help'] = 'A backup of this course will be available on Moodle.net for people to restore and use on their own site.';
+$string['status'] = 'Listing status';
+$string['statuspublished'] = 'Listed';
+$string['statusunpublished'] = 'Not listed';
+$string['tags'] = 'Tags';
+$string['tags_help'] = 'Tags help to further categorise your course and help it to be found. Please use simple, meaningful words and separate them with a comma. Example: math, algebra, geometry';
+$string['unpublish'] = 'Stop sharing';
+$string['unpublishalladvertisedcourses'] = 'Remove all courses that were shared on Moodle.net for people to join';
+$string['unpublishalluploadedcourses'] = 'Remove all courses that were shared on Moodle.net for people to download';
+$string['unpublishconfirmation'] = 'Do you really want to remove the course "{$a->courseshortname}" from "{$a->hubname}"';
+$string['unpublishcourse'] = 'Stop sharing {$a}';
+$string['updatestatus'] = 'Check it now.';
\ No newline at end of file
$string['comment:delete'] = 'Delete comments';
$string['comment:post'] = 'Post comments';
$string['comment:view'] = 'View comments';
-$string['community:add'] = 'Use the community block to search Moodle.net and find courses';
-$string['community:download'] = 'Download a course from the community block';
$string['competency:competencymanage'] = 'Manage competency frameworks';
$string['competency:competencygrade'] = 'Set competency rating';
$string['competency:competencyview'] = 'View competency frameworks';
/**
* Calls WS function hub_get_courses
*
+ * @deprecated since Moodle 3.8. Moodle.net has been sunsetted making this function useless.
+ *
* Parameter $options may have any of these fields:
* [
* 'ids' => new external_multiple_structure(new external_value(PARAM_INTEGER, 'id of a course in the hub course
* @throws moodle_exception
*/
public static function get_courses($search, $downloadable, $enrollable, $options) {
- static $availableoptions = ['ids', 'sitecourseids', 'coverage', 'licenceshortname', 'subject', 'audience',
- 'educationallevel', 'language', 'orderby', 'givememore', 'allsitecourses'];
-
- if (empty($options)) {
- $options = [];
- } else if (is_object($options)) {
- $options = (array)$options;
- } else if (!is_array($options)) {
- throw new \coding_exception('Parameter $options is invalid');
- }
-
- if ($unknownkeys = array_diff(array_keys($options), $availableoptions)) {
- throw new \coding_exception('Unknown option(s): ' . join(', ', $unknownkeys));
- }
-
- $params = [
- 'search' => $search,
- 'downloadable' => (int)(bool)$downloadable,
- 'enrollable' => (int)(bool)$enrollable,
- 'options' => $options
- ];
- $result = self::call('hub_get_courses', $params, true);
- $courses = $result['courses'];
- $coursetotal = $result['coursetotal'];
-
- foreach ($courses as $idx => $course) {
- $courses[$idx]['screenshotbaseurl'] = null;
- if (!empty($course['screenshots'])) {
- $courses[$idx]['screenshotbaseurl'] = new moodle_url(HUB_MOODLEORGHUBURL . '/local/hub/webservice/download.php',
- array('courseid' => $course['id'],
- 'filetype' => self::HUB_SCREENSHOT_FILE_TYPE));
- }
- $courses[$idx]['commenturl'] = new moodle_url(HUB_MOODLEORGHUBURL,
- array('courseid' => $course['id'], 'mustbelogged' => true));
- }
-
- return [$courses, $coursetotal];
+ debugging("This function has been deprecated as part of the Moodle.net sunsetting process.");
+ return [[], 0];
}
/**
/**
* Unpublish courses
*
+ * @deprecated since Moodle 3.8. Moodle.net has been sunsetted making this function useless.
+ *
* @param int[]|int $courseids
* @throws moodle_exception
*/
public static function unregister_courses($courseids) {
- $courseids = (array)$courseids;
- $params = array('courseids' => $courseids);
- self::call('hub_unregister_courses', $params);
+ debugging("This function has been deprecated as part of the Moodle.net sunsetting process.");
}
/**
* Publish one course
*
+ * @deprecated since Moodle 3.8. Moodle.net has been sunsetted making this function useless.
+ *
* Expected contents of $courseinfo:
* [
* 'sitecourseid' => new external_value(PARAM_INT, 'the id of the course on the publishing site'),
* @throws moodle_exception if communication to moodle.net failed or course could not be published
*/
public static function register_course($courseinfo) {
- $params = array('courses' => array($courseinfo));
- $hubcourseids = self::call('hub_register_courses', $params);
- if (count($hubcourseids) != 1) {
- throw new moodle_exception('errorcoursewronglypublished', 'hub');
- }
- return $hubcourseids[0];
+ debugging("This function has been deprecated as part of the Moodle.net sunsetting process.");
+ throw new moodle_exception('errorcoursewronglypublished', 'hub');
}
/**
* Uploads a screenshot for the published course
*
+ * @deprecated since Moodle 3.8. Moodle.net has been sunsetted making this function useless.
+ *
* @param int $hubcourseid id of the published course on moodle.net, it must be published from this site
* @param \stored_file $file
* @param int $screenshotnumber ordinal number of the screenshot
*/
public static function add_screenshot($hubcourseid, \stored_file $file, $screenshotnumber) {
- $curl = new \curl();
- $params = array();
- $params['filetype'] = self::HUB_SCREENSHOT_FILE_TYPE;
- $params['file'] = $file;
- $params['courseid'] = $hubcourseid;
- $params['filename'] = $file->get_filename();
- $params['screenshotnumber'] = $screenshotnumber;
- $params['token'] = registration::get_token(MUST_EXIST);
- $curl->post(HUB_MOODLEORGHUBURL . "/local/hub/webservice/upload.php", $params);
+ debugging("This function has been deprecated as part of the Moodle.net sunsetting process.");
}
/**
* Downloads course backup
*
+ * @deprecated since Moodle 3.8. Moodle.net has been sunsetted making this function useless.
+ *
* @param int $hubcourseid id of the course on moodle.net
* @param string $path local path (in tempdir) to save the downloaded backup to.
*/
public static function download_course_backup($hubcourseid, $path) {
- $fp = fopen($path, 'w');
-
- $curlurl = new \moodle_url(HUB_MOODLEORGHUBURL . '/local/hub/webservice/download.php',
- ['filetype' => self::HUB_BACKUP_FILE_TYPE, 'courseid' => $hubcourseid]);
-
- // Send an identification token if the site is registered.
- if ($token = registration::get_token()) {
- $curlurl->param('token', $token);
- }
-
- $ch = curl_init($curlurl->out(false));
- curl_setopt($ch, CURLOPT_FILE, $fp);
- curl_exec($ch);
- curl_close($ch);
- fclose($fp);
+ debugging("This function has been deprecated as part of the Moodle.net sunsetting process.");
}
/**
* Uploads a course backup
*
+ * @deprecated since Moodle 3.8. Moodle.net has been sunsetted making this function useless.
+ *
* @param int $hubcourseid id of the published course on moodle.net, it must be published from this site
* @param \stored_file $backupfile
*/
public static function upload_course_backup($hubcourseid, \stored_file $backupfile) {
- $curl = new \curl();
- $params = array();
- $params['filetype'] = self::HUB_BACKUP_FILE_TYPE;
- $params['courseid'] = $hubcourseid;
- $params['file'] = $backupfile;
- $params['token'] = registration::get_token();
- $curl->post(HUB_MOODLEORGHUBURL . '/local/hub/webservice/upload.php', $params);
+ debugging("This function has been deprecated as part of the Moodle.net sunsetting process.");
}
}
\ No newline at end of file
+++ /dev/null
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Class course_publication_form
- *
- * @package core
- * @copyright 2017 Marina Glancy
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace core\hub;
-defined('MOODLE_INTERNAL') || die();
-
-use stdClass;
-use license_manager;
-use moodle_url;
-use core_collator;
-
-global $CFG;
-require_once($CFG->libdir . '/formslib.php');
-require_once($CFG->libdir . '/licenselib.php');
-
-/**
- * The forms used for course publication
- *
- * @package core
- * @copyright 2017 Marina Glancy
- * @author Jerome Mouneyrac <jerome@mouneyrac.com>
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class course_publication_form extends \moodleform {
-
- /**
- * Form definition
- */
- public function definition() {
- global $CFG, $USER, $PAGE;
-
- $strrequired = get_string('required');
- $mform = & $this->_form;
- $course = $this->_customdata['course'];
- if (!empty($this->_customdata['publication'])) {
- // We are editing existing publication.
- $publication = $this->_customdata['publication'];
- $advertise = $publication->enrollable;
- $publishedcourse = publication::get_published_course($publication);
- } else {
- $publication = null;
- $advertise = $this->_customdata['advertise'];
- }
- $share = !$advertise;
-
- if (!empty($publishedcourse)) {
- $hubcourseid = $publishedcourse['id'];
- $defaultfullname = $publishedcourse['fullname'];
- $defaultshortname = $publishedcourse['shortname'];
- $defaultsummary = $publishedcourse['description'];
- $defaultlanguage = $publishedcourse['language'];
- $defaultpublishername = $publishedcourse['publishername'];
- $defaultpublisheremail = $publishedcourse['publisheremail'];
- $defaultcontributornames = $publishedcourse['contributornames'];
- $defaultcoverage = $publishedcourse['coverage'];
- $defaultcreatorname = $publishedcourse['creatorname'];
- $defaultlicenceshortname = $publishedcourse['licenceshortname'];
- $defaultsubject = $publishedcourse['subject'];
- $defaultaudience = $publishedcourse['audience'];
- $defaulteducationallevel = $publishedcourse['educationallevel'];
- $defaultcreatornotes = $publishedcourse['creatornotes'];
- $defaultcreatornotesformat = $publishedcourse['creatornotesformat'];
- $screenshotsnumber = $publishedcourse['screenshots'];
- $screenshotbaseurl = $publishedcourse['screenshotbaseurl'];
- $privacy = $publishedcourse['privacy'];
- if (($screenshotsnumber > 0) and !empty($privacy)) {
- $PAGE->requires->yui_module('moodle-block_community-imagegallery',
- 'M.blocks_community.init_imagegallery',
- array(array('imageids' => array($hubcourseid),
- 'imagenumbers' => array($screenshotsnumber),
- 'huburl' => HUB_MOODLEORGHUBURL)));
- }
- } else {
- $defaultfullname = $course->fullname;
- $defaultshortname = $course->shortname;
- $defaultsummary = clean_param($course->summary, PARAM_TEXT);
- if (empty($course->lang)) {
- $language = get_site()->lang;
- if (empty($language)) {
- $defaultlanguage = current_language();
- } else {
- $defaultlanguage = $language;
- }
- } else {
- $defaultlanguage = $course->lang;
- }
- $defaultpublishername = $USER->firstname . ' ' . $USER->lastname;
- $defaultpublisheremail = $USER->email;
- $defaultcontributornames = '';
- $defaultcoverage = '';
- $defaultcreatorname = $USER->firstname . ' ' . $USER->lastname;
- $defaultlicenceshortname = 'cc';
- $defaultsubject = 'none';
- $defaultaudience = publication::HUB_AUDIENCE_STUDENTS;
- $defaulteducationallevel = publication::HUB_EDULEVEL_TERTIARY;
- $defaultcreatornotes = '';
- $defaultcreatornotesformat = FORMAT_HTML;
- $screenshotsnumber = 0;
- $screenshotbaseurl = null;
- }
-
- // The input parameters.
- $mform->addElement('header', 'moodle', get_string('publicationinfo', 'hub'));
-
- $mform->addElement('text', 'name', get_string('coursename', 'hub'),
- array('class' => 'metadatatext'));
- $mform->addRule('name', $strrequired, 'required', null, 'client');
- $mform->setType('name', PARAM_TEXT);
- $mform->setDefault('name', $defaultfullname);
- $mform->addHelpButton('name', 'name', 'hub');
-
- $mform->addElement('hidden', 'id', $course->id);
- $mform->setType('id', PARAM_INT);
-
- $mform->addElement('hidden', 'publicationid', $publication ? $publication->id : null);
- $mform->setType('publicationid', PARAM_INT);
-
- if ($share) {
- $buttonlabel = get_string('shareon', 'hub', 'Moodle.net');
-
- $mform->addElement('hidden', 'share', $share);
- $mform->setType('share', PARAM_BOOL);
- $mform->addElement('text', 'demourl', get_string('demourl', 'hub'),
- array('class' => 'metadatatext'));
- $mform->setType('demourl', PARAM_URL);
- $mform->setDefault('demourl', new moodle_url("/course/view.php?id=" . $course->id));
- $mform->addHelpButton('demourl', 'demourl', 'hub');
- }
-
- if ($advertise) {
- if (!$publication) {
- $buttonlabel = get_string('advertiseon', 'hub', 'Moodle.net');
- } else {
- $buttonlabel = get_string('readvertiseon', 'hub', 'Moodle.net');
- }
- $mform->addElement('hidden', 'advertise', $advertise);
- $mform->setType('advertise', PARAM_BOOL);
- $mform->addElement('hidden', 'courseurl', $CFG->wwwroot . "/course/view.php?id=" . $course->id);
- $mform->setType('courseurl', PARAM_URL);
- $mform->addElement('static', 'courseurlstring', get_string('courseurl', 'hub'));
- $mform->setDefault('courseurlstring', new moodle_url("/course/view.php?id=" . $course->id));
- $mform->addHelpButton('courseurlstring', 'courseurl', 'hub');
- }
-
- $mform->addElement('text', 'courseshortname', get_string('courseshortname', 'hub'),
- array('class' => 'metadatatext'));
- $mform->setDefault('courseshortname', $defaultshortname);
- $mform->addHelpButton('courseshortname', 'courseshortname', 'hub');
- $mform->setType('courseshortname', PARAM_TEXT);
- $mform->addElement('textarea', 'description', get_string('description', 'hub'), array('rows' => 10,
- 'cols' => 57));
- $mform->addRule('description', $strrequired, 'required', null, 'client');
- $mform->setDefault('description', $defaultsummary);
- $mform->setType('description', PARAM_TEXT);
- $mform->addHelpButton('description', 'description', 'hub');
-
- $languages = get_string_manager()->get_list_of_languages();
- core_collator::asort($languages);
- $mform->addElement('select', 'language', get_string('language'), $languages);
- $mform->setDefault('language', $defaultlanguage);
- $mform->addHelpButton('language', 'language', 'hub');
-
- $mform->addElement('text', 'publishername', get_string('publishername', 'hub'),
- array('class' => 'metadatatext'));
- $mform->setDefault('publishername', $defaultpublishername);
- $mform->addRule('publishername', $strrequired, 'required', null, 'client');
- $mform->addHelpButton('publishername', 'publishername', 'hub');
- $mform->setType('publishername', PARAM_NOTAGS);
-
- $mform->addElement('text', 'publisheremail', get_string('publisheremail', 'hub'),
- array('class' => 'metadatatext'));
- $mform->setDefault('publisheremail', $defaultpublisheremail);
- $mform->addRule('publisheremail', $strrequired, 'required', null, 'client');
- $mform->addHelpButton('publisheremail', 'publisheremail', 'hub');
- $mform->setType('publisheremail', PARAM_EMAIL);
-
- $mform->addElement('text', 'creatorname', get_string('creatorname', 'hub'),
- array('class' => 'metadatatext'));
- $mform->addRule('creatorname', $strrequired, 'required', null, 'client');
- $mform->setType('creatorname', PARAM_NOTAGS);
- $mform->setDefault('creatorname', $defaultcreatorname);
- $mform->addHelpButton('creatorname', 'creatorname', 'hub');
-
- $mform->addElement('text', 'contributornames', get_string('contributornames', 'hub'),
- array('class' => 'metadatatext'));
- $mform->setDefault('contributornames', $defaultcontributornames);
- $mform->addHelpButton('contributornames', 'contributornames', 'hub');
- $mform->setType('contributornames', PARAM_NOTAGS);
-
- $mform->addElement('text', 'coverage', get_string('tags', 'hub'),
- array('class' => 'metadatatext'));
- $mform->setType('coverage', PARAM_TEXT);
- $mform->setDefault('coverage', $defaultcoverage);
- $mform->addHelpButton('coverage', 'tags', 'hub');
-
- $licensemanager = new license_manager();
- $licences = $licensemanager->get_licenses();
- $options = array();
- foreach ($licences as $license) {
- $options[$license->shortname] = get_string($license->shortname, 'license');
- }
- $mform->addElement('select', 'licence', get_string('license'), $options);
- $mform->setDefault('licence', $defaultlicenceshortname);
- unset($options);
- $mform->addHelpButton('licence', 'licence', 'hub');
-
- $options = publication::get_sorted_subjects();
-
- $mform->addElement('searchableselector', 'subject',
- get_string('subject', 'hub'), $options);
- unset($options);
- $mform->addHelpButton('subject', 'subject', 'hub');
- $mform->setDefault('subject', $defaultsubject);
- $mform->addRule('subject', $strrequired, 'required', null, 'client');
-
- $options = publication::audience_options();
- $mform->addElement('select', 'audience', get_string('audience', 'hub'), $options);
- $mform->setDefault('audience', $defaultaudience);
- unset($options);
- $mform->addHelpButton('audience', 'audience', 'hub');
-
- $options = publication::educational_level_options();
- $mform->addElement('select', 'educationallevel', get_string('educationallevel', 'hub'), $options);
- $mform->setDefault('educationallevel', $defaulteducationallevel);
- unset($options);
- $mform->addHelpButton('educationallevel', 'educationallevel', 'hub');
-
- $editoroptions = array('maxfiles' => 0, 'maxbytes' => 0, 'trusttext' => false, 'forcehttps' => false);
- $mform->addElement('editor', 'creatornotes', get_string('creatornotes', 'hub'), '', $editoroptions);
- $mform->addRule('creatornotes', $strrequired, 'required', null, 'client');
- $mform->setType('creatornotes', PARAM_CLEANHTML);
- $mform->addHelpButton('creatornotes', 'creatornotes', 'hub');
-
- if ($advertise) {
- if (!empty($screenshotsnumber)) {
- if (!empty($privacy)) {
- $screenshothtml = \html_writer::empty_tag('img',
- array('src' => $screenshotbaseurl, 'alt' => $defaultfullname));
- $screenshothtml = \html_writer::tag('div', $screenshothtml,
- array('class' => 'coursescreenshot',
- 'id' => 'image-' . $hubcourseid));
- } else {
- $screenshothtml = get_string('existingscreenshotnumber', 'hub', $screenshotsnumber);
- }
- $mform->addElement('static', 'existingscreenshots', get_string('existingscreenshots', 'hub'), $screenshothtml);
- $mform->addHelpButton('existingscreenshots', 'deletescreenshots', 'hub');
- $mform->addElement('checkbox', 'deletescreenshots', '', ' ' . get_string('deletescreenshots', 'hub'));
- }
-
- $mform->addElement('hidden', 'existingscreenshotnumber', $screenshotsnumber);
- $mform->setType('existingscreenshotnumber', PARAM_INT);
- }
-
- $mform->addElement('filemanager', 'screenshots', get_string('addscreenshots', 'hub'), null,
- array('subdirs' => 0,
- 'maxbytes' => 1000000,
- 'maxfiles' => 3
- ));
- $mform->addHelpButton('screenshots', 'screenshots', 'hub');
-
- $this->add_action_buttons(false, $buttonlabel);
-
- // Set default value for creatornotes editor.
- $data = new stdClass();
- $data->creatornotes = array();
- $data->creatornotes['text'] = $defaultcreatornotes;
- $data->creatornotes['format'] = $defaultcreatornotesformat;
- $this->set_data($data);
- }
-
- /**
- * Custom form validation
- *
- * @param array $data
- * @param array $files
- * @return array
- */
- public function validation($data, $files) {
- $errors = parent::validation($data, $files);
-
- if ($this->_form->_submitValues['subject'] == 'none') {
- $errors['subject'] = get_string('mustselectsubject', 'hub');
- }
-
- return $errors;
- }
-}
+++ /dev/null
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Class publication
- *
- * @package core
- * @copyright 2017 Marina Glancy
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace core\hub;
-defined('MOODLE_INTERNAL') || die();
-
-use moodle_exception;
-use moodle_url;
-use context_user;
-use stdClass;
-use html_writer;
-
-/**
- * Methods to work with site registration on moodle.net
- *
- * @package core
- * @copyright 2017 Marina Glancy
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class publication {
-
- /** @var Audience: educators */
- const HUB_AUDIENCE_EDUCATORS = 'educators';
-
- /** @var Audience: students */
- const HUB_AUDIENCE_STUDENTS = 'students';
-
- /** @var Audience: admins */
- const HUB_AUDIENCE_ADMINS = 'admins';
-
- /** @var Educational level: primary */
- const HUB_EDULEVEL_PRIMARY = 'primary';
-
- /** @var Educational level: secondary */
- const HUB_EDULEVEL_SECONDARY = 'secondary';
-
- /** @var Educational level: tertiary */
- const HUB_EDULEVEL_TERTIARY = 'tertiary';
-
- /** @var Educational level: government */
- const HUB_EDULEVEL_GOVERNMENT = 'government';
-
- /** @var Educational level: association */
- const HUB_EDULEVEL_ASSOCIATION = 'association';
-
- /** @var Educational level: corporate */
- const HUB_EDULEVEL_CORPORATE = 'corporate';
-
- /** @var Educational level: other */
- const HUB_EDULEVEL_OTHER = 'other';
-
-
- /**
- * Retrieve all the sorted course subjects
- *
- * @return array $subjects
- */
- public static function get_sorted_subjects() {
- $subjects = get_string_manager()->load_component_strings('edufields', current_language());
-
- // Sort the subjects.
- $return = [];
- asort($subjects);
- foreach ($subjects as $key => $option) {
- $keylength = strlen($key);
- if ($keylength == 12) {
- $return[$key] = $option; // We want only selectable categories.
- }
- }
- return $return;
- }
-
- /**
- * Get all publication for a course
- *
- * @param int $courseid local course id
- * @return array of publication
- */
- public static function get_course_publications($courseid) {
- global $DB;
- $sql = 'SELECT cp.id, cp.status, cp.timechecked, cp.timepublished, rh.hubname,
- rh.huburl, cp.courseid, cp.enrollable, cp.hubcourseid
- FROM {course_published} cp, {registration_hubs} rh
- WHERE cp.huburl = rh.huburl and cp.courseid = :courseid and rh.huburl = :huburl
- ORDER BY cp.enrollable DESC, rh.hubname, cp.timepublished';
- $params = array('courseid' => $courseid, 'huburl' => HUB_MOODLEORGHUBURL);
- $records = $DB->get_records_sql($sql, $params);
-
- // Add links for publications that are listed.
- foreach ($records as $id => $record) {
- if ($record->status) {
- $records[$id]->link = new moodle_url(HUB_MOODLEORGHUBURL, ['courseid' => $record->hubcourseid]);
- }
- }
- return $records;
- }
-
- /**
- * Load publication information from local db
- *
- * @param int $id
- * @param int $courseid if specified publication will be checked that it is in the current course
- * @param int $strictness
- * @return stdClass
- */
- public static function get_publication($id, $courseid = 0, $strictness = IGNORE_MISSING) {
- global $DB;
- if (!$id && $strictness != MUST_EXIST) {
- return false;
- }
- $params = ['id' => $id, 'huburl' => HUB_MOODLEORGHUBURL];
- if ($courseid) {
- $params['courseid'] = $courseid;
- }
- return $DB->get_record('course_published', $params, '*', $strictness);
- }
-
- /**
- * Update a course publication
- * @param stdClass $publication
- */
- protected static function update_publication($publication) {
- global $DB;
- $DB->update_record('course_published', $publication);
- }
-
- /**
- * Check all courses published from this site if they have been approved
- */
- public static function request_status_update() {
- global $DB;
-
- list($sitecourses, $coursetotal) = api::get_courses('', 1, 1, ['allsitecourses' => 1]);
-
- // Update status for all these course.
- foreach ($sitecourses as $sitecourse) {
- // Get the publication from the hub course id.
- $publication = $DB->get_record('course_published', ['hubcourseid' => $sitecourse['id']]);
- if (!empty($publication)) {
- $publication->status = $sitecourse['privacy'];
- $publication->timechecked = time();
- self::update_publication($publication);
- } else {
- $msgparams = new stdClass();
- $msgparams->id = $sitecourse['id'];
- $msgparams->hubname = html_writer::tag('a', 'Moodle.net', array('href' => HUB_MOODLEORGHUBURL));
- \core\notification::add(get_string('detectednotexistingpublication', 'hub', $msgparams)); // TODO action?
- }
- }
-
- }
-
- /**
- * Unpublish a course
- *
- * @param stdClass $publication
- */
- public static function unpublish($publication) {
- global $DB;
- // Unpublish the publication by web service.
- api::unregister_courses($publication->hubcourseid);
-
- // Delete the publication from the database.
- $DB->delete_records('course_published', array('id' => $publication->id));
-
- // Add confirmation message.
- $course = get_course($publication->courseid);
- $context = \context_course::instance($course->id);
- $publication->courseshortname = format_string($course->shortname, true, ['context' => $context]);
- $publication->hubname = 'Moodle.net';
- \core\notification::add(get_string('courseunpublished', 'hub', $publication), \core\output\notification::NOTIFY_SUCCESS);
- }
-
- /**
- * Publish a course
- *
- * @param \stdClass $courseinfo
- * @param \stored_file[] $files
- */
- public static function publish_course($courseinfo, $files) {
- global $DB;
-
- // Register course and get id of the course on moodle.net ($hubcourseid).
- $courseid = $courseinfo->sitecourseid;
- try {
- $hubcourseid = api::register_course($courseinfo);
- } catch (Exception $e) {
- throw new moodle_exception('errorcoursepublish', 'hub',
- new moodle_url('/course/view.php', array('id' => $courseid)), $e->getMessage());
- }
-
- // Insert/update publication record in the local DB.
- $publication = $DB->get_record('course_published', array('hubcourseid' => $hubcourseid, 'huburl' => HUB_MOODLEORGHUBURL));
-
- if ($publication) {
- $DB->update_record('course_published', ['id' => $publication->id, 'timepublished' => time()]);
- } else {
- $publication = new stdClass();
- $publication->huburl = HUB_MOODLEORGHUBURL;
- $publication->courseid = $courseid;
- $publication->hubcourseid = $hubcourseid;
- $publication->enrollable = (int)$courseinfo->enrollable;
- $publication->timepublished = time();
- $publication->id = $DB->insert_record('course_published', $publication);
- }
-
- // Send screenshots.
- if ($files) {
- $screenshotnumber = $courseinfo->screenshots - count($files);
- foreach ($files as $file) {
- $screenshotnumber++;
- api::add_screenshot($hubcourseid, $file, $screenshotnumber);
- }
- }
-
- return $hubcourseid;
- }
-
- /**
- * Delete all publications
- *
- * @param int $advertised search for advertised courses
- * @param int $shared search for shared courses
- * @throws moodle_exception
- */
- public static function delete_all_publications($advertised = true, $shared = true) {
- global $DB;
-
- if (!$advertised && !$shared) {
- // Nothing to do.
- return true;
- }
-
- $params = ['huburl' => HUB_MOODLEORGHUBURL];
- if (!$advertised || !$shared) {
- // Retrieve ONLY advertised or ONLY shared.
- $params['enrollable'] = $advertised ? 1 : 0;
- }
-
- if (!$publications = $DB->get_records('course_published', $params)) {
- // Nothing to unpublish.
- return true;
- }
-
- foreach ($publications as $publication) {
- $hubcourseids[] = $publication->hubcourseid;
- }
-
- api::unregister_courses($hubcourseids);
-
- // Delete the published courses from local db.
- $DB->delete_records('course_published', $params);
- return true;
- }
-
- /**
- * Get an array of all block instances for a given context
- * @param int $contextid a context id
- * @return array of block instances.
- */
- public static function get_block_instances_by_context($contextid) {
- global $DB;
- return $DB->get_records('block_instances', array('parentcontextid' => $contextid), 'blockname');
- }
-
- /**
- * List of available educational levels
- *
- * @param bool $any add option for "Any" (for search forms)
- * @return array
- */
- public static function educational_level_options($any = false) {
- $options = array();
- if ($any) {
- $options['all'] = get_string('any');
- }
- $options[self::HUB_EDULEVEL_PRIMARY] = get_string('edulevelprimary', 'hub');
- $options[self::HUB_EDULEVEL_SECONDARY] = get_string('edulevelsecondary', 'hub');
- $options[self::HUB_EDULEVEL_TERTIARY] = get_string('eduleveltertiary', 'hub');
- $options[self::HUB_EDULEVEL_GOVERNMENT] = get_string('edulevelgovernment', 'hub');
- $options[self::HUB_EDULEVEL_ASSOCIATION] = get_string('edulevelassociation', 'hub');
- $options[self::HUB_EDULEVEL_CORPORATE] = get_string('edulevelcorporate', 'hub');
- $options[self::HUB_EDULEVEL_OTHER] = get_string('edulevelother', 'hub');
- return $options;
- }
-
- /**
- * List of available audience options
- *
- * @param bool $any add option for "Any" (for search forms)
- * @return array
- */
- public static function audience_options($any = false) {
- $options = array();
- if ($any) {
- $options['all'] = get_string('any');
- }
- $options[self::HUB_AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'hub');
- $options[self::HUB_AUDIENCE_STUDENTS] = get_string('audiencestudents', 'hub');
- $options[self::HUB_AUDIENCE_ADMINS] = get_string('audienceadmins', 'hub');
- return $options;
- }
-
- /**
- * Search for courses
- *
- * For the list of fields returned for each course see {@link communication::get_courses}
- *
- * @param string $search search string
- * @param bool $downloadable true - return downloadable courses, false - return enrollable courses
- * @param array|\stdClass $options other options from the list of allowed options:
- * 'ids', 'sitecourseids', 'coverage', 'licenceshortname', 'subject', 'audience',
- * 'educationallevel', 'language', 'orderby', 'givememore', 'allsitecourses'
- * @return array of two elements: [$courses, $coursetotal]
- */
- public static function search($search, $downloadable, $options) {
- try {
- return api::get_courses($search, $downloadable, !$downloadable, $options);
- } catch (moodle_exception $e) {
- \core\notification::add(get_string('errorcourselisting', 'block_community', $e->getMessage()),
- \core\output\notification::NOTIFY_ERROR);
- return [[], 0];
- }
- }
-
- /**
- * Retrieves information about published course
- *
- * For the list of fields returned for the course see {@link communication::get_courses}
- *
- * @param stdClass $publication
- * @return array|null
- */
- public static function get_published_course($publication) {
- try {
- list($courses, $unused) = api::get_courses('', !$publication->enrollable,
- $publication->enrollable, ['ids' => [$publication->hubcourseid], 'allsitecourses' => 1]);
- return reset($courses);
- } catch (\Exception $e) {
- \core\notification::add(get_string('errorcourseinfo', 'hub', $e->getMessage()),
- \core\output\notification::NOTIFY_ERROR);
- }
- return null;
- }
-
- /**
- * Downloads course backup and stores it in the user private files
- *
- * @param int $hubcourseid
- * @param string $coursename
- * @return array
- */
- public static function download_course_backup($hubcourseid, $coursename) {
- global $CFG, $USER;
- require_once($CFG->libdir . "/filelib.php");
-
- $backuptempdir = make_backup_temp_directory('');
- $filename = md5(time() . '-' . $hubcourseid . '-'. $USER->id . '-'. random_string(20));
- $path = $backuptempdir.'/'.$filename.".mbz";
-
- api::download_course_backup($hubcourseid, $path);
-
- $fs = get_file_storage();
- $record = new stdClass();
- $record->contextid = context_user::instance($USER->id)->id;
- $record->component = 'user';
- $record->filearea = 'private';
- $record->itemid = 0;
- $record->filename = urlencode($coursename).'_'.time().".mbz";
- $record->filepath = '/downloaded_backup/';
- if (!$fs->file_exists($record->contextid, $record->component,
- $record->filearea, 0, $record->filepath, $record->filename)) {
- $fs->create_file_from_pathname($record, $path);
- }
-
- return [$record->filepath . $record->filename, $filename];
- }
-
- /**
- * Uploads a course backup
- *
- * @param int $hubcourseid id of the published course on moodle.net, it must be published from this site
- * @param \stored_file $backupfile
- */
- public static function upload_course_backup($hubcourseid, \stored_file $backupfile) {
- api::upload_course_backup($hubcourseid, $backupfile);
- }
-}
\ No newline at end of file
return true;
}
- // Unpublish the courses.
- try {
- publication::delete_all_publications($unpublishalladvertisedcourses, $unpublishalluploadedcourses);
- } catch (moodle_exception $e) {
- $errormessage = $e->getMessage();
- $errormessage .= \html_writer::empty_tag('br') .
- get_string('errorunpublishcourses', 'hub');
-
- \core\notification::add(get_string('unregistrationerror', 'hub', $errormessage),
- \core\output\notification::NOTIFY_ERROR);
- return false;
- }
-
// Course unpublish went ok, unregister the site now.
try {
api::unregister_site();
- I go to "<gradepath_string>" in the course gradebook
* A new admin setting widget 'core_admin\local\settings\filesize' is added.
* Core capabilities 'moodle/community:add' and 'moodle/community:download' have been removed from core as part of Moodle.net sunsetting.
+* As part of Moodle.net sunsetting process the following hub api functions have been deprecated:
+ - get_courses
+ - unregister_courses
+ - register_course
+ - add_screenshot
+ - download_course_backup
+ - upload_course_backup
=== 3.7 ===