/** * * @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 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 _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; }
/** * * @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 _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; }
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'); $videos = $model->getUserTotalVideos($userid); return $videos; }