Gets a nice title to represent the participants in a conversation.
public static participantTitle ( array | object $Conversation, boolean $Html = true, integer $Max = 3 ) : string | ||
$Conversation | array | object | The conversation to get the participants for. |
$Html | boolean | Whether or not to return HTML. |
$Max | integer | The maximum number of participants to show in the list. |
return | string | Returns a title for the conversation. |
$CssClass .= $Conversation->CountNewMessages > 0 ? ' New' : ''; $CssClass .= $LastPhoto != '' ? ' HasPhoto' : ''; $CssClass .= ' ' . ($Conversation->CountNewMessages <= 0 ? 'Read' : 'Unread'); $JumpToItem = $Conversation->CountMessages - $Conversation->CountNewMessages; $Message = sliceString(Gdn_Format::plainText($Conversation->LastBody, $Conversation->LastFormat), 100); if (stringIsNullOrEmpty(trim($Message))) { $Message = t('Blank Message'); } $this->EventArguments['Conversation'] = $Conversation; ?> <li class="<?php echo $CssClass; ?> "> <?php $Names = ConversationModel::participantTitle($Conversation, false); ?> <div class="ItemContent Conversation"> <?php $Url = '/messages/' . $Conversation->ConversationID . '/#Item_' . $JumpToItem; echo '<h3 class="Users">'; if ($Names) { if ($LastPhoto) { echo '<div class="Author Photo">' . $LastPhoto . '</div>'; } echo anchor(htmlspecialchars($Names), $Url); } if ($Subject = val('Subject', $Conversation)) { if ($Names) { echo Bullet(' '); }
/** * Shows all uncleared messages within a conversation for the viewing user * * @since 2.0.0 * @access public * * @param int $ConversationID Unique ID of conversation to view. * @param int $Offset Number to skip. * @param int $Limit Number to show. */ public function index($ConversationID = false, $Offset = -1, $Limit = '') { $this->Offset = $Offset; $Session = Gdn::session(); Gdn_Theme::section('Conversation'); // Figure out Conversation ID if (!is_numeric($ConversationID) || $ConversationID < 0) { $ConversationID = 0; } // Form setup for adding comments $this->Form->setModel($this->ConversationMessageModel); $this->Form->addHidden('ConversationID', $ConversationID); // Check permissions on the recipients. $InConversation = $this->ConversationModel->inConversation($ConversationID, Gdn::session()->UserID); if (!$InConversation) { // Conversation moderation must be enabled and they must have permission if (!c('Conversations.Moderation.Allow', false)) { throw permissionException(); } $this->permission('Conversations.Moderation.Manage'); } $this->Conversation = $this->ConversationModel->getID($ConversationID); $this->Conversation->Participants = $this->ConversationModel->getRecipients($ConversationID); $this->setData('Conversation', $this->Conversation); // Bad conversation? Redirect if ($this->Conversation === false) { throw notFoundException('Conversation'); } // Get limit if ($Limit == '' || !is_numeric($Limit) || $Limit < 0) { $Limit = Gdn::config('Conversations.Messages.PerPage', 50); } // Calculate counts if (!is_numeric($this->Offset) || $this->Offset < 0) { // Round down to the appropriate offset based on the user's read messages & messages per page $CountReadMessages = $this->Conversation->CountMessages - $this->Conversation->CountNewMessages; if ($CountReadMessages < 0) { $CountReadMessages = 0; } if ($CountReadMessages > $this->Conversation->CountMessages) { $CountReadMessages = $this->Conversation->CountMessages; } // (((67 comments / 10 perpage) = 6.7) rounded down = 6) * 10 perpage = offset 60; $this->Offset = floor($CountReadMessages / $Limit) * $Limit; // Send the hash link in. if ($CountReadMessages > 1) { $this->addDefinition('LocationHash', '#Item_' . $CountReadMessages); } } // Fetch message data $this->MessageData = $this->ConversationMessageModel->get($ConversationID, $Session->UserID, $this->Offset, $Limit); $this->EventArguments['MessageData'] = $this->MessageData; $this->fireEvent('beforeMessages'); $this->setData('Messages', $this->MessageData); // Figure out who's participating. $ParticipantTitle = ConversationModel::participantTitle($this->Conversation, true); $this->Participants = $ParticipantTitle; $this->title(strip_tags($this->Participants)); // $CountMessages = $this->ConversationMessageModel->getCount($ConversationID, $Session->UserID); // Build a pager $PagerFactory = new Gdn_PagerFactory(); $this->Pager = $PagerFactory->getPager('MorePager', $this); $this->Pager->MoreCode = 'Newer Messages'; $this->Pager->LessCode = 'Older Messages'; $this->Pager->ClientID = 'Pager'; $this->Pager->configure($this->Offset, $Limit, $this->Conversation->CountMessages, 'messages/' . $ConversationID . '/%1$s/%2$s/'); // Mark the conversation as ready by this user. $this->ConversationModel->markRead($ConversationID, $Session->UserID); // Deliver json data if necessary if ($this->_DeliveryType != DELIVERY_TYPE_ALL) { $this->setJson('LessRow', $this->Pager->toString('less')); $this->setJson('MoreRow', $this->Pager->toString('more')); $this->View = 'messages'; } // Add modules. $ClearHistoryModule = new ClearHistoryModule($this); $ClearHistoryModule->conversationID($ConversationID); $this->addModule($ClearHistoryModule); $InThisConversationModule = new InThisConversationModule($this); $InThisConversationModule->setData($this->Conversation->Participants); $this->addModule($InThisConversationModule); // Doesn't make sense for people who can't even start conversations to be adding people if (checkPermission('Conversations.Conversations.Add')) { $this->addModule('AddPeopleModule'); } $Subject = $this->data('Conversation.Subject'); if (!$Subject) { $Subject = t('Message'); } $this->Data['Breadcrumbs'][] = array('Name' => $Subject, 'Url' => url('', '//')); // Render view $this->render(); }
if (checkPermission('Conversations.Conversations.Add')) { echo anchor(t('New Message'), 'messages/add'); } echo wrap(t('Inbox'), 'strong'); ?> </li> <?php if (count($this->data('Conversations'))) { ?> <?php foreach ($this->data('Conversations') as $Row) { $Subject = ''; if ($Row['Subject']) { $Subject = Gdn_Format::text($Row['Subject']); } else { $Subject = ConversationModel::participantTitle($Row, false); } $PhotoUser = userBuilder($Row, 'LastInsert'); ?> <li class="Item" rel="<?php echo url("/messages/{$Row['ConversationID']}#Message_{$Row['LastMessageID']}"); ?> "> <div class="Author Photo"><?php echo userPhoto($PhotoUser); ?> </div> <div class="ItemContent"> <b class="Subject"><?php echo anchor($Subject, "/messages/{$Row['ConversationID']}#Message_{$Row['LastMessageID']}"); ?>