diff --git a/course/publish/forms.php b/course/publish/forms.php index 2d9f8996812..0ee89998e1b 100644 --- a/course/publish/forms.php +++ b/course/publish/forms.php @@ -337,25 +337,27 @@ class course_publication_form extends moodleform { $mform->setType('creatornotes', PARAM_CLEANHTML); $mform->addHelpButton('creatornotes', 'creatornotes', 'hub'); - if (!empty($screenshotsnumber)) { + if ($advertise) { + if (!empty($screenshotsnumber)) { - if (!empty($privacy)) { - $baseurl = new moodle_url($huburl . '/local/hub/webservice/download.php', - array('courseid' => $hubcourseid, 'filetype' => HUB_SCREENSHOT_FILE_TYPE)); - $screenshothtml = html_writer::empty_tag('img', - array('src' => $baseurl, 'alt' => $defaultfullname)); - $screenshothtml = html_writer::tag('div', $screenshothtml, - array('class' => 'coursescreenshot', - 'id' => 'image-' . $hubcourseid)); - } else { - $screenshothtml = get_string('existingscreenshotnumber', 'hub', $screenshotsnumber); + if (!empty($privacy)) { + $baseurl = new moodle_url($huburl . '/local/hub/webservice/download.php', + array('courseid' => $hubcourseid, 'filetype' => HUB_SCREENSHOT_FILE_TYPE)); + $screenshothtml = html_writer::empty_tag('img', + array('src' => $baseurl, '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('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->addElement('hidden', 'existingscreenshotnumber', $screenshotsnumber); + } $mform->addElement('filemanager', 'screenshots', get_string('addscreenshots', 'hub'), null, array('subdirs' => 0, diff --git a/course/publish/metadata.php b/course/publish/metadata.php index c5046022c3a..ddcd5b6989b 100644 --- a/course/publish/metadata.php +++ b/course/publish/metadata.php @@ -162,7 +162,7 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE, //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)) { + if (!empty($fromform->deletescreenshots) or $share) { $courseinfo->screenshots = 0; } else { $courseinfo->screenshots = $fromform->existingscreenshotnumber; @@ -214,7 +214,7 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE, // send screenshots if (!empty($fromform->screenshots)) { - if (!empty($fromform->deletescreenshots)) { + if (!empty($fromform->deletescreenshots) or $share) { $screenshotnumber = 0; } else { $screenshotnumber = $fromform->existingscreenshotnumber;