|
2 | 2 |
|
3 | 3 | require_once __DIR__ . "/../../../resources/autoload.php"; // Load required libs |
4 | 4 |
|
| 5 | +use UnityWebPortal\lib\UnitySite; |
| 6 | + |
5 | 7 | $search_query = $_GET["search"]; // Search is passed as a get var |
6 | 8 | if (empty($search_query)) { |
7 | 9 | echo "<span>No Results</span>"; |
8 | | -} else { |
9 | | - $assocs = $LDAP->getAllPIGroups($SQL, $MAILER, $REDIS, $WEBHOOK); |
| 10 | + UnitySite::die("no results"); |
| 11 | +} |
| 12 | + |
| 13 | +$assocs = $LDAP->getAllPIGroups($SQL, $MAILER, $REDIS, $WEBHOOK); |
10 | 14 |
|
11 | | - $MAX_COUNT = 10; // Max results of PI search |
| 15 | +$MAX_COUNT = 10; // Max results of PI search |
12 | 16 |
|
13 | | - $out = array(); |
14 | | - foreach ($assocs as $assoc_obj) { |
15 | | - $assoc = $assoc_obj->getPIUID(); |
16 | | - // loop through each association |
17 | | - if (strpos($assoc, $search_query) !== false) { |
| 17 | +$out = array(); |
| 18 | +foreach ($assocs as $assoc_obj) { |
| 19 | + $assoc = $assoc_obj->getPIUID(); |
| 20 | + // loop through each association |
| 21 | + if (strpos($assoc, $search_query) !== false) { |
| 22 | + array_push($out, $assoc); |
| 23 | + if (count($out) >= $MAX_COUNT) { |
| 24 | + break; |
| 25 | + } |
| 26 | + } |
| 27 | + $fn = strtolower($assoc_obj->getOwner()->getFullName()); |
| 28 | + if (strpos($fn, strtolower($search_query)) !== false) { |
| 29 | + if (!in_array($assoc, $out)) { |
18 | 30 | array_push($out, $assoc); |
19 | 31 | if (count($out) >= $MAX_COUNT) { |
20 | 32 | break; |
21 | 33 | } |
22 | 34 | } |
23 | | - $fn = strtolower($assoc_obj->getOwner()->getFullName()); |
24 | | - if (strpos($fn, strtolower($search_query)) !== false) { |
25 | | - if (!in_array($assoc, $out)) { |
26 | | - array_push($out, $assoc); |
27 | | - if (count($out) >= $MAX_COUNT) { |
28 | | - break; |
29 | | - } |
30 | | - } |
31 | | - } |
32 | 35 | } |
| 36 | +} |
33 | 37 |
|
34 | | - foreach ($out as $pi_acct) { |
35 | | - echo "<span>$pi_acct</span>"; |
36 | | - } |
| 38 | +foreach ($out as $pi_acct) { |
| 39 | + echo "<span>$pi_acct</span>"; |
37 | 40 | } |
0 commit comments