Skip to content

Commit d1f07cb

Browse files
committed
revert conditional 2
1 parent d2f4c87 commit d1f07cb

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

webroot/panel/modal/pi_search.php

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,39 @@
22

33
require_once __DIR__ . "/../../../resources/autoload.php"; // Load required libs
44

5+
use UnityWebPortal\lib\UnitySite;
6+
57
$search_query = $_GET["search"]; // Search is passed as a get var
68
if (empty($search_query)) {
79
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);
1014

11-
$MAX_COUNT = 10; // Max results of PI search
15+
$MAX_COUNT = 10; // Max results of PI search
1216

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)) {
1830
array_push($out, $assoc);
1931
if (count($out) >= $MAX_COUNT) {
2032
break;
2133
}
2234
}
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-
}
3235
}
36+
}
3337

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>";
3740
}

0 commit comments

Comments
 (0)