/** * Ajax function to save a new wall entry * * @param message A message that is submitted by the user * @param uniqueId The unique id for this group * **/ function ajaxSaveWall($response, $message, $uniqueId, $cache_id = "") { $my = CFactory::getUser(); $user = CFactory::getUser($uniqueId); $config = CFactory::getConfig(); JPlugin::loadLanguage('plg_walls', JPATH_ADMINISTRATOR); // Load libraries CFactory::load('models', 'photos'); CFactory::load('libraries', 'wall'); CFactory::load('helpers', 'url'); CFactory::load('libraries', 'activities'); $message = JString::trim($message); $message = strip_tags($message); if (empty($message)) { $response->addAlert(JText::_('PLG_WALLS_PLEASE_ADD_MESSAGE')); } else { $maxchar = $this->params->get('charlimit', 0); if (!empty($maxchar)) { $msglength = strlen($message); if ($msglength > $maxchar) { $message = substr($message, 0, $maxchar); } } // @rule: Spam checks if ($config->get('antispam_akismet_walls')) { CFactory::load('libraries', 'spamfilter'); $filter = CSpamFilter::getFilter(); $filter->setAuthor($my->getDisplayName()); $filter->setMessage($message); $filter->setEmail($my->email); $filter->setURL(CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id)); $filter->setType('message'); $filter->setIP($_SERVER['REMOTE_ADDR']); if ($filter->isSpam()) { $response->addAlert(JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM')); return $response->sendResponse(); } } $wall = CWallLibrary::saveWall($uniqueId, $message, 'user', $my, $my->id == $user->id, 'profile,profile'); CFactory::load('libraries', 'activities'); CFactory::load('helpers', 'videos'); $matches = cGetVideoLinkMatches($message); $activityParams = ''; // We only want the first result of the video to be in the activity if ($matches) { $videoLink = $matches[0]; CFactory::load('libraries', 'videos'); $videoLib = new CVideoLibrary(); $provider = $videoLib->getProvider($videoLink); $activityParams .= 'videolink=' . $videoLink . "\r\n"; if ($provider->isValid()) { $activityParams .= 'url=' . $provider->getThumbnail(); } } $act = new stdClass(); $act->cmd = 'profile.wall.create'; $act->actor = $my->id; $act->target = $uniqueId; $act->title = JText::_('COM_COMMUNITY_ACTIVITIES_WALL_POST_PROFILE'); $act->content = ''; $act->app = 'walls'; $act->cid = $wall->id; // Allow comments on all these $act->comment_id = CActivities::COMMENT_SELF; $act->comment_type = 'walls'; CActivityStream::add($act, $activityParams); // @rule: Send notification to the profile user. if ($my->id != $user->id) { CFactory::load('libraries', 'notification'); $params = new CParameter(''); $params->set('url', 'index.php?option=com_community&view=profile&userid=' . $user->id); $params->set('message', $message); CNotificationLibrary::add('etype_profile_submit_wall', $my->id, $user->id, JText::sprintf('PLG_WALLS_NOTIFY_EMAIL_SUBJECT', $my->getDisplayName()), '', 'profile.wall', $params); } //add user points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('profile.wall.create'); $response->addScriptCall('joms.walls.insert', $wall->content); $response->addScriptCall('if(joms.jQuery(".content-nopost").length){ joms.jQuery("#wall-empty-container").remove(); }'); $cache =& JFactory::getCache('plgCommunityWalls'); $cache->remove($cache_id); $cache =& JFactory::getCache('plgCommunityWalls_fullview'); $cache->remove($cache_id); } return $response; }
/** * Initialize the video with a new url */ public function init($url) { // create the provider // $this->_provider should be null here $videoLib = new CVideoLibrary(); $this->_provider = $videoLib->getProvider($url); $isValid = $this->_provider->isValid(); if ($isValid) { $this->title = $this->_provider->getTitle(); $this->type = $this->_provider->getType(); $this->video_id = $this->_provider->getId(); $this->duration = $this->_provider->getDuration(); $this->status = 'ready'; $this->thumb = $this->_provider->getThumbnail(); $this->path = $url; $this->description = str_replace(array("\r", "\n"), " ", $this->_provider->getDescription()); // remove line break from description $this->status = 'ready'; } return $isValid; }
/** * Initialize the video with a new url */ public function init($url) { // create the provider // $this->_provider should be null here CFactory::load('libraries', 'videos'); $videoLib = new CVideoLibrary(); $this->_provider = $videoLib->getProvider($url); $isValid = $this->_provider->isValid(); if ($isValid) { $this->title = $this->_provider->getTitle(); $this->type = $this->_provider->getType(); $this->video_id = $this->_provider->getId(); $this->duration = $this->_provider->getDuration(); $this->status = 'ready'; $this->thumb = $this->_provider->getThumbnail(); $this->path = $url; $this->description = $this->_provider->getDescription(); $this->status = 'ready'; } return $isValid; }
/** * Displays specific groups **/ public function viewGroup($group) { $mainframe =& JFactory::getApplication(); CFactory::load('libraries', 'tooltip'); CFactory::load('libraries', 'wall'); CFactory::load('libraries', 'window'); CFactory::load('libraries', 'videos'); CFactory::load('libraries', 'activities'); CFactory::load('helpers', 'group'); CWindow::load(); $config = CFactory::getConfig(); $document = JFactory::getDocument(); $groupLib = new CGroups(); // Load appropriate models $groupModel = CFactory::getModel('groups'); $wallModel = CFactory::getModel('wall'); $userModel = CFactory::getModel('user'); $discussModel = CFactory::getModel('discussions'); $bulletinModel = CFactory::getModel('bulletins'); $photosModel = CFactory::getModel('photos'); $activityModel = CFactory::getModel('activities'); //$groupid = JRequest::getInt( 'groupid' , '' ); //CError::assert( $groupid , '' , '!empty' , __FILE__ , __LINE__ ); $editGroup = JRequest::getVar('edit', false, 'GET'); $editGroup = $editGroup == 1 ? true : false; $params = $group->getParams(); CFactory::load('helpers', 'string'); $document->setMetaData('title', CStringHelper::escape($group->name)); $document->setMetaData('description', CStringHelper::escape(strip_tags($group->description))); $document->addCustomTag('<link rel="image_src" href="' . JURI::root() . $group->thumb . '" />'); // @rule: Test if the group is unpublished, don't display it at all. if (!$group->published) { $this->_redirectUnpublishGroup(); return; } // Show submenu $this->showSubmenu(); // Set the group info to contain proper <br> $group->description = nl2br($group->description); $this->addPathway(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups')); $this->addPathway(JText::sprintf('COM_COMMUNITY_GROUPS_NAME_TITLE', $group->name), ''); // Load the current browsers data $my = CFactory::getUser(); // If user are invited $isInvited = $groupModel->isInvited($my->id, $group->id); // Get members list for display //$members = $groupModel->getAllMember($group->id); //Set limit for member listing on view group page $limit = 12; $approvedMembers = $groupModel->getMembers($group->id, $limit, true, false, true); CError::assert($approvedMembers, 'array', 'istype', __FILE__, __LINE__); $membersCount = $groupModel->total; // Is there any my friend is the member of this group? $join = ''; $friendsCount = 0; if ($isInvited) { // Get the invitors $invitors = $groupModel->getInvitors($my->id, $group->id); if (count($invitors) == 1) { $user = CFactory::getUser($invitors[0]->creator); $join = '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } else { for ($i = 0; $i < count($invitors); $i++) { $user = CFactory::getUser($invitors[$i]->creator); if ($i + 1 == count($invitors)) { $join .= ' ' . JText::_('COM_COMMUNITY_AND') . ' ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } else { $join .= ', ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } } } // Get users friends in this group $friendsCount = $groupModel->getFriendsCount($my->id, $group->id); } $admins = $groupModel->getAdmins($group->id, $limit, CC_RANDOMIZE); // Get list of unapproved members $groupModel->getMembers($group->id, null, false); $unapproved = $groupModel->total; //Get list of approved members // Test if the current user is admin $isAdmin = $groupModel->isAdmin($my->id, $group->id); // Test if the current browser is a member of the group $isMember = $groupModel->isMember($my->id, $group->id); $waitingApproval = false; // Test if the current user is banned from this group $isBanned = $group->isBanned($my->id); // Attach avatar of the member // Pre-load multiple users at once $userids = array(); $limitloop = $limit; foreach ($approvedMembers as $uid) { $userids[] = $uid->id; if (--$limitloop < 1) { break; } } CFactory::loadUsers($userids); $limitloop = $limit; for ($i = 0; $i < count($approvedMembers); $i++) { $row =& $approvedMembers[$i]; $approvedMembers[$i] = CFactory::getUser($row->id); if (--$limitloop < 1) { break; } } if ($isBanned) { $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_GROUPS_MEMBER_BANNED'), 'error'); } // If I have tried to join this group, but not yet approved, display a notice if ($groupModel->isWaitingAuthorization($my->id, $group->id)) { $waitingApproval = true; } // Get the walls if (!$isBanned) { $wallContent = CWallLibrary::getWallContents('groups', $group->id, $isAdmin, 10, 0, 'wall.content', 'groups,group'); } else { $wallContent = CWallLibrary::getWallContents('groups', $group->id, $isAdmin, 10, 0, 'wall.content', 'groups,group', null, '1'); } $wallCount = CWallLibrary::getWallCount('groups', $group->id); $viewAllLink = false; if (JRequest::getVar('task', '', 'REQUEST') != 'app') { $viewAllLink = CRoute::_('index.php?option=com_community&view=groups&task=app&groupid=' . $group->id . '&app=walls'); } $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount); $wallForm = ''; CFactory::load('helpers', 'owner'); if (!$config->get('lockgroupwalls') || $config->get('lockgroupwalls') && ($isMember && !$isBanned) && !$waitingApproval || COwnerHelper::isCommunityAdmin()) { $wallForm = CWallLibrary::getWallInputForm($group->id, 'groups,ajaxSaveWall', 'groups,ajaxRemoveWall'); } // Get like CFactory::load('libraries', 'like'); $likes = new CLike(); $likesHTML = $isMember && !$isBanned ? $likes->getHTML('groups', $group->id, $my->id) : $likes->getHtmlPublic('groups', $group->id); // Get discussions data $discussionData = $this->_cachedCall('_getDiscussionListHTML', array($params, $group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL)); $discussionsHTML = $discussionData['HTML']; $totalDiscussion = $discussionData['total']; $discussions = $discussionData['data']; // Get bulletins data $bulletinData = $this->_cachedCall('_getBulletinListHTML', array($group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL)); $totalBulletin = $bulletinData['total']; $bulletinsHTML = $bulletinData['HTML']; $bulletins = $bulletinData['data']; // Get album data $albumData = $this->_cachedCall('_getAlbums', array($params, $group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL)); $albums = $albumData['data']; $totalAlbums = $albumData['total']; // Get video data $videoData = $this->_getVideos($params, $group->id); $videos = $videoData['data']; $totalVideos = $videoData['total']; $tmpl = new CTemplate(); // Get categories list // We should really load this in saperate file // @todo: editing group should really open a new page if ($my->id == $group->ownerid || COwnerHelper::isCommunityAdmin()) { $categories = $groupModel->getCategories(); CError::assert($categories, 'array', 'istype', __FILE__, __LINE__); $tmpl->set('categories', $categories); } $isMine = $my->id == $group->ownerid; // Get reporting html CFactory::load('libraries', 'reporting'); $report = new CReportingLibrary(); $reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_REPORT_GROUP'), 'groups,reportGroup', array($group->id)); $isSuperAdmin = COwnerHelper::isCommunityAdmin(); if ($group->approvals == '1' && !$isMine && !$isMember && !$isSuperAdmin) { $this->addWarning(JText::_('COM_COMMUNITY_GROUPS_PRIVATE_NOTICE')); } $videoThumbWidth = CVideoLibrary::thumbSize('width'); $videoThumbHeight = CVideoLibrary::thumbSize('height'); $eventsModel = CFactory::getModel('Events'); $tmpEvents =& $eventsModel->getGroupEvents($group->id, $params->get('grouprecentevents', GROUP_EVENT_RECENT_LIMIT)); $totalEvents = $eventsModel->getTotalGroupEvents($group->id); $events = array(); foreach ($tmpEvents as $event) { $table =& JTable::getInstance('Event', 'CTable'); $table->bind($event); $events[] = $table; } $allowManagePhotos = CGroupHelper::allowManagePhoto($group->id); $allowManageVideos = CGroupHelper::allowManageVideo($group->id); $allowCreateEvent = CGroupHelper::allowCreateEvent($my->id, $group->id); CFactory::load('libraries', 'bookmarks'); $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id)); $bookmarksHTML = $bookmarks->getHTML(); $isCommunityAdmin = COwnerHelper::isCommunityAdmin(); if ($group->approvals == '0' || $isMine || $isMember && !$isBanned || $isCommunityAdmin) { // Set feed url $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewbulletins&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_BULLETIN_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussions&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_DISCUSSION_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=photos&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_PHOTOS_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=videos&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_VIDEOS_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=events&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_EVENTS_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); } $friendsModel = CFactory::getModel('Friends'); $groupsModel = CFactory::getModel('Groups'); CFactory::load('libraries', 'invitation'); $inviteHTML = CInvitation::getHTML(null, 'groups,inviteUsers', $group->id); // Add tagging code /* $tagsHTML = ''; if($config->get('tags_groups')){ CFactory::load('libraries', 'tags'); $tags = new CTags(); $tagsHTML = $tags->getHTML('groups', $group->id, $isAdmin ); } */ // Upgrade wall to stream @since 2.5 if (!$params->get('stream', FALSE)) { $group->upgradeWallToStream(); } // Add custom stream $activities = new CActivities(); $streamHTML = $groupLib->getStreamHTML($group); $totalStream = $activityModel->getTotalActivities(array("`groupid` = '{$group->id}'")); CFactory::load('libraries', 'userstatus'); $creators = array(); $creators[] = CUserStatusCreator::getMessageInstance(); if ($isAdmin && $params->get('photopermission') == 1 || $isMember && $params->get('photopermission') == 2) { $creators[] = CUserStatusCreator::getPhotoInstance(); } if ($isAdmin && $params->get('videopermission') == 1 || $isMember && $params->get('videopermission') == 2) { $creators[] = CUserStatusCreator::getVideoInstance(); } if ($allowCreateEvent && $config->get('group_events') && $config->get('enableevents') && ($config->get('createevents') || COwnerHelper::isCommunityAdmin())) { $creators[] = CUserStatusCreator::getEventInstance(); } $status = new CUserStatus($group->id, 'groups', $creators); // Get Event Admins $groupAdmins = $group->getAdmins(12, CC_RANDOMIZE); $adminsInArray = array(); // Attach avatar of the admin for ($i = 0; $i < count($groupAdmins); $i++) { $row =& $groupAdmins[$i]; $admin = CFactory::getUser($row->id); array_push($adminsInArray, '<a href="' . CUrlHelper::userLink($admin->id) . '">' . $admin->getDisplayName() . '</a>'); } $adminsList = ltrim(implode(', ', $adminsInArray), ','); echo $tmpl->setMetaTags('group', $group)->set('streamHTML', $streamHTML)->set('status', $status)->set('likesHTML', $likesHTML)->set('events', $events)->set('totalEvents', $totalEvents)->set('inviteHTML', $inviteHTML)->set('showEvents', $config->get('group_events') && $config->get('enableevents'))->set('showPhotos', $params->get('photopermission') != -1)->set('showVideos', $params->get('videopermission') != -1)->set('bookmarksHTML', $bookmarksHTML)->set('allowManagePhotos', $allowManagePhotos)->set('allowManageVideos', $allowManageVideos)->set('allowCreateEvent', $allowCreateEvent)->set('videos', $videos)->set('videoThumbWidth', $videoThumbWidth)->set('videoThumbHeight', $videoThumbHeight)->set('totalVideos', $totalVideos)->set('albums', $albums)->set('totalAlbums', $totalAlbums)->set('reportHTML', $reportHTML)->set('editGroup', $editGroup)->set('waitingApproval', $waitingApproval)->set('config', $config)->set('my', $my)->set('isMine', $isMine)->set('isAdmin', $isAdmin)->set('isSuperAdmin', $isSuperAdmin)->set('isMember', $isMember)->set('isInvited', $isInvited)->set('friendsCount', $friendsCount)->set('join', $join)->set('unapproved', $unapproved)->set('membersCount', $membersCount)->set('group', $group)->set('totalBulletin', $totalBulletin)->set('totalDiscussion', $totalDiscussion)->set('totalVideos', $totalVideos)->set('members', $approvedMembers)->set('bulletins', $bulletins)->set('wallForm', $wallForm)->set('wallContent', $wallContent)->set('discussions', $discussions)->set('discussionsHTML', $discussionsHTML)->set('bulletinsHTML', $bulletinsHTML)->set('isCommunityAdmin', $isCommunityAdmin)->set('isBanned', $isBanned)->set('isPrivate', $group->approvals)->set('limit', $limit)->set('adminsList', $adminsList)->set('alertNewDiscussion', $my->count('group_discussion_' . $group->id) != $totalDiscussion)->set('alertNewBulletin', $my->count('group_bulletin_' . $group->id) != $totalBulletin)->set('alertNewStream', $my->count('group_activity_' . $group->id) != $totalStream)->fetch('groups.viewgroup'); // Update stream count cache, can only set this after we've set the alert aove $my->setCount('group_activity_' . $group->id, $totalStream); }
public function prepareVideosData($videos, $limit, &$objResponse) { //CFactory::load( 'helpers', 'videos' ); //CFactory::load( 'helpers', 'string' ); //CFactory::load( 'libraries', 'videos' ); $data = array(); for ($i = 0; $i < $limit; $i++) { $video = JTable::getInstance('Video', 'CTable'); $video->load($videos[$i]->id); // $video->title = htmlspecialchars( $video->title , ENT_QUOTES , 'UTF-8' ); // $video->description = htmlspecialchars( $video->description , ENT_QUOTES , 'UTF-8' ); $data[] = $video; } $tmpl = new CTemplate(); $tmpl->set('data', $data); $tmpl->set('thumbWidth', CVideoLibrary::thumbSize('width')); $tmpl->set('thumbHeight', CVideoLibrary::thumbSize('height')); return $tmpl->fetch('frontpage.latestvideos'); }
/** * Generate Featured Videos HTML * * @param array Array of video objects * @return string HTML * @since 1.2 */ public function _getFeatHTML($videos) { CFactory::load('helpers', 'owner'); CFactory::load('libraries', 'videos'); $tmpl = new CTemplate(); $tmpl->set('videos', $videos); $tmpl->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin()); $tmpl->set('videoThumbWidth', CVideoLibrary::thumbSize('width')); $tmpl->set('videoThumbHeight', CVideoLibrary::thumbSize('height')); return $tmpl->fetch('videos.featured'); }
/** * This function will regenerate the thumbnail of videos * @param int $id * @param bool $returnThumb * @return bool */ public function _fetchThumbnail($id = 0, $returnThumb = false) { if (!COwnerHelper::isRegisteredUser()) { return; } if (!$id) { return false; } $table = JTable::getInstance('Video', 'CTable'); $table->load($id); $config = CFactory::getConfig(); if ($table->type == 'file') { // We can only recreate the thumbnail for local video file only // it's not possible to process remote video file with ffmpeg if ($table->storage != 'file') { $this->setError(JText::_('COM_COMMUNITY_INVALID_FILE_REQUEST') . ': ' . 'FFmpeg cannot process remote video.'); return false; } $videoLib = new CVideoLibrary(); $videoFullPath = JPATH::clean(JPATH_ROOT . '/' . $table->path); if (!JFile::exists($videoFullPath)) { return false; } // Read duration $videoInfo = $videoLib->getVideoInfo($videoFullPath); if (!$videoInfo) { return false; } else { $videoFrame = CVideosHelper::formatDuration((int) ($videoInfo['duration']['sec'] / 2), 'HH:MM:SS'); // Create thumbnail $oldThumb = $table->thumb; $thumbFolder = CVideoLibrary::getPath($table->creator, 'thumb'); $thumbSize = CVideoLibrary::thumbSize(); $thumbFilename = $videoLib->createVideoThumb($videoFullPath, $thumbFolder, $videoFrame, $thumbSize); } if (!$thumbFilename) { return false; } } else { if (!CRemoteHelper::curlExists()) { $this->setError(JText::_('COM_COMMUNITY_CURL_NOT_EXISTS')); return false; } $videoLib = new CVideoLibrary(); $videoObj = $videoLib->getProvider($table->path); if ($videoObj == false) { $this->setError($videoLib->getError()); return false; } if (!$videoObj->isValid()) { $this->setError($videoObj->getError()); return false; } $remoteThumb = $videoObj->getThumbnail(); $thumbData = CRemoteHelper::getContent($remoteThumb, true); if (empty($thumbData)) { $this->setError(JText::_('COM_COMMUNITY_INVALID_FILE_REQUEST') . ': ' . $remoteThumb); return false; } // split the header and body list($headers, $body) = explode("\r\n\r\n", $thumbData, 2); preg_match('/Content-Type: image\\/(.*)/i', $headers, $matches); if (!empty($matches)) { $thumbPath = CVideoLibrary::getPath($table->creator, 'thumb'); $thumbFileName = CFileHelper::getRandomFilename($thumbPath); $tmpThumbPath = $thumbPath . '/' . $thumbFileName; if (!JFile::write($tmpThumbPath, $body)) { $this->setError(JText::_('COM_COMMUNITY_INVALID_FILE_REQUEST') . ': ' . $thumbFileName); return false; } // We'll remove the old or none working thumbnail after this $oldThumb = $table->thumb; // Get the image type first so we can determine what extensions to use $info = getimagesize($tmpThumbPath); $mime = image_type_to_mime_type($info[2]); $thumbExtension = CImageHelper::getExtension($mime); $thumbFilename = $thumbFileName . $thumbExtension; $thumbPath = $thumbPath . '/' . $thumbFilename; if (!JFile::move($tmpThumbPath, $thumbPath)) { $this->setError(JText::_('WARNFS_ERR02') . ': ' . $thumbFileName); return false; } // Resize the thumbnails //CImageHelper::resizeProportional( $thumbPath , $thumbPath , $mime , CVideoLibrary::thumbSize('width') , CVideoLibrary::thumbSize('height') ); list($width, $height) = explode('x', $config->get('videosThumbSize')); CImageHelper::resizeAspectRatio($thumbPath, $thumbPath, $width, $height); } else { $this->setError(JText::_('COM_COMMUNITY_PHOTOS_IMAGE_NOT_PROVIDED_ERROR')); return false; } } // Update the DB with new thumbnail $thumb = $config->get('videofolder') . '/' . VIDEO_FOLDER_NAME . '/' . $table->creator . '/' . VIDEO_THUMB_FOLDER_NAME . '/' . $thumbFilename; $table->set('thumb', $thumb); $table->store(); // If this video storage is not on local, we move it to remote storage // and remove the old thumb if existed if ($table->storage != 'file') { // && ($table->storage == $storageType)) $config = CFactory::getConfig(); $storageType = $config->getString('videostorage'); $storage = CStorage::getStorage($storageType); $storage->delete($oldThumb); $localThumb = JPATH::clean(JPATH_ROOT . '/' . $table->thumb); $tempThumbname = JPATH::clean(JPATH_ROOT . '/' . md5($table->thumb)); if (JFile::exists($localThumb)) { JFile::copy($localThumb, $tempThumbname); } if (JFile::exists($tempThumbname)) { $storage->put($table->thumb, $tempThumbname); JFile::delete($localThumb); JFile::delete($tempThumbname); } } else { if (JFile::exists(JPATH_ROOT . '/' . $oldThumb)) { JFile::delete(JPATH_ROOT . '/' . $oldThumb); } } if ($returnThumb) { return $table->getThumbnail(); } return true; }
/** * Display Upload video form for user **/ function linkVideo() { if (!$this->accessAllowed('registered')) { echo JText::_('CC MEMBERS AREA'); return; } CFactory::load('libraries', 'filterbar'); CFactory::load('libraries', 'videos'); CFactory::load('helpers', 'videos'); $mainframe =& JFactory::getApplication(); $document =& JFactory::getDocument(); $config = CFactory::getConfig(); $my = CFactory::getUser(); $videoModel = CFactory::getModel('videos'); $pathway =& $mainframe->getPathway(); $pathway->addItem(JText::_($my->getDisplayName()), CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id)); $pathway->addItem(JText::_('CC EDIT PROFILE VIDEO'), ''); // Load the toolbar $this->showSubmenu(); $document->setTitle(JText::_('CC EDIT PROFILE VIDEO')); $video = $this->_getCurrentProfileVideo(); $filters = array('creator' => $my->id, 'status' => 'ready', 'sorting' => JRequest::getVar('sort', 'latest')); $videos = $videoModel->getVideos($filters, true); $sortItems = array('latest' => JText::_('CC VIDEO SORT LATEST'), 'mostwalls' => JText::_('CC VIDEO SORT MOST WALL POST'), 'mostviews' => JText::_('CC VIDEO SORT POPULAR'), 'title' => JText::_('CC VIDEO SORT TITLE')); // Pagination $pagination = $videoModel->getPagination(); $redirectUrl = CRoute::getURI(false); $tmpl = new CTemplate(); $tmpl->set('my', $my); $tmpl->set('video', $video); $tmpl->set('sort', JRequest::getVar('sort', 'latest')); $tmpl->set('videos', $videos); $tmpl->set('sortings', CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest')); $tmpl->set('pagination', $pagination); $tmpl->set('videoThumbWidth', CVideoLibrary::thumbSize('width')); $tmpl->set('videoThumbHeight', CVideoLibrary::thumbSize('height')); $tmpl->set('redirectUrl', $redirectUrl); echo $tmpl->fetch('profile.linkvideo'); }
public function showLatestVideos($total = 5, $raw = false) { $tmpl = new CTemplate(); $config = CFactory::getConfig(); $showlatestvideos = intval($tmpl->params->get('showlatestvideos')); $html = ''; $data = array(); if ($showlatestvideos != 0) { $my = CFactory::getUser(); // Oversample the total so that we get a randomized value $oversampledTotal = $total * COMMUNITY_OVERSAMPLING_FACTOR; CFactory::load('libraries', 'videos'); $videoModel = CFactory::getModel('videos'); $videosfilter = array('published' => 1, 'status' => 'ready', 'permissions' => $my->id == 0 ? 0 : 20, 'or_group_privacy' => 0, 'limit' => $oversampledTotal); $result = $videoModel->getVideos($videosfilter, true); $videos = array(); // Bind with video table to inherit its method foreach ($result as $videoEntry) { $video =& JTable::getInstance('Video', 'CTable'); $video->bind($videoEntry); $videos[] = $video; } if ($videos) { shuffle($videos); // Test the number of result so the loop will not fail with incorrect index. $total = count($videos) < $total ? count($videos) : $total; $videos = array_slice($videos, 0, $total); } if ($raw) { return $videos; } $tmpl = new CTemplate(); $html = $tmpl->setRef('data', $videos)->set('thumbWidth', CVideoLibrary::thumbSize('width'))->set('thumbHeight', CVideoLibrary::thumbSize('height'))->fetch('frontpage.latestvideos'); } $data['HTML'] = $html; return $data; }
/** * Generate Featured Videos HTML * * @param array Array of video objects * @return string HTML * @since 1.2 */ private function _getFeatHTML($videos) { $config = CFactory::getConfig(); $tmpl = new CTemplate(); return $tmpl->set('videos', $videos)->set('showFeatured', $config->get('show_featured'))->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('videoThumbWidth', CVideoLibrary::thumbSize('width'))->set('videoThumbHeight', CVideoLibrary::thumbSize('height'))->fetch('videos.featured'); }
public function modProfileUserVideo() { $my = CFactory::getUser(); $jinput = JFactory::getApplication()->input; $userid = $jinput->get('userid', $my->id, 'INT'); $user = CFactory::getUser($userid); $config = CFactory::getConfig(); $params = $user->getParams(); $profilevideoId = $params->get('profileVideo', 0); if ($config->get('enablevideos') && $config->get('enableprofilevideo') && $profilevideoId) { $video = JTable::getInstance('Video', 'CTable'); $video->load($profilevideoId); $tmpl = new CTemplate(); echo $tmpl->set('video', $video)->set('videoThumbWidth', CVideoLibrary::thumbSize('width'))->set('videoThumbHeight', CVideoLibrary::thumbSize('height'))->fetch('profile.video'); } return false; }
/** * Displays specific groups **/ function viewGroup() { $mainframe =& JFactory::getApplication(); CFactory::load('libraries', 'tooltip'); CFactory::load('libraries', 'wall'); CFactory::load('libraries', 'window'); CWindow::load(); $config = CFactory::getConfig(); $document =& JFactory::getDocument(); // Load appropriate models $groupModel = CFactory::getModel('groups'); $wallModel = CFactory::getModel('wall'); $userModel = CFactory::getModel('user'); $discussModel = CFactory::getModel('discussions'); $bulletinModel = CFactory::getModel('bulletins'); $photosModel = CFactory::getModel('photos'); $groupid = JRequest::getInt('groupid', ''); CError::assert($groupid, '', '!empty', __FILE__, __LINE__); $editGroup = JRequest::getVar('edit', false, 'GET'); $editGroup = $editGroup == 1 ? true : false; // Load the group table. $group =& JTable::getInstance('Group', 'CTable'); $group->load($groupid); $params = $group->getParams(); CFactory::load('helpers', 'string'); $mainframe->appendMetaTag('title', CStringHelper::escape($group->name)); $mainframe->appendMetaTag('description', CStringHelper::escape(strip_tags($group->description))); $mainframe->addCustomHeadTag('<link rel="image_src" href="' . JURI::root() . $group->thumb . '" />'); // @rule: Test if the group is unpublished, don't display it at all. if (!$group->published) { echo JText::_('CC GROUP UNPUBLISHED'); return; } // Show submenu $this->showSubmenu(); // Set the group info to contain proper <br> $group->description = nl2br($group->description); $this->addPathway(JText::_('CC GROUPS'), CRoute::_('index.php?option=com_community&view=groups')); $this->addPathway(JText::sprintf('CC VIEW GROUP TITLE', $group->name), ''); // Load the current browsers data $my = CFactory::getUser(); // If user are invited $isInvited = $groupModel->isInvited($my->id, $groupid); // Get members list for display $members = $groupModel->getMembers($groupid, 12, true, CC_RANDOMIZE, true); $membersCount = $groupModel->total; CError::assert($members, 'array', 'istype', __FILE__, __LINE__); // Is there any my friend is the member of this group? $join = ''; $friendsCount = 0; if ($isInvited) { // Get the invitors $invitors = $groupModel->getInvitors($my->id, $groupid); if (count($invitors) == 1) { $user = CFactory::getUser($invitors[0]->creator); $join = '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } else { for ($i = 0; $i < count($invitors); $i++) { $user = CFactory::getUser($invitors[$i]->creator); if ($i + 1 == count($invitors)) { $join .= ' ' . JText::_('CC AND') . ' ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } else { $join .= ', ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } } } // Get users friends in this group $friendsCount = $groupModel->getFriendsCount($my->id, $groupid); } $admins = $groupModel->getAdmins($groupid, 12, CC_RANDOMIZE); $adminsCount = $groupModel->total; // Get the news $bulletins = $bulletinModel->getBulletins($group->id); $totalBulletin = $bulletinModel->total; CError::assert($bulletins, 'array', 'istype', __FILE__, __LINE__); // Get discussions $discussions = $discussModel->getDiscussionTopics($group->id, '10', $params->get('discussordering', DISCUSSION_ORDER_BYLASTACTIVITY)); $totalDiscussion = $discussModel->total; CError::assert($discussions, 'array', 'istype', __FILE__, __LINE__); // Get list of unapproved members $unapproved = $groupModel->getMembers($group->id, null, false); // Attach avatar of the member to the discussions for ($i = 0; $i < count($discussions); $i++) { $row =& $discussions[$i]; $row->user = CFactory::getUser($row->creator); // Get last replier for the discussion $row->lastreplier = $discussModel->getLastReplier($row->id); if ($row->lastreplier) { $row->lastreplier->post_by = CFactory::getUser($row->lastreplier->post_by); } } // Attach avatar of the admin for ($i = 0; $i < count($admins); $i++) { $row =& $admins[$i]; $admins[$i] = CFactory::getUser($row->id); } // Attach avatar of the member // Pre-load multiple users at once $userids = array(); foreach ($members as $uid) { $userids[] = $uid->id; } CFactory::loadUsers($userids); for ($i = 0; $i < count($members); $i++) { $row =& $members[$i]; $members[$i] = CFactory::getUser($row->id); } // Test if the current user is admin $isAdmin = $groupModel->isAdmin($my->id, $group->id); // Test if the current browser is a member of the group $isMember = $group->isMember($my->id); $waitingApproval = false; // Test if the current user is banned from this group $isBanned = $group->isBanned($my->id); if ($isBanned) { $mainframe->enqueueMessage(JText::_('CC GROUP MEMBER BANNED'), 'error'); } // If I have tried to join this group, but not yet approved, display a notice if ($groupModel->isWaitingAuthorization($my->id, $group->id)) { $waitingApproval = true; } // Get the walls $wallContent = CWallLibrary::getWallContents('groups', $group->id, $isAdmin, 10, 0, 'wall.content', 'groups,group'); $wallCount = CWallLibrary::getWallCount('groups', $group->id); $viewAllLink = false; if (JRequest::getVar('task', '', 'REQUEST') != 'app') { $viewAllLink = CRoute::_('index.php?option=com_community&view=groups&task=app&groupid=' . $group->id . '&app=walls'); } $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount); $wallForm = ''; CFactory::load('helpers', 'owner'); if (!$config->get('lockgroupwalls') || $config->get('lockgroupwalls') && ($isMember && !$isBanned) && !$waitingApproval || COwnerHelper::isCommunityAdmin()) { $wallForm = CWallLibrary::getWallInputForm($group->id, 'groups,ajaxSaveWall', 'groups,ajaxRemoveWall'); } // Get like CFactory::load('libraries', 'like'); $likes = new CLike(); $likesHTML = $isMember && !$isBanned ? $likes->getHTML('groups', $group->id, $my->id) : $likes->getHtmlPublic('groups', $group->id); // Process discussions HTML output $tmpl = new CTemplate(); $tmpl->set('discussions', $discussions); $tmpl->set('groupId', $group->id); $discussionsHTML = $tmpl->fetch('groups.discussionlist'); unset($tmpl); // Get the creator of the discussions for ($i = 0; $i < count($bulletins); $i++) { $row =& $bulletins[$i]; $row->creator = CFactory::getUser($row->created_by); } // Only trigger the bulletins if there is really a need to. if (!empty($bulletins)) { $appsLib =& CAppPlugins::getInstance(); $appsLib->loadApplications(); // Format the bulletins // the bulletins need to be an array or reference to work around // PHP 5.3 pass by value $args = array(); foreach ($bulletins as &$b) { $args[] =& $b; } $appsLib->triggerEvent('onBulletinDisplay', $args); } // Process bulletins HTML output $tmpl = new CTemplate(); $tmpl->set('bulletins', $bulletins); $tmpl->set('groupId', $group->id); $bulletinsHTML = $tmpl->fetch('groups.bulletinlist'); unset($tmpl); $tmpl = new CTemplate(); // Get categories list // We should really load this in saperate file // @todo: editing group should really open a new page if ($my->id == $group->ownerid || COwnerHelper::isCommunityAdmin()) { $categories = $groupModel->getCategories(); CError::assert($categories, 'array', 'istype', __FILE__, __LINE__); $tmpl->set('categories', $categories); } $isMine = $my->id == $group->ownerid; // Get reporting html CFactory::load('libraries', 'reporting'); $report = new CReportingLibrary(); $reportHTML = $report->getReportingHTML(JText::_('CC REPORT GROUP'), 'groups,reportGroup', array($group->id)); $isSuperAdmin = COwnerHelper::isCommunityAdmin(); if ($group->approvals == '1' && !$isMine && !$isMember && !$isSuperAdmin) { $this->addWarning(JText::_('CC PRIVATE GROUP NOTICE')); } $albums =& $photosModel->getGroupAlbums($group->id, true, false, $params->get('grouprecentphotos', GROUP_PHOTO_RECENT_LIMIT)); $totalAlbums = $photosModel->total; CFactory::load('helpers', 'videos'); CFactory::load('libraries', 'videos'); CFactory::load('helpers', 'group'); $videoModel = CFactory::getModel('videos'); $tmpVideos = $videoModel->getGroupVideos($group->id, '', $params->get('grouprecentvideos', GROUP_VIDEO_RECENT_LIMIT)); $videos = array(); if ($tmpVideos) { foreach ($tmpVideos as $videoEntry) { $video =& JTable::getInstance('Video', 'CTable'); $video->bind($videoEntry); $videos[] = $video; } } $videoThumbWidth = CVideoLibrary::thumbSize('width'); $videoThumbHeight = CVideoLibrary::thumbSize('height'); $totalVideos = $videoModel->total; $eventsModel = CFactory::getModel('Events'); $tmpEvents =& $eventsModel->getGroupEvents($group->id, $params->get('grouprecentevents', GROUP_EVENT_RECENT_LIMIT)); $totalEvents = $eventsModel->getTotalGroupEvents($group->id); $events = array(); foreach ($tmpEvents as $event) { $table =& JTable::getInstance('Event', 'CTable'); $table->bind($event); $events[] = $table; } $allowManagePhotos = CGroupHelper::allowManagePhoto($group->id); $allowManageVideos = CGroupHelper::allowManageVideo($group->id); $allowCreateEvent = CGroupHelper::allowCreateEvent($my->id, $group->id); CFactory::load('libraries', 'bookmarks'); $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id)); $bookmarksHTML = $bookmarks->getHTML(); $isCommunityAdmin = COwnerHelper::isCommunityAdmin(); if ($group->approvals == '0' || $isMine || $isMember && !$isBanned || $isCommunityAdmin) { // Set feed url $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewbulletins&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO BULLETIN FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussions&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO DISCUSSION FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=photos&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO GROUP PHOTOS FEEDS') . '" href="' . $feedLink . '"/>'; $mainframe->addCustomHeadTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=videos&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO GROUP VIDEOS FEEDS') . '" href="' . $feedLink . '"/>'; $mainframe->addCustomHeadTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=events&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO GROUP EVENTS FEEDS') . '" href="' . $feedLink . '"/>'; $mainframe->addCustomHeadTag($feed); } $friendsModel = CFactory::getModel('Friends'); $groupsModel = CFactory::getModel('Groups'); $tmpFriends = $friendsModel->getFriends($my->id, 'name', false); $friends = array(); for ($i = 0; $i < count($tmpFriends); $i++) { $friend =& $tmpFriends[$i]; $groupInvite =& JTable::getInstance('GroupInvite', 'CTable'); $groupInvite->load($group->id, $friend->id); if (!$groupsModel->isMember($friend->id, $group->id)) { $friends[] = $friend; } } unset($tmpFriends); CFactory::load('libraries', 'invitation'); $inviteHTML = CInvitation::getHTML($friends, 'groups,inviteUsers', $group->id); $tmpl->setMetaTags('group', $group); $tmpl->set('likesHTML', $likesHTML); $tmpl->set('events', $events); $tmpl->set('totalEvents', $totalEvents); $tmpl->set('inviteHTML', $inviteHTML); $tmpl->set('showEvents', $params->get('eventpermission') != -1); $tmpl->set('showPhotos', $params->get('photopermission') != -1); $tmpl->set('showVideos', $params->get('videopermission') != -1); $tmpl->set('bookmarksHTML', $bookmarksHTML); $tmpl->set('allowManagePhotos', $allowManagePhotos); $tmpl->set('allowManageVideos', $allowManageVideos); $tmpl->set('allowCreateEvent', $allowCreateEvent); $tmpl->set('videos', $videos); $tmpl->set('videoThumbWidth', $videoThumbWidth); $tmpl->set('videoThumbHeight', $videoThumbHeight); $tmpl->set('totalVideos', $totalVideos); $tmpl->set('albums', $albums); $tmpl->set('totalAlbums', $totalAlbums); $tmpl->set('reportHTML', $reportHTML); $tmpl->set('editGroup', $editGroup); $tmpl->set('waitingApproval', $waitingApproval); $tmpl->set('config', $config); $tmpl->set('my', $my); $tmpl->set('isMine', $isMine); $tmpl->set('isAdmin', $isAdmin); $tmpl->set('isSuperAdmin', $isSuperAdmin); $tmpl->set('isMember', $isMember); $tmpl->set('isInvited', $isInvited); $tmpl->set('friendsCount', $friendsCount); $tmpl->set('join', $join); $tmpl->set('unapproved', count($unapproved)); $tmpl->set('membersCount', $membersCount); $tmpl->set('group', $group); $tmpl->set('totalBulletin', $totalBulletin); $tmpl->set('totalDiscussion', $totalDiscussion); $tmpl->set('members', $members); $tmpl->set('admins', $admins); $tmpl->set('adminsCount', $adminsCount); $tmpl->set('bulletins', $bulletins); $tmpl->set('wallForm', $wallForm); $tmpl->set('wallContent', $wallContent); $tmpl->set('discussions', $discussions); $tmpl->set('discussionsHTML', $discussionsHTML); $tmpl->set('bulletinsHTML', $bulletinsHTML); $tmpl->set('isCommunityAdmin', $isCommunityAdmin); $tmpl->set('isBanned', $isBanned); echo $tmpl->fetch('groups.viewgroup'); }
public function upload() { $document = JFactory::getDocument(); $mainframe = JFactory::getApplication(); $my = $this->plugin->get('user'); $creatorType = JRequest::getVar('creatortype', VIDEO_USER_TYPE); $groupid = $creatorType == VIDEO_GROUP_TYPE ? JRequest::getInt('groupid', 0) : 0; $config = CFactory::getConfig(); CFactory::load('helpers', 'videos'); CFactory::load('libraries', 'videos'); $redirect = CVideosHelper::getVideoReturnUrlFromRequest(); // Process according to video creator type if (!empty($groupid)) { CFactory::load('helpers', 'group'); $allowManageVideos = CGroupHelper::allowManageVideo($groupid); $creatorType = VIDEO_GROUP_TYPE; $videoLimit = $config->get('groupvideouploadlimit'); CError::assert($allowManageVideos, '', '!empty', __FILE__, __LINE__); } else { $creatorType = VIDEO_USER_TYPE; $videoLimit = $config->get('videouploadlimit'); } // Check is video upload is permitted CFactory::load('helpers', 'limits'); if (CLimitsHelper::exceededVideoUpload($my->id, $creatorType)) { $message = JText::sprintf('CC VIDEOS CREATION REACH LIMIT', $videoLimit); $this->setError($message); return false; } if (!$config->get('enablevideos')) { $this->setError(JText::_('CC VIDEO DISABLED', 'notice')); return false; } if (!$config->get('enablevideosupload')) { $this->setError(JText::_('CC VIDEO UPLOAD DISABLED', 'notice')); return false; } // Check if the video file is valid $files = JRequest::get('files'); $videoFile = !empty($files['video']) ? $files['video'] : array(); if (empty($files) || empty($videoFile['name']) && $videoFile['size'] < 1) { $this->setError(JText::_('CC VIDEO UPLOAD ERROR', 'error')); return false; } // Check file type. $fileType = $videoFile['type']; // Override from iphone $fileType = 'video/quicktime'; $allowable = CVideosHelper::getValidMIMEType(); if (!in_array($fileType, $allowable)) { $this->setError(JText::sprintf('CC VIDEO FILE TYPE NOT SUPPORTED', $fileType)); return false; } // Check if the video file exceeds file size limit $uploadLimit = $config->get('maxvideouploadsize') * 1024 * 1024; $videoFileSize = sprintf("%u", filesize($videoFile['tmp_name'])); if ($uploadLimit > 0 && $videoFileSize > $uploadLimit) { $this->setError(JText::sprintf('CC VIDEO FILE SIZE EXCEEDED', $uploadLimit)); return false; } // Passed all checking, attempt to save the video file CFactory::load('helpers', 'file'); $folderPath = CVideoLibrary::getPath($my->id, 'original'); $randomFileName = CFileHelper::getRandomFilename($folderPath, $videoFile['name'], ''); $destination = JPATH::clean($folderPath . DS . $randomFileName); if (!CFileHelper::upload($videoFile, $destination)) { $this->setError(JText::_('CC VIDEO UPLOAD FAILED', 'error')); return false; } $config = CFactory::getConfig(); $videofolder = $config->get('videofolder'); CFactory::load('models', 'videos'); $video = JTable::getInstance('Video', 'CTable'); $video->set('path', $videofolder . '/originalvideos/' . $my->id . '/' . $randomFileName); $video->set('title', JRequest::getVar('title')); $video->set('description', JRequest::getVar('description')); $video->set('category_id', JRequest::getInt('category', 0, 'post')); $video->set('permissions', JRequest::getInt('privacy', 0, 'post')); $video->set('creator', $my->id); $video->set('creator_type', $creatorType); $video->set('groupid', $groupid); $video->set('filesize', $videoFileSize); if (!$video->store()) { $this->setError(JText::_('CC VIDEO SAVE ERROR', 'error')); return false; } // Trigger for onVideoCreate $this->_triggerEvent('onVideoCreate', $video); // Video saved, redirect return $video; }
function showLatestVideos($total = 5, $raw = false) { $my = CFactory::getUser(); // Oversample the total so that we get a randomized value $oversampledTotal = $total * COMMUNITY_OVERSAMPLING_FACTOR; CFactory::load('libraries', 'videos'); $videoModel = CFactory::getModel('videos'); $videosfilter = array('published' => 1, 'status' => 'ready', 'permissions' => $my->id == 0 ? 0 : 20, 'or_group_privacy' => 0, 'limit' => $oversampledTotal); $videos = $videoModel->getVideos($videosfilter, true); if ($videos) { shuffle($videos); // Test the number of result so the loop will not fail with incorrect index. $total = count($videos) < $total ? count($videos) : $total; $videos = array_slice($videos, 0, $total); } if ($raw) { return $videos; } $tmpl = new CTemplate(); $tmpl->setRef('data', $videos); $tmpl->set('thumbWidth', CVideoLibrary::thumbSize('width')); $tmpl->set('thumbHeight', CVideoLibrary::thumbSize('height')); return $tmpl->fetch('frontpage.latestvideos'); }
/** * Ajax function to save a new wall entry * * @param message A message that is submitted by the user * @param uniqueId The unique id for this group * **/ function ajaxSaveWall($response, $message, $uniqueId, $cache_id = "") { $my = CFactory::getUser(); $user = CFactory::getUser($uniqueId); JPlugin::loadLanguage('plg_walls', JPATH_ADMINISTRATOR); // Load libraries CFactory::load('models', 'photos'); CFactory::load('libraries', 'wall'); CFactory::load('helpers', 'url'); CFactory::load('libraries', 'activities'); $message = JString::trim($message); $message = strip_tags($message); if (empty($message)) { $response->addAlert(JText::_('PLG_WALLS PLEASE ADD MESSAGE')); } else { $maxchar = $this->params->get('charlimit', 0); if (!empty($maxchar)) { $msglength = strlen($message); if ($msglength > $maxchar) { $message = substr($message, 0, $maxchar); } } $wall = CWallLibrary::saveWall($uniqueId, $message, 'user', $my, $my->id == $user->id, 'profile,profile'); CFactory::load('libraries', 'activities'); CFactory::load('helpers', 'videos'); $matches = cGetVideoLinkMatches($message); $activityParams = ''; // We only want the first result of the video to be in the activity if ($matches) { $videoLink = $matches[0]; CFactory::load('libraries', 'videos'); $videoLib = new CVideoLibrary(); $provider = $videoLib->getProvider($videoLink); $activityParams .= 'videolink=' . $videoLink . "\r\n"; if ($provider->isValid()) { $activityParams .= 'url=' . $provider->getThumbnail(); } } $act = new stdClass(); $act->cmd = 'profile.wall.create'; $act->actor = $my->id; $act->target = $uniqueId; $act->title = JText::_('CC ACTIVITIES WALL POST PROFILE'); $act->content = '{plugins,walls,getWallActivityContent}'; $act->app = 'walls'; $act->cid = $wall->id; CActivityStream::add($act, $activityParams); // @rule: Send notification to the profile user. if ($my->id != $user->id) { CFactory::load('libraries', 'notification'); $params = new JParameter(''); $params->set('url', 'index.php?option=com_community&view=profile&userid=' . $user->id); $params->set('message', $message); CNotificationLibrary::add('profile.submit.wall', $my->id, $user->id, JText::sprintf('PLG_WALLS NOTIFY EMAIL SUBJECT', $my->getDisplayName()), '', 'profile.wall', $params); } //add user points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('profile.wall.create'); $response->addScriptCall('joms.walls.insert', $wall->content); $response->addScriptCall('if(joms.jQuery(".content-nopost").length){ joms.jQuery("#wall-empty-container").remove(); }'); $cache =& JFactory::getCache('plgCommunityWalls'); $cache->remove($cache_id); $cache =& JFactory::getCache('plgCommunityWalls_fullview'); $cache->remove($cache_id); } return $response; }