MDL-66072 core: Remove course sharing and related capabilities
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -4014,7 +4014,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 {
|
||||
|
||||
@@ -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 <[email protected]>
|
||||
* @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();
|
||||
@@ -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 <[email protected]>
|
||||
* @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);
|
||||
@@ -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 <[email protected]>
|
||||
* @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]));
|
||||
@@ -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 <[email protected]>
|
||||
* @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();
|
||||
@@ -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();
|
||||
@@ -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 <[email protected]>
|
||||
* @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();
|
||||
@@ -3193,7 +3193,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);
|
||||
}
|
||||
@@ -3225,7 +3224,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);
|
||||
|
||||
|
||||
@@ -2334,12 +2334,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);
|
||||
@@ -2351,7 +2350,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);
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -3390,5 +3390,11 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2019052001.04);
|
||||
}
|
||||
|
||||
if ($oldversion < 2019052001.12) {
|
||||
// Remove unused config.
|
||||
unset_config('enablecoursepublishing');
|
||||
upgrade_main_savepoint(true, 2019052001.12);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2019052001.11; // 20190520 = branching date YYYYMMDD - do not modify!
|
||||
$version = 2019052001.12; // 20190520 = branching date YYYYMMDD - do not modify!
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user