publication MDL-19315 add course screenshots support

This commit is contained in:
jerome mouneyrac 2010-05-28 02:42:37 +00:00
parent 91bc072a31
commit d315aedc11
3 changed files with 34 additions and 28 deletions

View File

@ -43,13 +43,13 @@ class block_community_renderer extends plugin_renderer_base {
$table = new html_table();
$table->head = array(get_string('coursename', 'block_community'),
$table->head = array('', get_string('coursename', 'block_community'),
get_string('coursedesc', 'block_community'),
get_string('courselang', 'block_community'),
get_string('operation', 'block_community'));
$table->align = array('left', 'left', 'center', 'center');
$table->size = array('25%', '40%', '5%', '%5');
$table->align = array('center', 'left', 'left', 'center', 'center');
$table->size = array('10%', '25%', '40%', '5%', '%5');
if (empty($courses)) {
@ -139,7 +139,14 @@ class block_community_renderer extends plugin_renderer_base {
}
// add a row to the table
$cells = array($coursenamehtml, $deschtml, $language, $addbuttonhtml);
$firstscreenshothtml = '';
if (!empty($course->screenshotsids)) {
$params = array('courseid' => $course->id, 'filetype' => SCREENSHOT_FILE_TYPE);
$imgurl = new moodle_url($huburl."/local/hub/webservice/download.php", $params);
$firstscreenshothtml = html_writer::empty_tag('img', array('src' => $imgurl));
}
$cells = array($firstscreenshothtml, $coursenamehtml, $deschtml, $language, $addbuttonhtml);
$row = new html_table_row($cells);

View File

@ -303,13 +303,13 @@ class course_publication_form extends moodleform {
// $mform->addElement('filemanager', 'screenshots', get_string('screenshots','hub'), null,
// array('subdirs'=>0,
// 'maxbytes'=>1000000,
// 'maxfiles'=>3
// ));
// $mform->setHelpButton('screenshots', array('screenshots', get_string('screenshots', 'hub'), 'hub'));
// $mform->addHelpButton('screenshots', 'screenshots', 'hub');
$mform->addElement('filemanager', 'screenshots', get_string('screenshots','hub'), null,
array('subdirs'=>0,
'maxbytes'=>1000000,
'maxfiles'=>3
));
$mform->setHelpButton('screenshots', array('screenshots', get_string('screenshots', 'hub'), 'hub'));
$mform->addHelpButton('screenshots', 'screenshots', 'hub');
$this->add_action_buttons(false, $buttonlabel);
}

View File

@ -138,12 +138,9 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE,
$fs = get_file_storage();
$files = $fs->get_area_files(get_context_instance(CONTEXT_USER, $USER->id)->id, 'user_draft', $screenshots);
if (!empty($files)) {
$courseinfo->screenshotsids = '';
foreach ($files as $file) {
if ($file->is_valid_image()) {
$courseinfo->screenshotsids = $courseinfo->screenshotsids . "notsend:" . $file->get_contenthash() . ";";
}
}
$courseinfo->screenshotsids = count($files);
} else {
$courseinfo->screenshotsids = 0;
}
}
@ -192,13 +189,17 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE,
// send screenshots
if (!empty($fromform->screenshots)) {
require_once($CFG->dirroot. "/lib/filelib.php");
$params = array('token' => $registeredhub->token, 'filetype' => SCREENSHOT_FILE_TYPE,
'courseshortname' => $courseinfo->shortname);
$screenshotnumber = 0;
foreach ($files as $file) {
if ($file->is_valid_image()) {
$screenshotnumber = $screenshotnumber + 1;
$params = array();
$params['filetype'] = SCREENSHOT_FILE_TYPE;
$params['file'] = $file;
$params['courseid'] = $courseids[0];
$params['filename'] = $file->get_filename();
$params['screenshotnumber'] = $screenshotnumber;
$params['token'] = $registeredhub->token;
$curl->post($huburl."/local/hub/webservice/upload.php", $params);
}
}
@ -207,14 +208,12 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE,
// send backup
if ($share) {
foreach ($courseids as $courseid) {
$params = array();
$params['filetype'] = BACKUP_FILE_TYPE;
$params['courseid'] = $courseid;
$params['file'] = $backupfile;
$params['token'] = $registeredhub->token;
$curl->post($huburl."/local/hub/webservice/upload.php", $params);
}
$params = array();
$params['filetype'] = BACKUP_FILE_TYPE;
$params['courseid'] = $courseids[0];
$params['file'] = $backupfile;
$params['token'] = $registeredhub->token;
$curl->post($huburl."/local/hub/webservice/upload.php", $params);
//Delete the backup from user_tohub
$backupfile->delete();