diff options
author | fwenzel@mozilla.com <fwenzel@mozilla.com@4eb1ac78-321c-0410-a911-ec516a8615a5> | 2009-06-22 21:24:47 (GMT) |
---|---|---|
committer | fwenzel@mozilla.com <fwenzel@mozilla.com@4eb1ac78-321c-0410-a911-ec516a8615a5> | 2009-06-22 21:24:47 (GMT) |
commit | f254c45e183adcf7e850464c55ebe6db56795a17 (patch) | |
tree | a91c6e51ea9140c3accceab0df46602e502096f5 | |
parent | 1e378b475447580035971b1ef37cee4df6e77ca5 (diff) |
handle "myself" in collection roles properly (bug 496419, r=clouserw)
git-svn-id: http://svn.mozilla.org/addons/trunk@28257 4eb1ac78-321c-0410-a911-ec516a8615a5
-rw-r--r-- | site/app/controllers/collections_controller.php | 10 | ||||
-rw-r--r-- | site/app/models/collection.php | 8 |
2 files changed, 11 insertions, 7 deletions
diff --git a/site/app/controllers/collections_controller.php b/site/app/controllers/collections_controller.php index 3ea4688..34b314d 100644 --- a/site/app/controllers/collections_controller.php +++ b/site/app/controllers/collections_controller.php @@ -533,7 +533,7 @@ class CollectionsController extends AppController } // get collection data for display (and publish to view) - $this->_getCollectionDataForView($id); + $this->_getCollectionDataForView($id, $user); // view setup $this->layout = 'amo2009'; // TODO: remove this when the entire controller is amo2009-based @@ -552,7 +552,7 @@ class CollectionsController extends AppController * @return void * @access private */ - function _getCollectionDataForView($id) { + function _getCollectionDataForView($id, $user) { $this->Collection->unbindModel(array('hasAndBelongsToMany'=>array('Addon'))); $collection = $this->Collection->findById($id); $this->data['Collection'] = $collection; @@ -589,12 +589,14 @@ class CollectionsController extends AppController ), false); // get existing publishers and managers - $publishers = $this->Collection->getUsers($id, array(COLLECTION_ROLE_PUBLISHER)); + $publishers = $this->Collection->getUsers($id, + array(COLLECTION_ROLE_PUBLISHER), array($user['id'])); $publishers_noscript = $managers_noscript = array(); foreach ($publishers as &$p) { $publishers_noscript[$p['User']['id']] = $p['User']['email']; } - $managers = $this->Collection->getUsers($id, array(COLLECTION_ROLE_ADMIN)); + $managers = $this->Collection->getUsers($id, + array(COLLECTION_ROLE_ADMIN), array($user['id'])); foreach ($managers as &$m) { $managers_noscript[$m['User']['id']] = $m['User']['email']; } diff --git a/site/app/models/collection.php b/site/app/models/collection.php index fa751f6..0bc76ff 100644 --- a/site/app/models/collection.php +++ b/site/app/models/collection.php @@ -398,8 +398,9 @@ class Collection extends AppModel * * @param int id of the collection * @param array (optional) list of roles for which users should be fetched + * @param array (optional) list of user IDs to be excluded */ - function getUsers($collectionId, $roles=null) { + function getUsers($collectionId, $roles=null, $exclude=null) { if (!is_numeric($collectionId)) return null; // Build SQL to look up user IDs and roles for collection @@ -421,8 +422,9 @@ class Collection extends AppModel $rows = $this->execute($sql); $user_map = array(); foreach ($rows as $row) { - $user_map[$row['collections_users']['user_id']] = - $row['collections_users']; + if (is_array($exclude) && !in_array($row['collections_users']['user_id'], $exclude)) { + $user_map[$row['collections_users']['user_id']] = $row['collections_users']; + } } // Look up users with user IDs, merge the role info into each found. |