Beispiel #1
0
 public static function getAllValidUsers($ownerUid = 0)
 {
     $users = $uids = array();
     // -- In the unexpected event that the user with UID=$ownerUid cannot be found in the usual ways
     $dummyOwnerRecord = array("name" => "dummy", "uid" => $ownerUid, "gecos" => "uid=" . $ownerUid);
     // -- Fetch special users from local DB
     foreach (auth::getSpecialUsers(TRUE) as $row) {
         $users[strtolower(functions::strip_accents($row["gecos"]))] = array("name" => $row["name"], "uid" => $row["uid"], "gecos" => $row["gecos"]);
         $uids[$row["uid"]] = 1;
     }
     // -- Fetch active users from EA
     foreach (people::getPeopleArray("all") as $row) {
         $name = "";
         $row["nw_fullname"] = functions::utf8encode($row["nw_fullname"]);
         // Use SU usernames before trying KTH usernames
         if (!empty($row["nw_acc_su"])) {
             $name = $row["nw_acc_su"];
         } elseif (!empty($row["nw_acc_kth"])) {
             $name = $row["nw_acc_kth"];
         }
         // Get UID from local passwd file
         $u = posix_getpwnam($name);
         if (!empty($u["uid"]) && !preg_match("/20[0-9][0-9]/i", $name)) {
             // Not sure what the YYYY test is for
             $users[strtolower(functions::strip_accents($row["nw_fullname"]))] = array("name" => $name, "uid" => $u["uid"], "gecos" => $row["nw_fullname"]);
             $uids[$u["uid"]] = 1;
         }
     }
     if (!empty($ownerUid) && !in_array($ownerUid, array_keys($uids))) {
         $users["~~owner"] = $dummyOwnerRecord;
     }
     ksort($users);
     return $users;
 }