From f508f60db1ec312e95c6af587103aa838430a619 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Mon, 9 Jul 2018 11:48:41 -0400 Subject: [PATCH] Fix broken token implementation in ListItems channel provider. --- .../src/VuFind/ChannelProvider/ListItems.php | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/module/VuFind/src/VuFind/ChannelProvider/ListItems.php b/module/VuFind/src/VuFind/ChannelProvider/ListItems.php index 9b0c21ca44e..576690a5da0 100644 --- a/module/VuFind/src/VuFind/ChannelProvider/ListItems.php +++ b/module/VuFind/src/VuFind/ChannelProvider/ListItems.php @@ -164,7 +164,9 @@ class ListItems extends AbstractChannelProvider protected function buildListChannels($channelToken) { $channels = []; - foreach ($this->getLists() as $list) { + $lists = $channelToken + ? $this->getListsById([$channelToken]) : $this->getLists(); + foreach ($lists as $list) { $tokenOnly = (count($channels) >= $this->initialListsToDisplay); $channel = $this->getChannelFromList($list, $tokenOnly); if ($tokenOnly || count($channel['contents']) > 0) { @@ -175,19 +177,35 @@ class ListItems extends AbstractChannelProvider } /** - * Get a list of public lists to display: + * Get a list of lists, identified by ID; filter to public lists only. + * + * @param array $ids IDs to retrieve * * @return array */ - protected function getLists() + protected function getListsById($ids) { $lists = []; - foreach ($this->ids as $id) { + foreach ($ids as $id) { $list = $this->userList->getExisting($id); if ($list->public) { $lists[] = $list; } } + return $lists; + } + + /** + * Get a list of public lists to display: + * + * @return array + */ + protected function getLists() + { + // First fetch hard-coded IDs: + $lists = $this->getListsById($this->ids); + + // Next add public lists if necessary: if ($this->displayPublicLists) { $ids = $this->ids; $callback = function ($select) use ($ids) { @@ -200,6 +218,7 @@ class ListItems extends AbstractChannelProvider $lists[] = $list; } } + return $lists; } -- GitLab