Example #1
0
 function display($data = null)
 {
     $mainframe = JFactory::getApplication();
     $config = CFactory::getConfig();
     $document =& JFactory::getDocument();
     $document->setTitle(JText::sprintf('CC FRONTPAGE TITLE', $config->get('sitename')));
     $document->setLink(CRoute::_('index.php?option=com_community'));
     $my = CFactory::getUser();
     CFactory::load('libraries', 'activities');
     CFactory::load('helpers', 'string');
     $act = new CActivityStream();
     $rows = $act->getFEED('', '', null, $mainframe->getCfg('feed_limit'));
     if ($config->get('showactivitystream') == COMMUNITY_SHOW || $config->get('showactivitystream') == COMMUNITY_MEMBERS_ONLY && $my->id != 0) {
         foreach ($rows->data as $row) {
             if ($row->type != 'title') {
                 // load individual item creator class
                 $item = new JFeedItem();
                 // cannot escape the title. it's already formated. we should
                 // escape it during CActivityStream::add
                 //$item->title 		= CStringHelper::escape($row->title);
                 $item->title = $row->title;
                 $item->link = CRoute::_('index.php?option=com_community&view=profile&userid=' . $row->actor);
                 $item->description = "<img src=\"{$row->favicon}\" alt=\"\"/>&nbsp;" . $row->title;
                 $item->date = $row->createdDate;
                 $item->category = '';
                 //$row->category;
                 // Make sure url is absolute
                 $item->description = JString::str_ireplace('href="/', 'href="' . JURI::base(), $item->description);
                 // loads item info into rss array
                 $document->addItem($item);
             }
         }
     }
 }
Example #2
0
 /**
  * Displays the viewing profile page.
  * 	 	
  * @access	public
  * @param	array  An associative array to display the fields
  */
 public function profile(&$data)
 {
     $mainframe = JFactory::getApplication();
     $friendsModel = CFactory::getModel('friends');
     $showfriends = JRequest::getVar('showfriends', false);
     $userid = JRequest::getVar('userid', '');
     $user = CFactory::getUser($userid);
     $linkUrl = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id);
     $document = JFactory::getDocument();
     $document->setTitle(JText::sprintf('COM_COMMUNITY_USERS_FEED_TITLE', $user->getDisplayName()));
     $document->setDescription(JText::sprintf('COM_COMMUNITY_USERS_FEED_DESCRIPTION', $user->getDisplayName(), $user->lastvisitDate));
     $document->setLink($linkUrl);
     include_once JPATH_COMPONENT . '/libraries/activities.php';
     $act = new CActivityStream();
     $friendIds = $friendsModel->getFriendIds($user->id);
     $friendIds = $showfriends ? $friendIds : null;
     $rows = $act->getFEED($user->id, $friendIds, null, $mainframe->getCfg('feed_limit'));
     // add the avatar image
     $rssImage = new JFeedImage();
     $rssImage->url = $user->getThumbAvatar();
     $rssImage->link = $linkUrl;
     $rssImage->width = 64;
     $rssImage->height = 64;
     $document->image = $rssImage;
     //CFactory::load( 'helpers' , 'string' );
     //CFactory::load( 'helpers' , 'time' );
     foreach ($rows->data as $row) {
         if ($row->type != 'title') {
             // Get activities link
             $pattern = '/<a href=\\"(.*?)\\"/';
             preg_match_all($pattern, $row->title, $matches);
             // Use activity owner link when activity link is not available
             if (!empty($matches[1][1])) {
                 $linkUrl = $matches[1][1];
             } else {
                 if (!empty($matches[1][0])) {
                     $linkUrl = $matches[1][0];
                 }
             }
             // load individual item creator class
             $item = new JFeedItem();
             $item->title = $row->title;
             $item->link = $linkUrl;
             $item->description = "<img src=\"{$row->favicon}\" alt=\"\" />&nbsp;" . $row->title;
             $item->date = CTimeHelper::getDate($row->createdDateRaw)->toRFC822();
             $item->category = '';
             //$row->category;
             $item->description = CString::str_ireplace('_QQQ_', '"', $item->description);
             // Make sure url is absolute
             $pattern = '/href="(.*?)index.php/';
             $replace = 'href="' . JURI::base() . 'index.php';
             $string = $item->description;
             $item->description = preg_replace($pattern, $replace, $string);
             // loads item info into rss array
             $document->addItem($item);
         }
     }
 }
Example #3
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&amp;view=poll&amp;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);
     }
 }
Example #4
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);
     }
 }
Example #5
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);
 }
Example #6
0
 /**
  * Delete the photo, the original and the actual resized photos and thumbnails
  */
 public function delete($pk = null)
 {
     $storage = CStorage::getStorage($this->storage);
     $storage->delete($this->image);
     $storage->delete($this->thumbnail);
     /* We did store original than now time to remove it */
     if (!empty($this->original)) {
         /* Original do not sync with 3rd storage than we don't need to use $storage->delete; even it would be same */
         if (JFile::exists(JPATH_ROOT . '/' . $this->original)) {
             JFile::delete(JPATH_ROOT . '/' . $this->original);
         }
         $originalDir = dirname(JPATH_ROOT . '/' . $this->original);
         $files = JFolder::files($originalDir);
         /* If the original path is empty, we can delete it too */
         if (empty($files)) {
             JFolder::delete($originalDir);
         }
     }
     // if the photo is the album cover, set the album cover as default 0
     $album = JTable::getInstance('Album', 'CTable');
     $album->load($this->albumid);
     $album->set('photoid', 0);
     $album->store();
     // delete the tags
     CFactory::load('libraries', 'phototagging');
     $phototagging = new CPhotoTagging();
     $phototagging->removeTagByPhoto($this->id);
     // delete the activities
     CActivities::remove('photos', $this->id);
     //Remove photo from activity stream
     CActivityStream::remove('photo.like', $this->id);
     // delete the comments
     $wall = CFactory::getModel('wall');
     $wall->deleteAllChildPosts($this->id, 'photos');
     /* And now finally we do delete this photo in database */
     /* return parent::delete(); */
     /**
      * @since 3.2
      * We do not delete database record for now. Leave it for cron !
      * @todo Considering local files should be deleted this time or not ?
      */
     $this->published = 0;
     $this->status = 'delete';
     $this->store();
 }
Example #7
0
 /**
  * Display the photo thumbnails from an album
  **/
 public function album()
 {
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     $config = CFactory::getConfig();
     $handler = $this->_getHandler();
     $my = CFactory::getUser();
     CFactory::load('libraries', 'activities');
     // Get show photo location map by default
     $photoMapsDefault = $config->get('photosmapdefault');
     $albumId = JRequest::getVar('albumid', '', 'GET');
     $defaultId = JRequest::getVar('photo', '', 'GET');
     $userId = JRequest::getVar('userid', '', 'GET');
     $user = CFactory::getUser($userId);
     // Set pathway for group photos
     // Community > Groups > Group Name > Photos > Album Name
     $pathway =& $mainframe->getPathway();
     $groupId = JRequest::getVar('groupid', '', 'GET');
     if (!empty($groupId)) {
         $group =& JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         $pathway->addItem(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
         $pathway->addItem($group->name, CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId));
         $pathway->addItem(JText::_('COM_COMMUNITY_PHOTOS'), CRoute::_('index.php?option=com_community&view=photos&groupid=' . $groupId));
     } else {
         $pathway->addItem(JText::_('COM_COMMUNITY_PHOTOS'), CRoute::_('index.php?option=com_community&view=photos'));
         $pathway->addItem(JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $user->getDisplayName()), CRoute::_('index.php?option=com_community&view=photos&task=myphotos&userid=' . $userId));
     }
     $handler->setMiniHeader();
     if (empty($albumId)) {
         echo JText::_('COM_COMMUNITY_PHOTOS_NO_ALBUMID_ERROR');
         return;
     }
     if (!$handler->isAlbumBrowsable($albumId)) {
         return;
     }
     $album =& JTable::getInstance('Album', 'CTable');
     $album->load($albumId);
     //$photos		= $handler->getAlbumPhotos( $album->id );
     $photoPaginationLimit = intval($config->get('photopaginationlimit'));
     $photoThumbLimit = $photoPaginationLimit;
     $model = CFactory::getModel('photos');
     $photos = $model->getPhotos($album->id, $photoThumbLimit, JRequest::getVar('limitstart', '0', 'GET'));
     $pagination = $model->getPagination();
     $photo =& JTable::getInstance('Photo', 'CTable');
     $photo->load($album->photoid);
     if ($album->photoid == '0') {
         $album->thumbnail = $photo->getThumbURI();
     } else {
         $album->thumbnail = $photo->getImageURI();
     }
     // Increment album's hit each time this page is loaded.
     $album->hit();
     $otherAlbums = $model->_getOnlyAlbums($user->id, PHOTOS_USER_TYPE, 0, 20);
     $totalAlbums = count($otherAlbums);
     $showOtherAlbum = 6;
     $randomAlbum = array();
     if (count($otherAlbums) > 0) {
         $randomId = $totalAlbums < $showOtherAlbum ? array_rand($otherAlbums, $totalAlbums) : array_rand($otherAlbums, $showOtherAlbum);
         $count = 0;
         for ($i = 0; $i < $totalAlbums; $i++) {
             $num = is_array($randomId) ? $randomId[$i] : $randomId;
             if ($otherAlbums[$num]->id != $album->id) {
                 $count++;
                 $randomAlbum[] = $otherAlbums[$num];
             }
             if (count($randomAlbum) == $showOtherAlbum - 1) {
                 break;
             }
         }
     }
     $js = 'assets/gallery';
     $js .= $config->getBool('usepackedjavascript') ? '.pack.js' : '.js';
     CAssets::attach($js, 'js');
     CFactory::load('helpers', 'string');
     $document->setTitle(JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $handler->getCreatorName()) . ' - ' . $album->name);
     $this->setTitle($album->name);
     $handler->setAlbumPathway(CStringHelper::escape($album->name));
     $handler->setRSSHeader($albumId);
     // Set album thumbnail and description for social bookmarking sites linking
     $document->addHeadLink($album->getCoverThumbURI(), 'image_src', 'rel');
     $document->setDescription(CStringHelper::escape($album->getDescription()));
     CFactory::load('libraries', 'phototagging');
     $tagging = new CPhotoTagging();
     $people = array();
     $maxTime = $album->created;
     // Need to append the absolute path for the captions
     for ($i = 0; $i < count($photos); $i++) {
         $item =& JTable::getInstance('Photo', 'CTable');
         $item->bind($photos[$i]);
         $photos[$i] = $item;
         $photo =& $photos[$i];
         $photo->link = $handler->getPhotoURI($photo->id, $photo->albumid);
         $tags = $tagging->getTaggedList($photo->id);
         //Get last update
         $maxTime = $photo->created > $maxTime ? $photo->created : $maxTime;
         // Get the people in the tags
         foreach ($tags as $tag) {
             $people[] = $tag->userid;
         }
     }
     //Update lastUpdated
     $maxTime = new JDate($maxTime);
     $album->lastUpdated = CActivityStream::_createdLapse($maxTime, false);
     $people = array_unique($people);
     foreach ($people as &$person) {
         $person = CFactory::getUser($person);
     }
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks($handler->getAlbumExternalURI($album->id));
     // Get the walls
     CFactory::load('libraries', 'wall');
     $wallContent = CWallLibrary::getWallContents('albums', $album->id, COwnerHelper::isCommunityAdmin() || $my->id == $album->creator && $my->id != 0, 10, 0);
     $wallCount = CWallLibrary::getWallCount('albums', $album->id);
     $viewAllLink = false;
     if (JRequest::getVar('task', '', 'REQUEST') != 'app') {
         $viewAllLink = CRoute::_('index.php?option=com_community&view=photos&task=app&albumid=' . $album->id . '&app=walls');
     }
     $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     $wallForm = CWallLibrary::getWallInputForm($album->id, 'photos,ajaxAlbumSaveWall', 'photos,ajaxAlbumRemoveWall', $viewAllLink);
     $redirectUrl = CRoute::getURI(false);
     // Add tagging code
     //		$tagsHTML = '';
     //		if($config->get('tags_photos')){
     //			CFactory::load('libraries', 'tags');
     //			$tags = new CTags();
     //			$tagsHTML = $tags->getHTML('albums', $album->id, $handler->isAlbumOwner( $album->id ) );
     //		}
     $this->showSubmenu();
     $tmpl = new CTemplate();
     if ($album->location != "") {
         CFactory::load('libraries', 'mapping');
         $zoomableMap = CMapping::drawZoomableMap($album->location, 220, 150);
     } else {
         $zoomableMap = "";
     }
     // Get the likes / dislikes item
     CFactory::load('libraries', 'like');
     $like = new CLike();
     $likesHTML = $like->getHTML('album', $album->id, $my->id);
     $owner = CFactory::getUser($album->creator);
     echo $tmpl->set('likesHTML', $likesHTML)->set('photosmapdefault', $photoMapsDefault)->set('my', $my)->set('bookmarksHTML', $bookmarks->getHTML())->set('isOwner', $handler->isAlbumOwner($album->id))->set('isAdmin', COwnerHelper::isCommunityAdmin())->set('owner', $owner)->set('photos', $photos)->set('people', $people)->set('album', $album)->set('otherAlbums', $randomAlbum)->set('likesHTML', $likesHTML)->set('wallForm', $wallForm)->set('wallContent', $wallContent)->set('zoomableMap', $zoomableMap)->set('pagination', $pagination)->fetch('photos.album');
 }
Example #8
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);
 }
Example #9
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 );
		}
	}
Example #10
0
 /**
  * Delete post message
  *
  * @param	response	An ajax Response object
  * @param	id			A unique identifier for the wall row
  *
  * returns	response
  */
 function ajaxRemoveWall($response, $id, $cache_id = "")
 {
     $my = CFactory::getUser();
     $wallModel = CFactory::getModel('wall');
     $wall = $wallModel->get($id);
     CError::assert($id, '', '!empty', __FILE__, __LINE__);
     CFactory::load('helpers', 'owner');
     // Make sure the current user actually has the correct permission
     // Only the original writer and the person the wall is meant for (and admin of course)
     // can delete the wall
     if ($my->id == $wall->post_by || $my->id == $wall->contentid || COwnerHelper::isCommunityAdmin()) {
         if ($wallModel->deletePost($id)) {
             // @rule: Remove the wall activity from the database as well
             CFactory::load('libraries', 'activities');
             CActivityStream::remove('walls', $id);
             //add user points
             if ($wall->post_by != 0) {
                 CFactory::load('libraries', 'userpoints');
                 CUserPoints::assignPoint('wall.remove', $wall->post_by);
             }
         } else {
             $html = JText::_('Error while removing wall. Line:' . __LINE__);
             $response->addAlert($html);
         }
         $cache =& JFactory::getCache('plgCommunityWalls');
         $cache->remove($cache_id);
         $cache =& JFactory::getCache('plgCommunityWalls_fullview');
         $cache->remove($cache_id);
     } else {
         $html = JText::_('COM_COMMUNITY_PERMISSION_DENIED_WARNING');
         $response->addAlert($html);
     }
     return $response;
 }
Example #11
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;
 }
Example #12
0
 public function onAfterDeleteTopic($target)
 {
     CFactory::load('libraries', 'activities');
     CActivityStream::remove('kunena.thread.post', $target->id);
     // TODO: Need get replied id
     CActivityStream::remove('kunena.thread.replied', $target->id);
 }
Example #13
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());
     }
 }
Example #14
0
 /**
  * Add an application for the user
  *
  * @param    $name    string Application name / element
  */
 public function ajaxAdd($name)
 {
     // Check permissions
     $my = CFactory::getUser();
     $filter = JFilterInput::getInstance();
     $name = $filter->clean($name, 'string');
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     $objResponse = new JAXResponse();
     $appModel = CFactory::getModel('apps');
     // Get List of added apps
     $apps = $appModel->getAvailableApps();
     $addedApps = array();
     for ($i = 0; $i < count($apps); $i++) {
         $app = $apps[$i];
         if ($appModel->isAppUsed($my->id, $app->name)) {
             $addedApps[] = $app;
         }
     }
     $appModel->addApp($my->id, $name);
     $theApp = $appModel->getAppInfo($name);
     $appId = $appModel->getUserApplicationId($name, $my->id);
     $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 = 'app.install.' . $name;
     $act->cid = 0;
     $params = new JRegistry('');
     $params->set('app', $name);
     CActivityStream::addActor($act, $params->toString());
     //CFactory::load( 'libraries' , 'userpoints' );
     CUserPoints::assignPoint('application.add');
     // Change cWindow title
     $objResponse->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_ADD_APPLICATION_TITLE'));
     $formAction = CRoute::_('index.php?option=com_community&view=friends&task=deleteSent', false);
     $action = '<form name="cancelRequest" action="" method="POST">';
     $action .= '<input type="button" class="input button" name="save" onclick="joms.apps.showSettingsWindow(\'' . $appId . '\',\'' . $name . '\');" value="' . JText::_('COM_COMMUNITY_VIDEOS_SETTINGS_BUTTON') . '" />&nbsp;';
     $action .= '<input type="button" class="input button" onclick="cWindowHide();return false;" name="cancel" value="' . JText::_('COM_COMMUNITY_BUTTON_CLOSE_BUTTON') . '" />';
     $action .= '</form>';
     $html = '<div class="ajax-notice-apps-added">' . JText::_('COM_COMMUNITY_APPS_AJAX_ADDED') . '</div>';
     $objResponse->addScriptCall('cWindowAddContent', $html, $action);
     $objResponse->addScriptCall("joms.jQuery('." . $name . " .added-button').remove();");
     $objResponse->addScriptCall("joms.jQuery('." . $name . "').append('<span class=\"added-ribbon\">" . JText::_('COM_COMMUNITY_APPS_LIST_ADDED') . "</span>');");
     return $objResponse->sendResponse();
 }
Example #15
0
 public static function getGroupChildId($gid)
 {
     $db = JFactory::getDBO();
     //CFactory::load( 'libraries' , 'activities' );
     $sql = "SELECT\n\t\t\t\t\t\t" . $db->quoteName("id") . "\n\t\t\t\tFROM\n\t\t\t\t\t\t" . $db->quoteName("#__community_groups_discuss") . "\n\t\t\t\tWHERE\n\t\t\t\t\t\t" . $db->quoteName("groupid") . " = " . $db->Quote($gid);
     $db->setQuery($sql);
     $row = $db->loadobjectList();
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     $sql = "SELECT\n\t\t\t\t\t\t" . $db->quoteName("id") . "\n\t\t\t\tFROM\n\t\t\t\t\t\t" . $db->quoteName("#__community_groups_bulletins") . "\n\t\t\t\tWHERE\n\t\t\t\t\t\t" . $db->quoteName("groupid") . " = " . $db->Quote($gid);
     $db->setQuery($sql);
     $bulletin = $db->loadobjectList();
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     $sql = "SELECT\n\t\t\t\t\t\t" . $db->quoteName("id") . "\n\t\t\t\tFROM\n\t\t\t\t\t\t" . $db->quoteName("#__community_wall") . "\n\t\t\t\tWHERE\n\t\t\t\t\t\t" . $db->quoteName("contentid") . " = " . $db->Quote($gid);
     $db->setQuery($sql);
     $wall = $db->loadobjectList();
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     $row = array_merge($row, array_merge($bulletin, $wall));
     if (!empty($row)) {
         $ids_array = array();
         foreach ($row as $tempid) {
             array_push($ids_array, $tempid->id);
         }
         $ids = implode(',', $ids_array);
         $ids .= ',' . $gid;
         //Remove All groupActivity stream
         CActivityStream::removeGroup($ids);
     }
 }
            $attachment->type = 'general';
            break;
    }
    !isset($attachment->type) ? $attachments = array() : ($attachments[] = $attachment);
    $groupString = "";
    if (isset($activity->groupid) && !empty($activity->groupid)) {
        $groupTable = JTable::getInstance('Group', 'CTable');
        $groupTable->load($activity->groupid);
        $groupString = JText::sprintf('COM_COMMUNITY_SHARE_VIDEO_FROM_GROUP', $groupTable->getLink(), $groupTable->name);
    }
    $stream = new stdClass();
    $stream->actor = $user;
    $stream->target = null;
    $stream->headline = JText::sprintf('COM_COMMUNITY_ACTIVITY_SHARE_STATUS', CUrlHelper::userLink($user->id), $user->getDisplayName(), CUrlHelper::userLink($actor->id), $actor->getDisplayName(), isset($app[$activity->app]) ? $app[$activity->app] : '') . $groupString;
    $stream->message = CActivities::format($act->title);
    $stream->mood = $params->get('mood', NULL);
    $stream->sharedMessage = CActivities::format($activity->title);
    $stream->sharedMood = $activityParam->get('mood', NULL);
    $stream->groupid = $activity->groupid;
    $stream->eventid = "";
    $stream->access = $this->act->access;
    $stream->attachments = $attachments;
    /**
     * @todo Need to clearly this one
     * Right now it's return on right data
     */
    $stream->attachments[] = CActivityStream::formatStreamAttachment($activity);
    $stream->createdtime = $createdTime;
    $this->set('stream', $stream);
    $this->load('stream/base-extended');
}
Example #17
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();
 }
Example #18
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;
        }
    }
Example #19
0
 private function _getActivityStream()
 {
     CFactory::load('libraries', 'activities');
     $act = new CActivityStream();
     $html = $act->getHTML('', '', null, 0, '', '', true, COMMUNITY_SHOW_ACTIVITY_MORE);
     return $html;
 }
Example #20
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();
 }
Example #21
0
 function _getAlbumsHTML($albums, $type = PHOTOS_USER_TYPE)
 {
     $my = CFactory::getUser();
     $groupId = JRequest::getInt('groupid', '', 'REQUEST');
     $tmpl = new CTemplate();
     CFactory::load('libraries', 'activities');
     CFactory::load('models', 'groups');
     CFactory::load('helpers', 'owner');
     for ($i = 0; $i < count($albums); $i++) {
         $albums[$i]->user = CFactory::getUser($albums[$i]->creator);
         $albums[$i]->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$albums[$i]->id}&userid={$albums[$i]->creator}");
         $albums[$i]->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$albums[$i]->id}&userid={$albums[$i]->creator}");
         $albums[$i]->uploadLink = CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$albums[$i]->id}&userid={$albums[$i]->creator}");
         $albums[$i]->isOwner = $my->id == $albums[$i]->creator;
         if ($type == PHOTOS_GROUP_TYPE) {
             $group =& JTable::getInstance('Group', 'CTable');
             $group->load($groupId);
             $albums[$i]->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}");
             $albums[$i]->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}");
             $albums[$i]->uploadLink = CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}");
             $params = $group->getParams();
             $photopermission = $params->get('photopermission', GROUP_PHOTO_PERMISSION_ADMINS);
             if ($photopermission == GROUP_PHOTO_PERMISSION_MEMBERS && $group->isMember($my->id)) {
                 $albums[$i]->isOwner = $my->id == $albums[$i]->creator;
             } else {
                 if ($photopermission == GROUP_PHOTO_PERMISSION_ADMINS && $group->isAdmin($my->id) || COwnerHelper::isCommunityAdmin()) {
                     $albums[$i]->isOwner = true;
                 } else {
                     $albums[$i]->isOwner = false;
                 }
             }
         }
         // If new albums that has just been created and
         // does not contain any images, the lastupdated will always be 0000-00-00 00:00:00:00
         // Try to use the albums creation date instead.
         if ($albums[$i]->lastupdated == '0000-00-00 00:00:00' || $albums[$i]->lastupdated == '') {
             $albums[$i]->lastupdated = $albums[$i]->created;
             if ($albums[$i]->lastupdated == '' || $albums[$i]->lastupdated == '0000-00-00 00:00:00') {
                 $albums[$i]->lastupdated = JText::_('CC NO LAST ACTIVITY');
             } else {
                 $lastUpdated = new JDate($albums[$i]->lastupdated);
                 $albums[$i]->lastupdated = CActivityStream::_createdLapse($lastUpdated);
             }
         } else {
             $lastUpdated = new JDate($albums[$i]->lastupdated);
             $albums[$i]->lastupdated = CActivityStream::_createdLapse($lastUpdated);
         }
     }
     CFactory::load('helpers', 'owner');
     CFactory::load('libraries', 'featured');
     $featured = new CFeatured(FEATURED_ALBUMS);
     $featuredList = $featured->getItemIds();
     $task = JRequest::getVar('task', '', 'GET');
     $showFeatured = empty($task) ? true : false;
     $createLink = CRoute::_('index.php?option=com_community&view=photos&task=newalbum&userid=' . $my->id);
     if ($type == PHOTOS_GROUP_TYPE) {
         $createLink = CRoute::_('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $groupId);
         CFactory::load('helpers', 'group');
         $isOwner = CGroupHelper::allowManagePhoto($groupId);
     } else {
         $userId = JRequest::getInt('userid', '', 'REQUEST');
         $user = CFactory::getUser($userId);
         $isOwner = $my->id == $user->id ? true : false;
     }
     $task = JRequest::getCmd('task', '');
     $tmpl->set('isOwner', $isOwner);
     $tmpl->set('type', $type);
     $tmpl->set('createLink', $createLink);
     $tmpl->set('currentTask', $task);
     $tmpl->set('showFeatured', $showFeatured);
     $tmpl->set('featuredList', $featuredList);
     $tmpl->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin());
     $tmpl->set('my', $my);
     $tmpl->set('albums', $albums);
     $tmpl->set('isSuperAdmin', COwnerHelper::isCommunityAdmin());
     return $tmpl->fetch('albums.list');
 }
Example #22
0
 /**
  * Function to call Popup window for share status
  * @param  [int] $activityId [activity stream id]
  * @return
  */
 public function ajaxSharePopup($activityId)
 {
     $my = CFactory::getUser();
     if ($my->id == 0) {
         $this->ajaxBlockUnregister();
     }
     $act = JTable::getInstance('Activity', 'CTable');
     $act->load($activityId);
     $user = CFactory::getUser($act->creator);
     $act = CActivityStream::formatSharePopup($act);
     if (!empty($act->params)) {
         if (!is_object($act->params)) {
             $act->params = new JRegistry($act->params);
         }
         $mood = $act->params->get('mood', null);
     } else {
         $mood = null;
     }
     switch ($act->app) {
         case 'groups.discussion':
             $db = JFactory::getDbo();
             $query = ' SELECT `d`.`title`, `d`.`message`, `g`.`name`, `g`.`description`, `g`.`id` ';
             $query .= ' FROM ' . $db->quoteName('#__community_groups_discuss') . ' AS `d` ';
             $query .= ' INNER JOIN ' . $db->quoteName('#__community_groups') . ' AS `g` ON `g`.`id` = `d`.`groupid` ';
             $query .= ' WHERE `d`.`id` = ' . (int) $act->cid;
             $db->setQuery($query);
             $data = $db->loadObject();
             break;
     }
     $tmpl = new CTemplate();
     isset($data) ? $tmpl->set('data', $data) : null;
     $tmpl->set('act', $act)->set('user', $user)->set('mood', $mood);
     $html = $tmpl->fetch('ajax.showsharepopup');
     $json = array('title' => JText::_('COM_COMMUNITY_SHARE_STATUS_TITLE'), 'html' => $html, 'btnShare' => JText::_('COM_COMMUNITY_SHARE'), 'btnCancel' => JText::_('COM_COMMUNITY_CANCEL_BUTTON'));
     die(json_encode($json));
 }
Example #23
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;
 }
Example #24
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 );
	}
Example #25
0
 /**
  * Delete an album
  * Set all photo within the album to have albumid = 0
  * Do not yet delete the photos, this could be very slow on an album that
  * has huge amount of photos
  */
 public function delete($pk = null)
 {
     //lets get all the photo info under the album
     $photoModel = CFactory::getModel('photos');
     $photos = $photoModel->getAllPhotos($this->id, $this->type);
     $db = JFactory::getDBO();
     $strSQL = 'UPDATE ' . $db->quoteName('#__community_photos') . ' SET ' . $db->quoteName('albumid') . '=' . $db->Quote(0) . ', ' . $db->quoteName('status') . ' = ' . $db->quote('temp') . ' WHERE ' . $db->quoteName('albumid') . '=' . $db->Quote($this->id);
     $db->setQuery($strSQL);
     $result = $db->query();
     // The whole local folder should be deleted, regardless of the storage type
     // BUT some old version of JomSocial might store other photo in the same
     // folder, we check in db first
     $strSQL = 'SELECT count(*) FROM ' . $db->quoteName('#__community_photos') . ' WHERE ' . $db->quoteName('image') . ' LIKE ' . $db->Quote('%' . dirname($this->path) . '%');
     $db->setQuery($strSQL);
     $result = $db->loadResult();
     if ($result == 0) {
         if (JFolder::exists(JPATH_ROOT . '/' . rtrim($this->path, '/') . '/' . $this->id)) {
             JFolder::delete(JPATH_ROOT . '/' . rtrim($this->path, '/') . '/' . $this->id);
         }
     }
     // We need to delete all activity stream related to this album
     CActivityStream::remove('photos', $this->id);
     //we need to delete all activity related to the photos inside the album as well
     if (isset($photos) && count($photos) > 0) {
         foreach ($photos as $photo) {
             CActivityStream::remove('photos', $photo->id);
         }
     }
     /* Delete album directory */
     $config = CFactory::getConfig();
     $dirPath = JPATH_ROOT . '/' . $config->getString('imagefolder') . '/photos/' . $this->creator . '/' . $this->id;
     if (JFolder::exists($dirPath)) {
         JFolder::delete($dirPath);
     }
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $appsLib->triggerEvent('onAfterAlbumDelete', array($this));
     // @rule: remove from featured item if item is featured
     $featured = new CFeatured(FEATURED_ALBUMS);
     $featured->delete($this->id);
     // if this is an avatar, we have to remove the avatar from the respective user
     if ($this->type == 'profile.avatar') {
         $user = CFactory::getUser($this->creator);
         $userModel = CFactory::getModel('User');
         $userModel->removeProfilePicture($user->id, 'avatar');
         $userModel->removeProfilePicture($user->id, 'thumb');
         $activityModel = CFactory::getModel('activities');
         $activityModel->removeAvatarActivity('profile.avatar.upload', $user->id);
     } elseif ($this->type == 'event.avatar') {
         $eventTable = JTable::getInstance('Event', 'CTable');
         $eventTable->load($this->eventid);
         $eventTable->removeAvatar();
         $activityModel = CFactory::getModel('activities');
         $activityModel->removeAvatarActivity('events.avatar.upload', $this->eventid);
     } elseif ($this->type == 'group.avatar') {
         $eventTable = JTable::getInstance('Group', 'CTable');
         $eventTable->load($this->groupid);
         $eventTable->removeAvatar();
         $activityModel = CFactory::getModel('activities');
         $activityModel->removeAvatarActivity('groups.avatar.upload', $this->groupid);
     }
     //add user points
     CUserPoints::assignPoint('album.remove');
     // Remove from activity stream
     //CActivityStream::remove('photos', $this->id);
     // Remove from activity stream
     CActivityStream::remove('albums', $this->id);
     // Remove likes activity
     $likeModel = CFactory::getModel('like');
     $likeModel->removeLikes('album', $this->id);
     // Remove comment
     $wallModel = CFactory::getModel('wall');
     $wallModel->deletePostByType('albums', $this->id);
     return parent::delete();
 }
Example #26
0
 /**
  *
  */
 public static function joinApproved($groupId, $userid)
 {
     $group = JTable::getInstance('Group', 'CTable');
     $member = JTable::getInstance('GroupMembers', 'CTable');
     $group->load($groupId);
     $act = new stdClass();
     $act->cmd = 'group.join';
     $act->actor = $userid;
     $act->target = 0;
     $act->title = '';
     //JText::sprintf('COM_COMMUNITY_GROUPS_GROUP_JOIN' , '{group_url}' , $group->name );
     $act->content = '';
     $act->app = 'groups.join';
     $act->cid = $group->id;
     $act->groupid = $group->id;
     $params = new CParameter('');
     $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
     $params->set('action', 'group.join');
     // Add logging
     if (CUserPoints::assignPoint('group.join')) {
         CActivityStream::addActor($act, $params->toString());
     }
     // Store the group and update stats
     $group->updateStats();
     $group->store();
 }
Example #27
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());
 }
Example #28
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();
 }
Example #29
0
 /**
  * Display the photo thumbnails from an album
  * */
 public function album()
 {
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $config = CFactory::getConfig();
     $handler = $this->_getHandler();
     $my = CFactory::getUser();
     //CFactory::load( 'libraries' , 'activities' );
     // Get show photo location map by default
     $photoMapsDefault = $config->get('photosmapdefault');
     $albumId = $jinput->get('albumid', 0, 'INT');
     $album = JTable::getInstance('Album', 'CTable');
     $album->load($albumId);
     $defaultId = $jinput->get('photoid', 0, 'INT');
     $userId = $jinput->get('userid', 0, 'INT');
     $limitstart = $jinput->get->get('limitstart', '0', 'INT');
     if (empty($limitstart)) {
         $limitstart = $jinput->get->get('start', '0', 'INT');
     }
     $user = CFactory::getUser($album->creator);
     // Set pathway for group photos
     // Community > Groups > Group Name > Photos > Album Name
     $pathway = $mainframe->getPathway();
     if ($album->type == 'group') {
         if (!$my->authorise('community.view', 'photos.group.album.' . $album->groupid, $album)) {
             echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
             return;
         }
     } else {
         if (!$my->authorise('community.view', 'photos.user.album.' . $album->id)) {
             echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
             return;
         }
     }
     $groupId = $album->groupid;
     if ($groupId > 0) {
         $group = JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         $pathway->addItem(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
         $pathway->addItem($group->name, CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId));
         $pathway->addItem(JText::_('COM_COMMUNITY_PHOTOS'), CRoute::_('index.php?option=com_community&view=photos&groupid=' . $groupId));
     } else {
         $pathway->addItem(JText::_('COM_COMMUNITY_PHOTOS'), CRoute::_('index.php?option=com_community&view=photos'));
         $pathway->addItem(JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $user->getDisplayName()), CRoute::_('index.php?option=com_community&view=photos&task=myphotos&userid=' . $userId));
     }
     $handler->setMiniHeader();
     if (empty($albumId)) {
         echo JText::_('COM_COMMUNITY_PHOTOS_NO_ALBUMID_ERROR');
         return;
     }
     if (is_null($album->id)) {
         echo JText::_('COM_COMMUNITY_ALBUM_DELETED');
         return;
     }
     if (!$handler->isAlbumBrowsable($albumId)) {
         return;
     }
     //$photos		= $handler->getAlbumPhotos( $album->id );
     $photoPaginationLimit = intval($config->get('pagination'));
     $photoThumbLimit = $photoPaginationLimit;
     $model = CFactory::getModel('photos');
     $photos = $model->getPhotos($album->id, $photoThumbLimit, $limitstart);
     $pagination = $model->getPagination();
     $photo = JTable::getInstance('Photo', 'CTable');
     $photo->load($album->photoid);
     if ($album->photoid == '0') {
         $album->thumbnail = $photo->getThumbURI();
     } else {
         $album->thumbnail = $photo->getImageURI();
     }
     // Increment album's hit each time this page is loaded.
     $album->hit();
     if ($groupId > 0) {
         $otherAlbums = $model->getGroupAlbums($groupId);
     } else {
         $otherAlbums = $model->getAlbums($user->id);
     }
     $totalAlbums = count($otherAlbums);
     $showOtherAlbum = 6;
     $randomAlbum = array();
     if (count($otherAlbums) > 0) {
         $randomId = $totalAlbums < $showOtherAlbum ? array_rand($otherAlbums, $totalAlbums) : array_rand($otherAlbums, $showOtherAlbum);
         $count = 0;
         for ($i = 0; $i < $totalAlbums; $i++) {
             $num = is_array($randomId) ? $randomId[$i] : $randomId;
             if ($otherAlbums[$num]->id != $album->id) {
                 $count++;
                 $randomAlbum[] = $otherAlbums[$num];
             }
             if (count($randomAlbum) == $showOtherAlbum - 1) {
                 break;
             }
         }
     }
     /* set head meta */
     if (strtolower(trim(JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $handler->getCreatorName()))) == strtolower(trim($album->name))) {
         /**
          * Opengraph
          */
         CHeadHelper::setType('website', JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $handler->getCreatorName()), CStringHelper::escape($album->getDescription()));
     } else {
         /**
          * Opengraph
          */
         CHeadHelper::setType('website', JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $handler->getCreatorName()) . ' - ' . $album->name, CStringHelper::escape($album->getDescription()));
     }
     $this->setTitle($album->name);
     $handler->setAlbumPathway(CStringHelper::escape($album->name));
     $handler->setRSSHeader($albumId);
     // Set album thumbnail and description for social bookmarking sites linking
     $document->addHeadLink($album->getCoverThumbURI(), 'image_src', 'rel');
     //$document->setDescription( CStringHelper::escape($album->getDescription()) );
     //CFactory::load( 'libraries' , 'phototagging' );
     $getTaggingUsers = new CPhotoTagging();
     $people = array();
     // @TODO temporary fix for undefined link
     $list = array();
     foreach ($photos as $photo) {
         $photo->link = $handler->getPhotoURI($photo->id, $photo->albumid);
         CHeadHelper::addOpengraph('og:image', JUri::root(true) . '/' . $photo->image, true);
         $list[] = $photo;
     }
     $photos = $list;
     $albumParam = new Cparameter($album->params);
     $tagged = $albumParam->get('tagged');
     if (!empty($tagged)) {
         $people = explode(',', $albumParam->get('tagged'));
     }
     //Update lastUpdated
     $lastUpdated = new JDate($album->lastupdated);
     $album->lastUpdated = CActivityStream::_createdLapse($lastUpdated, false);
     $people = array_unique($people);
     CFactory::loadUsers($people);
     foreach ($people as &$person) {
         $person = CFactory::getUser($person);
     }
     //CFactory::load( 'libraries' , 'bookmarks' );
     $bookmarks = new CBookmarks($handler->getAlbumExternalURI($album->id));
     // Get wall data.
     $wallCount = CWallLibrary::getWallCount('albums', $album->id);
     $viewAllLink = false;
     if ($jinput->request->get('task', '') != 'app') {
         $viewAllLink = CRoute::_('index.php?option=com_community&view=photos&task=app&albumid=' . $album->id . '&app=walls');
     }
     $wallContent = CWallLibrary::getWallContents('albums', $album->id, COwnerHelper::isCommunityAdmin() || $my->id == $album->creator && $my->id != 0, $config->get('stream_default_comments'), 0, 'wall/content', 'photos,album');
     $wallForm = CWallLibrary::getWallInputForm($album->id, 'photos,ajaxAlbumSaveWall', 'photos,ajaxAlbumRemoveWall', $viewAllLink);
     $viewAllLink = CRoute::_('index.php?option=com_community&view=photos&task=app&albumid=' . $album->id . '&app=walls');
     $wallViewAll = '';
     if ($wallCount > $config->get('stream_default_comments')) {
         $wallViewAll = CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     }
     $redirectUrl = CRoute::getURI(false);
     $tmpl = new CTemplate();
     if ($album->location != "") {
         $zoomableMap = CMapping::drawZoomableMap($album->location, 220, 150);
     } else {
         $zoomableMap = "";
     }
     // Get the likes / dislikes item
     //CFactory::load( 'libraries' , 'like' );
     $like = new CLike();
     $likeCount = $like->getLikeCount('album', $album->id);
     $likeLiked = $like->userLiked('album', $album->id, $my->id) === COMMUNITY_LIKE;
     $owner = CFactory::getUser($album->creator);
     echo $tmpl->set('photosmapdefault', $photoMapsDefault)->set('my', $my)->set('bookmarksHTML', $bookmarks->getHTML())->set('isOwner', $handler->isAlbumOwner($album->id))->set('isAdmin', COwnerHelper::isCommunityAdmin())->set('owner', $owner)->set('photos', $photos)->set('people', $people)->set('album', $album)->set('groupId', $groupId)->set('otherAlbums', $randomAlbum)->set('likeCount', $likeCount)->set('likeLiked', $likeLiked)->set('wallContent', $wallContent)->set('wallForm', $wallForm)->set('wallCount', $wallCount)->set('wallViewAll', $wallViewAll)->set('zoomableMap', $zoomableMap)->set('pagination', $pagination)->set('photoId', $defaultId)->set('submenu', $this->showSubmenu(false))->fetch('photos/list');
 }
Example #30
0
 public function getLastUpdated($raw = false)
 {
     $query = ' SELECT MAX(created) AS lastupdated' . ' FROM ' . $this->_db->nameQuote('#__community_videos') . ' WHERE ' . $this->_db->nameQuote('id') . ' = ' . $this->_db->quote($this->getId());
     $this->_db->setQuery($query);
     $this->_lastupdated = $this->_db->loadResult();
     if ($raw) {
         return $this->_lastupdated;
     }
     CFactory::load('libraries', 'activities');
     if ($this->_lastupdated == '0000-00-00 00:00:00' || $this->_lastupdated == '') {
         $this->_lastupdated = $this->created;
         if ($this->_lastupdated == '' || $this->_lastupdated == '0000-00-00 00:00:00') {
             $this->_lastupdated = JText::_('CC NO LAST ACTIVITY');
         } else {
             $lastUpdated = new JDate($this->_lastupdated);
             $this->_lastupdated = CActivityStream::_createdLapse($lastUpdated);
         }
     } else {
         $lastUpdated = new JDate($this->_lastupdated);
         $this->_lastupdated = CActivityStream::_createdLapse($lastUpdated);
     }
     return $this->_lastupdated;
 }