/** * Generate module contents * * @return void */ public function run() { include_once Component::path('com_members') . DS . 'tables' . DS . 'profile.php'; include_once Component::path('com_members') . DS . 'tables' . DS . 'association.php'; $database = \App::get('db'); $this->row = null; $this->profile = null; // Randomly choose one $filters = array('limit' => 1, 'show' => trim($this->params->get('show')), 'start' => 0, 'sortby' => "RAND()", 'search' => '', 'authorized' => false, 'show' => trim($this->params->get('show'))); if ($min = $this->params->get('min_contributions')) { $filters['contributions'] = $min; } $mp = new \Components\Members\Tables\Profile($database); $rows = $mp->getRecords($filters, false); if (count($rows) > 0) { $this->row = $rows[0]; } // Load their bio $this->profile = Profile::getInstance($this->row->uidNumber); if (trim(strip_tags($this->profile->get('bio'))) == '') { return ''; } // Did we have a result to display? if ($this->row) { $this->cls = trim($this->params->get('moduleclass_sfx')); $this->txt_length = trim($this->params->get('txt_length')); $config = Component::params('com_members'); $rparams = new Registry($this->profile->get('params')); $this->params = $config; $this->params->merge($rparams); if ($this->params->get('access_bio') == 0 || $this->params->get('access_bio') == 1 && !User::isGuest()) { $this->txt = $this->profile->getBio('parsed'); } else { $this->txt = ''; } // Member profile $this->title = $this->row->name; if (!trim($this->title)) { $this->title = $this->row->givenName . ' ' . $this->row->surname; } $this->id = $this->row->uidNumber; $this->thumb = $this->profile->getPicture(); $this->filters = $filters; require $this->getLayoutPath(); } }
/** * Get module contents * * @return void */ public function run() { include_once Component::path('com_resources') . DS . 'tables' . DS . 'resource.php'; include_once Component::path('com_members') . DS . 'tables' . DS . 'profile.php'; include_once Component::path('com_members') . DS . 'tables' . DS . 'association.php'; include_once Component::path('com_answers') . DS . 'tables' . DS . 'question.php'; include_once Component::path('com_answers') . DS . 'tables' . DS . 'response.php'; include_once Component::path('com_blog') . DS . 'tables' . DS . 'entry.php'; include_once Component::path('com_blog') . DS . 'tables' . DS . 'comment.php'; $this->database = \App::get('db'); // Get the admin configured settings $filters = array(); $filters['limit'] = 5; $filters['start'] = 0; // featured items $tbls = array('resources', 'profiles'); $spots = array(); $spots[0] = trim($this->params->get('spotone')); $spots[1] = trim($this->params->get('spottwo')); $spots[2] = trim($this->params->get('spotthree')); $spots[3] = trim($this->params->get('spotfour')); $spots[4] = trim($this->params->get('spotfive')); $spots[5] = trim($this->params->get('spotsix')); $spots[6] = trim($this->params->get('spotseven')); $numspots = $this->params->get('numspots', 3); // some collectors $activespots = array(); $rows = array(); // styling $cls = trim($this->params->get('moduleclass_sfx')); $txtLength = trim($this->params->get('txt_length')); $start = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y'))) . ' 00:00:00'; $end = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y'))) . ' 23:59:59'; $this->html = ''; $k = 1; $out = ''; for ($i = 0, $n = $numspots; $i < $numspots; $i++) { $spot = $spots[$i]; if ($spot == '') { continue; } $row = null; $out = ''; $tbl = ''; $tbl = $spot == 'tools' || $spot == 'nontools' ? 'resources' : ''; $tbl = $spot == 'members' ? 'profiles' : $tbl; $tbl = $spot == 'topics' ? 'topics' : $tbl; $tbl = $spot == 'itunes' ? 'itunes' : $tbl; $tbl = $spot == 'answers' ? 'answers' : $tbl; $tbl = $spot == 'blog' ? 'blog' : $tbl; $tbl = !$tbl ? array_rand($tbls, 1) : $tbl; // we need to randomly choose one switch ($tbl) { case 'resources': // Initiate a resource object $rr = new \Components\Resources\Tables\Resource($this->database); $filters['start'] = 0; $filters['type'] = $spot; $filters['sortby'] = 'random'; $filters['minranking'] = trim($this->params->get('minranking')); $filters['tag'] = $spot == 'tools' ? trim($this->params->get('tag')) : ''; // tag is set for tools only // Get records $rows[$spot] = isset($rows[$spot]) ? $rows[$spot] : $rr->getRecords($filters, false); break; case 'profiles': // No - so we need to randomly choose one $filters['start'] = 0; $filters['sortby'] = "RAND()"; $filters['search'] = ''; $filters['state'] = 'public'; $filters['authorized'] = false; $filters['tag'] = ''; $filters['contributions'] = trim($this->params->get('min_contributions')); $filters['show'] = trim($this->params->get('show')); $mp = new \Components\Members\Tables\Profile($this->database); // Get records $rows[$spot] = isset($rows[$spot]) ? $rows[$spot] : $mp->getRecords($filters, false); break; case 'topics': // No - so we need to randomly choose one $topics_tag = trim($this->params->get('topics_tag')); $query = "SELECT DISTINCT w.id, w.pagename, w.title "; $query .= " FROM #__wiki_page AS w "; if ($topics_tag) { $query .= " JOIN #__tags_object AS RTA ON RTA.objectid=w.id AND RTA.tbl='wiki' "; $query .= " INNER JOIN #__tags AS TA ON TA.id=RTA.tagid "; } else { $query .= ", #__wiki_version AS v "; } $query .= " WHERE w.access!=1 AND w.scope = '' "; if ($topics_tag) { $query .= " AND (TA.tag='" . $topics_tag . "' OR TA.raw_tag='" . $topics_tag . "') "; } else { $query .= " AND v.pageid=w.id AND v.approved = 1 AND v.pagetext != '' "; } $query .= " ORDER BY RAND() "; $this->database->setQuery($query); $rows[$spot] = isset($rows[$spot]) ? $rows[$spot] : $this->database->loadObjectList(); break; case 'itunes': // Initiate a resource object $rr = new \Components\Resources\Tables\Resource($this->database); $filters['start'] = 0; $filters['sortby'] = 'random'; $filters['tag'] = trim($this->params->get('itunes_tag')); // Get records $rows[$spot] = isset($rows[$spot]) ? $rows[$spot] : $rr->getRecords($filters, false); break; case 'answers': $query = "SELECT C.id, C.subject, C.question, C.created, C.created_by, C.anonymous "; $query .= ", (SELECT COUNT(*) FROM #__answers_responses AS a WHERE a.state!=2 AND a.question_id=C.id) AS rcount "; $query .= " FROM #__answers_questions AS C "; $query .= " WHERE C.state=0 "; $query .= " AND (C.reward > 0 OR C.helpful > 0) "; $query .= " ORDER BY RAND() "; $this->database->setQuery($query); $rows[$spot] = isset($rows[$spot]) ? $rows[$spot] : $this->database->loadObjectList(); break; case 'blog': $filters = array(); $filters['limit'] = 1; $filters['start'] = 0; $filters['state'] = 'public'; $filters['order'] = "RAND()"; $filters['search'] = ''; $filters['scope'] = 'member'; $filters['group_id'] = 0; $filters['authorized'] = false; $filters['sql'] = ''; $mp = new \Components\Blog\Tables\Entry($this->database); $entry = $mp->getRecords($filters); $rows[$spot] = isset($rows[$spot]) ? $rows[$spot] : $entry; break; } if ($rows && count($rows[$spot]) > 0) { $row = $rows[$spot][0]; } // make sure we aren't pulling the same item if ($k != 1 && in_array($spot, $activespots) && $rows && count($rows[$spot]) > 1) { $row = count($rows[$spot]) < $k ? $rows[$spot][$k - 1] : $rows[$spot][1]; // get the next one } // pull info if ($row) { $out = $this->_composeEntry($row, $tbl, $txtLength); $itemid = $this->_composeEntry($row, $tbl, 0, 1); $activespots[] = $spot; } // Did we get any results? if ($out) { $this->html .= '<li class="spot_' . $k . '">' . $out . '</li>' . "\n"; $k++; } } // Output HTML require $this->getLayoutPath(); }
/** * Display a list of members * * @apiMethod GET * @apiUri /members/list * @apiParameter { * "name": "limit", * "description": "Number of result to return.", * "type": "integer", * "required": false, * "default": 25 * } * @apiParameter { * "name": "start", * "description": "Number of where to start returning results.", * "type": "integer", * "required": false, * "default": 0 * } * @apiParameter { * "name": "search", * "description": "A word or phrase to search for.", * "type": "string", * "required": false, * "default": "" * } * @apiParameter { * "name": "sort", * "description": "Field to sort results by.", * "type": "string", * "required": false, * "default": "name", * "allowedValues": "name, id" * } * @apiParameter { * "name": "sort_Dir", * "description": "Direction to sort results by.", * "type": "string", * "required": false, * "default": "desc", * "allowedValues": "asc, desc" * } * @return void */ public function listTask() { include_once dirname(dirname(__DIR__)) . DS . 'tables' . DS . 'profile.php'; $filters = array('limit' => Request::getInt('limit', 25), 'start' => Request::getInt('limitstart', 0), 'search' => Request::getVar('search', ''), 'sortby' => Request::getWord('sort', 'name'), 'sort_Dir' => strtoupper(Request::getWord('sortDir', 'DESC')), 'authorized' => false, 'emailConfirmed' => true, 'public' => 1, 'show' => 'members'); if ($filters['sortby'] == 'id') { $filters['sortby'] = 'uidNumber'; } $database = App::get('db'); $c = new \Components\Members\Tables\Profile($database); $response = new stdClass(); $response->members = array(); $response->total = $c->getCount($filters, false); if ($response->total) { $base = rtrim(Request::base(), '/'); foreach ($c->getRecords($filters, false) as $i => $entry) { $obj = new stdClass(); $obj->id = $entry->uidNumber; $obj->name = $entry->name; $obj->organization = $entry->organization; $obj->uri = str_replace('/api', '', $base . '/' . ltrim(Route::url('index.php?option=' . $this->_option . '&id=' . $entry->uidNumber), '/')); $response->members[] = $obj; } } $response->success = true; $this->send($response); }
if ($this->contribution_counting) { ?> <div class="grid"> <div class="col span3"> <h2><?php echo Lang::txt('COM_MEMBERS_TOP_CONTRIBUTOR'); ?> </h2> </div><!-- / .col span3 --> <div class="col span9 omega"> <div class="grid"> <?php $db = App::get('db'); $c = new \Components\Members\Tables\Profile($db); $filters = array('limit' => 4, 'start' => 0, 'show' => 'contributors', 'sortby' => 'contributions', 'contributions' => 1, 'public' => 1, 'authorized' => false); if ($rows = $c->getRecords($filters, false)) { $i = 0; foreach ($rows as $row) { $contributor = \Hubzero\User\Profile::getInstance($row->uidNumber); if (!$contributor || !$contributor->get('uidNumber')) { continue; } if ($i == 2) { $i = 0; } switch ($i) { case 2: $cls = ''; break; case 1: $cls = 'omega';
/** * Display a list of members * * @return void */ public function browseTask() { $this->view->contribution_counting = $this->config->get('contribution_counting', true); // Incoming $this->view->filters = array(); $this->view->filters['limit'] = Request::getVar('limit', Config::get('list_limit'), 'request'); $this->view->filters['start'] = Request::getInt('limitstart', 0, 'get'); $this->view->filters['show'] = strtolower(Request::getWord('show', $this->_view)); $this->view->filters['sortby'] = strtolower(Request::getWord('sortby', 'name')); $this->view->filters['search'] = Request::getVar('search', ''); $this->view->filters['index'] = Request::getWord('index', ''); if ($this->view->contribution_counting == false) { if ($this->view->filters['show'] = 'contributors') { $this->view->filters['show'] = 'members'; } if ($this->view->filters['sortby'] == 'contributions') { $this->view->filters['sortby'] = 'name'; } } else { $this->view->filters['contributions'] = 0; } // Build the page title if ($this->view->filters['show'] == 'contributors') { $this->view->title = Lang::txt('CONTRIBUTORS'); $this->view->filters['sortby'] = strtolower(Request::getWord('sortby', 'contributions')); } else { $this->view->title = Lang::txt('MEMBERS'); } $this->view->title .= $this->_task ? ': ' . Lang::txt(strtoupper($this->_task)) : ''; if (!in_array($this->view->filters['sortby'], array('name', 'organization', 'contributions'))) { $this->view->filters['sortby'] = $this->view->filters['show'] == 'contributors' ? 'contributions' : 'name'; } // Set the page title Document::setTitle($this->view->title); // Set the document pathway if (Pathway::count() <= 0) { Pathway::append(Lang::txt(strtoupper($this->_name)), 'index.php?option=' . $this->_option); } // Was a specific index (letter) set? if ($this->view->filters['index']) { // Add to the pathway Pathway::append(strtoupper($this->view->filters['index']), 'index.php?option=' . $this->_option . '&index=' . $this->view->filters['index']); } // Check authorization $this->view->authorized = $this->_authorize(); if ($this->view->authorized === 'admin') { $admin = true; } else { $admin = false; } $this->view->filters['authorized'] = $this->view->authorized; $this->view->filters['emailConfirmed'] = true; // Initiate a contributor object $c = new \Components\Members\Tables\Profile($this->database); if (!($stats = Cache::get('members.stats'))) { $stats = $this->stats(); Cache::put('members.stats', $stats, intval($this->config->get('cache_time', 15))); } // Get record count of ALL members $this->view->total_members = $stats->total_members; //$c->getCount(array('show' => ''), true); // Get record count of ALL members $this->view->total_public_members = $stats->total_public_members; //$c->getCount(array('show' => '', 'authorized' => false), false); // Get record count $this->view->total = $c->getCount($this->view->filters, $admin); // Get records $this->view->rows = $c->getRecords($this->view->filters, $admin); //get newly registered members (past day) //$this->database->setQuery("SELECT COUNT(*) FROM `#__xprofiles` WHERE registerDate > '" . Date::of(strtotime('-1 DAY'))->toSql() . "'"); $this->view->past_day_members = $stats->past_day_members; //$this->database->loadResult(); //get newly registered members (past month) //$this->database->setQuery("SELECT COUNT(*) FROM `#__xprofiles` WHERE registerDate > '" . Date::of(strtotime('-1 MONTH'))->toSql() . "'"); $this->view->past_month_members = $stats->past_month_members; //$this->database->loadResult(); $this->view->registration = new \Hubzero\Base\Object(); $this->view->registration->Fullname = $this->_registrationField('registrationFullname', 'RRRR', $this->_task); $this->view->registration->Organization = $this->_registrationField('registrationOrganization', 'HOOO', $this->_task); // Instantiate the view $this->view->config = $this->config; $this->view->view = $this->_view; foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->display(); }