diff --git a/backup/util/checks/backup_check.class.php b/backup/util/checks/backup_check.class.php index 164da0b3856..7cd4c14af54 100644 --- a/backup/util/checks/backup_check.class.php +++ b/backup/util/checks/backup_check.class.php @@ -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(); diff --git a/backup/util/checks/restore_check.class.php b/backup/util/checks/restore_check.class.php index ee2b6cdbc98..35fe2d9bf9b 100644 --- a/backup/util/checks/restore_check.class.php +++ b/backup/util/checks/restore_check.class.php @@ -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(); diff --git a/course/lib.php b/course/lib.php index aa67ccb0083..cd74de3c046 100644 --- a/course/lib.php +++ b/course/lib.php @@ -4001,7 +4001,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 = has_capability('moodle/course:publish', $context); $options->reset = has_capability('moodle/course:reset', $context); $options->roles = has_capability('moodle/role:switchroles', $context); } else { diff --git a/course/publish/backup.php b/course/publish/backup.php deleted file mode 100644 index c50951fa1ea..00000000000 --- a/course/publish/backup.php +++ /dev/null @@ -1,112 +0,0 @@ -. // -// // -/////////////////////////////////////////////////////////////////////////// - -/** - * This page display the publication backup form - * - * @package course - * @subpackage publish - * @author Jerome Mouneyrac - * @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); -if (!has_capability('moodle/course:publish', context_course::instance($id)) - or !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(); diff --git a/course/publish/forms.php b/course/publish/forms.php deleted file mode 100644 index 288475e0aae..00000000000 --- a/course/publish/forms.php +++ /dev/null @@ -1,36 +0,0 @@ -. // -// // -/////////////////////////////////////////////////////////////////////////// - -/** - * @package course - * @subpackage publish - * @author Jerome Mouneyrac - * @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); diff --git a/course/publish/hubselector.php b/course/publish/hubselector.php deleted file mode 100644 index e731d4dceae..00000000000 --- a/course/publish/hubselector.php +++ /dev/null @@ -1,30 +0,0 @@ -. - -/* - * @package course - * @subpackage publish - * @author Jerome Mouneyrac - * @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])); \ No newline at end of file diff --git a/course/publish/index.php b/course/publish/index.php deleted file mode 100644 index 1ce7fee9ceb..00000000000 --- a/course/publish/index.php +++ /dev/null @@ -1,96 +0,0 @@ -. - -/* - * @package course - * @subpackage publish - * @author Jerome Mouneyrac - * @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); - -require_capability('moodle/course:publish', context_course::instance($courseid)); - -// 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(); diff --git a/course/publish/lib.php b/course/publish/lib.php deleted file mode 100644 index 72330f6fe23..00000000000 --- a/course/publish/lib.php +++ /dev/null @@ -1,17 +0,0 @@ -. - -defined('MOODLE_INTERNAL') || die(); diff --git a/course/publish/metadata.php b/course/publish/metadata.php deleted file mode 100644 index 21ffb348803..00000000000 --- a/course/publish/metadata.php +++ /dev/null @@ -1,189 +0,0 @@ -. // -// // -/////////////////////////////////////////////////////////////////////////// - -/* - * @package course - * @subpackage publish - * @author Jerome Mouneyrac - * @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); - -require_capability('moodle/course:publish', context_course::instance($id)); - -// 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(); diff --git a/course/renderer.php b/course/renderer.php index aeb96e1c5e5..d476a51fe60 100644 --- a/course/renderer.php +++ b/course/renderer.php @@ -2082,128 +2082,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 @@ -2217,23 +2095,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 diff --git a/course/tests/courselib_test.php b/course/tests/courselib_test.php index 1e9cddc3a06..5e70ddff4b8 100644 --- a/course/tests/courselib_test.php +++ b/course/tests/courselib_test.php @@ -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->assertTrue($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); diff --git a/course/tests/externallib_test.php b/course/tests/externallib_test.php index 39c187f46eb..dab49de1c51 100644 --- a/course/tests/externallib_test.php +++ b/course/tests/externallib_test.php @@ -2141,12 +2141,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); @@ -2158,7 +2157,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); diff --git a/lib/classes/hub/course_publication_form.php b/lib/classes/hub/course_publication_form.php deleted file mode 100644 index 498f087049a..00000000000 --- a/lib/classes/hub/course_publication_form.php +++ /dev/null @@ -1,308 +0,0 @@ -. - -/** - * 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 - * @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; - } -} diff --git a/lib/classes/hub/publication.php b/lib/classes/hub/publication.php deleted file mode 100644 index f0f48d946ba..00000000000 --- a/lib/classes/hub/publication.php +++ /dev/null @@ -1,409 +0,0 @@ -. - -/** - * Class publication - * - * @package core - * @copyright 2017 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace core\hub; -defined('MOODLE_INTERNAL') || die(); - -use moodle_exception; -use moodle_url; -use context_user; -use stdClass; -use html_writer; - -/** - * Methods to work with site registration on moodle.net - * - * @package core - * @copyright 2017 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class publication { - - /** @var Audience: educators */ - const HUB_AUDIENCE_EDUCATORS = 'educators'; - - /** @var Audience: students */ - const HUB_AUDIENCE_STUDENTS = 'students'; - - /** @var Audience: admins */ - const HUB_AUDIENCE_ADMINS = 'admins'; - - /** @var Educational level: primary */ - const HUB_EDULEVEL_PRIMARY = 'primary'; - - /** @var Educational level: secondary */ - const HUB_EDULEVEL_SECONDARY = 'secondary'; - - /** @var Educational level: tertiary */ - const HUB_EDULEVEL_TERTIARY = 'tertiary'; - - /** @var Educational level: government */ - const HUB_EDULEVEL_GOVERNMENT = 'government'; - - /** @var Educational level: association */ - const HUB_EDULEVEL_ASSOCIATION = 'association'; - - /** @var Educational level: corporate */ - const HUB_EDULEVEL_CORPORATE = 'corporate'; - - /** @var Educational level: other */ - const HUB_EDULEVEL_OTHER = 'other'; - - - /** - * Retrieve all the sorted course subjects - * - * @return array $subjects - */ - public static function get_sorted_subjects() { - $subjects = get_string_manager()->load_component_strings('edufields', current_language()); - - // Sort the subjects. - $return = []; - asort($subjects); - foreach ($subjects as $key => $option) { - $keylength = strlen($key); - if ($keylength == 12) { - $return[$key] = $option; // We want only selectable categories. - } - } - return $return; - } - - /** - * Get all publication for a course - * - * @param int $courseid local course id - * @return array of publication - */ - public static function get_course_publications($courseid) { - global $DB; - $sql = 'SELECT cp.id, cp.status, cp.timechecked, cp.timepublished, rh.hubname, - rh.huburl, cp.courseid, cp.enrollable, cp.hubcourseid - FROM {course_published} cp, {registration_hubs} rh - WHERE cp.huburl = rh.huburl and cp.courseid = :courseid and rh.huburl = :huburl - ORDER BY cp.enrollable DESC, rh.hubname, cp.timepublished'; - $params = array('courseid' => $courseid, 'huburl' => HUB_MOODLEORGHUBURL); - $records = $DB->get_records_sql($sql, $params); - - // Add links for publications that are listed. - foreach ($records as $id => $record) { - if ($record->status) { - $records[$id]->link = new moodle_url(HUB_MOODLEORGHUBURL, ['courseid' => $record->hubcourseid]); - } - } - return $records; - } - - /** - * Load publication information from local db - * - * @param int $id - * @param int $courseid if specified publication will be checked that it is in the current course - * @param int $strictness - * @return stdClass - */ - public static function get_publication($id, $courseid = 0, $strictness = IGNORE_MISSING) { - global $DB; - if (!$id && $strictness != MUST_EXIST) { - return false; - } - $params = ['id' => $id, 'huburl' => HUB_MOODLEORGHUBURL]; - if ($courseid) { - $params['courseid'] = $courseid; - } - return $DB->get_record('course_published', $params, '*', $strictness); - } - - /** - * Update a course publication - * @param stdClass $publication - */ - protected static function update_publication($publication) { - global $DB; - $DB->update_record('course_published', $publication); - } - - /** - * Check all courses published from this site if they have been approved - */ - public static function request_status_update() { - global $DB; - - list($sitecourses, $coursetotal) = api::get_courses('', 1, 1, ['allsitecourses' => 1]); - - // Update status for all these course. - foreach ($sitecourses as $sitecourse) { - // Get the publication from the hub course id. - $publication = $DB->get_record('course_published', ['hubcourseid' => $sitecourse['id']]); - if (!empty($publication)) { - $publication->status = $sitecourse['privacy']; - $publication->timechecked = time(); - self::update_publication($publication); - } else { - $msgparams = new stdClass(); - $msgparams->id = $sitecourse['id']; - $msgparams->hubname = html_writer::tag('a', 'Moodle.net', array('href' => HUB_MOODLEORGHUBURL)); - \core\notification::add(get_string('detectednotexistingpublication', 'hub', $msgparams)); // TODO action? - } - } - - } - - /** - * Unpublish a course - * - * @param stdClass $publication - */ - public static function unpublish($publication) { - global $DB; - // Unpublish the publication by web service. - api::unregister_courses($publication->hubcourseid); - - // Delete the publication from the database. - $DB->delete_records('course_published', array('id' => $publication->id)); - - // Add confirmation message. - $course = get_course($publication->courseid); - $context = \context_course::instance($course->id); - $publication->courseshortname = format_string($course->shortname, true, ['context' => $context]); - $publication->hubname = 'Moodle.net'; - \core\notification::add(get_string('courseunpublished', 'hub', $publication), \core\output\notification::NOTIFY_SUCCESS); - } - - /** - * Publish a course - * - * @param \stdClass $courseinfo - * @param \stored_file[] $files - */ - public static function publish_course($courseinfo, $files) { - global $DB; - - // Register course and get id of the course on moodle.net ($hubcourseid). - $courseid = $courseinfo->sitecourseid; - try { - $hubcourseid = api::register_course($courseinfo); - } catch (Exception $e) { - throw new moodle_exception('errorcoursepublish', 'hub', - new moodle_url('/course/view.php', array('id' => $courseid)), $e->getMessage()); - } - - // Insert/update publication record in the local DB. - $publication = $DB->get_record('course_published', array('hubcourseid' => $hubcourseid, 'huburl' => HUB_MOODLEORGHUBURL)); - - if ($publication) { - $DB->update_record('course_published', ['id' => $publication->id, 'timepublished' => time()]); - } else { - $publication = new stdClass(); - $publication->huburl = HUB_MOODLEORGHUBURL; - $publication->courseid = $courseid; - $publication->hubcourseid = $hubcourseid; - $publication->enrollable = (int)$courseinfo->enrollable; - $publication->timepublished = time(); - $publication->id = $DB->insert_record('course_published', $publication); - } - - // Send screenshots. - if ($files) { - $screenshotnumber = $courseinfo->screenshots - count($files); - foreach ($files as $file) { - $screenshotnumber++; - api::add_screenshot($hubcourseid, $file, $screenshotnumber); - } - } - - return $hubcourseid; - } - - /** - * Delete all publications - * - * @param int $advertised search for advertised courses - * @param int $shared search for shared courses - * @throws moodle_exception - */ - public static function delete_all_publications($advertised = true, $shared = true) { - global $DB; - - if (!$advertised && !$shared) { - // Nothing to do. - return true; - } - - $params = ['huburl' => HUB_MOODLEORGHUBURL]; - if (!$advertised || !$shared) { - // Retrieve ONLY advertised or ONLY shared. - $params['enrollable'] = $advertised ? 1 : 0; - } - - if (!$publications = $DB->get_records('course_published', $params)) { - // Nothing to unpublish. - return true; - } - - foreach ($publications as $publication) { - $hubcourseids[] = $publication->hubcourseid; - } - - api::unregister_courses($hubcourseids); - - // Delete the published courses from local db. - $DB->delete_records('course_published', $params); - return true; - } - - /** - * Get an array of all block instances for a given context - * @param int $contextid a context id - * @return array of block instances. - */ - public static function get_block_instances_by_context($contextid) { - global $DB; - return $DB->get_records('block_instances', array('parentcontextid' => $contextid), 'blockname'); - } - - /** - * List of available educational levels - * - * @param bool $any add option for "Any" (for search forms) - * @return array - */ - public static function educational_level_options($any = false) { - $options = array(); - if ($any) { - $options['all'] = get_string('any'); - } - $options[self::HUB_EDULEVEL_PRIMARY] = get_string('edulevelprimary', 'hub'); - $options[self::HUB_EDULEVEL_SECONDARY] = get_string('edulevelsecondary', 'hub'); - $options[self::HUB_EDULEVEL_TERTIARY] = get_string('eduleveltertiary', 'hub'); - $options[self::HUB_EDULEVEL_GOVERNMENT] = get_string('edulevelgovernment', 'hub'); - $options[self::HUB_EDULEVEL_ASSOCIATION] = get_string('edulevelassociation', 'hub'); - $options[self::HUB_EDULEVEL_CORPORATE] = get_string('edulevelcorporate', 'hub'); - $options[self::HUB_EDULEVEL_OTHER] = get_string('edulevelother', 'hub'); - return $options; - } - - /** - * List of available audience options - * - * @param bool $any add option for "Any" (for search forms) - * @return array - */ - public static function audience_options($any = false) { - $options = array(); - if ($any) { - $options['all'] = get_string('any'); - } - $options[self::HUB_AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'hub'); - $options[self::HUB_AUDIENCE_STUDENTS] = get_string('audiencestudents', 'hub'); - $options[self::HUB_AUDIENCE_ADMINS] = get_string('audienceadmins', 'hub'); - return $options; - } - - /** - * Search for courses - * - * For the list of fields returned for each course see {@link communication::get_courses} - * - * @param string $search search string - * @param bool $downloadable true - return downloadable courses, false - return enrollable courses - * @param array|\stdClass $options other options from the list of allowed options: - * 'ids', 'sitecourseids', 'coverage', 'licenceshortname', 'subject', 'audience', - * 'educationallevel', 'language', 'orderby', 'givememore', 'allsitecourses' - * @return array of two elements: [$courses, $coursetotal] - */ - public static function search($search, $downloadable, $options) { - try { - return api::get_courses($search, $downloadable, !$downloadable, $options); - } catch (moodle_exception $e) { - \core\notification::add(get_string('errorcourselisting', 'block_community', $e->getMessage()), - \core\output\notification::NOTIFY_ERROR); - return [[], 0]; - } - } - - /** - * Retrieves information about published course - * - * For the list of fields returned for the course see {@link communication::get_courses} - * - * @param stdClass $publication - * @return array|null - */ - public static function get_published_course($publication) { - try { - list($courses, $unused) = api::get_courses('', !$publication->enrollable, - $publication->enrollable, ['ids' => [$publication->hubcourseid], 'allsitecourses' => 1]); - return reset($courses); - } catch (\Exception $e) { - \core\notification::add(get_string('errorcourseinfo', 'hub', $e->getMessage()), - \core\output\notification::NOTIFY_ERROR); - } - return null; - } - - /** - * Downloads course backup and stores it in the user private files - * - * @param int $hubcourseid - * @param string $coursename - * @return array - */ - public static function download_course_backup($hubcourseid, $coursename) { - global $CFG, $USER; - require_once($CFG->libdir . "/filelib.php"); - - $backuptempdir = make_backup_temp_directory(''); - $filename = md5(time() . '-' . $hubcourseid . '-'. $USER->id . '-'. random_string(20)); - $path = $backuptempdir.'/'.$filename.".mbz"; - - api::download_course_backup($hubcourseid, $path); - - $fs = get_file_storage(); - $record = new stdClass(); - $record->contextid = context_user::instance($USER->id)->id; - $record->component = 'user'; - $record->filearea = 'private'; - $record->itemid = 0; - $record->filename = urlencode($coursename).'_'.time().".mbz"; - $record->filepath = '/downloaded_backup/'; - if (!$fs->file_exists($record->contextid, $record->component, - $record->filearea, 0, $record->filepath, $record->filename)) { - $fs->create_file_from_pathname($record, $path); - } - - return [$record->filepath . $record->filename, $filename]; - } - - /** - * Uploads a course backup - * - * @param int $hubcourseid id of the published course on moodle.net, it must be published from this site - * @param \stored_file $backupfile - */ - public static function upload_course_backup($hubcourseid, \stored_file $backupfile) { - api::upload_course_backup($hubcourseid, $backupfile); - } -} \ No newline at end of file diff --git a/lib/classes/hub/registration.php b/lib/classes/hub/registration.php index 2061ef0a611..555fe7be7fb 100644 --- a/lib/classes/hub/registration.php +++ b/lib/classes/hub/registration.php @@ -406,19 +406,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(); diff --git a/lib/db/access.php b/lib/db/access.php index f57e18e0cb8..60dbba7f271 100644 --- a/lib/db/access.php +++ b/lib/db/access.php @@ -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, @@ -1957,15 +1929,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', diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 47807a9bed5..f22d0246213 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -4441,13 +4441,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)); diff --git a/version.php b/version.php index 25a31b5efc2..cc1309a80a2 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2018120305.11; // 20181203 = branching date YYYYMMDD - do not modify! +$version = 2018120305.12; // 20181203 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches. // .XX = incremental changes.