Exemplo n.º 1
0
 public function getRequestedSearchResults()
 {
     $userList = new UserList();
     $userList->sortBy('uDateAdded', 'desc');
     $userList->showInactiveUsers = true;
     $userList->showInvalidatedUsers = true;
     if ($_GET['keywords'] != '') {
         $userList->filterByKeywords($_GET['keywords']);
     }
     if ($_REQUEST['numResults']) {
         $userList->setItemsPerPage($_REQUEST['numResults']);
     }
     if (isset($_REQUEST['gID']) && is_array($_REQUEST['gID'])) {
         foreach ($_REQUEST['gID'] as $gID) {
             $userList->filterByGroupID($gID);
         }
     }
     if (is_array($_REQUEST['selectedSearchField'])) {
         foreach ($_REQUEST['selectedSearchField'] as $i => $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 ($_GET['active'] === '0') {
                             $userList->filterByIsActive(0);
                         } else {
                             if ($_GET['active'] === '1') {
                                 $userList->filterByIsActive(1);
                             }
                         }
                         break;
                     case "date_added":
                         $dateFrom = $_REQUEST['date_from'];
                         $dateTo = $_REQUEST['date_to'];
                         if ($dateFrom != '') {
                             $dateFrom = date('Y-m-d', strtotime($dateFrom));
                             $userList->filterByDateAdded($dateFrom, '>=');
                             $dateFrom .= ' 00:00:00';
                         }
                         if ($dateTo != '') {
                             $dateTo = date('Y-m-d', strtotime($dateTo));
                             $dateTo .= ' 23:59:59';
                             $userList->filterByDateAdded($dateTo, '<=');
                         }
                         break;
                     default:
                         $akID = $item;
                         $fak = UserAttributeKey::get($akID);
                         $type = $fak->getAttributeType();
                         $cnt = $type->getController();
                         $cnt->setAttributeKey($fak);
                         $cnt->searchForm($userList);
                         break;
                 }
             }
         }
     }
     return $userList;
 }
Exemplo n.º 2
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
$valt = Loader::helper('validation/token');
if ($valt->validate('quick_user_select_' . $_REQUEST['key'], $_REQUEST['token'])) {
    $u = new User();
    $db = Loader::db();
    $userList = new UserList();
    $userList->filterByFuzzyUserName($_GET['term']);
    $userList->sortByUserName();
    $userList->setItemsPerPage(7);
    $pagination = $userList->getPagination();
    $users = $pagination->getCurrentPageResults();
    $userNames = array();
    foreach ($users as $ui) {
        $userNames[] = array('label' => $ui->getUserDisplayName(), 'value' => $ui->getUserID());
    }
    $jh = Loader::helper('json');
    echo $jh->encode($userNames);
}
Exemplo n.º 3
0
	public function getRequestedSearchResults() {
		$userList = new UserList();
		$userList->sortBy('uDateAdded', 'desc');
		$userList->showInactiveUsers = true;
		$userList->showInvalidatedUsers = true;
		
		$columns = UserSearchColumnSet::getCurrent();
		$this->set('columns', $columns);

		if ($_GET['keywords'] != '') {
			$userList->filterByKeywords($_GET['keywords']);
		}	
		
		if ($_REQUEST['numResults'] && Loader::helper('validation/numbers')->integer($_REQUEST['numResults'])) {
			$userList->setItemsPerPage($_REQUEST['numResults']);
		}
		
		$pk = PermissionKey::getByHandle('access_user_search');
		$asl = $pk->getMyAssignment();

		$p = new Permissions();

		$filterGIDs = array();
		if ($asl->getGroupsAllowedPermission() == 'C') { 
			$userList->filter('u.uID', USER_SUPER_ID, '<>');
			$userList->addToQuery("left join UserGroups ugRequired on ugRequired.uID = u.uID ");	
			if (in_array(REGISTERED_GROUP_ID, $asl->getGroupsAllowedArray())) {
				$userList->filter(false, '(ugRequired.gID in (' . implode(',', $asl->getGroupsAllowedArray()) . ') or ugRequired.gID is null)');
			} else {
				$userList->filter('ugRequired.gID', $asl->getGroupsAllowedArray(), 'in');		
			}
		}
		
		if (isset($_REQUEST['gID']) && is_array($_REQUEST['gID'])) {
			foreach($_REQUEST['gID'] as $gID) {
				$g = Group::getByID($gID);
				if (is_object($g)) {
					if ($pk->validate($g) && (!in_array($g->getGroupID(), $filterGIDs))) {
						$filterGIDs[] = $g->getGroupID();
					}
				}
			}
		}
		
		foreach($filterGIDs as $gID) {
			$userList->filterByGroupID($gID);
		}
		if (is_array($_REQUEST['selectedSearchField'])) {
			foreach($_REQUEST['selectedSearchField'] as $i => $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 ($_GET['active'] === '0') {
								$userList->filterByIsActive(0);
							} else if ($_GET['active'] === '1') {
								$userList->filterByIsActive(1);
							}
							break;
						case "date_added":
							$dateFrom = $_REQUEST['date_from'];
							$dateTo = $_REQUEST['date_to'];
							if ($dateFrom != '') {
								$dateFrom = date('Y-m-d', strtotime($dateFrom));
								$userList->filterByDateAdded($dateFrom, '>=');
								$dateFrom .= ' 00:00:00';
							}
							if ($dateTo != '') {
								$dateTo = date('Y-m-d', strtotime($dateTo));
								$dateTo .= ' 23:59:59';
								
								$userList->filterByDateAdded($dateTo, '<=');
							}
							break;
						case "group_set":
							$gsID = $_REQUEST['gsID'];
							$gs = GroupSet::getByID($gsID);
							$groupsetids = array(-1);
							if (is_object($gs)) {
								$groups = $gs->getGroups();
							}
							$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) . ')';
							$userList->filter(false, $instr);
							break;

						default:
							$akID = $item;
							$fak = UserAttributeKey::get($akID);
							$type = $fak->getAttributeType();
							$cnt = $type->getController();
							$cnt->setAttributeKey($fak);
							$cnt->searchForm($userList);
							break;
					}
				}
			}
		}
		return $userList;
	}