本文整理汇总了PHP中DiscussHelper::formatConversations方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussHelper::formatConversations方法的具体用法?PHP DiscussHelper::formatConversations怎么用?PHP DiscussHelper::formatConversations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussHelper
的用法示例。
在下文中一共展示了DiscussHelper::formatConversations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Loads a list of new messages via ajax.
*
* @since 3.0
* @access public
* @param null
*/
public function load()
{
$my = JFactory::getUser();
$ajax = DiscussHelper::getHelper('Ajax');
$config = DiscussHelper::getConfig();
if ($my->id <= 0 || !$config->get('main_conversations_notification') || !$config->get('main_conversations')) {
$ajax->fail(JText::_('COM_EASYDISCUSS_NOT_ALLOWED'));
return;
}
// @TODO: Show only x amount of items
// Get a list of conversations to be displayed in the drop down.
$model = DiscussHelper::getModel('Conversation');
$conversations = $model->getConversations($my->id, array('limit' => $config->get('main_conversations_notification_items')));
// Format messages
DiscussHelper::formatConversations($conversations);
$theme = new DiscussThemes();
$theme->set('conversations', $conversations);
$output = $theme->fetch('toolbar.conversation.item.php');
$ajax->success($output);
}
示例2: read
/**
* Displays the conversation.
*
* @since 3.0
* @access public
*/
public function read()
{
$id = JRequest::getInt('id');
$app = JFactory::getApplication();
$my = JFactory::getUser();
// Do not allow non logged in users to view anything in conversation.
if (!$my->id) {
$returnURL = base64_encode(JRequest::getURI());
//DiscussHelper::setMessageQueue( JText::_( 'COM_EASYDISCUSS_NOT_ALLOWED' ) , DISCUSS_QUEUE_ERROR );
//$app->redirect( DiscussRouter::_( 'index.php?option=com_easydiscuss&view=index' , false ) );
$app->redirect(DiscussHelper::getLoginLink($returnURL));
$app->close();
}
// Try to load the conversation
$conversation = DiscussHelper::getTable('Conversation');
$state = $conversation->load($id);
// The conversation id needs to be valid.
if (!$state) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_CONVERSATION_INVALID'), DISCUSS_QUEUE_ERROR);
$app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false));
$app->close();
}
// Check if the current logged in user has access to this conversation.
$model = DiscussHelper::getModel('Conversation');
if (!$model->hasAccess($conversation->id, $my->id)) {
DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_NOT_ALLOWED'), DISCUSS_QUEUE_ERROR);
$app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false));
$app->close();
}
$doc = JFactory::getDocument();
$result = $conversation->getParticipants($my->id);
$user = DiscussHelper::getTable('Profile');
$user->load($result[0]);
DiscussHelper::setPageTitle(JText::sprintf('COM_EASYDISCUSS_VIEW_CONVERSATION_TITLE', $this->escape($user->getName())));
// Mark this message as read for the current logged in user.
$conversation->markAsRead($my->id);
// Check if it is view all messages
$viewAll = JRequest::getVar('show');
$count = JRequest::getInt('count');
if ($viewAll == 'all') {
// For future use
$count = '';
}
if ($viewAll == 'previous') {
$count = JRequest::getInt('count');
// Check if the value is integer, we do no want any weird values
if (isset($count) && is_int($count)) {
// Convert to absolute number
$count = abs($count);
}
}
// Get replies in the conversation
$replies = $model->getMessages($conversation->id, $my->id, $viewAll, $count);
// Format conversation replies.
DiscussHelper::formatConversationReplies($replies);
// Format the conversation object.
$data = array($conversation);
DiscussHelper::formatConversations($data);
$theme = new DiscussThemes();
$theme->set('replies', $replies);
$theme->set('conversation', $data[0]);
echo $theme->fetch('conversation.read.php');
}