From 396a5776cd043e899e4897ec50fc8edc52585512 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Wed, 30 Jan 2019 15:56:04 +0100 Subject: author filter home --- app/class/modelart.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'app/class/modelart.php') diff --git a/app/class/modelart.php b/app/class/modelart.php index 0cb9b1c..45ff3c2 100644 --- a/app/class/modelart.php +++ b/app/class/modelart.php @@ -178,6 +178,29 @@ class Modelart extends Modeldb return $filteredlist; } + public function filterauthorfilter(array $artlist, array $authorchecked, $authorcompare = 'OR') + { + + $filteredlist = []; + foreach ($artlist as $art) { + if (empty($authorchecked)) { + $filteredlist[] = $art->id(); + } else { + $inter = (array_intersect($art->authors('array'), $authorchecked)); + if ($authorcompare == 'OR') { + if (!empty($inter)) { + $filteredlist[] = $art->id(); + } + } elseif ($authorcompare == 'AND') { + if (!array_diff($authorchecked, $art->authors('array'))) { + $filteredlist[] = $art->id(); + } + } + } + } + return $filteredlist; + } + public function filtersecure(array $artlist, $secure) { $filteredlist = []; -- cgit v1.2.3