function onActivityContentDisplay($args) { $model =& CFactory::getModel('Wall'); $wall =& JTable::getInstance('Wall', 'CTable'); $my = CFactory::getUser(); if (empty($args->content)) { return ''; } $wall->load($args->cid); CFactory::load('libraries', 'privacy'); CFactory::load('libraries', 'comment'); $comment = CComment::stripCommentData($wall->comment); $config = CFactory::getConfig(); $commentcut = false; if (strlen($comment) > $config->getInt('streamcontentlength')) { $origcomment = $comment; $comment = JString::substr($comment, 0, $config->getInt('streamcontentlength')) . ' ...'; $commentcut = true; } if (CPrivacy::isAccessAllowed($my->id, $args->target, 'user', 'privacyProfileView')) { CFactory::load('helpers', 'videos'); CFactory::load('libraries', 'videos'); CFactory::load('libraries', 'wall'); $videoContent = ''; $params = new CParameter($args->params); $videoLink = $params->get('videolink'); $image = $params->get('url'); // For older activities that does not have videoLink , we need to process it the old way. if (!$videoLink) { $html = CWallLibrary::_processWallContent($comment); $tmpl = new CTemplate(); $html = CStringHelper::escape($html); if ($commentcut) { //add read more/less link for content $html .= '<br /><br /><a href="javascript:void(0)" onclick="jQuery(\'#shortcomment_' . $args->cid . '\').hide(); jQuery(\'#origcomment_' . $args->cid . '\').show();" >' . JText::_('COM_COMMUNITY_READ_MORE') . '</a>'; $html = '<div id="shortcomment_' . $args->cid . '">' . $html . '</div>'; $html .= '<div id="origcomment_' . $args->cid . '" style="display:none;">' . $origcomment . '<br /><br /><a href="javascript:void(0);" onclick="jQuery(\'#shortcomment_' . $args->cid . '\').show(); jQuery(\'#origcomment_' . $args->cid . '\').hide();" >' . JText::_('COM_COMMUNITY_READ_LESS') . '</a></div>'; } $tmpl->set('comment', $html); $html = $tmpl->fetch('activity.wall.post'); } else { $html = '<ul class ="cDetailList clrfix">'; $html .= '<li>'; $image = !$image ? rtrim(JURI::root(), '/') . '/components/com_community/assets/playvideo.gif' : $image; $videoLib = new CVideoLibrary(); $provider = $videoLib->getProvider($videoLink); $html .= '<!-- avatar --><div class="avatarWrap"><a href="javascript:void(0);" onclick="joms.activities.showVideo(\'' . $args->id . '\');"><img width="64" src="' . $image . '" class="cAvatar"/></a></div><!-- avatar -->'; $videoPlayer = $provider->getViewHTML($provider->getId(), '300', '300'); $comment = CString::str_ireplace($videoLink, '', $comment); $html .= '<!-- details --><div class="detailWrap alpha">' . $comment . '</div><!-- details -->'; if (!empty($videoPlayer)) { $html .= '<div style="display: none;clear: both;padding-top: 5px;" class="video-object">' . $videoPlayer . '</div>'; } $html .= '</li>'; $html .= '</ul>'; } return $html; } }
public static function friendsView($userId, $assetId) { $accesAllowed = CPrivacy::isAccessAllowed($userId, $assetId, 'user', 'privacyFriendsView'); if (!$accesAllowed || $userId == 0 && $assetId == 0) { return false; } return true; }
/** * Get content for activity based on the activity id. * * @params $activityId Int Activity id **/ public function ajaxGetContent($activityId) { $my = CFactory::getUser(); $showMore = true; $objResponse = new JAXResponse(); $model = CFactory::getModel('Activities'); CFactory::load('libraries', 'privacy'); CFactory::load('libraries', 'activities'); // These core apps has default privacy issues with it $coreapps = array('photos', 'walls', 'videos', 'groups'); // make sure current user has access to the content item // For known apps, we can filter this manually $activity = $model->getActivity($activityId); if (in_array($activity->app, $coreapps)) { CFactory::load('helpers', 'privacy'); switch ($activity->app) { case 'walls': // make sure current user has permission to the profile $showMore = CPrivacy::isAccessAllowed($my->id, $activity->target, 'user', 'privacyProfileView'); break; case 'videos': // Each video has its own privacy setting within the video itself CFactory::load('models', 'videos'); $video = JTable::getInstance('Video', 'CTable'); $video->load($activity->cid); $showMore = CPrivacy::isAccessAllowed($my->id, $activity->actor, 'custom', $video->permissions); break; case 'photos': // for photos, we uses the actor since the target is 0 and he // is doing the action himself $showMore = CPrivacy::isAccessAllowed($my->id, $activity->actor, 'user', 'privacyPhotoView'); break; case 'groups': } } else { // if it is not one of the core apps, we should allow plugins to decide // if they want to block the 'more' view } if ($showMore) { $act = $model->getActivity($activityId); $content = CActivityStream::getActivityContent($act); $objResponse->addScriptCall('joms.activities.setContent', $activityId, $content); } else { $content = JText::_('CC ACCESS FORBIDDEN'); $content = nl2br($content); $content = JString::str_ireplace("\n", '', $content); $objResponse->addScriptCall('joms.activities.setContent', $activityId, $content); } $objResponse->addScriptCall('joms.tooltip.setup();'); return $objResponse->sendResponse(); }
/** * View all friends. Could be current user, if $_GET['id'] is not defined * otherise, show your own friends */ public function friends() { CFactory::load('libraries', 'privacy'); $document =& JFactory::getDocument(); $my =& JFactory::getUser(); $viewType = $document->getType(); $tagsFriends = JRequest::getVar('tags', '', 'GET'); $view =& $this->getView('friends', '', $viewType); $model =& $this->getModel('friends'); // Get the friend id to be displayed $id = JRequest::getCmd('userid', $my->id); // Check privacy setting $accesAllowed = CPrivacy::isAccessAllowed($my->id, $id, 'user', 'privacyFriendsView'); if (!$accesAllowed || $my->id == 0 && $id == 0) { $this->blockUnregister(); return; } $data = new stdClass(); echo $view->get('friends'); }
/** * Ajax function to save a new wall entry * * @param message A message that is submitted by the user * @param uniqueId The unique id for this group * **/ function onProfileDisplay() { JPlugin::loadLanguage('plg_community_mytaggedvideos', JPATH_ADMINISTRATOR); $mainframe = JFactory::getApplication(); // Attach CSS $document = JFactory::getDocument(); // $css = JURI::base() . 'plugins/community/myvideos/style.css'; // $document->addStyleSheet($css); $user = CFactory::getRequestUser(); $userid = $user->id; $this->loadUserParams(); $limit = $this->params->get('count', 6); $limitstart = JRequest::getVar('limitstart', 0, 'REQUEST'); $row = $this->getVideos($userid); $total = count($row); //we must filter the results $results = array(); $limitCount = 0; foreach ($row as $result) { if (!CPrivacy::isAccessAllowed($this->_my->id, $userid, 'custom', $result->permissions)) { continue; } $results[] = $result; if (++$limit == $limitCount) { break; } } if ($this->params->get('hide_empty', 0) && !$total) { return ''; } $caching = $this->params->get('cache', 1); if ($caching) { $caching = $mainframe->getCfg('caching'); } $cache = JFactory::getCache('plgCommunityMyTaggedVideos'); $cache->setCaching($caching); $callback = array('plgCommunityMyTaggedVideos', '_getLatestVideosHTML'); $content = $cache->call($callback, $userid, $this->userparams->get('count', 5), $limitstart, $results, $total); return $content; }
public function isAlbumBrowsable($albumId) { $mainframe = JFactory::getApplication(); $album = JTable::getInstance('Album', 'CTable'); $album->load($albumId); $my = CFactory::getUser(); /* Community Admin can access anywhere */ if (COwnerHelper::isCommunityAdmin($my->id)) { return true; } if ($this->user->block && !COwnerHelper::isCommunityAdmin($my->id)) { $mainframe->redirect('index.php?option=com_community&view=photos', JText::_('COM_COMMUNITY_PHOTOS_USER_ACCOUNT_IS_BANNED')); return false; } //owner can always access if ($album->creator == $this->my->id) { return true; } //if( !CPrivacy::isAccessAllowed($this->my->id, $this->user->id, 'user', 'privacyPhotoView') || $album->creator != $this->user->id ) if (!CPrivacy::isAccessAllowed($this->my->id, $this->user->id, 'custom', $album->permissions)) { $this->noAccess(); return false; } else { return true; } return false; }
/** get field value of $userId accordimg to $fieldCode */ public function getInfo($userId, $fieldCode) { // Run Query to return 1 value $db = JFactory::getDBO(); $query = 'SELECT b.* FROM ' . $db->nameQuote('#__community_fields') . ' AS a ' . 'INNER JOIN ' . $db->nameQuote('#__community_fields_values') . ' AS b ' . 'ON b.' . $db->nameQuote('field_id') . '=a.' . $db->nameQuote('id') . ' ' . 'AND b.' . $db->nameQuote('user_id') . '=' . $db->Quote($userId) . ' ' . 'INNER JOIN ' . $db->nameQuote('#__community_users') . ' AS c ' . 'ON c.' . $db->nameQuote('userid') . '= b.' . $db->nameQuote('user_id') . 'WHERE a.' . $db->nameQuote('fieldcode') . ' =' . $db->Quote($fieldCode); $db->setQuery($query); $result = $db->loadObject(); $field = JTable::getInstance('FieldValue', 'CTable'); $field->bind($result); if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); } $config = CFactory::getConfig(); // @rule: Only trigger 3rd party apps whenever they override extendeduserinfo configs if ($config->getBool('extendeduserinfo')) { CFactory::load('libraries', 'apps'); $apps = CAppPlugins::getInstance(); $apps->loadApplications(); $params = array(); $params[] = $fieldCode; $params[] =& $field->value; $apps->triggerEvent('onGetUserInfo', $params); } // Respect privacy settings. if (!XIPT_JOOMLA_15) { $my = CFactory::getUser(); CFactory::load('libraries', 'privacy'); if (!CPrivacy::isAccessAllowed($my->id, $userId, 'custom', $field->access)) { return false; } } return $field->value; }
public function checkPhotoAccess($albumid = null, $photoid = null) { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $config = CFactory::getConfig(); $userId = $jinput->get('userid'); $groupId = $jinput->get('groupid'); $my = CFactory::getUser(); if ($userId) { $creator = CFactory::getuser($userId); $creatorId = $creator->id; } if ($albumid) { $album = JTable::getInstance('Album', 'CTable'); $album->load($albumid); $creatorId = $album->creator; } if ($photoid) { $photo = JTable::getINstance('Photo', 'CTable'); $photo->load($photoid); $creatorId = $photo->creator; } // check privacy $allowed = true; // default privacy levels if (isset($creatorId) && !$groupId) { if (isset($album) && $album->permission <= 10) { return true; } else { if (!CPrivacy::isAccessAllowed($my->id, $creatorId, 'privacyPhotoView', 'privacyPhotoView')) { $allowed = false; } } } elseif (isset($groupId) && $groupId) { $group = JTable::getInstance('Group', 'CTable'); $group->load($group); if ($group->approvals == 1 && !$group->isMember($my->id) && !COwnerHelper::isCommunityAdmin()) { $allowed = false; } else { $allowed = true; } } if (!$allowed) { echo "<div class=\"cEmpty cAlert\">" . JText::_('COM_COMMUNITY_PRIVACY_ERROR_MSG') . "</div>"; return; } if (!$config->get('enablephotos')) { $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_PHOTOS_DISABLED'), ''); return false; } return true; }
function _userAlbum() { $mainframe =& JFactory::getApplication(); $document =& JFactory::getDocument(); // Get the configuration object. $config = CFactory::getConfig(); // Get necessary properties and load the libraries CFactory::load('models', 'photos'); CFactory::load('helpers', 'friends'); CFactory::load('helpers', 'privacy'); $my = CFactory::getUser(); $userid = JRequest::getInt('userid', ''); $user = CFactory::getUser($userid); if (!$user->block || COwnerHelper::isCommunityAdmin($my->id)) { $model = CFactory::getModel('photos'); $albumId = JRequest::getVar('albumid', '', 'GET'); $defaultId = JRequest::getVar('photo', '', 'GET'); // Show the mini header when viewing other's photos if ($my->id != $user->id) { $this->attachMiniHeaderUser($user->id); } // Load the album table $album =& JTable::getInstance('Album', 'CTable'); $album->load($albumId); $albumCreator = CFactory::getUser($album->creator); CFactory::load('helpers', 'owner'); CFactory::load('libraries', 'privacy'); if (empty($albumId) || $album->creator != $user->id && !COwnerHelper::isCommunityAdmin()) { echo JText::_('CC NO PROPER ALBUM ID'); return; } // Get list of photos and set some limit to be displayed. // @todo: make limit configurable? $photos = $model->getAllPhotos($albumId, PHOTOS_USER_TYPE, null, null, COMMUNITY_ORDER_BY_DESC, COMMUNITY_ORDERING_BY_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 = CRoute::_('index.php?option=com_community&view=photos&task=photo&userid=' . $user->id . '&albumid=' . $photo->albumid) . '#photoid=' . $photo->id; } // Set document title CFactory::load('helpers', 'string'); $document->setTitle(JText::sprintf('CC USER PHOTOS TITLE', $user->getDisplayName()) . ' - ' . $album->name); $this->setTitle($album->name); if (!CPrivacy::isAccessAllowed($my->id, $user->id, 'user', 'privacyPhotoView')) { echo JText::_('CC ACCESS FORBIDDEN'); return; } $guidData = array(); for ($i = 0; $i < 20 && $i < count($photos); $i++) { $photo = $photos[$i]; $item = new JFeedItem(); $item->title = $photo->caption; $item->link = CRoute::_('index.php?option=com_community&view=photos&task=photo&userid=' . $album->creator . '&albumid=' . $album->id) . '#photoid=' . $photo->id; $item->description = '<img src="' . $photo->getImageURI() . '" width="320"/>'; $item->date = $photo->created; $item->source = $photo->getImageURI(); //$item->author = $albumAuthor->getDisplayName(); // inject guid with unique data to be replaced later $item->guid = 'photo-' . rand(); $media = '<media:content expression="full" type="image/jpg" url="' . htmlspecialchars($photo->getImageURI(), ENT_COMPAT, 'UTF-8') . '">'; $media .= '<media:description />'; $media .= '<media:rating scheme="urn:simple">nonadult</media:rating>'; $media .= '<media:adult>false</media:adult>'; $media .= '<media:thumbnail url="' . htmlspecialchars($photo->getThumbURI(), ENT_COMPAT, 'UTF-8') . '" width="64" height="64" />'; $media .= '<media:title>ki1.jpg</media:title>'; $media .= '</media:content>'; $guidData['<guid>' . $item->guid . '</guid>'] = $media; $document->addItem($item); } $content = $document->render(); foreach ($guidData as $key => $val) { $content = str_replace($key, $val, $content); } // Add media namespace declaration $content = str_replace('<rss ', '<rss xmlns:media="http://search.yahoo.com/mrss/" ', $content); echo $content; exit; } else { $mainframe->redirect('index.php?option=com_community&view=photos', JText::_('CC USER ACCOUNT IS BANNED')); } }
/** * Method to display groups that belongs to a user. * * @access public */ public function mygroups($userid) { $mainframe =& JFactory::getApplication(); $document = JFactory::getDocument(); //$userid = JRequest::getInt('userid', null ); $user = CFactory::getUser($userid); $my = CFactory::getUser(); // Respect profile privacy setting. CFactory::load('libraries', 'privacy'); if (!CPrivacy::isAccessAllowed($my->id, $user->id, 'user', 'privacyGroupsView')) { echo JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN'); return; } $title = $my->id == $user->id ? JText::_('COM_COMMUNITY_GROUPS_MY_GROUPS') : JText::sprintf('COM_COMMUNITY_GROUPS_USER_TITLE', $user->getDisplayName()); $document->setTitle($title); // Add the miniheader if necessary if ($my->id != $user->id) { $this->attachMiniHeaderUser($user->id); } // Load required filterbar library that will be used to display the filtering and sorting. CFactory::load('libraries', 'filterbar'); $this->addPathway(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups')); $this->addPathway(JText::_('COM_COMMUNITY_GROUPS_MY_GROUPS'), ''); $this->showSubmenu(); $uri = JURI::base(); //@todo: make mygroups page to contain several admin tools for owner? $groupsModel = CFactory::getModel('groups'); $avatarModel = CFactory::getModel('avatar'); $wallsModel = CFactory::getModel('wall'); $activityModel = CFactory::getModel('activities'); $discussionModel = CFactory::getModel('discussions'); $sorted = JRequest::getVar('sort', 'latest', 'GET'); // @todo: proper check with CError::assertion // Make sure the sort value is not other than the array keys $groups = $groupsModel->getGroups($user->id, $sorted); $pagination = $groupsModel->getPagination(count($groups)); require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'activities.php'; $act = new CActivityStream(); // Attach additional properties that the group might have $groupIds = ''; if ($groups) { foreach ($groups as $group) { $groupIds = empty($groupIds) ? $group->id : $groupIds . ',' . $group->id; } } // Get the template for the group lists $groupsHTML = $this->_getGroupsHTML($groups, $pagination); $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=mygroups&userid=' . $userid . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_LATEST_MY_GROUPS_FEED') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewmylatestdiscussions&groupids=' . $groupIds . '&userid=' . $userid . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_LATEST_MY_GROUP_DISCUSSIONS_FEED') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $pendingListHTML = $this->_getPendingListHTML($my->id); $sortItems = array('latest' => JText::_('COM_COMMUNITY_GROUPS_SORT_LATEST'), 'alphabetical' => JText::_('COM_COMMUNITY_SORT_ALPHABETICAL'), 'mostactive' => JText::_('COM_COMMUNITY_GROUPS_SORT_MOST_ACTIVE')); $tmpl = new CTemplate(); echo $tmpl->set('groupsHTML', $groupsHTML)->set('pendingListHTML', $pendingListHTML)->set('pagination', $pagination)->set('my', $my)->set('sortings', CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest'))->set('discussionsHTML', $this->modUserDiscussion($user->id))->fetch('groups.mygroups'); }
<?php if ($groupName != 'ungrouped') { ?> <li><h4 class="joms-text--title joms-text--bold"><?php echo JText::_($groupName); ?> </h4></li> <?php } ?> <?php foreach ($items as $item) { ?> <?php if (CPrivacy::isAccessAllowed($my->id, $profile['id'], 'custom', $item['access'])) { // There is some displayable data here $hasData = $hasData || CProfileLibrary::getFieldData($item) != ''; ?> <?php $fieldData = CProfileLibrary::getFieldData($item); // Escape unless it is URL type, since URL type is in HTML format if ($item['type'] != 'url' && $item['type'] != 'email' && $item['type'] != 'list' && $item['type'] != 'checkbox') { $fieldData = $this->escape($fieldData); } // If textarea, we need to support multiline entry if ($item['type'] == 'textarea') { $fieldData = nl2br($fieldData); } if (!empty($fieldData)) {
/** * 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) { return CPrivacy::isAccessAllowed($myid, $userid, 'custom', $permissions); }
public function ajaxShowVideoFeatured($video_id) { $objResponse = new JAXResponse(); $allowToView = true; //determine the view premission $my = CFactory::getUser(); $video = JTable::getInstance('Video', 'CTable'); if (!$video->load($video_id)) { $allowToView = false; } /* === Start Premission Checking === */ $user = CFactory::getUser($video->creator); $blocked = $user->isBlocked(); if ($blocked && !COwnerHelper::isCommunityAdmin()) { $allowToView = false; } if ($video->creator_type == VIDEO_GROUP_TYPE) { //CFactory::load( 'helpers' , 'group' ); if (!CGroupHelper::allowViewMedia($video->groupid)) { $allowToView = false; } } else { if (!CPrivacy::isAccessAllowed($my->id, $video->creator, 'custom', $video->permissions)) { switch ($video->permissions) { case '40': $allowToView = false; break; case '30': $allowToView = false; $this->noAccess(JText::sprintf('COM_COMMUNITY_VIDEOS_FRIEND_PERMISSION_MESSAGE', $owner->getDisplayName())); break; default: $allowToView = false; break; } } } /* === End Permission Checking === */ if ($allowToView) { // Hit counter + 1 $video->hit(); $notiHtml = '<div class="cVideo-Player video-player"> ' . $video->getPlayerHTML() . ' </div>'; } else { $notiHtml = JText::_('COM_COMMUNITY_VIDEO_UNABLE_VIEW'); } // Get like //CFactory::load( 'libraries' , 'like' ); $likes = new CLike(); $likesHTML = $likes->getHTML('videos', $video->id, $my->id); // Get wall count //CFactory::load( 'libraries' , 'wall' ); $wallCount = CWallLibrary::getWallCount('videos', $video->id); // Get video link $videoCommentLink = CRoute::_('index.php?option=com_community&view=videos&task=video&videoid=' . $video->id . '&groupid=' . $video->groupid . '&userid=' . $video->creator . '#comments'); $videoLink = CRoute::_('index.php?option=com_community&view=videos&task=video&videoid=' . $video->id . '&groupid=' . $video->groupid . '&userid=' . $video->creator); $creatorName = $video->getCreatorName(); $creatorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $video->creator); $objResponse->addScriptCall('updatePlayer', $notiHtml, $video->title, $likesHTML, $video->getHits(), $wallCount, $videoLink, $videoCommentLink, $creatorName, $creatorLink); $objResponse->sendResponse(); }
public function mutualFriends() { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $document = JFactory::getDocument(); $my = CFactory::getUser(); $viewType = $document->getType(); $tagsFriends = $jinput->get->get('tags', '', 'NONE'); $view = $this->getView('friends', '', $viewType); $model = $this->getModel('friends'); // Get the friend id to be displayed $id = JRequest::getCmd('userid', $my->id); // Check privacy setting $accesAllowed = CPrivacy::isAccessAllowed($my->id, $id, 'user', 'privacyFriendsView'); if (!$accesAllowed || $my->id == 0 && $id == 0) { $this->blockUnregister(); return; } $data = new stdClass(); echo $view->get('friends'); }
/** * 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) { CFactory::load('libraries', 'privacy'); return CPrivacy::isAccessAllowed($myid, $userid, 'custom', $permissions); }
public function isAlbumBrowsable($albumId) { CFactory::load('libraries', 'privacy'); $mainframe =& JFactory::getApplication(); $album =& JTable::getInstance('Album', 'CTable'); $album->load($albumId); if ($this->user->block && !COwnerHelper::isCommunityAdmin($this->my->id)) { $mainframe->redirect('index.php?option=com_community&view=photos', JText::_('CC USER ACCOUNT IS BANNED')); return false; } if (!CPrivacy::isAccessAllowed($this->my->id, $this->user->id, 'user', 'privacyPhotoView') || $album->creator != $this->user->id) { $this->noAccess(); return false; } return true; }