/** * 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)); }
public static function formatStreamAttachment($obj) { switch ($obj->app) { case 'videos.linking': $video = JTable::getInstance('Video', 'CTable'); $video->load($obj->cid); $attachment = new stdClass(); $attachment->type = 'videos.linking'; $attachment->type = 'video'; $attachment->id = $obj->cid; $attachment->title = $video->title; $attachment->thumbnail = $video->getThumbnail(); $attachment->description = $video->description; $attachment->duration = CVideosHelper::toNiceHMS(CVideosHelper::formatDuration($video->getDuration())); $attachment->access = $obj->access; $attachment->video_type = $video->type; $attachment->link = $video->path; $attachment->video = $video; break; case 'profile.status.share': $params = new CParameter($obj->params); $act = JTable::getInstance('Activity', 'CTable'); $act->load($params->get('activityId')); $attachment = self::formatStreamAttachment($act); break; case 'groups.wall': case 'events.wall': case 'profile': $params = new CParameter($obj->params); $headMetas = $params->get('headMetas', NULL); $headers = new CParameter($headMetas); if (!is_null($headers->get('title'))) { $attachment = new stdClass(); $attachment->type = 'fetched'; $data = new stdClass(); $headers = new CParameter($headMetas); $data->title = $headers->get('title'); $data->description = $headers->get('description'); $data->thumb = $headers->get('image'); $data->app = $obj->app; $data->params = $obj->params; $attachment->message = CActivityStream::formatSharePopup($data)->content; } else { $attachment = new stdClass(); $attachment->type = 'quote'; $attachment->id = $obj->id; $attachment->location = $obj->location; $attachment->message = CActivities::format($obj->title, $params->get('mood')); } break; case 'videos': $video = JTable::getInstance('Video', 'CTable'); $video->load($obj->cid); $attachment = new stdClass(); $attachment->type = 'video'; $attachment->id = $obj->cid; $attachment->title = $video->title; $attachment->thumbnail = $video->getThumbnail(); $attachment->description = $video->description; $attachment->duration = CVideosHelper::toNiceHMS(CVideosHelper::formatDuration($video->getDuration())); $attachment->link = $video->getURL(); $attachment->video_type = $video->type; $attachment->link = $video->path; $attachment->video = $video; break; case 'photos': $params = new CParameter($obj->params); $count = $params->get('count', 1); $photoId = $params->get('photoid', 0); $photoIds = explode(',', $params->get('photosId', 0)); $attachment = new stdClass(); if ($count == 1 && $photoId > 0) { $attachment->type = 'photo'; $photo = JTable::getInstance('Photo', 'CTable'); if ($photo->load($photoId) && $photo->status != 'delete') { $attachment->singlephoto = $photo->getImageURI(); $attachment->caption = $photo->caption; $attachment->thumbnail = $photo->getThumbURI(); $attachment->link = $params->get('photo_url'); $attachment->albumid = $photo->albumid; $attachment->id = $photo->id; } } elseif ($count > 1 && $photoId > 0) { $attachment->type = 'photos'; $album = JTable::getInstance('Album', 'CTable'); $album->load($obj->cid); if (count($photoIds) > 1) { foreach ($photoIds as $pid) { $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($pid); /* Make sure photo is not deleted */ if ($photo->status != 'delete') { $photos[] = $photo; } foreach ($photos as $key => $data) { if ($data->id == $photoId) { unset($photos[$key]); /* remove this photo */ array_unshift($photos, $data); /* move it to beginning of array */ } } } } else { $photos = $album->getLatestPhoto($count); } $tmpIdArray = array(); $tmpAlbumArray = array(); $tmpUrlArray = array(); $tmpThumbArray = array(); $tmpCaptionArray = array(); if ($count >= 5) { $photos = array_slice($photos, 0, 5); } foreach ($photos as $photo) { $tmpIdArray[] = $photo->id; $tmpAlbumArray[] = $photo->albumid; $tmpThumbArray[] = $photo->getImageURI(); $tmpUrlArray[] = $photo->getPhotoLink(); $tmpCaptionArray[] = $photo->caption; } $attachment->id = $tmpIdArray; $attachment->album = $tmpAlbumArray; $attachment->link = $tmpUrlArray; $attachment->thumbnail = $tmpThumbArray; $attachment->caption = $tmpCaptionArray; } break; case 'groups': $attachment = new stdClass(); $attachment->type = 'group_share'; $group = JTable::getInstance('Group', 'CTable'); $group->load($obj->cid); $attachment->message = new stdClass(); $attachment->message->title = $group->name; $attachment->message->description = $group->description; $attachment->message->link = $group->getLink(); break; case 'events': $attachment = new stdClass(); $attachment->type = 'event_share'; $event = JTable::getInstance('Event', 'CTable'); $event->load($obj->cid); $attachment->message = $event; break; case 'cover.upload': $params = new CParameter($obj->params); $attachment = new stdClass(); $attachment->type = 'cover'; $attachment->thumbnail = $params->get('attachment'); break; case 'profile.avatar.upload': $params = new CParameter($obj->params); $attachment = new stdClass(); $attachment->type = 'profile_avatar'; $attachment->thumbnail = $params->get('attachment'); break; default: $attachment = new stdClass(); $attachment->type = ''; break; } return $attachment; }