Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit c08f9f5

Browse files
committed
BUG: refs #453. Admins can now see all private feeds
Also fixed a bug where feed related to a community invitation was not removed when the community invitation was deleted as a result of user deletion, which caused the feed page to crash. Admins will see the recipient of a community invitation in the feed now instead of just seeing "invited you to join the community".
1 parent 689b377 commit c08f9f5

File tree

4 files changed

+34
-20
lines changed

4 files changed

+34
-20
lines changed

core/controllers/FeedController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function init()
3737
public function indexAction()
3838
{
3939
$this->view->feeds = $this->Feed->getGlobalFeeds($this->userSession->Dao);
40+
$this->view->loggedUser = $this->userSession->Dao;
4041
$this->view->itemThumbnails = $this->Item->getRandomThumbnails($this->userSession->Dao, 0, 12, true);
4142
$this->view->nUsers = $this->User->getCountAll();
4243
$this->view->nCommunities = $this->Community->getCountAll();

core/models/base/UserModelBase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public function delete($user)
103103
$invitations = $user->getInvitations();
104104
foreach($invitations as $invitation)
105105
{
106-
$ciModel->delete($invitation);
106+
//Must call removeInvitation instead of delete so the corresponding feed is also deleted
107+
$ciModel->removeInvitation($invitation->getCommunity(), $user);
107108
}
108109

109110
// Delete this user's folder tree recursively

core/models/pdo/FeedModel.php

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,28 @@ protected function getFeeds($loggedUserDao, $userDao = null, $communityDao = nul
160160
->setIntegrityCheck(false)
161161
->from(array('f' => 'feed'))
162162
->limit($limit);
163-
$sql ->joinLeft(array('fpu' => 'feedpolicyuser'), '
164-
f.feed_id = fpu.feed_id AND '.$this->database->getDB()->quoteInto('fpu.policy >= ?', $policy).'
165-
AND '.$this->database->getDB()->quoteInto('fpu.user_id = ? ', $userId).' ', array('userpolicy' => 'fpu.policy'))
166-
->joinLeft(array('fpg' => 'feedpolicygroup'), '
167-
f.feed_id = fpg.feed_id AND '.$this->database->getDB()->quoteInto('fpg.policy >= ?', $policy).'
168-
AND ( '.$this->database->getDB()->quoteInto('fpg.group_id = ? ', MIDAS_GROUP_ANONYMOUS_KEY).' OR
169-
fpg.group_id IN (' .new Zend_Db_Expr(
170-
$this->database->select()
171-
->setIntegrityCheck(false)
172-
->from(array('u2g' => 'user2group'),
173-
array('group_id'))
174-
->where('u2g.user_id = ?', $userId)
175-
) .'))', array('grouppolicy' => 'fpg.policy'))
176-
->where(
177-
'(
178-
fpu.feed_id is not null or
179-
fpg.feed_id is not null)'
180-
);
163+
164+
if(!$isAdmin)
165+
{
166+
$sql->joinLeft(array('fpu' => 'feedpolicyuser'), '
167+
f.feed_id = fpu.feed_id AND '.$this->database->getDB()->quoteInto('fpu.policy >= ?', $policy).'
168+
AND '.$this->database->getDB()->quoteInto('fpu.user_id = ? ', $userId).' ', array('userpolicy' => 'fpu.policy'))
169+
->joinLeft(array('fpg' => 'feedpolicygroup'), '
170+
f.feed_id = fpg.feed_id AND '.$this->database->getDB()->quoteInto('fpg.policy >= ?', $policy).'
171+
AND ( '.$this->database->getDB()->quoteInto('fpg.group_id = ? ', MIDAS_GROUP_ANONYMOUS_KEY).' OR
172+
fpg.group_id IN (' .new Zend_Db_Expr(
173+
$this->database->select()
174+
->setIntegrityCheck(false)
175+
->from(array('u2g' => 'user2group'),
176+
array('group_id'))
177+
->where('u2g.user_id = ?', $userId)
178+
) .'))', array('grouppolicy' => 'fpg.policy'))
179+
->where(
180+
'(
181+
fpu.feed_id is not null or
182+
fpg.feed_id is not null)'
183+
);
184+
}
181185

182186
if($userDao != null)
183187
{

core/views/element/feed.phtml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,15 @@ PURPOSE. See the above copyright notices for more information.
4646
echo "{$view->t("added the community")} <a href='{$view->webroot}/community/{$feed->getRessource()->getKey()}'>".$view->slicename($feed->getRessource()->getName(),30)."</a>";
4747
break;
4848
case MIDAS_FEED_COMMUNITY_INVITATION:
49-
echo "{$view->t("invited you to the community")} <a href='{$view->webroot}/community/{$feed->getRessource()->getCommunity()->getKey()}'>".$view->slicename($feed->getRessource()->getCommunity()->getName(),30)."</a>";
49+
if($view->loggedUser && $view->loggedUser->getKey() == $feed->getRessource()->getUser()->getKey())
50+
{
51+
echo $view->t('invited you to the community');
52+
}
53+
else
54+
{
55+
echo $view->t('invited').' '.$view->linkuser($feed->getRessource()->getUser()).' '.$view->t('to the community');
56+
}
57+
echo " <a href='{$view->webroot}/community/{$feed->getRessource()->getCommunity()->getKey()}'>".$view->slicename($feed->getRessource()->getCommunity()->getName(),30)."</a>";
5058
break;
5159
case MIDAS_FEED_UPDATE_COMMUNITY:
5260
case MIDAS_FEED_CREATE_FOLDER:

0 commit comments

Comments
 (0)