當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Conversation::getUnreadCountByUser方法代碼示例

本文整理匯總了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);
 }
開發者ID:RamaKavanan,項目名稱:InitialVersion,代碼行數:41,代碼來源:ConversationTest.php

示例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);
 }
開發者ID:RamaKavanan,項目名稱:InitialVersion,代碼行數:8,代碼來源:ConversationsUtil.php


注:本文中的Conversation::getUnreadCountByUser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。