Ejemplo n.º 1
0
 /**
  * Ajax function to save a new wall entry
  *
  * @param message    A message that is submitted by the user
  * @param uniqueId    The unique id for this group
  *
  * */
 public function ajaxSaveWall($message, $uniqueId, $appId = null, $photoId = 0)
 {
     $filter = JFilterInput::getInstance();
     $message = $filter->clean($message, 'string');
     $uniqueId = $filter->clean($uniqueId, 'int');
     $appId = $filter->clean($appId, 'int');
     $photoId = $filter->clean($photoId, 'int');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $json = array();
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $message = strip_tags($message);
     $photo = JTable::getInstance('Photo', 'CTable');
     $photo->load($uniqueId);
     $album = JTable::getInstance('Album', 'CTable');
     $album->load($photo->albumid);
     $handler = $this->_getHandler($album);
     if (!$handler->isWallsAllowed($photo->id)) {
         echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_POST_COMMENT');
         return;
     }
     // If the content is false, the message might be empty.
     if (empty($message) && $photoId == 0) {
         $json['error'] = JText::_('COM_COMMUNITY_WALL_EMPTY_MESSAGE');
     } else {
         // @rule: Spam checks
         if ($config->get('antispam_akismet_walls')) {
             $filter = CSpamFilter::getFilter();
             $filter->setAuthor($my->getDisplayName());
             $filter->setMessage($message);
             $filter->setEmail($my->email);
             $filter->setURL(CRoute::_('index.php?option=com_community&view=photos&task=photo&albumid=' . $photo->albumid) . '&photoid=' . $photo->id);
             $filter->setType('message');
             $filter->setIP($_SERVER['REMOTE_ADDR']);
             if ($filter->isSpam()) {
                 $json['error'] = JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM');
                 die(json_encode($json));
             }
         }
         $wall = CWallLibrary::saveWall($uniqueId, $message, 'photos', $my, $my->id == $photo->creator, 'photos,photo', 'wall/content', 0, $photoId);
         $url = $photo->getRawPhotoURI();
         $param = new CParameter('');
         $param->set('photoid', $uniqueId);
         $param->set('action', 'wall');
         $param->set('wallid', $wall->id);
         $param->set('url', $url);
         // Get the album type
         $app = $album->type;
         // Add activity logging based on app's type
         $permission = $this->_getAppPremission($app, $album);
         /**
          * We don't need to check for permission to create activity
          * Activity will follow album privacy
          * @since 3.2
          */
         if ($app == 'user' || $app == 'group') {
             $group = JTable::getInstance('Group', 'CTable');
             $group->load($album->groupid);
             $event = null;
             $this->_addActivity('photos.wall.create', $my->id, 0, '', $message, 'photos.comment', $uniqueId, $group, $event, $param->toString(), $permission);
         }
         // Add notification
         $params = new CParameter('');
         $params->set('url', $photo->getRawPhotoURI());
         $params->set('message', CUserHelper::replaceAliasURL($message));
         $params->set('photo', JText::_('COM_COMMUNITY_SINGULAR_PHOTO'));
         $params->set('photo_url', $url);
         // @rule: Send notification to the photo owner.
         if ($my->id !== $photo->creator) {
             CNotificationLibrary::add('photos_submit_wall', $my->id, $photo->creator, JText::sprintf('COM_COMMUNITY_PHOTO_WALL_EMAIL_SUBJECT'), '', 'photos.wall', $params);
         } else {
             //for activity reply action
             //get relevent users in the activity
             $wallModel = CFactory::getModel('wall');
             $users = $wallModel->getAllPostUsers('photos', $photo->id, $photo->creator);
             if (!empty($users)) {
                 CNotificationLibrary::add('photos_reply_wall', $my->id, $users, JText::sprintf('COM_COMMUNITY_PHOTO_WALLREPLY_EMAIL_SUBJECT'), '', 'photos.wallreply', $params);
             }
         }
         //email and add notification if user are tagged
         $info = array('type' => 'image-comment', 'album_id' => $album->id, 'image_id' => $photo->id);
         CUserHelper::parseTaggedUserNotification($message, CFactory::getUser($photo->creator), $wall, $info);
         // Add user points
         CUserPoints::assignPoint('photos.wall.create');
         // Log user engagement
         CEngagement::log('photo.comment', $my->id);
         $json['success'] = true;
         $json['html'] = $wall->content;
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES));
     die(json_encode($json));
 }
Ejemplo n.º 2
0
 /**
  * Return formatted comment given the wall item
  */
 public static function formatComment($wall)
 {
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     $actModel = CFactory::getModel('activities');
     $like = new CLike();
     $likeCount = $like->getLikeCount('comment', $wall->id);
     $isLiked = $like->userLiked('comment', $wall->id, $my->id);
     $user = CFactory::getUser($wall->post_by);
     // Censor if the user is banned
     if ($user->block) {
         $wall->comment = $origComment = JText::_('COM_COMMUNITY_CENSORED');
     } else {
         // strip out the comment data
         $CComment = new CComment();
         $wall->comment = $CComment->stripCommentData($wall->comment);
         // Need to perform basic formatting here
         // 1. support nl to br,
         // 2. auto-link text
         $CTemplate = new CTemplate();
         $wall->comment = $origComment = $CTemplate->escape($wall->comment);
         $wall->comment = CStringHelper::autoLink($wall->comment);
     }
     $commentsHTML = '';
     $commentsHTML .= '<div class="cComment wall-coc-item" id="wall-' . $wall->id . '"><a href="' . CUrlHelper::userLink($user->id) . '"><img src="' . $user->getThumbAvatar() . '" alt="" class="wall-coc-avatar" /></a>';
     $date = new JDate($wall->date);
     $commentsHTML .= '<a class="wall-coc-author" href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a> ';
     $commentsHTML .= $wall->comment;
     $commentsHTML .= '<span class="wall-coc-time">' . CTimeHelper::timeLapse($date);
     $cid = isset($wall->contentid) ? $wall->contentid : null;
     $activity = $actModel->getActivity($cid);
     $ownPost = $my->id == $wall->post_by;
     $allowRemove = $my->authorise('community.delete', 'walls', $wall);
     $canEdit = $config->get('wallediting') && $my->id == $wall->post_by || COwnerHelper::isCommunityAdmin();
     // only poster can edit
     if ($allowRemove) {
         $commentsHTML .= ' <span class="wall-coc-remove-link">&#x2022; <a href="#removeComment">' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</a></span>';
     }
     $commentsHTML .= '</span>';
     $commentsHTML .= '</div>';
     $editHTML = '';
     if ($config->get('wallediting') && $ownPost || COwnerHelper::isCommunityAdmin()) {
         $editHTML .= '<a href="javascript:" class="joms-button--edit">';
         $editHTML .= '<svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="' . CRoute::getURI() . '#joms-icon-pencil"></use></svg>';
         $editHTML .= '<span>' . JText::_('COM_COMMUNITY_EDIT') . '</span>';
         $editHTML .= '</a>';
     }
     $removeHTML = '';
     if ($allowRemove) {
         $removeHTML .= '<a href="javascript:" class="joms-button--remove">';
         $removeHTML .= '<svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="' . CRoute::getURI() . '#joms-icon-remove"></use></svg>';
         $removeHTML .= '<span>' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</span>';
         $removeHTML .= '</a>';
     }
     $removeTagHTML = '';
     if (CActivitiesHelper::hasTag($my->id, $wall->comment)) {
         $removeTagHTML = '<span><a data-action="remove-tag" data-id="' . $wall->id . '" href="javascript:">' . JText::_('COM_COMMUNITY_WALL_REMOVE_TAG') . '</a></span>';
     }
     /* user deleted */
     if ($user->guest == 1) {
         $userLink = '<span class="cStream-Author">' . $user->getDisplayName() . '</span> ';
     } else {
         $userLink = '<a class="cStream-Avatar cStream-Author cFloat-L" href="' . CUrlHelper::userLink($user->id) . '"> <img class="cAvatar" src="' . $user->getThumbAvatar() . '"> </a> ';
     }
     $params = $wall->params;
     $paramsHTML = '';
     $image = (array) $params->get('image');
     $photoThumbnail = false;
     if ($params->get('attached_photo_id') > 0) {
         $photo = JTable::getInstance('Photo', 'CTable');
         $photo->load($params->get('attached_photo_id'));
         $photoThumbnail = $photo->getThumbURI();
         $paramsHTML .= '<div style="padding: 5px 0"><img class="joms-stream-thumb" src="' . $photoThumbnail . '" /></div>';
     } else {
         if ($params->get('title')) {
             $video = self::detectVideo($params->get('url'));
             if (is_object($video)) {
                 $paramsHTML .= '<div class="joms-media--video joms-js--video"';
                 $paramsHTML .= ' data-type="' . $video->type . '"';
                 $paramsHTML .= ' data-id="' . $video->id . '"';
                 $paramsHTML .= ' data-path="' . ($video->type === 'file' ? JURI::root(true) . '/' : '') . $video->path . '"';
                 $paramsHTML .= ' style="margin-top:10px;">';
                 $paramsHTML .= '<div class="joms-media__thumbnail">';
                 $paramsHTML .= '<img src="' . $video->getThumbnail() . '">';
                 $paramsHTML .= '<a href="javascript:" class="mejs-overlay mejs-layer mejs-overlay-play joms-js--video-play joms-js--video-play-' . $wall->id . '">';
                 $paramsHTML .= '<div class="mejs-overlay-button"></div>';
                 $paramsHTML .= '</a>';
                 $paramsHTML .= '</div>';
                 $paramsHTML .= '<div class="joms-media__body">';
                 $paramsHTML .= '<h4 class="joms-media__title">' . JHTML::_('string.truncate', $video->title, 50, true, false) . '</h4>';
                 $paramsHTML .= '<p class="joms-media__desc">' . JHTML::_('string.truncate', $video->description, $config->getInt('streamcontentlength'), true, false) . '</p>';
                 $paramsHTML .= '</div>';
                 $paramsHTML .= '</div>';
             } else {
                 $paramsHTML .= '<div class="joms-gap"></div>';
                 $paramsHTML .= '<div class="joms-media--album joms-relative joms-js--comment-preview">';
                 if ($user->id == $my->id || COwnerHelper::isCommunityAdmin()) {
                     $paramsHTML .= '<span class="joms-media__remove" data-action="remove-preview" onClick="joms.api.commentRemovePreview(\'' . $wall->id . '\');"><svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="#joms-icon-remove"></use></svg></span>';
                 }
                 if ($params->get('image')) {
                     $paramsHTML .= $params->get('link');
                     $paramsHTML .= '<div class="joms-media__thumbnail">';
                     $paramsHTML .= '<a href="' . $params->get('link') ? $params->get('link') : '#' . '">';
                     $paramsHTML .= '<img src="' . array_shift($image) . '" />';
                     $paramsHTML .= '</a>';
                     $paramsHTML .= '</div>';
                 }
                 $url = $params->get('url') ? $params->get('url') : '#';
                 $paramsHTML .= '<div class="joms-media__body">';
                 $paramsHTML .= '<a href="' . $url . '">';
                 $paramsHTML .= '<h4 class="joms-media__title">' . $params->get('title') . '</h4>';
                 $paramsHTML .= '<p class="joms-media__desc reset-gap">' . CStringHelper::trim_words($params->get('description')) . '</p>';
                 if ($params->get('link')) {
                     $paramsHTML .= '<span class="joms-text--light"><small>' . preg_replace('#^https?://#', '', $params->get('link')) . '</small></span>';
                 }
                 $paramsHTML .= '</a></div></div>';
             }
         }
     }
     if (!$params->get('title') && $params->get('url')) {
         $paramsHTML .= '<div class="joms-gap"></div>';
         $paramsHTML .= '<div class="joms-media--album">';
         $paramsHTML .= '<a href="' . $params->get('url') . '">';
         $paramsHTML .= '<img class="joms-stream-thumb" src="' . $params->get('url') . '" />';
         $paramsHTML .= '</a>';
         $paramsHTML .= '</div>';
     }
     $wall->comment = nl2br($wall->comment);
     $wall->comment = CUserHelper::replaceAliasURL($wall->comment);
     $wall->comment = CStringHelper::getEmoticon($wall->comment);
     $wall->comment = CStringHelper::converttagtolink($wall->comment);
     // convert to hashtag
     $template = new CTemplate();
     $template->set('wall', $wall)->set('originalComment', $origComment)->set('date', $date)->set('isLiked', $isLiked)->set('likeCount', $likeCount)->set('canRemove', $allowRemove)->set('canEdit', $canEdit)->set('canRemove', $allowRemove)->set('user', $user)->set('photoThumbnail', $photoThumbnail)->set('paramsHTML', $paramsHTML);
     $commentsHTML = $template->fetch('stream/single-comment');
     return $commentsHTML;
 }
Ejemplo n.º 3
0
/**
 * Deprecated since 1.8
 * Use CUserHelper::replaceAliasURL instead.
 */
function cGenerateUserAliasLinks($message)
{
    return CUserHelper::replaceAliasURL($message);
}
Ejemplo n.º 4
0
 public function ajaxRemoveUserTag($id, $type = 'comment')
 {
     $my = CFactory::getUser();
     if ($my->id == 0) {
         $this->ajaxBlockUnregister();
     }
     // Remove tag.
     $updatedMessage = CApiActivities::removeUserTag($id, $type);
     $origValue = $updatedMessage;
     $value = CStringHelper::autoLink($origValue);
     $value = nl2br($value);
     $value = CUserHelper::replaceAliasURL($value);
     $value = CStringHelper::getEmoticon($value);
     $json = array('success' => true, 'unparsed' => $origValue, 'data' => $value);
     die(json_encode($json));
 }
Ejemplo n.º 5
0
 public function send($vars)
 {
     $db = $this->getDBO();
     $my = CFactory::getUser();
     // @todo: user db table later on
     //$cDate = JFactory::getDate(gmdate('Y-m-d H:i:s'), $mainframe->getCfg('offset'));//get the current date from system.
     //$date	= cGetDate();
     $date = JFactory::getDate();
     //get the time without any offset!
     $cDate = $date->toSql();
     $obj = new stdClass();
     $obj->id = null;
     $obj->from = $my->id;
     $obj->posted_on = $date->toSql();
     $obj->from_name = $my->name;
     $obj->subject = $vars['subject'];
     $obj->body = $vars['body'];
     $body = new JRegistry();
     $body->set('content', CUserHelper::replaceAliasURL($obj->body));
     // photo attachment
     if (isset($vars['photo'])) {
         $photoId = $vars['photo'];
         if ($photoId > 0) {
             //lets check if the photo belongs to the uploader
             $photo = JTable::getInstance('Photo', 'CTable');
             $photo->load($photoId);
             if ($photo->creator == $my->id && $photo->albumid == '-1') {
                 $body->set('attached_photo_id', $photoId);
                 //sets the status to ready so that it wont be deleted on cron run
                 $photo->status = 'ready';
                 $photo->store();
             }
         }
     }
     /**
      * @since 3.2.1
      * Message URL fetching
      */
     if (preg_match("/\\b(?:(?:https?|ftp):\\/\\/|www\\.)[-a-z0-9+&@#\\/%?=~_|!:,.;]*[-a-z0-9+&@#\\/%=~_|]/i", $obj->body)) {
         $graphObject = CParsers::linkFetch($obj->body);
         if ($graphObject) {
             $graphObject->merge($body);
             $obj->body = $graphObject->toString();
         }
     } else {
         $obj->body = $body->toString();
     }
     // Don't add message if user is sending message to themselve
     if ($vars['to'] != $my->id) {
         $db->insertObject('#__community_msg', $obj, 'id');
         // Update the parent
         $obj->parent = $obj->id;
         $db->updateObject('#__community_msg', $obj, 'id');
     }
     if (is_array($vars['to'])) {
         //multiple recepint
         foreach ($vars['to'] as $sToId) {
             if ($vars['to'] != $my->id) {
                 $this->addReceipient($obj, $sToId);
             }
         }
     } else {
         //single recepient
         if ($vars['to'] != $my->id) {
             $this->addReceipient($obj, $vars['to']);
         }
     }
     return $obj->id;
 }
Ejemplo n.º 6
0
 public function ajaxeditComment($id, $value, $photoId = 0)
 {
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     $actModel = CFactory::getModel('activities');
     $objResponse = new JAXResponse();
     $json = array();
     if ($my->id == 0) {
         $this->blockUnregister();
     }
     $wall = JTable::getInstance('wall', 'CTable');
     $wall->load($id);
     $cid = isset($wall->contentid) ? $wall->contentid : null;
     $activity = $actModel->getActivity($cid);
     $ownPost = $my->id == $wall->post_by;
     $targetPost = $activity->target == $my->id;
     $allowEdit = COwnerHelper::isCommunityAdmin() || ($ownPost || $targetPost) && !empty($my->id);
     $value = trim($value);
     if (empty($value)) {
         $json['error'] = JText::_('COM_COMMUNITY_CANNOT_EDIT_COMMENT_ERROR');
     } else {
         if ($config->get('wallediting') && $allowEdit) {
             $params = new CParameter($wall->params);
             //if photo id is not 0, this wall is appended with a picture
             if ($photoId > 0 && $params->get('attached_photo_id') != $photoId) {
                 //lets check if the photo belongs to the uploader
                 $photo = JTable::getInstance('Photo', 'CTable');
                 $photo->load($photoId);
                 if ($photo->creator == $my->id && $photo->albumid == '-1') {
                     $params->set('attached_photo_id', $photoId);
                     //sets the status to ready so that it wont be deleted on cron run
                     $photo->status = 'ready';
                     $photo->store();
                 }
             } else {
                 if ($photoId == -1) {
                     //if there is nothing, remove the param if applicable
                     //delete from db and files
                     $photoModel = CFactory::getModel('photos');
                     $photoTable = $photoModel->getPhoto($params->get('attached_photo_id'));
                     $photoTable->delete();
                     $params->set('attached_photo_id', 0);
                 }
             }
             $wall->params = $params->toString();
             $wall->comment = $value;
             $wall->store();
             $CComment = new CComment();
             $value = $CComment->stripCommentData($value);
             // Need to perform basic formatting here
             // 1. support nl to br,
             // 2. auto-link text
             $CTemplate = new CTemplate();
             $value = $origValue = $CTemplate->escape($value);
             $value = CStringHelper::autoLink($value);
             $value = nl2br($value);
             $value = CUserHelper::replaceAliasURL($value);
             $value = CStringHelper::getEmoticon($value);
             $json['comment'] = $value;
             $json['originalComment'] = $origValue;
             // $objResponse->addScriptCall("joms.jQuery('div[data-commentid=" . $id . "] .cStream-Content span.comment').html", $value);
             // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] [data-type=stream-comment-editor] textarea").val', $origValue);
             // $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] [data-type=stream-comment-editor] textarea").removeData', 'initialized');
             // if ($photoId == -1) {
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-thumb").parent().remove', '');
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-attachment").css("display", "none").attr("data-no_thumb", 1);');
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-thumbnail").html', '<img/>');
             // } else if ($photoId != 0) {
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-fetch-wrapper").remove', '');
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-thumb").parent().remove', '');
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] [data-type=stream-comment-content] .cStream-Meta").before', '<div style="padding: 5px 0"><img class="joms-stream-thumb" src="' . JUri::root(true) ."/". $photo->thumbnail . '" /></div>');
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-stream-attachment").css("display", "block").removeAttr("data-no_thumb");');
             //     $objResponse->addScriptCall('joms.jQuery("div[data-commentid=' . $id . '] .joms-thumbnail img").attr("src", "' . JUri::root(true) ."/". $photo->thumbnail . '").attr("data-photo_id", "0").data("photo_id", 0);');
             // }
         } else {
             $json['error'] = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_EDIT');
         }
     }
     if (!isset($json['error'])) {
         $json['success'] = true;
     }
     die(json_encode($json));
 }
Ejemplo n.º 7
0
 /**
  * Show the message reading window
  */
 public function read($data)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     if (!$this->accessAllowed('registered')) {
         return;
     }
     $config = CFactory::getConfig();
     if (!$config->get('enablepm')) {
         echo JText::_('COM_COMMUNITY_PRIVATE_MESSAGING_DISABLED');
         return;
     }
     //page title
     $document = JFactory::getDocument();
     $inboxModel = CFactory::getModel('inbox');
     $my = CFactory::getUser();
     $msgid = $jinput->request->get('msgid', 0, 'INT');
     if (!$inboxModel->canRead($my->id, $msgid)) {
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_PERMISSION_DENIED_WARNING'), 'error');
         return;
     }
     $pathway = $mainframe->getPathway();
     $pathway->addItem($this->escape(JText::_('COM_COMMUNITY_INBOX_TITLE')), CRoute::_('index.php?option=com_community&view=inbox'));
     $parentData = '';
     $html = '';
     $messageHeading = '';
     $recipient = array();
     $parentData = $inboxModel->getMessage($msgid);
     if (!empty($data->messages)) {
         $document = JFactory::getDocument();
         $pathway->addItem($this->escape(htmlspecialchars_decode($parentData->subject)));
         $document->setTitle(htmlspecialchars_decode($parentData->subject));
         require_once COMMUNITY_COM_PATH . '/libraries/apps.php';
         $appsLib = CAppPlugins::getInstance();
         $appsLib->loadApplications();
         $config = CFactory::getConfig();
         $pagination = intval($config->get('stream_default_comments', 5));
         $count = count($data->messages);
         $hide = true;
         foreach ($data->messages as $row) {
             $count--;
             if ($count < $pagination) {
                 $hide = false;
             }
             // onMessageDisplay Event trigger
             $args = array();
             $originalBodyContent = $row->body;
             $row->body = new JRegistry($row->body);
             if ($row->body == '{}') {
                 //backward compatibility, save the old data into content parameter if needed
                 $newParam = new CParameter();
                 $newParam->set('content', $originalBodyContent);
                 $table = JTable::getInstance('Message', 'CTable');
                 $table->load($row->id);
                 $table->body = $newParam->toString();
                 $table->store();
                 $row->body = new CParameter($table->body);
             }
             // Escape content
             $content = $originalContent = $row->body->get('content');
             $content = CTemplate::escape($content);
             $content = CStringHelper::autoLink($content);
             $content = nl2br($content);
             $content = CStringHelper::getEmoticon($content);
             $content = CStringHelper::converttagtolink($content);
             $content = CUserHelper::replaceAliasURL($content);
             $params = $row->body;
             $args[] = $row;
             $appsLib->triggerEvent('onMessageDisplay', $args);
             $user = CFactory::getUser($row->from);
             //construct the delete link
             $deleteLink = CRoute::_('index.php?option=com_community&view=inbox&task=remove&msgid=' . $row->id);
             $authorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id);
             //get thumbnail if available
             $photoThumbnail = '';
             if ($params->get('attached_photo_id')) {
                 $photo = JTable::getInstance('Photo', 'CTable');
                 $photo->load($params->get('attached_photo_id'));
                 $photoThumbnail = $photo->getThumbURI();
             }
             $tmpl = new CTemplate();
             $html .= $tmpl->set('user', $user)->set('msg', $row)->set('hide', $hide)->set('originalContent', $originalContent)->set('content', $content)->set('params', $params)->set('isMine', COwnerHelper::isMine($my->id, $user->id))->set('removeLink', $deleteLink)->set('authorLink', $authorLink)->set('photoThumbnail', $photoThumbnail)->fetch('inbox.message');
         }
         $myLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id);
         $recipient = $inboxModel->getRecepientMessage($msgid);
         $recepientCount = count($recipient);
         $textOther = $recepientCount > 1 ? 'COM_COMMUNITY_MSG_OTHER' : 'COM_COMMUNITY_MSG_OTHER_SINGULAR';
         $messageHeading = JText::sprintf('COM_COMMUNITY_MSG_BETWEEN_YOU_AND_USER', $myLink, '#', JText::sprintf($textOther, $recepientCount));
     } else {
         $html = '<div class="text">' . JText::_('COM_COMMUNITY_INBOX_MESSAGE_EMPTY') . '</div>';
     }
     //end if
     $tmplMain = new CTemplate();
     echo $tmplMain->set('messageHeading', $messageHeading)->set('recipient', $recipient)->set('limit', $pagination)->set('messages', $data->messages)->set('parentData', $parentData)->set('htmlContent', $html)->set('my', $my)->set('submenu', $this->showSubmenu(false))->fetch('inbox.read');
 }
Ejemplo n.º 8
0
            $groupname = CStringHelper::escape($groupPost[0]->groupname);
            $grouplink = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId);
            ?>

    	    <h4><?php 
            echo $groupname;
            ?>
</h4>

            	<?php 
            foreach ($groupPost as $post_info) {
                $user = CFactory::getUser($post_info->actor);
                $comment = CComment::stripCommentData($post_info->title);
                $comment = JString::substr($comment, 0, $charactersCount);
                $comment .= $charactersCount > JString::strlen($comment) ? '' : '...';
                $comment = CUserHelper::replaceAliasURL($comment);
                ?>
            	<div class="joms-stream__header wide ">
            		<div class= "joms-avatar--stream">
                        <a title="<?php 
                echo $user->getDisplayName();
                ?>
" href="<?php 
                echo CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id);
                ?>
">
            				<img src="<?php 
                echo $user->getThumbAvatar();
                ?>
" alt="<?php 
                echo $groupname;
							<?php 
        echo $discussion['created_interval'];
        ?>
						</small>
					</span>
				</div>
			</div>
			<div class="joms-stream__body">
				<?php 
        // Escape content
        $discussion['comment'] = CTemplate::escape($discussion['comment']);
        $discussion['comment'] = CStringHelper::autoLink($discussion['comment']);
        $discussion['comment'] = nl2br($discussion['comment']);
        $discussion['comment'] = CStringHelper::getEmoticon($discussion['comment']);
        $discussion['comment'] = CStringHelper::converttagtolink($discussion['comment']);
        $discussion['comment'] = CUserHelper::replaceAliasURL($discussion['comment']);
        echo substr($discussion['comment'], 0, 250);
        if (strlen($discussion['comment']) > 250) {
            echo ' ...';
        }
        // @TODO: DRY
        $video = JTable::getInstance('Video', 'CTable');
        if ($video->init($params->get('url'))) {
            $video->isValid();
        } else {
            $video = false;
        }
        if (is_object($video)) {
            ?>
                    <div class="joms-media--video joms-js--video"
                            data-type="<?php 
    //break if it has more than 3
    ?>
                <li class="joms-list__item">
                    <a  href="<?php 
    echo CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $disc->groupid . '&topicid=' . $disc->id);
    ?>
">
                        <?php 
    echo $disc->title;
    ?>
                    </a>
                    <?php 
    if ($disc->lastmessage != null) {
        ?>
                    <span class="joms-block"><?php 
        echo JHTML::_('string.truncate', CUserHelper::replaceAliasURL($disc->lastmessage, false, true), 150);
        ?>
</span>
                    <?php 
    }
    ?>
                    <div class="joms-text--light joms-text--small">
                        <a href="<?php 
    echo CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $disc->groupid . '&topicid=' . $disc->id);
    ?>
">
                            <?php 
    echo JText::sprintf(CStringHelper::isPlural($disc->count) ? 'COM_COMMUNITY_TOTAL_REPLIES_MANY' : 'COM_COMMUNITY_GROUPS_DISCUSSION_REPLY_COUNT', $disc->count);
    ?>
                        </a>
Ejemplo n.º 11
0
 /**
  * Update the status of current user
  */
 public function ajaxUpdate($message = '')
 {
     $filter = JFilterInput::getInstance();
     $message = $filter->clean($message, 'string');
     $cache = CFactory::getFastCache();
     $cache->clean(array('activities'));
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $objResponse = new JAXResponse();
     //@rule: In case someone bypasses the status in the html, we enforce the character limit.
     $config = CFactory::getConfig();
     if (JString::strlen($message) > $config->get('statusmaxchar')) {
         $message = JHTML::_('string.truncate', $message, $config->get('statusmaxchar'));
     }
     //trim it here so that it wun go into activities stream.
     $message = JString::trim($message);
     $my = CFactory::getUser();
     $status = $this->getModel('status');
     // @rule: Spam checks
     if ($config->get('antispam_akismet_status')) {
         //CFactory::load( 'libraries' , 'spamfilter' );
         $filter = CSpamFilter::getFilter();
         $filter->setAuthor($my->getDisplayName());
         $filter->setMessage($message);
         $filter->setEmail($my->email);
         $filter->setURL(CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
         $filter->setType('message');
         $filter->setIP($_SERVER['REMOTE_ADDR']);
         if ($filter->isSpam()) {
             $objResponse->addAlert(JText::_('COM_COMMUNITY_STATUS_MARKED_SPAM'));
             return $objResponse->sendResponse();
         }
     }
     $status->update($my->id, $message);
     //set user status for current session.
     $today = JFactory::getDate();
     $message2 = empty($message) ? ' ' : $message;
     $my->set('_status', $message2);
     $my->set('_posted_on', $today->toSql());
     $profileid = $jinput->get->get('userid', 0, 'INT');
     //JRequest::getVar('userid' , 0 , 'GET');
     if (COwnerHelper::isMine($my->id, $profileid)) {
         $objResponse->addScriptCall("joms.jQuery('#profile-status span#profile-status-message').html('" . addslashes($message) . "');");
     }
     //CFactory::load( 'helpers' , 'string' );
     // $message		= CStringHelper::escape( $message );
     if (!empty($message)) {
         $act = new stdClass();
         $act->cmd = 'profile.status.update';
         $act->actor = $my->id;
         $act->target = $my->id;
         //CFactory::load( 'helpers' , 'linkgenerator' );
         // @rule: Autolink hyperlinks
         $message = CLinkGeneratorHelper::replaceURL($message);
         // @rule: Autolink to users profile when message contains @username
         $message = CUserHelper::replaceAliasURL($message);
         $privacyParams = $my->getParams();
         $act->title = $message;
         $act->content = '';
         $act->app = 'profile';
         $act->cid = $my->id;
         $act->access = $privacyParams->get('privacyProfileView');
         $act->comment_id = CActivities::COMMENT_SELF;
         $act->comment_type = 'profile.status';
         $act->like_id = CActivities::LIKE_SELF;
         $act->like_type = 'profile.status';
         //add user points
         //CFactory::load( 'libraries' , 'userpoints' );
         if (CUserPoints::assignPoint('profile.status.update')) {
             //only assign act if user points is set to true
             CActivityStream::add($act);
         }
         //now we need to reload the activities streams (since some report regarding update status from hello me we disabled update the stream, cuz hellome usually called  out from jomsocial page)
         $friendsModel = CFactory::getModel('friends');
         $memberSince = CTimeHelper::getDate($my->registerDate);
         $friendIds = $friendsModel->getFriendIds($my->id);
         //include_once(JPATH_COMPONENT .'/libraries/activities.php');
         $act = new CActivityStream();
         $params = $my->getParams();
         $limit = !empty($params) ? $params->get('activityLimit', '') : '';
         //$html	= $act->getHTML($my->id, $friendIds, $memberSince, $limit );
         $status = $my->getStatus();
         $status = str_replace(array("\r\n", "\n", "\r"), "", $status);
         $status = addslashes($status);
         // also update hellome module if available
         $script = "joms.jQuery('.joms-js--mod-hellome-label').html('" . $status . "');";
         $script .= "joms.jQuery('.joms-js--mod-hellome-loading').hide();";
         $objResponse->addScriptCall($script);
     }
     return $objResponse->sendResponse();
 }
Ejemplo n.º 12
0
" 
                        alt=""
                        <?php 
            echo $params->get('show_image', 2) == 1 ? 'data-author="' . $comment->post_by . '"' : '';
            ?>
                         />
                    </a>
                </div>
            <?php 
        }
        ?>


                <div class="joms-stream__meta">
                    "<?php 
        echo CUserHelper::replaceAliasURL(CStringHelper::escape($comment->comment), false, true);
        ?>
" by
                    <a href="<?php 
        echo CRoute::_('index.php?option=com_community&view=profiles&userid=' . $comment->post_by);
        ?>
"><?php 
        echo CFactory::getUser($comment->post_by)->getDisplayName();
        ?>
</a>
                    <div class="joms-text--light"><small><?php 
        echo $createdTime;
        ?>
</small></div>

                </div>
Ejemplo n.º 13
0
 /**
  * @param $message    A message that is submitted by the user
  * @param $uniqueId    The unique id for this group
  * @param int $photoId
  */
 public function ajaxSaveWall($message, $uniqueId, $photoId = 0)
 {
     $filter = JFilterInput::getInstance();
     $uniqueId = $filter->clean($uniqueId, 'int');
     $photoId = $filter->clean($photoId, 'int');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $response = new JAXResponse();
     $json = array();
     $my = CFactory::getUser();
     $video = JTable::getInstance('Video', 'CTable');
     $video->load($uniqueId);
     // If the content is false, the message might be empty.
     if (empty($message) && $photoId == 0) {
         $json['error'] = JText::_('COM_COMMUNITY_WALL_EMPTY_MESSAGE');
     } else {
         $config = CFactory::getConfig();
         // @rule: Spam checks
         if ($config->get('antispam_akismet_walls')) {
             //CFactory::load( 'libraries' , 'spamfilter' );
             $filter = CSpamFilter::getFilter();
             $filter->setAuthor($my->getDisplayName());
             $filter->setMessage($message);
             $filter->setEmail($my->email);
             $filter->setURL(CRoute::_('index.php?option=com_community&view=videos&task=video&videoid=' . $uniqueId));
             $filter->setType('message');
             $filter->setIP($_SERVER['REMOTE_ADDR']);
             if ($filter->isSpam()) {
                 $json['error'] = JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM');
                 die(json_encode($json));
             }
         }
         //CFactory::load( 'libraries' , 'wall' );
         $wall = CWallLibrary::saveWall($uniqueId, $message, 'videos', $my, $my->id == $video->creator, 'videos,video', 'wall/content', 0, $photoId);
         // Add activity logging
         $url = $video->getViewUri(false);
         $params = new CParameter('');
         $params->set('videoid', $uniqueId);
         $params->set('action', 'wall');
         $params->set('wallid', $wall->id);
         $params->set('video_url', $url);
         $act = new stdClass();
         $act->cmd = 'videos.wall.create';
         $act->actor = $my->id;
         $act->access = $video->permissions;
         $act->target = 0;
         $act->title = JText::sprintf('COM_COMMUNITY_VIDEOS_ACTIVITIES_WALL_POST_VIDEO', '{video_url}', $video->title);
         $act->app = 'videos.comment';
         $act->cid = $uniqueId;
         $act->params = $params->toString();
         $act->groupid = $video->groupid;
         $act->eventid = $video->eventid;
         CActivityStream::add($act);
         // Add notification
         //CFactory::load( 'libraries' , 'notification' );
         $params = new CParameter('');
         $params->set('url', $url);
         $params->set('message', CUserHelper::replaceAliasURL($message));
         $params->set('video', $video->title);
         $params->set('video_url', $url);
         if ($my->id !== $video->creator) {
             CNotificationLibrary::add('videos_submit_wall', $my->id, $video->creator, JText::sprintf('COM_COMMUNITY_VIDEO_WALL_EMAIL_SUBJECT'), '', 'videos.wall', $params);
         } else {
             //for activity reply action
             //get relevent users in the activity
             $wallModel = CFactory::getModel('wall');
             $users = $wallModel->getAllPostUsers('videos', $video->id, $video->creator);
             if (!empty($users)) {
                 CNotificationLibrary::add('videos_reply_wall', $my->id, $users, JText::sprintf('COM_COMMUNITY_VIDEO_WALLREPLY_EMAIL_SUBJECT'), '', 'videos.wallreply', $params);
             }
         }
         //email and add notification if user are tagged
         $info = array('type' => 'video-comment', 'video_id' => $video->id);
         CUserHelper::parseTaggedUserNotification($message, CFactory::getUser($video->creator), $wall, $info);
         // Add user points
         CUserPoints::assignPoint('videos.comment');
         //@since 4.1 we dump the info into photo stats
         $statsModel = CFactory::getModel('stats');
         $statsModel->addVideoStats($video->id, 'comment');
         // Log user engagement
         CEngagement::log('video.comment', $my->id);
         $json['html'] = $wall->content;
         $json['success'] = true;
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES));
     die(json_encode($json));
 }
Ejemplo n.º 14
0
 /**
  * General purpose stream formatting function
  */
 public static function format($str, $mood = null)
 {
     // Some database actually already stored some URL already linked! Such as @mention format
     // To handle this, we strip to to the base format. and apply the linking later
     $str = preg_replace('|@<a href="(.*?)".*>(.*)</a>|', '@${2}', $str);
     //Strip html href tag
     $str = preg_replace('|<a href="(.*?)".*>(.*)</a>|', '${1}', $str);
     // Escape it first
     $str = CStringHelper::escape(rtrim(str_replace('&nbsp;', '', $str)));
     $str = str_replace('&amp;quot;', '"', $str);
     // Autolink url
     $str = CStringHelper::autoLink($str);
     // Nl2Br
     $str = nl2br($str);
     // Autolinked username
     $str = CUserHelper::replaceAliasURL($str);
     $str = CStringHelper::getEmoticon($str);
     $str = CStringHelper::getMood($str, $mood);
     $str = CStringHelper::converttagtolink($str);
     return $str;
 }
Ejemplo n.º 15
0
 /**
  * General purpose stream formatting function
  */
 public static function format($str, $mood = null)
 {
     // Some database actually already stored some URL already linked! Such as @mention format
     // To handle this, we strip to to the base format. and apply the linking later
     $str = preg_replace('|@<a href="(.*?)".*>(.*)</a>|', '@${2}', $str);
     //Strip html href tag
     $str = preg_replace('|<a href="(.*?)".*>(.*)</a>|', '${1}', $str);
     // Escape it first
     $str = CStringHelper::escape(rtrim(str_replace('&nbsp;', '', $str)));
     $str = str_replace('&amp;quot;', '"', $str);
     // Autolink url
     $str = CStringHelper::autoLink($str);
     // Nl2Br
     $str = nl2br($str);
     // Autolinked username
     $str = CUserHelper::replaceAliasURL($str);
     $str = CStringHelper::getEmoticon($str);
     $str = CStringHelper::getMood($str, $mood);
     $str = CStringHelper::converttagtolink($str);
     //onstream comment filter
     // onMessageDisplay Event trigger
     if ($str) {
         $appsLib = CAppPlugins::getInstance();
         $appsLib->loadApplications();
         $strObj = new stdClass();
         $strObj->body = $str;
         $arg[] = $strObj;
         $appsLib->triggerEvent('onFormatConversion', $arg);
         $str = $arg[0]->body;
         // reassign back to string
     }
     return $str;
 }