Exemplo n.º 1
0
 /**
  * Display a list of site members
  *
  * @return     void
  */
 public function displayTask()
 {
     // Get filters
     $this->view->filters = array('search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')), 'search_field' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search_field', 'search_field', 'name')), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'registerDate'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'DESC'), 'registerDate' => Request::getState($this->_option . '.' . $this->_controller . '.registerDate', 'registerDate', ''), 'emailConfirmed' => Request::getState($this->_option . '.' . $this->_controller . '.emailConfirmed', 'emailConfirmed', 0, 'int'), 'public' => Request::getState($this->_option . '.' . $this->_controller . '.public', 'public', -1, 'int'), 'limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'));
     $this->view->filters['sortby'] = $this->view->filters['sort'] . ' ' . $this->view->filters['sort_Dir'];
     // In case limit has been changed, adjust limitstart accordingly
     $this->view->filters['start'] = $this->view->filters['limit'] != 0 ? floor($this->view->filters['start'] / $this->view->filters['limit']) * $this->view->filters['limit'] : 0;
     $obj = new \Components\Members\Tables\Profile($this->database);
     // Get a record count
     $this->view->total = $obj->getRecordCount($this->view->filters, true);
     // Get records
     $this->view->rows = $obj->getRecordEntries($this->view->filters, true);
     $this->view->config = $this->config;
     // Output the HTML
     $this->view->display();
 }
Exemplo n.º 2
0
 /**
  * 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();
     }
 }
Exemplo n.º 3
0
 /**
  * populate the geosearch markers table
  *
  * @param	 object	 $job	\Components\Cron\Models\Job
  * @return	boolean
  */
 public function getLocationData(\Components\Cron\Models\Job $job)
 {
     //setup database object
     $this->database = App::get('db');
     //get the relevant tables
     require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'profile.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_geosearch' . DS . 'tables' . DS . 'geosearchmarkers.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_jobs' . DS . 'tables' . DS . 'job.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_events' . DS . 'tables' . DS . 'event.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'organization.php';
     // get current markers
     $markers = new \Components\Geosearch\Tables\GeosearchMarkers($this->database);
     $markers = $markers->getMarkers(array(), 'array');
     // user profiles
     $objProfile = new \Components\Members\Tables\Profile($this->database);
     $profiles = $objProfile->selectWhere('uidNumber', 'public=1');
     // jobs
     $objJob = new \Components\Jobs\Tables\Job($this->database);
     $jobs = $objJob->get_openings();
     // events
     $objEvents = new \Components\Events\Tables\Event($this->database);
     $events = $objEvents->getEvents('year', array('year' => date('Y'), 'category' => 0));
     // organizations
     $objOrganizations = new \Components\Members\Tables\Organization($this->database);
     $organizations = $objOrganizations->find('all');
     if (count($markers) > 0) {
         //separate by scope
         $existingMarkers = $this->_separatebyScope($markers);
         //unique entries
         foreach ($existingMarkers as $class => &$existing) {
             switch ($class) {
                 case 'markerJobIDs':
                     $identifier = 'code';
                     $all = $jobs;
                     break;
                 case 'markerMemberIDs':
                     $identifier = 'uidNumber';
                     $all = $profiles;
                     break;
                 case 'markerEventIDs':
                     $identifier = 'id';
                     $all = $events;
                     break;
                 case 'markerOrganizationIDs':
                     $identifier = 'id';
                     $all = $organizations;
                     break;
                 default:
                     $identifier = '';
                     $all = array();
                     break;
             }
             //end switch
             if ($identifier != '' && count($all) > 0) {
                 //var_dump($all);
                 $existing = $this->_distill($existing, $all, $identifier);
             }
         }
         $markerMemberIDs = $this->_scopify($existingMarkers['markerMemberIDs'], 'member');
         $markerJobIDs = $this->_scopify($existingMarkers['markerJobIDs'], 'job');
         $markerEventIDs = $this->_scopify($existingMarkers['markerEventIDs'], 'event');
         $markerOrganizationIDs = $this->_scopify($existingMarkers['markerOrganizationIDs'], 'organization');
     } elseif (count($markers) == 0) {
         $markerMemberIDs = array();
         $markerJobIDs = array();
         $markerEventIDs = array();
         $markerOrganizationIDs = array();
         foreach ($profiles as $profile) {
             $obj = array();
             $obj['scope'] = 'member';
             $obj['scope_id'] = $profile->uidNumber;
             array_push($markerMemberIDs, $obj);
         }
         foreach ($jobs as $job) {
             $obj = array();
             $obj['scope'] = 'job';
             $obj['scope_id'] = $job->code;
             array_push($markerJobIDs, $obj);
         }
         foreach ($events as $event) {
             $obj = array();
             $obj['scope'] = 'event';
             $obj['scope_id'] = $event->id;
             array_push($markerEventIDs, $obj);
         }
         foreach ($organizations as $organization) {
             $obj = array();
             $obj['scope'] = 'organization';
             $obj['scope_id'] = $organization->id;
             array_push($markerEventIDs, $obj);
         }
     }
     //merge into one array
     $newMarkers = $this->_merger($markerMemberIDs, $markerJobIDs, $markerEventIDs, $markerOrganizationIDs);
     $creations = $this->_doGeocode($newMarkers, $objProfile, $objJob, $objEvents, $objOrganizations);
     foreach ($creations as $creation) {
         $m = new \Components\Geosearch\Tables\GeosearchMarkers($this->database);
         $m->addressLatitude = $creation->location->getLatitude();
         $m->addressLongitude = $creation->location->getLongitude();
         $m->scope_id = $creation->scope_id;
         $m->scope = $creation->scope;
         $m->store(true);
     }
     return true;
 }
Exemplo n.º 4
0
 /**
  * Serve up an example CSV file
  *
  * @return  void
  */
 public function sampleTask()
 {
     $profile = new \Components\Members\Tables\Profile($this->database);
     $skip = array('gid', 'gidnumber', 'regIP', 'regHost', 'modifiedDate', 'proxypassword', 'loginshell', 'ftpshell', 'shadowexpire', 'params', 'proxyuidnumber');
     $fields = array();
     $row = array();
     foreach ($profile->getProperties() as $key => $val) {
         if (in_array(strtolower($key), $skip)) {
             continue;
         }
         array_push($fields, $key);
         array_push($row, 'Example');
     }
     $multi = array('interests', 'race', 'disability');
     foreach ($multi as $key) {
         array_push($fields, $key);
         array_push($row, 'example;example;example');
     }
     // Output header
     @ob_end_clean();
     header("Pragma: public");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Expires: 0");
     header("Content-Transfer-Encoding: binary");
     header('Content-type: text/comma-separated-values');
     header('Content-disposition: attachment; filename="members.csv"');
     echo $this->quoteCsvRow($fields);
     //array_map('ucfirst', $fields));
     echo $this->quoteCsvRow($row);
     exit;
 }
Exemplo n.º 5
0
 /**
  * Edit form for a resource
  *
  * @param   integer  $isnew  Flag for editing (0) or creating new (1)
  * @return  void
  */
 public function editTask($isnew = 0)
 {
     Request::setVar('hidemainmenu', 1);
     $this->view->isnew = $isnew;
     // Get the resource component config
     $this->view->rconfig = $this->config;
     // Push some needed styles to the tmeplate
     $this->css('resources.css');
     // Incoming resource ID
     $id = Request::getVar('id', array(0));
     if (is_array($id)) {
         $id = !empty($id) ? $id[0] : 0;
     }
     // Incoming parent ID - this determines if the resource is standalone or not
     $this->view->pid = Request::getInt('pid', 0);
     // Grab some filters for returning to place after editing
     $this->view->return = array();
     $this->view->return['type'] = Request::getVar('type', '');
     $this->view->return['sort'] = Request::getVar('sort', '');
     $this->view->return['status'] = Request::getVar('status', '');
     // Instantiate our resource object
     $this->view->row = new Resource($this->database);
     $this->view->row->load($id);
     // Fail if checked out not by 'me'
     if ($this->view->row->checked_out && $this->view->row->checked_out != User::get('id')) {
         $task = '';
         if ($this->view->pid) {
             $task = '&task=children&pid=' . $this->view->pid;
         }
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . $task, false), Lang::txt('COM_RESOURCES_WARNING_CHECKED_OUT'), 'notice');
         return;
     }
     // Is this a new resource?
     if (!$id) {
         $this->view->row->created = Date::toSql();
         $this->view->row->created_by = User::get('id');
         $this->view->row->modified = $this->database->getNullDate();
         $this->view->row->modified_by = 0;
         $this->view->row->publish_up = Date::toSql();
         $this->view->row->publish_down = Lang::txt('COM_RESOURCES_NEVER');
         if ($this->view->pid) {
             $this->view->row->published = 1;
             $this->view->row->standalone = 0;
         } else {
             $this->view->row->published = 3;
             // default to "new" status
             $this->view->row->standalone = 1;
         }
         $this->view->row->access = 0;
     }
     // Editing existing
     $this->view->row->checkout(User::get('id'));
     if (trim($this->view->row->publish_down) == '0000-00-00 00:00:00') {
         $this->view->row->publish_down = Lang::txt('COM_RESOURCES_NEVER');
     }
     // Get name of resource creator
     $creator = User::getInstance($this->view->row->created_by);
     $this->view->row->created_by_name = $creator->get('name');
     $this->view->row->created_by_name = $this->view->row->created_by_name ? $this->view->row->created_by_name : Lang::txt('Unknown');
     // Get name of last person to modify resource
     if ($this->view->row->modified_by) {
         $modifier = User::getInstance($this->view->row->modified_by);
         $this->view->row->modified_by_name = $modifier->get('name');
         $this->view->row->modified_by_name = $this->view->row->modified_by_name ? $this->view->row->modified_by_name : Lang::txt('Unknown');
     } else {
         $this->view->row->modified_by_name = '';
     }
     // Get params definitions
     $this->view->params = new \Hubzero\Html\Parameter($this->view->row->params, dirname(dirname(__DIR__)) . DS . 'resources.xml');
     $this->view->attribs = new \Hubzero\Config\Registry($this->view->row->attribs);
     // Build selects of various types
     $rt = new Type($this->database);
     if ($this->view->row->standalone != 1) {
         $this->view->lists['type'] = Html::selectType($rt->getTypes(30), 'type', $this->view->row->type, '', '', '', '');
         $this->view->lists['logical_type'] = Html::selectType($rt->getTypes(28), 'logical_type', $this->view->row->logical_type, '[ none ]', '', '', '');
         $this->view->lists['sub_type'] = Html::selectType($rt->getTypes(30), 'logical_type', $this->view->row->logical_type, '[ none ]', '', '', '');
     } else {
         $this->view->lists['type'] = Html::selectType($rt->getTypes(27), 'type', $this->view->row->type, '', '', '', '');
         $this->view->lists['logical_type'] = Html::selectType($rt->getTypes(21), 'logical_type', $this->view->row->logical_type, '[ none ]', '', '', '');
     }
     // Build the <select> of admin users
     $this->view->lists['created_by'] = $this->userSelect('created_by', 0, 1);
     // Build the <select> for the group access
     $this->view->lists['access'] = Html::selectAccess($this->view->rconfig->get('accesses'), $this->view->row->access);
     // Is this a standalone resource?
     if ($this->view->row->standalone == 1) {
         $this->view->lists['tags'] = '';
         // Get groups
         $filters = array('authorized' => 'admin', 'fields' => array('cn', 'description', 'published', 'gidNumber', 'type'), 'type' => array(1, 3), 'sortby' => 'description');
         $groups = \Hubzero\User\Group::find($filters);
         // Build <select> of groups
         $this->view->lists['groups'] = Html::selectGroup($groups, $this->view->row->group_owner);
         include_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'profile.php';
         include_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'association.php';
         // Get all contributors
         $mp = new \Components\Members\Tables\Profile($this->database);
         $members = null;
         //$mp->getRecords(array('sortby'=>'surname DESC','limit'=>'all','search'=>'','show'=>''), true);
         // Get all contributors linked to this resource
         $authnames = array();
         if ($this->view->row->id) {
             $ma = new \Components\Members\Tables\Association($this->database);
             $sql = "SELECT n.uidNumber AS id, a.authorid, a.name, n.givenName, n.middleName, n.surname, a.role, a.organization\n\t\t\t\t\t\tFROM " . $ma->getTableName() . " AS a\n\t\t\t\t\t\tLEFT JOIN " . $mp->getTableName() . " AS n ON n.uidNumber=a.authorid\n\t\t\t\t\t\tWHERE a.subtable='resources'\n\t\t\t\t\t\tAND a.subid=" . $this->view->row->id . "\n\t\t\t\t\t\tORDER BY a.ordering";
             $this->database->setQuery($sql);
             $authnames = $this->database->loadObjectList();
             // Get the tags on this item
             $tagger = new Tags($this->view->row->id);
             $this->view->lists['tags'] = $tagger->render('string');
         }
         // Build <select> of contributors
         $authorslist = new \Hubzero\Component\View(array('name' => $this->_controller, 'layout' => 'authors'));
         $authorslist->authnames = $authnames;
         $authorslist->attribs = $this->view->attribs;
         $authorslist->option = $this->_option;
         $authorslist->roles = $rt->getRolesForType($this->view->row->type);
         $this->view->lists['authors'] = $authorslist->loadTemplate();
     }
     // Set any errors
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Output the HTML
     $this->view->setLayout('edit')->display();
 }
Exemplo n.º 6
0
 /**
  * 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();
 }
Exemplo n.º 7
0
 /**
  * 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);
 }
Exemplo n.º 8
0
	<?php 
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;
Exemplo n.º 9
0
 /**
  * Calculate stats
  *
  * @return     object
  */
 public function stats()
 {
     $c = new \Components\Members\Tables\Profile($this->database);
     $stats = new \stdClass();
     // Get record count of ALL members
     $stats->total_members = $c->getCount(array('show' => ''), true);
     // Get record count of ALL members
     $stats->total_public_members = $c->getCount(array('show' => '', 'authorized' => false), false);
     //get newly registered members (past day)
     $this->database->setQuery("SELECT COUNT(*) FROM `#__xprofiles` WHERE registerDate > '" . Date::of(strtotime('-1 DAY'))->toSql() . "'");
     $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() . "'");
     $stats->past_month_members = $this->database->loadResult();
     return $stats;
 }