public static function getAccessLevel($actorId, $targetId) { $actor = CFactory::getUser($actorId); $target = CFactory::getUser($targetId); CFactory::load('helpers', 'owner'); CFactory::load('helpers', 'friends'); // public guest $access = 0; // site members if ($actor->id > 0) { $access = 20; } // they are friends if ($target->id > 0 && CFriendsHelper::isConnected($actor->id, $target->id)) { $access = 30; } // mine, target and actor is the same person if ($target->id > 0 && COwnerHelper::isMine($actor->id, $target->id)) { $access = 40; } if (COwnerHelper::isCommunityAdmin()) { $access = 40; } return $access; }
/** * Return true if actor have access to target's item * @param type where the privacy setting should be extracted, {user, group, global, custom} * Site super admin waill always have access to all area */ static function isAccessAllowed($actorId, $targetId, $type, $userPrivacyParam) { $actor = CFactory::getUser($actorId); $target = CFactory::getUser($targetId); CFactory::load('helpers', 'owner'); CFactory::load('helpers', 'friends'); // Load User params $params =& $target->getParams(); // guest $relation = 10; // site members if ($actor->id != 0) { $relation = 20; } // friends if (CFriendsHelper::isConnected($actorId, $targetId)) { $relation = 30; } // mine, target and actor is the same person if (COwnerHelper::isMine($actor->id, $target->id)) { $relation = 40; } // @todo: respect privacy settings // If type is 'custom', then $userPrivacyParam will contain the exact // permission level $permissionLevel = $type == 'custom' ? $userPrivacyParam : $params->get($userPrivacyParam); if ($relation < $permissionLevel && !COwnerHelper::isCommunityAdmin($actorId)) { return false; } return true; }
function showMiniHeader($userId) { CMiniHeader::load(); CFactory::load('helpers', 'friends'); CFactory::load('helpers', 'owner'); $option = JRequest::getVar('option', '', 'REQUEST'); $lang =& JFactory::getLanguage(); $lang->load('com_community'); $my = CFactory::getUser(); $config = CFactory::getConfig(); if (!empty($userId)) { $user = CFactory::getUser($userId); CFactory::load('libraries', 'messaging'); $sendMsg = CMessaging::getPopup($user->id); $tmpl = new CTemplate(); $tmpl->set('my', $my); $tmpl->set('user', $user); $tmpl->set('isMine', COwnerHelper::isMine($my->id, $user->id)); $tmpl->set('sendMsg', $sendMsg); $tmpl->set('config', $config); $tmpl->set('isFriend', CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id); $showMiniHeader = $option == 'com_community' ? $tmpl->fetch('profile.miniheader') : '<div id="community-wrap" style="min-height:50px;">' . $tmpl->fetch('profile.miniheader') . '</div>'; return $showMiniHeader; } }
/** * Add default items for status box */ static function addDefaultStatusCreator(&$status) { $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); $config = CFactory::getConfig(); $template = new CTemplate(); $isMine = COwnerHelper::isMine($my->id, $user->id); /* Message creator */ $creator = new CUserStatusCreator('message'); $creator->title = JText::_('COM_COMMUNITY_STATUS'); $creator->html = $template->fetch('status.message'); $status->addCreator($creator); if ($isMine) { if ($config->get('enablephotos')) { /* Photo creator */ $creator = new CUserStatusCreator('photo'); $creator->title = JText::_('COM_COMMUNITY_SINGULAR_PHOTO'); $creator->html = $template->fetch('status.photo'); $status->addCreator($creator); } if ($config->get('enablevideos')) { /* Video creator */ $creator = new CUserStatusCreator('video'); $creator->title = JText::_('COM_COMMUNITY_SINGULAR_VIDEO'); $creator->html = $template->fetch('status.video'); $status->addCreator($creator); } if ($config->get('enableevents') && ($config->get('createevents') || COwnerHelper::isCommunityAdmin())) { /* Event creator */ //CFactory::load( 'helpers' , 'event' ); $dateSelection = CEventHelper::getDateSelection(); $model = CFactory::getModel('events'); $categories = $model->getCategories(); // Load category tree $cTree = CCategoryHelper::getCategories($categories); $lists['categoryid'] = CCategoryHelper::getSelectList('events', $cTree); $template->set('startDate', $dateSelection->startDate); $template->set('endDate', $dateSelection->endDate); $template->set('startHourSelect', $dateSelection->startHour); $template->set('endHourSelect', $dateSelection->endHour); $template->set('startMinSelect', $dateSelection->startMin); $template->set('repeatEnd', $dateSelection->endDate); $template->set('enableRepeat', $my->authorise('community.view', 'events.repeat')); $template->set('endMinSelect', $dateSelection->endMin); $template->set('startAmPmSelect', $dateSelection->startAmPm); $template->set('endAmPmSelect', $dateSelection->endAmPm); $template->set('lists', $lists); $creator = new CUserStatusCreator('event'); $creator->title = JText::_('COM_COMMUNITY_SINGULAR_EVENT'); $creator->html = $template->fetch('status.event'); $status->addCreator($creator); } } }
public static function showMiniHeader($userId) { CMiniHeader::load(); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; JFactory::getLanguage()->load('com_community'); $option = $jinput->get('option', '', 'STRING'); //JRequest::getVar('option', '' , 'REQUEST'); $my = CFactory::getUser(); $config = CFactory::getConfig(); if (!empty($userId)) { $user = CFactory::getUser($userId); $params = $user->getParams(); //links information $photoEnabled = $config->get('enablephotos') ? true : false; $eventEnabled = $config->get('enableevents') ? true : false; $groupEnabled = $config->get('enablegroups') ? true : false; $videoEnabled = $config->get('enablevideos') ? true : false; //likes 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); //profile $profileModel = CFactory::getModel('profile'); $profile = $profileModel->getViewableProfile($user->id, $user->getProfileType()); $profile = JArrayHelper::toObject($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); /* is featured */ $modelFeatured = CFactory::getModel('Featured'); $profile->featured = $modelFeatured->isExists(FEATURED_USERS, $profile->id); $sendMsg = CMessaging::getPopup($user->id); $tmpl = new CTemplate(); $tmpl->set('my', $my)->set('user', $user)->set('isBlocked', $user->isBlocked())->set('isMine', COwnerHelper::isMine($my->id, $user->id))->set('sendMsg', $sendMsg)->set('config', $config)->set('isWaitingApproval', CFriendsHelper::isWaitingApproval($my->id, $user->id))->set('isLikeEnabled', $isLikeEnabled)->set('photoEnabled', $photoEnabled)->set('eventEnabled', $eventEnabled)->set('groupEnabled', $groupEnabled)->set('videoEnabled', $videoEnabled)->set('profile', $profile)->set('isUserLiked', $isUserLiked)->set('likes', $likes)->set('isFriend', CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id); $showMiniHeader = $option == 'com_community' ? $tmpl->fetch('profile.miniheader') : '<div id="community-wrap" style="min-height:50px;">' . $tmpl->fetch('profile.miniheader') . '</div>'; return $showMiniHeader; } }
public function ajaxWallShowComments($uniqueId, $type = false) { $my = CFactory::getUser(); $html = ''; if ($type == 'albums') { $album = JTable::getInstance('Album', 'CTable'); $album->load($uniqueId); $html = CWallLibrary::getWallContents($type, $album->id, COwnerHelper::isCommunityAdmin() || COwnerHelper::isMine($my->id, $album->creator), 0, 0); } else { if ($type == 'discussions') { $discussion = JTable::getInstance('Discussion', 'CTable'); $discussion->load($uniqueId); $html = CWallLibrary::getWallContents($type, $discussion->id, $my->id == $discussion->creator, 0, 0, 'wall/content', 'groups,discussion'); } else { if ($type == 'videos') { $video = JTable::getInstance('Video', 'CTable'); $video->load($uniqueId); $html = CWallLibrary::getWallContents($type, $video->id, COwnerHelper::isCommunityAdmin() || $my->id == $video->creator && $my->id != 0, 0, 0, 'wall/content', 'videos,video'); } else { if ($type == 'photos') { $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($uniqueId); $html = CWallLibrary::getWallContents($type, $photo->id, COwnerHelper::isCommunityAdmin() || $my->id == $photo->creator, 0, 0, 'wall/content', 'photos,photo'); } } } } $json = array(); $json['success'] = true; $json['html'] = $html; die(json_encode($json)); }
/** * Check if permitted to play the video * * @param int $myid The current user's id * @param int $userid The active profile user's id * @param int $permission The video's permission * @return bool True if it's permitted * @since 1.2 */ public function isPermitted($myid = 0, $userid = 0, $permissions = 0) { if ($permissions == 0) { return true; } // public // Load Libraries CFactory::load('helpers', 'friends'); CFactory::load('helpers', 'owner'); if (COwnerHelper::isCommunityAdmin()) { return true; } $relation = 0; if ($myid != 0) { $relation = 20; } // site members if (CFriendsHelper::isConnected($myid, $userid)) { $relation = 30; } // friends if (COwnerHelper::isMine($myid, $userid)) { $relation = 40; // mine } if ($relation >= $permissions) { return true; } return false; }
/** * Check if permitted to play the video * * @param int $myid The current user's id * @param int $userid The active profile user's id * @param int $permission The video's permission * @return bool True if it's permitted * @since 1.2 */ public function isPermitted($myid = 0, $userid = 0, $permissions = 0) { if ($permissions == 0) { return true; } // public if (COwnerHelper::isCommunityAdmin()) { return true; } $relation = 0; if ($myid != 0) { $relation = 20; } // site members if (CFriendsHelper::isConnected($myid, $userid)) { $relation = 30; } // friends if (COwnerHelper::isMine($myid, $userid)) { $relation = 40; // mine } if ($relation >= $permissions) { return true; } return false; }
/** * Return html formatted activity stream * @access public * @todo Add caching - Improve performance via caching */ function getHTML($actor, $target, $date = null, $maxEntry = 0, $type = '', $idprefix = '', $showActivityContent = true, $showMoreActivity = false, $exclusions = null, $displayArchived = false) { jimport('joomla.utilities.date'); $mainframe =& JFactory::getApplication(); CFactory::load('helpers', 'url'); CFactory::load('helpers', 'owner'); CFactory::load('libraries', 'template'); $activities = CFactory::getModel('activities'); $appModel = CFactory::getModel('apps'); $config = CFactory::getConfig(); $html = ''; $numLines = 0; $my = CFactory::getUser(); $actorId = $actor; $htmlData = array(); $tmpl = new CTemplate(); $maxList = $maxEntry == 0 ? $config->get('maxactivities') : $maxEntry; $config = CFactory::getConfig(); $isSuperAdmin = COwnerHelper::isCommunityAdmin(); $data = $this->_getData($actor, $target, $date, $maxList, $type, $exclusions, $displayArchived); // Do not show more activity button if there is nothing more to read. if ($activities->getTotalActivities() <= $config->get('maxactivities')) { $showMoreActivity = false; } // We should also exclude any data that earlier (hence larger id) than any // of the current exclusion list $exclusions = $data->exclusions; $htmlData = $data->data; $tmpl->set('showMoreActivity', $showMoreActivity); $tmpl->set('exclusions', $exclusions); $tmpl->set('isMine', COwnerHelper::isMine($my->id, $actor)); $tmpl->set('activities', $htmlData); $tmpl->set('idprefix', $idprefix); $tmpl->set('my', $my); $tmpl->set('isSuperAdmin', $isSuperAdmin); $tmpl->set('config', $config); $tmpl->set('showMore', $showActivityContent); return $tmpl->fetch('activities.index'); }
/** * Method to display video * @return void */ public function video() { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $document = JFactory::getDocument(); $config = CFactory::getConfig(); $my = CFactory::getUser(); $requestUser = CFactory::getRequestUser(); $videoId = $jinput->get('videoid', '', 'INT'); $task = $jinput->getCmd('task'); // Get show video location map by default $videoMapsDefault = $config->get('videosmapdefault'); // Load window library CWindow::load(); $video = JTable::getInstance('Video', 'CTable'); if (empty($videoId)) { if ($jinput->get('videoid', '', 'INT')) { $videoId = $jinput->get('videoid', '', 'INT'); } else { $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'); } if ($video->groupid) { JRequest::setVar('groupid', $video->groupid); } elseif ($video->eventid) { JRequest::setVar('eventid', $video->eventid); } // Setting up the sub menu if (COwnerHelper::isCommunityAdmin() || $my->id == $video->creator && $my->id != 0) { $this->addSubmenuItem('', JText::_('COM_COMMUNITY_VIDEOS_FETCH_THUMBNAIL'), "joms.api.videoFetchThumbnail('" . $video->id . "');", true); // Only add the set as profile video for video owner if ($my->id == $video->creator && $config->get('enableprofilevideo')) { $this->addSubmenuItem('', JText::_('COM_COMMUNITY_VIDEOS_SET_AS_PROFILE'), "joms.api.videoLinkToProfile('" . $video->id . "');", true); } $redirectUrl = CRoute::getURI(false); $this->addSubmenuItem('', JText::_('COM_COMMUNITY_EDIT'), "joms.api.videoEdit('" . $video->id . "');", true); $this->addSubmenuItem('', JText::_('COM_COMMUNITY_DELETE'), "joms.api.videoRemove('" . $video->id . "');", true); } $this->_addSubmenu(); // 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 = $jinput->get('sort', 'latest', 'STRING'); $limit = $jinput->get('limitstart', 6, 'INT'); $permissions = $my->id == 0 ? 0 : 20; $cat_id = $jinput->get('cat_id', '', 'INT'); $model = CFactory::getModel('videos'); /* We get groupid from video table instead user input */ $groupId = $video->groupid; if ($video->creator_type == VIDEO_GROUP_TYPE) { if (!CGroupHelper::allowViewMedia($groupId)) { /** * Opengraph */ CHeadHelper::setType('website', 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&task=display&groupid=' . $groupId)); $pathway->addItem($video->getTitle(), ''); $otherVideos = $model->getGroupVideos($groupId, $cat_id, $limit); } else { if (!$this->isPermitted($my->id, $video->creator, $video->permissions)) { /** * Opengraph */ CHeadHelper::setType('website', 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); } // Set the current user's active profile CFactory::setActiveProfile($video->creator); // Hit counter + 1 $video->hit(); // Get reporting html $reportHTML = ''; $report = new CReportingLibrary(); if ($user->id != $my->id) { $reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_VIDEOS_REPORT_VIDEOS'), 'videos,reportVideo', array($video->id)); } // Get bookmark html $bookmarks = new CBookmarks($video->getPermalink()); $bookmarksHTML = $bookmarks->getHTML(); // Get the walls $wallContent = CWallLibrary::getWallContents('videos', $video->id, COwnerHelper::isCommunityAdmin() || $my->id == $video->creator && $my->id != 0, $config->get('stream_default_comments'), 0, 'wall/content', 'videos,video'); $wallCount = CWallLibrary::getWallCount('videos', $video->id); $viewAllLink = CRoute::_('index.php?option=com_community&view=videos&task=app&videoid=' . $video->id . '&app=walls'); $wallViewAll = ''; if ($wallCount > $config->get('stream_default_comments')) { $wallViewAll = 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 information. $like = new CLike(); $likeCount = $like->getLikeCount('videos', $video->id); $likeLiked = $like->userLiked('videos', $video->id, $my->id) === COMMUNITY_LIKE; $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) { $zoomableMap = CMapping::drawZoomableMap($video->location, 220, 150, $video->longitude, $video->latitude); } else { $zoomableMap = ""; } //friend list for video tag $tagging = new CVideoTagging(); $taggedList = $tagging->getTaggedList($video->id); for ($t = 0; $t < count($taggedList); $t++) { $tagItem = $taggedList[$t]; $tagUser = CFactory::getUser($tagItem->userid); $canRemoveTag = 0; // 1st we check the tagged user is the video owner. // If yes, canRemoveTag == true. // If no, then check on user is the tag creator or not. // If yes, canRemoveTag == true // If no, then check on user whether user is being tagged if (COwnerHelper::isMine($my->id, $video->creator) || COwnerHelper::isMine($my->id, $tagItem->created_by) || COwnerHelper::isMine($my->id, $tagItem->userid)) { $canRemoveTag = 1; } $tagItem->user = $tagUser; $tagItem->canRemoveTag = $canRemoveTag; } if ($video->type == "file") { $storage = CStorage::getStorage($video->storage); $video->path = $storage->getURI($video->path); } $config = CFactory::getConfig(); $canSearch = 1; if ($my->id == 0 && !$config->get('enableguestsearchvideos')) { $canSearch = 0; } CHeadHelper::addOpengraph('og:image', JUri::root() . $video->thumb, true); CHeadHelper::setType('website', $video->title); $video->tagged = $taggedList; echo $tmpl->setMetaTags('video', $video)->set('user', $user)->set('zoomableMap', $zoomableMap)->set('likeCount', $likeCount)->set('canSearch', $canSearch)->set('likeLiked', $likeLiked)->set('redirectUrl', $redirectUrl)->set('wallContent', $wallContent)->set('wallForm', $wallForm)->set('wallCount', $wallCount)->set('wallViewAll', $wallViewAll)->set('bookmarksHTML', $bookmarksHTML)->set('reportHTML', $reportHTML)->set('video', $video)->set('otherVideos', $otherVideos)->set('videoMapsDefault', $videoMapsDefault)->set('wallCount', $wallCount)->set('isGroup', $groupId ? true : false)->set('groupId', $groupId ? $groupId : null)->set('submenu', $this->showSubmenu(false))->fetch('videos/single'); }
/** * Update the status of current user */ public function ajaxUpdate($message = '') { if (!COwnerHelper::isRegisteredUser()) { return $this->ajaxBlockUnregister(); } $mainframe =& JFactory::getApplication(); $objResponse = new JAXResponse(); //@rule: In case someone bypasses the status in the html, we enforce the character limit. $config = CFactory::getConfig(); if (JString::strlen($message) > $config->get('statusmaxchar')) { $message = JString::substr($message, 0, $config->get('statusmaxchar')); } //trim it here so that it wun go into activities stream. $message = JString::trim($message); $my = CFactory::getUser(); $status =& $this->getModel('status'); $status->update($my->id, $message); //set user status for current session. $today =& JFactory::getDate(); $message2 = empty($message) ? ' ' : $message; $my->set('_status', $message2); $my->set('_posted_on', $today->toMySQL()); $profileid = JRequest::getVar('userid', 0, 'GET'); if (COwnerHelper::isMine($my->id, $profileid)) { $objResponse->addScriptCall("joms.jQuery('#profile-status span#profile-status-message').html('" . addslashes($message) . "');"); } CFactory::load('helpers', 'string'); $message = CStringHelper::escape($message); if (!empty($message)) { $act = new stdClass(); $act->cmd = 'profile.status.update'; $act->actor = $my->id; $act->target = $my->id; CFactory::load('helpers', 'linkgenerator'); // @rule: Autolink hyperlinks $message = CLinkGeneratorHelper::replaceURL($message); // @rule: Autolink to users profile when message contains @username $message = CLinkGeneratorHelper::replaceAliasURL($message); $privacyParams = $my->getParams(); $act->title = '{actor} ' . $message; $act->content = ''; $act->app = 'profile'; $act->cid = $my->id; $act->access = $privacyParams->get('privacyProfileView'); CFactory::load('libraries', 'activities'); CActivityStream::add($act); //add user points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('profile.status.update'); //now we need to reload the activities streams $friendsModel = CFactory::getModel('friends'); $memberSince = CTimeHelper::getDate($my->registerDate); $friendIds = $friendsModel->getFriendIds($my->id); include_once JPATH_COMPONENT . DS . 'libraries' . DS . 'activities.php'; $act = new CActivityStream(); $params =& $my->getParams(); $limit = !empty($params) ? $params->get('activityLimit', '') : ''; $html = $act->getHTML($my->id, $friendIds, $memberSince, $limit); $status = $my->getStatus(); $status = addslashes($status); $objResponse->addScriptCall("joms.jQuery('#profile-status-message').html('" . $status . "');"); $objResponse->addScriptCall("joms.jQuery('title').val('" . $status . "');"); $objResponse->addAssign('activity-stream-container', 'innerHTML', $html); } return $objResponse->sendResponse(); }
/** * Show profile miniheader */ function _getMiniHeader() { CFactory::load('helpers', 'friends'); $my = CFactory::getUser(); $config = CFactory::getConfig(); if (!empty($this->_showMiniHeaderUser)) { $user = CFactory::getUser($this->_showMiniHeaderUser); CFactory::load('libraries', 'messaging'); $sendMsg = CMessaging::getPopup($user->id); $tmpl = new CTemplate(); $tmpl->set('my', $my); $tmpl->set('user', $user); $tmpl->set('isMine', COwnerHelper::isMine($my->id, $user->id)); $tmpl->set('sendMsg', $sendMsg); $tmpl->set('config', $config); $tmpl->set('isFriend', CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id); return $tmpl->fetch('profile.miniheader'); } }
<?php if ($enableReporting) { ?> <button class="joms-button--neutral joms-button--small" onclick="joms.api.photoReport('<?php echo $photo->id; ?> ');"><?php echo JText::_('COM_COMMUNITY_REPORT'); ?> </button> <?php } ?> <?php if (COwnerHelper::isMine($my->id, $album->creator) || CFriendsHelper::isConnected($my->id, $album->creator)) { ?> <button class="joms-button--neutral joms-button--small joms-js--btn-tag"><?php echo JText::_('COM_COMMUNITY_TAG_THIS_PHOTO'); ?> </button> <?php } ?> <div class="joms-js--photo-tag-ct"></div> <div class="joms-gap"></div> <div> <h5 class="joms-text--title"><?php echo JText::_('COM_COMMUNITY_PHOTOS_ALBUM_DESC');
/** * Update the status of current user */ public function ajaxUpdate($message = '') { $filter = JFilterInput::getInstance(); $message = $filter->clean($message, 'string'); $cache = CFactory::getFastCache(); $cache->clean(array('activities')); if (!COwnerHelper::isRegisteredUser()) { return $this->ajaxBlockUnregister(); } $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $objResponse = new JAXResponse(); //@rule: In case someone bypasses the status in the html, we enforce the character limit. $config = CFactory::getConfig(); if (JString::strlen($message) > $config->get('statusmaxchar')) { $message = JHTML::_('string.truncate', $message, $config->get('statusmaxchar')); } //trim it here so that it wun go into activities stream. $message = JString::trim($message); $my = CFactory::getUser(); $status = $this->getModel('status'); // @rule: Spam checks if ($config->get('antispam_akismet_status')) { //CFactory::load( 'libraries' , 'spamfilter' ); $filter = CSpamFilter::getFilter(); $filter->setAuthor($my->getDisplayName()); $filter->setMessage($message); $filter->setEmail($my->email); $filter->setURL(CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id)); $filter->setType('message'); $filter->setIP($_SERVER['REMOTE_ADDR']); if ($filter->isSpam()) { $objResponse->addAlert(JText::_('COM_COMMUNITY_STATUS_MARKED_SPAM')); return $objResponse->sendResponse(); } } $status->update($my->id, $message); //set user status for current session. $today = JFactory::getDate(); $message2 = empty($message) ? ' ' : $message; $my->set('_status', $message2); $my->set('_posted_on', $today->toSql()); $profileid = $jinput->get->get('userid', 0, 'INT'); //JRequest::getVar('userid' , 0 , 'GET'); if (COwnerHelper::isMine($my->id, $profileid)) { $objResponse->addScriptCall("joms.jQuery('#profile-status span#profile-status-message').html('" . addslashes($message) . "');"); } //CFactory::load( 'helpers' , 'string' ); // $message = CStringHelper::escape( $message ); if (!empty($message)) { $act = new stdClass(); $act->cmd = 'profile.status.update'; $act->actor = $my->id; $act->target = $my->id; //CFactory::load( 'helpers' , 'linkgenerator' ); // @rule: Autolink hyperlinks $message = CLinkGeneratorHelper::replaceURL($message); // @rule: Autolink to users profile when message contains @username $message = CUserHelper::replaceAliasURL($message); $privacyParams = $my->getParams(); $act->title = $message; $act->content = ''; $act->app = 'profile'; $act->cid = $my->id; $act->access = $privacyParams->get('privacyProfileView'); $act->comment_id = CActivities::COMMENT_SELF; $act->comment_type = 'profile.status'; $act->like_id = CActivities::LIKE_SELF; $act->like_type = 'profile.status'; //add user points //CFactory::load( 'libraries' , 'userpoints' ); if (CUserPoints::assignPoint('profile.status.update')) { //only assign act if user points is set to true CActivityStream::add($act); } //now we need to reload the activities streams (since some report regarding update status from hello me we disabled update the stream, cuz hellome usually called out from jomsocial page) $friendsModel = CFactory::getModel('friends'); $memberSince = CTimeHelper::getDate($my->registerDate); $friendIds = $friendsModel->getFriendIds($my->id); //include_once(JPATH_COMPONENT .'/libraries/activities.php'); $act = new CActivityStream(); $params = $my->getParams(); $limit = !empty($params) ? $params->get('activityLimit', '') : ''; //$html = $act->getHTML($my->id, $friendIds, $memberSince, $limit ); $status = $my->getStatus(); $status = str_replace(array("\r\n", "\n", "\r"), "", $status); $status = addslashes($status); // also update hellome module if available $script = "joms.jQuery('.joms-js--mod-hellome-label').html('" . $status . "');"; $script .= "joms.jQuery('.joms-js--mod-hellome-loading').hide();"; $objResponse->addScriptCall($script); } return $objResponse->sendResponse(); }
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'); }
/** * 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; }
/** * Check if current user has the correct permission to view the page. * We will validate access based on the current profile privacy setting and * the access type give. Should be called by view * * @param string type The access type, one of CUser param variables or * mine (active profile = my id)/registered(any registered user) * @param bool $showWarning * @return bool true if access is OK */ public function accessAllowed($type = '', $showWarning = true) { if (empty($type)) { return true; } $my = CFactory::getUser(); $userid = JRequest::getVar('userid', ''); $user = CFactory::getUser($userid); // @rule: For site administrators / community admin, we should allow access // no matter what the privacy is. CFactory::load('helpers', 'owner'); if (COwnerHelper::isCommunityAdmin()) { return true; } if ($type == 'registered') { if (!$my->id) { $mainframe =& JFactory::getApplication(); $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_RESTRICTED_ACCESS'), 'notice'); $this->noAccess(); return false; } else { return true; } } // you can always view your own profile if (COwnerHelper::isMine($my->id, $user->id)) { return true; } $param =& $user->getParams(); if ($type == 'mine') { $access = PRIVACY_PRIVATE; } else { $access = $param->get($type); } switch ($access) { case PRIVACY_PUBLIC: return true; break; case PRIVACY_MEMBERS: if ($my->id == 0) { $mainframe =& JFactory::getApplication(); $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_RESTRICTED_ACCESS'), 'notice'); $tmpl = new CTemplate(); $notice = ''; if ($type == 'privacyProfileView') { $userInfo = $this->_prepUser($user); if (!empty($userInfo)) { $tmpl->set('data', $userInfo); $tmpl->set('sortings', ''); $tmpl->set('featuredList', ''); $tmpl->set('isCommunityAdmin', ''); $tmpl->set('my', $my); echo $tmpl->fetch('people.browse'); } else { //user object not found. $notice = JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_VIEW_PAGE'); } $tmpl->set('notice', $notice); echo $tmpl->fetch('notice.access'); } else { $this->noAccess(); } return false; } return true; break; case PRIVACY_FRIENDS: CFactory::load('helpers', 'friends'); if (!CFriendsHelper::isConnected($my->id, $user->id)) { $mainframe =& JFactory::getApplication(); $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_RESTRICTED_ACCESS'), 'notice'); $tmpl = new CTemplate(); if ($type == 'privacyProfileView') { $userInfo = $this->_prepUser($user); if (!empty($userInfo)) { $tmpl->set('data', $userInfo); $tmpl->set('sortings', ''); // add this variable to avoid error thrown. $tmpl->set('featuredList', ''); $tmpl->set('isCommunityAdmin', ''); $tmpl->set('my', $my); echo $tmpl->fetch('people.browse'); } else { //user object not found. $this->noAccess(); } } else { $this->noAccess(); } return false; } else { return true; } break; case PRIVACY_PRIVATE: if ($my->id != $user->id) { $mainframe =& JFactory::getApplication(); $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_RESTRICTED_ACCESS'), 'error'); $this->noAccess(); return false; } else { return true; } break; } return true; }
/** * Deprecated since 1.8 */ function isMine($id1, $id2) { return COwnerHelper::isMine($id1, $id2); }
function _userPhoto() { $mainframe =& JFactory::getApplication(); $document =& JFactory::getDocument(); // Get necessary properties and load the libraries CFactory::load('models', 'photos'); CFactory::load('helpers', 'friends'); $my = CFactory::getUser(); $model = CFactory::getModel('photos'); $albumId = JRequest::getVar('albumid', '', 'GET'); $defaultId = JRequest::getVar('photoid', '', 'GET'); if (empty($albumId)) { echo JText::_('CC NO PROPER ALBUM ID'); return; } // Load the album table $album =& JTable::getInstance('Album', 'CTable'); $album->load($albumId); // Since the URL might not contain userid, we need to get the user object from the creator $user = CFactory::getUser($album->creator); if (!$user->block || COwnerHelper::isCommunityAdmin($my->id)) { // Set the current user's active profile CFactory::setActiveProfile($album->creator); // Get list of photos and set some limit to be displayed. // @todo: make limit configurable? set to 1000, unlimited? $photos = $model->getPhotos($albumId, 1000); $pagination = $model->getPagination(); CFactory::load('helpers', 'pagination'); // @todo: make limit configurable? $paging = CPaginationLibrary::getLinks($pagination, 'photos,ajaxPagination', $albumId, 10); // Set document title CFactory::load('helpers', 'string'); $document->setTitle($album->name); // @checks: Test if album doesnt have any default photo id. We need to get the first row // of the photos to be the default if ($album->photoid == '0') { $album->photoid = count($photos) >= 1 ? $photos[0]->id : '0'; } // Try to see if there is any photo id in the query $defaultId = !empty($defaultId) ? $defaultId : $album->photoid; // Load the default photo $photo =& JTable::getInstance('Photo', 'CTable'); $photo->load($defaultId); // If default has an id of 0, we need to tell the template to dont process anything $default = $photo->id == 0 ? false : $photo; // Load User params $params =& $user->getParams(); // site visitor $relation = 10; // site members if ($my->id != 0) { $relation = 20; } // friends if (CFriendsHelper::isConnected($my->id, $user->id)) { $relation = 30; } // mine if (COwnerHelper::isMine($my->id, $user->id)) { $relation = 40; } if ($my->id != $user->id) { $this->attachMiniHeaderUser($user->id); } CFactory::load('helpers', 'owner'); // @todo: respect privacy settings if ($relation < $params->get('privacyPhotoView') && !COwnerHelper::isCommunityAdmin()) { echo JText::_('CC ACCESS FORBIDDEN'); return; } CFactory::load('helpers', 'owner'); //friend list for photo tag CFactory::load('libraries', 'phototagging'); $tagging = new CPhotoTagging(); for ($i = 0; $i < count($photos); $i++) { $item = JTable::getInstance('Photo', 'CTable'); $item->bind($photos[$i]); $photos[$i] = $item; $row =& $photos[$i]; $taggedList = $tagging->getTaggedList($row->id); for ($t = 0; $t < count($taggedList); $t++) { $tagItem =& $taggedList[$t]; $tagUser = CFactory::getUser($tagItem->userid); $canRemoveTag = 0; // 1st we check the tagged user is the photo owner. // If yes, canRemoveTag == true. // If no, then check on user is the tag creator or not. // If yes, canRemoveTag == true // If no, then check on user whether user is being tagged if (COwnerHelper::isMine($my->id, $row->creator) || COwnerHelper::isMine($my->id, $tagItem->created_by) || COwnerHelper::isMine($my->id, $tagItem->userid)) { $canRemoveTag = 1; } $tagItem->user = $tagUser; $tagItem->canRemoveTag = $canRemoveTag; } $row->tagged = $taggedList; } $friendModel = CFactory::getModel('friends'); $friends = $friendModel->getFriends($my->id, '', false); array_unshift($friends, $my); // Show wall contents CFactory::load('helpers', 'friends'); // Load up required objects. $user = CFactory::getUser($photo->creator); $config = CFactory::getConfig(); $isConnected = CFriendsHelper::isConnected($my->id, $user->id); $isMe = COwnerHelper::isMine($my->id, $user->id); $showWall = false; $allowTag = false; // Check if user is really allowed to post walls on this photo. if ($isMe || !$config->get('lockprofilewalls') || $config->get('lockprofilewalls') && $isConnected) { $showWall = true; } //check if we can allow the current viewing user to tag the photos if ($isMe || $isConnected) { $allowTag = true; } $tmpl = new CTemplate(); CFactory::load('libraries', 'bookmarks'); $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $user->id)); $bookmarksHTML = $bookmarks->getHTML(); $tmpl->set('showWall', $showWall); $tmpl->set('allowTag', $allowTag); $tmpl->set('isOwner', COwnerHelper::isMine($my->id, $user->id)); $tmpl->set('photos', $photos); $tmpl->set('pagination', $paging); $tmpl->set('default', $default); $tmpl->set('album', $album); $tmpl->set('config', $config); //echo $tmpl->fetch('photos.photo'); } else { CFactory::load('helpers', 'owner'); $tmpl = new CTemplate(); echo $tmpl->fetch('profile.blocked'); return; } }
$params->def('pending', $friendModel->countPending($my->id)); $params->def('myLink', CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id)); $params->def('myName', $my->getDisplayName()); $params->def('myAvatar', $my->getAvatar()); $params->def('myId', $my->id); $CUserPoints = new CUserPoints(); $params->def('myKarma', $CUserPoints->getPointsImage($my)); $params->def('enablephotos', $config->get('enablephotos')); $params->def('enablevideos', $config->get('enablevideos')); $params->def('enablegroups', $config->get('enablegroups')); $params->def('enableevents', $config->get('enableevents')); $enablekarma = $config->get('enablekarma') ? $params->get('show_karma', 1) : $config->get('enablekarma'); $params->def('enablekarma', $enablekarma); $modHelloMeHelper = new modHelloMeHelper(); $COwnerHelper = new COwnerHelper(); $js = $modHelloMeHelper->getHelloMeScript($my->getStatus(), $COwnerHelper->isMine($my->id, $profileid)); $document = JFactory::getDocument(); $document->addScriptDeclaration($js); if ($params->get('enable_facebookconnect', '1')) { $params->def('facebookuser', $modHelloMeHelper->isFacebookUser()); } else { $params->def('facebookuser', false); } $unreadCount = $params->get('unreadCount', 1); $pending = $params->get('pending', 1); $myLink = $params->get('myLink', 1); $myName = $params->get('myName', 1); $myAvatar = $params->get('myAvatar', 1); $myId = $params->get('myId', 1); $myKarma = $params->get('myKarma', 1); $enablephotos = $params->get('enablephotos', 1);
public function isOwner() { $my = CFactory::getUser(); return COwnerHelper::isMine($my->id, $this->creator); }
$friendModel = CFactory::getModel('friends'); $profileid = JRequest::getVar('userid', 0, 'GET'); $params->def('unreadCount', $inboxModel->countUnRead($filter)); $params->def('pending', $friendModel->countPending($my->id)); $params->def('myLink', CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id)); $params->def('myName', $my->getDisplayName()); $params->def('myAvatar', $my->getAvatar()); $params->def('myId', $my->id); $params->def('myKarma', CUserPoints::getPointsImage($my)); $params->def('enablephotos', $config->get('enablephotos')); $params->def('enablevideos', $config->get('enablevideos')); $params->def('enablegroups', $config->get('enablegroups')); $params->def('enableevents', $config->get('enableevents')); $enablekarma = $config->get('enablekarma') ? $params->get('show_karma', 1) : $config->get('enablekarma'); $params->def('enablekarma', $enablekarma); $js = modHelloMeHelper::getHelloMeScript($my->getStatus(), COwnerHelper::isMine($my->id, $profileid)); $document = JFactory::getDocument(); $document->addScriptDeclaration($js); if ($params->get('enable_facebookconnect', '1')) { $params->def('facebookuser', modHelloMeHelper::isFacebookUser()); } else { $params->def('facebookuser', false); } CFactory::load('helpers', 'string'); $unreadCount = $params->get('unreadCount', 1); $pending = $params->get('pending', 1); $myLink = $params->get('myLink', 1); $myName = $params->get('myName', 1); $myAvatar = $params->get('myAvatar', 1); $myId = $params->get('myId', 1); $myKarma = $params->get('myKarma', 1);
public function _getMyGroupsHTML($userid = null) { $document = JFactory::getDocument(); $is_rtl = $document->direction == 'rtl' ? 'dir="rtl"' : ''; $html = ''; $groupsModel = CFactory::getModel('groups'); $my = CFactory::getUser($userid); $user = CFactory::getRequestUser(); $this->loadUserParams(); $params = $user->getParams(); // site visitor $relation = 10; // site members if ($my->id != 0) { $relation = 20; } // friends if (CFriendsHelper::isConnected($my->id, $user->id)) { $relation = 30; } // mine if (COwnerHelper::isMine($my->id, $user->id)) { $relation = 40; } if ($relation >= $params->get('privacyGroupsView')) { // count the groups $groups = $groupsModel->getGroups($user->id, 'latest', false); $total = count($groups); if ($this->params->get('hide_empty', 0) && !$total) { return ''; } $count = $this->userparams->get('count', $this->params->get('count', 10)); $groupsModel->setState('limit', $count); $groups = $groupsModel->getGroups($user->id, 'latest', false); if ($groups) { shuffle($groups); } ob_start(); ?> <?php if ($groups) { $i = 0; ?> <?php foreach ($groups as $group) { if ($i >= $count) { break; } $table = JTable::getInstance('Group', 'CTable'); $table->load($group->id); if ($table->unlisted && !$groupsModel->isMember($my->id, $table->id)) { continue; } $i++; ?> <div class="joms-stream__header"> <div class="joms-avatar--stream"> <a href="<?php echo CRoute::_('index.php?option=com_community&view=groups&groupid=' . $group->id . '&task=viewgroup'); ?> "> <img src="<?php echo $table->getThumbAvatar(); ?> " alt="<?php echo CStringHelper::escape($group->name); ?> " > </a> </div> <div class="joms-stream__meta"> <a class="joms-text--title" href="<?php echo CRoute::_('index.php?option=com_community&view=groups&groupid=' . $group->id . '&task=viewgroup'); ?> "> <?php echo $group->name; ?> </a> <a href="<?php echo CRoute::_("index.php?option=com_community&view=groups&task=viewmembers&groupid=" . $group->id); ?> " class="joms-block"><small> <?php echo JText::sprintf(!CStringHelper::isSingular($group->membercount) ? 'COM_COMMUNITY_GROUPS_MEMBERS_MANY' : 'COM_COMMUNITY_GROUPS_MEMBERS_SINGULAR', $group->membercount); ?> </small></a> </div> </div> <?php } ?> <?php } else { ?> <div><?php echo JText::_('COM_COMMUNITY_NO_GROUPS_YET'); ?> </div> <?php } if ($i < $total) { ?> <div class="joms-gap"></div> <a href="<?php echo CRoute::_('index.php?option=com_community&view=groups&task=mygroups&userid=' . $userid); ?> "> <span><?php echo JText::_('PLG_MYGROUPS_VIEWALL_GROUPS'); ?> </span> <span>(<?php echo $total; ?> )</span> </a> <?php } ?> <?php $html = ob_get_contents(); ob_end_clean(); } return $html; }
private function getVideoTags($video) { $tagging = new CVideoTagging(); $taggedList = $tagging->getTaggedList($video->id); $tags = array(); $my = CFactory::getUser(); for ($i = 0, $count = count($taggedList); $i < $count; $i++) { $tagItem = $taggedList[$i]; $tagUser = CFactory::getUser($tagItem->userid); // Check if user can remove tag. // 1st we check the tagged user is the photo owner. // If yes, canRemoveTag == true. // If no, then check on user is the tag creator or not. // If yes, canRemoveTag == true // If no, then check on user whether user is being tagged $canRemoveTag = 0; if (COwnerHelper::isMine($my->id, $video->creator) || COwnerHelper::isMine($my->id, $tagItem->created_by) || COwnerHelper::isMine($my->id, $tagItem->userid)) { $canRemoveTag = 1; } $tagItem->user = $tagUser; $tagItem->canRemoveTag = $canRemoveTag; $tags[] = array('id' => $tagItem->id, 'userId' => $tagItem->userid, 'displayName' => $tagItem->user->getDisplayName(), 'profileUrl' => CRoute::_('index.php?option=com_community&view=profile&userid=' . $tagItem->userid, false), 'canRemove' => $tagItem->canRemoveTag); } return $tags; }
<?php /** * @copyright (C) 2013 iJoomla, Inc. - All rights reserved. * @license GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html) * @author iJoomla.com <*****@*****.**> * @url https://www.jomsocial.com/license-agreement * The PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript *are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0 * More info at https://www.jomsocial.com/license-agreement */ defined('_JEXEC') or die; $isMine = COwnerHelper::isMine($my->id, $user->id); $avatar = $user->getAvatarInfo(); $loggedIn = $my->id != 0; $profileFields = ''; $themeModel = CFactory::getModel('theme'); $profileModel = CFactory::getModel('profile'); $settings = $themeModel->getSettings('profile'); $my = CFactory::getUser($profile->id); $config = CFactory::getConfig(); $featured = new CFeatured(FEATURED_USERS); $featuredList = $featured->getItemIds(); if (isset($settings['profile']['tagline']) && strlen($settings['profile']['tagline'])) { $blocks = json_decode($settings['profile']['tagline'], true); $blockEnabled = true; foreach ($blocks as $block) { $blockString = ""; if ($block['spacebefore']) { $blockString .= " "; } if (strlen($block['before'])) {
/** * Show the message reading window */ public function read($data) { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; if (!$this->accessAllowed('registered')) { return; } $config = CFactory::getConfig(); if (!$config->get('enablepm')) { echo JText::_('COM_COMMUNITY_PRIVATE_MESSAGING_DISABLED'); return; } //page title $document = JFactory::getDocument(); $inboxModel = CFactory::getModel('inbox'); $my = CFactory::getUser(); $msgid = $jinput->request->get('msgid', 0, 'INT'); if (!$inboxModel->canRead($my->id, $msgid)) { $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_PERMISSION_DENIED_WARNING'), 'error'); return; } $pathway = $mainframe->getPathway(); $pathway->addItem($this->escape(JText::_('COM_COMMUNITY_INBOX_TITLE')), CRoute::_('index.php?option=com_community&view=inbox')); $parentData = ''; $html = ''; $messageHeading = ''; $recipient = array(); $parentData = $inboxModel->getMessage($msgid); if (!empty($data->messages)) { $document = JFactory::getDocument(); $pathway->addItem($this->escape(htmlspecialchars_decode($parentData->subject))); $document->setTitle(htmlspecialchars_decode($parentData->subject)); require_once COMMUNITY_COM_PATH . '/libraries/apps.php'; $appsLib = CAppPlugins::getInstance(); $appsLib->loadApplications(); $config = CFactory::getConfig(); $pagination = intval($config->get('stream_default_comments', 5)); $count = count($data->messages); $hide = true; foreach ($data->messages as $row) { $count--; if ($count < $pagination) { $hide = false; } // onMessageDisplay Event trigger $args = array(); $originalBodyContent = $row->body; $row->body = new JRegistry($row->body); if ($row->body == '{}') { //backward compatibility, save the old data into content parameter if needed $newParam = new CParameter(); $newParam->set('content', $originalBodyContent); $table = JTable::getInstance('Message', 'CTable'); $table->load($row->id); $table->body = $newParam->toString(); $table->store(); $row->body = new CParameter($table->body); } // Escape content $content = $originalContent = $row->body->get('content'); $content = CTemplate::escape($content); $content = CStringHelper::autoLink($content); $content = nl2br($content); $content = CStringHelper::getEmoticon($content); $content = CStringHelper::converttagtolink($content); $content = CUserHelper::replaceAliasURL($content); $params = $row->body; $args[] = $row; $appsLib->triggerEvent('onMessageDisplay', $args); $user = CFactory::getUser($row->from); //construct the delete link $deleteLink = CRoute::_('index.php?option=com_community&view=inbox&task=remove&msgid=' . $row->id); $authorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id); //get thumbnail if available $photoThumbnail = ''; if ($params->get('attached_photo_id')) { $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($params->get('attached_photo_id')); $photoThumbnail = $photo->getThumbURI(); } $tmpl = new CTemplate(); $html .= $tmpl->set('user', $user)->set('msg', $row)->set('hide', $hide)->set('originalContent', $originalContent)->set('content', $content)->set('params', $params)->set('isMine', COwnerHelper::isMine($my->id, $user->id))->set('removeLink', $deleteLink)->set('authorLink', $authorLink)->set('photoThumbnail', $photoThumbnail)->fetch('inbox.message'); } $myLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id); $recipient = $inboxModel->getRecepientMessage($msgid); $recepientCount = count($recipient); $textOther = $recepientCount > 1 ? 'COM_COMMUNITY_MSG_OTHER' : 'COM_COMMUNITY_MSG_OTHER_SINGULAR'; $messageHeading = JText::sprintf('COM_COMMUNITY_MSG_BETWEEN_YOU_AND_USER', $myLink, '#', JText::sprintf($textOther, $recepientCount)); } else { $html = '<div class="text">' . JText::_('COM_COMMUNITY_INBOX_MESSAGE_EMPTY') . '</div>'; } //end if $tmplMain = new CTemplate(); echo $tmplMain->set('messageHeading', $messageHeading)->set('recipient', $recipient)->set('limit', $pagination)->set('messages', $data->messages)->set('parentData', $parentData)->set('htmlContent', $html)->set('my', $my)->set('submenu', $this->showSubmenu(false))->fetch('inbox.read'); }
public function isWallsAllowed($photoId) { $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($photoId); $config = CFactory::getConfig(); $isConnected = CFriendsHelper::isConnected($this->my->id, $photo->creator); $isMe = COwnerHelper::isMine($this->my->id, $photo->creator); // Check if user is really allowed to post walls on this photo. if ($isMe || !$config->get('lockphotoswalls') || $config->get('lockphotoswalls') && $isConnected || COwnerHelper::isCommunityAdmin()) { return true; } return false; }
public function _getMyFriendsHTML($userid = null) { $document = JFactory::getDocument(); $this->loadUserParams(); $count = $this->userparams->get('count', $this->params->get('count', 10)); $is_rtl = $document->direction == 'rtl' ? 'dir="rtl"' : ''; $html = ''; $friendsModel = CFactory::getModel('friends'); $my = CFactory::getUser($userid); $user = CFactory::getRequestUser(); $params = $user->getParams(); // site visitor $relation = 10; // site members if ($my->id != 0) { $relation = 20; } // friends if (CFriendsHelper::isConnected($my->id, $user->id)) { $relation = 30; } // mine if (COwnerHelper::isMine($my->id, $user->id)) { $relation = 40; } // @todo: respect privacy settings if ($relation >= $params->get('privacyFriendsView')) { $friends = $friendsModel->getFriends($user->id, 'latest', false, '', $count + $count); // randomize the friend count if ($friends) { shuffle($friends); } $total = $user->getFriendCount(); if ($this->params->get('hide_empty', 0) && !$total) { return ''; } ob_start(); ?> <?php if ($friends) { ?> <ul class='joms-list--thumbnail'> <?php for ($i = 0; $i < count($friends); $i++) { if ($i >= $count) { break; } $friend =& $friends[$i]; ?> <li class='joms-list__item'> <div class="joms-avatar <?php echo CUserHelper::onlineIndicator($friend); ?> "> <a href="<?php echo CRoute::_('index.php?option=com_community&view=profile&userid=' . $friend->id); ?> " > <img alt="<?php echo $friend->getDisplayName(); ?> " title="<?php echo $friend->getTooltip(); ?> " src="<?php echo $friend->getThumbAvatar(); ?> " data-author="<?php echo $friend->id; ?> " /> </a> </div> </li> <?php } ?> </ul> <?php } else { ?> <div class="cEmpty"><?php echo JText::_('COM_COMMUNITY_NO_FRIENDS_YET'); ?> </div> <?php } if ($total > $count) { ?> <div class="joms-gap"></div> <a href="<?php echo CRoute::_('index.php?option=com_community&view=friends&userid=' . $user->id); ?> "> <span><?php echo JText::_('COM_COMMUNITY_FRIENDS_VIEW_ALL'); ?> </span> <span <?php echo $is_rtl; ?> > (<?php echo $total; ?> )</span> </a> <?php } ?> <?php $html = ob_get_contents(); ob_end_clean(); } return $html; }
public function isAlbumOwner($albumId) { if ($this->my->id == 0) { return false; } $album = JTable::getInstance('Album', 'CTable'); $album->load($albumId); return COwnerHelper::isMine($this->my->id, $album->creator); }
public function isAlbumOwner($albumId) { CFactory::load('models', 'photos'); if ($this->my->id == 0) { return false; } $album =& JTable::getInstance('Album', 'CTable'); $album->load($albumId); return COwnerHelper::isMine($this->my->id, $album->creator); }