Example #1
0
 public function search_members()
 {
     $keywords = $this->get('keywords');
     if ($keywords != '') {
         $this->userList->filterByKeywords($keywords);
     }
 }
Example #2
0
 public function testKeywords()
 {
     $this->list->filterByKeywords('testu');
     $this->assertEquals(2, $this->list->getTotalResults());
     $this->list->filterByKeywords('.org');
     $this->assertEquals(3, $this->list->getTotalResults());
 }
 private function getIsEmailInSystem($email)
 {
     //array_push($Adresses, Config::get('xmailer.allow'));
     $grp = new UserList();
     $grp->filterByKeywords($email);
     return $grp->getTotalResults() > 0;
 }
Example #4
0
 public function search()
 {
     $dh = Loader::helper('concrete/user');
     if (!$dh->canAccessUserSearchInterface()) {
         return false;
     }
     if ($_REQUEST['submitSearch']) {
         $this->searchRequest->resetSearchRequest();
     }
     $req = $this->searchRequest->getSearchRequest();
     $columns = UserSearchColumnSet::getCurrent();
     if (!$this->userList->getActiveSortColumn()) {
         $col = $columns->getDefaultSortColumn();
         $this->userList->sanitizedSortBy($col->getColumnKey(), $col->getColumnDefaultSortDirection());
     }
     $this->userList->includeInactiveUsers();
     $this->userList->includeUnvalidatedUsers();
     $columns = UserSearchColumnSet::getCurrent();
     $this->set('columns', $columns);
     if ($req['keywords'] != '') {
         $this->userList->filterByKeywords($req['keywords']);
     }
     if ($req['numResults'] && Loader::helper('validation/numbers')->integer($req['numResults'])) {
         $this->userList->setItemsPerPage($req['numResults']);
     }
     $u = new User();
     if (!$u->isSuperUser()) {
         $gIDs = array(-1);
         $gs = new GroupList();
         $groups = $gs->getResults();
         foreach ($groups as $g) {
             $gp = new Permissions($g);
             if ($gp->canSearchUsersInGroup()) {
                 $gIDs[] = $g->getGroupID();
             }
         }
         $this->userList->getQueryObject()->leftJoin("u", "UserGroups", "ugRequired", "ugRequired.uID = u.uID");
         $groups = 'ugRequired.gID in (' . implode(',', $gIDs) . ')';
         $gg = Group::getByID(REGISTERED_GROUP_ID);
         $ggp = new Permissions($gg);
         if ($ggp->canSearchUsersInGroup()) {
             $null = 'ugRequired.gID is null';
         }
         $this->userList->getQueryObject()->select('distinct (u.uID)');
         $expr = $this->userList->getQueryObject()->expr()->orX($groups, $null);
         $this->userList->getQueryObject()->andwhere($expr);
     }
     $filterGIDs = array();
     if (isset($req['gID']) && is_array($req['gID'])) {
         foreach ($req['gID'] as $gID) {
             $g = Group::getByID($gID);
             if (is_object($g)) {
                 $gp = new Permissions($g);
                 if ($gp->canSearchUsersInGroup()) {
                     $filterGIDs[] = $g->getGroupID();
                 }
             }
         }
     }
     foreach ($filterGIDs as $gID) {
         $this->userList->filterByGroupID($gID);
     }
     if (is_array($req['field'])) {
         foreach ($req['field'] as $i => $item) {
             $this->fields[] = $this->getField($item);
             // due to the way the form is setup, index will always be one more than the arrays
             if ($item != '') {
                 switch ($item) {
                     case 'is_active':
                         if ($req['active'] === '0') {
                             $this->userList->filterByIsActive(0);
                         } elseif ($req['active'] === '1') {
                             $this->userList->filterByIsActive(1);
                         }
                         break;
                     case "date_added":
                         $wdt = Loader::helper('form/date_time');
                         /* @var $wdt \Concrete\Core\Form\Service\Widget\DateTime */
                         $dateFrom = $wdt->translate('date_added_from', $_REQUEST);
                         if ($dateFrom) {
                             $this->userList->filterByDateAdded($dateFrom, '>=');
                         }
                         $dateTo = $wdt->translate('date_added_to', $_REQUEST);
                         if ($dateTo) {
                             if (preg_match('/^(.+\\d+:\\d+):00$/', $dateTo, $m)) {
                                 $dateTo = $m[1] . ':59';
                             }
                             $this->userList->filterByDateAdded($dateTo, '<=');
                         }
                         break;
                     case "group_set":
                         $gsID = $_REQUEST['gsID'];
                         $gs = GroupSet::getByID($gsID);
                         $groupsetids = array(-1);
                         if (is_object($gs)) {
                             $groups = $gs->getGroups();
                         }
                         $this->userList->addToQuery('left join UserGroups ugs on u.uID = ugs.uID');
                         foreach ($groups as $g) {
                             if ($pk->validate($g) && !in_array($g->getGroupID(), $groupsetids)) {
                                 $groupsetids[] = $g->getGroupID();
                             }
                         }
                         $instr = 'ugs.gID in (' . implode(',', $groupsetids) . ')';
                         $this->userList->filter(false, $instr);
                         break;
                     default:
                         $akID = $item;
                         $fak = UserAttributeKey::getByID($akID);
                         $type = $fak->getAttributeType();
                         $cnt = $type->getController();
                         $cnt->setAttributeKey($fak);
                         $cnt->searchForm($this->userList);
                         break;
                 }
             }
         }
     }
     $ilr = new UserSearchResult($columns, $this->userList, URL::to('/ccm/system/search/users/submit'), $this->fields);
     $this->result = $ilr;
 }
Example #5
0
 /**
  * Filters keyword fields by keywords (including username, email and attributes).
  * @param $keywords
  */
 public function filterByKeywords($keywords)
 {
     return parent::filterByKeywords($keywords);
 }