function display($tpl = null) { // Reset the stream view count every time we visit this page $doc = JFactory::getDocument(); $my = JXFactory::getUser(); $lastMessageId = StreamMessage::lastMessageId(); $groupView = StreamFactory::getView('groups'); $eventView = StreamFactory::getView('events'); // Side bar modules JXModule::addBuffer('right', $this->modTagsTrendingHTML()); if (!$my->isExtranetMember()) { JXModule::addBuffer('right', $groupView->getNewGroupsHTML($my->getMergedGroupIDs())); } JXModule::addBuffer('right', $eventView->getUpcomingHTML()); echo $this->getStreamPostHTML(); // Post box echo $this->getStreamDataHTML(); // Stream items }
<?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ ?> <tr> <td valign="top" style="background:#f9f9f9;font-size:14px;" width="50" > <img src="<?php echo $actor->getThumbAvatarURL(); ?> " alt="logo" style="display:block;border:3px solid #ffffff;outline:1px solid #ccc;margin:20px 0 0 20px;" width="50" height="50" /> </td> <td valign="top" style="background:#f9f9f9;font-size:14px;" width="20" > </td> <td valign="middle" style="background:#f9f9f9;font-size:14px;" width="538" > <p style="padding:0;margin:20px 20px 0 0;font-family:Helvetica,Geneva,sans-serif;"><strong><?php echo StreamMessage::formatShortDisplay($contentName, $linkOption); ?> </strong></p> <p style="margin:0;padding:0;font-size:13px;color:#777;"><?php echo JText::sprintf('COM_STREAM_POST_DETAIL', $actor->get('name'), $actor->get('designation'), JXDate::formatDate($date, $formatDateShort)); ?> </p> </td> </tr>
public static function sendFileReplaceNew() { $funcArgs = func_get_args(); // Get notification type from caller $notificationType = $funcArgs[0]; // Get the file table object from passed in parameter $fileTable = $funcArgs[1]; // Get the previous filename $previousFilename = $funcArgs[2]; if ($fileTable instanceof JTable) { // Get commentor $owner = JXFactory::getUser($fileTable->user_id); // Get Wall Post followers users $followers = $fileTable->followers; $userList = explode(',', $followers); $userList = self::groupUserByLanguage($userList, $fileTable->user_id, $notificationType); $messageUrl = StreamMessage::getMessageUri($fileTable->stream_id); $arrParam = array('fileTable' => $fileTable, 'previousFilename' => $previousFilename, 'owner' => $owner); $jConfig = new JConfig(); foreach ($userList as $language => $bccEmail) { self::loadLanguage($language); $bodyContent = self::getHeaderContent(JText::_('COM_STREAM_NOTIFICATION_FILE_REPLACE_NEW'), $messageUrl); $bodyContent .= self::getBodyContent('notification.file.replace', $arrParam); $bodyContent .= self::getFooterContent(); $subject = JText::sprintf('COM_STREAM_NOTIFICATION_FILE_REPLACE_NEW_SUBJECT', $owner->name); self::sendMail($jConfig->mailfrom, $jConfig->fromname, $jConfig->mailfrom, $subject, $bodyContent, $bccEmail); } } }
$doneTodo++; } ?> "> <a href="javascript: void(0);" data-message_id="<?php echo $task->id; ?> " data-type="list" data-todo_index="<?php echo $todoIndex; ?> " class="done-todo-item <?php echo $my->authorise('stream.todo.done', $task) ? '' : 'readonly'; ?> "></a> <span><?php echo StreamMessage::format($todo); ?> <?php if ($isDone) { ?> <span class="small hint"><?php echo $this->escape($doneBy->name); echo $doneOn; ?> </span><?php } ?> </span> </li> <?php $todoIndex++;
</ol> </div> <div class="data-grid"> <div class="content-title"> <h3>Links</h3> <a href="<?php echo JRoute::_('index.php?option=com_stream&view=links&user_id=' . $this->user->id); ?> ">Show All (<?php echo $this->linkCount; ?> )</a> </div> <ol class="content-list"> <?php foreach ($this->links as $link) { ?> <li><?php echo StreamMessage::format($link->link); ?> </li> <?php } ?> </ol> </div>
} ?> <?php if ($comment->id > $lastCommentView) { $my->setParam('group_' . $comment->group_id . '_comment', $comment->id); $my->save(); } ?> <a href="<?php echo $user->getURL(); ?> "><?php echo $this->escape($user->name); ?> </a> <?php echo StreamMessage::format($comment->comment); ?> <div class="comment-meta"> <span><?php echo JXDate::formatLapse($commentDate); ?> </span> <span style="<?php if ($commentLikeCount <= 0) { echo 'display: none;'; } ?> ">• <span class="comment-like"><?php echo $commentLikeCount; ?> </span></span>
* To change this template, choose Tools | Templates * and open the template in the editor. */ ?> <tr> <td valign="top" style="background:#f9f9f9;font-size:14px;" width="50" > <img src="<?php echo $actor->getThumbAvatarURL(); ?> " alt="logo" style="display:block;border:3px solid #ffffff;outline:1px solid #ccc;margin:20px 0 0 20px;" width="50" height="50" /> </td> <td valign="top" style="background:#f9f9f9;font-size:14px;" width="20" > </td> <td valign="middle" style="background:#f9f9f9;font-size:14px;" width="538" > <p style="padding:0;margin:20px 20px 0 0;font-family:Helvetica,Geneva,sans-serif;"><strong><?php echo StreamMessage::formatShortDisplay($todoName, $linkOption); ?> </strong></p> <p style="padding:0;margin:20px 20px 0 0;font-family:Helvetica,Geneva,sans-serif;">✔ <?php echo $todoItem; ?> </p> <?php $now = new JDate(); ?> <p style="margin:0;padding:0;font-size:13px;color:#777;"><?php echo JText::sprintf('COM_STREAM_POST_DETAIL', $actor->get('name'), $actor->get('designation'), JXDate::formatDate($now, $formatDateShort, $recipient)); ?> </p> </td> </tr>
?> "><?php echo StreamTemplate::escape(JHtmlString::abridge($row->filename, 32, 25)); ?> </a> <span class="small"> <?php $fext = strtolower(substr($row->filename, -4)); if ($jxConfig->isCrocodocsEnabled() || $jxConfig->isScribdEnabled()) { if (in_array($fext, array('.doc', 'docx', '.pdf', '.ppt', 'pptx'))) { echo ' <a href="javascript:void(0);" class="meta-preview small" data-message_id="' . $row->stream_id . '" data-filename="' . StreamTemplate::escape($row->filename) . '" data-file_id="' . $row->id . '" onclick="S.preview.show(this);">' . JText::_('COM_STREAM_LABEL_PREVIEW') . '</a>'; } } ?> (<?php echo StreamMessage::formatBytes($row->filesize); ?> ) </span> <div class="file-list-meta-content"> <div class="file-list-meta-inner"> <span>Attached in:</span> <a href="<?php echo $streamObj->getUri(); ?> "><?php echo StreamTemplate::escape(JHtmlString::truncate($streamObj->message, 200)); ?> </a> </div> <span class="uploader"><a href="<?php
</div> <p style="margin:0;padding:0;font-size:13px;color:#777;"><?php echo JText::sprintf('COM_STREAM_POST_DETAIL', $postOwner->get('name'), $postOwner->get('designation'), JXDate::formatDate($streamMessage->created, $formatDateShort)); ?> </p> </td> </tr> <tr> <td valign="top" style="background:#f9f9f9;font-size:14px;" width="50" > <img src="<?php echo $sender->getThumbAvatarURL(); ?> " alt="logo" style="display:block;border:3px solid #ffffff;outline:1px solid #ccc;margin:20px 0 0 20px;" width="50" height="50" /> </td> <td valign="top" style="background:#f9f9f9;font-size:14px;" width="10" > <div style="width:0;min-height:0;border-width:8px;border-style:solid;border-color:#f8fafb #3ea7af #f8fafb #f8fafb;margin-top:35px;"></div> </td> <td valign="middle" style="background:#f9f9f9;font-size:14px;" width="548" > <div id="topic" style="background:#3ea7af;padding:10px;color:#fefefe;display:block;margin:20px 20px 5px 0;"> <p style="padding:0;margin:0;font-style:italic;font-family:georgia,serif;">“ <?php echo StreamMessage::formatShortDisplay($messageComment->get('comment'), $linkOption); ?> ”</p> </div> <p style="margin:0;padding:0;font-size:13px;color:#777;"><?php echo JText::sprintf('COM_STREAM_POST_DETAIL', $sender->get('name'), $sender->get('designation'), JXDate::formatDate($messageComment->created, $formatDateShort)); ?> </p> </td> </tr>
<thead> <tr> <th class="file-name"><?php echo JText::_('COM_STREAM_LABEL_LINKS'); ?> </th> </tr> </thead> <tbody> <?php foreach ($links as $no => $row) { $user = JXFactory::getUser($row->user_ids); ?> <tr> <td> <?php echo $no + 1 . '. ' . StreamMessage::format($row->link); ?> </td> </tr> <?php } ?> </tbody> </table> <div class="pagination"> <?php echo $pagination->getPagesLinks(); ?> </div>
public function replaceNew() { $my = JXFactory::getUser(); $file_id = JRequest::getInt('file_id'); $file = JTable::getInstance('File', 'StreamTable'); $result = new stdClass(); $result->error = true; if (intval($file_id) > 0) { $file->load($file_id); $previousFilename = $file->filename; if ($file->user_id != $my->id) { continue; } require JPATH_ROOT . DS . 'components' . DS . 'com_stream' . DS . 'controllers' . DS . 'system.php'; $systemController = new StreamControllerSystem(); $result = $systemController->handleUpload(); if (isset($result['success']) && $result['success']) { // Get mime type if (function_exists('finfo_open')) { $finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension $file->mimetype = finfo_file($finfo, JPATH_ROOT . DS . $result['path']); finfo_close($finfo); } else { $file->mimetype = @mime_content_type(JPATH_ROOT . DS . $result['path']); } $newFileExt = array_pop(explode('.', $result['filename'])); $oldFileExt = array_pop(explode('.', $file->filename)); $file->filename = preg_replace('/\\.\\w+$/', '.' . $newFileExt, $file->filename); // Delete the old one before saving the new one to the file db entry if ($file->getParam('has_preview')) { JFile::delete(JPATH_ROOT . DS . $file->path); $pathinfo = pathinfo($file->path); $thumbPath = JPATH_ROOT . DS . $pathinfo['dirname'] . DS . $pathinfo['filename'] . '_thumb.jpg'; JFile::delete($thumbPath); $thumbPath = JPATH_ROOT . DS . $pathinfo['dirname'] . DS . $pathinfo['filename'] . '_preview.jpg'; JFile::delete($thumbPath); } // set the file entry to the new uploaded file $file->path = $result['path']; $file->filesize = filesize(JPATH_ROOT . DS . $file->path); $file->store(); // Trigger Mentioned Name Notification $notificationType = 'file_replace_new'; StreamNotification::trigger($notificationType, $file, $previousFilename); $result['filename'] = $file->filename; $result['newext'] = $newFileExt; $result['oldext'] = $oldFileExt; $result['filesize'] = '(' . StreamMessage::formatBytes($file->filesize) . ')'; if ($file->getParam('has_preview')) { $pathinfo = pathinfo($result['path']); $result['preview'] = JURI::root() . str_replace(DS, '/', $file->getParam('thumb_path')); } else { $result['preview'] = JURI::root(); } } } echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); exit; }
<tr> <td valign="top" style="background:#f9f9f9;font-size:14px;" width="50" > <img src="<?php echo $sender->getThumbAvatarURL(); ?> " alt="logo" style="display:block;border:3px solid #ffffff;outline:1px solid #ccc;margin:20px 0 0 20px;" width="50" height="50" /> </td> <td valign="top" style="background:#f9f9f9;font-size:14px;" width="10" > <div style="width:0;min-height:0;border-width:8px;border-style:solid;border-color:#f8fafb #dbf5f7 #f8fafb #f8fafb;margin-top:35px;"></div> </td> <td valign="middle" style="background:#f9f9f9;font-size:14px;" width="548" > <div id="topic" style="background:#dbf5f7;padding:10px;color:#333333;display:block;margin:20px 20px 5px 0;"> <p style="padding:0;margin:0;font-style:italic;font-family:georgia,serif;">“ <?php echo StreamMessage::formatShortDisplay($streamMessage->get('message'), $linkOption); ?> ”</p> </div> <p style="margin:0;padding:0;font-size:13px;color:#777;"><?php echo JText::sprintf('COM_STREAM_POST_DETAIL', $sender->get('name'), $sender->get('designation'), JXDate::formatDate($streamMessage->created, $formatDateShort)); ?> </p> </td> </tr>
/** * Return attachment view for the given stream */ public static function getAttachmentHTML($stream) { $my = JXFactory::getUser(); $data = json_decode($stream->raw); $html = ''; if (!function_exists('whoMakesAction')) { /** * Call this function to retrieve the item/message viewer * @param JTable $stream the current StreamTable * @param int $item_id the owner of the item (for example: id of the file or id of a message contains a link) * @param String $type type of the item (since tracking is done by id, being specific is safer. eg: file_220, link_220) */ function whoMakesAction($stream, $item_id = 0, $type = NULL) { // get list of avatar who viewed the stream $whoMakesAction = $stream->whoMakesAction($item_id, $type); $avatarListWhoMakeAction = ''; if ($whoMakesAction && count($whoMakesAction) > 0) { // Do rename the variable if its too long or easily mistyped $avatarListWhoMakeAction .= '<div class="user-horizontal-list message-reader-list">'; if ($type == 'video') { // change language from READ to SEEN if its a video $avatarListWhoMakeAction .= '<span class="small">' . JText::_('COM_STREAM_LABEL_SEEN_BY') . ' '; } else { $avatarListWhoMakeAction .= '<span class="small">' . JText::_('COM_STREAM_LABEL_READ_BY') . ' '; } /* $avatarListWhoMakeAction .= count($whoMakesAction) . ' reader'; */ $avatarListWhoMakeAction .= '<a href="#showReaders" data-content="<ul>'; foreach ($whoMakesAction as $user_id) { // there will be 0 as user which in return will load current user if ($user_id != 0 && $user_id != NULL) { $user = JXFactory::getUser($user_id); $avatarListWhoMakeAction .= StreamTemplate::escape('<li><a href="' . $user->getURL() . '">' . $user->name . '</a></li>'); } } $avatarListWhoMakeAction .= '</ul>">'; $label = count($whoMakesAction) > 1 ? JText::_('COM_STREAM_LABEL_USERS') : JText::_('COM_STREAM_LABEL_USER'); $avatarListWhoMakeAction .= count($whoMakesAction) . " {$label}</a>"; $avatarListWhoMakeAction .= '</span></div>'; } return $avatarListWhoMakeAction; } } // Attachment $jxConfig = new JXConfig(); $files = $stream->getFiles(); $hasPreview = false; $numPreview = 0; // Sort the files, photos at the bottom usort($files, array('StreamMessage', 'sortAttachment')); $imgHtml = '<div class="message-content-attachment">'; foreach ($files as $file) { // only show if the file does exist // @todo: templatize this ? $dlLink = JRoute::_('index.php?option=com_stream&view=system&task=download&file_id=' . $file->id); // Show file name only if preview doesn't exist // Otherwise, just show the preview. People can click on the preview and download it from tehre if (!$file->getParam('has_preview')) { // Show preview link, of if the filename is doc, docx, pdf, ppt, pptx $fext = strtolower(substr($file->filename, -4)); $html .= '<div data-filename="' . $file->filename . '" ' . 'data-message_id=' . $stream->id . ' class="message-content-file ">'; $html .= '<a title="Click to download" href="' . $dlLink . '">' . StreamTemplate::escape(JHtmlString::abridge($file->filename, 20, 13)) . '</a>'; $html .= ' <span class="small hint">(' . StreamMessage::formatBytes($file->filesize, 1) . ')</span>'; // append to file container only once if ($jxConfig->isCrocodocsEnabled() || $jxConfig->isScribdEnabled()) { if (in_array($fext, array('.doc', 'docx', '.pdf', '.ppt', 'pptx'))) { $html .= ' <a href="#preview" class="meta-preview small" data-filename="' . StreamTemplate::escape($file->filename) . '" data-file_id="' . $file->id . '" onclick="return S.preview.show(this);">' . JText::_('COM_STREAM_LABEL_PREVIEW') . '</a>'; } } $html .= whoMakesAction($stream, $file->id, 'file'); $html .= '<div class="clear"></div>'; $html .= '</div>'; /* // File can only be remove in 'edit' view if( $my->authorise('stream.message.edit', $stream) ){ $html .= '<a class="meta-edit" href="#removeAttachment" file_id="'.$file->id.'">'. JText::_('COM_STREAM_LABEL_REMOVE').'</a>'; } */ } if ($file->getParam('has_preview')) { $randId = 'preview_' . rand(1000, 9999); $path = str_replace(DS, '/', $file->getParam('thumb_path')); $imgHtml .= '<div class="message-content-preview"><img rel="#' . $randId . '" src="' . JURI::root() . $path . '" /></div>'; // Attach overlay code $width = $file->getParam('width'); $height = $file->getParam('height'); if (!empty($width) && !empty($height)) { if ($width > 640) { $height = 640 / $width * $height; $width = 640; } if ($height > 640) { $width = 640 / $height * $width; $height = 640; } $viewLink = JRoute::_('index.php?option=com_stream&view=system&task=download&file_id=' . $file->id . '&display=1'); $dlLink = JRoute::_('index.php?option=com_stream&view=system&task=download&file_id=' . $file->id); // Replace all <show_next> tag, since the previous one is clearly not the last one $imgHtml = str_replace('<show_next>', '<div class="image_next btn btn-large" onclick="$(\'[rel=\\\'#' . $randId . '\\\']\').click();">→</div>', $imgHtml); $imgHtml .= ' <div id="' . $randId . '" class="apple_overlay" style="width:' . $width . 'px">'; // IF this is NOT the first preview, add the 'PREV' button if ($numPreview != 0) { $imgHtml .= '<div class="image_prev btn btn-large" onclick="$(\'[rel=\\\'#' . $prevRandId . '\\\']\').click();">←</div>'; } $imgSrc = $dlLink; if ($file->getParam('preview_path')) { $imgSrc = str_replace(DS, '/', $file->getParam('preview_path')); $imgSrc = JURI::root() . $imgSrc; } $imgHtml .= '<show_next> <a class="close"></a> <img width="' . $width . '" height="' . $height . '" src="' . $imgSrc . '" /> <div> <a href="' . $viewLink . '" target="_blank">View full-size image</a> • <a href="' . $dlLink . '">Download</a></div> </div>'; $prevRandId = $randId; $hasPreview = true; $numPreview++; } } } $imgHtml .= '</div>'; // If there is no attachement at all, remove the div $imgHtml = str_replace('<div class="message-content-attachment"></div>', '', $imgHtml); $html .= $imgHtml; // If we have added the preview, which is left floated, we need to add a clearing div // the sorting function above will make sure that preview'ed would be the last attachment if ($hasPreview) { // Get rid of all the <show_next> marker $html = str_replace('<show_next>', '', $html); $html .= '<div class="clear"></div>'; } // Videos if (!empty($data->video)) { foreach ($data->video as $videoid) { $video = JTable::getInstance('Video', 'StreamTable'); if ($video->load($videoid)) { $html .= '<div class="message-content-video" id="video-' . $videoid . '"> <img class="message-content-video-thumbnail interactive" src="' . $video->thumb . '" embed_id="' . $videoid . '" embed_type="videos"/> <span class="video-duration">' . StreamMessage::formatDuration($video->duration) . '</span> <div class="message-content-preview-desc"> <div class="preview-title">' . JHtmlString::truncate($video->title, 24) . '</div> <div class="preview-desc">' . JHtmlString::truncate($video->description, 180) . '</div> </div><div class="clear"></div>' . whoMakesAction($stream, $video->id, 'video') . ' <div class="clear"></div> </div>'; } } } // Slideshare if (!empty($data->slideshare)) { foreach ($data->slideshare as $slideshareid) { $slideshare = JTable::getInstance('Slideshare', 'StreamTable'); if ($slideshare->load($slideshareid)) { $ss = json_decode($slideshare->response); $html .= '<div class="message-content-video slideshare" id="video-' . $slideshareid . '"> <img src="' . $ss->thumbnail . '" embed_id="' . $slideshareid . '" embed_type="slideshare"/> <span class="video-duration"></span> <div class="message-content-preview-desc"> <div class="preview-title">' . JHtmlString::truncate($ss->title, 24) . '</div> <div class="preview-desc">' . JHtmlString::truncate($ss->author_name, 180) . '</div> </div><div class="clear"></div>' . whoMakesAction($stream, $slideshareid, 'slideshare') . ' <div class="clear"></div> </div>'; } } } /* Link service * Certain link will able to store excerpt from the linked page */ $params = json_decode($stream->params); /* refetch if the link is not grab yet */ $url = self::getLinks($stream->message); if (!empty($url[0])) { $linkTable = JTable::getInstance('Link', 'StreamTable'); if ($linkTable->load(array('link' => $url[0]))) { $linkParam = StreamLinks::format($linkTable->params); if (!empty($linkParam) && strlen($linkParam->text) > 0) { $html .= '<div class="stream-message-links-in-post">'; if ($linkParam->media_type && $linkParam->media_link) { if (strlen($linkParam->media_type == 'image' && $linkParam->media_link) > 0) { $html .= '<div class="stream-links-image-container"> <span> <img class="stream-message-links-image" src="' . StreamLinks::imageAssetThumbnailPath($linkParam->media_link) . '" /> </span> </div>'; } } $html .= '<div class="stream-links-container"> <div class="stream-message-links-title">' . $linkParam->title . '</div> <div class="stream-message-links-url">' . $linkParam->url . '</div> <div class="stream-message-links-content">' . $linkParam->text . '</div>' . '</div><div class="clear"></div>' . whoMakesAction($stream, $stream->id, 'link') . ' <div class="clear"></div> </div>'; } } } return $html; }
<div class="moduletable"> <h3><?php echo $title; ?> </h3> <?php if (!empty($files)) { ?> <ul class="reset file-list"> <?php foreach ($files as $file) { $dlLink = JRoute::_('index.php?option=com_stream&view=system&task=download&file_id=' . $file->id); echo '<li data-filename="' . $file->filename . '" class="message-content-file">'; echo '<a title="Click to download" href="' . $dlLink . '">' . StreamTemplate::escape(JHtmlString::truncate($file->filename, 24)) . '</a>'; echo ' <span class="small hint">(' . StreamMessage::formatBytes($file->filesize, 1) . ')</span>'; echo '</li>'; } ?> </ul> <?php if ($total > count($files)) { if (!empty($group)) { $allLink = JRoute::_('index.php?option=com_stream&view=groups&task=show_files&group_id=' . $group->id); } else { $allLink = JRoute::_('index.php?option=com_stream&view=files&user_id=' . $user->id); } ?> <!-- more files than meet the eyes --> <span><a href="<?php echo $allLink; ?>
foreach ($readBy as $recipientId) { $readByUsers[] = JXFactory::getUser($recipientId)->name; } echo implode(', ', $readByUsers); ?> <?php } ?> </span> </div> </li> <li class="inbox-delete"> <a href="" class="close">×</a> </li> <?php if (!empty($attachments)) { echo '<li style="border-top: 1px solid #EFEFEF; width: 540px; margin-left: 40px;">'; foreach ($attachments as $attachment) { $dlLink = JRoute::_('index.php?option=com_messaging&task=download&file_id=' . $attachment->id); $html = '<div class="message-content-file ">'; $html .= '<a title="Click to download" href="' . $dlLink . '">' . StreamTemplate::escape(JHtmlString::abridge($attachment->filename, 16)) . '</a>'; $html .= ' <span class="small hint">(' . StreamMessage::formatBytes($attachment->filesize, 1) . ')</span>'; $html .= '</div>'; echo $html; } echo '</li>'; } ?> </ul> </li>
/** * Delete a message */ public function delete() { $my = JXFactory::getUser(); $message_id = JRequest::getVar('message_id'); $stream = JTable::getInstance('Stream', 'StreamTable'); $stream->load($message_id); if (!$my->authorise('stream.message.delete', $stream)) { // No reason this code would ever get here! exit; } // Remove trending tags data $tagsTrend = new StreamTag(); $rawData = json_decode($stream->raw); $rawData->tags = isset($rawData->tags) ? $rawData->tags : ''; $tagsArray = explode(',', trim($rawData->tags, ',')); foreach ($tagsArray as $tag) { // trim hashes $tag = trim($tag, '#'); // remove trending data $tagsTrend->updateTrending($tag, $stream->group_id, false); } $stream->delete(); // Delete related comments StreamComment::deleteComments($message_id); // Unattach all files $user = JXFactory::getUser($stream->user_id); $links = StreamMessage::getLinks($stream->message); if (!empty($links)) { $userLinks = $user->getParam('links'); foreach ($links as $row) { $link = JTable::getInstance('Link', 'StreamTable'); $link->load(array('link' => $row)); $link->removeUser($user->id); $link->store(); $userLinks = JXUtility::csvRemove($userLinks, $link->id); } $user->setParam('links', $userLinks); $user->save(); } // @todo: delete attachments // Upgrade group stats if necessary if (JRequest::getVar('group_id')) { $group = JTable::getInstance('Group', 'StreamTable'); $group->load(JRequest::getVar('group_id')); $group->setParam('message_count', $streamModel->countStream(array('group_id' => $group->id))); $group->setParam($stream->type . '_count', $streamModel->countStream(array('group_id' => $group->id, 'type' => $stream->type))); $group->store(); } $data = array(); $data['id'] = $message_id; header('Content-Type: text/json'); echo json_encode($data); exit; }
<div class="clear"></div> </div> <?php } ?> <!-- Secondary Toolbar --> <div id="secondToolbar" class="altToolbar"> <ul> <!-- company stream --> <li class="iconHome iconSecondary<?php if ($option == 'com_stream' && $view == 'company') { echo ' active'; $lastMessageId = StreamMessage::lastMessageId(); $my->setParam('message_last_read', $lastMessageId); $my->save(); } ?> "> <a href="<?php echo JRoute::_('index.php?option=com_stream&view=company'); ?> "><?php echo JText::_('NAVIGATOR_LABEL_HOME'); ?> </a> <?php if ($count > 0) { ?>
if (!empty($files)) { foreach ($files as $file) { ?> <li style="list-style: none outside none;margin-left:0px;padding-left: 8px;" class="qq-upload-success"> <div data-filename="<?php echo $file->filename; ?> " class="message-content-file" file_id="<?php echo $file->id; ?> "> <?php echo StreamTemplate::escape(JHtmlString::abridge($file->filename, 24)); ?> <span class="small hint">(<?php echo StreamMessage::formatBytes($file->filesize, 1); ?> )</span> <a file_id="<?php echo $file->id; ?> " href="#unlinkAttachment" class="meta-edit">Remove</a> <input type="hidden" value="<?php echo $file->id; ?> " name="attachment[]"> </div> </li> <?php } }
/** * Return */ public function modGetPendingTask($inFilter) { $tasks = ''; $tmpl = new StreamTemplate(); $model = StreamFactory::getModel('stream'); $my = JXFactory::getUser(); // Get todo list with due date $filter = array(); $filter['type'] = 'todo'; $filter['has_end_date'] = true; $filter['order_by_asc'] = 'end_date'; $filter = array_merge($filter, $inFilter); $data = $model->getStream($filter); // calculate total task $hasWarnDue = false; $hasWarnToday = false; $hasWarnThisWeek = false; $hasWarnLater = false; $username = ''; $showName = JRequest::getVar('option') == 'com_stream'; $today = new JXDate(); //echo count($data); exit; foreach ($data as $stream) { $dueDate = new JDate($stream->end_date); $raw = json_decode($stream->raw); $todoIndex = 0; $class = $my->authorise('stream.todo.done', $stream) ? '' : 'readonly'; foreach ($raw->todo as $todo) { if (!empty($todo)) { if (!$stream->getState($todoIndex)) { // Put the due labels if ($today->isOverdue($dueDate)) { if (!$hasWarnDue) { $tasks .= '<li class="todo-overdue"><span class="label label-important">' . JText::_('COM_PROFILE_LABEL_OVERDUE') . '</span></li>'; $hasWarnDue = true; } } elseif ($today->isToday($dueDate)) { if (!$hasWarnToday) { $tasks .= '<li class="todo-today"><span class="label label-success">' . JText::_('COM_PROFILE_LABEL_TODAY') . '</span></li>'; $hasWarnToday = true; } } elseif ($today->isThisWeek($dueDate)) { if (!$hasWarnThisWeek) { $tasks .= '<li class="todo-thisweek"><span class="label label-warning">' . JText::_('COM_PROFILE_LABEL_THIS_WEEK') . '</span></li>'; $hasWarnThisWeek = true; } } elseif (!$hasWarnLater) { $tasks .= '<li class="todo-later"><span class="label">' . JText::_('COM_PROFILE_LABEL_LATER') . '</span></li>'; $hasWarnLater = true; } // end due labels if ($showName) { $username = '******' . StreamTemplate::escape(JXFactory::getUser($stream->user_id)->name) . '</span>'; } $tasks .= '<li class="clearfix todo-item"><a class="done-todo-item ' . $class . '" data-message_id="' . $stream->id . '" data-todo_index="' . $todoIndex . '" href="javascript: void(0);"></a><span>' . StreamMessage::format($todo) . $username . '</span></li>'; } $todoIndex++; } } } // Get todo with NO due date unset($filter); $filter = array(); $filter['type'] = 'todo'; $filter['!has_end_date'] = true; $filter['order_by_asc'] = 'id'; $filter = array_merge($filter, $inFilter); $data = $model->getStream($filter); $hasWarnAnytime = false; foreach ($data as $stream) { $raw = json_decode($stream->raw); $todoIndex = 0; foreach ($raw->todo as $todo) { if (!empty($todo)) { $class = $my->authorise('stream.todo.done', $stream) ? '' : 'readonly'; if (!$stream->getState($todoIndex)) { if (!$hasWarnAnytime) { $tasks .= '<li class="todo-anytime"><span class="label">' . JText::_('COM_PROFILE_LABEL_ANYTIME') . '</span></li>'; $hasWarnAnytime = true; } if ($showName) { $username = '******' . StreamTemplate::escape(JXFactory::getUser($stream->user_id)->name) . '</span>'; } $tasks .= '<li class="clearfix todo-item"><a class="done-todo-item ' . $class . '" data-message_id="' . $stream->id . '" data-todo_index="' . $todoIndex . '" href="javascript:void(0);"></a><span>' . StreamMessage::format($todo) . $username . '</span></li>'; } $todoIndex++; } } } if (empty($tasks)) { $tasks = '<div class="alert-message block-message info"><p>' . JText::_('COM_STREAM_LABEL_NO_PENDING_TASK') . '</p></div>'; } $tmpl->set('tasks', $tasks); return $tmpl->fetch('todo.module.pending'); }
?> class="complete-todo" id="complete_<?php echo $milestone->id; ?> " data-status="<?php echo $milestone->status; ?> "/> <?php } ?> <span><a href="<?php echo $milestone->getUri(); ?> "><?php echo StreamMessage::format($milestone->message); ?> </a></span> </div> <?php if ($milestoneStatus != COMPLETED) { ?> <div class="progress progress-info progress-striped" milestone="<?php echo $milestone->id; ?> "> <div class="bar" style="width: <?php echo $milestone->getParam('progress', 0); ?> %;"></div>
?> </a> <span style="font-size: 16px;"> › </span> <?php echo implode($members, ', '); ?> </div> <div class="direct-content-message"> <div class="autoShorten"> <?php echo StreamMessage::format($stream->message); ?> </div> <div class="clear"></div> <div class="message-content"> <?php echo StreamMessage::getAttachmentHTML($stream); ?> </div> </div> </div> <div class="direct-date"> <?php echo JXDate::formatLapse($date); ?> </div> <div class="clear"></div> <div> <ul class="replies"> <li id="message_<?php echo $stream->id; ?>
public function notification() { $my = JXFactory::getUser(); $data = array(); // No notification for guest. Trigger a logout in user's browser if (!$my->id) { $data['logout'] = true; echo json_encode($data); exit; } include_once JPATH_LIBRARIES . DS . 'joomla' . DS . 'html' . DS . 'html' . DS . 'string.php'; $phash = JRequest::getVar('pHash'); // public data cache hash $data['notification'] = array(); $data['comments'] = array(); $data['updates'] = array(); // Get my groups $streamModel = StreamFactory::getModel('stream'); $groupsModel = StreamFactory::getModel('groups'); $groupIJoin = $my->getParam('groups_member'); $groupIFollow = $my->getParam('groups_follow'); $myGroups = JXUtility::csvMerge($groupIFollow, $groupIJoin); $myGroups = $groupsModel->getGroups(array('id' => $myGroups)); // Get public notices $lastMessageRead = $my->getParam('message_last_read'); $publicCount = StreamMessage::countMessageSince($lastMessageRead); $data['notification']['company_updates'] = $publicCount; // we can merge this request with the group request so that template are fetched on the same loop but the group content is unique to each group // @todo: optimize the whole request $publicMessageContents = $streamModel->getStream(array('group_id' => 0), $publicCount); $publicMessagesHTML = '<ul>'; foreach ($publicMessageContents as $row) { $tmpl = new StreamTemplate(); $tmpl->set('stream', $row); $publicMessagesHTML .= $tmpl->fetch('notification.message'); $data['updates'][0]['message_id'][] = $row->id; } $publicMessagesHTML .= '</ul>'; $data['data_content'][0] = $publicMessagesHTML; $data['updates'][0]['name'] = 'public'; $data['updates'][0]['notification'] = $publicCount; $data['updates'][0]['content'] = $publicMessagesHTML; // @todo: this is kinda heavy. Optimize further. Otherwise the live update // will kill us $updatedGroups = array(); $updatedGroupsComment = array(); foreach ($myGroups as $group) { $lastReadId = $my->getParam('group_' . $group->id . '_read'); $lastCommentId = $my->getParam('group_' . $group->id . '_comment'); $groupLastMsg = $group->getParam('last_message'); $groupLastComment = $group->getParam('last_comment'); $groupNewMsg = $streamModel->countStream(array('!user_id' => $my->id, 'id_more' => $lastReadId, 'group_id' => $group->id)); $groupNewComment = $streamModel->countComments(array('group_id' => $group->id, 'id_more' => $lastCommentId)); // // the array key is the same as html id element of the <span> that // will take this value $data['notification']['groups_' . $group->id] = intval($groupNewMsg); // rand ( 0 , 20 ); $data['comments']['groups_' . $group->id] = intval($groupNewComment); // rand ( 0 , 20 ); $data['updates'][$group->id]['name'] = $group->name; $data['updates'][$group->id]['notification'] = intval($groupNewMsg); $data['updates'][$group->id]['comments'] = intval($groupNewComment); // Add popover data if ($groupNewMsg > 0) { $updatedGroups[] = $group; } if ($groupNewComment > 0) { $updatedGroupsComment[] = $group; } } // Get the popover data if necessary // This is done saperately to give opportunity for caching if (md5(serialize($data['notification']) . serialize($data['comments'])) != $phash) { if (!empty($updatedGroups)) { foreach ($updatedGroups as $group) { $limit = $data['notification']['groups_' . $group->id]; $newMessages = $streamModel->getStream(array('group_id' => $group->id), $limit); $newMessagesHTML = '<ul>'; foreach ($newMessages as $row) { $tmpl = new StreamTemplate(); $tmpl->set('stream', $row); $newMessagesHTML .= $tmpl->fetch('notification.message'); } $newMessagesHTML .= '</ul>'; $data['data_content']['#groups_' . $group->id . '_link'] = $newMessagesHTML; $data['updates'][$group->id]['content'] = $newMessagesHTML; } } /* if(!empty($updatedGroupsComment)){ foreach($updatedGroupsComment as $group) { $data['data_comment']['#groups_'.$group->id.'_link'] = ''; } } */ } if ($phash == md5(serialize($data['notification']) . serialize($data['comments']))) { $data['data_content'] = array(); $data['notification'] = array(); $data['comments'] = array(); $data['updates'] = array(); } $data['pHash'] = md5(serialize($data['notification']) . serialize($data['comments'])); header('Content-Type: text/json'); echo json_encode($data); exit; }