Exemplo n.º 1
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.º 2
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;
 }