Skip to content

Commit

Permalink
MDL-45562 blog: fixed issues when creating/editing an external blog.
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Jul 11, 2014
1 parent b4d0a44 commit 417b692
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
19 changes: 12 additions & 7 deletions blog/external_blog_edit.php
Expand Up @@ -79,13 +79,16 @@
$newexternal->description = (empty($data->description)) ? $rss->get_description() : $data->description;
$newexternal->userid = $USER->id;
$newexternal->url = $data->url;
$newexternal->filtertags = $data->filtertags;
$newexternal->filtertags = (!empty($data->filtertags)) ? $data->filtertags : null;
$newexternal->timemodified = time();

$newexternal->id = $DB->insert_record('blog_external', $newexternal);
blog_sync_external_entries($newexternal);
tag_set('blog_external', $newexternal->id, explode(',', $data->autotags), 'core',
context_user::instance($newexternal->userid)->id);
if ($CFG->usetags) {
$autotags = (!empty($data->autotags)) ? $data->autotags : null;
tag_set('blog_external', $newexternal->id, explode(',', $autotags), 'core',
context_user::instance($newexternal->userid)->id);
}

break;

Expand All @@ -99,13 +102,15 @@
$external->description = (empty($data->description)) ? $rss->get_description() : $data->description;
$external->userid = $USER->id;
$external->url = $data->url;
$external->filtertags = $data->filtertags;
$external->filtertags = (!empty($data->filtertags)) ? $data->filtertags : null;
$external->timemodified = time();

$DB->update_record('blog_external', $external);
tag_set('blog_external', $external->id, explode(',', $data->autotags), 'core',
context_user::instance($newexternal->userid)->id);

if ($CFG->usetags) {
$autotags = (!empty($data->autotags)) ? $data->autotags : null;
tag_set('blog_external', $external->id, explode(',', $autotags), 'core',
context_user::instance($external->userid)->id);
}
} else {
print_error('wrongexternalid', 'blog');
}
Expand Down
4 changes: 3 additions & 1 deletion blog/external_blog_edit_form.php
Expand Up @@ -118,7 +118,9 @@ public function definition_after_data() {
if ($id = $mform->getElementValue('id')) {
$mform->setDefault('autotags', implode(',', tag_get_tags_array('blog_external', $id)));
$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
// Use $rss->get_channel_tags()
}
Expand Down

0 comments on commit 417b692

Please sign in to comment.