mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
course publication MDL-19315 get_publication returned the first result without specifying a hub in parameter => fix, the return publication now depends of the hub passed in parameter
This commit is contained in:
parent
6010eda22d
commit
acfc901427
@ -62,7 +62,7 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE,
|
||||
//update status for all these course
|
||||
foreach ($sitecourses as $sitecourse) {
|
||||
//get the publication from the hub course id
|
||||
$publication = $publicationmanager->get_publication($sitecourse['id']);
|
||||
$publication = $publicationmanager->get_publication($sitecourse['id'], $hub->huburl);
|
||||
if (!empty($publication)) {
|
||||
$publication->status = $sitecourse['privacy'];
|
||||
$publication->timechecked = time();
|
||||
|
@ -177,16 +177,17 @@ class course_publish_manager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a publication for a course id on the hub
|
||||
* Get a publication for a course id on a hub
|
||||
* (which is either the id of the unique possible enrollable publication of a course,
|
||||
* either an id of one of the downloadable publication)
|
||||
* @param int $hubcourseid
|
||||
* @param string $huburl
|
||||
* @return object publication
|
||||
*/
|
||||
public function get_publication($hubcourseid) {
|
||||
public function get_publication($hubcourseid, $huburl) {
|
||||
global $DB;
|
||||
return $DB->get_record('course_published',
|
||||
array('hubcourseid' => $hubcourseid));
|
||||
array('hubcourseid' => $hubcourseid, 'huburl' => $huburl));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,7 +172,7 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE,
|
||||
}
|
||||
|
||||
//save the record into the published course table
|
||||
$publication = $publicationmanager->get_publication($courseids[0]);
|
||||
$publication = $publicationmanager->get_publication($courseids[0], $huburl);
|
||||
if (empty($publication)) {
|
||||
//if never been published or if we share, we need to save this new publication record
|
||||
$publicationmanager->add_course_publication($registeredhub->huburl, $course->id, !$share, $courseids[0]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user