Merge branch 'MDL-66072-master-3' of git://github.com/peterRd/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2019-09-05 02:48:00 +02:00
commit 9533156775
25 changed files with 153 additions and 1571 deletions

View File

@ -48,7 +48,4 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$optionalsubsystems->add(new admin_setting_configcheckbox('allowstealth', new lang_string('allowstealthmodules'),
new lang_string('allowstealthmodules_help'), 0, 1, 0));
$optionalsubsystems->add(new admin_setting_configcheckbox('enablecoursepublishing',
new lang_string('enablecoursepublishing', 'hub'), new lang_string('enablecoursepublishing_help', 'hub'), 0));
}

View File

@ -128,15 +128,6 @@ abstract class backup_check {
// Now, if backup mode is hub or import, check userid has permissions for those modes
// other modes will perform common checks only (backupxxxx capabilities in $typecapstocheck)
switch ($mode) {
case backup::MODE_HUB:
if (!has_capability('moodle/backup:backuptargethub', $coursectx, $userid)) {
$a = new stdclass();
$a->userid = $userid;
$a->courseid = $courseid;
$a->capability = 'moodle/backup:backuptargethub';
throw new backup_controller_exception('backup_user_missing_capability', $a);
}
break;
case backup::MODE_IMPORT:
if (!has_capability('moodle/backup:backuptargetimport', $coursectx, $userid)) {
$a = new stdclass();

View File

@ -90,15 +90,6 @@ abstract class restore_check {
// Now, if restore mode is hub or import, check userid has permissions for those modes
// other modes will perform common checks only (restorexxxx capabilities in $typecapstocheck)
switch ($mode) {
case backup::MODE_HUB:
if (!has_capability('moodle/restore:restoretargethub', $coursectx, $userid)) {
$a = new stdclass();
$a->userid = $userid;
$a->courseid = $courseid;
$a->capability = 'moodle/restore:restoretargethub';
throw new restore_controller_exception('restore_user_missing_capability', $a);
}
break;
case backup::MODE_IMPORT:
if (!has_capability('moodle/restore:restoretargetimport', $coursectx, $userid)) {
$a = new stdclass();

View File

@ -4045,7 +4045,6 @@ function course_get_user_administration_options($course, $context) {
$options->outcomes = !empty($CFG->enableoutcomes) && has_capability('moodle/course:update', $context);
$options->badges = !empty($CFG->enablebadges);
$options->import = has_capability('moodle/restore:restoretargetimport', $context);
$options->publish = !empty($CFG->enablecoursepublishing) && has_capability('moodle/course:publish', $context);
$options->reset = has_capability('moodle/course:reset', $context);
$options->roles = has_capability('moodle/role:switchroles', $context);
} else {

View File

@ -1,113 +0,0 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// This file is part of Moodle - http://moodle.org/ //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// //
// 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/>. //
// //
///////////////////////////////////////////////////////////////////////////
/**
* This page display the publication backup form
*
* @package course
* @subpackage publish
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*/
define('NO_OUTPUT_BUFFERING', true);
require_once('../../config.php');
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_plan_builder.class.php');
require_once($CFG->libdir . '/filelib.php');
//retrieve initial page parameters
$id = required_param('id', PARAM_INT);
$hubcourseid = required_param('hubcourseid', PARAM_INT);
//some permissions and parameters checking
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
require_login($course);
$context = context_course::instance($course->id);
if (empty($CFG->enablecoursepublishing) || !has_capability('moodle/course:publish', $context) || !confirm_sesskey()) {
throw new moodle_exception('nopermission');
}
//page settings
$PAGE->set_url('/course/publish/backup.php');
$PAGE->set_pagelayout('incourse');
$PAGE->set_title(get_string('course') . ': ' . $course->fullname);
$PAGE->set_heading($course->fullname);
//BEGIN backup processing
$backupid = optional_param('backup', false, PARAM_ALPHANUM);
if (!($bc = backup_ui::load_controller($backupid))) {
$bc = new backup_controller(backup::TYPE_1COURSE, $id, backup::FORMAT_MOODLE,
backup::INTERACTIVE_YES, backup::MODE_HUB, $USER->id);
}
$backup = new backup_ui($bc,
array('id' => $id, 'hubcourseid' => $hubcourseid, 'huburl' => HUB_MOODLEORGHUBURL, 'hubname' => 'Moodle.net'));
$backup->process();
if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
$backup->execute();
} else {
$backup->save_controller();
}
if ($backup->get_stage() !== backup_ui::STAGE_COMPLETE) {
$renderer = $PAGE->get_renderer('core', 'backup');
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('publishcourseon', 'hub', 'Moodle.net'), 3, 'main');
if ($backup->enforce_changed_dependencies()) {
debugging('Your settings have been altered due to unmet dependencies', DEBUG_DEVELOPER);
}
echo $renderer->progress_bar($backup->get_progress_bar());
echo $backup->display($renderer);
echo $OUTPUT->footer();
die();
}
//$backupfile = $backup->get_stage_results();
$backupfile = $bc->get_results();
$backupfile = $backupfile['backup_destination'];
//END backup processing
//display the sending file page
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('sendingcourse', 'hub'), 3, 'main');
$renderer = $PAGE->get_renderer('core', 'course');
echo $renderer->sendingbackupinfo($backupfile);
if (ob_get_level()) {
ob_flush();
}
flush();
//send backup file to the hub
\core\hub\publication::upload_course_backup($hubcourseid, $backupfile);
//delete the temp backup file from user_tohub aera
$backupfile->delete();
$bc->destroy();
//Output sending success
echo $renderer->sentbackupinfo($id, HUB_MOODLEORGHUBURL, 'Moodle.net');
echo $OUTPUT->footer();

View File

@ -1,36 +0,0 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// This file is part of Moodle - http://moodle.org/ //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// //
// 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/>. //
// //
///////////////////////////////////////////////////////////////////////////
/**
* @package course
* @subpackage publish
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*
* The forms used for course publication
*/
defined('MOODLE_INTERNAL') || die();
debugging('Support for alternative hubs has been removed from Moodle in 3.4. For communication with moodle.net ' .
'see lib/classes/hub/ .', DEBUG_DEVELOPER);

View File

@ -1,30 +0,0 @@
<?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/>.
/*
* @package course
* @subpackage publish
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*
* On this page the user selects where he wants to publish the course
*/
require('../../config.php');
$id = required_param('id', PARAM_INT);
redirect(new moodle_url('/course/publish/index.php', ['id' => $id]));

View File

@ -1,99 +0,0 @@
<?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/>.
/*
* @package course
* @subpackage publish
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*
* The user selects if he wants to publish the course on Moodle.org hub or
* on a specific hub. The site must be registered on a hub to be able to
* publish a course on it.
*/
require('../../config.php');
$courseid = required_param('id', PARAM_INT); // Course id.
$publicationid = optional_param('publicationid', 0, PARAM_INT); // Id of course publication to unpublish.
require_login($courseid);
$shortname = format_string($COURSE->shortname);
$PAGE->set_url('/course/publish/index.php', array('id' => $courseid));
$PAGE->set_pagelayout('incourse');
$PAGE->set_title(get_string('publish', 'core_hub') . ': ' . $COURSE->fullname);
$PAGE->set_heading($COURSE->fullname);
$context = context_course::instance($courseid);
if (empty($CFG->enablecoursepublishing) || !has_capability('moodle/course:publish', $context)) {
throw new moodle_exception('nopermission');
}
// If the site is not registered display an error page.
if (!\core\hub\registration::is_registered()) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('publishcourseon', 'hub', 'Moodle.net'), 3, 'main');
echo $OUTPUT->box(get_string('notregisteredonhub', 'hub'));
if (has_capability('moodle/site:config', context_system::instance())) {
echo $OUTPUT->single_button(new moodle_url('/admin/registration/index.php'), get_string('register', 'admin'));
}
echo $OUTPUT->footer();
die();
}
// When hub listing status is requested update statuses of all published courses.
$updatestatusid = optional_param('updatestatusid', false, PARAM_INT);
if (!empty($updatestatusid) && confirm_sesskey()) {
if (core\hub\publication::get_publication($updatestatusid, $courseid)) {
core\hub\publication::request_status_update();
redirect($PAGE->url);
}
}
$renderer = $PAGE->get_renderer('core', 'course');
// Unpublish course.
if ($publication = \core\hub\publication::get_publication($publicationid, $courseid)) {
$confirm = optional_param('confirm', 0, PARAM_BOOL);
if ($confirm && confirm_sesskey()) {
\core\hub\publication::unpublish($publication);
} else {
// Display confirmation page for unpublishing.
$publication = \core\hub\publication::get_publication($publicationid, $courseid, MUST_EXIST);
$publication->courseshortname = format_string($COURSE->shortname);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('unpublishcourse', 'hub', $shortname), 3, 'main');
echo $renderer->confirmunpublishing($publication);
echo $OUTPUT->footer();
die();
}
}
// List current publications and "Publish" buttons.
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('publishcourse', 'hub', $shortname), 3, 'main');
echo $renderer->publicationselector($courseid);
$publications = \core\hub\publication::get_course_publications($courseid);
if (!empty($publications)) {
echo $OUTPUT->heading(get_string('publishedon', 'hub'), 3, 'main');
echo $renderer->registeredonhublisting($courseid, $publications);
}
echo $OUTPUT->footer();

View File

@ -1,17 +0,0 @@
<?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/>.
defined('MOODLE_INTERNAL') || die();

View File

@ -1,192 +0,0 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// This file is part of Moodle - http://moodle.org/ //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// //
// 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/>. //
// //
///////////////////////////////////////////////////////////////////////////
/*
* @package course
* @subpackage publish
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*
* This page display the publication metadata form
*/
require_once('../../config.php');
require_once($CFG->libdir . '/filelib.php');
//check user access capability to this page
$id = required_param('id', PARAM_INT);
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
require_login($course);
//page settings
$PAGE->set_url('/course/publish/metadata.php', array('id' => $course->id));
$PAGE->set_pagelayout('incourse');
$PAGE->set_title(get_string('course') . ': ' . $course->fullname);
$PAGE->set_heading($course->fullname);
$context = context_course::instance($course->id);
if (empty($CFG->enablecoursepublishing) || !has_capability('moodle/course:publish', $context)) {
throw new moodle_exception('nopermission');
}
// Retrieve hub name and hub url.
require_sesskey();
// Set the publication form.
$advertise = optional_param('advertise', false, PARAM_BOOL);
$publicationid = optional_param('publicationid', false, PARAM_INT);
$formparams = array('course' => $course, 'advertise' => $advertise);
if ($publicationid) {
$publication = \core\hub\publication::get_publication($publicationid, $course->id, MUST_EXIST);
$formparams['publication'] = $publication;
$advertise = $formparams['advertise'] = $publication->enrollable;
}
$share = !$advertise;
$coursepublicationform = new \core\hub\course_publication_form('', $formparams);
$fromform = $coursepublicationform->get_data();
if (!empty($fromform)) {
// Retrieve the course information.
$courseinfo = new stdClass();
$courseinfo->fullname = $fromform->name;
$courseinfo->shortname = $fromform->courseshortname;
$courseinfo->description = $fromform->description;
$courseinfo->language = $fromform->language;
$courseinfo->publishername = $fromform->publishername;
$courseinfo->publisheremail = $fromform->publisheremail;
$courseinfo->contributornames = $fromform->contributornames;
$courseinfo->coverage = $fromform->coverage;
$courseinfo->creatorname = $fromform->creatorname;
$courseinfo->licenceshortname = $fromform->licence;
$courseinfo->subject = $fromform->subject;
$courseinfo->audience = $fromform->audience;
$courseinfo->educationallevel = $fromform->educationallevel;
$creatornotes = $fromform->creatornotes;
$courseinfo->creatornotes = $creatornotes['text'];
$courseinfo->creatornotesformat = $creatornotes['format'];
$courseinfo->sitecourseid = $id;
if (!empty($fromform->deletescreenshots)) {
$courseinfo->deletescreenshots = $fromform->deletescreenshots;
}
if ($share) {
$courseinfo->demourl = $fromform->demourl;
$courseinfo->enrollable = false;
} else {
$courseinfo->courseurl = $fromform->courseurl;
$courseinfo->enrollable = true;
}
// Retrieve the outcomes of this course.
require_once($CFG->libdir . '/grade/grade_outcome.php');
$outcomes = grade_outcome::fetch_all_available($id);
if (!empty($outcomes)) {
foreach ($outcomes as $outcome) {
$sentoutcome = new stdClass();
$sentoutcome->fullname = $outcome->fullname;
$courseinfo->outcomes[] = $sentoutcome;
}
}
// Retrieve the content information from the course.
$coursecontext = context_course::instance($course->id);
$courseblocks = \core\hub\publication::get_block_instances_by_context($coursecontext->id);
if (!empty($courseblocks)) {
$blockname = '';
foreach ($courseblocks as $courseblock) {
if ($courseblock->blockname != $blockname) {
if (!empty($blockname)) {
$courseinfo->contents[] = $content;
}
$blockname = $courseblock->blockname;
$content = new stdClass();
$content->moduletype = 'block';
$content->modulename = $courseblock->blockname;
$content->contentcount = 1;
} else {
$content->contentcount = $content->contentcount + 1;
}
}
$courseinfo->contents[] = $content;
}
$activities = get_fast_modinfo($course, $USER->id);
foreach ($activities->instances as $activityname => $activitydetails) {
$content = new stdClass();
$content->moduletype = 'activity';
$content->modulename = $activityname;
$content->contentcount = count($activities->instances[$activityname]);
$courseinfo->contents[] = $content;
}
// Save into screenshots field the references to the screenshot content hash
// (it will be like a unique id from the hub perspective).
if (!empty($fromform->deletescreenshots) or $share) {
$courseinfo->screenshots = 0;
} else {
$courseinfo->screenshots = $fromform->existingscreenshotnumber;
}
$files = [];
if (!empty($fromform->screenshots)) {
$fs = get_file_storage();
$files = $fs->get_area_files(context_user::instance($USER->id)->id, 'user', 'draft', $fromform->screenshots,
'filepath, filename', false);
$files = array_filter($files, function(stored_file $file) {
return $file->is_valid_image();
});
$courseinfo->screenshots += count($files);
}
// PUBLISH ACTION.
$hubcourseid = \core\hub\publication::publish_course($courseinfo, $files);
// Redirect to the backup process page.
if ($share) {
$params = array('sesskey' => sesskey(), 'id' => $id, 'hubcourseid' => $hubcourseid);
$backupprocessurl = new moodle_url("/course/publish/backup.php", $params);
redirect($backupprocessurl);
} else {
// Redirect to the index publis page.
redirect(new moodle_url('/course/publish/index.php', ['id' => $id]),
get_string('coursepublished', 'hub', 'Moodle.net'), null, \core\output\notification::NOTIFY_SUCCESS);
}
}
// OUTPUT SECTION.
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('publishcourseon', 'hub', 'Moodle.net'), 3, 'main');
// Display hub information (logo, name, description).
$renderer = $PAGE->get_renderer('core', 'course');
if ($hubinfo = \core\hub\registration::get_moodlenet_info()) {
echo $renderer->hubinfo($hubinfo);
}
// Display metadata form.
$coursepublicationform->display();
echo $OUTPUT->footer();

View File

@ -2106,128 +2106,6 @@ class core_course_renderer extends plugin_renderer_base {
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
@ -2241,23 +2119,6 @@ class core_course_renderer extends plugin_renderer_base {
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

View File

@ -3307,7 +3307,6 @@ class core_course_courselib_testcase extends advanced_testcase {
$this->assertFalse($adminoptions->outcomes);
$this->assertTrue($adminoptions->badges);
$this->assertTrue($adminoptions->import);
$this->assertFalse($adminoptions->publish);
$this->assertTrue($adminoptions->reset);
$this->assertTrue($adminoptions->roles);
}
@ -3339,7 +3338,6 @@ class core_course_courselib_testcase extends advanced_testcase {
$this->assertFalse($adminoptions->outcomes);
$this->assertTrue($adminoptions->badges);
$this->assertFalse($adminoptions->import);
$this->assertFalse($adminoptions->publish);
$this->assertFalse($adminoptions->reset);
$this->assertFalse($adminoptions->roles);

View File

@ -2296,12 +2296,11 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
$this->assertFalse($adminoptions->outcomes);
$this->assertFalse($adminoptions->badges);
$this->assertFalse($adminoptions->import);
$this->assertFalse($adminoptions->publish);
$this->assertFalse($adminoptions->reset);
$this->assertFalse($adminoptions->roles);
$this->assertFalse($adminoptions->editcompletion);
} else {
$this->assertCount(15, $course['options']);
$this->assertCount(14, $course['options']);
$this->assertFalse($adminoptions->update);
$this->assertFalse($adminoptions->filters);
$this->assertFalse($adminoptions->reports);
@ -2313,7 +2312,6 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
$this->assertFalse($adminoptions->outcomes);
$this->assertTrue($adminoptions->badges);
$this->assertFalse($adminoptions->import);
$this->assertFalse($adminoptions->publish);
$this->assertFalse($adminoptions->reset);
$this->assertFalse($adminoptions->roles);
$this->assertFalse($adminoptions->editcompletion);

View File

@ -48,3 +48,61 @@ purgedefinitionsuccess,core_cache
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

View File

@ -22,13 +22,6 @@
* @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})';
@ -42,27 +35,13 @@ $string['badgesnumber'] = 'Number of badges ({$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.';
@ -75,21 +54,11 @@ $string['edulevelsecondary'] = 'Secondary';
$string['eduleveltertiary'] = 'Tertiary';
$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['enablecoursepublishing'] = "Course sharing on Moodle.net";
$string['enablecoursepublishing_help'] = "Moodle.net is our community site for sharing courses and content with other Moodle users worldwide. A course may be shared for others to enrol in (requires email-based self-registration on the site and self enrolment in the course) or as a backup file for others to download.";
$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';
@ -114,8 +83,6 @@ $string['no'] = 'No';
$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';
@ -124,15 +91,6 @@ $string['postaladdress'] = 'Postal address';
$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';
@ -142,23 +100,15 @@ $string['registeredactiveuserdevices'] = 'Number of active users with registered
$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'] = 'Moodle newsletter';
@ -199,25 +149,74 @@ $string['siteversion_help'] = 'The Moodle version of this site.';
$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.';

View File

@ -69,7 +69,6 @@ $string['backup:backupcourse'] = 'Backup courses';
$string['backup:backupsection'] = 'Backup sections';
$string['backup:configure'] = 'Configure backup options';
$string['backup:downloadfile'] = 'Download files from backup areas';
$string['backup:backuptargethub'] = 'Backup for publishing on Moodle.net';
$string['backup:backuptargetimport'] = 'Backup for import';
$string['backup:userinfo'] = 'Backup user data';
$string['badges:awardbadge'] = 'Award badge to a user';
@ -111,8 +110,6 @@ $string['cohort:manage'] = 'Create, delete and move cohorts';
$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';
@ -181,7 +178,6 @@ $string['course:managescales'] = 'Manage scales';
$string['course:markcomplete'] = 'Mark users as complete in course completion';
$string['course:movesections'] = 'Move sections';
$string['course:overridecompletion'] = 'Override activity completion status';
$string['course:publish'] = 'Publish a course';
$string['course:renameroles'] = 'Rename roles';
$string['course:request'] = 'Request new courses';
$string['course:reset'] = 'Reset course';
@ -363,7 +359,6 @@ $string['restore:createuser'] = 'Create users on restore';
$string['restore:restoreactivity'] = 'Restore activities';
$string['restore:restoresection'] = 'Restore sections';
$string['restore:restorecourse'] = 'Restore courses';
$string['restore:restoretargethub'] = 'Restore courses downloaded from Moodle.net';
$string['restore:restoretargetimport'] = 'Restore from files targeted as import';
$string['restore:rolldates'] = 'Allowed to roll activity configuration dates on restore';
$string['restore:uploadfile'] = 'Upload files to backup areas';

View File

@ -167,6 +167,8 @@ class api {
/**
* 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
@ -255,43 +257,8 @@ class api {
* @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];
}
/**
@ -307,18 +274,20 @@ class api {
/**
* 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'),
@ -360,70 +329,44 @@ class api {
* @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.");
}
}

View File

@ -1,308 +0,0 @@
<?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;
}
}

View File

@ -1,409 +0,0 @@
<?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);
}
}

View File

@ -418,19 +418,6 @@ class registration {
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();

View File

@ -181,20 +181,6 @@ $capabilities = array(
'clonepermissionsfrom' => 'moodle/backup:backupcourse'
),
'moodle/backup:backuptargethub' => array(
'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/backup:backupcourse'
),
'moodle/backup:backuptargetimport' => array(
'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
@ -311,20 +297,6 @@ $capabilities = array(
),
),
'moodle/restore:restoretargethub' => array(
'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/restore:restorecourse'
),
'moodle/restore:restoretargetimport' => array(
'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
@ -1987,15 +1959,6 @@ $capabilities = array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
'moodle/course:publish' => array(
'captype' => 'write',
'riskbitmask' => RISK_SPAM | RISK_PERSONAL,
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'manager' => CAP_ALLOW
)
),
'moodle/course:markcomplete' => array(
'captype' => 'write',

View File

@ -3513,5 +3513,11 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2019083000.01);
}
if ($oldversion < 2019083000.02) {
// Remove unused config.
unset_config('enablecoursepublishing');
upgrade_main_savepoint(true, 2019083000.02);
}
return true;
}

View File

@ -4530,13 +4530,6 @@ class settings_navigation extends navigation_node {
$coursenode->add(get_string('import'), $url, self::TYPE_SETTING, null, 'import', new pix_icon('i/import', ''));
}
// Publish course on a hub
if ($adminoptions->publish) {
$url = new moodle_url('/course/publish/index.php', array('id'=>$course->id));
$coursenode->add(get_string('publish', 'core_hub'), $url, self::TYPE_SETTING, null, 'publish',
new pix_icon('i/publish', ''));
}
// Reset this course
if ($adminoptions->reset) {
$url = new moodle_url('/course/reset.php', array('id'=>$course->id));

View File

@ -54,6 +54,13 @@ validation against and defaults to null (so, no user needed) if not provided.
- 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 ===

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2019083000.01; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2019083000.02; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.