Пример #1
0
 function onAfterVote($poll, $option_id)
 {
     $user =& JFactory::getUser();
     $points = JPATH_ROOT . '/components/com_community/libraries/core.php';
     $activity = JPATH_ROOT . '/components/com_community/libraries/core.php';
     if ($this->params->get('points', '0') == '1' && file_exists($points)) {
         require_once $points;
         CUserPoints::assignPoint('com_acepolls.vote');
     }
     if ($this->params->get('activity', '0') == '1' && file_exists($activity)) {
         require_once $activity;
         $text = JText::_('COM_ACEPOLLS_ACTIVITY_TEXT');
         $link = JRoute::_('index.php?option=com_acepolls&view=poll&id=' . $poll->id . ":" . $poll->alias . self::getItemid($poll->id));
         $act = new stdClass();
         $act->cmd = 'wall.write';
         $act->actor = $user->id;
         $act->target = 0;
         $act->title = JText::_('{actor} ' . $text . ' <a href="' . $link . '">' . $poll->title . '</a>');
         $act->content = '';
         $act->app = 'wall';
         $act->cid = 0;
         CFactory::load('libraries', 'activities');
         CActivityStream::add($act);
     }
 }
Пример #2
0
 function add_stream($listing_id, $cids, $ctype = '')
 {
     include_once JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php';
     // load language strings for this component so we get translated activity stream messages
     $lang =& JFactory::getLanguage();
     $lang->load('com_relate');
     $sql = "SELECT id, title, catid FROM #__content WHERE id = '{$listing_id}'";
     $this->_db->setQuery($sql);
     $listing = $this->_db->loadObject();
     $listing_title = $listing->title;
     $listing_href = CRoute::_('index.php?option=com_content&view=article&catid=' . $listing->catid . '&id=' . $listing->id);
     $listing_link = '<a href="' . $listing_href . '">' . $listing_title . '</a>';
     if ($ctype != '') {
         $content_type = $ctype;
         $category_id = 1;
         $is_listing = false;
     } else {
         $sql = "SELECT l.id, l.catid, l.title, c.title AS cat_title FROM #__categories c, #__content l " . "WHERE c.id = l.catid AND l.id IN (" . implode(",", $cids) . ")";
         $this->_db->setQuery($sql);
         $content = $this->_db->loadObjectList('id');
         $is_listing = true;
     }
     foreach ($cids as $cid) {
         if ($is_listing) {
             $content_title = $content[$cid]->title;
             $content_type = $content[$cid]->cat_title;
             $category_id = $content[$cid]->catid;
             $content_id = $content[$cid]->id;
             $href = CRoute::_('index.php?option=com_content&view=article&catid=' . $category_id . '&id=' . $content_id);
             $content_link = '<a href="' . $href . '">' . $content_title . '</a>';
             $content_info = $content_link . ' (' . $content_type . ')';
         } else {
             $content_id = $cid;
             $tab = '';
             if ($content_type == "photo") {
                 $tab = '#bilder';
             } else {
                 if ($content_type == "video") {
                     $tab = '#video';
                 }
             }
             $content_link = '<a href="' . $listing_href . $tab . '">' . JText::_("a {$content_type}") . '</a>';
             $content_info = $content_link;
         }
         $act = new stdClass();
         $act->cmd = 'wall.write';
         $act->actor = JFactory::getUser()->id;
         $act->target = 0;
         $act->title = JText::sprintf('RELATION ADDED', $content_info, $listing_link);
         $act->content = '';
         $act->app = 'wall';
         $act->cid = $content_id;
         CFactory::load('libraries', 'activities');
         CActivityStream::add($act);
     }
 }
Пример #3
0
 public function upload()
 {
     $my = $this->plugin->get('user');
     $config = CFactory::getConfig();
     $returns = array();
     // Load up required models and properties
     CFactory::load('controllers', 'photos');
     CFactory::load('libraries', 'photos');
     CFactory::load('models', 'photos');
     CFactory::load('helpers', 'image');
     $photos = JRequest::get('Files');
     $albumId = JRequest::getVar('albumid', '', 'REQUEST');
     $album =& JTable::getInstance('Album', 'CTable');
     $album->load($albumId);
     $handler = $this->_getHandler($album);
     foreach ($photos as $imageFile) {
         if (!$this->_validImage($imageFile)) {
             $this->_showUploadError(true, $this->getError());
             return;
         }
         if ($this->_imageLimitExceeded(filesize($imageFile['tmp_name']))) {
             $this->_showUploadError(true, JText::_('CC IMAGE FILE SIZE EXCEEDED'));
             return;
         }
         // We need to read the filetype as uploaded always return application/octet-stream
         // regardless od the actual file type
         $info = getimagesize($imageFile['tmp_name']);
         $isDefaultPhoto = JRequest::getVar('defaultphoto', false, 'REQUEST');
         if ($album->id == 0 || $my->id != $album->creator && $album->type != PHOTOS_GROUP_TYPE) {
             $this->_showUploadError(true, JText::_('CC INVALID ALBUM'));
             return;
         }
         if (!$album->hasAccess($my->id, 'upload')) {
             $this->_showUploadError(true, JText::_('CC INVALID ALBUM'));
             return;
         }
         // Hash the image file name so that it gets as unique possible
         $fileName = JUtility::getHash($imageFile['tmp_name'] . time());
         $hashFilename = JString::substr($fileName, 0, 24);
         $imgType = image_type_to_mime_type($info[2]);
         // Load the tables
         $photoTable =& JTable::getInstance('Photo', 'CTable');
         // @todo: configurable paths?
         $storage = JPATH_ROOT . DS . $config->getString('photofolder');
         $albumPath = empty($album->path) ? '' : $album->id . DS;
         // Test if the photos path really exists.
         jimport('joomla.filesystem.file');
         jimport('joomla.filesystem.folder');
         CFactory::load('helpers', 'limits');
         $originalPath = $handler->getOriginalPath($storage, $albumPath, $album->id);
         CFactory::load('helpers', 'owner');
         // @rule: Just in case user tries to exploit the system, we should prevent this from even happening.
         if ($handler->isExceedUploadLimit() && !COwnerHelper::isCommunityAdmin()) {
             $config = CFactory::getConfig();
             $photoLimit = $config->get('groupphotouploadlimit');
             echo JText::sprintf('CC GROUP PHOTO UPLOAD LIMIT REACHED', $photoLimit);
             return;
         }
         if (!JFolder::exists($originalPath)) {
             if (!JFolder::create($originalPath, (int) octdec($config->get('folderpermissionsphoto')))) {
                 $this->_showUploadError(true, JText::_('CC ERROR CREATING USERS PHOTO FOLDER'));
                 return;
             }
         }
         $locationPath = $handler->getLocationPath($storage, $albumPath, $album->id);
         if (!JFolder::exists($locationPath)) {
             if (!JFolder::create($locationPath, (int) octdec($config->get('folderpermissionsphoto')))) {
                 $this->_showUploadError(true, JText::_('CC ERROR CREATING USERS PHOTO FOLDER'));
                 return;
             }
         }
         $thumbPath = $handler->getThumbPath($storage, $album->id);
         $thumbPath = $thumbPath . DS . $albumPath . 'thumb_' . $hashFilename . CImageHelper::getExtension($imageFile['type']);
         CPhotos::generateThumbnail($imageFile['tmp_name'], $thumbPath, $imgType);
         // Original photo need to be kept to make sure that, the gallery works
         $useAlbumId = empty($album->path) ? 0 : $album->id;
         $originalFile = $originalPath . $hashFilename . CImageHelper::getExtension($imgType);
         $this->_storeOriginal($imageFile['tmp_name'], $originalFile, $useAlbumId);
         $photoTable->original = JString::str_ireplace(JPATH_ROOT . DS, '', $originalFile);
         // Set photos properties
         $photoTable->albumid = $albumId;
         $photoTable->caption = $imageFile['name'];
         $photoTable->creator = $my->id;
         $photoTable->created = gmdate('Y-m-d H:i:s');
         // Remove the filename extension from the caption
         if (JString::strlen($photoTable->caption) > 4) {
             $photoTable->caption = JString::substr($photoTable->caption, 0, JString::strlen($photoTable->caption) - 4);
         }
         // @todo: configurable options?
         // Permission should follow album permission
         $photoTable->published = '1';
         $photoTable->permissions = $album->permissions;
         // Set the relative path.
         // @todo: configurable path?
         $storedPath = $handler->getStoredPath($storage, $albumId);
         $storedPath = $storedPath . DS . $albumPath . $hashFilename . CImageHelper::getExtension($imageFile['type']);
         $photoTable->image = JString::str_ireplace(JPATH_ROOT . DS, '', $storedPath);
         $photoTable->thumbnail = JString::str_ireplace(JPATH_ROOT . DS, '', $thumbPath);
         //photo filesize, use sprintf to prevent return of unexpected results for large file.
         $photoTable->filesize = sprintf("%u", filesize($originalPath));
         // @rule: Set the proper ordering for the next photo upload.
         $photoTable->setOrdering();
         // Store the object
         $photoTable->store();
         // We need to see if we need to rotate this image, from EXIF orientation data
         // Only for jpeg image.
         if ($config->get('photos_auto_rotate') && $imgType == 'image/jpeg') {
             // Read orientation data from original file
             $orientation = CImageHelper::getOrientation($imageFile['tmp_name']);
             //echo $orientation; exit;
             // A newly uplaoded image might not be resized yet, do it now
             $displayWidth = $config->getInt('photodisplaysize');
             JRequest::setVar('imgid', $photoTable->id, 'GET');
             JRequest::setVar('maxW', $displayWidth, 'GET');
             JRequest::setVar('maxH', $displayWidth, 'GET');
             $this->showimage(false);
             // Rotata resized files ince it is smaller
             switch ($orientation) {
                 case 1:
                     // nothing
                     break;
                 case 2:
                     // horizontal flip
                     // $image->flipImage($public,1);
                     break;
                 case 3:
                     // 180 rotate left
                     //  $image->rotateImage($public,180);
                     CImageHelper::rotate($storedPath, $storedPath, 180);
                     CImageHelper::rotate($thumbPath, $thumbPath, 180);
                     break;
                 case 4:
                     // vertical flip
                     //  $image->flipImage($public,2);
                     break;
                 case 5:
                     // vertical flip + 90 rotate right
                     //$image->flipImage($public, 2);
                     //$image->rotateImage($public, -90);
                     break;
                 case 6:
                     // 90 rotate right
                     // $image->rotateImage($public, -90);
                     CImageHelper::rotate($storedPath, $storedPath, -90);
                     CImageHelper::rotate($thumbPath, $thumbPath, -90);
                     break;
                 case 7:
                     // horizontal flip + 90 rotate right
                     // 			            $image->flipImage($public,1);
                     // 			            $image->rotateImage($public, -90);
                     break;
                 case 8:
                     // 90 rotate left
                     // 			            $image->rotateImage($public, 90);
                     CImageHelper::rotate($storedPath, $storedPath, 90);
                     CImageHelper::rotate($thumbPath, $thumbPath, 90);
                     break;
             }
         }
         // Trigger for onPhotoCreate
         CFactory::load('libraries', 'apps');
         $apps =& CAppPlugins::getInstance();
         $apps->loadApplications();
         $params = array();
         $params[] =& $photoTable;
         $apps->triggerEvent('onPhotoCreate', $params);
         // Set image as default if necessary
         // Load photo album table
         if ($isDefaultPhoto) {
             // Set the photo id
             $album->photoid = $photoTable->id;
             $album->store();
         }
         // @rule: Set first photo as default album cover if enabled
         if (!$isDefaultPhoto && $config->get('autoalbumcover')) {
             $photosModel = CFactory::getModel('Photos');
             $totalPhotos = $photosModel->getTotalPhotos($album->id);
             if ($totalPhotos <= 1) {
                 $album->photoid = $photoTable->id;
                 $album->store();
             }
         }
         $act = new stdClass();
         $act->cmd = 'photo.upload';
         $act->actor = $my->id;
         $act->access = $my->getParam('privacyPhotoView');
         $act->target = 0;
         $act->title = JText::sprintf($handler->getUploadActivityTitle(), '{photo_url}', $album->name);
         $act->content = '<img src="' . rtrim(JURI::root(), '/') . '/' . $photoTable->thumbnail . '" style=\\"border: 1px solid #eee;margin-right: 3px;" />';
         $act->app = 'photos';
         $act->cid = $albumId;
         $params = new JParameter('');
         $params->set('multiUrl', $handler->getAlbumURI($albumId, false));
         $params->set('photoid', $photoTable->id);
         $params->set('action', 'upload');
         $params->set('photo_url', $handler->getPhotoURI($albumId, $photoTable->id, false));
         // Add activity logging
         CFactory::load('libraries', 'activities');
         CActivityStream::add($act, $params->toString());
         //add user points
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('photo.upload');
         // Photo upload was successfull, display a proper message
         //$this->_showUploadError( false , JText::sprintf('CC PHOTO UPLOADED SUCCESSFULLY', $photoTable->caption ) , $photoTable->getThumbURI(), $albumId );
         $returns[] = array('album_id' => $albumId, 'image_id' => $photoTable->id, 'caption' => $photoTable->caption, 'created' => $photoTable->created, 'storage' => $photoTable->storage, 'thumbnail' => $photoTable->getThumbURI(), 'image' => $photoTable->getImageURI());
     }
     return $returns;
     exit;
 }
Пример #4
0
 function pushToJomsocialActivity($actor_id, $act_type = '', $act_subtype = '', $act_description = '', $act_link = '', $act_title = '', $act_access)
 {
     /*load Jomsocial core*/
     $linkHTML = '';
     $jspath = JPATH_ROOT . DS . 'components' . DS . 'com_community';
     if (file_exists($jspath)) {
         include_once $jspath . DS . 'libraries' . DS . 'core.php';
     }
     //push activity
     if ($act_title and $act_link) {
         $linkHTML = '<a href="' . $act_link . '">' . $act_title . '</a>';
     }
     $act = new stdClass();
     $act->cmd = 'wall.write';
     $act->actor = $actor_id;
     $act->target = 0;
     // no target
     $act->title = '{actor} ' . $act_description . ' ' . $linkHTML;
     $act->content = '';
     $act->app = 'wall';
     $act->cid = 0;
     $act->access = $act_access;
     CFactory::load('libraries', 'activities');
     if (defined('CActivities::COMMENT_SELF')) {
         $act->comment_id = CActivities::COMMENT_SELF;
         $act->comment_type = 'profile.location';
     }
     if (defined('CActivities::LIKE_SELF')) {
         $act->like_id = CActivities::LIKE_SELF;
         $act->like_type = 'profile.location';
     }
     $res = CActivityStream::add($act);
     return true;
 }
Пример #5
0
 private function _addAvatarUploadActivity($userid, $thumbnail)
 {
     if (CUserPoints::assignPoint('profile.avatar.upload')) {
         // Generate activity stream.
         $act = new stdClass();
         $act->cmd = 'profile.avatar.upload';
         $act->actor = $userid;
         $act->target = 0;
         $act->title = '';
         $act->content = '';
         $act->app = 'profile.avatar.upload';
         $act->cid = 0;
         $act->comment_id = CActivities::COMMENT_SELF;
         $act->comment_type = 'profile.avatar.upload';
         $act->like_id = CActivities::LIKE_SELF;
         $act->like_type = 'profile.avatar.upload';
         // We need to make a copy of current avatar and set it as stream 'attachement'
         // which will only gets deleted once teh stream is deleted
         $params = new JRegistry();
         // store a copy of the avatar
         $imageAttachment = str_replace('thumb_', 'stream_', $thumbnail);
         $thumbnail = str_replace('thumb_', '', $thumbnail);
         JFile::copy($thumbnail, $imageAttachment);
         $params->set('attachment', $imageAttachment);
         // Add activity logging
         CActivityStream::add($act, $params->toString());
     }
 }
Пример #6
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();
 }
Пример #7
0
 private function _createPhotoUploadStream($album, $jsonObj)
 {
     $obj = json_decode($jsonObj);
     $photoIds = array();
     $batchcount = count($obj->files);
     foreach ($obj->files as $file) {
         $photoIds[] = $file->photoId;
     }
     $photoTable = JTable::getInstance('Photo', 'cTable');
     $photoTable->load($photoIds[count($photoIds) - 1]);
     $my = CFactory::getUser();
     $handler = $this->_getHandler($album);
     // Generate activity stream
     $act = new stdClass();
     $act->cmd = 'photo.upload';
     $act->actor = $my->id;
     $act->access = $album->permissions;
     $act->target = 0;
     $act->title = '';
     // Empty title, auto-generated by stream
     $act->content = '';
     // Gegenerated automatically by stream. No need to add anything
     $act->app = 'photos';
     $act->cid = $album->id;
     $act->location = $album->location;
     // Store group info
     // I hate to load group here, but unfortunately, album does
     // not store group permission setting
     $group = JTable::getInstance('Group', 'CTable');
     $group->load($album->groupid);
     $act->groupid = $album->groupid;
     $act->group_access = $group->approvals;
     // Allow comment on the album
     $act->comment_type = 'photos';
     $act->comment_id = $photoTable->id;
     // Allow like on the album
     $act->like_type = 'photo';
     $act->like_id = $photoTable->id;
     $params = new CParameter('');
     $params->set('multiUrl', $handler->getAlbumURI($album->id, false));
     $params->set('photoid', $photoTable->id);
     $params->set('action', 'upload');
     $params->set('photo_url', $photoTable->getThumbURI());
     $params->set('style', COMMUNITY_STREAM_STYLE);
     // Get the upload count per session
     $session = JFactory::getSession();
     $uploadSessionCount = $session->get('album-' . $album->id . '-upload', 0);
     $params->set('count', $uploadSessionCount);
     $params->set('batchcount', $batchcount);
     $params->set('photosId', implode(',', $photoIds));
     // Add activity logging
     CActivityStream::add($act, $params->toString());
 }
Пример #8
0
 /**
  * Called by status box to add new stream data
  *
  * @param type $message
  * @param type $attachment
  * @return type
  */
 public function ajaxStreamAdd($message, $attachment, $streamFilter = FALSE)
 {
     $streamHTML = '';
     // $attachment pending filter
     $cache = CFactory::getFastCache();
     $cache->clean(array('activities'));
     $my = CFactory::getUser();
     $userparams = $my->getParams();
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     //@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'));
     }
     $message = JString::trim($message);
     $objResponse = new JAXResponse();
     $rawMessage = $message;
     // @rule: Autolink hyperlinks
     // @rule: Autolink to users profile when message contains @username
     // $message     = CUserHelper::replaceAliasURL($message); // the processing is done on display side
     $emailMessage = CUserHelper::replaceAliasURL($rawMessage, true);
     // @rule: Spam checks
     if ($config->get('antispam_akismet_status')) {
         $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();
         }
     }
     $attachment = json_decode($attachment, true);
     switch ($attachment['type']) {
         case 'message':
             //if (!empty($message)) {
             switch ($attachment['element']) {
                 case 'profile':
                     //only update user status if share messgage is on his profile
                     if (COwnerHelper::isMine($my->id, $attachment['target'])) {
                         //save the message
                         $status = $this->getModel('status');
                         /* If no privacy in attachment than we apply default: Public */
                         if (!isset($attachment['privacy'])) {
                             $attachment['privacy'] = COMMUNITY_STATUS_PRIVACY_PUBLIC;
                         }
                         $status->update($my->id, $rawMessage, $attachment['privacy']);
                         //set user status for current session.
                         $today = JFactory::getDate();
                         $message2 = empty($message) ? ' ' : $message;
                         $my->set('_status', $rawMessage);
                         $my->set('_posted_on', $today->toSql());
                         // Order of replacement
                         $order = array("\r\n", "\n", "\r");
                         $replace = '<br />';
                         // Processes \r\n's first so they aren't converted twice.
                         $messageDisplay = str_replace($order, $replace, $message);
                         $messageDisplay = CKses::kses($messageDisplay, CKses::allowed());
                         //update user status
                         $objResponse->addScriptCall("joms.jQuery('#profile-status span#profile-status-message').html('" . addslashes($messageDisplay) . "');");
                     }
                     //if actor posted something to target, the privacy should be under target's profile privacy settings
                     if (!COwnerHelper::isMine($my->id, $attachment['target']) && $attachment['target'] != '') {
                         $attachment['privacy'] = CFactory::getUser($attachment['target'])->getParams()->get('privacyProfileView');
                     }
                     //push to activity stream
                     $act = new stdClass();
                     $act->cmd = 'profile.status.update';
                     $act->actor = $my->id;
                     $act->target = $attachment['target'];
                     $act->title = $message;
                     $act->content = '';
                     $act->app = $attachment['element'];
                     $act->cid = $my->id;
                     $act->access = $attachment['privacy'];
                     $act->comment_id = CActivities::COMMENT_SELF;
                     $act->comment_type = 'profile.status';
                     $act->like_id = CActivities::LIKE_SELF;
                     $act->like_type = 'profile.status';
                     $activityParams = new CParameter('');
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $headMeta = new CParameter('');
                     if (isset($attachment['fetch'])) {
                         $headMeta->set('title', $attachment['fetch'][2]);
                         $headMeta->set('description', $attachment['fetch'][3]);
                         $headMeta->set('image', $attachment['fetch'][1]);
                         $headMeta->set('link', $attachment['fetch'][0]);
                         //do checking if this is a video link
                         $video = JTable::getInstance('Video', 'CTable');
                         $isValidVideo = @$video->init($attachment['fetch'][0]);
                         if ($isValidVideo) {
                             $headMeta->set('type', 'video');
                             $headMeta->set('video_provider', $video->type);
                             $headMeta->set('video_id', $video->getVideoId());
                             $headMeta->set('height', $video->getHeight());
                             $headMeta->set('width', $video->getWidth());
                         }
                         $activityParams->set('headMetas', $headMeta->toString());
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $activityParams->set('mood', $attachment['mood']);
                     }
                     $act->params = $activityParams->toString();
                     //CActivityStream::add($act);
                     //check if the user points is enabled
                     if (CUserPoints::assignPoint('profile.status.update')) {
                         /* Let use our new CApiStream */
                         $activityData = CApiActivities::add($act);
                         CTags::add($activityData);
                         $recipient = CFactory::getUser($attachment['target']);
                         $params = new CParameter('');
                         $params->set('actorName', $my->getDisplayName());
                         $params->set('recipientName', $recipient->getDisplayName());
                         $params->set('url', CUrlHelper::userLink($act->target, false));
                         $params->set('message', $message);
                         $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                         $params->set('stream_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $activityData->actor . '&actid=' . $activityData->id));
                         CNotificationLibrary::add('profile_status_update', $my->id, $attachment['target'], JText::sprintf('COM_COMMUNITY_FRIEND_WALL_POST', $my->getDisplayName()), '', 'wall.post', $params);
                         //email and add notification if user are tagged
                         CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment'));
                     }
                     break;
                     // Message posted from Group page
                 // Message posted from Group page
                 case 'groups':
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     // Permission check, only site admin and those who has
                     // mark their attendance can post message
                     if (!COwnerHelper::isCommunityAdmin() && !$group->isMember($my->id) && $config->get('lockgroupwalls')) {
                         $objResponse->addScriptCall("alert('permission denied');");
                         return $objResponse->sendResponse();
                     }
                     $act = new stdClass();
                     $act->cmd = 'groups.wall';
                     $act->actor = $my->id;
                     $act->target = 0;
                     $act->title = $message;
                     $act->content = '';
                     $act->app = 'groups.wall';
                     $act->cid = $attachment['target'];
                     $act->groupid = $group->id;
                     $act->group_access = $group->approvals;
                     $act->eventid = 0;
                     $act->access = 0;
                     $act->comment_id = CActivities::COMMENT_SELF;
                     $act->comment_type = 'groups.wall';
                     $act->like_id = CActivities::LIKE_SELF;
                     $act->like_type = 'groups.wall';
                     $activityParams = new CParameter('');
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $headMeta = new CParameter('');
                     if (isset($attachment['fetch'])) {
                         $headMeta->set('title', $attachment['fetch'][2]);
                         $headMeta->set('description', $attachment['fetch'][3]);
                         $headMeta->set('image', $attachment['fetch'][1]);
                         $headMeta->set('link', $attachment['fetch'][0]);
                         //do checking if this is a video link
                         $video = JTable::getInstance('Video', 'CTable');
                         $isValidVideo = @$video->init($attachment['fetch'][0]);
                         if ($isValidVideo) {
                             $headMeta->set('type', 'video');
                             $headMeta->set('video_provider', $video->type);
                             $headMeta->set('video_id', $video->getVideoId());
                             $headMeta->set('height', $video->getHeight());
                             $headMeta->set('width', $video->getWidth());
                         }
                         $activityParams->set('headMetas', $headMeta->toString());
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $activityParams->set('mood', $attachment['mood']);
                     }
                     $act->params = $activityParams->toString();
                     $activityData = CApiActivities::add($act);
                     CTags::add($activityData);
                     CUserPoints::assignPoint('group.wall.create');
                     $recipient = CFactory::getUser($attachment['target']);
                     $params = new CParameter('');
                     $params->set('message', $emailMessage);
                     $params->set('group', $group->name);
                     $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
                     $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id, false));
                     //Get group member emails
                     $model = CFactory::getModel('Groups');
                     $members = $model->getMembers($attachment['target'], null, true, false, true);
                     $membersArray = array();
                     if (!is_null($members)) {
                         foreach ($members as $row) {
                             if ($my->id != $row->id) {
                                 $membersArray[] = $row->id;
                             }
                         }
                     }
                     $groupParams = new CParameter($group->params);
                     if ($groupParams->get('wallnotification')) {
                         CNotificationLibrary::add('groups_wall_create', $my->id, $membersArray, JText::sprintf('COM_COMMUNITY_NEW_WALL_POST_NOTIFICATION_EMAIL_SUBJECT', $my->getDisplayName(), $group->name), '', 'groups.post', $params);
                     }
                     //@since 4.1 when a there is a new post in group, dump the data into group stats
                     $statsModel = CFactory::getModel('stats');
                     $statsModel->addGroupStats($group->id, 'post');
                     // Add custom stream
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     break;
                     // Message posted from Event page
                 // Message posted from Event page
                 case 'events':
                     $eventLib = new CEvents();
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     // Permission check, only site admin and those who has
                     // mark their attendance can post message
                     if (!COwnerHelper::isCommunityAdmin() && !$event->isMember($my->id) && $config->get('lockeventwalls')) {
                         $objResponse->addScriptCall("alert('permission denied');");
                         return $objResponse->sendResponse();
                     }
                     // If this is a group event, set the group object
                     $groupid = $event->type == 'group' ? $event->contentid : 0;
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($groupid);
                     $act = new stdClass();
                     $act->cmd = 'events.wall';
                     $act->actor = $my->id;
                     $act->target = 0;
                     $act->title = $message;
                     $act->content = '';
                     $act->app = 'events.wall';
                     $act->cid = $attachment['target'];
                     $act->groupid = $event->type == 'group' ? $event->contentid : 0;
                     $act->group_access = $group->approvals;
                     $act->eventid = $event->id;
                     $act->event_access = $event->permission;
                     $act->access = 0;
                     $act->comment_id = CActivities::COMMENT_SELF;
                     $act->comment_type = 'events.wall';
                     $act->like_id = CActivities::LIKE_SELF;
                     $act->like_type = 'events.wall';
                     $activityParams = new CParameter('');
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $headMeta = new CParameter('');
                     if (isset($attachment['fetch'])) {
                         $headMeta->set('title', $attachment['fetch'][2]);
                         $headMeta->set('description', $attachment['fetch'][3]);
                         $headMeta->set('image', $attachment['fetch'][1]);
                         $headMeta->set('link', $attachment['fetch'][0]);
                         //do checking if this is a video link
                         $video = JTable::getInstance('Video', 'CTable');
                         $isValidVideo = @$video->init($attachment['fetch'][0]);
                         if ($isValidVideo) {
                             $headMeta->set('type', 'video');
                             $headMeta->set('video_provider', $video->type);
                             $headMeta->set('video_id', $video->getVideoId());
                             $headMeta->set('height', $video->getHeight());
                             $headMeta->set('width', $video->getWidth());
                         }
                         $activityParams->set('headMetas', $headMeta->toString());
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $activityParams->set('mood', $attachment['mood']);
                     }
                     $act->params = $activityParams->toString();
                     $activityData = CApiActivities::add($act);
                     CTags::add($activityData);
                     // add points
                     CUserPoints::assignPoint('event.wall.create');
                     $params = new CParameter('');
                     $params->set('message', $emailMessage);
                     $params->set('event', $event->title);
                     $params->set('event_url', 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id);
                     $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false));
                     //Get event member emails
                     $members = $event->getMembers(COMMUNITY_EVENT_STATUS_ATTEND, 12, CC_RANDOMIZE);
                     $membersArray = array();
                     if (!is_null($members)) {
                         foreach ($members as $row) {
                             if ($my->id != $row->id) {
                                 $membersArray[] = $row->id;
                             }
                         }
                     }
                     CNotificationLibrary::add('events_wall_create', $my->id, $membersArray, JText::sprintf('COM_COMMUNITY_NEW_WALL_POST_NOTIFICATION_EMAIL_SUBJECT_EVENTS', $my->getDisplayName(), $event->title), '', 'events.post', $params);
                     //@since 4.1 when a there is a new post in event, dump the data into event stats
                     $statsModel = CFactory::getModel('stats');
                     $statsModel->addEventStats($event->id, 'post');
                     // Reload the stream with new stream data
                     $streamHTML = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true));
                     break;
             }
             $objResponse->addScriptCall('__callback', '');
             // /}
             break;
         case 'photo':
             switch ($attachment['element']) {
                 case 'profile':
                     $photoIds = $attachment['id'];
                     //use User Preference for Privacy
                     //$privacy = $userparams->get('privacyPhotoView'); //$privacy = $attachment['privacy'];
                     $photo = JTable::getInstance('Photo', 'CTable');
                     if (!isset($photoIds[0]) || $photoIds[0] <= 0) {
                         //$objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                         exit;
                     }
                     //always get album id from the photo itself, do not let it assign by params from user post data
                     $photoModel = CFactory::getModel('photos');
                     $photo = $photoModel->getPhoto($photoIds[0]);
                     /* OK ! If album_id is not provided than we use album id from photo ( it should be default album id ) */
                     $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid;
                     $album = JTable::getInstance('Album', 'CTable');
                     $album->load($albumid);
                     $privacy = $album->permissions;
                     //limit checking
                     //                        $photoModel = CFactory::getModel( 'photos' );
                     //                        $config       = CFactory::getConfig();
                     //                        $total        = $photoModel->getTotalToday( $my->id );
                     //                        $max      = $config->getInt( 'limit_photo_perday' );
                     //                        $remainingUploadCount = $max - $total;
                     $params = array();
                     foreach ($photoIds as $key => $photoId) {
                         if (CLimitsLibrary::exceedDaily('photos')) {
                             unset($photoIds[$key]);
                             continue;
                         }
                         $photo->load($photoId);
                         $photo->permissions = $privacy;
                         $photo->published = 1;
                         $photo->status = 'ready';
                         $photo->albumid = $albumid;
                         /* We must update this photo into correct album id */
                         $photo->store();
                         $params[] = clone $photo;
                     }
                     if ($config->get('autoalbumcover') && !$album->photoid) {
                         $album->photoid = $photoIds[0];
                         $album->store();
                     }
                     // Break if no photo added, which is likely because of daily limit.
                     if (count($photoIds) < 1) {
                         $objResponse->addScriptCall('__throwError', JText::_('COM_COMMUNITY_PHOTO_UPLOAD_LIMIT_EXCEEDED'));
                         return $objResponse->sendResponse();
                     }
                     // Trigger onPhotoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $apps->triggerEvent('onPhotoCreate', array($params));
                     $act = new stdClass();
                     $act->cmd = 'photo.upload';
                     $act->actor = $my->id;
                     $act->access = $privacy;
                     //$attachment['privacy'];
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->title = $message;
                     $act->content = '';
                     // Generated automatically by stream. No need to add anything
                     $act->app = 'photos';
                     $act->cid = $albumid;
                     $act->location = $album->location;
                     /* Comment and like for individual photo upload is linked
                      * to the photos itsel
                      */
                     $act->comment_id = $photo->id;
                     $act->comment_type = 'photos';
                     $act->like_id = $photo->id;
                     $act->like_type = 'photo';
                     $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $my->id;
                     $albumUrl = CRoute::_($albumUrl);
                     $photoUrl = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&userid=' . $photo->creator . '&photoid=' . $photo->id;
                     $photoUrl = CRoute::_($photoUrl);
                     $params = new CParameter('');
                     $params->set('multiUrl', $albumUrl);
                     $params->set('photoid', $photo->id);
                     $params->set('action', 'upload');
                     $params->set('stream', '1');
                     $params->set('photo_url', $photoUrl);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     $params->set('photosId', implode(',', $photoIds));
                     if (count($photoIds > 1)) {
                         $params->set('count', count($photoIds));
                         $params->set('batchcount', count($photoIds));
                     }
                     //Store mood in param
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     // Add activity logging
                     // CActivityStream::remove($act->app, $act->cid);
                     $activityData = CActivityStream::add($act, $params->toString());
                     // Add user points
                     CUserPoints::assignPoint('photo.upload');
                     //add a notification to the target user if someone posted photos on target's profile
                     if ($my->id != $attachment['target']) {
                         $recipient = CFactory::getUser($attachment['target']);
                         $params = new CParameter('');
                         $params->set('actorName', $my->getDisplayName());
                         $params->set('recipientName', $recipient->getDisplayName());
                         $params->set('url', CUrlHelper::userLink($act->target, false));
                         $params->set('message', $message);
                         $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                         $params->set('stream_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $activityData->actor . '&actid=' . $activityData->id));
                         CNotificationLibrary::add('profile_status_update', $my->id, $attachment['target'], JText::sprintf('COM_COMMUNITY_NOTIFICATION_STREAM_PHOTO_POST', count($photoIds)), '', 'wall.post', $params);
                     }
                     //email and add notification if user are tagged
                     CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment'));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                     break;
                 case 'events':
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     $privacy = 0;
                     //if this is a group event, we need to follow the group privacy
                     if ($event->type == 'group' && $event->contentid) {
                         $group = JTable::getInstance('Group', 'CTable');
                         $group->load(${$event}->contentid);
                         $privacy = $group->approvals ? PRIVACY_GROUP_PRIVATE_ITEM : 0;
                     }
                     $photoIds = $attachment['id'];
                     $photo = JTable::getInstance('Photo', 'CTable');
                     $photo->load($photoIds[0]);
                     $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid;
                     $album = JTable::getInstance('Album', 'CTable');
                     $album->load($albumid);
                     $params = array();
                     foreach ($photoIds as $photoId) {
                         $photo->load($photoId);
                         $photo->caption = $message;
                         $photo->permissions = $privacy;
                         $photo->published = 1;
                         $photo->status = 'ready';
                         $photo->albumid = $albumid;
                         $photo->store();
                         $params[] = clone $photo;
                     }
                     // Trigger onPhotoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $apps->triggerEvent('onPhotoCreate', array($params));
                     $act = new stdClass();
                     $act->cmd = 'photo.upload';
                     $act->actor = $my->id;
                     $act->access = $privacy;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->title = $message;
                     //JText::sprintf('COM_COMMUNITY_ACTIVITIES_UPLOAD_PHOTO' , '{photo_url}', $album->name );
                     $act->content = '';
                     // Generated automatically by stream. No need to add anything
                     $act->app = 'photos';
                     $act->cid = $album->id;
                     $act->location = $album->location;
                     $act->eventid = $event->id;
                     $act->group_access = $privacy;
                     // just in case this event belongs to a group
                     //$act->access      = $attachment['privacy'];
                     /* Comment and like for individual photo upload is linked
                      * to the photos itsel
                      */
                     $act->comment_id = $photo->id;
                     $act->comment_type = 'photos';
                     $act->like_id = $photo->id;
                     $act->like_type = 'photo';
                     $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $my->id;
                     $albumUrl = CRoute::_($albumUrl);
                     $photoUrl = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&userid=' . $photo->creator . '&photoid=' . $photo->id;
                     $photoUrl = CRoute::_($photoUrl);
                     $params = new CParameter('');
                     $params->set('multiUrl', $albumUrl);
                     $params->set('photoid', $photo->id);
                     $params->set('action', 'upload');
                     $params->set('stream', '1');
                     // this photo uploaded from status stream
                     $params->set('photo_url', $photoUrl);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     $params->set('photosId', implode(',', $photoIds));
                     // Add activity logging
                     if (count($photoIds > 1)) {
                         $params->set('count', count($photoIds));
                         $params->set('batchcount', count($photoIds));
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     // CActivityStream::remove($act->app, $act->cid);
                     $activityData = CActivityStream::add($act, $params->toString());
                     // Add user points
                     CUserPoints::assignPoint('photo.upload');
                     // Reload the stream with new stream data
                     $eventLib = new CEvents();
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     $streamHTML = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                     break;
                 case 'groups':
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     $photoIds = $attachment['id'];
                     $privacy = $group->approvals ? PRIVACY_GROUP_PRIVATE_ITEM : 0;
                     $photo = JTable::getInstance('Photo', 'CTable');
                     $photo->load($photoIds[0]);
                     $albumid = isset($attachment['album_id']) ? $attachment['album_id'] : $photo->albumid;
                     $album = JTable::getInstance('Album', 'CTable');
                     $album->load($albumid);
                     $params = array();
                     foreach ($photoIds as $photoId) {
                         $photo->load($photoId);
                         $photo->caption = $message;
                         $photo->permissions = $privacy;
                         $photo->published = 1;
                         $photo->status = 'ready';
                         $photo->albumid = $albumid;
                         $photo->store();
                         $params[] = clone $photo;
                     }
                     // Trigger onPhotoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $apps->triggerEvent('onPhotoCreate', array($params));
                     $act = new stdClass();
                     $act->cmd = 'photo.upload';
                     $act->actor = $my->id;
                     $act->access = $privacy;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->title = $message;
                     //JText::sprintf('COM_COMMUNITY_ACTIVITIES_UPLOAD_PHOTO' , '{photo_url}', $album->name );
                     $act->content = '';
                     // Generated automatically by stream. No need to add anything
                     $act->app = 'photos';
                     $act->cid = $album->id;
                     $act->location = $album->location;
                     $act->groupid = $group->id;
                     $act->group_access = $group->approvals;
                     $act->eventid = 0;
                     //$act->access      = $attachment['privacy'];
                     /* Comment and like for individual photo upload is linked
                      * to the photos itsel
                      */
                     $act->comment_id = $photo->id;
                     $act->comment_type = 'photos';
                     $act->like_id = $photo->id;
                     $act->like_type = 'photo';
                     $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $my->id;
                     $albumUrl = CRoute::_($albumUrl);
                     $photoUrl = 'index.php?option=com_community&view=photos&task=photo&albumid=' . $album->id . '&userid=' . $photo->creator . '&photoid=' . $photo->id;
                     $photoUrl = CRoute::_($photoUrl);
                     $params = new CParameter('');
                     $params->set('multiUrl', $albumUrl);
                     $params->set('photoid', $photo->id);
                     $params->set('action', 'upload');
                     $params->set('stream', '1');
                     // this photo uploaded from status stream
                     $params->set('photo_url', $photoUrl);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     $params->set('photosId', implode(',', $photoIds));
                     // Add activity logging
                     if (count($photoIds > 1)) {
                         $params->set('count', count($photoIds));
                         $params->set('batchcount', count($photoIds));
                     }
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     // CActivityStream::remove($act->app, $act->cid);
                     $activityData = CActivityStream::add($act, $params->toString());
                     // Add user points
                     CUserPoints::assignPoint('photo.upload');
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_PHOTO_UPLOADED_SUCCESSFULLY', $photo->caption));
                     break;
                     dafault:
                     return;
             }
             break;
         case 'video':
             switch ($attachment['element']) {
                 case 'profile':
                     // attachment id
                     $fetch = $attachment['fetch'];
                     $cid = $fetch[0];
                     $privacy = isset($attachment['privacy']) ? $attachment['privacy'] : COMMUNITY_STATUS_PRIVACY_PUBLIC;
                     $video = JTable::getInstance('Video', 'CTable');
                     $video->load($cid);
                     $video->set('creator_type', VIDEO_USER_TYPE);
                     $video->set('status', 'ready');
                     $video->set('permissions', $privacy);
                     $video->set('title', $fetch[3]);
                     $video->set('description', $fetch[4]);
                     $video->set('category_id', $fetch[5]);
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         $video->set('location', $attachment['location'][0]);
                         $video->set('latitude', $attachment['location'][1]);
                         $video->set('longitude', $attachment['location'][2]);
                     }
                     // Add activity logging
                     $url = $video->getViewUri(false);
                     $act = new stdClass();
                     $act->cmd = 'videos.linking';
                     $act->actor = $my->id;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->access = $privacy;
                     //filter empty message
                     $act->title = $message;
                     $act->app = 'videos.linking';
                     $act->content = '';
                     $act->cid = $video->id;
                     $act->location = $video->location;
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $act->comment_id = $video->id;
                     $act->comment_type = 'videos.linking';
                     $act->like_id = $video->id;
                     $act->like_type = 'videos.linking';
                     $params = new CParameter('');
                     $params->set('video_url', $url);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     //
                     $activityData = CActivityStream::add($act, $params->toString());
                     //this video must be public because it's posted on someone else's profile
                     if ($my->id != $attachment['target']) {
                         $video->set('permissions', COMMUNITY_STATUS_PRIVACY_PUBLIC);
                         $params = new CParameter();
                         $params->set('activity_id', $activityData->id);
                         // activity id is used to remove the activity if someone deleted this video
                         $params->set('target_id', $attachment['target']);
                         $video->params = $params->toString();
                         //also send a notification to the user
                         $recipient = CFactory::getUser($attachment['target']);
                         $params = new CParameter('');
                         $params->set('actorName', $my->getDisplayName());
                         $params->set('recipientName', $recipient->getDisplayName());
                         $params->set('url', CUrlHelper::userLink($act->target, false));
                         $params->set('message', $message);
                         $params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
                         $params->set('stream_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $activityData->actor . '&actid=' . $activityData->id));
                         CNotificationLibrary::add('profile_status_update', $my->id, $attachment['target'], JText::_('COM_COMMUNITY_NOTIFICATION_STREAM_VIDEO_POST'), '', 'wall.post', $params);
                     }
                     $video->store();
                     // @rule: Add point when user adds a new video link
                     //
                     CUserPoints::assignPoint('video.add', $video->creator);
                     //email and add notification if user are tagged
                     CUserHelper::parseTaggedUserNotification($message, $my, $activityData, array('type' => 'post-comment'));
                     // Trigger for onVideoCreate
                     //
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $params = array();
                     $params[] = $video;
                     $apps->triggerEvent('onVideoCreate', $params);
                     $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS, COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_VIDEOS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_VIDEOS_UPLOAD_SUCCESS', $video->title));
                     break;
                 case 'groups':
                     // attachment id
                     $fetch = $attachment['fetch'];
                     $cid = $fetch[0];
                     $privacy = 0;
                     //$attachment['privacy'];
                     $video = JTable::getInstance('Video', 'CTable');
                     $video->load($cid);
                     $video->set('status', 'ready');
                     $video->set('groupid', $attachment['target']);
                     $video->set('permissions', $privacy);
                     $video->set('creator_type', VIDEO_GROUP_TYPE);
                     $video->set('title', $fetch[3]);
                     $video->set('description', $fetch[4]);
                     $video->set('category_id', $fetch[5]);
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         $video->set('location', $attachment['location'][0]);
                         $video->set('latitude', $attachment['location'][1]);
                         $video->set('longitude', $attachment['location'][2]);
                     }
                     $video->store();
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     // Add activity logging
                     $url = $video->getViewUri(false);
                     $act = new stdClass();
                     $act->cmd = 'videos.linking';
                     $act->actor = $my->id;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->access = $privacy;
                     //filter empty message
                     $act->title = $message;
                     $act->app = 'videos';
                     $act->content = '';
                     $act->cid = $video->id;
                     $act->groupid = $video->groupid;
                     $act->group_access = $group->approvals;
                     $act->location = $video->location;
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $act->comment_id = $video->id;
                     $act->comment_type = 'videos';
                     $act->like_id = $video->id;
                     $act->like_type = 'videos';
                     $params = new CParameter('');
                     $params->set('video_url', $url);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     $activityData = CActivityStream::add($act, $params->toString());
                     // @rule: Add point when user adds a new video link
                     CUserPoints::assignPoint('video.add', $video->creator);
                     // Trigger for onVideoCreate
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $params = array();
                     $params[] = $video;
                     $apps->triggerEvent('onVideoCreate', $params);
                     $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS, COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_VIDEOS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_VIDEOS_UPLOAD_SUCCESS', $video->title));
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     break;
                 case 'events':
                     //event videos
                     $fetch = $attachment['fetch'];
                     $cid = $fetch[0];
                     $privacy = 0;
                     //$attachment['privacy'];
                     $video = JTable::getInstance('Video', 'CTable');
                     $video->load($cid);
                     $video->set('status', 'ready');
                     $video->set('eventid', $attachment['target']);
                     $video->set('permissions', $privacy);
                     $video->set('creator_type', VIDEO_EVENT_TYPE);
                     $video->set('title', $fetch[3]);
                     $video->set('description', $fetch[4]);
                     $video->set('category_id', $fetch[5]);
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         $video->set('location', $attachment['location'][0]);
                         $video->set('latitude', $attachment['location'][1]);
                         $video->set('longitude', $attachment['location'][2]);
                     }
                     $video->store();
                     //
                     $eventLib = new CEvents();
                     $event = JTable::getInstance('Event', 'CTable');
                     $event->load($attachment['target']);
                     $group = new stdClass();
                     if ($event->type == 'group' && $event->contentid) {
                         // check if this a group event, and follow the permission
                         $group = JTable::getInstance('Group', 'CTable');
                         $group->load($event->contentid);
                     }
                     // Add activity logging
                     $url = $video->getViewUri(false);
                     $act = new stdClass();
                     $act->cmd = 'videos.linking';
                     $act->actor = $my->id;
                     $act->target = $attachment['target'] == $my->id ? 0 : $attachment['target'];
                     $act->access = $privacy;
                     //filter empty message
                     $act->title = $message;
                     $act->app = 'videos';
                     $act->content = '';
                     $act->cid = $video->id;
                     $act->groupid = 0;
                     $act->group_access = isset($group->approvals) ? $group->approvals : 0;
                     // if this is a group event
                     $act->location = $video->location;
                     /* Save cords if exists */
                     if (isset($attachment['location'])) {
                         /* Save geo name */
                         $act->location = $attachment['location'][0];
                         $act->latitude = $attachment['location'][1];
                         $act->longitude = $attachment['location'][2];
                     }
                     $act->eventid = $event->id;
                     $act->comment_id = $video->id;
                     $act->comment_type = 'videos';
                     $act->like_id = $video->id;
                     $act->like_type = 'videos';
                     $params = new CParameter('');
                     $params->set('video_url', $url);
                     $params->set('style', COMMUNITY_STREAM_STYLE);
                     // set stream style
                     //Store mood in paramm
                     if (isset($attachment['mood']) && $attachment['mood'] != 'Mood') {
                         $params->set('mood', $attachment['mood']);
                     }
                     $activityData = CActivityStream::add($act, $params->toString());
                     // @rule: Add point when user adds a new video link
                     CUserPoints::assignPoint('video.add', $video->creator);
                     // Trigger for onVideoCreate
                     $apps = CAppPlugins::getInstance();
                     $apps->loadApplications();
                     $params = array();
                     $params[] = $video;
                     $apps->triggerEvent('onVideoCreate', $params);
                     $this->cacheClean(array(COMMUNITY_CACHE_TAG_VIDEOS, COMMUNITY_CACHE_TAG_FRONTPAGE, COMMUNITY_CACHE_TAG_FEATURED, COMMUNITY_CACHE_TAG_VIDEOS_CAT, COMMUNITY_CACHE_TAG_ACTIVITIES));
                     $objResponse->addScriptCall('__callback', JText::sprintf('COM_COMMUNITY_VIDEOS_UPLOAD_SUCCESS', $video->title));
                     // Reload the stream with new stream data
                     $streamHTML = $eventLib->getStreamHTML($event, array('showLatestActivityOnTop' => true));
                     break;
                 default:
                     return;
             }
             break;
         case 'event':
             switch ($attachment['element']) {
                 case 'profile':
                     require_once COMMUNITY_COM_PATH . '/controllers/events.php';
                     $eventController = new CommunityEventsController();
                     // Assign default values where necessary
                     $attachment['description'] = $message;
                     $attachment['ticket'] = 0;
                     $attachment['offset'] = 0;
                     $event = $eventController->ajaxCreate($attachment, $objResponse);
                     $objResponse->addScriptCall('window.location="' . $event->getLink() . '";');
                     if (CFactory::getConfig()->get('event_moderation')) {
                         $objResponse->addAlert(JText::sprintf('COM_COMMUNITY_EVENTS_MODERATION_NOTICE', $event->title));
                     }
                     break;
                 case 'groups':
                     require_once COMMUNITY_COM_PATH . '/controllers/events.php';
                     $eventController = new CommunityEventsController();
                     //
                     $groupLib = new CGroups();
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($attachment['target']);
                     // Assign default values where necessary
                     $attachment['description'] = $message;
                     $attachment['ticket'] = 0;
                     $attachment['offset'] = 0;
                     $event = $eventController->ajaxCreate($attachment, $objResponse);
                     CEvents::addGroupNotification($event);
                     $objResponse->addScriptCall('window.location="' . $event->getLink() . '";');
                     // Reload the stream with new stream data
                     $streamHTML = $groupLib->getStreamHTML($group, array('showLatestActivityOnTop' => true));
                     if (CFactory::getConfig()->get('event_moderation')) {
                         $objResponse->addAlert(JText::sprintf('COM_COMMUNITY_EVENTS_MODERATION_NOTICE', $event->title));
                     }
                     break;
             }
             break;
         case 'link':
             break;
     }
     //no matter what kind of message it is, always filter the hashtag if there's any
     if (!empty($act->title) && isset($activityData->id) && $activityData->id) {
         //use model to check if this has a tag in it and insert into the table if possible
         $hashtags = CContentHelper::getHashTags($act->title);
         if (count($hashtags)) {
             //$hashTag
             $hashtagModel = CFactory::getModel('hashtags');
             foreach ($hashtags as $tag) {
                 $hashtagModel->addActivityHashtag($tag, $activityData->id);
             }
         }
     }
     // Frontpage filter
     if ($streamFilter != false) {
         $streamFilter = json_decode($streamFilter);
         $filter = $streamFilter->filter;
         $value = $streamFilter->value;
         $extra = false;
         // Append added data to the list.
         if (isset($activityData) && $activityData->id) {
             $model = CFactory::getModel('Activities');
             $extra = $model->getActivity($activityData->id);
         }
         switch ($filter) {
             case 'privacy':
                 if ($value == 'me-and-friends' && $my->id != 0) {
                     $streamHTML = CActivities::getActivitiesByFilter('active-user-and-friends', $my->id, 'frontpage', true, array(), $extra);
                 } else {
                     $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array(), $extra);
                 }
                 break;
             case 'apps':
                 $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array('apps' => array($value)), $extra);
                 break;
             case 'hashtag':
                 $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array($filter => $value), $extra);
                 break;
             default:
                 $defaultFilter = $config->get('frontpageactivitydefault');
                 if ($defaultFilter == 'friends' && $my->id != 0) {
                     $streamHTML = CActivities::getActivitiesByFilter('active-user-and-friends', $my->id, 'frontpage', true, array(), $extra);
                 } else {
                     $streamHTML = CActivities::getActivitiesByFilter('all', $my->id, 'frontpage', true, array(), $extra);
                 }
                 break;
         }
     }
     if (!isset($attachment['filter'])) {
         $attachment['filter'] = '';
         $filter = $config->get('frontpageactivitydefault');
         $filter = explode(':', $filter);
         $attachment['filter'] = isset($filter[1]) ? $filter[1] : $filter[0];
     }
     if (empty($streamHTML)) {
         if (!isset($attachment['target'])) {
             $attachment['target'] = '';
         }
         if (!isset($attachment['element'])) {
             $attachment['element'] = '';
         }
         $streamHTML = CActivities::getActivitiesByFilter($attachment['filter'], $attachment['target'], $attachment['element'], true, array('show_featured' => true, 'showLatestActivityOnTop' => true));
     }
     $objResponse->addAssign('activity-stream-container', 'innerHTML', $streamHTML);
     // Log user engagement
     CEngagement::log($attachment['type'] . '.share', $my->id);
     return $objResponse->sendResponse();
 }
Пример #9
0
 public function ajaxAddApp($name, $position)
 {
     // Check permissions
     $my =& JFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     $filter = JFilterInput::getInstance();
     $name = $filter->clean($name, 'string');
     $position = $filter->clean($position, 'string');
     // Add application
     $appModel = CFactory::getModel('apps');
     $appModel->addApp($my->id, $name, $position);
     // Activity stream
     $act = new stdClass();
     $act->cmd = 'application.add';
     $act->actor = $my->id;
     $act->target = 0;
     $act->title = JText::_('COM_COMMUNITY_ACTIVITIES_APPLICATIONS_ADDED');
     $act->content = '';
     $act->app = $name;
     $act->cid = $my->id;
     CFactory::load('libraries', 'activities');
     CActivityStream::add($act);
     // User points
     CFactory::load('libraries', 'userpoints');
     CUserPoints::assignPoint('application.add');
     // Get application
     $id = $appModel->getUserApplicationId($name, $my->id);
     $appInfo = $appModel->getAppInfo($name);
     $params = new CParameter($appModel->getPluginParams($id, null));
     $isCoreApp = $params->get('coreapp');
     $app->id = $id;
     $app->title = isset($appInfo->title) ? $appInfo->title : '';
     $app->description = isset($appInfo->description) ? $appInfo->description : '';
     $app->isCoreApp = $isCoreApp;
     $app->name = $name;
     if (JFile::exists(CPluginHelper::getPluginPath('community', $name) . DS . $name . DS . 'favicon.png')) {
         $app->favicon['16'] = rtrim(JURI::root(), '/') . CPluginHelper::getPluginURI('community', $name) . '/' . $name . '/favicon.png';
     } else {
         $app->favicon['16'] = rtrim(JURI::root(), '/') . '/components/com_community/assets/app_favicon.png';
     }
     $tmpl = new CTemplate();
     $tmpl->set('apps', array($app));
     $tmpl->set('itemType', 'edit');
     $html = $tmpl->fetch('application.item');
     $objResponse = new JAXResponse();
     $objResponse->addScriptCall('joms.apps.showSettingsWindow', $app->id, $app->name);
     $objResponse->addScriptCall('joms.editLayout.addAppToLayout', $position, $html);
     // $objResponse->addScriptCall('cWindowHide();');
     return $objResponse->sendResponse();
 }
Пример #10
0
 /**
  * Ajax function to approve a friend request
  **/
 public function ajaxApproveRequest($requestId)
 {
     $filter = JFilterInput::getInstance();
     $requestId = $filter->clean($requestId, 'int');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $objResponse = new JAXResponse();
     $my = CFactory::getUser();
     $friendsModel = CFactory::getModel('friends');
     if ($friendsModel->isMyRequest($requestId, $my->id)) {
         $connected = $friendsModel->approveRequest($requestId);
         if ($connected) {
             $act = new stdClass();
             $act->cmd = 'friends.request.approve';
             $act->actor = $connected[0];
             $act->target = $connected[1];
             $act->title = '';
             //JText::_('COM_COMMUNITY_ACTIVITY_FRIENDS_NOW');
             $act->content = '';
             $act->app = 'friends.connect';
             $act->cid = 0;
             $friendId = $connected[0] == $my->id ? $connected[1] : $connected[0];
             $friend = CFactory::getUser($friendId);
             //generate the activity if enabled
             $userPointModel = CFactory::getModel('Userpoints');
             $point = $userPointModel->getPointData('friends.request.approve');
             if ($point->published) {
                 CActivityStream::add($act);
                 //add user points - give points to both party
                 //CFactory::load( 'libraries' , 'userpoints' );
                 CUserPoints::assignPoint('friends.request.approve');
                 CUserPoints::assignPoint('friends.request.approve', $friendId);
             }
             // Add the friend count for the current user and the connected user
             $friendsModel->addFriendCount($connected[0]);
             $friendsModel->addFriendCount($connected[1]);
             // Add notification
             //CFactory::load( 'libraries' , 'notification' );
             $params = new CParameter('');
             $params->set('url', 'index.php?option=com_community&view=profile&userid=' . $my->id);
             $params->set('friend', $my->getDisplayName());
             $params->set('friend_url', 'index.php?option=com_community&view=profile&userid=' . $my->id);
             CNotificationLibrary::add('friends_create_connection', $my->id, $friend->id, JText::sprintf('COM_COMMUNITY_FRIEND_REQUEST_APPROVED'), '', 'friends.approve', $params);
             $objResponse->addScriptCall('joms.jQuery("#msg-pending-' . $requestId . '").html("' . addslashes(JText::sprintf('COM_COMMUNITY_FRIENDS_NOW', $friend->getDisplayName())) . '");');
             $objResponse->addScriptCall('joms.notifications.updateNotifyCount();');
             $objResponse->addScriptCall('joms.jQuery("#noti-pending-' . $requestId . '").fadeOut(1000, function() { joms.jQuery("#noti-pending-' . $requestId . '").remove();} );');
             $objResponse->addScriptCall('update_counter("#jsMenuNotif > .notifcount", -1);');
             $objResponse->addScriptCall('update_counter("#jsMenuFriend > .notifcount", -1);');
             //trigger for onFriendApprove
             require_once JPATH_ROOT . '/components/com_community/controllers/friends.php';
             $eventObject = new stdClass();
             $eventObject->profileOwnerId = $my->id;
             $eventObject->friendId = $friendId;
             CommunityFriendsController::triggerFriendEvents('onFriendApprove', $eventObject);
             unset($eventObject);
         }
     } else {
         $objResponse->addScriptCall('joms.jQuery("#error-pending-' . $requestId . '").html("' . JText::_('COM_COMMUNITY_FRIENDS_NOT_YOUR_REQUEST') . '");');
         $objResponse->addScriptCall('joms.jQuery("#error-pending-' . $requestId . '").attr("class", "error");');
     }
     return $objResponse->sendResponse();
 }
Пример #11
0
 public static function addJomSocialActivityComment($comment, $blogTitle)
 {
     $jsCoreFile = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php';
     $config = EasyBlogHelper::getConfig();
     // We do not want to add activities if new blog activity is disabled.
     if (!$config->get('integrations_jomsocial_comment_new_activity')) {
         return false;
     }
     if (JFile::exists($jsCoreFile)) {
         require_once $jsCoreFile;
         $config = EasyBlogHelper::getConfig();
         $command = 'easyblog.comment.add';
         $maxTitleLength = $config->get('jomsocial_blog_title_length', 80);
         if (JString::strlen($blogTitle) > $maxTitleLength) {
             $blogTitle = JString::substr($blogTitle, 0, $maxTitleLength) . '...';
         }
         $blogLink = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $comment->post_id, false, true) . '#comment-' . $comment->id;
         $content = '';
         if ($config->get('integrations_jomsocial_submit_content')) {
             $content = $comment->comment;
             $content = EasyBlogCommentHelper::parseBBCode($content);
             $content = nl2br($content);
             $content = strip_tags($content);
             $content = JString::substr($content, 0, $config->get('integrations_jomsocial_comments_length'));
         }
         $obj = new stdClass();
         if (!$comment->created_by) {
             $obj->title = JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_GUEST_COMMENT_ADDED', $blogLink, $blogTitle);
         } else {
             $obj->title = JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_COMMENT_ADDED', $blogLink, $blogTitle);
         }
         $obj->content = $config->get('integrations_jomsocial_submit_content') ? $content : '';
         $obj->cmd = $command;
         $obj->actor = $comment->created_by;
         $obj->target = 0;
         $obj->app = 'easyblog';
         $obj->cid = $comment->id;
         if ($config->get('integrations_jomsocial_activity_likes')) {
             $obj->like_id = $comment->id;
             $obj->like_type = 'com_easyblog.comments';
         }
         if ($config->get('integrations_jomsocial_activity_comments')) {
             $obj->comment_id = $comment->id;
             $obj->comment_type = 'com_easyblog.comments';
         }
         // add JomSocial activities
         CFactory::load('libraries', 'activities');
         CActivityStream::add($obj);
     }
 }
Пример #12
0
<?php

/**
 * Example script for adding an entry to JomSocial wall.  In this example, it just adds ...
 * '{actor} sent {target} a drink'
 * ... to the wall, getting {actor} from logged in user, and {target} from a field on the form.
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die;
include_once JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php';
$myuser =& JFactory::getUser();
$act = new stdClass();
$act->cmd = 'wall.write';
$act->actor = $myuser->get('id');
$act->target = $fabrikFormData['other_user_raw'];
$act->title = JText::_('{actor} sent {target} a drink');
$act->content = '';
$act->app = 'wall';
$act->cid = 0;
CFactory::load('libraries', 'activities');
CActivityStream::add($act);
Пример #13
0
 function refundDeal($user_id, $point)
 {
     $api_AUP = JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'userpoints.php';
     require_once $api_AUP;
     $juser =& JFactory::getUser($userId);
     if ($juser->id != 0) {
         $aid = $juser->aid;
         if (is_null($aid)) {
             $aid = 0;
             $acl =& JFactory::getACL();
             $grp = $acl->getAroGroup($juser->id);
             $group = 'USERS';
             if ($acl->is_group_child_of($grp->name, $group)) {
                 $aid = 1;
                 // Fudge Authors, Editors, Publishers and Super Administrators into the special access group
                 if ($acl->is_group_child_of($grp->name, 'Registered') || $acl->is_group_child_of($grp->name, 'Public Backend')) {
                     $aid = 2;
                 }
             }
         }
         $user = CFactory::getUser($userId);
         $points = $user->getKarmaPoint();
         $point = $point / 2;
         $user->_points = $points - $point;
         $user->save();
         $act = new stdClass();
         $act->cmd = 'wall.write';
         $act->actor = $user_id;
         $act->target = 0;
         $act->title = JText::_('{actor} just refund a Deal');
         $act->content = '';
         $act->app = 'wall';
         $act->cid = 0;
         CFactory::load('libraries', 'activities');
         CActivityStream::add($act);
     }
 }
Пример #14
0
 public function onAfterThankyou($target, $actor, $message)
 {
     CFactory::load('libraries', 'userpoints');
     CUserPoints::assignPoint('com_kunena.thread.thankyou', $target);
     $username = KunenaFactory::getUser($actor)->username;
     $act = new stdClass();
     $act->cmd = 'wall.write';
     $act->actor = JFactory::getUser()->id;
     $act->target = $target;
     $act->title = JText::_('{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_THANKYOU_TITLE', $username));
     $act->content = NULL;
     $act->app = 'kunena.thankyou';
     $act->cid = $target;
     $act->access = $this->getAccess($message->getCategory());
     // Comments and like support
     $act->comment_id = $target;
     $act->comment_type = 'kunena.thankyou';
     $act->like_id = $target;
     $act->like_type = 'kunena.thankyou';
     // Do not add private activities
     if ($act->access > 20) {
         return;
     }
     CFactory::load('libraries', 'activities');
     CActivityStream::add($act);
 }
Пример #15
0
 function streamActivity($action, $obj)
 {
     global $option;
     $app =& JFactory::getApplication();
     $cwConfig = $app->getUserState(SESSION_CONFIG);
     $user =& JFactory::getUser();
     $menu =& JSite::getMenu();
     $mnuitems = $menu->getItems('link', 'index.php?option=' . $option . '&view=crosswords');
     $itemid = isset($mnuitems[0]) ? '&amp;Itemid=' . $mnuitems[0]->id : '';
     if (strcasecmp($cwConfig[ACTIVITY_STREAM_TYPE], COMPONENT_JOMSOCIAL) == 0) {
         $API = JPATH_SITE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'userpoints.php';
         if (file_exists($API)) {
             include_once $API;
             $act = new stdClass();
             $act->cmd = 'wall.write';
             $act->actor = $user->id;
             $act->target = 0;
             // no target
             $act->content = '';
             $act->app = 'wall';
             $act->cid = 0;
             switch ($action) {
                 case 1:
                     // New question
                     $act->title = JText::_('{actor} ' . JText::_('TXT_SUBMITTED_CROSSWORD_QUESTION'));
                     break;
                 case 2:
                     // Solved crossword
                     $text = JText::_('TXT_SOLVED_CROSSWORD');
                     $link = JRoute::_('index.php?option=' . $option . '&view=crosswords&task=view&id=' . $obj->id . ':' . $obj->alias . $itemid);
                     $act->title = JText::_('{actor} ' . $text . ' <a href="' . $link . '">' . $obj->title . '</a>');
                     break;
             }
             CFactory::load('libraries', 'activities');
             CActivityStream::add($act);
         }
     } else {
         if (strcasecmp($cwConfig[ACTIVITY_STREAM_TYPE], 'touch') == 0) {
             $API = JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'api.php';
             if (file_exists($API)) {
                 require_once $API;
                 $capi = new JSCommunityApi();
                 if ($user->id) {
                     $link = JRoute::_('index.php?option=' . $option . '&view=crosswords&task=view&id=' . $obj->id . ":" . $obj->alias . $itemid);
                     $icon = JURI::base() . 'components/' . $option . '/assets/images/logo.png';
                     $text = '';
                     switch ($action) {
                         case 1:
                             // New question
                             $text = $user->{$cwConfig}[USER_NAME] . ' ' . JText::_('TXT_SUBMITTED_CROSSWORD_QUESTION');
                             break;
                         case 2:
                             // solved crossword
                             $text = $user->{$cwConfig}[USER_NAME] . ' ' . JText::_('TXT_SOLVED_CROSSWORD') . ' <a href="' . $link . '">' . $obj->title . '</a>';
                             break;
                     }
                     $capi->registerActivity(0, $text, $user->get('id'), $icon, 'user', null, $option, '', 'Crosswords');
                 }
             }
         }
     }
 }
Пример #16
0
 public function ajaxUpdateStatus($eventId, $status)
 {
     $filter = JFilterInput::getInstance();
     $eventId = $filter->clean($eventId, 'int');
     $status = $filter->clean($status, 'int');
     $target = NULL;
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $my = CFactory::getUser();
     $objResponse = new JAXResponse();
     $memberId = $my->id;
     $modal =& $this->getModel('events');
     $event =& JTable::getInstance('Event', 'CTable');
     $event->load($eventId);
     CFactory::load('helpers', 'event');
     $handler = CEventHelper::getHandler($event);
     if (!$handler->isAllowed()) {
         $objResponse->addAlert(JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN'));
         return $objResponse->sendResponse();
     }
     if ($event->ticket && ($status == COMMUNITY_EVENT_STATUS_ATTEND && $event->confirmedcount + 1 > $event->ticket)) {
         $objResponse->addAlert(JText::_('COM_COMMUNITY_EVENTS_TICKET_FULL'));
         return $objResponse->sendResponse();
     }
     $eventMember =& JTable::getInstance('EventMembers', 'CTable');
     $eventMember->load($memberId, $eventId);
     if ($eventMember->permission != 1 && $eventMember->permission != 2) {
         $eventMember->permission = 3;
     }
     $date =& JFactory::getDate();
     $eventMember->created = $date->toMYSQL();
     $eventMember->status = $status;
     $eventMember->store();
     $event->updateGuestStats();
     $event->store();
     //activities stream goes here.
     $url = $handler->getFormattedLink('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false);
     CFactory::load('helpers', 'event');
     // We update the activity only if a user attend an event and the event was set to public event
     if ($status == COMMUNITY_EVENT_STATUS_ATTEND && $handler->isPublic()) {
         $command = 'events.attendence.attend';
         $actor = $my->id;
         $target = 0;
         $content = '';
         $cid = $event->id;
         $app = 'events';
         $act = $handler->getActivity($command, $actor, $target, $content, $cid, $app);
         $act->eventid = $event->id;
         $params = new CParameter('');
         $action_str = 'events.attendence.attend';
         $params->set('eventid', $event->id);
         $params->set('action', $action_str);
         $params->set('event_url', $url);
         // Add activity logging
         CFactory::load('libraries', 'activities');
         CActivityStream::add($act, $params->toString());
     }
     //trigger goes here.
     CFactory::load('libraries', 'apps');
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $params = array();
     $params[] =& $event;
     $params[] = $my->id;
     $params[] = $status;
     if (!is_null($target)) {
         $params[] = $target;
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_EVENTS, COMMUNITY_CACHE_TAG_ACTIVITIES));
     CFactory::load('libraries', 'events');
     $html = CEvents::getEventMemberHTML($event->id);
     if ($status == COMMUNITY_EVENT_STATUS_ATTEND) {
         $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_ATTENDING_EVENT_MESSAGE');
     } else {
         $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_NOT_ATTENDING_EVENT_MESSAGE');
     }
     $objResponse->addScriptCall('__callback', $html);
     $objResponse->addScriptCall("joms.jQuery('#community-event-rsvp-alert .cdata').html('{$RSVPmessage}');");
     return $objResponse->sendResponse();
 }
Пример #17
0
    /**
     * Streams activity to selected extension stream. The parameters should include required values based on extension as associative array
     *
     * <ul>
     * <li>command: command for jomsocial activity, mostly component_name.action</li>
     * <li>title: title of the stream</li>
     * <li>description: short description. if full text is passed it will be stripped upto length <code>$params['length']</code></li>
     * <li>length: max length of the activity description</li>
     * <li>href: url of the stream</li>
     * <li>icon: icon to be used for mighty touch stream</li>
     * <li>component: component name i.e.com_yourcomponentname</li>
     * <li>group: group name for touch stream. ex. Articles</li>
     * </ul>
     *
     * @param string $system Component to stream
     * @param int $userid User id
     * @param array $params params based on component type
     */
    public static function stream_activity($system, $userid, $params = array())
    {
        switch ($system) {
            case 'jomsocial':
                $api = JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php';
                if (file_exists($api) && !empty($params['title']) && !empty($params['command'])) {
                    include_once $api;
                    CFactory::load('libraries', 'activities');
                    $act = new stdClass();
                    $act->cmd = 'wall.write';
                    $act->target = 0;
                    $act->app = 'wall';
                    $act->cid = 0;
                    $act->comment_id = CActivities::COMMENT_SELF;
                    $act->like_id = CActivities::LIKE_SELF;
                    $act->actor = $userid;
                    $act->title = $params['title'];
                    $act->comment_type = $params['command'];
                    $act->like_type = $params['command'];
                    $act->access = 0;
                    if (!empty($params['description']) && !empty($params['length'])) {
                        $content = CJFunctions::substrws($params['description'], $params['length']);
                        if (!empty($params['href'])) {
                            $act->content = $content . '
									<div style="margin-top: 5px;">
										<div style="float: right; font-weight: bold; font-size: 12px;">
											<a href="' . $params['href'] . '">' . JText::_('COM_CJLIB_READ_MORE') . '</a>
										</div>
										<div style="clear: both;"></div>
									</div>';
                        } else {
                            $act->content = $content;
                        }
                    }
                    CActivityStream::add($act);
                }
                break;
            case 'cb':
                global $_CB_framework, $_CB_database, $ueConfig, $mainframe;
                $api = JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php';
                if (!is_file($api)) {
                    return;
                }
                require_once $api;
                cbimport('cb.database');
                cbimport('cb.tables');
                cbimport('cb.field');
                cbimport('language.front');
                $activity = new cbactivityActivity($_CB_database);
                $activity->set('user_id', (int) $userid);
                $activity->set('type', 'profile');
                $activity->set('subtype', 'registration');
                $activity->set('title', 'has joined [sitename_linked]');
                $activity->set('icon', 'nameplate');
                $activity->set('date', cbactivityClass::getUTCDate());
                $activity->store();
                break;
            case 'easysocial':
                $api = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_easysocial' . DS . 'includes' . DS . 'foundry.php';
                if (file_exists($api)) {
                    require_once $api;
                    $stream = Foundry::stream();
                    $template = $stream->getTemplate();
                    $content = $params['length'] > 0 ? CJFunctions::substrws($params['description'], $params['length']) : $params['description'];
                    $template->setActor($userid, 'user');
                    $template->setContext($params['item_id'], $params['context']);
                    $template->setTitle($params['title']);
                    $template->setContent($content);
                    $template->setVerb('create');
                    // 					$template->setSideWide( true );
                    $template->setType('full');
                    $stream->add($template);
                }
                break;
        }
    }
Пример #18
0
 public function addActivityRanks($userRanks)
 {
     $core = JPATH_ROOT . '/components/com_community/libraries/core.php';
     $config = DiscussHelper::getConfig();
     $my = JFactory::getUser();
     if (!JFile::exists($core)) {
         return false;
     }
     require_once $core;
     $lang = JFactory::getLanguage();
     $lang->load('com_easydiscuss', JPATH_ROOT);
     // We do not want to add activities if ranking activity is disabled.
     if (!$config->get('integration_jomsocial_activity_ranks', 0)) {
         return false;
     }
     $title = $this->getActivityTitle($userRanks->title);
     $obj = new stdClass();
     $obj->title = JText::sprintf('COM_EASYDISCUSS_JOMSOCIAL_ACTIVITY_RANKS_ITEM', $title);
     $obj->content = '';
     $obj->cmd = 'easydiscuss.rank.up';
     $obj->actor = $my->id;
     $obj->target = 0;
     $obj->like_id = $userRanks->uniqueId;
     $obj->like_type = 'com_easydiscuss_rank';
     $obj->comment_id = $userRanks->uniqueId;
     $obj->comment_type = 'com_easydiscuss_rank';
     $obj->app = 'easydiscuss';
     $obj->cid = $userRanks->uniqueId;
     // add JomSocial activities
     CFactory::load('libraries', 'activities');
     CActivityStream::add($obj);
 }
Пример #19
0
 function repost($response, $actId, $from = 'frontpage')
 {
     JPlugin::loadLanguage('plg_activitycomment', JPATH_ADMINISTRATOR);
     $my = CFactory::getUser();
     if ($my->id == 0) {
         $response->addScriptCall('alert', 'NOT ALLOWED');
         return $response->sendResponse();
     }
     $db = JFactory::getDBO();
     $query = 'SELECT * FROM #__community_activities WHERE `id`=' . $db->Quote($actId);
     $db->setQuery($query);
     $activity = $db->loadObject();
     // Add activity logging
     CFactory::load('libraries', 'activities');
     $actor = CFactory::getUser($activity->actor);
     $act = new stdClass();
     $author = '<a href="' . CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id) . '">' . $my->getDisplayName() . '</a>';
     $act->cmd = 'activitycomment.repost';
     $act->actor = $my->id;
     $act->target = 0;
     $act->title = JText::sprintf('%1$s,', $author) . ' ' . $activity->title;
     $act->content = $activity->content;
     $act->app = $activity->app;
     $act->cid = $my->id;
     CActivityStream::add($act);
     $friendsModel =& CFactory::getModel('friends');
     CFactory::load('helpers', 'time');
     $memberSince = cGetDate($my->registerDate);
     $friendIds = $friendsModel->getFriendIds($my->id);
     include_once JPATH_COMPONENT . DS . 'libraries' . DS . 'activities.php';
     $act = new CActivityStream();
     $config = CFactory::getConfig();
     if ($from == 'frontpage') {
         $html = $act->getHTML('', '', null, $config->get('maxacitivities'));
     } else {
         $html = $act->getHTML($my->id, $friendIds, $memberSince, 10);
     }
     $response->addAssign('activity-stream-container', 'innerHTML', $html);
     return $response->sendResponse();
 }
Пример #20
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
         * 
         **/
        function ajaxSaveWall($response, $message, $uniqueId, $cache_id = "")
        {
            $my = CFactory::getUser();
            $user = CFactory::getUser($uniqueId);
            $config = CFactory::getConfig();
            JPlugin::loadLanguage('plg_walls', JPATH_ADMINISTRATOR);
            // Load libraries
            CFactory::load('models', 'photos');
            CFactory::load('libraries', 'wall');
            CFactory::load('helpers', 'url');
            CFactory::load('libraries', 'activities');
            $message = JString::trim($message);
            $message = strip_tags($message);
            if (empty($message)) {
                $response->addAlert(JText::_('PLG_WALLS_PLEASE_ADD_MESSAGE'));
            } else {
                $maxchar = $this->params->get('charlimit', 0);
                if (!empty($maxchar)) {
                    $msglength = strlen($message);
                    if ($msglength > $maxchar) {
                        $message = substr($message, 0, $maxchar);
                    }
                }
                // @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=profile&userid=' . $user->id));
                    $filter->setType('message');
                    $filter->setIP($_SERVER['REMOTE_ADDR']);
                    if ($filter->isSpam()) {
                        $response->addAlert(JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM'));
                        return $response->sendResponse();
                    }
                }
                $wall = CWallLibrary::saveWall($uniqueId, $message, 'user', $my, $my->id == $user->id, 'profile,profile');
                CFactory::load('libraries', 'activities');
                CFactory::load('helpers', 'videos');
                $matches = cGetVideoLinkMatches($message);
                $activityParams = '';
                // We only want the first result of the video to be in the activity
                if ($matches) {
                    $videoLink = $matches[0];
                    CFactory::load('libraries', 'videos');
                    $videoLib = new CVideoLibrary();
                    $provider = $videoLib->getProvider($videoLink);
                    $activityParams .= 'videolink=' . $videoLink . "\r\n";
                    if ($provider->isValid()) {
                        $activityParams .= 'url=' . $provider->getThumbnail();
                    }
                }
                $act = new stdClass();
                $act->cmd = 'profile.wall.create';
                $act->actor = $my->id;
                $act->target = $uniqueId;
                $act->title = JText::_('COM_COMMUNITY_ACTIVITIES_WALL_POST_PROFILE');
                $act->content = '';
                $act->app = 'walls';
                $act->cid = $wall->id;
                // Allow comments on all these
                $act->comment_id = CActivities::COMMENT_SELF;
                $act->comment_type = 'walls';
                CActivityStream::add($act, $activityParams);
                // @rule: Send notification to the profile user.
                if ($my->id != $user->id) {
                    CFactory::load('libraries', 'notification');
                    $params = new CParameter('');
                    $params->set('url', 'index.php?option=com_community&view=profile&userid=' . $user->id);
                    $params->set('message', $message);
                    CNotificationLibrary::add('etype_profile_submit_wall', $my->id, $user->id, JText::sprintf('PLG_WALLS_NOTIFY_EMAIL_SUBJECT', $my->getDisplayName()), '', 'profile.wall', $params);
                }
                //add user points
                CFactory::load('libraries', 'userpoints');
                CUserPoints::assignPoint('profile.wall.create');
                $response->addScriptCall('joms.walls.insert', $wall->content);
                $response->addScriptCall('if(joms.jQuery(".content-nopost").length){
											joms.jQuery("#wall-empty-container").remove();
										}');
                $cache =& JFactory::getCache('plgCommunityWalls');
                $cache->remove($cache_id);
                $cache =& JFactory::getCache('plgCommunityWalls_fullview');
                $cache->remove($cache_id);
            }
            return $response;
        }
Пример #21
0
 /**
  * Maps a user status with JomSocial's user status
  *
  *	@param	Array	User values
  **/
 public function mapStatus($userId)
 {
     $result = $this->facebook->api('/me/statuses');
     $status = isset($result['data'][0]) ? $result['data'][0] : '';
     if (empty($status)) {
         return;
     }
     CFactory::load('helpers', 'linkgenerator');
     $connectModel = CFactory::getModel('Connect');
     $status = $status['message'];
     $rawStatus = $status;
     // @rule: Do not strip html tags but escape them.
     CFactory::load('helpers', 'string');
     $status = CStringHelper::escape($status);
     // @rule: Autolink hyperlinks
     $status = CLinkGeneratorHelper::replaceURL($status);
     // @rule: Autolink to users profile when message contains @username
     $status = CLinkGeneratorHelper::replaceAliasURL($status);
     // Reload $my from CUser so we can use some of the methods there.
     $my = CFactory::getUser($userId);
     $params = $my->getParams();
     // @rule: For existing statuses, do not set them.
     if ($connectModel->statusExists($status, $userId)) {
         return;
     }
     CFactory::load('libraries', 'activities');
     $act = new stdClass();
     $act->cmd = 'profile.status.update';
     $act->actor = $userId;
     $act->target = $userId;
     $act->title = '{actor} ' . $status;
     $act->content = '';
     $act->app = 'profile';
     $act->cid = $userId;
     $act->access = $params->get('privacyProfileView');
     $act->comment_id = CActivities::COMMENT_SELF;
     $act->comment_type = 'profile.status';
     $act->like_id = CActivities::LIKE_SELF;
     $act->like_type = 'profile.status';
     CActivityStream::add($act);
     //add user points
     CFactory::load('libraries', 'userpoints');
     CUserPoints::assignPoint('profile.status.update');
     // Update status from facebook.
     $my->setStatus($rawStatus);
 }
Пример #22
0
	public function onAfterThankyou($thankyoutargetid, $username , $message) {
		CFactory::load ( 'libraries', 'userpoints' );
		CUserPoints::assignPoint ( 'com_kunena.thread.thankyou', $thankyoutargetid );

		// Check for permisions of the current category - activity only if public or registered
		if ($message->getCategory()->pub_access <= 0) {
			//activity stream - reply post
			require_once KPATH_SITE.'/lib/kunena.link.class.php';
			$JSPostLink = CKunenaLink::GetThreadPageURL ( 'view', $message->catid, $message->thread, 0 );

			$act = new stdClass ();
			$act->cmd = 'wall.write';
			$act->actor = JFactory::getUser()->id;
			$act->target = $thankyoutargetid;
			$act->title = JText::_ ( '{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::_( 'COM_KUNENA_JS_ACTIVITYSTREAM_THANKYOU' ).' <a href="' . $JSPostLink . '">' . $message->subject . '</a> ' . JText::_ ( 'COM_KUNENA_JS_ACTIVITYSTREAM_REPLY_MSG2' ) );
			$act->content = NULL;
			$act->app = 'kunena.thankyou';
			$act->cid = $message->id;

			// jomsocial 0 = public, 20 = registered members
			if ($message->getCategory()->pub_access == 0) {
				$act->access = 0;
			} else {
				$act->access = 20;
			}

			CFactory::load ( 'libraries', 'activities' );
			CActivityStream::add ( $act );
		}
	}
Пример #23
0
 public function onAfterThankyou($thankyoutargetid, $username, $message)
 {
     CFactory::load('libraries', 'userpoints');
     CUserPoints::assignPoint('com_kunena.thread.thankyou', $thankyoutargetid);
     if (!empty($message->parent)) {
         //activity stream - reply post
         require_once KPATH_SITE . '/lib/kunena.link.class.php';
         $JSPostLink = CKunenaLink::GetThreadPageURL('view', $message->get('catid'), $message->get('thread'), 1);
         $act = new stdClass();
         $act->cmd = 'wall.write';
         $act->actor = JFactory::getUser()->id;
         $act->target = $thankyoutargetid;
         $act->title = JText::_('{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::_('COM_KUNENA_JS_ACTIVITYSTREAM_THANKYOU') . ' <a href="' . $JSPostLink . '">' . $message->get('subject') . '</a> ');
         $act->content = NULL;
         $act->app = 'kunena.thankyou';
         $act->cid = $thankyoutargetid;
         $act->access = $this->getAccess($message);
         CFactory::load('libraries', 'activities');
         CActivityStream::add($act);
     }
 }
Пример #24
0
 /**
  * List down all connection request waiting for user to approve
  */
 public function pending()
 {
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->blockUnregister();
     }
     $view = $this->getView('friends');
     $model =& $this->getModel('friends');
     $usermodel =& $this->getModel('user');
     // @todo: make sure the rejectId and approveId is valid for this user
     if ($id = JRequest::getVar('rejectId', 0, 'GET')) {
         $mainframe =& JFactory::getApplication();
         if (!$model->rejectRequest($id)) {
             $mainframe->enqueueMessage(JText::sprintf('COM_COMMUNITY_FRIENDS_REQUEST_REJECT_FAILED', $id));
         }
     }
     if ($id = JRequest::getVar('approveId', 0, 'GET')) {
         $mainframe =& JFactory::getApplication();
         $connected = $model->approveRequest($id);
         // If approbe id is not valid or already approve, $connected will
         // be null.. yuck
         if ($connected) {
             $act = new stdClass();
             $act->cmd = 'friends.request.approve';
             $act->actor = $connected[0];
             $act->target = $connected[1];
             $act->title = JText::_('COM_COMMUNITY_ACTIVITY_FRIENDS_NOW');
             $act->content = '';
             $act->app = 'friends';
             $act->cid = 0;
             CFactory::load('libraries', 'activities');
             CActivityStream::add($act);
             //add user points - give points to both parties
             CFactory::load('libraries', 'userpoints');
             CUserPoints::assignPoint('friends.request.approve');
             $friendId = $connected[0] == $my->id ? $connected[1] : $connected[0];
             $friend = CFactory::getUser($friendId);
             CUserPoints::assignPoint('friends.request.approve', $friendId);
             $mainframe->enqueueMessage(JText::sprintf('COM_COMMUNITY_FRIENDS_NOW', $friend->getDisplayName()));
         }
     }
     $data = new stdClass();
     $rpending = $model->getPending($my->id);
     $data->pending = $rpending;
     $data->pagination =& $model->getPagination();
     echo $view->get(__FUNCTION__, $data);
 }
Пример #25
0
 function showActivity($userid, $newPtype, $oldPtype)
 {
     if ($newPtype === $oldPtype) {
         return;
     }
     $ptName = XiptHelperProfiletypes::getProfileTypeData($newPtype, 'name');
     $act = new stdClass();
     $act->cmd = 'wall.write';
     $act->actor = $userid;
     $act->target = 0;
     // no target
     $changePt = XiptText::_('CHANGED_PROFILETYPE_TO');
     $act->title = JText::_('{actor}' . $changePt . $ptName);
     $act->content = '';
     $act->app = 'wall';
     $act->cid = 0;
     CFactory::load('libraries', 'activities');
     $act->comment_type = 'xipt_community.myaction';
     $act->comment_id = CActivities::COMMENT_SELF;
     $act->like_type = 'xipt_community.myaction';
     $act->like_id = CActivities::LIKE_SELF;
     CActivityStream::add($act);
     return true;
 }
Пример #26
0
 function _streamAddLake($lake)
 {
     include_once JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php';
     $lake_uri = ContentHelperRoute::getArticleRoute($lake->id, $lake->catid, $lake->sectionid);
     $lake_link = '<a href="' . $lake_uri . '">' . $lake->title . '</a>';
     // make sure the language file is loaded (if this was called from the api)
     $lang =& JFactory::getLanguage();
     $lang->load('com_relate');
     $act = new stdClass();
     $act->cmd = 'wall.write';
     $act->actor = $lake->created_by;
     $act->target = 0;
     $act->title = JText::sprintf('ADDED A LAKE', $lake_link);
     $act->content = '';
     $act->app = 'wall';
     $act->cid = 0;
     CFactory::load('libraries', 'activities');
     CActivityStream::add($act);
 }
Пример #27
0
 /**
  * AJAX method to add predefined activity
  * */
 public function ajaxAddPredefined($key, $message = '', $privacy = 0)
 {
     $objResponse = new JAXResponse();
     $my = CFactory::getUser();
     $filter = JFilterInput::getInstance();
     $key = $filter->clean($key, 'string');
     $message = $filter->clean($message, 'string');
     $privacy = $filter->clean($privacy, 'int');
     if (!COwnerHelper::isCommunityAdmin() || empty($message)) {
         return;
     }
     // Predefined system custom activity.
     $system = array('system.registered', 'system.populargroup', 'system.totalphotos', 'system.popularprofiles', 'system.popularphotos', 'system.popularvideos');
     $act = new stdClass();
     $act->actor = 0;
     //$my->id; System message should not capture actor. Otherwise the stream filter will be inaccurate
     $act->target = 0;
     $act->app = 'system';
     $act->access = !$privacy ? 0 : $privacy;
     $params = new CParameter('');
     if (in_array($key, $system)) {
         switch ($key) {
             case 'system.registered':
                 // $usersModel   = CFactory::getModel( 'user' );
                 // $now          = new JDate();
                 // $date         = CTimeHelper::getDate();
                 // $title        = JText::sprintf('COM_COMMUNITY_TOTAL_USERS_REGISTERED_THIS_MONTH_ACTIVITY_TITLE', $usersModel->getTotalRegisteredByMonth($now->format('Y-m')) , $date->_monthToString($now->format('m')));
                 $act->app = 'system.members.registered';
                 $act->cmd = 'system.registered';
                 $act->title = '';
                 $act->content = '';
                 $params->set('action', 'registered_users');
                 break;
             case 'system.populargroup':
                 // $groupsModel = CFactory::getModel('groups');
                 // $activeGroup = $groupsModel->getMostActiveGroup();
                 // $title       = JText::sprintf('COM_COMMUNITY_MOST_POPULAR_GROUP_ACTIVITY_TITLE', $activeGroup->name);
                 // $act->cmd    = 'groups.popular';
                 // $act->cid    = $activeGroup->id;
                 // $act->title  = $title;
                 $act->app = 'system.groups.popular';
                 $params->set('action', 'top_groups');
                 // $params->set('group_url', CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid='.$activeGroup->id));
                 break;
             case 'system.totalphotos':
                 // $photosModel = CFactory::getModel( 'photos' );
                 // $total       = $photosModel->getTotalSitePhotos();
                 $act->app = 'system.photos.total';
                 $act->cmd = 'photos.total';
                 $act->title = '';
                 //JText::sprintf('COM_COMMUNITY_TOTAL_PHOTOS_ACTIVITY_TITLE', $total);
                 $params->set('action', 'total_photos');
                 // $params->set('photos_url', CRoute::_('index.php?option=com_community&view=photos'));
                 break;
             case 'system.popularprofiles':
                 $act->app = 'system.members.popular';
                 $act->cmd = 'members.popular';
                 $act->title = '';
                 //JText::sprintf('COM_COMMUNITY_ACTIVITIES_TOP_PROFILES', 5);
                 $params->set('action', 'top_users');
                 // $params->set('count', 5);
                 break;
             case 'system.popularphotos':
                 $act->app = 'system.photos.popular';
                 $act->cmd = 'photos.popular';
                 $act->title = '';
                 //JText::sprintf('COM_COMMUNITY_ACTIVITIES_TOP_PHOTOS', 5);
                 $params->set('action', 'top_photos');
                 // $params->set('count', 5);
                 break;
             case 'system.popularvideos':
                 $act->app = 'system.videos.popular';
                 $act->cmd = 'videos.popular';
                 $act->title = '';
                 //JText::sprintf( 'COM_COMMUNITY_ACTIVITIES_TOP_VIDEOS', 5 );
                 $params->set('action', 'top_videos');
                 // $params->set('count', 5);
                 break;
         }
     } else {
         // For additional custom activities, we only take the content passed by them.
         if (!empty($message)) {
             $message = CStringHelper::escape($message);
             $app = explode('.', $key);
             $app = isset($app[0]) ? $app[0] : 'system';
             $act->app = 'system.message';
             $act->title = $message;
             $params->set('action', 'message');
         }
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES));
     // Allow comments on all these
     $act->comment_id = CActivities::COMMENT_SELF;
     $act->comment_type = $key;
     // Allow like for all admin activities
     $act->like_id = CActivities::LIKE_SELF;
     $act->like_type = $key;
     // Add activity logging
     CActivityStream::add($act, $params->toString());
     $objResponse->addAssign('activity-stream-container', 'innerHTML', $this->_getActivityStream());
     $objResponse->addScriptCall("joms.jQuery('.jomTipsJax').addClass('jomTips');");
     $objResponse->addScriptCall('joms.tooltip.setup();');
     return $objResponse->sendResponse();
 }
Пример #28
0
 public function _addToActivityStream($cid = 0)
 {
     // $cid shouldn't be 0
     if ($cid == 0) {
         return;
     }
     // Construct activity stream
     $act = new stdClass();
     $act->cid = $cid;
     $act->target = 0;
     $act->app = $this->type . '.featured';
     $act->cmd = $this->type . '.featured';
     $params = new JRegistry('');
     // Process each type of featured content
     switch ($this->type) {
         case FEATURED_EVENTS:
             //
             $table = JTable::getInstance('Event', 'CTable');
             $table->load($cid);
             $act->actor = $table->creator;
             $eventUrl = 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $table->id;
             $act->title = JText::sprintf('COM_COMMUNITY_ACTIVITIES_FEATURED_EVENT', $eventUrl, $table->title);
             $act->content = '<img src=\\"' . $table->getAvatar() . '\\" style=\\"border: 1px solid #eee;margin-right: 3px;\\" />';
             $act->comment_type = $act->app;
             $act->like_id = CActivities::LIKE_SELF;
             $act->like_type = $act->app;
             break;
         case FEATURED_GROUPS:
             //
             $table = JTable::getInstance('Group', 'CTable');
             $table->load($cid);
             $act->actor = $table->ownerid;
             $groupUrl = 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $table->id;
             $act->title = JText::sprintf('COM_COMMUNITY_ACTIVITIES_FEATURED_GROUP', $groupUrl, $table->name);
             $act->content = '<img src=\\"' . $table->getAvatar() . '\\" style=\\"border: 1px solid #eee;margin-right: 3px;\\" />';
             $act->comment_type = $act->app;
             $act->like_id = CActivities::LIKE_SELF;
             $act->like_type = $act->app;
             break;
         case FEATURED_USERS:
             $user = CFactory::getUser($cid);
             $ownerUrl = 'index.php?option=com_community&view=profile&userid=' . $user->id;
             $act->actor = $user->id;
             $act->title = '';
             //JText::sprintf('COM_COMMUNITY_ACTIVITIES_FEATURED_USER', '{owner_url}', $user->getDisplayName());
             $act->content = '';
             $act->comment_type = $act->app;
             $act->like_id = CActivities::LIKE_SELF;
             $act->like_type = $act->app;
             $params->set('userid', $user->id);
             $params->set('owner_url', $ownerUrl);
             break;
         case FEATURED_VIDEOS:
             $table = JTable::getInstance('Video', 'CTable');
             $table->load($cid);
             $videoUrl = $table->getViewURI();
             $ownerUrl = 'index.php?option=com_community&view=profile&userid=' . $table->creator;
             $user = CFactory::getUser($table->creator);
             $ownerName = $user->getDisplayName();
             $act->actor = $table->creator;
             $act->title = '';
             //JText::sprintf('COM_COMMUNITY_ACTIVITIES_FEATURED_VIDEO', '{owner_url}', $ownerName, '{video_url}');
             $config = CFactory::getConfig();
             $act->comment_type = $act->app;
             $act->like_id = CActivities::LIKE_SELF;
             $act->like_type = $act->app;
             $params->set('owner_url', $ownerUrl);
             $params->set('video_url', $videoUrl);
             // embed the video when click show more
             // now only applies to external video provider
             break;
         case FEATURED_ALBUMS:
             $table = JTable::getInstance('Album', 'CTable');
             $table->load($cid);
             $albumUrl = 'index.php?option=com_community&view=photos&task=album&albumid=' . $table->id;
             $ownerUrl = 'index.php?option=com_community&view=profile&userid=' . $table->creator;
             $user = CFactory::getUser($table->creator);
             $ownerName = $user->getDisplayName();
             $act->actor = $table->creator;
             $act->title = '';
             //JText::sprintf('COM_COMMUNITY_ACTIVITIES_FEATURED_ALBUM', '{owner_url}', $ownerName, '{album_url}');
             //$table->thumbnail= $table->getCoverThumbPath();
             //$table->thumbnail= ($table->thumbnail) ? JURI::root() . $table->thumbnail : JURI::root() . 'components/com_community/assets/album_thumb.jpg';
             $act->content = '';
             //<img src="' . $table->thumbnail . '" style="border: 1px solid #eee;margin-right: 3px;" />';
             $params->set('owner_url', $ownerUrl);
             $params->set('album_url', $albumUrl);
             $act->comment_type = $act->app;
             $act->like_id = CActivities::LIKE_SELF;
             $act->like_type = $act->app;
             break;
         default:
             // If featured type is unknown, we'll skip it
             return;
     }
     // Add activity logging with 0 points
     CActivityStream::add($act, $params->toString(), 0);
 }
Пример #29
0
	public static function addJomSocialActivity( $options = array() )
	{
		$defaultOptions = array(
			'comment'		=> '',
			'title'			=> '',
			'content'		=> '',
			'cmd'			=> '',
			'actor'			=> '',
			'target'		=> 0,
			'app'			=> '',
			'cid'			=> '',
			'comment_id'	=> '',
			'comment_type'	=> '',
			'like_id'		=> '',
			'like_type'		=> ''

		);

		$options = Komento::mergeOptions( $defaultOptions, $options );

		$jsCoreFile	= JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php';
		$config		= Komento::getConfig();

		if( !JFile::exists( $jsCoreFile ) )
		{
			return false;
		}
		require_once( $jsCoreFile );

		$obj				= (object) $options;

		// add JomSocial activities
		CFactory::load ( 'libraries', 'activities' );
		CActivityStream::add( $obj );
	}
Пример #30
0
 public function onAfterThankyou($actor, $target, $message)
 {
     CFactory::load('libraries', 'userpoints');
     CUserPoints::assignPoint('com_kunena.thread.thankyou', $target);
     $actor = CFactory::getUser($actor);
     $target = CFactory::getUser($target);
     //Create CParameter use for params
     $params = new CParameter('');
     $params->set('actorName', $actor->getDisplayName());
     $params->set('recipientName', $target->getDisplayName());
     $params->set('recipientUrl', 'index.php?option=com_community&view=profile&userid=' . $target->id);
     // Actor Link
     $params->set('url', JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $message->getPermaUrl(null));
     // {url} tag for activity. Used when hovering over avatar in notification window, as well as in email notification
     $params->set('title', $message->displayField('subject'));
     // (title) tag in language file
     $params->set('title_url', $message->getPermaUrl());
     // Make the title in notification - linkable
     $params->set('message', $message->message);
     // (message) tag in language file
     $params->set('actor', $actor->getDisplayName());
     // Actor in the stream
     $params->set('actor_url', 'index.php?option=com_community&view=profile&userid=' . $actor->id);
     // Actor Link
     // Finally, send notifications
     CNotificationLibrary::add('kunena_thankyou', $actor->id, $target->id, JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_THANKYOU_TITLE_ACT'), JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_THANKYOU_TEXT'), '', $params);
     $act = new stdClass();
     $act->cmd = 'wall.write';
     $act->actor = $actor->id;
     $act->target = $target->id;
     $act->title = JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_THANKYOU_WALL', $params->get('actor_url'), $params->get('actor'), $params->get('recipientUrl'), $params->get('recipientName'), $params->get('url'), $params->get('title'));
     $act->content = NULL;
     $act->app = 'kunena.message.thankyou';
     $act->cid = $target->id;
     $act->access = $this->getAccess($message->getCategory());
     // Comments and like support
     $act->comment_id = $target->id;
     $act->comment_type = 'kunena.message.thankyou';
     $act->like_id = $target->id;
     $act->like_type = 'kunena.message.thankyou';
     // Do not add private activities
     if ($act->access > 20) {
         return;
     }
     CFactory::load('libraries', 'activities');
     $table = CActivityStream::add($act);
     if (is_object($table)) {
         $table->like_id = $table->id;
         $table->store();
     }
 }