From 86ad52aa33debdf135900ad1c879796ff1eb6142 Mon Sep 17 00:00:00 2001 From: Naeem Date: Mon, 5 Oct 2015 14:05:59 +0200 Subject: [PATCH 1/2] filter user exhibits --- functions.php | 3 ++- models/Table/Exhibit.php | 18 +++++++++++++++++- views/admin/exhibits/browse.php | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index 309d9b7b..7b6b606c 100644 --- a/functions.php +++ b/functions.php @@ -424,9 +424,10 @@ function exhibit_builder_public_main_nav($navArray) */ function exhibit_builder_admin_nav($navArray) { + /* By default user will see its own exhibits. */ $navArray[] = array( 'label' => __('Exhibits'), - 'uri' => url('exhibits'), + 'uri' => url('exhibits', array('owner' => current_user()->id)), 'resource' => 'ExhibitBuilder_Exhibits', 'privilege' => 'browse' ); diff --git a/models/Table/Exhibit.php b/models/Table/Exhibit.php index 3de0333e..64cc38e9 100644 --- a/models/Table/Exhibit.php +++ b/models/Table/Exhibit.php @@ -68,7 +68,7 @@ public function getSelect() /** * Define filters for browse and findBy. * - * Available filters are: "tag" or "tags", "public" and "featured". "sort" + * Available filters are: "tag" or "tags", "public", "featured" and "owner(user)". "sort" * also adds specific sorting strategies "alpha" and "recent", but the * normal sorting can also be used. * @@ -102,6 +102,9 @@ public function applySearchFilters($select, $params) case 'featured': $this->filterByFeatured($select, $params['featured']); break; + case 'owner': /* Filter a user's own exhibits from others. */ + $this->filterByUser($select, $params['owner']); + break; } } return $select; @@ -195,4 +198,17 @@ public function filterByFeatured($select, $isFeatured) $select->where('exhibits.featured = 0'); } } + + /** + * Apply a filter to get exhibts of a user + * + * @param Zend_Db_Select + * @param integer $userId Id of the user whose exhibits are to be retrieved + */ + public function filterByUser($select, $userId) + { + if (!empty($userId) && $userId > 0) { + $select->where('exhibits.owner_id = '. $userId); + } + } } diff --git a/views/admin/exhibits/browse.php b/views/admin/exhibits/browse.php index 9d13323a..0925ab5c 100644 --- a/views/admin/exhibits/browse.php +++ b/views/admin/exhibits/browse.php @@ -17,6 +17,8 @@
+ +
From 4d5387e66f3e4070db8026ad4152328eb48e3fbd Mon Sep 17 00:00:00 2001 From: Naeem Date: Wed, 18 Nov 2015 10:08:51 +0100 Subject: [PATCH 2/2] restore pull request changes --- functions.php | 3 +-- models/Table/Exhibit.php | 18 +----------------- views/admin/exhibits/browse.php | 2 -- 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/functions.php b/functions.php index 7b6b606c..309d9b7b 100644 --- a/functions.php +++ b/functions.php @@ -424,10 +424,9 @@ function exhibit_builder_public_main_nav($navArray) */ function exhibit_builder_admin_nav($navArray) { - /* By default user will see its own exhibits. */ $navArray[] = array( 'label' => __('Exhibits'), - 'uri' => url('exhibits', array('owner' => current_user()->id)), + 'uri' => url('exhibits'), 'resource' => 'ExhibitBuilder_Exhibits', 'privilege' => 'browse' ); diff --git a/models/Table/Exhibit.php b/models/Table/Exhibit.php index 64cc38e9..3de0333e 100644 --- a/models/Table/Exhibit.php +++ b/models/Table/Exhibit.php @@ -68,7 +68,7 @@ public function getSelect() /** * Define filters for browse and findBy. * - * Available filters are: "tag" or "tags", "public", "featured" and "owner(user)". "sort" + * Available filters are: "tag" or "tags", "public" and "featured". "sort" * also adds specific sorting strategies "alpha" and "recent", but the * normal sorting can also be used. * @@ -102,9 +102,6 @@ public function applySearchFilters($select, $params) case 'featured': $this->filterByFeatured($select, $params['featured']); break; - case 'owner': /* Filter a user's own exhibits from others. */ - $this->filterByUser($select, $params['owner']); - break; } } return $select; @@ -198,17 +195,4 @@ public function filterByFeatured($select, $isFeatured) $select->where('exhibits.featured = 0'); } } - - /** - * Apply a filter to get exhibts of a user - * - * @param Zend_Db_Select - * @param integer $userId Id of the user whose exhibits are to be retrieved - */ - public function filterByUser($select, $userId) - { - if (!empty($userId) && $userId > 0) { - $select->where('exhibits.owner_id = '. $userId); - } - } } diff --git a/views/admin/exhibits/browse.php b/views/admin/exhibits/browse.php index 0925ab5c..9d13323a 100644 --- a/views/admin/exhibits/browse.php +++ b/views/admin/exhibits/browse.php @@ -17,8 +17,6 @@
- -