mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
MDL-16360 - added support for mime-style subformat detection for portfolio supported formats
works well with flickr plugin (tested by uploading an image as a forum attachment and being offered flickr plugin but not for normal attachments)
This commit is contained in:
parent
0b46f19e89
commit
ea0de12f10
10 changed files with 135 additions and 16 deletions
|
@ -3166,9 +3166,13 @@ class assignment_portfolio_caller extends portfolio_module_caller_base {
|
|||
if (!$this->assignment->portfolio_exportable()) {
|
||||
throw new portfolio_caller_exception('notexportable', 'portfolio', $this->get_return_url());
|
||||
}
|
||||
global $USER;
|
||||
$this->userid = $USER->id;
|
||||
$this->file = (array_key_exists('file', $callbackargs)) ? $callbackargs['file'] : null;
|
||||
if (array_key_exists('file', $callbackargs)) {
|
||||
$fs = get_file_storage();
|
||||
$this->file = $fs->get_file_by_id($callbackargs['file']);
|
||||
$this->supportedformats = array(portfolio_format_from_file($this->file));
|
||||
} else if (is_callable(array($this->assignment, 'portfolio_supported_formats'))) {
|
||||
$this->supportedformats = $this->assignment->portfolio_supported_formats();
|
||||
}
|
||||
}
|
||||
|
||||
public function prepare_package() {
|
||||
|
@ -3193,11 +3197,10 @@ class assignment_portfolio_caller extends portfolio_module_caller_base {
|
|||
}
|
||||
|
||||
// default ...
|
||||
$fs = get_file_storage();
|
||||
$status = true;
|
||||
if ($this->file) {
|
||||
return $fs->get_file_by_id($this->file)->get_contenthash();
|
||||
return $this->file->get_contenthash();
|
||||
}
|
||||
$fs = get_file_storage();
|
||||
if ($files = $fs->get_area_files($this->assignment->context->id,
|
||||
'assignment_submission', $this->user->id, '', false)) {
|
||||
$sha1s = array();
|
||||
|
|
|
@ -279,6 +279,10 @@ class assignment_online extends assignment_base {
|
|||
$submission = $this->get_submission($userid);
|
||||
return $exporter->write_new_file(format_text($submission->data1, $submission->data2), 'assignment.html');
|
||||
}
|
||||
|
||||
function portfolio_supported_formats() {
|
||||
return array(PORTFOLIO_FORMAT_HTML);
|
||||
}
|
||||
}
|
||||
|
||||
class mod_assignment_online_edit_form extends moodleform {
|
||||
|
|
|
@ -855,6 +855,7 @@ class chat_portfolio_caller extends portfolio_module_caller_base {
|
|||
$select,
|
||||
$params
|
||||
);
|
||||
$this->supportedformats = array(PORTFOLIO_FORMAT_HTML);
|
||||
}
|
||||
|
||||
public function expected_time() {
|
||||
|
|
|
@ -2466,6 +2466,7 @@ class data_portfolio_caller extends portfolio_module_caller_base {
|
|||
$this->singlerecord = $DB->get_record('data_records', array('id' => $callbackargs['record']));
|
||||
$this->singlerecord->content = $DB->get_records('data_content', array('recordid' => $this->singlerecord->id));
|
||||
$this->exporttype = 'single';
|
||||
$this->supportedformats = array(PORTFOLIO_FORMAT_HTML);
|
||||
} else {
|
||||
// all records as csv or whatever
|
||||
$this->selectedfields = array();
|
||||
|
|
|
@ -7209,9 +7209,7 @@ class forum_portfolio_caller extends portfolio_module_caller_base {
|
|||
throw new portfolio_caller_exception('noattachments', 'forum');
|
||||
}
|
||||
$this->postfiles = array($f);
|
||||
if (in_array($f->get_mimetype(), array('image/gif', 'image/jpeg', 'image/png'))) {
|
||||
$this->supportedformats = array(PORTFOLIO_FORMAT_IMAGE);
|
||||
}
|
||||
$this->supportedformats = array(portfolio_format_from_file($f));
|
||||
} elseif ($this->post) {
|
||||
$this->postfiles = $fs->get_area_files(get_context_instance(CONTEXT_MODULE, $this->cm->id)->id, 'forum_attachment', $this->post->id, "timemodified", false);
|
||||
} else {
|
||||
|
|
|
@ -2454,6 +2454,7 @@ class glossary_entry_portfolio_caller extends portfolio_module_caller_base {
|
|||
|| !$this->entry = $DB->get_record('glossary_entries', array('id' => $callbackargs['entryid']))) {
|
||||
throw new portfolio_caller_exception('noentry', 'glossary');
|
||||
}
|
||||
$this->supportedformats = array(PORTFOLIO_FORMAT_HTML);
|
||||
}
|
||||
|
||||
public function expected_time() {
|
||||
|
|
|
@ -722,6 +722,16 @@ class resource_portfolio_caller extends portfolio_module_caller_base {
|
|||
$this->resourcefile = $CFG->dirroot.'/mod/resource/type/'.$this->cm->type.'/resource.class.php';
|
||||
require_once($this->resourcefile);
|
||||
$this->resource= new $resourceclass($this->cm->id);
|
||||
// this is kind of yuk... but there's just not good enough OO here
|
||||
$format = PORTFOLIO_FORMAT_FILE;
|
||||
switch ($this->cm->type) {
|
||||
case 'html':
|
||||
$format = PORTFOLIO_FORMAT_HTML;
|
||||
case 'text':
|
||||
$format = PORTFOLIO_FORMAT_TEXT;
|
||||
case 'file':
|
||||
// $format = portfolio_format_from_mimetype($something); // change after we switch upload type resources over to new files api.
|
||||
}
|
||||
}
|
||||
|
||||
public function __wakeup() {
|
||||
|
@ -734,7 +744,7 @@ class resource_portfolio_caller extends portfolio_module_caller_base {
|
|||
}
|
||||
|
||||
public function expected_time() {
|
||||
// @todo penny check filesize if the type is uploadey
|
||||
// @todo penny check filesize if the type is uploadey (not implemented yet)
|
||||
return PORTFOLIO_TIME_LOW;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue