本文整理汇总了PHP中Conversation::getUnreadCountByUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Conversation::getUnreadCountByUser方法的具体用法?PHP Conversation::getUnreadCountByUser怎么用?PHP Conversation::getUnreadCountByUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conversation
的用法示例。
在下文中一共展示了Conversation::getUnreadCountByUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetUnreadConversationCount
/**
* @depends testResolveConversationParticipantsForExplicitModelPermissions
*/
public function testGetUnreadConversationCount()
{
$super = User::getByUsername('super');
$mary = User::getByUsername('mary');
$count = Conversation::getUnreadCountByUser($super);
$account2 = AccountTestHelper::createAccountByNameForOwner('anAccount2', $super);
$conversation = new Conversation();
$conversation->owner = $super;
$conversation->subject = 'My test subject2';
$conversation->description = 'My test description2';
$conversation->conversationItems->add($account2);
$this->assertTrue($conversation->save());
//when super adds a comment, it should remain same count
$comment = new Comment();
$comment->description = 'This is my first comment';
$conversation->comments->add($comment);
$this->assertTrue($conversation->save());
$count = Conversation::getUnreadCountByUser($super);
$this->assertEquals(1, $count);
//Add mary as a participant
$explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($conversation);
$postData = array();
$postData['itemIds'] = $super->getClassId('Item') . ',' . $mary->getClassId('Item');
// Not Coding Standard
ConversationParticipantsUtil::resolveConversationHasManyParticipantsFromPost($conversation, $postData, $explicitReadWriteModelPermissions);
$success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($conversation, $explicitReadWriteModelPermissions);
$this->assertTrue($success);
$conversation->save();
//when mary adds a comment, super's count should go up (assumming count was previously 0)
Yii::app()->user->userModel = $mary;
$comment = new Comment();
$comment->description = 'This is mary\'s first comment';
$conversation->comments->add($comment);
$this->assertTrue($conversation->save());
Yii::app()->user->userModel = $super;
$count = Conversation::getUnreadCountByUser($super);
$this->assertEquals(2, $count);
}
示例2: getUnreadCountTabMenuContentForCurrentUser
/**
* For the current user, render a string of how many unread conversations exist for the user.
* @return string
*/
public static function getUnreadCountTabMenuContentForCurrentUser()
{
return Conversation::getUnreadCountByUser(Yii::app()->user->userModel);
}