MDL-45562 blog: fixed issues when creating/editing an external blog.

This commit is contained in:
Simey Lameze 2014-07-11 12:58:26 +08:00
parent 5fd0df97c5
commit 17af896c4b
2 changed files with 15 additions and 8 deletions

View File

@ -79,13 +79,16 @@ if ($externalblogform->is_cancelled()){
$newexternal->description = (empty($data->description)) ? $rss->get_description() : $data->description; $newexternal->description = (empty($data->description)) ? $rss->get_description() : $data->description;
$newexternal->userid = $USER->id; $newexternal->userid = $USER->id;
$newexternal->url = $data->url; $newexternal->url = $data->url;
$newexternal->filtertags = $data->filtertags; $newexternal->filtertags = (!empty($data->filtertags)) ? $data->filtertags : null;
$newexternal->timemodified = time(); $newexternal->timemodified = time();
$newexternal->id = $DB->insert_record('blog_external', $newexternal); $newexternal->id = $DB->insert_record('blog_external', $newexternal);
blog_sync_external_entries($newexternal); blog_sync_external_entries($newexternal);
tag_set('blog_external', $newexternal->id, explode(',', $data->autotags), 'core', if ($CFG->usetags) {
context_user::instance($newexternal->userid)->id); $autotags = (!empty($data->autotags)) ? $data->autotags : null;
tag_set('blog_external', $newexternal->id, explode(',', $autotags), 'core',
context_user::instance($newexternal->userid)->id);
}
break; break;
@ -99,13 +102,15 @@ if ($externalblogform->is_cancelled()){
$external->description = (empty($data->description)) ? $rss->get_description() : $data->description; $external->description = (empty($data->description)) ? $rss->get_description() : $data->description;
$external->userid = $USER->id; $external->userid = $USER->id;
$external->url = $data->url; $external->url = $data->url;
$external->filtertags = $data->filtertags; $external->filtertags = (!empty($data->filtertags)) ? $data->filtertags : null;
$external->timemodified = time(); $external->timemodified = time();
$DB->update_record('blog_external', $external); $DB->update_record('blog_external', $external);
tag_set('blog_external', $external->id, explode(',', $data->autotags), 'core', if ($CFG->usetags) {
context_user::instance($newexternal->userid)->id); $autotags = (!empty($data->autotags)) ? $data->autotags : null;
tag_set('blog_external', $external->id, explode(',', $autotags), 'core',
context_user::instance($external->userid)->id);
}
} else { } else {
print_error('wrongexternalid', 'blog'); print_error('wrongexternalid', 'blog');
} }

View File

@ -118,7 +118,9 @@ class blog_edit_external_form extends moodleform {
if ($id = $mform->getElementValue('id')) { if ($id = $mform->getElementValue('id')) {
$mform->setDefault('autotags', implode(',', tag_get_tags_array('blog_external', $id))); $mform->setDefault('autotags', implode(',', tag_get_tags_array('blog_external', $id)));
$mform->freeze('url'); $mform->freeze('url');
$mform->freeze('filtertags'); if ($mform->elementExists('filtertags')) {
$mform->freeze('filtertags');
}
// TODO change the filtertags element to a multiple select, using the tags of the external blog // TODO change the filtertags element to a multiple select, using the tags of the external blog
// Use $rss->get_channel_tags() // Use $rss->get_channel_tags()
} }