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:
jerome mouneyrac 2010-06-28 06:26:54 +00:00
parent 6010eda22d
commit acfc901427
3 changed files with 6 additions and 5 deletions

View File

@ -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();

View File

@ -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));
}
/**

View File

@ -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]);