Merge branch 'MDL-52599-master' of git://github.com/danpoltawski/moodle
authorAndrew Nicols <andrew@nicols.co.uk>
Tue, 17 May 2016 03:04:38 +0000 (11:04 +0800)
committerDavid Monllao <davidm@moodle.com>
Tue, 17 May 2016 09:16:11 +0000 (17:16 +0800)
blocks/rss_client/edit_form.php

index f8fcf89..eb7fe27 100644 (file)
@@ -47,13 +47,20 @@ class block_rss_client_edit_form extends block_edit_form {
             $mform->setDefault('config_shownumentries', 5);
         }
 
-        $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
-                ORDER BY CASE WHEN preferredtitle = ? THEN ' . $DB->sql_compare_text('title', 64) . ' ELSE preferredtitle END ',
-                array('', $USER->id, ''));
+        $params = array('userid' => $USER->id);
+        $rssconfig = unserialize(base64_decode($this->block->instance->configdata));
+        list($insql, $inparams) = $DB->get_in_or_equal($rssconfig->rssid, SQL_PARAMS_NAMED);
+        $params += $inparams;
+
+        $titlesql = "CASE WHEN preferredtitle = '' THEN {$DB->sql_compare_text('title', 64)} ELSE preferredtitle END";
+
+        $rssfeeds = $DB->get_records_sql_menu("
+                SELECT id, $titlesql
+                  FROM {block_rss_client}
+                 WHERE userid = :userid OR shared = 1 OR id $insql
+                 ORDER BY $titlesql",
+                $params);
+
         if ($rssfeeds) {
             $select = $mform->addElement('select', 'config_rssid', get_string('choosefeedlabel', 'block_rss_client'), $rssfeeds);
             $select->setMultiple(true);