MDL-52599 blocks/rss_client: Fix RSS block config page

This fixes an error where the RSS block config page would display
'Array' where the multiselect list of feeds should be when
accessed by a user who has not saved any RSS feed urls and yet the
block has been previously configured by another user.
This commit is contained in:
Clement Smith
2016-05-16 11:04:36 +01:00
committed by Dan Poltawski
parent 65cbefc403
commit af8cab9b69
+11 -2
View File
@@ -47,13 +47,22 @@ class block_rss_client_edit_form extends block_edit_form {
$mform->setDefault('config_shownumentries', 5);
}
$rssconfig = unserialize(base64_decode($this->block->instance->configdata));
list($insql, $inparams) = $DB->get_in_or_equal($rssconfig->rssid);
$queryparams = array('', $USER->id);
foreach ($inparams as $paramid) {
$queryparams[] = $paramid;
}
$queryparams[] = '';
$rssfeeds = $DB->get_records_sql_menu('
SELECT id,
CASE WHEN preferredtitle = ? THEN ' . $DB->sql_compare_text('title', 64) .' ELSE preferredtitle END
FROM {block_rss_client}
WHERE userid = ? OR shared = 1
WHERE userid = ? OR shared = 1 OR id '.$insql.'
ORDER BY CASE WHEN preferredtitle = ? THEN ' . $DB->sql_compare_text('title', 64) . ' ELSE preferredtitle END ',
array('', $USER->id, ''));
$queryparams);
if ($rssfeeds) {
$select = $mform->addElement('select', 'config_rssid', get_string('choosefeedlabel', 'block_rss_client'), $rssfeeds);
$select->setMultiple(true);