本文整理匯總了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);
}