public static function resolveRowCssClasses($grid, $row, $data) { if (is_array($grid->rowCssClass) && ($n = count($grid->rowCssClass)) > 0) { $content = $grid->rowCssClass[$row % $n]; if (!ConversationsUtil::hasUserReadConversationLatest($data, Yii::app()->user->userModel)) { $content .= ' unread'; } return $content; } }
public function actionDetails($id) { $conversation = static::getModelAndCatchNotFoundAndDisplayError('Conversation', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($conversation); AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($conversation), 'ConversationsModule'), $conversation); ConversationsUtil::markUserHasReadLatest($conversation, Yii::app()->user->userModel); $detailsView = new ConversationDetailsView($this->getId(), $this->getModule()->getId(), $conversation); $conversationsMashableInboxUrl = Yii::app()->createUrl('mashableInbox/default/list', array('modelClassName' => 'Conversation')); $breadcrumbLinks = array(Zurmo::t('ConversationsModule', 'Conversations') => $conversationsMashableInboxUrl, StringUtil::getChoppedStringContent(strval($conversation), 25)); $view = new ConversationsPageView(ZurmoDefaultViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $detailsView, $breadcrumbLinks, 'ConversationBreadCrumbView')); echo $view->render(); }
/** * Override to handle sending email messages on new comment */ protected function afterSuccessfulSave($model) { assert('$model instanceof Item'); parent::afterSuccessfulSave($model); $user = Yii::app()->user->userModel; if ($this->relatedModel instanceof Conversation) { $participants = ConversationsUtil::resolvePeopleToSendNotificationToOnNewComment($this->relatedModel, $user); CommentsUtil::sendNotificationOnNewComment($this->relatedModel, $model, $user, $participants); } elseif ($this->relatedModel instanceof Mission) { $participants = MissionsUtil::resolvePeopleToSendNotificationToOnNewComment($this->relatedModel, $user); CommentsUtil::sendNotificationOnNewComment($this->relatedModel, $model, $user, $participants); } }
/** * Override to handle sending email messages on new comment */ protected function afterSuccessfulSave($model) { assert('$model instanceof Item'); parent::afterSuccessfulSave($model); $user = Yii::app()->user->userModel; if ($this->relatedModel instanceof Conversation) { $participants = ConversationsUtil::resolvePeopleToSendNotificationToOnNewComment($this->relatedModel, $user); CommentsUtil::sendNotificationOnNewComment($this->relatedModel, $model, $participants); } elseif ($this->relatedModel instanceof Mission) { $participants = MissionsUtil::resolvePeopleToSendNotificationToOnNewComment($this->relatedModel, $user); CommentsUtil::sendNotificationOnNewComment($this->relatedModel, $model, $participants); } elseif ($this->relatedModel instanceof Task) { TasksNotificationUtil::submitTaskNotificationMessage($this->relatedModel, TasksNotificationUtil::TASK_NEW_COMMENT, $model->createdByUser, $model); //Log the event if ($this->relatedModel->project->id > 0) { ProjectsUtil::logAddCommentEvent($this->relatedModel, $model->description); } } }
public function testMarkReadUnreadMassActionByModel() { $super = User::getByUsername('super'); //Conversation model $conversation = new Conversation(); $conversation->owner = $super; $conversation->subject = 'My test conversation subject'; $conversation->description = 'My test conversation description'; $this->assertTrue($conversation->save()); $conversationId = $conversation->id; $this->assertTrue((bool) ConversationsUtil::hasUserReadConversationLatest($conversation, $super)); //Mark conversation as unread $selectedIds = $conversationId; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $this->setGetArray(array('ajax' => 'list-view', 'modelClassName' => 'Conversation', 'MashableInboxForm' => array('massAction' => 'markUnread', 'selectedIds' => $selectedIds))); $content = $this->runControllerWithNoExceptionsAndGetContent('mashableInbox/default/list'); $conversation = Conversation::getById($conversationId); $this->assertFalse((bool) ConversationsUtil::hasUserReadConversationLatest($conversation, $super)); //Mark conversation as read $this->setGetArray(array('ajax' => 'list-view', 'modelClassName' => 'Conversation', 'MashableInboxForm' => array('massAction' => 'markRead', 'selectedIds' => $selectedIds))); $content = $this->runControllerWithNoExceptionsAndGetContent('mashableInbox/default/list'); $conversation = Conversation::getById($conversationId); $this->assertTrue((bool) ConversationsUtil::hasUserReadConversationLatest($conversation, $super)); //Mission model $mission = new Mission(); $mission->owner = $super; $mission->description = 'My test mission description'; $mission->status = Mission::STATUS_AVAILABLE; $this->assertTrue($mission->save()); $missionId = $mission->id; $this->assertTrue((bool) MissionsUtil::hasUserReadMissionLatest($mission, $super)); //Mark mission as unread $selectedIds = $missionId; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $this->setGetArray(array('ajax' => 'list-view', 'modelClassName' => 'Mission', 'MashableInboxForm' => array('massAction' => 'markUnread', 'selectedIds' => $selectedIds))); $content = $this->runControllerWithNoExceptionsAndGetContent('mashableInbox/default/list'); $mission = Mission::getById($missionId); $this->assertFalse((bool) MissionsUtil::hasUserReadMissionLatest($mission, $super)); //Mark mission as read $this->setGetArray(array('ajax' => 'list-view', 'modelClassName' => 'Mission', 'MashableInboxForm' => array('massAction' => 'markRead', 'selectedIds' => $selectedIds))); $content = $this->runControllerWithNoExceptionsAndGetContent('mashableInbox/default/list'); $mission = Mission::getById($missionId); $this->assertTrue((bool) MissionsUtil::hasUserReadMissionLatest($mission, $super)); }
public function hasCurrentUserReadLatest($modelId) { assert('$modelId > 0'); $modelClassName = $this->getModelClassName(); $model = $modelClassName::getById($modelId); return ConversationsUtil::hasUserReadConversationLatest($model, Yii::app()->user->userModel); }
/** * @depends testResolvePeopleOnConversation */ public function testResolvePeopleToSendNotificationToOnNewComment() { $super = Yii::app()->user->userModel; $jack = User::getByUsername('jack'); $steven = User::getByUsername('steven'); $conversation = new Conversation(); $conversation->owner = Yii::app()->user->userModel; $conversation->subject = 'Test People To Send Notification'; $conversation->description = 'This is a test conversation'; $peopleToSendNotification = ConversationsUtil::resolvePeopleToSendNotificationToOnNewComment($conversation, $super); $this->assertEquals(0, count($peopleToSendNotification)); $conversationParticipant = new ConversationParticipant(); $conversationParticipant->person = $jack; $conversation->conversationParticipants->add($conversationParticipant); $peopleToSendNotification = ConversationsUtil::resolvePeopleToSendNotificationToOnNewComment($conversation, $super); $this->assertEquals(1, count($peopleToSendNotification)); $this->assertEquals($jack, $peopleToSendNotification[0]); }