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; }
/** * * @param type $params * @return type */ public static function getList(&$params) { $user = CFactory::getUser(); $db = JFactory::getDBO(); $extraQuery = ''; switch ($params->get('album_type', 0)) { case 1: //profile albums $extraQuery = " AND c." . $db->quoteName('type') . " LIKE '%profile%'"; break; case 2: //group albums $extraQuery = ' AND c.' . $db->quoteName('type') . ' LIKE ' . $db->quote('%group%'); break; case 3: //event albums $extraQuery = ' AND c.' . $db->quoteName('type') . ' LIKE ' . $db->quote('%event%'); break; default: //all albums } /* Do query */ $query = 'SELECT a.*,b.*,c.' . $db->quoteName('type') . ' as phototype,c.' . $db->quoteName('groupid') . ' FROM ' . $db->quoteName('#__community_wall') . ' AS a ' . ' INNER JOIN ' . $db->quoteName('#__community_photos') . ' AS b ' . ' ON a.' . $db->quoteName('contentid') . '=b.' . $db->quoteName('id') . ' INNER JOIN ' . $db->quoteName('#__community_photos_albums') . ' AS c ' . ' ON b.' . $db->quoteName('albumid') . '=c.' . $db->quoteName('id') . ' WHERE a.' . $db->quoteName('type') . ' =' . $db->Quote('photos') . $extraQuery . ' ORDER BY a.' . $db->quoteName('date') . ' DESC '; $db->setQuery($query); $comments = $db->loadObjectList(); //Once results are loaded, filter the count and the user premission level $counter = $params->get('limit', 10); $data = array(); foreach ($comments as $comment) { /* permission checking */ $permission = CPrivacy::getAccessLevel($user->id, $comment->creator); if ($permission >= $comment->permissions) { $data[] = $comment; if (--$counter == 0) { break; } } } return $data; }
/** * * @param type $params * @return type */ public static function getList(&$params) { $my = CFactory::getUser(); /* Do query */ $db = JFactory::getDBO(); $query = 'SELECT * FROM ' . $db->quoteName('#__community_wall') . ' AS a ' . ' INNER JOIN ' . $db->quoteName('#__community_videos') . ' AS b ' . ' ON a.' . $db->quoteName('contentid') . '=b.' . $db->quoteName('id') . ' WHERE a.' . $db->quoteName('type') . ' =' . $db->Quote('videos') . 'AND b.' . $db->quoteName('status') . ' =' . $db->Quote('ready') . 'ORDER BY a.' . $db->quoteName('date') . ' DESC '; $db->setQuery($query); $comments = $db->loadObjectList(); //Once results are loaded, filter the count and the user premission level $counter = $params->get('count', 5); $data = array(); foreach ($comments as $key => $comment) { /* permission checking */ $permission = CPrivacy::getAccessLevel($my->id, $comment->creator); if ($permission >= $comment->permissions) { $data[] = $comment; if (--$counter == 0) { break; } } } return $data; }
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'); }
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 } ?> <?php if ($config->get('enablegroups')) { ?> <div class="joms-form__group"> <span><?php echo JText::_('COM_COMMUNITY_PRIVACY_GROUPS_FIELD'); ?> </span> <?php echo CPrivacy::getHTML('privacyGroupsView', $params->get('privacyGroupsView'), COMMUNITY_PRIVACY_BUTTON_LARGE); ?> </div> <?php } ?> <?php if ($config->get('privacy_search_email') == 1) { ?> <div class="joms-form__group"> <span></span> <label class="joms-checkbox"> <input type="checkbox" class="joms-checkbox" name="search_email" value="1" <?php if ($my->get('_search_email') == 1) {
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; }
/** * 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); }
echo $f->id; ?> " class="label"><?php if ($f->required == 1) { echo '*'; } echo JText::_($f->name); ?> </label></td> <td class="value"><?php echo CProfileLibrary::getFieldHTML($f, ''); ?> </td> <td class="privacy"> <?php echo CPrivacy::getHTML('privacy' . $f->id, $f->access); ?> </td> </tr> <?php } ?> </tbody> </table> <?php } ?> <table class="formtable" cellspacing="1" cellpadding="0"> <tr> <td class="key"></td> <td class="value"><span class="hints"><?php
public function getVideos($userid, $limitstart, $limit) { $photoType = PHOTOS_USER_TYPE; //privacy settings //CFactory::load('libraries', 'privacy'); $permission = CPrivacy::getAccessLevel($this->_my->id, $userid); //get videos from the user //CFactory::load('models', 'videos'); $model = CFactory::getModel('Videos'); if ($this->_my->id == $userid || COwnerHelper::isCommunityAdmin()) { $permission = 40; } elseif (CFriendsHelper::isConnected($this->_my->id, $userid)) { $permission = 30; } elseif ($this->_my->id != 0) { $permission = 20; } else { $permission = 10; } $videos = $model->getUserTotalVideos($userid, $permission); return $videos; }
public function _getOnlyAlbums($id, $type, $limitstart = "", $limit = "") { $db =& $this->getDBO(); $extraSQL = ' WHERE a.type = ' . $db->Quote($type); $extraSQL .= ' AND a.creator=' . $db->Quote($id) . ' '; // privacy CFactory::load('libraries', 'privacy'); $permission = CPrivacy::getAccessLevel(null, $id); $extraSQL .= ' AND a.permissions <=' . $db->Quote($permission) . ' '; // Get limit $limit = $limit !== '' ? $limit : ''; $limitstart = $limitstart !== '' ? $limitstart : ''; // Get total albums $total = $this->getAlbumCount($extraSQL); $this->total = $total; $extraSQL .= ' AND b.published =' . $db->Quote(1) . ' '; $result = $limit === '' || $limitstart === '' ? $this->getAlbumPhotoCount($extraSQL) : $this->getAlbumPhotoCount($extraSQL, $limit, $limitstart); /* filter results, album that has photos + all unpublished = not to be displayed * album that has no photos = display */ foreach ($result as $key => $res) { if ($res->count <= 0) { unset($result[$key]); } } // Update their correct Thumbnails $this->_updateThumbnail($result); return $result; }
/** * * @param type $userid * @param type $limitstart * @param type $limit * @return type */ public function getPhotos($userid, $limitstart, $limit) { $photoType = PHOTOS_USER_TYPE; //privacy settings //CFactory::load('libraries', 'privacy'); $permission = CPrivacy::getAccessLevel($this->_my->id, $userid); $sql = "\tSELECT\n\t\t\t\t\t\t\t\ta.id\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t" . $this->db->quoteName('#__community_photos') . " AS a\n\t\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\t\t\t" . $this->db->quoteName('#__community_photos_albums') . " AS b ON a.`albumid` = b.`id`\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\ta." . $this->db->quoteName('creator') . " = " . $this->db->quote($userid) . " AND\n\t\t\t\t\t\t\t\tb." . $this->db->quoteName('type') . " = " . $this->db->quote($photoType) . " AND\n\t\t\t\t\t\t\t\ta." . $this->db->quoteName('published') . "=" . $this->db->quote(1) . " AND\n\t\t\t\t\t\t\t\tb.permissions <=" . $this->db->quote($permission) . "\n\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\ta." . $this->db->quoteName('created') . " DESC\n\t\t\t\t\t\tLIMIT\n\t\t\t\t\t\t\t\t" . $limitstart . "," . $limit; $query = $this->db->setQuery($sql); $row = $this->db->loadObjectList(); if ($this->db->getErrorNum()) { JError::raiseError(500, $this->db->stderr()); } return $row; }
public function ajaxEditVideo($id) { $response = new JAXResponse(); $model = $this->getModel('videoscategories'); $config = CFactory::getConfig(); $categories = $model->getCategories(); $video = JTable::getInstance('Video', 'CTable'); $video->load($id); $video->title = CStringHelper::escape($video->title); $video->description = CStringHelper::escape($video->description); ob_start(); ?> <form name="editvideo" action="" method="post" id="editvideo"> <div style="background-color: #F9F9F9; border: 1px solid #D5D5D5; margin-bottom: 10px; padding: 5px;font-weight: bold;"> <?php echo JText::_('Edit Video Detail'); ?> </div> <table cellspacing="0" class="admintable" border="0" width="100%"> <tbody> <tr> <td class="key" valign="top"><?php echo JText::_('COM_COMMUNITY_TITLE'); ?> </td> <td><input type="text" id="title" name="title" class="input text" value="<?php echo $video->title; ?> " style="width: 90%;" maxlength="255"/></tD> </tr> <tr> <td class="key"><?php echo JText::_('COM_COMMUNITY_DESCRIPTION'); ?> </td> <td><textarea name="description" style="width: 90%;" rows="8" id="description"><?php echo $video->description; ?> </textarea></td> </tr> <tr> <td class="key"><?php echo JText::_('COM_COMMUNITY_CATEGORY'); ?> </td> <td> <select name="category_id"> <?php for ($i = 0; $i < count($categories); $i++) { $selected = $video->category_id == $categories[$i]->id ? ' selected="selected"' : ''; ?> <option value="<?php echo $categories[$i]->id; ?> "<?php echo $selected; ?> ><?php echo $categories[$i]->name; ?> </option> <?php } ?> </select> </td> </tr> <?php if ($config->get('videosmapdefault')) { ?> <tr> <td class="key"><?php echo JText::_('COM_COMMUNITY_CONFIGURATION_LOCATION'); ?> </td> <td><input type="text" id="title" name="location" class="input text" value="<?php echo $video->location; ?> " style="width: 90%;"/></td> </tr> <?php } ?> <tr> <td class="key"><?php echo JText::_('COM_COMMUNITY_VIDEOS_WHO_CAN_SEE'); ?> </td> <td><?php echo CPrivacy::getHTML('permissions', $video->permissions, COMMUNITY_PRIVACY_BUTTON_LARGE, null, 'select'); ?> </td> </tr> </tbody> </table> <input type="hidden" name="id" value="<?php echo $video->id; ?> "/> <input type="hidden" name="option" value="com_community"/> <input type="hidden" name="task" value="savevideos"/> <input type="hidden" name="view" value="videos"/> <?php $contents = ob_get_contents(); ob_end_clean(); $response->addAssign('cWindowContent', 'innerHTML', $contents); $action = '<input type="button" class="btn btn-small btn-info pull-right" onclick="azcommunity.saveVideo();" name="' . JText::_('COM_COMMUNITY_SAVE') . '" value="' . JText::_('COM_COMMUNITY_SAVE') . '" />'; $action .= ' <input type="button" class="btn btn-small pull-left" onclick="cWindowHide();" name="' . JText::_('COM_COMMUNITY_CLOSE') . '" value="' . JText::_('COM_COMMUNITY_CLOSE') . '" />'; $response->addScriptCall('cWindowActions', $action); return $response->sendResponse(); }
"> </div> <?php } ?> <?php if ($showPrivacy) { ?> <div class="joms-form__group"> <span><?php echo JText::_('COM_COMMUNITY_VIDEOS_WHO_CAN_SEE'); ?> </span> <?php echo CPrivacy::getHTML('permissions', $video->permissions, COMMUNITY_PRIVACY_BUTTON_LARGE, $isStreamVideo ? array('public' => true) : array(), 'select'); ?> </div> <?php } ?> <div class="joms-form__group"> <span></span> <input type="hidden" name="id" value="<?php echo $video->id; ?> "> <input type="hidden" name="option" value="com_community"> <input type="hidden" name="view" value="videos"> <input type="hidden" name="task" value="saveVideo">
"> </div> <?php } ?> <?php if ($showPrivacy) { ?> <div class="joms-form__group"> <span><?php echo JText::_('COM_COMMUNITY_VIDEOS_WHO_CAN_SEE'); ?> </span> <?php echo CPrivacy::getHTML('permissions', $video->permissions, COMMUNITY_PRIVACY_BUTTON_LARGE, array(), 'select'); ?> </div> <?php } ?> <div class="joms-form__group"> <span></span> <input type="hidden" name="id" value="<?php echo $video->id; ?> "> <input type="hidden" name="option" value="com_community"> <input type="hidden" name="view" value="videos"> <input type="hidden" name="task" value="saveVideo">
echo $field->id; ?> " class="label"><?php if ($field->required == 1) { echo '*'; } echo JText::_($field->name); ?> </label></td> <td class="value"><?php echo $html; ?> </td> <td class="js_PriCell"> <?php echo CPrivacy::getHTML('privacy' . $field->id); ?> </td> </tr> <?php } ?> </tbody> </table> <?php } ?> <table class="ccontentTable" cellspacing="3" cellpadding="0"> <tbody> <?php
/** * 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); }
</div> </li> <?php if ($creatorType != VIDEO_GROUP_TYPE) { ?> <li> <label> <?php echo JText::_('COM_COMMUNITY_VIDEOS_WHO_CAN_SEE'); ?> </label> <div class="form-field"> <?php echo CPrivacy::getHTML('permissions', $permissions, COMMUNITY_PRIVACY_BUTTON_LARGE, array(), 't'); ?> </div> </li> <?php } ?> <li> <div class="form-field"> <div class="form-helper"><?php echo JText::_('COM_COMMUNITY_REGISTER_REQUIRED_FILEDS'); ?> </div> <?php
</span> </td> </tr> <?php if ($showPrivacy) { ?> <tr> <td class="key"><label class="label" for="description"><?php echo JText::_('COM_COMMUNITY_VIDEOS_WHO_CAN_SEE'); ?> </label></td> <td>:</td> <td> <?php echo CPrivacy::getHTML('permissions', $video->permissions, COMMUNITY_PRIVACY_BUTTON_LARGE); ?> </td> </tr> <?php } ?> </tbody> </table> <input type="hidden" name="id" value="<?php echo $video->id; ?> " /> <input type="hidden" name="option" value="com_community" /> <input type="hidden" name="view" value="videos" /> <input type="hidden" name="task" value="saveVideo" />
/** 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 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 _getOnlyGroupAlbums($id, $groupid, $type, $limitstart = "", $limit = "") { $db = $this->getDBO(); $extraSQL = ' WHERE a.groupid=' . $db->Quote($groupid) . ' '; // privacy $permission = CPrivacy::getAccessLevel(null, $id); $extraSQL .= ' AND a.permissions <=' . $db->Quote($permission) . ' '; // Get limit $limit = $limit !== '' ? $limit : ''; $limitstart = $limitstart !== '' ? $limitstart : ''; // Get total albums $total = $this->getAlbumCount($extraSQL); $this->total = $total; $extraSQL .= ' AND b.published =' . $db->Quote(1) . ' '; $result = $limit === '' || $limitstart === '' ? $this->getAlbumPhotoCount($extraSQL) : $this->getAlbumPhotoCount($extraSQL, $limit, $limitstart); /* filter results, album that has photos + all unpublished = not to be displayed * album that has no photos = display */ foreach ($result as $key => $res) { if ($res->count <= 0) { unset($result[$key]); } } // Update their correct Thumbnails $this->_updateThumbnail($result); $data = array(); foreach ($result as $row) { $album = JTable::getInstance('Album', 'CTable'); $album->bind($row); $data[] = $album; } return $data; }
<?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)) {
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; }
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; }