/** * Display the photo thumbnails from an album * */ public function album() { $document = JFactory::getDocument(); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $config = CFactory::getConfig(); $handler = $this->_getHandler(); $my = CFactory::getUser(); //CFactory::load( 'libraries' , 'activities' ); // Get show photo location map by default $photoMapsDefault = $config->get('photosmapdefault'); $albumId = $jinput->get('albumid', 0, 'INT'); $album = JTable::getInstance('Album', 'CTable'); $album->load($albumId); $defaultId = $jinput->get('photoid', 0, 'INT'); $userId = $jinput->get('userid', 0, 'INT'); $limitstart = $jinput->get->get('limitstart', '0', 'INT'); if (empty($limitstart)) { $limitstart = $jinput->get->get('start', '0', 'INT'); } $user = CFactory::getUser($album->creator); // Set pathway for group photos // Community > Groups > Group Name > Photos > Album Name $pathway = $mainframe->getPathway(); if ($album->type == 'group') { if (!$my->authorise('community.view', 'photos.group.album.' . $album->groupid, $album)) { echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION'); return; } } else { if (!$my->authorise('community.view', 'photos.user.album.' . $album->id)) { echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION'); return; } } $groupId = $album->groupid; if ($groupId > 0) { $group = JTable::getInstance('Group', 'CTable'); $group->load($groupId); $pathway->addItem(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups')); $pathway->addItem($group->name, CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId)); $pathway->addItem(JText::_('COM_COMMUNITY_PHOTOS'), CRoute::_('index.php?option=com_community&view=photos&groupid=' . $groupId)); } else { $pathway->addItem(JText::_('COM_COMMUNITY_PHOTOS'), CRoute::_('index.php?option=com_community&view=photos')); $pathway->addItem(JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $user->getDisplayName()), CRoute::_('index.php?option=com_community&view=photos&task=myphotos&userid=' . $userId)); } $handler->setMiniHeader(); if (empty($albumId)) { echo JText::_('COM_COMMUNITY_PHOTOS_NO_ALBUMID_ERROR'); return; } if (is_null($album->id)) { echo JText::_('COM_COMMUNITY_ALBUM_DELETED'); return; } if (!$handler->isAlbumBrowsable($albumId)) { return; } //$photos = $handler->getAlbumPhotos( $album->id ); $photoPaginationLimit = intval($config->get('pagination')); $photoThumbLimit = $photoPaginationLimit; $model = CFactory::getModel('photos'); $photos = $model->getPhotos($album->id, $photoThumbLimit, $limitstart); $pagination = $model->getPagination(); $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($album->photoid); if ($album->photoid == '0') { $album->thumbnail = $photo->getThumbURI(); } else { $album->thumbnail = $photo->getImageURI(); } // Increment album's hit each time this page is loaded. $album->hit(); if ($groupId > 0) { $otherAlbums = $model->getGroupAlbums($groupId); } else { $otherAlbums = $model->getAlbums($user->id); } $totalAlbums = count($otherAlbums); $showOtherAlbum = 6; $randomAlbum = array(); if (count($otherAlbums) > 0) { $randomId = $totalAlbums < $showOtherAlbum ? array_rand($otherAlbums, $totalAlbums) : array_rand($otherAlbums, $showOtherAlbum); $count = 0; for ($i = 0; $i < $totalAlbums; $i++) { $num = is_array($randomId) ? $randomId[$i] : $randomId; if ($otherAlbums[$num]->id != $album->id) { $count++; $randomAlbum[] = $otherAlbums[$num]; } if (count($randomAlbum) == $showOtherAlbum - 1) { break; } } } /* set head meta */ if (strtolower(trim(JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $handler->getCreatorName()))) == strtolower(trim($album->name))) { /** * Opengraph */ CHeadHelper::setType('website', JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $handler->getCreatorName()), CStringHelper::escape($album->getDescription())); } else { /** * Opengraph */ CHeadHelper::setType('website', JText::sprintf('COM_COMMUNITY_PHOTOS_USER_PHOTOS_TITLE', $handler->getCreatorName()) . ' - ' . $album->name, CStringHelper::escape($album->getDescription())); } $this->setTitle($album->name); $handler->setAlbumPathway(CStringHelper::escape($album->name)); $handler->setRSSHeader($albumId); // Set album thumbnail and description for social bookmarking sites linking $document->addHeadLink($album->getCoverThumbURI(), 'image_src', 'rel'); //$document->setDescription( CStringHelper::escape($album->getDescription()) ); //CFactory::load( 'libraries' , 'phototagging' ); $getTaggingUsers = new CPhotoTagging(); $people = array(); // @TODO temporary fix for undefined link $list = array(); foreach ($photos as $photo) { $photo->link = $handler->getPhotoURI($photo->id, $photo->albumid); CHeadHelper::addOpengraph('og:image', JUri::root(true) . '/' . $photo->image, true); $list[] = $photo; } $photos = $list; $albumParam = new Cparameter($album->params); $tagged = $albumParam->get('tagged'); if (!empty($tagged)) { $people = explode(',', $albumParam->get('tagged')); } //Update lastUpdated $lastUpdated = new JDate($album->lastupdated); $album->lastUpdated = CActivityStream::_createdLapse($lastUpdated, false); $people = array_unique($people); CFactory::loadUsers($people); foreach ($people as &$person) { $person = CFactory::getUser($person); } //CFactory::load( 'libraries' , 'bookmarks' ); $bookmarks = new CBookmarks($handler->getAlbumExternalURI($album->id)); // Get wall data. $wallCount = CWallLibrary::getWallCount('albums', $album->id); $viewAllLink = false; if ($jinput->request->get('task', '') != 'app') { $viewAllLink = CRoute::_('index.php?option=com_community&view=photos&task=app&albumid=' . $album->id . '&app=walls'); } $wallContent = CWallLibrary::getWallContents('albums', $album->id, COwnerHelper::isCommunityAdmin() || $my->id == $album->creator && $my->id != 0, $config->get('stream_default_comments'), 0, 'wall/content', 'photos,album'); $wallForm = CWallLibrary::getWallInputForm($album->id, 'photos,ajaxAlbumSaveWall', 'photos,ajaxAlbumRemoveWall', $viewAllLink); $viewAllLink = CRoute::_('index.php?option=com_community&view=photos&task=app&albumid=' . $album->id . '&app=walls'); $wallViewAll = ''; if ($wallCount > $config->get('stream_default_comments')) { $wallViewAll = CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount); } $redirectUrl = CRoute::getURI(false); $tmpl = new CTemplate(); if ($album->location != "") { $zoomableMap = CMapping::drawZoomableMap($album->location, 220, 150); } else { $zoomableMap = ""; } // Get the likes / dislikes item //CFactory::load( 'libraries' , 'like' ); $like = new CLike(); $likeCount = $like->getLikeCount('album', $album->id); $likeLiked = $like->userLiked('album', $album->id, $my->id) === COMMUNITY_LIKE; $owner = CFactory::getUser($album->creator); echo $tmpl->set('photosmapdefault', $photoMapsDefault)->set('my', $my)->set('bookmarksHTML', $bookmarks->getHTML())->set('isOwner', $handler->isAlbumOwner($album->id))->set('isAdmin', COwnerHelper::isCommunityAdmin())->set('owner', $owner)->set('photos', $photos)->set('people', $people)->set('album', $album)->set('groupId', $groupId)->set('otherAlbums', $randomAlbum)->set('likeCount', $likeCount)->set('likeLiked', $likeLiked)->set('wallContent', $wallContent)->set('wallForm', $wallForm)->set('wallCount', $wallCount)->set('wallViewAll', $wallViewAll)->set('zoomableMap', $zoomableMap)->set('pagination', $pagination)->set('photoId', $defaultId)->set('submenu', $this->showSubmenu(false))->fetch('photos/list'); }
public function getLastUpdated($raw = false) { $query = ' SELECT MAX(created) AS lastupdated' . ' FROM ' . $this->_db->nameQuote('#__community_videos') . ' WHERE ' . $this->_db->nameQuote('id') . ' = ' . $this->_db->quote($this->getId()); $this->_db->setQuery($query); $this->_lastupdated = $this->_db->loadResult(); if ($raw) { return $this->_lastupdated; } CFactory::load('libraries', 'activities'); if ($this->_lastupdated == '0000-00-00 00:00:00' || $this->_lastupdated == '') { $this->_lastupdated = $this->created; if ($this->_lastupdated == '' || $this->_lastupdated == '0000-00-00 00:00:00') { $this->_lastupdated = JText::_('CC NO LAST ACTIVITY'); } else { $lastUpdated = new JDate($this->_lastupdated); $this->_lastupdated = CActivityStream::_createdLapse($lastUpdated); } } else { $lastUpdated = new JDate($this->_lastupdated); $this->_lastupdated = CActivityStream::_createdLapse($lastUpdated); } return $this->_lastupdated; }
function _getAlbumsHTML($albums, $type = PHOTOS_USER_TYPE) { $my = CFactory::getUser(); $groupId = JRequest::getInt('groupid', '', 'REQUEST'); $tmpl = new CTemplate(); CFactory::load('libraries', 'activities'); CFactory::load('models', 'groups'); CFactory::load('helpers', 'owner'); for ($i = 0; $i < count($albums); $i++) { $albums[$i]->user = CFactory::getUser($albums[$i]->creator); $albums[$i]->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$albums[$i]->id}&userid={$albums[$i]->creator}"); $albums[$i]->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$albums[$i]->id}&userid={$albums[$i]->creator}"); $albums[$i]->uploadLink = CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$albums[$i]->id}&userid={$albums[$i]->creator}"); $albums[$i]->isOwner = $my->id == $albums[$i]->creator; if ($type == PHOTOS_GROUP_TYPE) { $group =& JTable::getInstance('Group', 'CTable'); $group->load($groupId); $albums[$i]->link = CRoute::_("index.php?option=com_community&view=photos&task=album&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}"); $albums[$i]->editLink = CRoute::_("index.php?option=com_community&view=photos&task=editAlbum&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}"); $albums[$i]->uploadLink = CRoute::_("index.php?option=com_community&view=photos&task=uploader&albumid={$albums[$i]->id}&groupid={$albums[$i]->groupid}"); $params = $group->getParams(); $photopermission = $params->get('photopermission', GROUP_PHOTO_PERMISSION_ADMINS); if ($photopermission == GROUP_PHOTO_PERMISSION_MEMBERS && $group->isMember($my->id)) { $albums[$i]->isOwner = $my->id == $albums[$i]->creator; } else { if ($photopermission == GROUP_PHOTO_PERMISSION_ADMINS && $group->isAdmin($my->id) || COwnerHelper::isCommunityAdmin()) { $albums[$i]->isOwner = true; } else { $albums[$i]->isOwner = false; } } } // If new albums that has just been created and // does not contain any images, the lastupdated will always be 0000-00-00 00:00:00:00 // Try to use the albums creation date instead. if ($albums[$i]->lastupdated == '0000-00-00 00:00:00' || $albums[$i]->lastupdated == '') { $albums[$i]->lastupdated = $albums[$i]->created; if ($albums[$i]->lastupdated == '' || $albums[$i]->lastupdated == '0000-00-00 00:00:00') { $albums[$i]->lastupdated = JText::_('CC NO LAST ACTIVITY'); } else { $lastUpdated = new JDate($albums[$i]->lastupdated); $albums[$i]->lastupdated = CActivityStream::_createdLapse($lastUpdated); } } else { $lastUpdated = new JDate($albums[$i]->lastupdated); $albums[$i]->lastupdated = CActivityStream::_createdLapse($lastUpdated); } } CFactory::load('helpers', 'owner'); CFactory::load('libraries', 'featured'); $featured = new CFeatured(FEATURED_ALBUMS); $featuredList = $featured->getItemIds(); $task = JRequest::getVar('task', '', 'GET'); $showFeatured = empty($task) ? true : false; $createLink = CRoute::_('index.php?option=com_community&view=photos&task=newalbum&userid=' . $my->id); if ($type == PHOTOS_GROUP_TYPE) { $createLink = CRoute::_('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $groupId); CFactory::load('helpers', 'group'); $isOwner = CGroupHelper::allowManagePhoto($groupId); } else { $userId = JRequest::getInt('userid', '', 'REQUEST'); $user = CFactory::getUser($userId); $isOwner = $my->id == $user->id ? true : false; } $task = JRequest::getCmd('task', ''); $tmpl->set('isOwner', $isOwner); $tmpl->set('type', $type); $tmpl->set('createLink', $createLink); $tmpl->set('currentTask', $task); $tmpl->set('showFeatured', $showFeatured); $tmpl->set('featuredList', $featuredList); $tmpl->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin()); $tmpl->set('my', $my); $tmpl->set('albums', $albums); $tmpl->set('isSuperAdmin', COwnerHelper::isCommunityAdmin()); return $tmpl->fetch('albums.list'); }
/** * 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'); }
public function getLastUpdated($raw = false) { $this->_lastupdated = $this->created; if ($raw) { return $this->_lastupdated; } if ($this->_lastupdated == '0000-00-00 00:00:00' || $this->_lastupdated == '') { $this->_lastupdated = $this->created; if ($this->_lastupdated == '' || $this->_lastupdated == '0000-00-00 00:00:00') { $this->_lastupdated = JText::_('COM_COMMUNITY_NO_LAST_ACTIVITY'); } else { $lastUpdated = new JDate($this->_lastupdated); $this->_lastupdated = CActivityStream::_createdLapse($lastUpdated, false); } } else { $lastUpdated = new JDate($this->_lastupdated); $this->_lastupdated = CActivityStream::_createdLapse($lastUpdated, false); } return $this->_lastupdated; }
/** * Show the main profile header */ function _showHeader(&$data) { jimport('joomla.utilities.arrayhelper'); $my =& JFactory::getUser(); $userid = JRequest::getVar('userid', $my->id); $user = CFactory::getUser($userid); $userModel = CFactory::getModel('user'); CFactory::load('libraries', 'messaging'); CFactory::load('helpers', 'owner'); // Get the admin controls HTML data $adminControlHTML = ''; $tmpl = new CTemplate(); $editStatus = ''; $editLink = ''; if (COwnerHelper::isMine($my->id, $user->id)) { $editStatus = '<input id="new-status" style="border:1px solid #cccccc;" type="text" value="" size="38" onkeyup="if(event.keyCode == 13) {cStatusAct()}"/>'; $editLink = '<span id="profile-status-edit" onclick="cStatusAct()">[' . JText::_('CC EDIT') . ']</span>'; } // 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); $tmpl->set('karmaImgUrl', CUserPoints::getPointsImage($user)); $tmpl->set('editStatus', $editStatus); $tmpl->set('editLink', $editLink); $tmpl->set('isMine', COwnerHelper::isMine($my->id, $user->id)); $profile = JArrayHelper::toObject($data->profile); $profile->largeAvatar = $user->getAvatar(); $profile->status = $user->getStatus(); CFactory::load('libraries', 'activities'); $postedOn = new JDate($user->_posted_on); $postedOn = CActivityStream::_createdLapse($postedOn); $profile->posted_on = $user->_posted_on == '0000-00-00 00:00:00' ? '' : $postedOn; // Assign videoId $profile->profilevideo = $data->videoid; $addbuddy = "joms.friends.connect('{$profile->id}')"; $sendMsg = CMessaging::getPopup($profile->id); $config = CFactory::getConfig(); $lastLogin = JText::_('CC 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 (!COwnerHelper::isMine($my->id, $user->id)) { $user->viewHit(); } $tmpl->set('lastLogin', $lastLogin); $tmpl->setRef('user', $user); $tmpl->set('addBuddy', $addbuddy); $tmpl->set('sendMsg', $sendMsg); $tmpl->set('config', $config); // @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); } $tmpl->set('multiprofile', $multiprofile); $tmpl->set('showBlogLink', $showBlogLink); $tmpl->set('isFriend', CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id); $tmpl->set('profile', $profile); $tmpl->set('unread', $unread); $tmpl->set('pending', $pending); $tmpl->set('registerDate', $user->registerDate); $tmpl->set('adminControlHTML', $adminControlHTML); $tmpl->set('likesHTML', $likesHTML); $html = $tmpl->fetch('profile.header'); return $html; }
public function modProfileUserinfo() { jimport('joomla.utilities.arrayhelper'); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $my = CFactory::getUser(); $userid = $jinput->get('userid', $my->id, 'INT'); $user = CFactory::getUser($userid); $params = $user->getParams(); $userModel = CFactory::getModel('user'); $profileModel = CFactory::getModel('profile'); //Reassign needed variable $data = new stdClass(); $data->user = $user; $data->profile = $profileModel->getViewableProfile($userid, $user->getProfileType()); $data->videoid = $params->get('profileVideo', 0); 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->defaultAvatar = $user->isDefaultAvatar(); $profile->status = $user->getStatus(); $profile->defaultCover = $user->isDefaultCover(); $profile->cover = $user->getCover(); $profile->coverPostion = $params->get('coverPosition', ''); if (strpos($profile->coverPostion, '%') === false) { $profile->coverPostion = 0; } $groupmodel = CFactory::getModel('groups'); $profile->_groups = $groupmodel->getGroupsCount($profile->id); $eventmodel = CFactory::getModel('events'); $profile->_events = $eventmodel->getEventsCount($profile->id); $profile->_friends = $user->_friendcount; $videoModel = CFactory::getModel('Videos'); $profile->_videos = $videoModel->getVideosCount($profile->id); $photosModel = CFactory::getModel('photos'); $profile->_photos = $photosModel->getPhotosCount($profile->id); 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 = ''; } /* is featured */ $modelFeatured = CFactory::getModel('Featured'); $profile->featured = $modelFeatured->isExists(FEATURED_USERS, $profile->id); // 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(); $jConfig = JFactory::getConfig(); $lastLogin = JText::_('COM_COMMUNITY_PROFILE_NEVER_LOGGED_IN'); if ($user->lastvisitDate != '0000-00-00 00:00:00') { $userLastLogin = new JDate($user->lastvisitDate); $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; $myblog = CMyBlog::getInstance(); if ($config->get('enablemyblogicon') && $myblog) { if ($myblog->userCanPost($user->id)) { $showBlogLink = true; } $tmpl->set('blogItemId', $myblog->getItemId()); } $photoEnabled = $config->get('enablephotos') ? true : false; $eventEnabled = $config->get('enableevents') ? true : false; $groupEnabled = $config->get('enablegroups') ? true : false; $videoEnabled = $config->get('enablevideos') ? true : false; $isSEFEnabled = $jConfig->get('sef') ? true : false; $multiprofile = JTable::getInstance('MultiProfile', 'CTable'); $multiprofile->load($user->getProfileType()); CFactory::load('libraries', 'like'); $like = new Clike(); $isLikeEnabled = $like->enabled('profile') && $params->get('profileLikes', 1) ? 1 : 0; $isUserLiked = $like->userLiked('profile', $user->id, $my->id); /* likes count */ $likes = $like->getLikeCount('profile', $user->id); /* User status */ $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(); $isMine = COwnerHelper::isMine($my->id, $user->id); $isCommunityAdmin = COwnerHelper::isCommunityAdmin($user->id); // Check if user is blocked $getBlockStatus = new blockUser(); $isblocked = $getBlockStatus->isUserBlocked($user->id, 'profile'); // Get block user html //$blockUserHTML = $isMine || $isCommunityAdmin ? '' : CUserHelper::getBlockUserHTML($user->id, $isBlocked); $isMine = COwnerHelper::isMine($my->id, $user->id); $isCommunityAdmin = COwnerHelper::isCommunityAdmin($user->id); // Get reporting html $report = new CReportingLibrary(); $reportsHTML = $isMine ? '' : $report->getReportingHTML(JText::_('COM_COMMUNITY_REPORT_USER'), 'profile,reportProfile', array($user->id)); $tmpl = new CTemplate(); echo $tmpl->set('karmaImgUrl', CUserPoints::getPointsImage($user))->set('reportsHTML', $reportsHTML)->set('isMine', $isMine)->set('lastLogin', $lastLogin)->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('isWaitingResponse', CFriendsHelper::isWaitingApproval($user->id, $my->id))->set('isBlocked', $isblocked)->set('profile', $profile)->set('unread', $unread)->set('pending', $pending)->set('registerDate', $user->registerDate)->set('adminControlHTML', $adminControlHTML)->set('userstatus', $status)->set('user', $user)->set('isUserLiked', $isUserLiked)->set('likes', $likes)->set('isLikeEnabled', $isLikeEnabled)->set('photoEnabled', $photoEnabled)->set('eventEnabled', $eventEnabled)->set('groupEnabled', $groupEnabled)->set('videoEnabled', $videoEnabled)->set('about', $this->_getProfileHTML($data->profile))->set('isSEFEnabled', $isSEFEnabled)->set('blocked', $user->isBlocked())->fetch('profile/focus'); }
/** * Show the main profile header */ public function _showHeader(&$data) { jimport('joomla.utilities.arrayhelper'); $my =& JFactory::getUser(); $userid = JRequest::getVar('userid', $my->id); $user = CFactory::getUser($userid); $params = $user->getParams(); $userModel = CFactory::getModel('user'); CFactory::load('libraries', 'messaging'); CFactory::load('helpers', 'owner'); $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(); CFactory::load('libraries', 'activities'); $profile->status = $user->getStatus(); if ($profile->status !== '') { CFactory::load('libraries', 'activities'); $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.friends.connect('{$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); } /* User status */ CFactory::load('libraries', 'userstatus'); $status = new CUserStatus($user->id, 'profile'); //respect wall setting CFactory::load('helpers', 'friends'); CFactory::load('helper', 'owner'); if ($my->id && (!$config->get('lockprofilewalls') || $config->get('lockprofilewalls') && CFriendsHelper::isConnected($my->id, $profile->id)) || COwnerHelper::isCommunityAdmin()) { // Add default status box CFactory::load('helpers', 'user'); CUserHelper::addDefaultStatusCreator($status); } $isblocked = $user->isBlocked(); return $tmpl->set('karmaImgUrl', CUserPoints::getPointsImage($user))->set('isMine', $isMine)->set('lastLogin', $lastLogin)->setRef('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('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'); }