public function getItems($options = array()) { $db = FD::db(); $sql = $db->sql(); $sql->select('#__social_clusters_nodes', 'a'); $sql->column('a.*'); $sql->leftjoin('#__users', 'b'); $sql->on('a.uid', 'b.id'); if (FD::config()->get('users.blocking.enabled') && !JFactory::getUser()->guest) { $sql->leftjoin('#__social_block_users', 'bus'); $sql->on('b.id', 'bus.user_id'); $sql->on('bus.target_id', JFactory::getUser()->id); $sql->isnull('bus.id'); } $sql->where('b.block', 0); if (!empty($options['groupid'])) { $sql->where('cluster_id', $options['groupid']); } if (isset($options['state'])) { $sql->where('state', $state); } if (isset($options['admin'])) { $sql->where('admin', $options['admin']); } $ordering = $this->getState('ordering'); if (!empty($ordering)) { $direction = $this->getState('direction'); if ($ordering == 'username') { $sql->order('b.username', $direction); } elseif ($ordering == 'name') { $sql->order('b.name', $direction); } else { $sql->order($ordering, $direction); } } $limit = $this->getState('limit'); if ($limit > 0) { $this->setState('limit', $limit); // Get the limitstart. $limitstart = $this->getUserStateFromRequest('limitstart', 0); $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0; $this->setState('limitstart', $limitstart); // Set the total number of items. $this->setTotal($sql->getTotalSql()); // Get the list of users $result = parent::getData($sql->getSql()); } else { $db->setQuery($sql); $result = $db->loadObjectList(); } $members = array(); foreach ($result as $row) { $member = FD::table('GroupMember'); $member->bind($row); $members[] = $member; } return $members; }
/** * Retrieves list of albums for admin area * * @since 1.0 * @access public * @param string * @return */ public function getDataWithState() { $db = FD::db(); // Get the query object $sql = $db->sql(); $sql->select('#__social_albums', 'a'); $sql->column('a.*'); $sql->column('COUNT(b.id)', 'totalphotos'); $sql->join('#__social_photos', 'b'); $sql->on('a.id', 'b.album_id'); $sql->group('a.id'); // Determines if we should search for the title $search = $this->getState('search'); if ($search) { $sql->where('a.title', '%' . $search . '%', 'LIKE', 'OR'); $sql->where('a.caption', '%' . $search . '%', 'LIKE', 'OR'); } // Determine the ordering $ordering = $this->getState('ordering'); if ($ordering) { $direction = $this->getState('direction'); $sql->order($ordering, $direction); } // We should only be picking up photos which are valid $sql->where('b.state', SOCIAL_STATE_PUBLISHED); // Determine the pagination limit $limit = $this->getState('limit'); if ($limit) { // Set the total number of items. $this->setTotal($sql->getSql(), true); // Get the list of users $result = parent::getData($sql->getSql(), true); } else { $db->setQuery($sql); $result = $db->loadObjectList(); } $albums = array(); foreach ($result as $row) { $album = FD::table('Album'); $album->bind($row); // Set custom attributes $album->totalphotos = $row->totalphotos; $albums[] = $album; } return $albums; }
public function getItemsWithState($options = array()) { $db = FD::db(); $sql = $db->sql(); // Determines if user is filtering the items $state = $this->getState('state'); $sql->column('a.*'); $sql->column('b.name', 'actorName'); $sql->column('c.title', 'clusterName'); if ($state == '3') { $sql->select('#__social_stream_history', 'a'); } else { $sql->select('#__social_stream', 'a'); } $sql->join('#__users', 'b', 'INNER'); $sql->on('a.actor_id', 'b.id'); $sql->join('#__social_clusters', 'c', 'LEFT'); $sql->on('a.cluster_id', 'c.id'); if (!is_null($state) && $state != '3') { if ($state == 'all') { $sql->where('(', '', '', 'AND'); $sql->where('a.state', '1', '=', 'OR'); $sql->where('a.state', '2', '=', 'OR'); $sql->where(')'); } else { $sql->where('a.state', $state); } } // Ordering $ordering = $this->getState('ordering', 'created'); if ($ordering) { $direction = $this->getState('direction') ? $this->getState('direction') : 'DESC'; $sql->order($ordering, $direction); } // Set the total $this->setTotal($sql->getTotalSql()); $result = parent::getData($sql->getSql()); $this->pagination = parent::getPagination(); return $result; }
/** * method used in backend to list down all the privacy items. * */ public function getList() { $db = FD::db(); $sql = $db->sql(); $sql->select('#__social_privacy'); // Determines if user wants to search for something $search = $this->getState('search'); if ($search) { $sql->where('type', $search, 'LIKE', 'OR'); $sql->where('rule', $search, 'LIKE', 'OR'); $sql->where('description', $search, 'LIKE', 'OR'); } $ordering = $this->getState('ordering'); if ($ordering) { $direction = $this->getState('direction'); $sql->order($ordering, $direction); } $this->setTotal($sql->getTotalSql()); $rows = parent::getData($sql->getSql()); if (!$rows) { return false; } // We want to pass back a list of PointsTable object. $data = array(); // Load the admin language file whenever there's points. JFactory::getLanguage()->load('com_easysocial', JPATH_ROOT . '/administrator'); foreach ($rows as $row) { $privacy = FD::table('Privacy'); $privacy->bind($row); $data[] = $privacy; } return $data; }
/** * Retrieves the list of reports * * @since 1.0 * @access public * @param string * @return */ public function getReports() { $db = FD::db(); $sql = $db->sql(); $sql->select('#__social_reports'); $sql->column('*'); $sql->column('COUNT(1)', 'total'); // We need to group up the items to ensure the unique-ness $sql->group('extension', 'uid', 'type'); // Determines if we need to search for something $search = $this->getState('search'); if ($search) { $sql->where('title', '%' . $search . '%', 'LIKE', 'OR'); $sql->where('message', '%' . $search . '%', 'LIKE', 'OR'); } // Set the total objects $this->setTotal($sql->getTotalSql()); // Set the ordering $ordering = $this->getState('ordering'); if ($ordering) { $direction = $this->getState('direction'); $sql->order($ordering, $direction); } // Get the real data now $result = parent::getData($sql->getSql()); if (!$result) { return false; } $reports = array(); foreach ($result as $item) { $report = FD::table('Report'); $report->bind($item); // Inject the total reports $report->total = $item->total; $reports[] = $report; } return $reports; }
/** * Retrieves the points history for a user * * @since 1.0 * @access public * @param int The user's id. * @return int The total points a user has. */ public function getHistory($userId, $options = array()) { $db = FD::db(); $query = $db->sql(); $query->select('#__social_points_history', 'a'); $query->column('a.*'); $query->column('b.title', 'points_title'); $query->column('b.extension'); $query->join('#__social_points', 'b'); $query->on('b.id', 'a.points_id'); $query->where('a.user_id', $userId); $query->where('a.state', SOCIAL_STATE_PUBLISHED); $query->order('a.created', 'DESC'); $limit = isset($options['limit']) ? $options['limit'] : 0; if ($limit != 0) { $this->setState('limit', $limit); // Get the limitstart. $limitstart = JRequest::getInt('limitstart', 0); $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0; $this->setState('limitstart', $limitstart); // Set the total number of items. $this->setTotal($query->getTotalSql()); // Get the list of users $result = parent::getData($query->getSql()); } else { $db->setQuery($query); $result = $db->loadObjectList(); } if (!$result) { return false; } $histories = array(); // Load admin language file as well FD::language()->loadAdmin(); $loadedLanguage = array(); foreach ($result as $row) { $history = FD::table('PointsHistory'); $history->bind($row); if ($row->extension !== SOCIAL_COMPONENT_NAME && !empty($row->extension) && !in_array($row->extension, $loadedLanguage)) { FD::language()->load($row->extension, JPATH_ROOT); FD::language()->load($row->extension, JPATH_ADMINISTRATOR); $loadedLanguage[] = $row->extension; } $history->points_title = JText::_($row->points_title); $histories[] = $history; } return $histories; }
/** * Returns a list of menus for the admin sidebar. * * Example: * <code> * <?php * $model = FD::model( 'Mailer' ); * * // Returns an array of mail items. * $model->getItems(); * ?> * </code> * * @since 1.0 * @access public * @param Array An array of options. * @return Array An array of SocialTableMailer * * @author Mark Lee <*****@*****.**> */ public function getItems($options = array()) { $db = FD::db(); $sql = $db->sql(); $sql->select('#__social_mailer'); // Determines if user is filtering the items $state = isset($options['state']) ? $options['state'] : null; if (!is_null($state)) { $sql->where('state', $state); } // Determines if we need to order the items by column. $ordering = $this->getState('ordering'); // Ordering based on caller if ($ordering) { $direction = $this->getState('direction', 'DESC'); $sql->order($ordering, $direction); } // Set the total $this->setTotal($sql->getTotalSql()); $result = parent::getData($sql->getSql()); if (!$result) { return $result; } $emails = array(); foreach ($result as $row) { $mail = FD::table('Mailer'); $mail->bind($row); $emails[] = $mail; } return $emails; }
/** * Retrieve a list of applications that is installed on the site. * * @since 1.0 * @access public * @param Array An array of configuration. * @return Array An array of application object. * * @author Mark Lee <*****@*****.**> */ public function getItemsWithState($options = array()) { $db = FD::db(); $sql = $db->sql(); $sql->select('#__social_apps'); // Determine if we should only fetch apps that are widgets $widget = isset($options['widget']) ? $options['widget'] : false; if ($widget) { $sql->where('widget', SOCIAL_STATE_PUBLISHED); } // Depending on type of apps. $filter = $this->getState('filter'); if ($filter && $filter != 'all') { $sql->where('type', $filter); } // Filter by group $group = $this->getState('group'); if ($group && $group != 'all') { $sql->where('group', $group); } // Search filter $search = $this->getState('search'); if ($search) { $sql->where('title', '%' . $search . '%', 'LIKE'); } // Depending on group of apps. $group = isset($options['group']) ? $options['group'] : ''; if ($group) { $sql->where('group', $group); } // Discover apps $discover = isset($options['discover']) ? $options['discover'] : ''; if ($discover) { $sql->where('state', SOCIAL_APP_STATE_DISCOVERED); } else { // State filters $state = $this->getState('state'); if ($state !== '' && $state != 'all') { $sql->where('state', $state); } $sql->where('('); $sql->where('state', SOCIAL_STATE_PUBLISHED, '=', 'OR'); $sql->where('state', SOCIAL_STATE_UNPUBLISHED, '=', 'OR'); $sql->where(')'); $sql->where('state', SOCIAL_APP_STATE_DISCOVERED, '!='); } // Check for ordering $ordering = $this->getState('ordering'); if ($ordering) { $direction = $this->getState('direction') ? $this->getState('direction') : 'DESC'; $sql->order($ordering, $direction); } $limit = $this->getState('limit', 0); if ($limit) { $this->setState('limit', $limit); // Get the limitstart. $limitstart = $this->getUserStateFromRequest('limitstart', 0); $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0; $this->setState('limitstart', $limitstart); // Set the total number of items. $this->setTotal($sql->getSql(), true); // Get the list of users $result = parent::getData($sql->getSql()); } else { // Set the total $this->setTotal($sql->getTotalSql()); // Get the result using parent's helper $result = $this->getData($sql->getSql()); } if (!$result) { return $result; } $apps = array(); foreach ($result as $row) { $appTable = FD::table('App'); $appTable->bind($row); $apps[] = $appTable; } return $apps; }