Ejemplo n.º 1
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');
 }
Ejemplo n.º 2
0
 /**
  * Ajax retreive Featured Profile Information
  * @since 2.6
  */
 public function ajaxShowProfileFeatured($userId)
 {
     $my = CFactory::getUser();
     $objResponse = new JAXResponse();
     $featureduser = CFactory::getUser($userId);
     $user = JTable::getInstance('MemberList', 'CTable');
     $user->load($userId);
     // Get group link
     // Get Avatar
     $avatar = $featureduser->getAvatar('avatar');
     // Get random picture
     // Get group link
     $userLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $userId);
     // Get unfeature icon
     $userUnfeature = '<a class="album-action remove-featured" title="' . JText::_('COM_COMMUNITY_REMOVE_FEATURED') . '" onclick="joms.featured.remove(\'' . $userId . '\',\'search\');" href="javascript:void(0);">' . JText::_('COM_COMMUNITY_REMOVE_FEATURED') . '</a>';
     $userStatus = $featureduser->getStatus();
     //Get Friend List
     $view = $this->getView('profile');
     $friendList = $view->modGetFriendsFeaturedHTML($userId);
     // Get like
     $likes = new CLike();
     $likesHTML = $likes->getHTML('profile', $userId, $my->id);
     $objResponse->addScriptCall('updateFeaturedProfile', $userId, $featureduser->getDisplayName(), $likesHTML, $avatar, $userLink, $userUnfeature, $userStatus, $friendList);
     $objResponse->sendResponse();
 }
Ejemplo n.º 3
0
 /**
  * Trigger any necessary items that needs to be changed when the photo
  * is changed.
  **/
 public function ajaxSwitchPhotoTrigger($photoId)
 {
     $response = new JAXResponse();
     // Load the default photo
     CFactory::load('models', 'photos');
     $photo =& JTable::getInstance('Photo', 'CTable');
     $photo->load($photoId);
     $my = CFactory::getUser();
     // Since the only way for us to get the id is through the AJAX call,
     // we can only increment the hit when the ajax loads
     $photo->hit();
     // Update the hits each time the photo is switched
     $response->addAssign('photo-hits', 'innerHTML', $photo->hits);
     // Show creator
     $creator = CFactory::getUser($photo->creator);
     $creatorHTML = JText::sprintf('CC UPLOADED BY', CRoute::_('index.php?option=com_community&view=profile&userid=' . $creator->id), $creator->getDisplayName());
     $response->addAssign('uploadedBy', 'innerHTML', $creatorHTML);
     // Get the wall form
     $wallInput = $this->showWallForm($photoId);
     $response->addAssign('community-photo-walls', 'innerHTML', $wallInput);
     // Get the wall contents
     $wallContents = $this->showWallContents($photoId);
     $response->addAssign('wallContent', 'innerHTML', $wallContents);
     $response->addScriptCall("joms.utils.textAreaWidth('#wall-message');");
     $photo =& JTable::getInstance('Photo', 'CTable');
     $photo->load($photoId);
     // When a photo is navigated, the sharing should also be updated.
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks($photo->getPhotoLink(true));
     // Get the reporting data
     CFactory::load('libraries', 'reporting');
     $report = new CReportingLibrary();
     $reportHTML = $report->getReportingHTML(JText::_('CC REPORT BAD PHOTO'), 'photos,reportPhoto', array($photoId));
     $response->addScriptCall('joms.gallery.updatePhotoReport', $reportHTML);
     $response->addScriptCall('joms.gallery.updatePhotoBookmarks', $bookmarks->getHTML());
     $response->addScriptCall('joms.jQuery("body").focus();');
     $response->addScriptCall('joms.gallery.bindFocus();');
     // Get the likes / dislikes item
     CFactory::load('libraries', 'like');
     $like = new CLike();
     $likeHTML = $like->getHTML('photo', $photoId, $my->id);
     $response->addScriptCall('__callback', $likeHTML);
     return $response->sendResponse();
 }
Ejemplo n.º 4
0
 /**
  * Displays the viewing profile page.
  *
  * @access	public
  * @param	array  An associative array to display the fields
  */
 function profile(&$data)
 {
     $mainframe =& JFactory::getApplication();
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $userid = JRequest::getVar('userid', $my->id);
     $user = CFactory::getUser($userid);
     $userId = JRequest::getVar('userid', '', 'GET');
     if ($my->id != 0 && empty($userId)) {
         CFactory::setActiveProfile($my->id);
         $user = $my;
     }
     // Display breadcrumb regardless whether the user is blocked or not
     $pathway =& $mainframe->getPathway();
     $pathway->addItem($user->getDisplayName(), '');
     // Get profile video information
     $params = $user->getParams();
     $videoid = $params->get('profileVideo', 0);
     CFactory::load('helpers', 'owner');
     $blocked = $user->isBlocked();
     if ($blocked && !COwnerHelper::isCommunityAdmin()) {
         $tmpl = new CTemplate();
         echo $tmpl->fetch('profile.blocked');
         return;
     }
     // If the current browser is a site admin, display some notice that user is blocked.
     if ($blocked) {
         $this->addWarning(JText::_('CC USER ACCOUNT BANNED'));
     }
     // access check
     if (!$this->accessAllowed('privacyProfileView')) {
         return;
     }
     require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'userpoints.php';
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     CFactory::load('helpers', 'string');
     $document =& JFactory::getDocument();
     $status = $user->getStatus(COMMUNITY_RAW_STATUS);
     $status = empty($status) ? '' : ' : ' . $status;
     $document->setTitle($user->getDisplayName(COMMUNITY_RAW_STATUS) . $status);
     $document->setMetaData('description', JText::sprintf('CC PROFILE META DESCRIPTION', $user->getDisplayName(), $config->get('sitename'), CStringHelper::escape($status)));
     $feedLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id . '&format=feed');
     $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO USER FEEDS') . '"  href="' . $feedLink . '"/>';
     $mainframe->addCustomHeadTag($feed);
     $feedLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id . '&showfriends=true&format=feed');
     $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO USER FRIENDS FEEDS') . '"  href="' . $feedLink . '"/>';
     $mainframe->addCustomHeadTag($feed);
     $feedLink = CRoute::_('index.php?option=com_community&view=photos&task=myphotos&userid=' . $user->id . '&format=feed');
     $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO USER PHOTO FEEDS') . '"  href="' . $feedLink . '"/>';
     $mainframe->addCustomHeadTag($feed);
     $feedLink = CRoute::_('index.php?option=com_community&view=videos&userid=' . $user->id . '&format=feed');
     $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO USER VIDEO FEEDS') . '"  href="' . $feedLink . '"/>';
     $mainframe->addCustomHeadTag($feed);
     // Get profile video information
     $params = $user->getParams();
     $data->videoid = $params->get('profileVideo', 0);
     // Show profile header
     $headerHTML = $this->_showHeader($data);
     // Load user application
     $apps = $data->apps;
     // Load community applications plugin
     $app =& CAppPlugins::getInstance();
     $appsModel = CFactory::getModel('apps');
     $tmpAppData = $app->triggerEvent('onProfileDisplay', '', true);
     $appData = array();
     // @rule: Only display necessary apps.
     $count = count($tmpAppData);
     for ($i = 0; $i < $count; $i++) {
         $app =& $tmpAppData[$i];
         $privacy = $appsModel->getPrivacy($user->id, $app->name);
         if ($this->appPrivacyAllowed($privacy)) {
             $appData[] = $app;
         }
     }
     unset($tmpAppData);
     // Split the apps into different list for different positon
     $appsInPositions = array();
     foreach ($appData as &$app) {
         $appsInPositions[$app->position][] = $app;
     }
     $tmpl = new CTemplate();
     $contenHTML = array();
     $contenHTML['content'] = '';
     $contenHTML['sidebar-top'] = '';
     $contenHTML['sidebar-bottom'] = '';
     $jscript = '';
     foreach ($appsInPositions as $position => $appData) {
         ob_start();
         foreach ($appData as $app) {
             // If the apps content is empty, we ignore this app from showing
             // the header in profile page.
             if (JString::trim($app->data) == "") {
                 continue;
             }
             $tmpl->set('app', $app);
             $tmpl->set('isOwner', COwnerHelper::isMine($my->id, $user->id));
             switch ($position) {
                 case 'sidebar-top':
                 case 'sidebar-bottom':
                     echo $tmpl->fetch('application.widget');
                     break;
                 default:
                     echo $tmpl->fetch('application.box');
             }
         }
         $contenHTML[$position] = ob_get_contents();
         ob_end_clean();
     }
     // Get the config
     $config = CFactory::getConfig();
     // get total group
     $groupsModel = CFactory::getModel('groups');
     $totalgroups = $groupsModel->getGroupsCount($user->id);
     // get total friend
     $friendsModel = CFactory::getModel('friends');
     $totalfriends = $user->getFriendCount();
     // get total photos
     $photosModel = CFactory::getModel('photos');
     $totalphotos = $photosModel->getPhotosCount($user->id);
     // get total activities
     $activitiesModel = CFactory::getModel('activities');
     $totalactivities = $activitiesModel->getActivityCount($user->id);
     $isMine = COwnerHelper::isMine($my->id, $user->id);
     $isCommunityAdmin = COwnerHelper::isCommunityAdmin($user->id);
     // Get reporting html
     CFactory::load('libraries', 'reporting');
     $report = new CReportingLibrary();
     $reportHTML = $isMine ? '' : $report->getReportingHTML(JText::_('CC REPORT BAD USER'), 'profile,reportProfile', array($user->id));
     // Check if user is blocked
     $blockUserModel = CFactory::getModel('block');
     $isBlocked = $blockUserModel->getBlockStatus($user->id, $my->id);
     // Get block user html
     CFactory::load('helpers', 'user');
     $blockUserHTML = $isMine || $isCommunityAdmin ? '' : CUserHelper::getBlockUserHTML($user->id, $isBlocked);
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=profile&userid=' . $user->id));
     $bookmarksHTML = $bookmarks->getHTML();
     // Get like
     // cater for buble, blueface template
     $likesHTML = '';
     if ($user->getParams()->get('profileLikes', true)) {
         CFactory::load('libraries', 'like');
         $likes = new CLike();
         $likesHTML = $my->id == 0 ? $likes->getHtmlPublic('profile', $user->id) : $likes->getHTML('profile', $user->id, $my->id);
     }
     $tmpl = new CTemplate();
     $tmpl->set('blockUserHTML', $blockUserHTML);
     $tmpl->set('bookmarksHTML', $bookmarksHTML);
     $tmpl->set('profileOwnerName', $user->getDisplayName());
     $tmpl->set('totalgroups', $totalgroups);
     $tmpl->set('totalfriends', $totalfriends);
     $tmpl->set('totalphotos', $totalphotos);
     $tmpl->set('totalactivities', $totalactivities);
     $tmpl->set('reportsHTML', $reportHTML);
     $tmpl->set('mainframe', $mainframe);
     $tmpl->set('config', $config);
     $tmpl->set('about', $this->_getProfileHTML($data->profile));
     $tmpl->set('friends', $this->_getFriendsHTML());
     $tmpl->set('groups', $this->_getGroupsHTML());
     $tmpl->set('newsfeed', $this->_getNewsfeedHTML());
     $tmpl->set('header', $headerHTML);
     $tmpl->set('adminControlHTML', $this->_getAdminControlHTML($user->id));
     $tmpl->set('content', $contenHTML['content']);
     $tmpl->set('sidebarTop', $contenHTML['sidebar-top']);
     $tmpl->set('sidebarBottom', $contenHTML['sidebar-bottom']);
     $tmpl->set('isMine', $isMine);
     $tmpl->set('jscript', '');
     // maintain for 1.8.0 template compatibility
     $tmpl->setRef('user', $user);
     $tmpl->set('my', $my);
     $tmpl->set('videoid', $data->videoid);
     $tmpl->set('likesHTML', $likesHTML);
     $html = $tmpl->fetch('profile.index');
     echo $html;
 }
Ejemplo n.º 5
0
 /**
  * Unlike an item
  * @param string $element   Can either be core object (photos/videos) or a plugins (plugins,plugin_name)
  * @param mixed $itemId	    Unique id to identify object item
  *
  */
 public function ajaxUnlike($element, $itemId)
 {
     $filter = JFilterInput::getInstance();
     $itemId = $filter->clean($itemId, 'int');
     $element = $filter->clean($element, 'string');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $my = CFactory::getUser();
     $objResponse = new JAXResponse();
     // Load libraries
     CFactory::load('libraries', 'like');
     $unlike = new CLike();
     if (!$unlike->enabled($element)) {
     } else {
         $unlike->unlike($element, $itemId);
         $html = $unlike->getHTML($element, $itemId, $my->id);
         $objResponse->addScriptCall('__callback', $html);
     }
     return $objResponse->sendResponse();
 }
Ejemplo n.º 6
0
 /**
  * Method to display video
  *
  **/
 function video()
 {
     $mainframe =& JFactory::getApplication();
     $document =& JFactory::getDocument();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     $videoId = JRequest::getVar('videoid', '', 'GET');
     $groupId = JRequest::getVar('groupid', '', 'GET');
     // Load window library
     CFactory::load('libraries', 'window');
     // Load necessary window css / javascript headers.
     CWindow::load();
     // Load the video table
     // Load string helper
     CFactory::load('helpers', 'string');
     $video =& JTable::getInstance('Video', 'CTable');
     if (empty($videoId)) {
         $url = CRoute::_('index.php?option=com_community&view=videos', false);
         $mainframe->redirect($url, JText::_('CC NO PROPER VIDEO ID'), 'warning');
     }
     if (!$video->load($videoId)) {
         $url = CRoute::_('index.php?option=com_community&view=videos', false);
         $mainframe->redirect($url, JText::_('CC VIDEO NOT AVAILABLE'), 'warning');
     }
     // Setting up the sub menu
     CFactory::load('helpers', 'owner');
     if (COwnerHelper::isCommunityAdmin() || $my->id == $video->creator && $my->id != 0) {
         $this->addSubmenuItem('', JText::_('CC FETCH VIDEO THUMBNAIL'), 'joms.videos.fetchThumbnail(\'' . $video->id . '\')', true);
         // Only add the set as profile video for video owner
         if ($my->id == $video->creator) {
             $this->addSubmenuItem('', JText::_('CC SET AS PROFILE VIDEO'), 'joms.videos.linkConfirmProfileVideo(\'' . $video->id . '\')', true);
         }
         $redirectUrl = CRoute::getURI(false);
         $this->addSubmenuItem('', JText::_('CC EDIT'), 'joms.videos.showEditWindow(\'' . $video->id . '\',\'' . $redirectUrl . '\');', true);
         $this->addSubmenuItem('', JText::_('CC DELETE'), 'joms.videos.deleteVideo(\'' . $video->id . '\')', true);
     }
     $this->_addSubmenu();
     $this->showSubmenu();
     // Show the mini header when viewing other's photos
     if ($video->creator_type == VIDEO_USER_TYPE && $my->id != $video->creator) {
         $this->attachMiniHeaderUser($video->creator);
     }
     // Check permission
     $user = CFactory::getUser($video->creator);
     $blocked = $user->isBlocked();
     if ($blocked && !COwnerHelper::isCommunityAdmin()) {
         $tmpl = new CTemplate();
         echo $tmpl->fetch('profile.blocked');
         return;
     }
     if ($video->creator_type == VIDEO_GROUP_TYPE) {
         CFactory::load('helpers', 'group');
         if (!CGroupHelper::allowViewMedia($groupId)) {
             $document->setTitle(JText::_('CC RESTRICTED ACCESS'));
             $mainframe->enqueueMessage(JText::_('CC RESTRICTED ACCESS', 'notice'));
             echo JText::_('CC VIDEO NEED GROUP MEMBER PERMISSION');
             return;
         }
         $group =& JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         // Set pathway
         $pathway =& $mainframe->getPathway();
         $pathway->addItem(JText::_('CC 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::_('CC VIDEOS'), CRoute::_('index.php?option=com_community&view=videos&groupid=' . $groupId));
         $pathway->addItem($video->getTitle(), '');
     } else {
         if (!$this->isPermitted($my->id, $video->creator, $video->permissions)) {
             $document->setTitle(JText::_('CC RESTRICTED ACCESS'));
             $mainframe->enqueueMessage(JText::_('CC RESTRICTED ACCESS', 'notice'));
             switch ($video->permissions) {
                 case '40':
                     echo JText::_('CC VIDEO OWNNER ONLY', 'notice');
                     break;
                 case '30':
                     $owner = CFactory::getUser($video->creator);
                     echo JText::sprintf('CC VIDEO NEED FRIEND PERMISSION', $owner->getDisplayName());
                     break;
                 default:
                     echo '<p>' . JText::_('CC VIDEO NEED LOGIN', 'notice') . '</p>';
                     break;
             }
             return;
         }
         // Set pathway
         $pathway =& $mainframe->getPathway();
         $pathway->addItem('Video', CRoute::_('index.php?option=com_community&view=videos'));
         $pathway->addItem($video->getTitle(), '');
     }
     // Set the current user's active profile
     CFactory::setActiveProfile($video->creator);
     // Hit counter + 1
     $video->hit();
     // Get reporting html
     $reportHTML = '';
     CFactory::load('libraries', 'reporting');
     $report = new CReportingLibrary();
     $reportHTML = $report->getReportingHTML(JText::_('CC REPORT VIDEOS'), 'videos,reportVideo', array($video->id));
     // Get bookmark html
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks($video->getPermalink());
     $bookmarksHTML = $bookmarks->getHTML();
     // Get the walls
     CFactory::load('libraries', 'wall');
     $wallContent = CWallLibrary::getWallContents('videos', $video->id, COwnerHelper::isCommunityAdmin() || $my->id == $video->creator && $my->id != 0, 10, 0);
     $wallCount = CWallLibrary::getWallCount('videos', $video->id);
     $viewAllLink = false;
     if (JRequest::getVar('task', '', 'REQUEST') != 'app') {
         $viewAllLink = CRoute::_('index.php?option=com_community&view=videos&task=app&videoid=' . $video->id . '&app=walls');
     }
     $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     $wallForm = '';
     $wallForm = CWallLibrary::getWallInputForm($video->id, 'videos,ajaxSaveWall', 'videos,ajaxRemoveWall', $viewAllLink);
     $redirectUrl = CRoute::getURI(false);
     // Get like
     CFactory::load('libraries', 'like');
     $likes = new CLike();
     $likesHTML = $likes->getHTML('videos', $video->id, $my->id);
     $tmpl = new CTemplate();
     $tmpl->setMetaTags('video', $video);
     if ($video->creator_type == VIDEO_GROUP_TYPE) {
         $group =& JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         $document =& JFactory::getDocument();
         $document->addHeadLink($group->getThumbAvatar(), 'image_src', 'rel');
     }
     $tmpl->set('likesHTML', $likesHTML);
     $tmpl->set('redirectUrl', $redirectUrl);
     $tmpl->set('wallForm', $wallForm);
     $tmpl->set('wallContent', $wallContent);
     $tmpl->set('bookmarksHTML', $bookmarksHTML);
     $tmpl->set('reportHTML', $reportHTML);
     $tmpl->set('video', $video);
     echo $tmpl->fetch('videos.video');
 }
Ejemplo n.º 7
0
 /**
  * Show the main profile header
  */
 private function _showHeader(&$data)
 {
     jimport('joomla.utilities.arrayhelper');
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $my = CFactory::getUser();
     $userid = $jinput->get('userid', $my->id, 'INT');
     //JRequest::getVar('userid', $my->id);
     $user = CFactory::getUser($userid);
     $params = $user->getParams();
     $userModel = CFactory::getModel('user');
     //CFactory::load ( 'libraries', 'messaging' );
     $isMine = COwnerHelper::isMine($my->id, $user->id);
     // Get the admin controls HTML data
     $adminControlHTML = '';
     $tmpl = new CTemplate();
     // get how many unread message
     $filter = array();
     $inboxModel = CFactory::getModel('inbox');
     $filter['user_id'] = $my->id;
     $unread = $inboxModel->countUnRead($filter);
     // get how many pending connection
     $friendModel = CFactory::getModel('friends');
     $pending = $friendModel->countPending($my->id);
     $profile = JArrayHelper::toObject($data->profile);
     $profile->largeAvatar = $user->getAvatar();
     $profile->status = $user->getStatus();
     if ($profile->status !== '') {
         $postedOn = new JDate($user->_posted_on);
         $postedOn = CActivityStream::_createdLapse($postedOn);
         $profile->posted_on = $user->_posted_on == '0000-00-00 00:00:00' ? '' : $postedOn;
     } else {
         $profile->posted_on = '';
     }
     // Assign videoId
     $profile->profilevideo = $data->videoid;
     $video = JTable::getInstance('Video', 'CTable');
     $video->load($profile->profilevideo);
     $profile->profilevideoTitle = $video->getTitle();
     $addbuddy = "joms.api.friendAdd('{$profile->id}')";
     $sendMsg = CMessaging::getPopup($profile->id);
     $config = CFactory::getConfig();
     $lastLogin = JText::_('COM_COMMUNITY_PROFILE_NEVER_LOGGED_IN');
     if ($user->lastvisitDate != '0000-00-00 00:00:00') {
         //$now = JFactory::getDate();
         $userLastLogin = new JDate($user->lastvisitDate);
         //CFactory::load( 'libraries' , 'activities');
         $lastLogin = CActivityStream::_createdLapse($userLastLogin);
     }
     // @todo : beside checking the owner, maybe we want to check for a cookie,
     // say every few hours only the hit get increment by 1.
     if (!$isMine) {
         $user->viewHit();
     }
     // @rule: myblog integrations
     $showBlogLink = false;
     //CFactory::load( 'libraries' , 'myblog' );
     $myblog = CMyBlog::getInstance();
     if ($config->get('enablemyblogicon') && $myblog) {
         if ($myblog->userCanPost($user->id)) {
             $showBlogLink = true;
         }
         $tmpl->set('blogItemId', $myblog->getItemId());
     }
     $multiprofile = JTable::getInstance('MultiProfile', 'CTable');
     $multiprofile->load($user->getProfileType());
     // Get like
     $likesHTML = '';
     if ($user->getParams()->get('profileLikes', true)) {
         //CFactory::load( 'libraries' , 'like' );
         $likes = new CLike();
         $likesHTML = $my->id == 0 ? $likes->getHtmlPublic('profile', $user->id) : $likes->getHTML('profile', $user->id, $my->id);
     }
     $status = new CUserStatus($user->id, 'profile');
     //respect wall setting
     if ($my->id && (!$config->get('lockprofilewalls') || $config->get('lockprofilewalls') && CFriendsHelper::isConnected($my->id, $profile->id)) || COwnerHelper::isCommunityAdmin()) {
         // Add default status box
         CUserHelper::addDefaultStatusCreator($status);
     }
     $isblocked = $user->isBlocked();
     return $tmpl->set('karmaImgUrl', CUserPoints::getPointsImage($user))->set('isMine', $isMine)->set('lastLogin', $lastLogin)->set('user', $user)->set('addBuddy', $addbuddy)->set('sendMsg', $sendMsg)->set('config', $config)->set('multiprofile', $multiprofile)->set('showBlogLink', $showBlogLink)->set('isFriend', CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id)->set('isWaitingApproval', CFriendsHelper::isWaitingApproval($my->id, $user->id))->set('isBlocked', $isblocked)->set('profile', $profile)->set('unread', $unread)->set('pending', $pending)->set('registerDate', $user->registerDate)->set('adminControlHTML', $adminControlHTML)->set('likesHTML', $likesHTML)->set('userstatus', $status)->fetch('profile.header');
 }
Ejemplo n.º 8
0
 /**
  * Responsible for displaying the event page.
  **/
 function viewevent()
 {
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     CFactory::load('libraries', 'tooltip');
     CFactory::load('libraries', 'wall');
     CFactory::load('libraries', 'window');
     CWindow::load();
     $eventid = JRequest::getInt('eventid', 0);
     $eventModel =& CFactory::getModel('events');
     $event =& JTable::getInstance('Event', 'CTable');
     CFactory::load('helpers', 'event');
     $handler = CEventHelper::getHandler($event);
     $event->load($eventid);
     if (!$handler->exists()) {
         $mainframe->enqueueMessage(JText::_('CC EVENTS NOT AVAILABLE'), 'error');
         return;
     }
     if (!$handler->browsable()) {
         echo JText::_('CC NOT ALLOWED TO ACCESS SECTION');
         return;
     }
     // @rule: Test if the group is unpublished, don't display it at all.
     if (!$event->published) {
         echo JText::_('CC EVENTS UNDER MODERATION');
         return;
     }
     $this->showSubmenu();
     $event->hit();
     // Basic page presentation
     if ($event->type == 'group') {
         $groupId = $event->contentid;
         $group =& JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         // Set pathway for group videos
         // Community > Groups > Group Name > Events
         $this->addPathway(JText::_('CC GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
         $this->addPathway($group->name, CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId));
     }
     $this->addPathway(JText::_('CC EVENTS'), CRoute::_('index.php?option=com_community&view=events'));
     $this->addPathway(JText::sprintf('CC VIEW EVENTS TITLE', $event->title), '');
     // Permissions and privacies
     CFactory::load('helpers', 'owner');
     $isEventGuest = $event->isMember($my->id);
     $isMine = $my->id == $event->creator;
     $isAdmin = $event->isAdmin($my->id);
     $isCommunityAdmin = COwnerHelper::isCommunityAdmin();
     // Get Event Admins
     $eventAdmins = $event->getAdmins(12, CC_RANDOMIZE);
     $eventAdminsCount = $event->getAdminsCount();
     // Attach avatar of the admin
     for ($i = 0; $i < count($eventAdmins); $i++) {
         $row =& $eventAdmins[$i];
         $eventAdmins[$i] = CFactory::getUser($row->id);
     }
     // Get Attending Event Guests
     $eventMembers = $event->getMembers(COMMUNITY_EVENT_STATUS_ATTEND, 12, CC_RANDOMIZE);
     $eventMembersCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_ATTEND);
     // Get pending event guests
     $pendingMembers = $event->getMembers(COMMUNITY_EVENT_STATUS_INVITED, 12, CC_RANDOMIZE);
     $pendingMembersCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_INVITED);
     // Get blocked Event Guests
     $blockedMembers = $event->getMembers(COMMUNITY_EVENT_STATUS_BLOCKED, 12, CC_RANDOMIZE);
     $blockedMembersCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_BLOCKED);
     // Attach avatar of the admin
     // Pre-load multiple users at once
     $userids = array();
     foreach ($eventMembers as $uid) {
         $userids[] = $uid->id;
     }
     CFactory::loadUsers($userids);
     for ($i = 0; $i < count($eventMembers); $i++) {
         $row =& $eventMembers[$i];
         $eventMembers[$i] = CFactory::getUser($row->id);
     }
     // Pre-load multiple users at once
     $userids = array();
     foreach ($pendingMembers as $uid) {
         $userids[] = $uid->id;
     }
     CFactory::loadUsers($userids);
     for ($i = 0; $i < count($pendingMembers); $i++) {
         $row =& $pendingMembers[$i];
         $pendingMembers[$i] = CFactory::getUser($row->id);
     }
     // Pre-load multiple users at once
     $userids = array();
     foreach ($blockedMembers as $uid) {
         $userids[] = $uid->id;
     }
     CFactory::loadUsers($userids);
     for ($i = 0; $i < count($blockedMembers); $i++) {
         $row =& $blockedMembers[$i];
         $blockedMembers[$i] = CFactory::getUser($row->id);
     }
     $waitingApproval = $event->isPendingApproval($my->id);
     $waitingRespond = false;
     $myStatus = $event->getUserStatus($my->id);
     $hasResponded = $myStatus == COMMUNITY_EVENT_STATUS_ATTEND || $myStatus == COMMUNITY_EVENT_STATUS_WONTATTEND || $myStatus == COMMUNITY_EVENT_STATUS_MAYBE;
     // Get Bookmark HTML
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id));
     $bookmarksHTML = $bookmarks->getHTML();
     // Get Reporting HTML
     CFactory::load('libraries', 'reporting');
     $report = new CReportingLibrary();
     $reportHTML = $report->getReportingHTML(JText::_('CC REPORT EVENT'), 'events,reportEvent', array($event->id));
     // Get the Wall
     CFactory::load('libraries', 'wall');
     $wallContent = CWallLibrary::getWallContents('events', $event->id, $isAdmin, 10, 0, 'wall.content', 'events,events');
     $wallCount = CWallLibrary::getWallCount('events', $event->id);
     $viewAllLink = false;
     if (JRequest::getVar('task', '', 'REQUEST') != 'app') {
         $viewAllLink = CRoute::_('index.php?option=com_community&view=events&task=app&eventid=' . $event->id . '&app=walls');
     }
     $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     $wallForm = '';
     if (!$config->get('lockeventwalls') || $config->get('lockeventwalls') && $isEventGuest && !$waitingApproval && $hasResponded || $isCommunityAdmin) {
         $wallForm = CWallLibrary::getWallInputForm($event->id, 'events,ajaxSaveWall', 'events,ajaxRemoveWall');
     }
     // Construct the RVSP radio list
     $arr = array(JHTML::_('select.option', COMMUNITY_EVENT_STATUS_ATTEND, JText::_('CC EVENT ACTION ATTEND')), JHTML::_('select.option', COMMUNITY_EVENT_STATUS_WONTATTEND, JText::_('CC EVENT ACTION DECLINE')), JHTML::_('select.option', COMMUNITY_EVENT_STATUS_MAYBE, JText::_('CC EVENT ACTION UNSURE')));
     $status = $event->getMemberStatus($my->id);
     $radioList = JHTML::_('select.radiolist', $arr, 'status', '', 'value', 'text', $status, false);
     $unapprovedCount = $event->inviteRequestCount();
     //...
     $editEvent = JRequest::getVar('edit', false, 'GET');
     $editEvent = $editEvent == 1 ? true : false;
     // Am I invited in this event?
     $isInvited = false;
     $join = '';
     $friendsCount = 0;
     $isInvited = $eventModel->isInvitedMe(0, $my->id, $event->id);
     // If I was invited, I want to know my invitation informations
     if ($isInvited) {
         $invitor = CFactory::getUser($isInvited[0]->invited_by);
         $join = '<a href="' . CUrlHelper::userLink($invitor->id) . '">' . $invitor->getDisplayName() . '</a>';
         // Get users friends in this group
         $friendsCount = $eventModel->getFriendsCount($my->id, $event->id);
     }
     $friendsModel = CFactory::getModel('Friends');
     $tmpFriends = $friendsModel->getFriends($my->id, 'name', false);
     $friends = array();
     for ($i = 0; $i < count($tmpFriends); $i++) {
         $friend =& $tmpFriends[$i];
         if (!$event->isMember($friend->id)) {
             $friends[] = $friend;
         }
     }
     unset($tmpFriends);
     // Get like
     CFactory::load('libraries', 'like');
     $likes = new CLike();
     $likesHTML = $likes->getHTML('events', $event->id, $my->id);
     // Is this event is a past event?
     $now = new JDate();
     $isPastEvent = $event->getEndDate(false)->toMySQL() < $now->toMySQL(true) ? true : false;
     // Output to template
     $tmpl = new CTemplate();
     CFactory::load('libraries', 'invitation');
     $inviteHTML = CInvitation::getHTML($friends, 'events,inviteUsers', $event->id, CInvitation::SHOW_FRIENDS, CInvitation::HIDE_EMAIL);
     $tmpl->setMetaTags('event', $event);
     $tmpl->set('timezone', CTimeHelper::getTimezone($event->offset));
     $tmpl->set('handler', $handler);
     $tmpl->set('likesHTML', $likesHTML);
     $tmpl->set('inviteHTML', $inviteHTML);
     $tmpl->set('guestStatus', $event->getUserStatus($my->id));
     $tmpl->set('event', $event);
     $tmpl->set('radioList', $radioList);
     $tmpl->set('bookmarksHTML', $bookmarksHTML);
     $tmpl->set('reportHTML', $reportHTML);
     $tmpl->set('isEventGuest', $isEventGuest);
     $tmpl->set('isMine', $isMine);
     $tmpl->set('isAdmin', $isAdmin);
     $tmpl->set('isCommunityAdmin', $isCommunityAdmin);
     $tmpl->set('unapproved', $unapprovedCount);
     $tmpl->set('waitingApproval', $waitingApproval);
     $tmpl->set('wallForm', $wallForm);
     $tmpl->set('wallContent', $wallContent);
     $tmpl->set('eventAdmins', $eventAdmins);
     $tmpl->set('eventAdminsCount', $eventAdminsCount);
     $tmpl->set('eventMembers', $eventMembers);
     $tmpl->set('eventMembersCount', $eventMembersCount);
     $tmpl->set('blockedMembers', $blockedMembers);
     $tmpl->set('blockedMembersCount', $blockedMembersCount);
     $tmpl->set('pendingMembers', $pendingMembers);
     $tmpl->set('pendingMembersCount', $pendingMembersCount);
     $tmpl->set('editEvent', $editEvent);
     $tmpl->set('my', $my);
     $tmpl->set('memberStatus', $myStatus);
     $tmpl->set('waitingRespond', $waitingRespond);
     $tmpl->set('isInvited', $isInvited);
     $tmpl->set('join', $join);
     $tmpl->set('friendsCount', $friendsCount);
     $tmpl->set('isPastEvent', $isPastEvent);
     echo $tmpl->fetch('events.viewevent');
 }
Ejemplo n.º 9
0
 /**
  * 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');
 }
Ejemplo n.º 10
0
 /**
  * Ajax retreive Featured Events Information
  * @since 2.4
  */
 public function ajaxShowEventFeatured($eventId, $allday)
 {
     $my = CFactory::getUser();
     $objResponse = new JAXResponse();
     //CFactory::load( 'models' , 'events' );
     $event = JTable::getInstance('Event', 'CTable');
     $event->load($eventId);
     // Get event link
     // Get Avatar
     $avatar = $event->getAvatar('avatar');
     /// Event date
     $config = CFactory::getConfig();
     $format = $config->get('eventshowampm') ? JText::_('COM_COMMUNITY_EVENTS_TIME_FORMAT_12HR') : JText::_('COM_COMMUNITY_EVENTS_TIME_FORMAT_24HR');
     $startDate = $event->getStartDate(false);
     $endDate = $event->getEndDate(false);
     $allday = false;
     if ($startDate->format('%Y-%m-%d') == $endDate->format('%Y-%m-%d') && $startDate->format('%H:%M:%S') == '00:00:00' && $endDate->format('%H:%M:%S') == '23:59:59') {
         $format = JText::_('COM_COMMUNITY_EVENT_TIME_FORMAT_LC1');
         $allday = true;
     }
     if ($allday) {
         $eventDate = JText::sprintf('COM_COMMUNITY_EVENTS_ALLDAY_DATE', CTimeHelper::getFormattedTime($event->startdate, $format));
     } else {
         $eventDate = JText::sprintf('COM_COMMUNITY_EVENTS_DURATION', CTimeHelper::getFormattedTime($event->startdate, $format), CTimeHelper::getFormattedTime($event->enddate, $format));
     }
     // Get event link
     $eventLink = CRoute::_('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id);
     //CFactory::load( 'helpers' , 'event' );
     $handler = CEventHelper::getHandler($event);
     $now = new JDate();
     $isPastEvent = $event->getEndDate(false)->toSql() < $now->toSql() ? true : false;
     // Get RSVP
     $rsvp = '';
     if ($my->id != 0) {
         if ($handler->isAllowed() && !$isPastEvent) {
             $rsvp = '<div class="selector focus" id="jomSelect-undefined">';
             /* Fix missing select style */
             if ($event->getMemberStatus($my->id) == COMMUNITY_EVENT_STATUS_ATTEND) {
                 $rsvp .= '<span class="attend">' . JText::_('COM_COMMUNITY_EVENTS_RSVP_ATTEND') . '</span>';
             } elseif ($event->getMemberStatus($my->id) >= COMMUNITY_EVENT_STATUS_WONTATTEND) {
                 $rsvp .= '<span class="notAttend">' . JText::_('COM_COMMUNITY_EVENTS_RSVP_NOT_ATTEND') . '</span>';
             } else {
                 $rsvp .= '<span class="noResponse">' . JText::_('COM_COMMUNITY_GROUPS_INVITATION_RESPONSE') . '</span>';
             }
             $rsvp .= '<select onchange="joms.events.submitRSVP(' . $event->id . ',this)" style="opacity:0;">';
             if ($event->getMemberStatus($my->id) == 0) {
                 $rsvp .= '<option class="noResponse" selected="selected">' . JText::_('COM_COMMUNITY_GROUPS_INVITATION_RESPONSE') . '</option>';
             }
             $rsvp .= '<option class="attend"';
             if ($event->getMemberStatus($my->id) == COMMUNITY_EVENT_STATUS_ATTEND) {
                 $rsvp .= ' selected="selected" ';
             }
             $rsvp .= 'value="' . COMMUNITY_EVENT_STATUS_ATTEND . '">' . JText::_('COM_COMMUNITY_EVENTS_RSVP_ATTEND') . '</option>';
             $rsvp .= '<option class="notAttend"';
             if ($event->getMemberStatus($my->id) >= COMMUNITY_EVENT_STATUS_WONTATTEND) {
                 $rsvp .= 'selected="selected"';
             }
             $rsvp .= 'value="' . COMMUNITY_EVENT_STATUS_WONTATTEND . '">' . JText::_('COM_COMMUNITY_EVENTS_RSVP_NOT_ATTEND') . '</option>';
             $rsvp .= '</select>';
             $rsvp .= '</div>';
         } else {
             $rsvp = JText::_('COM_COMMUNITY_EVENTS_PASSED');
         }
     }
     // Get unfeature icon
     $eventUnfeature = '<a class="album-action remove-featured" title="' . JText::_('COM_COMMUNITY_REMOVE_FEATURED') . '" onclick="joms.featured.remove(\'' . $event->id . '\',\'events\');" href="javascript:void(0);">' . JText::_('COM_COMMUNITY_REMOVE_FEATURED') . '</a>';
     // Get like
     //CFactory::load( 'libraries' , 'like' );
     $likes = new CLike();
     $likesHTML = $likes->getHTML('events', $eventId, $my->id);
     $objResponse->addScriptCall('updateEvent', $eventId, $event->title, JText::_($event->getCategoryName()), $likesHTML, $avatar, $eventDate, $event->location, $event->summary, $eventLink, $rsvp, $eventUnfeature);
     $objResponse->sendResponse();
 }
Ejemplo n.º 11
0
 /**
  * Undislike an item
  * @param string $element   Can either be core object (photos/videos) or a plugins (plugins,plugin_name)
  * @param mixed $itemId	    Unique id to identify object item
  *
  */
 public function ajaxUndislike($element, $itemId)
 {
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     // @rule: Only display likes html codes when likes is allowed.
     $config =& CFactory::getConfig();
     if (!$config->get('likes_' . $element)) {
         return;
     }
     $my = CFactory::getUser();
     $objResponse = new JAXResponse();
     // Load libraries
     CFactory::load('libraries', 'like');
     $unlike = new CLike();
     $result = $unlike->unlike($element, $itemId);
     if (!$result) {
         $msg = JText::_('CC UNLIKE ERROR');
         $objResponse->addScriptCall('cWindowShow', '', JText::_('CC UNLIKE'), 430, 100);
         $objResponse->addAssign('cWindowContent', 'innerHTML', $msg);
     } else {
         $like = new CLike();
         $html = $like->getHTML($element, $itemId, $my->id);
         $objResponse->addScriptCall('__callback', $html);
     }
     return $objResponse->sendResponse();
 }
Ejemplo n.º 12
0
 /**
  * Ajax retreive Featured Group Information
  * @since 2.6
  */
 public function ajaxShowGroupFeatured($groupId)
 {
     $my = CFactory::getUser();
     $objResponse = new JAXResponse();
     $group = JTable::getInstance('Group', 'CTable');
     $group->load($groupId);
     $group->updateStats();
     //ensure that stats are up-to-date
     // Get Avatar
     $avatar = $group->getAvatar('avatar');
     // group date
     $config = CFactory::getConfig();
     $groupDate = JHTML::_('date', $group->created, JText::_('DATE_FORMAT_LC'));
     // Get group link
     $groupLink = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
     // Get unfeature icon
     $groupUnfeature = '<a class="album-action remove-featured" title="' . JText::_('COM_COMMUNITY_REMOVE_FEATURED') . '" onclick="joms.featured.remove(\'' . $group->id . '\',\'groups\');" href="javascript:void(0);">' . JText::_('COM_COMMUNITY_REMOVE_FEATURED') . '</a>';
     // Get misc data
     $membercount = JText::sprintf(CStringHelper::isPlural($group->membercount) ? 'COM_COMMUNITY_GROUPS_MEMBER_COUNT_MANY' : 'COM_COMMUNITY_GROUPS_MEMBER_COUNT', $group->membercount);
     $discussion = JText::sprintf(!CStringHelper::isPlural($group->discusscount) ? 'COM_COMMUNITY_GROUPS_DISCUSSION_COUNT_MANY' : 'COM_COMMUNITY_GROUPS_DISCUSSION_COUNT', $group->discusscount);
     $wallposts = JText::sprintf(CStringHelper::isPlural($group->wallcount) ? 'COM_COMMUNITY_GROUPS_WALL_COUNT_MANY' : 'COM_COMMUNITY_GROUPS_WALL_COUNT', $group->wallcount);
     $memberCountLink = CRoute::_('index.php?option=com_community&view=groups&task=viewmembers&groupid=' . $group->id);
     // Get like
     $likes = new CLike();
     $likesHTML = $likes->getHTML('groups', $groupId, $my->id);
     $objResponse->addScriptCall('updateGroup', $groupId, $group->name, $group->getCategoryName(), $likesHTML, $avatar, $groupDate, $groupLink, JHTML::_('string.truncate', strip_tags($group->description), 300), $membercount, $discussion, $wallposts, $memberCountLink, $groupUnfeature);
     $objResponse->sendResponse();
 }
Ejemplo n.º 13
0
 /**
  * Method to display video
  *
  **/
 public function video()
 {
     $mainframe =& JFactory::getApplication();
     $document = JFactory::getDocument();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     $videoId = JRequest::getVar('videoid', '', 'GET');
     $groupId = JRequest::getVar('groupid', '', 'GET');
     // Get show video location map by default
     $videoMapsDefault = $config->get('videosmapdefault');
     // Load window library
     CFactory::load('libraries', 'window');
     // Load necessary window css / javascript headers.
     CWindow::load();
     // Load the video table
     // Load string helper
     CFactory::load('helpers', 'string');
     $video =& JTable::getInstance('Video', 'CTable');
     if (empty($videoId)) {
         $url = CRoute::_('index.php?option=com_community&view=videos', false);
         $mainframe->redirect($url, JText::_('COM_COMMUNITY_VIDEOS_ID_ERROR'), 'warning');
     }
     if (!$video->load($videoId)) {
         $url = CRoute::_('index.php?option=com_community&view=videos', false);
         $mainframe->redirect($url, JText::_('COM_COMMUNITY_VIDEOS_NOT_AVAILABLE'), 'warning');
     }
     // Setting up the sub menu
     CFactory::load('helpers', 'owner');
     if (COwnerHelper::isCommunityAdmin() || $my->id == $video->creator && $my->id != 0) {
         $this->addSubmenuItem('', JText::_('COM_COMMUNITY_VIDEOS_FETCH_THUMBNAIL'), 'joms.videos.fetchThumbnail(\'' . $video->id . '\')', true);
         // Only add the set as profile video for video owner
         if ($my->id == $video->creator) {
             $this->addSubmenuItem('', JText::_('COM_COMMUNITY_VIDEOS_SET_AS_PROFILE'), 'joms.videos.linkConfirmProfileVideo(\'' . $video->id . '\')', true);
         }
         $redirectUrl = CRoute::getURI(false);
         $this->addSubmenuItem('', JText::_('COM_COMMUNITY_EDIT'), 'joms.videos.showEditWindow(\'' . $video->id . '\',\'' . $redirectUrl . '\');', true);
         $this->addSubmenuItem('', JText::_('COM_COMMUNITY_DELETE'), 'joms.videos.deleteVideo(\'' . $video->id . '\')', true);
     }
     $this->_addSubmenu();
     $this->showSubmenu();
     // Show the mini header when viewing other's photos
     if ($video->creator_type == VIDEO_USER_TYPE && $my->id != $video->creator) {
         $this->attachMiniHeaderUser($video->creator);
     }
     // Check permission
     $user = CFactory::getUser($video->creator);
     $blocked = $user->isBlocked();
     if ($blocked && !COwnerHelper::isCommunityAdmin()) {
         $tmpl = new CTemplate();
         echo $tmpl->fetch('profile.blocked');
         return;
     }
     $sorted = JRequest::getVar('sort', 'latest');
     $limit = JRequest::getVar('limitstart', 6);
     $permissions = $my->id == 0 ? 0 : 20;
     $cat_id = JRequest::getVar('cat_id', '');
     $model = CFactory::getModel('videos');
     if ($video->creator_type == VIDEO_GROUP_TYPE) {
         CFactory::load('helpers', 'group');
         if (!CGroupHelper::allowViewMedia($groupId)) {
             $document->setTitle(JText::_('COM_COMMUNITY_RESTRICTED_ACCESS'));
             $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_RESTRICTED_ACCESS', 'notice'));
             echo JText::_('COM_COMMUNITY_GROUPS_VIDEO_MEMBER_PERMISSION');
             return;
         }
         $group =& JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         // Set pathway
         $pathway =& $mainframe->getPathway();
         $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_VIDEOS'), CRoute::_('index.php?option=com_community&view=videos&groupid=' . $groupId));
         $pathway->addItem($video->getTitle(), '');
         $otherVideos = $model->getGroupVideos($groupId, $cat_id, $limit);
     } else {
         if (!$this->isPermitted($my->id, $video->creator, $video->permissions)) {
             $document->setTitle(JText::_('COM_COMMUNITY_RESTRICTED_ACCESS'));
             $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_RESTRICTED_ACCESS', 'notice'));
             switch ($video->permissions) {
                 case '40':
                     $this->noAccess(JText::_('COM_COMMUNITY_VIDEOS_OWNER_ONLY', 'notice'));
                     break;
                 case '30':
                     $owner = CFactory::getUser($video->creator);
                     $this->noAccess(JText::sprintf('COM_COMMUNITY_VIDEOS_FRIEND_PERMISSION_MESSAGE', $owner->getDisplayName()));
                     break;
                 default:
                     $this->noAccess();
                     break;
             }
             return;
         }
         // Set pathway
         $pathway =& $mainframe->getPathway();
         $pathway->addItem('Video', CRoute::_('index.php?option=com_community&view=videos'));
         $pathway->addItem($video->getTitle(), '');
         $filters = array('status' => 'ready', 'category_id' => $cat_id, 'creator' => $user->id, 'permissions' => $permissions, 'or_group_privacy' => 0, 'sorting' => $sorted, 'limit' => $limit);
         $otherVideos = $model->getVideos($filters);
     }
     //var_dump($otherVideos);
     // Set the current user's active profile
     CFactory::setActiveProfile($video->creator);
     // Hit counter + 1
     $video->hit();
     // Get reporting html
     $reportHTML = '';
     CFactory::load('libraries', 'reporting');
     $report = new CReportingLibrary();
     $reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_VIDEOS_REPORT_VIDEOS'), 'videos,reportVideo', array($video->id));
     // Get bookmark html
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks($video->getPermalink());
     $bookmarksHTML = $bookmarks->getHTML();
     // Get the walls
     CFactory::load('libraries', 'wall');
     $wallContent = CWallLibrary::getWallContents('videos', $video->id, COwnerHelper::isCommunityAdmin() || $my->id == $video->creator && $my->id != 0, 10, 0);
     $wallCount = CWallLibrary::getWallCount('videos', $video->id);
     $viewAllLink = false;
     if (JRequest::getVar('task', '', 'REQUEST') != 'app') {
         $viewAllLink = CRoute::_('index.php?option=com_community&view=videos&task=app&videoid=' . $video->id . '&app=walls');
     }
     $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     $wallForm = '';
     if ($this->isPermitted($my->id, $video->creator, PRIVACY_FRIENDS) || !$config->get('lockvideoswalls')) {
         $wallForm = CWallLibrary::getWallInputForm($video->id, 'videos,ajaxSaveWall', 'videos,ajaxRemoveWall', $viewAllLink);
     }
     $redirectUrl = CRoute::getURI(false);
     // Get like
     CFactory::load('libraries', 'like');
     $likes = new CLike();
     $likesHTML = $likes->getHTML('videos', $video->id, $my->id);
     $tmpl = new CTemplate();
     if ($video->creator_type == VIDEO_GROUP_TYPE) {
         $group =& JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         $document = JFactory::getDocument();
         $document->addHeadLink($group->getThumbAvatar(), 'image_src', 'rel');
     }
     if ($video->location !== '' && $videoMapsDefault == 1) {
         CFactory::load('libraries', 'mapping');
         $zoomableMap = CMapping::drawZoomableMap($video->location, 220, 150);
     } else {
         $zoomableMap = "";
     }
     echo $tmpl->setMetaTags('video', $video)->set('user', $user)->set('zoomableMap', $zoomableMap)->set('likesHTML', $likesHTML)->set('redirectUrl', $redirectUrl)->set('wallForm', $wallForm)->set('wallContent', $wallContent)->set('bookmarksHTML', $bookmarksHTML)->set('reportHTML', $reportHTML)->set('video', $video)->set('otherVideos', $otherVideos)->fetch('videos.video');
 }
Ejemplo n.º 14
0
 /**
  * Unlike an item
  * @param string $element   Can either be core object (photos/videos) or a plugins (plugins,plugin_name)
  * @param mixed $itemId     Unique id to identify object item
  *
  */
 public function ajaxUnlike($element, $itemId)
 {
     $filter = JFilterInput::getInstance();
     $itemId = $filter->clean($itemId, 'int');
     $element = $filter->clean($element, 'string');
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $my = CFactory::getUser();
     $objResponse = new JAXResponse();
     // Load libraries
     $unlike = new CLike();
     if (!$unlike->enabled($element)) {
     } else {
         $unlike->unlike($element, $itemId);
         $likeCount = $unlike->getLikeCount($element, $itemId);
         $html = $unlike->getHTML($element, $itemId, $my->id);
         $objResponse->addScriptCall('__callback', $html);
     }
     $act = new stdClass();
     $act->cmd = $element . '.like';
     $act->actor = $my->id;
     $act->target = 0;
     $act->title = '';
     $act->content = '';
     $act->app = $element . '.like';
     $act->cid = $itemId;
     $params = new CParameter('');
     switch ($element) {
         case 'groups':
             $act->groupid = $itemId;
             break;
         case 'events':
             $act->eventid = $itemId;
             break;
     }
     $params->set('action', $element . '.like');
     // Remove logging
     CActivityStream::removeActor($act, $params->toString());
     $json = array('success' => true, 'likeCount' => $likeCount);
     die(json_encode($json));
 }
Ejemplo n.º 15
0
    public function ajaxShowVideoFeatured($video_id)
    {
        $objResponse = new JAXResponse();
        $allowToView = true;
        //determine the view premission
        $my = CFactory::getUser();
        $video = JTable::getInstance('Video', 'CTable');
        if (!$video->load($video_id)) {
            $allowToView = false;
        }
        /* === Start Premission Checking === */
        $user = CFactory::getUser($video->creator);
        $blocked = $user->isBlocked();
        if ($blocked && !COwnerHelper::isCommunityAdmin()) {
            $allowToView = false;
        }
        if ($video->creator_type == VIDEO_GROUP_TYPE) {
            //CFactory::load( 'helpers' , 'group' );
            if (!CGroupHelper::allowViewMedia($video->groupid)) {
                $allowToView = false;
            }
        } else {
            if (!CPrivacy::isAccessAllowed($my->id, $video->creator, 'custom', $video->permissions)) {
                switch ($video->permissions) {
                    case '40':
                        $allowToView = false;
                        break;
                    case '30':
                        $allowToView = false;
                        $this->noAccess(JText::sprintf('COM_COMMUNITY_VIDEOS_FRIEND_PERMISSION_MESSAGE', $owner->getDisplayName()));
                        break;
                    default:
                        $allowToView = false;
                        break;
                }
            }
        }
        /* === End Permission Checking === */
        if ($allowToView) {
            // Hit counter + 1
            $video->hit();
            $notiHtml = '<div class="cVideo-Player video-player">
							' . $video->getPlayerHTML() . '
						</div>';
        } else {
            $notiHtml = JText::_('COM_COMMUNITY_VIDEO_UNABLE_VIEW');
        }
        // Get like
        //CFactory::load( 'libraries' , 'like' );
        $likes = new CLike();
        $likesHTML = $likes->getHTML('videos', $video->id, $my->id);
        // Get wall count
        //CFactory::load( 'libraries' , 'wall' );
        $wallCount = CWallLibrary::getWallCount('videos', $video->id);
        // Get video link
        $videoCommentLink = CRoute::_('index.php?option=com_community&view=videos&task=video&videoid=' . $video->id . '&groupid=' . $video->groupid . '&userid=' . $video->creator . '#comments');
        $videoLink = CRoute::_('index.php?option=com_community&view=videos&task=video&videoid=' . $video->id . '&groupid=' . $video->groupid . '&userid=' . $video->creator);
        $creatorName = $video->getCreatorName();
        $creatorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $video->creator);
        $objResponse->addScriptCall('updatePlayer', $notiHtml, $video->title, $likesHTML, $video->getHits(), $wallCount, $videoLink, $videoCommentLink, $creatorName, $creatorLink);
        $objResponse->sendResponse();
    }
Ejemplo n.º 16
0
 /**
  * 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);
 }
Ejemplo n.º 17
0
 /**
  * Trigger any necessary items that needs to be changed when the photo
  * is changed.
  **/
 public function ajaxSwitchPhotoTrigger($photoId)
 {
     $filter = JFilterInput::getInstance();
     $photoId = $filter->clean($photoId, 'int');
     $response = new JAXResponse();
     // Load the default photo
     CFactory::load('models', 'photos');
     $photo =& JTable::getInstance('Photo', 'CTable');
     $photo->load($photoId);
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $album =& JTable::getInstance('Album', 'CTable');
     $album->load($photo->albumid);
     // Since the only way for us to get the id is through the AJAX call,
     // we can only increment the hit when the ajax loads
     $photo->hit();
     // Update the hits each time the photo is switched
     $response->addAssign('photo-hits', 'innerHTML', $photo->hits);
     // Show creator
     $creator = CFactory::getUser($photo->creator);
     $creatorHTML = JText::sprintf('COM_COMMUNITY_UPLOADED_BY', CRoute::_('index.php?option=com_community&view=profile&userid=' . $creator->id), $creator->getDisplayName());
     $response->addAssign('uploadedBy', 'innerHTML', $creatorHTML);
     // Get the wall form
     $wallInput = $this->_getWallFormHTML($photoId);
     $response->addAssign('community-photo-walls', 'innerHTML', $wallInput);
     // Get the wall contents
     $wallContents = '';
     $wallContents = $this->showWallContents($photoId);
     $response->addAssign('wallContent', 'innerHTML', $wallContents);
     $response->addScriptCall("joms.utils.textAreaWidth('#wall-message');");
     //$photo		=& JTable::getInstance( 'Photo' , 'CTable' );
     //$photo->load( $photoId );
     // When a photo is navigated, the sharing should also be updated.
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks($photo->getPhotoLink(true));
     // Get the reporting data
     CFactory::load('libraries', 'reporting');
     $report = new CReportingLibrary();
     // Add tagging code
     /*
     		$tagsHTML = '';
     		if($config->get('tags_photos')){
     			CFactory::load('libraries', 'tags');
     			$tags = new CTags();
     			// @todo: permission checking might be wrong here
     			$tagsHTML = $tags->getHTML('photos', $photoId, $photo->creator == $my->id || COwnerHelper::isCommunityAdmin());
     		}*/
     $reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_REPORT_BAD_PHOTO'), 'photos,reportPhoto', array($photoId));
     // $response->addAssign('tag-photo', 'innerHTML', $tagsHTML);
     $response->addScriptCall('joms.gallery.updatePhotoReport', $reportHTML);
     $response->addScriptCall('joms.gallery.updatePhotoBookmarks', $bookmarks->getHTML());
     $response->addScriptCall('joms.jQuery("body").focus();');
     $response->addScriptCall('joms.gallery.bindFocus();');
     // Get the likes / dislikes item
     CFactory::load('libraries', 'like');
     $like = new CLike();
     $likeHTML = $like->getHTML('photo', $photoId, $my->id);
     $response->addScriptCall('__callback', $likeHTML);
     return $response->sendResponse();
 }
Ejemplo n.º 18
0
 /**
  * Response display featured album
  * @Since 3.2
  * @todo Consider to merge with above method ajaxShowPhotoFeatured
  * @param int $albumId
  */
 public function ajaxShowAlbumFeatured($albumId)
 {
     $my = CFactory::getUser();
     $objResponse = new JAXResponse();
     /* Load table */
     $album = JTable::getInstance('Album', 'CTable');
     $album->load($albumId);
     $wallCount = CWallLibrary::getWallCount('albums', $album->id);
     /* Get Album link */
     $albumCommentLink = CRoute::_('index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&groupid=' . $album->groupid . '&userid=' . $album->creator . '#comments');
     $commentCountText = JText::_('COM_COMMUNITY_COMMENT');
     if ($wallCount > 1) {
         $commentCountText = JText::_('COM_COMMUNITY_COMMENTS');
     }
     /* Generate like */
     $likes = new CLike();
     $likesHTML = $likes->getHTML('album', $albumId, $my->id);
     /* Response */
     $objResponse->addScriptCall('updateGallery', $albumId, $likesHTML, $wallCount, $albumCommentLink, $commentCountText);
     $objResponse->sendResponse();
 }
Ejemplo n.º 19
0
 /**
  * Responsible for displaying the event page.
  **/
 public function viewevent()
 {
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     CFactory::load('libraries', 'tooltip');
     CFactory::load('libraries', 'wall');
     CFactory::load('libraries', 'window');
     CFactory::load('libraries', 'activities');
     CFactory::load('libraries', 'events');
     CWindow::load();
     $eventLib = new CEvents();
     $eventid = JRequest::getInt('eventid', 0);
     $eventModel =& CFactory::getModel('events');
     $event =& JTable::getInstance('Event', 'CTable');
     CFactory::load('helpers', 'event');
     $handler = CEventHelper::getHandler($event);
     $event->load($eventid);
     if (!$handler->exists()) {
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_EVENTS_NOT_AVAILABLE_ERROR'), 'error');
         return;
     }
     if (!$handler->browsable()) {
         echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
         return;
     }
     // @rule: Test if the group is unpublished, don't display it at all.
     if (!$event->published) {
         echo JText::_('COM_COMMUNITY_EVENTS_UNDER_MODERATION');
         return;
     }
     $this->showSubmenu();
     $event->hit();
     // Basic page presentation
     if ($event->type == 'group') {
         $groupId = $event->contentid;
         $group =& JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         // Set pathway for group videos
         // Community > Groups > Group Name > Events
         $this->addPathway(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
         $this->addPathway($group->name, CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId));
     }
     $this->addPathway(JText::_('COM_COMMUNITY_EVENTS'), CRoute::_('index.php?option=com_community&view=events'));
     $this->addPathway($event->title);
     // Permissions and privacies
     CFactory::load('helpers', 'owner');
     $isEventGuest = $event->isMember($my->id);
     $isMine = $my->id == $event->creator;
     $isAdmin = $event->isAdmin($my->id);
     $isCommunityAdmin = COwnerHelper::isCommunityAdmin();
     // Get Event Admins
     $eventAdmins = $event->getAdmins(12, CC_RANDOMIZE);
     $adminsInArray = array();
     // Attach avatar of the admin
     for ($i = 0; $i < count($eventAdmins); $i++) {
         $row =& $eventAdmins[$i];
         $admin = CFactory::getUser($row->id);
         array_push($adminsInArray, '<a href="' . CUrlHelper::userLink($admin->id) . '">' . $admin->getDisplayName() . '</a>');
     }
     $adminsList = ltrim(implode(', ', $adminsInArray), ',');
     // Get Attending Event Guests
     $eventMembers = $event->getMembers(COMMUNITY_EVENT_STATUS_ATTEND, 12, CC_RANDOMIZE);
     $eventMembersCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_ATTEND);
     // Attach avatar of the admin
     // Pre-load multiple users at once
     $userids = array();
     foreach ($eventMembers as $uid) {
         $userids[] = $uid->id;
     }
     CFactory::loadUsers($userids);
     for ($i = 0; $i < count($eventMembers); $i++) {
         $row =& $eventMembers[$i];
         $eventMembers[$i] = CFactory::getUser($row->id);
     }
     // Pre-load multiple users at once
     $waitingApproval = $event->isPendingApproval($my->id);
     $waitingRespond = false;
     $myStatus = $event->getUserStatus($my->id);
     $hasResponded = $myStatus == COMMUNITY_EVENT_STATUS_ATTEND || $myStatus == COMMUNITY_EVENT_STATUS_WONTATTEND || $myStatus == COMMUNITY_EVENT_STATUS_MAYBE;
     // Get Bookmark HTML
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id));
     $bookmarksHTML = $bookmarks->getHTML();
     // Get Reporting HTML
     CFactory::load('libraries', 'reporting');
     $report = new CReportingLibrary();
     $reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_EVENTS_REPORT'), 'events,reportEvent', array($event->id));
     // Get the Wall
     CFactory::load('libraries', 'wall');
     $wallContent = CWallLibrary::getWallContents('events', $event->id, $isAdmin, 10, 0, 'wall.content', 'events,events');
     $wallCount = CWallLibrary::getWallCount('events', $event->id);
     $viewAllLink = false;
     if (JRequest::getVar('task', '', 'REQUEST') != 'app') {
         $viewAllLink = CRoute::_('index.php?option=com_community&view=events&task=app&eventid=' . $event->id . '&app=walls');
     }
     $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     $wallForm = '';
     /*if( !$config->get('lockeventwalls')
     			|| ($config->get('lockeventwalls') && ($isEventGuest) && !($waitingApproval) && $hasResponded) 
     			|| $isCommunityAdmin )
     		{
     			$wallForm	= CWallLibrary::getWallInputForm( $event->id , 'events,ajaxSaveWall', 'events,ajaxRemoveWall' );
     		}*/
     // Construct the RVSP radio list
     $arr = array(JHTML::_('select.option', COMMUNITY_EVENT_STATUS_ATTEND, JText::_('COM_COMMUNITY_EVENTS_YES')), JHTML::_('select.option', COMMUNITY_EVENT_STATUS_WONTATTEND, JText::_('COM_COMMUNITY_EVENTS_NO')), JHTML::_('select.option', COMMUNITY_EVENT_STATUS_MAYBE, JText::_('COM_COMMUNITY_EVENTS_MAYBE')));
     $status = $event->getMemberStatus($my->id);
     $radioList = JHTML::_('select.radiolist', $arr, 'status', '', 'value', 'text', $status, false);
     $unapprovedCount = $event->inviteRequestCount();
     //...
     $editEvent = JRequest::getVar('edit', false, 'GET');
     $editEvent = $editEvent == 1 ? true : false;
     // Am I invited in this event?
     $isInvited = false;
     $join = '';
     $friendsCount = 0;
     $isInvited = $eventModel->isInvitedMe(0, $my->id, $event->id);
     // If I was invited, I want to know my invitation informations
     if ($isInvited) {
         $invitor = CFactory::getUser($isInvited[0]->invited_by);
         $join = '<a href="' . CUrlHelper::userLink($invitor->id) . '">' . $invitor->getDisplayName() . '</a>';
         // Get users friends in this group
         $friendsCount = $eventModel->getFriendsCount($my->id, $event->id);
     }
     // Get like
     CFactory::load('libraries', 'like');
     $likes = new CLike();
     $likesHTML = $likes->getHTML('events', $event->id, $my->id);
     // Is this event is a past event?
     $now = new JDate();
     $isPastEvent = $event->getEndDate(false)->toMySQL() < $now->toMySQL(true) ? true : false;
     // Get the formated date & time
     $format = $config->get('eventshowampm') ? JText::_('COM_COMMUNITY_EVENTS_TIME_FORMAT_12HR') : JText::_('COM_COMMUNITY_EVENTS_TIME_FORMAT_24HR');
     $startDate = $event->getStartDate(false);
     $endDate = $event->getEndDate(false);
     $allday = false;
     if ($startDate->toFormat('%Y-%m-%d') == $endDate->toFormat('%Y-%m-%d') && $startDate->toFormat('%H:%M:%S') == '00:00:00' && $endDate->toFormat('%H:%M:%S') == '23:59:59') {
         $format = JText::_('COM_COMMUNITY_EVENT_TIME_FORMAT_LC1');
         $allday = true;
     }
     $event->startdateHTML = CTimeHelper::getFormattedTime($event->startdate, $format);
     $event->enddateHTML = CTimeHelper::getFormattedTime($event->enddate, $format);
     CFactory::load('libraries', 'invitation');
     $inviteHTML = CInvitation::getHTML(null, 'events,inviteUsers', $event->id, CInvitation::SHOW_FRIENDS, CInvitation::SHOW_EMAIL);
     CFactory::load('libraries', 'userstatus');
     $status = new CUserStatus($event->id, 'events');
     $tmpl = new CTemplate();
     $creator = new CUserStatusCreator('message');
     $creator->title = $isMine ? JText::_('COM_COMMUNITY_STATUS') : JText::_('COM_COMMUNITY_MESSAGE');
     $creator->html = $tmpl->fetch('status.message');
     $status->addCreator($creator);
     // Upgrade wall to stream @since 2.5
     $event->upgradeWallToStream();
     // Add custom stream
     $streamHTML = $eventLib->getStreamHTML($event);
     if ($event->getMemberStatus($my->id) == COMMUNITY_EVENT_STATUS_ATTEND) {
         $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_ATTENDING_EVENT_MESSAGE');
     } else {
         if ($event->getMemberStatus($my->id) == COMMUNITY_EVENT_STATUS_WONTATTEND) {
             $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_NOT_ATTENDING_EVENT_MESSAGE');
         } else {
             $RSVPmessage = JText::_('COM_COMMUNITY_EVENTS_NOT_RESPOND_RSVP_MESSAGE');
         }
     }
     // Output to template
     echo $tmpl->setMetaTags('event', $event)->set('status', $status)->set('streamHTML', $streamHTML)->set('timezone', CTimeHelper::getTimezone($event->offset))->set('handler', $handler)->set('likesHTML', $likesHTML)->set('inviteHTML', $inviteHTML)->set('guestStatus', $event->getUserStatus($my->id))->set('event', $event)->set('radioList', $radioList)->set('bookmarksHTML', $bookmarksHTML)->set('reportHTML', $reportHTML)->set('isEventGuest', $isEventGuest)->set('isMine', $isMine)->set('isAdmin', $isAdmin)->set('isCommunityAdmin', $isCommunityAdmin)->set('unapproved', $unapprovedCount)->set('waitingApproval', $waitingApproval)->set('wallContent', $wallContent)->set('eventMembers', $eventMembers)->set('eventMembersCount', $eventMembersCount)->set('editEvent', $editEvent)->set('my', $my)->set('memberStatus', $myStatus)->set('waitingRespond', $waitingRespond)->set('isInvited', $isInvited)->set('join', $join)->set('friendsCount', $friendsCount)->set('isPastEvent', $isPastEvent)->set('adminsList', $adminsList)->set('RSVPmessage', $RSVPmessage)->set('allday', $allday)->fetch('events.viewevent');
 }