diff --git a/resources/init.php b/resources/init.php index b34df57a..6bc098de 100644 --- a/resources/init.php +++ b/resources/init.php @@ -119,10 +119,10 @@ $SEND_PIMESG_TO_ADMINS = $CONFIG["mail"]["send_pimesg_to_admins"]; $SQL->addLog( - $OPERATOR->getUID(), + $OPERATOR->uid, $_SERVER['REMOTE_ADDR'], "user_login", - $OPERATOR->getUID() + $OPERATOR->uid ); if (!$_SESSION["user_exists"]) { diff --git a/resources/lib/UnityGroup.php b/resources/lib/UnityGroup.php index 9fac0191..4a79b444 100644 --- a/resources/lib/UnityGroup.php +++ b/resources/lib/UnityGroup.php @@ -11,7 +11,7 @@ class UnityGroup { public const PI_PREFIX = "pi_"; - private $pi_uid; + public $gid; // Services private $LDAP; @@ -23,13 +23,13 @@ class UnityGroup /** * Constructor for the object * - * @param string $pi_uid PI UID in the format + * @param string $gid PI UID in the format * @param LDAP $LDAP LDAP Connection * @param SQL $SQL SQL Connection */ - public function __construct($pi_uid, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK) + public function __construct($gid, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK) { - $this->pi_uid = $pi_uid; + $this->gid = $gid; $this->LDAP = $LDAP; $this->SQL = $SQL; @@ -44,22 +44,12 @@ public function equals($other_group) throw new Exception("Unable to check equality because the parameter is not a " . self::class . " object"); } - return $this->getPIUID() == $other_group->getPIUID(); + return $this->gid == $other_group->gid; } public function __toString() { - return $this->getPIUID(); - } - - /** - * Returns this group's PI UID - * - * @return string PI UID of the group - */ - public function getPIUID() - { - return $this->pi_uid; + return $this->gid; } /** @@ -84,11 +74,11 @@ public function requestGroup($firstname, $lastname, $email, $org, $send_mail_to_ } // check if account deletion request already exists - if ($this->SQL->accDeletionRequestExists($this->getOwner()->getUID())) { + if ($this->SQL->accDeletionRequestExists($this->getOwner()->uid)) { return; } - $this->SQL->addRequest($this->getOwner()->getUID(), $firstname, $lastname, $email, $org); + $this->SQL->addRequest($this->getOwner()->uid, $firstname, $lastname, $email, $org); if ($send_mail) { // send email to requestor @@ -100,7 +90,7 @@ public function requestGroup($firstname, $lastname, $email, $org, $send_mail_to_ $this->WEBHOOK->sendWebhook( "group_request_admin", array( - "user" => $this->getOwner()->getUID(), + "user" => $this->getOwner()->uid, "org" => $org, "name" => "$firstname $lastname", "email" => $email @@ -112,7 +102,7 @@ public function requestGroup($firstname, $lastname, $email, $org, $send_mail_to_ "admin", "group_request_admin", array( - "user" => $this->getOwner()->getUID(), + "user" => $this->getOwner()->uid, "org" => $org, "name" => "$firstname $lastname", "email" => $email @@ -124,7 +114,7 @@ public function requestGroup($firstname, $lastname, $email, $org, $send_mail_to_ "pi_approve", "group_request_admin", array( - "user" => $this->getOwner()->getUID(), + "user" => $this->getOwner()->uid, "org" => $org, "name" => "$firstname $lastname", "email" => $email @@ -138,7 +128,7 @@ public function requestGroup($firstname, $lastname, $email, $org, $send_mail_to_ */ public function approveGroup($operator = null, $send_mail = true) { - $uid = $this->getOwner()->getUID(); + $uid = $this->getOwner()->uid; $request = $this->SQL->getRequest($uid, UnitySQL::REQUEST_BECOME_PI); // check for edge cases... @@ -162,15 +152,15 @@ public function approveGroup($operator = null, $send_mail = true) // remove the request from the sql table // this will silently fail if the request doesn't exist - $this->SQL->removeRequest($this->getOwner()->getUID()); + $this->SQL->removeRequest($this->getOwner()->uid); - $operator = is_null($operator) ? $this->getOwner()->getUID() : $operator->getUID(); + $operator = is_null($operator) ? $this->getOwner()->uid : $operator->uid; $this->SQL->addLog( $operator, $_SERVER['REMOTE_ADDR'], "approved_group", - $this->getOwner()->getUID() + $this->getOwner()->uid ); // send email to the newly approved PI @@ -188,19 +178,19 @@ public function approveGroup($operator = null, $send_mail = true) public function denyGroup($operator = null, $send_mail = true) { // remove request - this will fail silently if the request doesn't exist - $this->SQL->removeRequest($this->getOwner()->getUID()); + $this->SQL->removeRequest($this->getOwner()->uid); if ($this->exists()) { return; } - $operator = is_null($operator) ? $this->getOwner()->getUID() : $operator->getUID(); + $operator = is_null($operator) ? $this->getOwner()->uid : $operator->uid; $this->SQL->addLog( $operator, $_SERVER['REMOTE_ADDR'], "denied_group", - $this->getOwner()->getUID() + $this->getOwner()->uid ); // send email to the requestor @@ -214,17 +204,17 @@ public function denyGroup($operator = null, $send_mail = true) public function cancelGroupRequest($send_mail = true) { - if (!$this->SQL->requestExists($this->getOwner()->getUID())) { + if (!$this->SQL->requestExists($this->getOwner()->uid)) { return; } - $this->SQL->removeRequest($this->getOwner()->getUID()); + $this->SQL->removeRequest($this->getOwner()->uid); if ($send_mail) { $this->MAILER->sendMail( "admin", "group_request_cancelled", - ["uid" => $this->getOwner()->getUID()], + ["uid" => $this->getOwner()->uid], ); } } @@ -235,14 +225,14 @@ public function cancelGroupJoinRequest($user, $send_mail = true) return; } - $this->SQL->removeRequest($user->getUID(), $this->pi_uid); + $this->SQL->removeRequest($user->uid, $this->gid); if ($send_mail) { // send email to requestor $this->MAILER->sendMail( $this->getOwner()->getMail(), "group_join_request_cancelled", - ["uid" => $user->getUID()] + ["uid" => $user->uid] ); } } @@ -254,7 +244,7 @@ public function cancelGroupJoinRequest($user, $send_mail = true) // { // // remove any pending requests // // this will silently fail if the request doesn't exist (which is what we want) - // $this->SQL->removeRequests($this->pi_uid); + // $this->SQL->removeRequests($this->gid); // // we don't need to do anything extra if the group is already deleted // if (!$this->exists()) { @@ -268,9 +258,9 @@ public function cancelGroupJoinRequest($user, $send_mail = true) // $ldapPiGroupEntry = $this->getLDAPPiGroup(); // if ($ldapPiGroupEntry->exists()) { // $ldapPiGroupEntry->delete(); - // $this->REDIS->removeCacheArray("sorted_groups", "", $this->getPIUID()); + // $this->REDIS->removeCacheArray("sorted_groups", "", $this->gid); // foreach ($users as $user) { - // $this->REDIS->removeCacheArray($user->getUID(), "groups", $this->getPIUID()); + // $this->REDIS->removeCacheArray($user->uid, "groups", $this->gid); // } // } @@ -280,7 +270,7 @@ public function cancelGroupJoinRequest($user, $send_mail = true) // $this->MAILER->sendMail( // $user->getMail(), // "group_disband", - // array("group_name" => $this->pi_uid) + // array("group_name" => $this->gid) // ); // } // } @@ -291,9 +281,7 @@ public function cancelGroupJoinRequest($user, $send_mail = true) */ public function approveUser($new_user, $send_mail = true) { - $uid = $new_user->getUID(); - $gid = $this->getPIUID(); - $request = $this->SQL->getRequest($uid, $gid); + $request = $this->SQL->getRequest($new_user->uid, $this->gid); // check if user exists if (!$new_user->exists()) { $new_user->init( @@ -307,7 +295,7 @@ public function approveUser($new_user, $send_mail = true) // add user to the LDAP object $this->addUserToGroup($new_user); - $this->SQL->removeRequest($new_user->getUID(), $this->pi_uid); + $this->SQL->removeRequest($new_user->uid, $this->gid); // send email to the requestor if ($send_mail) { @@ -315,38 +303,36 @@ public function approveUser($new_user, $send_mail = true) $this->MAILER->sendMail( $new_user->getMail(), "group_user_added", - array("group" => $this->pi_uid) + array("group" => $this->gid) ); // send email to the PI $this->MAILER->sendMail( $this->getOwner()->getMail(), "group_user_added_owner", array( - "group" => $this->pi_uid, - "user" => $new_user->getUID(), + "group" => $this->gid, + "user" => $new_user->uid, "name" => $request["firstname"] . " " . $request["lastname"], "email" => $request["email"], "org" => $request["org"], - ) + ) ); } } public function denyUser($new_user, $send_mail = true) { - $uid = $new_user->getUID(); - $gid = $this->getPIUID(); - $request = $this->SQL->getRequest($uid, $gid); + $request = $this->SQL->getRequest($new_user->uid, $this->gid); // remove request, this will fail silently if the request doesn't exist - $this->SQL->removeRequest($new_user->getUID(), $this->pi_uid); + $this->SQL->removeRequest($new_user->uid, $this->gid); if ($send_mail) { // send email to the user $this->MAILER->sendMail( $new_user->getMail(), "group_user_denied", - array("group" => $this->pi_uid) + array("group" => $this->gid) ); // send email to the PI @@ -354,12 +340,12 @@ public function denyUser($new_user, $send_mail = true) $this->getOwner()->getMail(), "group_user_denied_owner", array( - "group" => $this->pi_uid, - "user" => $new_user->getUID(), + "group" => $this->gid, + "user" => $new_user->uid, "name" => $new_user->getFullName(), "email" => $new_user->getMail(), "org" => $new_user->getOrg() - ) + ) ); } } @@ -370,7 +356,7 @@ public function removeUser($new_user, $send_mail = true) return; } - if ($new_user->getUID() == $this->getOwner()->getUID()) { + if ($new_user->uid == $this->getOwner()->uid) { throw new Exception("Cannot delete group owner from group. Disband group instead"); } @@ -382,7 +368,7 @@ public function removeUser($new_user, $send_mail = true) $this->MAILER->sendMail( $new_user->getMail(), "group_user_removed", - array("group" => $this->pi_uid) + array("group" => $this->gid) ); // send email to the PI @@ -390,12 +376,12 @@ public function removeUser($new_user, $send_mail = true) $this->getOwner()->getMail(), "group_user_removed_owner", array( - "group" => $this->pi_uid, - "user" => $new_user->getUID(), + "group" => $this->gid, + "user" => $new_user->uid, "name" => $new_user->getFullName(), "email" => $new_user->getMail(), "org" => $new_user->getOrg() - ) + ) ); } } @@ -412,19 +398,19 @@ public function newUserRequest($new_user, $firstname, $lastname, $email, $org, $ return; } - if ($this->SQL->accDeletionRequestExists($new_user->getUID())) { + if ($this->SQL->accDeletionRequestExists($new_user->uid)) { throw new Exception("user '$new_user' requested account deletion"); return; } - $this->addRequest($new_user->getUID(), $firstname, $lastname, $email, $org); + $this->addRequest($new_user->uid, $firstname, $lastname, $email, $org); if ($send_mail) { // send email to user $this->MAILER->sendMail( $email, "group_user_request", - array("group" => $this->pi_uid) + array("group" => $this->gid) ); // send email to PI @@ -432,19 +418,19 @@ public function newUserRequest($new_user, $firstname, $lastname, $email, $org, $ $this->getOwner()->getMail(), "group_user_request_owner", array( - "group" => $this->pi_uid, - "user" => $new_user->getUID(), + "group" => $this->gid, + "user" => $new_user->uid, "name" => "$firstname $lastname", "email" => $email, "org" => $org, - ) + ) ); } } public function getRequests() { - $requests = $this->SQL->getRequests($this->pi_uid); + $requests = $this->SQL->getRequests($this->gid); $out = array(); foreach ($requests as $request) { @@ -476,17 +462,16 @@ public function getGroupMembers($ignorecache = false) { $members = $this->getGroupMemberUIDs($ignorecache); $out = array(); - $owner_uid = $this->getOwner()->getUID(); foreach ($members as $member) { - $user_obj = new UnityUser( - $member, - $this->LDAP, - $this->SQL, - $this->MAILER, - $this->REDIS, - $this->WEBHOOK - ); - array_push($out, $user_obj); + $user_obj = new UnityUser( + $member, + $this->LDAP, + $this->SQL, + $this->MAILER, + $this->REDIS, + $this->WEBHOOK + ); + array_push($out, $user_obj); } return $out; } @@ -494,7 +479,7 @@ public function getGroupMembers($ignorecache = false) public function getGroupMemberUIDs($ignorecache = false) { if (!$ignorecache) { - $cached_val = $this->REDIS->getCache($this->getPIUID(), "members"); + $cached_val = $this->REDIS->getCache($this->gid, "members"); if (!is_null($cached_val)) { $members = $cached_val; } @@ -507,7 +492,7 @@ public function getGroupMemberUIDs($ignorecache = false) } if (!$ignorecache && $updatecache) { sort($members); - $this->REDIS->setCache($this->getPIUID(), "members", $members); + $this->REDIS->setCache($this->gid, "members", $members); } return $members; } @@ -517,7 +502,7 @@ public function requestExists($user) $requesters = $this->getRequests(); if (count($requesters) > 0) { foreach ($requesters as $requester) { - if ($requester[0]->getUID() == $user->getUID()) { + if ($requester[0]->uid == $user->uid) { return true; } } @@ -543,11 +528,11 @@ private function init() $ldapPiGroupEntry->setAttribute("objectclass", UnityLDAP::POSIX_GROUP_CLASS); $ldapPiGroupEntry->setAttribute("gidnumber", strval($nextGID)); - $ldapPiGroupEntry->setAttribute("memberuid", array($owner->getUID())); + $ldapPiGroupEntry->setAttribute("memberuid", array($owner->uid)); $ldapPiGroupEntry->write(); } - $this->REDIS->appendCacheArray("sorted_groups", "", $this->getPIUID()); + $this->REDIS->appendCacheArray("sorted_groups", "", $this->gid); // TODO if we ever make this project based, we need to update the cache here with the memberuid } @@ -556,30 +541,30 @@ private function addUserToGroup($new_user) { // Add to LDAP Group $pi_group = $this->getLDAPPiGroup(); - $pi_group->appendAttribute("memberuid", $new_user->getUID()); + $pi_group->appendAttribute("memberuid", $new_user->uid); $pi_group->write(); - $this->REDIS->appendCacheArray($this->getPIUID(), "members", $new_user->getUID()); - $this->REDIS->appendCacheArray($new_user->getUID(), "groups", $this->getPIUID()); + $this->REDIS->appendCacheArray($this->gid, "members", $new_user->uid); + $this->REDIS->appendCacheArray($new_user->uid, "groups", $this->gid); } private function removeUserFromGroup($old_user) { // Remove from LDAP Group $pi_group = $this->getLDAPPiGroup(); - $pi_group->removeAttributeEntryByValue("memberuid", $old_user->getUID()); + $pi_group->removeAttributeEntryByValue("memberuid", $old_user->uid); $pi_group->write(); - $this->REDIS->removeCacheArray($this->getPIUID(), "members", $old_user->getUID()); - $this->REDIS->removeCacheArray($old_user->getUID(), "groups", $this->getPIUID()); + $this->REDIS->removeCacheArray($this->gid, "members", $old_user->uid); + $this->REDIS->removeCacheArray($old_user->uid, "groups", $this->gid); } public function userExists($user) { - return in_array($user->getUID(), $this->getGroupMemberUIDs()); + return in_array($user->uid, $this->getGroupMemberUIDs()); } private function addRequest($uid, $firstname, $lastname, $email, $org) { - $this->SQL->addRequest($uid, $firstname, $lastname, $email, $org, $this->pi_uid); + $this->SQL->addRequest($uid, $firstname, $lastname, $email, $org, $this->gid); } // @@ -589,7 +574,7 @@ private function addRequest($uid, $firstname, $lastname, $email, $org) public function getOwner() { return new UnityUser( - self::getUIDfromPIUID($this->pi_uid), + self::GID2OwnerUID($this->gid), $this->LDAP, $this->SQL, $this->MAILER, @@ -600,20 +585,19 @@ public function getOwner() public function getLDAPPiGroup() { - return $this->LDAP->getPIGroupEntry($this->pi_uid); + return $this->LDAP->getPIGroupEntry($this->gid); } - public static function getPIUIDfromUID($uid) + public static function ownerUID2GID($uid) { return self::PI_PREFIX . $uid; } - public static function getUIDfromPIUID($pi_uid) + public static function GID2OwnerUID($gid) { - if (substr($pi_uid, 0, strlen(self::PI_PREFIX)) == self::PI_PREFIX) { - return substr($pi_uid, strlen(self::PI_PREFIX)); - } else { - throw new Exception("PI netid doesn't have the correct prefix."); + if (substr($gid, 0, strlen(self::PI_PREFIX)) != self::PI_PREFIX) { + throw new Exception("PI group GID doesn't have the correct prefix."); } + return substr($gid, strlen(self::PI_PREFIX)); } } diff --git a/resources/lib/UnityOrg.php b/resources/lib/UnityOrg.php index c965d628..3f3ad111 100644 --- a/resources/lib/UnityOrg.php +++ b/resources/lib/UnityOrg.php @@ -6,7 +6,7 @@ class UnityOrg { - private $orgid; + public $gid; private $MAILER; private $SQL; @@ -14,9 +14,9 @@ class UnityOrg private $REDIS; private $WEBHOOK; - public function __construct($orgid, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK) + public function __construct($gid, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK) { - $this->orgid = $orgid; + $this->gid = $gid; $this->LDAP = $LDAP; $this->SQL = $SQL; @@ -37,7 +37,7 @@ public function init() $org_group->write(); } - $this->REDIS->appendCacheArray("sorted_orgs", "", $this->getOrgID()); + $this->REDIS->appendCacheArray("sorted_orgs", "", $this->gid); } public function exists() @@ -47,34 +47,28 @@ public function exists() public function getLDAPOrgGroup() { - return $this->LDAP->getOrgGroupEntry($this->orgid); - } - - public function getOrgID() - { - return $this->orgid; + return $this->LDAP->getOrgGroupEntry($this->gid); } public function inOrg($user, $ignorecache = false) { - return in_array($user->getUID(), $this->getOrgMemberUIDs($ignorecache)); + return in_array($user->uid, $this->getOrgMemberUIDs($ignorecache)); } public function getOrgMembers($ignorecache = false) { $members = $this->getGroupMemberUIDs($ignorecache); $out = array(); - $owner_uid = $this->getOwner()->getUID(); foreach ($members as $member) { - $user_obj = new UnityUser( - $member, - $this->LDAP, - $this->SQL, - $this->MAILER, - $this->REDIS, - $this->WEBHOOK - ); - array_push($out, $user_obj); + $user_obj = new UnityUser( + $member, + $this->LDAP, + $this->SQL, + $this->MAILER, + $this->REDIS, + $this->WEBHOOK + ); + array_push($out, $user_obj); } return $out; } @@ -82,7 +76,7 @@ public function getOrgMembers($ignorecache = false) public function getOrgMemberUIDs($ignorecache = false) { if (!$ignorecache) { - $cached_val = $this->REDIS->getCache($this->getOrgID(), "members"); + $cached_val = $this->REDIS->getCache($this->gid, "members"); if (!is_null($cached_val)) { $members = $cached_val; } @@ -95,7 +89,7 @@ public function getOrgMemberUIDs($ignorecache = false) } if (!$ignorecache && $updatecache) { sort($members); - $this->REDIS->setCache($this->getOrgID(), "members", $members); + $this->REDIS->setCache($this->gid, "members", $members); } return $members; } @@ -103,16 +97,16 @@ public function getOrgMemberUIDs($ignorecache = false) public function addUser($user) { $org_group = $this->getLDAPOrgGroup(); - $org_group->appendAttribute("memberuid", $user->getUID()); + $org_group->appendAttribute("memberuid", $user->uid); $org_group->write(); - $this->REDIS->appendCacheArray($this->getOrgID(), "members", $user->getUID()); + $this->REDIS->appendCacheArray($this->gid, "members", $user->uid); } public function removeUser($user) { $org_group = $this->getLDAPOrgGroup(); - $org_group->removeAttributeEntryByValue("memberuid", $user->getUID()); + $org_group->removeAttributeEntryByValue("memberuid", $user->uid); $org_group->write(); - $this->REDIS->removeCacheArray($this->getOrgID(), "members", $user->getUID()); + $this->REDIS->removeCacheArray($this->gid, "members", $user->uid); } } diff --git a/resources/lib/UnitySQL.php b/resources/lib/UnitySQL.php index 26721a6c..db004c50 100644 --- a/resources/lib/UnitySQL.php +++ b/resources/lib/UnitySQL.php @@ -107,7 +107,7 @@ public function requestExists($requestor, $dest = self::REQUEST_BECOME_PI) try { $this->getRequest($requestor, $dest); return true; - // FIXME use a specific exception + // FIXME use a specific exception } catch (\Exception) { return false; } @@ -165,10 +165,8 @@ public function addNotice($title, $date, $content, $operator) $stmt->execute(); - $operator = $operator->getUID(); - $this->addLog( - $operator, + $operator->uid, $_SERVER['REMOTE_ADDR'], "added_cluster_notice", $operator @@ -252,10 +250,8 @@ public function editPage($id, $content, $operator) $stmt->execute(); - $operator = $operator->getUID(); - $this->addLog( - $operator, + $operator->uid, $_SERVER['REMOTE_ADDR'], "edited_page", $operator @@ -266,7 +262,7 @@ public function editPage($id, $content, $operator) public function addLog($operator, $operator_ip, $action_type, $recipient) { $stmt = $this->conn->prepare( - "INSERT INTO " . self::TABLE_AUDIT_LOG . " (operator, operator_ip, action_type, recipient) + "INSERT INTO " . self::TABLE_AUDIT_LOG . " (operator, operator_ip, action_type, recipient) VALUE (:operator, :operator_ip, :action_type, :recipient)" ); $stmt->bindParam(":operator", $operator); diff --git a/resources/lib/UnityUser.php b/resources/lib/UnityUser.php index 983e2a5f..77639a81 100644 --- a/resources/lib/UnityUser.php +++ b/resources/lib/UnityUser.php @@ -9,7 +9,7 @@ class UnityUser { private const HOME_DIR = "/home/"; - private $uid; + public $uid; // service stack private $LDAP; @@ -35,7 +35,7 @@ public function equals($other_user) throw new Exception("Unable to check equality because the parameter is not a " . self::class . " object"); } - return $this->getUID() == $other_user->getUID(); + return $this->uid == $other_user->uid; } public function __toString() @@ -59,7 +59,7 @@ public function init($firstname, $lastname, $email, $org, $send_mail = true) // Create LDAP group // $ldapGroupEntry = $this->getLDAPGroup(); - $id = $this->LDAP->getUnassignedID($this->getUID(), $this->SQL); + $id = $this->LDAP->getUnassignedID($this->uid, $this->SQL); if (!$ldapGroupEntry->exists()) { $ldapGroupEntry->setAttribute("objectclass", UnityLDAP::POSIX_GROUP_CLASS); @@ -113,20 +113,20 @@ public function init($firstname, $lastname, $email, $org, $send_mail = true) } // add to user group as well as user OU - $this->LDAP->getUserGroup()->appendAttribute("memberuid", $this->getUID()); + $this->LDAP->getUserGroup()->appendAttribute("memberuid", $this->uid); $this->LDAP->getUserGroup()->write(); // add user to cache - $this->REDIS->appendCacheArray("sorted_users", "", $this->getUID()); + $this->REDIS->appendCacheArray("sorted_users", "", $this->uid); // // add to audit log // $this->SQL->addLog( - $this->getUID(), + $this->uid, $_SERVER['REMOTE_ADDR'], "user_added", - $this->getUID() + $this->uid ); // @@ -170,16 +170,6 @@ public function exists() // User Attribute Functions // - /** - * Get method for NetID - * - * @return string Net ID of user - */ - public function getUID() - { - return $this->uid; - } - public function setOrg($org) { $ldap_user = $this->getLDAPUser(); @@ -192,7 +182,7 @@ public function getOrg($ignorecache = false) { assert($this->exists()); if (!$ignorecache) { - $cached_val = $this->REDIS->getCache($this->getUID(), "org"); + $cached_val = $this->REDIS->getCache($this->uid, "org"); if (!is_null($cached_val)) { return $cached_val; } @@ -202,7 +192,7 @@ public function getOrg($ignorecache = false) $org = $this->getLDAPUser()->getAttribute("o")[0]; if (!$ignorecache) { - $this->REDIS->setCache($this->getUID(), "org", $org); + $this->REDIS->setCache($this->uid, "org", $org); } return $this->getLDAPUser()->getAttribute("o")[0]; @@ -220,13 +210,13 @@ public function setFirstname($firstname, $operator = null) { $ldap_user = $this->getLDAPUser(); $ldap_user->setAttribute("givenname", $firstname); - $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); + $operator = is_null($operator) ? $this->uid : $operator->uid; $this->SQL->addLog( $operator, $_SERVER['REMOTE_ADDR'], "firstname_changed", - $this->getUID() + $this->uid ); $ldap_user->write(); @@ -242,7 +232,7 @@ public function getFirstname($ignorecache = false) { assert($this->exists()); if (!$ignorecache) { - $cached_val = $this->REDIS->getCache($this->getUID(), "firstname"); + $cached_val = $this->REDIS->getCache($this->uid, "firstname"); if (!is_null($cached_val)) { return $cached_val; } @@ -252,7 +242,7 @@ public function getFirstname($ignorecache = false) $firstname = $this->getLDAPUser()->getAttribute("givenname")[0]; if (!$ignorecache) { - $this->REDIS->setCache($this->getUID(), "firstname", $firstname); + $this->REDIS->setCache($this->uid, "firstname", $firstname); } return $firstname; @@ -270,13 +260,13 @@ public function setLastname($lastname, $operator = null) { $ldap_user = $this->getLDAPUser(); $ldap_user->setAttribute("sn", $lastname); - $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); + $operator = is_null($operator) ? $this->uid : $operator->uid; $this->SQL->addLog( $operator, $_SERVER['REMOTE_ADDR'], "lastname_changed", - $this->getUID() + $this->uid ); $this->getLDAPUser()->write(); @@ -292,7 +282,7 @@ public function getLastname($ignorecache = false) { assert($this->exists()); if (!$ignorecache) { - $cached_val = $this->REDIS->getCache($this->getUID(), "lastname"); + $cached_val = $this->REDIS->getCache($this->uid, "lastname"); if (!is_null($cached_val)) { return $cached_val; } @@ -302,7 +292,7 @@ public function getLastname($ignorecache = false) $lastname = $this->getLDAPUser()->getAttribute("sn")[0]; if (!$ignorecache) { - $this->REDIS->setCache($this->getUID(), "lastname", $lastname); + $this->REDIS->setCache($this->uid, "lastname", $lastname); } return $lastname; @@ -326,13 +316,13 @@ public function setMail($email, $operator = null) { $ldap_user = $this->getLDAPUser(); $ldap_user->setAttribute("mail", $email); - $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); + $operator = is_null($operator) ? $this->uid : $operator->uid; $this->SQL->addLog( $operator, $_SERVER['REMOTE_ADDR'], "email_changed", - $this->getUID() + $this->uid ); $this->getLDAPUser()->write(); @@ -348,7 +338,7 @@ public function getMail($ignorecache = false) { assert($this->exists()); if (!$ignorecache) { - $cached_val = $this->REDIS->getCache($this->getUID(), "mail"); + $cached_val = $this->REDIS->getCache($this->uid, "mail"); if (!is_null($cached_val)) { return $cached_val; } @@ -358,7 +348,7 @@ public function getMail($ignorecache = false) $mail = $this->getLDAPUser()->getAttribute("mail")[0]; if (!$ignorecache) { - $this->REDIS->setCache($this->getUID(), "mail", $mail); + $this->REDIS->setCache($this->uid, "mail", $mail); } return $mail; @@ -375,7 +365,7 @@ public function getMail($ignorecache = false) public function setSSHKeys($keys, $operator = null, $send_mail = true) { $ldapUser = $this->getLDAPUser(); - $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); + $operator = is_null($operator) ? $this->uid : $operator->uid; $keys_filt = array_values(array_unique($keys)); if ($ldapUser->exists()) { $ldapUser->setAttribute("sshpublickey", $keys_filt); @@ -391,7 +381,7 @@ public function setSSHKeys($keys, $operator = null, $send_mail = true) $operator, $_SERVER['REMOTE_ADDR'], "sshkey_modify", - $this->getUID() + $this->uid ); if ($send_mail) { @@ -412,7 +402,7 @@ public function getSSHKeys($ignorecache = false) { assert($this->exists()); if (!$ignorecache) { - $cached_val = $this->REDIS->getCache($this->getUID(), "sshkeys"); + $cached_val = $this->REDIS->getCache($this->uid, "sshkeys"); if (!is_null($cached_val)) { return $cached_val; } @@ -428,7 +418,7 @@ public function getSSHKeys($ignorecache = false) } if (!$ignorecache) { - $this->REDIS->setCache($this->getUID(), "sshkeys", $keys); + $this->REDIS->setCache($this->uid, "sshkeys", $keys); } return $keys; @@ -460,13 +450,13 @@ public function setLoginShell($shell, $operator = null, $send_mail = true) $ldapUser->write(); } - $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); + $operator = is_null($operator) ? $this->uid : $operator->uid; $this->SQL->addLog( $operator, $_SERVER['REMOTE_ADDR'], "loginshell_changed", - $this->getUID() + $this->uid ); $this->REDIS->setCache($this->uid, "loginshell", $shell); @@ -489,7 +479,7 @@ public function getLoginShell($ignorecache = false) { assert($this->exists()); if (!$ignorecache) { - $cached_val = $this->REDIS->getCache($this->getUID(), "loginshell"); + $cached_val = $this->REDIS->getCache($this->uid, "loginshell"); if (!is_null($cached_val)) { return $cached_val; } @@ -501,7 +491,7 @@ public function getLoginShell($ignorecache = false) $loginshell = $ldapUser->getAttribute("loginshell")[0]; if (!$ignorecache) { - $this->REDIS->setCache($this->getUID(), "loginshell", $loginshell); + $this->REDIS->setCache($this->uid, "loginshell", $loginshell); } return $loginshell; @@ -516,13 +506,13 @@ public function setHomeDir($home, $operator = null) if ($ldapUser->exists()) { $ldapUser->setAttribute("homedirectory", $home); $ldapUser->write(); - $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); + $operator = is_null($operator) ? $this->uid : $operator->uid; $this->SQL->addLog( $operator, $_SERVER['REMOTE_ADDR'], "homedir_changed", - $this->getUID() + $this->uid ); $this->REDIS->setCache($this->uid, "homedir", $home); @@ -538,7 +528,7 @@ public function getHomeDir($ignorecache = false) { assert($this->exists()); if (!$ignorecache) { - $cached_val = $this->REDIS->getCache($this->getUID(), "homedir"); + $cached_val = $this->REDIS->getCache($this->uid, "homedir"); if (!is_null($cached_val)) { return $cached_val; } @@ -550,7 +540,7 @@ public function getHomeDir($ignorecache = false) $homedir = $ldapUser->getAttribute("homedirectory"); if (!$ignorecache) { - $this->REDIS->setCache($this->getUID(), "homedir", $homedir); + $this->REDIS->setCache($this->uid, "homedir", $homedir); } return $homedir; @@ -583,7 +573,7 @@ public function isPI() public function getPIGroup() { return new UnityGroup( - UnityGroup::getPIUIDfromUID($this->uid), + UnityGroup::ownerUID2GID($this->uid), $this->LDAP, $this->SQL, $this->MAILER, @@ -613,7 +603,7 @@ public function getGroups($ignorecache = false) $out = array(); if (!$ignorecache) { - $cached_val = $this->REDIS->getCache($this->getUID(), "groups"); + $cached_val = $this->REDIS->getCache($this->uid, "groups"); if (!is_null($cached_val)) { $groups = $cached_val; foreach ($groups as $group) { @@ -637,14 +627,14 @@ public function getGroups($ignorecache = false) $cache_arr = array(); foreach ($all_pi_groups as $pi_group) { - if (in_array($this->getUID(), $pi_group->getGroupMemberUIDs())) { + if (in_array($this->uid, $pi_group->getGroupMemberUIDs())) { array_push($out, $pi_group); - array_push($cache_arr, $pi_group->getPIUID()); + array_push($cache_arr, $pi_group->gid); } } if (!$ignorecache) { - $this->REDIS->setCache($this->getUID(), "groups", $cache_arr); + $this->REDIS->setCache($this->uid, "groups", $cache_arr); } return $out; @@ -655,12 +645,12 @@ public function getGroups($ignorecache = false) */ public function requestAccountDeletion() { - $this->SQL->addAccountDeletionRequest($this->getUID()); + $this->SQL->addAccountDeletionRequest($this->uid); $this->MAILER->sendMail( "admin", "account_deletion_request_admin", array( - "user" => $this->getUID(), + "user" => $this->uid, "name" => $this->getFullname(), "email" => $this->getMail() ) @@ -674,7 +664,7 @@ public function requestAccountDeletion() */ public function hasRequestedAccountDeletion() { - return $this->SQL->accDeletionRequestExists($this->getUID()); + return $this->SQL->accDeletionRequestExists($this->uid); } /** diff --git a/test/functional/AccountDeletionRequestTest.php b/test/functional/AccountDeletionRequestTest.php index 08eb2af4..e6fae600 100644 --- a/test/functional/AccountDeletionRequestTest.php +++ b/test/functional/AccountDeletionRequestTest.php @@ -9,10 +9,10 @@ private function assertNumberAccountDeletionRequests(int $x) global $USER, $SQL; if ($x == 0) { $this->assertFalse($USER->hasRequestedAccountDeletion()); - $this->assertFalse($SQL->accDeletionRequestExists($USER->getUID())); + $this->assertFalse($SQL->accDeletionRequestExists($USER->uid)); } elseif ($x > 0) { $this->assertTrue($USER->hasRequestedAccountDeletion()); - $this->assertTrue($SQL->accDeletionRequestExists($USER->getUID())); + $this->assertTrue($SQL->accDeletionRequestExists($USER->uid)); } else { throw new RuntimeError("x must not be negative"); } @@ -25,7 +25,7 @@ private function getNumberAccountDeletionRequests() $stmt = $SQL->getConn()->prepare( "SELECT * FROM account_deletion_requests WHERE uid=:uid" ); - $uid = $USER->getUID(); + $uid = $USER->uid; $stmt->bindParam(":uid", $uid); $stmt->execute(); return count($stmt->fetchAll()); @@ -49,7 +49,7 @@ public function testRequestAccountDeletionUserHasNoGroups() ); $this->assertNumberAccountDeletionRequests(1); } finally { - $SQL->deleteAccountDeletionRequest($USER->getUID()); + $SQL->deleteAccountDeletionRequest($USER->uid); $this->assertNumberAccountDeletionRequests(0); } } @@ -68,7 +68,7 @@ public function testRequestAccountDeletionUserHasGroup() ); $this->assertNumberAccountDeletionRequests(0); } finally { - $SQL->deleteAccountDeletionRequest($USER->getUID()); + $SQL->deleteAccountDeletionRequest($USER->uid); $this->assertNumberAccountDeletionRequests(0); } } diff --git a/test/functional/NewUserTest.php b/test/functional/NewUserTest.php index b0f0fb23..4da13cce 100644 --- a/test/functional/NewUserTest.php +++ b/test/functional/NewUserTest.php @@ -13,7 +13,7 @@ private function assertRequestedPIGroup(bool $expected) global $USER, $SQL; $this->assertEquals( $expected, - $SQL->requestExists($USER->getUID(), UnitySQL::REQUEST_BECOME_PI) + $SQL->requestExists($USER->uid, UnitySQL::REQUEST_BECOME_PI) ); } @@ -22,7 +22,7 @@ private function assertRequestedMembership(bool $expected, string $gid) global $USER, $SQL; $this->assertEquals( $expected, - $SQL->requestExists($USER->getUID(), $gid) + $SQL->requestExists($USER->uid, $gid) ); } @@ -58,7 +58,7 @@ private function cancelAllRequests() private function ensureUserDoesNotExist() { global $USER, $SQL, $LDAP; - $SQL->deleteRequestsByUser($USER->getUID()); + $SQL->deleteRequestsByUser($USER->uid); if ($USER->exists()) { $org = $USER->getOrgGroup(); if ($org->exists() and $org->inOrg($USER)) { @@ -70,14 +70,14 @@ private function ensureUserDoesNotExist() } $all_users_group = $LDAP->getUserGroup(); $all_member_uids = $all_users_group->getAttribute("memberuid"); - $new_uids = array_diff($all_member_uids, [$USER->getUID()]); - if (in_array($USER->getUID(), $all_member_uids)) { + $new_uids = array_diff($all_member_uids, [$USER->uid]); + if (in_array($USER->uid, $all_member_uids)) { $all_users_group->setAttribute( "memberuid", - array_diff($all_member_uids, [$USER->getUID()]) + array_diff($all_member_uids, [$USER->uid]) ); $all_users_group->write(); - assert(!in_array($USER->getUID(), $all_users_group->getAttribute("memberuid"))); + assert(!in_array($USER->uid, $all_users_group->getAttribute("memberuid"))); } } @@ -114,7 +114,7 @@ public function testCreateUserByJoinGoup() global $USER, $SSO, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK; switchUser(...getUserIsPIHasNoMembersNoMemberRequests()); $pi_group = $USER->getPIGroup(); - $gid = $pi_group->getPIUID(); + $gid = $pi_group->gid; switchUser(...getNonExistentUser()); $this->assertTrue(!$USER->exists()); $newOrg = new UnityOrg($SSO["org"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK); @@ -123,12 +123,12 @@ public function testCreateUserByJoinGoup() $this->assertTrue(!$pi_group->userExists($USER)); $this->assertRequestedMembership(false, $gid); try { - $this->requestGroupMembership($pi_group->getPIUID()); + $this->requestGroupMembership($pi_group->gid); $this->assertRequestedMembership(true, $gid); // $second_request_failed = false; // try { - $this->requestGroupMembership($pi_group->getPIUID()); + $this->requestGroupMembership($pi_group->gid); // } catch(Exception) { // $second_request_failed = true; // } @@ -138,7 +138,7 @@ public function testCreateUserByJoinGoup() $this->cancelAllRequests(); $this->assertRequestedMembership(false, $gid); - $this->requestGroupMembership($pi_group->getPIUID()); + $this->requestGroupMembership($pi_group->gid); $this->assertTrue($pi_group->requestExists($USER)); $this->assertRequestedMembership(true, $gid); @@ -153,7 +153,7 @@ public function testCreateUserByJoinGoup() // $third_request_failed = false; // try { - $this->requestGroupMembership($pi_group->getPIUID()); + $this->requestGroupMembership($pi_group->gid); // } catch(Exception) { // $third_request_failed = true; // } @@ -182,7 +182,7 @@ public function testCreateUserByCreateGroup() // $second_request_failed = false; // try { - $this->requestGroupCreation(); + $this->requestGroupCreation(); // } catch(Exception) { // $second_request_failed = true; // } @@ -205,7 +205,7 @@ public function testCreateUserByCreateGroup() // $third_request_failed = false; // try { - $this->requestGroupCreation(); + $this->requestGroupCreation(); // } catch(Exception) { // $third_request_failed = true; // } diff --git a/test/functional/PIMemberRequestTest.php b/test/functional/PIMemberRequestTest.php index ec4cff71..51e76e79 100644 --- a/test/functional/PIMemberRequestTest.php +++ b/test/functional/PIMemberRequestTest.php @@ -28,13 +28,13 @@ public function testRequestMembership() switchUser(...getUserIsPIHasNoMembersNoMemberRequests()); $pi = $USER; $pi_group = $USER->getPIGroup(); - $gid = $pi_group->getPIUID(); + $gid = $pi_group->gid; $this->assertTrue($USER->isPI()); $this->assertTrue($pi_group->exists()); $this->assertTrue(arraysAreEqualUnOrdered([$pi], $pi_group->getGroupMembers())); $this->assertEquals([], $SQL->getRequests($gid)); switchUser(...getUserNotPiNotRequestedBecomePi()); - $uid = $USER->getUID(); + $uid = $USER->uid; $this->assertFalse($USER->isPI()); $this->assertFalse($SQL->requestExists($uid, UnitySQL::REQUEST_BECOME_PI)); $this->assertFalse($pi_group->userExists($USER)); diff --git a/test/functional/PiBecomeRequestTest.php b/test/functional/PiBecomeRequestTest.php index 6c1bb3ba..abd446a1 100644 --- a/test/functional/PiBecomeRequestTest.php +++ b/test/functional/PiBecomeRequestTest.php @@ -9,9 +9,9 @@ private function assertNumberPiBecomeRequests(int $x) { global $USER, $SQL; if ($x == 0) { - $this->assertFalse($SQL->requestExists($USER->getUID())); + $this->assertFalse($SQL->requestExists($USER->uid)); } elseif ($x > 0) { - $this->assertTrue($SQL->requestExists($USER->getUID())); + $this->assertTrue($SQL->requestExists($USER->uid)); } else { throw new RuntimeError("x must not be negative"); } @@ -26,7 +26,7 @@ private function getNumberPiBecomeRequests() $stmt = $SQL->getConn()->prepare( "SELECT * FROM requests WHERE uid=:uid and request_for='admin'" ); - $uid = $USER->getUID(); + $uid = $USER->uid; $stmt->bindParam(":uid", $uid); $stmt->execute(); return count($stmt->fetchAll()); @@ -61,7 +61,7 @@ public function testRequestBecomePi() $this->assertNumberPiBecomeRequests(1); } finally { if ($SQL->requestExists($USER, UnitySQL::REQUEST_BECOME_PI)) { - $SQL->removeRequest($USER->getUID(), UnitySQL::REQUEST_BECOME_PI); + $SQL->removeRequest($USER->uid, UnitySQL::REQUEST_BECOME_PI); } } } @@ -72,7 +72,7 @@ public function testRequestBecomePiUserRequestedAccountDeletion() switchUser(...getUserNotPiNotRequestedBecomePiRequestedAccountDeletion()); $this->assertFalse($USER->isPI()); $this->assertNumberPiBecomeRequests(0); - $this->assertTrue($SQL->accDeletionRequestExists($USER->getUID())); + $this->assertTrue($SQL->accDeletionRequestExists($USER->uid)); try { http_post( __DIR__ . "/../../webroot/panel/account.php", @@ -81,7 +81,7 @@ public function testRequestBecomePiUserRequestedAccountDeletion() $this->assertNumberPiBecomeRequests(0); } finally { if ($SQL->requestExists($USER, UnitySQL::REQUEST_BECOME_PI)) { - $SQL->removeRequest($USER->getUID(), UnitySQL::REQUEST_BECOME_PI); + $SQL->removeRequest($USER->uid, UnitySQL::REQUEST_BECOME_PI); } } } diff --git a/test/functional/PiMemberApproveTest.php b/test/functional/PiMemberApproveTest.php index 94ee6af8..cfb9e80f 100644 --- a/test/functional/PiMemberApproveTest.php +++ b/test/functional/PiMemberApproveTest.php @@ -52,9 +52,9 @@ public function testApproveRequest() $piSwitchArgs = getUserIsPIHasNoMembersNoMemberRequests(); switchUser(...$userSwitchArgs); $user = $USER; - $uid = $USER->getUID(); + $uid = $USER->uid; switchUser(...$piSwitchArgs); - $piUID = $USER->getUID(); + $piUID = $USER->uid; $piGroup = $USER->getPIGroup(); $this->assertTrue($piGroup->exists()); @@ -62,7 +62,7 @@ public function testApproveRequest() $this->assertEmpty($piGroup->getRequests()); try { switchUser(...$userSwitchArgs); - $this->requestJoinPI($piGroup->getPIUID()); + $this->requestJoinPI($piGroup->gid); $this->assertFalse($piGroup->userExists($user)); switchUser(...$piSwitchArgs); @@ -86,9 +86,9 @@ public function testApproveNonexistentRequest() global $USER; switchUser(...getNormalUser2()); $user = $USER; - $uid = $USER->getUID(); + $uid = $USER->uid; switchUser(...getUserIsPIHasNoMembersNoMemberRequests()); - $piUID = $USER->getUID(); + $piUID = $USER->uid; $piGroup = $USER->getPIGroup(); $this->assertTrue($piGroup->exists()); diff --git a/test/functional/PiMemberDenyTest.php b/test/functional/PiMemberDenyTest.php index 4278a1d5..a3738bc6 100644 --- a/test/functional/PiMemberDenyTest.php +++ b/test/functional/PiMemberDenyTest.php @@ -10,7 +10,7 @@ class PiMemberDenyTest extends TestCase { public static function setUpBeforeClass(): void{ global $USER; switchUser(...getNormalUser()); - self::$requestUid = $USER->getUID(); + self::$requestUid = $USER->uid; } private function denyUser(string $uid) @@ -30,7 +30,7 @@ public function testDenyRequest() $this->assertTrue($piGroup->exists()); $this->assertTrue( arraysAreEqualUnOrdered( - [$pi->getUID()], + [$pi->uid], $piGroup->getGroupMemberUIDs() ) ); @@ -50,13 +50,13 @@ public function testDenyRequest() $this->assertEmpty($piGroup->getRequests()); $this->assertTrue( arraysAreEqualUnOrdered( - [$pi->getUID()], + [$pi->uid], $piGroup->getGroupMemberUIDs() ) ); $this->assertFalse($piGroup->userExists($requestedUser)); } finally { - $SQL->removeRequest(self::$requestUid, $piGroup->getPIUID()); + $SQL->removeRequest(self::$requestUid, $piGroup->gid); } } } diff --git a/test/functional/PiRemoveUserTest.php b/test/functional/PiRemoveUserTest.php index 1d7dd72f..ab1de450 100644 --- a/test/functional/PiRemoveUserTest.php +++ b/test/functional/PiRemoveUserTest.php @@ -18,7 +18,7 @@ public function testRemoveUser() global $USER, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK; switchUser(...getUserIsPIHasAtLeastOneMember()); $pi = $USER; - $piUid = $USER->getUID(); + $piUid = $USER->uid; $piGroup = $USER->getPIGroup(); $this->assertTrue($piGroup->exists()); $memberUIDs = $piGroup->getGroupMemberUIDs(); @@ -36,10 +36,10 @@ public function testRemoveUser() break; } } - $this->assertNotEquals($pi->getUID(), $memberToDelete->getUID()); + $this->assertNotEquals($pi->uid, $memberToDelete->uid); $this->assertTrue($piGroup->userExists($memberToDelete)); try { - $this->removeUser($memberToDelete->getUID()); + $this->removeUser($memberToDelete->uid); $this->assertFalse($piGroup->userExists($memberToDelete)); } finally { if (!$piGroup->userExists($memberToDelete)) { @@ -65,7 +65,7 @@ public function testRemovePIFromTheirOwnGroup() $this->assertTrue($piGroup->userExists($pi)); $this->expectException(Exception::class); try { - $this->removeUser($pi->getUID()); + $this->removeUser($pi->uid); $this->assertTrue($piGroup->userExists($pi)); } finally { if (!$piGroup->userExists($pi)) { diff --git a/test/functional/ViewAsUserTest.php b/test/functional/ViewAsUserTest.php index 8d5be3c4..9c298586 100644 --- a/test/functional/ViewAsUserTest.php +++ b/test/functional/ViewAsUserTest.php @@ -10,10 +10,10 @@ public function _testViewAsUser(array $beforeUser, array $afterUser) { global $USER; switchUser(...$afterUser); - $afterUid = $USER->getUID(); + $afterUid = $USER->uid; switchUser(...$beforeUser); // $this->assertTrue($USER->isAdmin()); - $beforeUid = $USER->getUID(); + $beforeUid = $USER->uid; // $this->assertNotEquals($afterUid, $beforeUid); http_post( __DIR__ . "/../../webroot/admin/user-mgmt.php", @@ -28,7 +28,7 @@ public function _testViewAsUser(array $beforeUser, array $afterUser) session_write_close(); http_get(__DIR__ . "/../../resources/init.php"); // now we should be new user - $this->assertEquals($afterUid, $USER->getUID()); + $this->assertEquals($afterUid, $USER->uid); // $this->assertTrue($_SESSION["user_exists"]); http_post( __DIR__ . "/../../resources/templates/header.php", @@ -40,7 +40,7 @@ public function _testViewAsUser(array $beforeUser, array $afterUser) session_write_close(); http_get(__DIR__ . "/../../resources/init.php"); // now we should be back to original user - $this->assertEquals($beforeUid, $USER->getUID()); + $this->assertEquals($beforeUid, $USER->uid); } public function testViewAsUser() @@ -62,7 +62,7 @@ public function testNonAdminViewAsAdmin() { global $USER; switchUser(...getAdminUser()); - $adminUid = $USER->getUID(); + $adminUid = $USER->uid; $this->assertTrue($USER->isAdmin()); switchUser(...getNormalUser()); http_post( diff --git a/webroot/admin/ajax/get_group_members.php b/webroot/admin/ajax/get_group_members.php index e3e56759..9f6c3cb0 100644 --- a/webroot/admin/ajax/get_group_members.php +++ b/webroot/admin/ajax/get_group_members.php @@ -9,18 +9,18 @@ UnitySite::forbidden("not an admin"); } -if (!isset($_GET["pi_uid"])) { +if (!isset($_GET["gid"])) { UnitySite::badRequest("PI UID not set"); } -$group = new UnityGroup($_GET["pi_uid"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK); +$group = new UnityGroup($_GET["gid"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK); $members = $group->getGroupMembers(); $requests = $group->getRequests(); $i = 0; $count = count($members) + count($requests); foreach ($members as $member) { - if ($member->getUID() == $group->getOwner()->getUID()) { + if ($member->uid == $group->getOwner()->uid) { continue; } @@ -31,15 +31,15 @@ } echo "" . $member->getFullname() . ""; - echo "" . $member->getUID() . ""; + echo "" . $member->uid . ""; echo "" . $member->getMail() . ""; echo ""; echo - "
+ " - - + +
"; echo ""; @@ -54,17 +54,17 @@ } else { echo ""; } - $uid = $user->getUID(); + $uid = $user->uid; echo "" . $firstname . " " . $lastname . ""; echo "" . $uid . ""; echo "" . $email . ""; echo ""; echo - "
- +
"; echo ""; diff --git a/webroot/admin/pi-mgmt.php b/webroot/admin/pi-mgmt.php index c546704b..2826bc3c 100644 --- a/webroot/admin/pi-mgmt.php +++ b/webroot/admin/pi-mgmt.php @@ -83,7 +83,7 @@ echo "" . date("jS F, Y", strtotime($request['timestamp'])) . ""; echo ""; echo - "
+ " Actions -getAllPIGroups($SQL, $MAILER, $REDIS, $WEBHOOK); usort($accounts, function ($a, $b) { - return strcmp($a->getPIUID(), $b->getPIUID()); + return strcmp($a->gid, $b->gid); }); foreach ($accounts as $pi_group) { @@ -121,8 +121,8 @@ echo ""; echo "" . $pi_user->getFirstname() . - " " . $pi_user->getLastname() . ""; - echo "" . $pi_group->getPIUID() . ""; + " " . $pi_user->getLastname() . ""; + echo "" . $pi_group->gid . ""; echo "" . $pi_user->getMail() . ""; echo ""; } @@ -132,7 +132,7 @@ getAllUsers($SQL, $MAILER, $REDIS, $WEBHOOK); usort($users, function ($a, $b) { - return strcmp($a->getUID(), $b->getUID()); + return strcmp($a->uid, $b->uid); }); foreach ($users as $user) { @@ -50,13 +50,13 @@ echo ""; } echo "" . $user->getFirstname() . " " . $user->getLastname() . ""; - echo "" . $user->getUID() . ""; + echo "" . $user->uid . ""; echo "" . $user->getOrg() . ""; echo "" . $user->getMail() . ""; echo ""; $cur_user_groups = $user->getGroups(); foreach ($cur_user_groups as $cur_group) { - echo "" . $cur_group->getPIUID() . ""; + echo "" . $cur_group->gid . ""; if ($cur_group !== array_key_last($cur_user_groups)) { echo '
'; } @@ -64,9 +64,9 @@ echo ""; echo ""; echo " + onsubmit='return confirm(\"Are you sure you want to switch to the user " . $user->uid . "?\");'> - +
"; echo ""; diff --git a/webroot/js/tables.js b/webroot/js/tables.js index ed0de340..a749b43e 100644 --- a/webroot/js/tables.js +++ b/webroot/js/tables.js @@ -13,7 +13,7 @@ $("button.btnExpand").click(function() { var pi_wrapper = $(this).parent(); // parent column (td) var piRow = pi_wrapper.parent(); // parent row (tr) var piTree = piRow.parent(); // parent table (table) - var pi_uid = pi_wrapper.next().html(); + var gid = pi_wrapper.next().html(); if ($(this).hasClass("btnExpanded")) { // already expanded @@ -32,7 +32,7 @@ $("button.btnExpand").click(function() { $("button.btnExpanded").trigger("click"); // not expanded $.ajax({ - url: ajax_url + pi_uid, + url: ajax_url + gid, success: function(result) { console.log(result); piRow.after(result); diff --git a/webroot/panel/account.php b/webroot/panel/account.php index f63a1f7a..192ca3e5 100644 --- a/webroot/panel/account.php +++ b/webroot/panel/account.php @@ -57,13 +57,13 @@ if ($USER->isPI()) { UnitySite::badRequest("already a PI"); } - if ($SQL->requestExists($USER->getUID())) { + if ($SQL->requestExists($USER->uid)) { UnitySite::badRequest("already requested to be PI"); } - if ($USER->getUID() != $SSO["user"]) { + if ($USER->uid != $SSO["user"]) { UnitySite::badRequest( "cannot request due to uid mismatch: " . - "USER='{$USER->getUID()}' SSO[user]='$sso_user'" + "USER='{$USER->uid}' SSO[user]='$sso_user'" ); } $USER->getPIGroup()->requestGroup( @@ -82,7 +82,7 @@ if ($hasGroups) { break; } - if (!$SQL->accDeletionRequestExists($USER->getUID())) { + if (!$SQL->accDeletionRequestExists($USER->uid)) { $USER->requestAccountDeletion(); } break; @@ -99,7 +99,7 @@ - + @@ -145,7 +145,7 @@ id='piReq' > "; - if ($SQL->accDeletionRequestExists($USER->getUID())) { + if ($SQL->accDeletionRequestExists($USER->uid)) { echo ""; echo " "; } else { - if ($SQL->requestExists($USER->getUID())) { + if ($SQL->requestExists($USER->uid)) { $prompt = "onclick='return confirm(\"Are you sure you want to cancel this request?\")"; echo ""; echo " @@ -236,7 +236,7 @@ > "; - if ($SQL->accDeletionRequestExists($USER->getUID())) { + if ($SQL->accDeletionRequestExists($USER->uid)) { echo ""; echo ""; } else { diff --git a/webroot/panel/ajax/get_group_members.php b/webroot/panel/ajax/get_group_members.php index 222c2e25..8b8c74dd 100644 --- a/webroot/panel/ajax/get_group_members.php +++ b/webroot/panel/ajax/get_group_members.php @@ -5,18 +5,18 @@ use UnityWebPortal\lib\UnityGroup; use UnityWebPortal\lib\UnitySite; -if (!isset($_GET["pi_uid"])) { +if (!isset($_GET["gid"])) { UnitySite::badRequest("PI UID not set"); } -$group = new UnityGroup($_GET["pi_uid"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK); +$group = new UnityGroup($_GET["gid"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK); if (!$group->userExists($USER)) { UnitySite::forbidden("not a group member"); } $members = $group->getGroupMembers(); $count = count($members); foreach ($members as $key => $member) { - if ($member->getUID() == $group->getOwner()->getUID()) { + if ($member->uid == $group->getOwner()->uid) { continue; } @@ -27,8 +27,8 @@ } echo ""; - echo ""; + echo ""; echo ""; - echo ""; + echo ""; echo ""; } diff --git a/webroot/panel/groups.php b/webroot/panel/groups.php index ed5b8ba4..2cfbb9af 100644 --- a/webroot/panel/groups.php +++ b/webroot/panel/groups.php @@ -31,11 +31,11 @@ array_push($modalErrors, "You\'re already in this PI group"); } - if ($USER->getUID() != $SSO["user"]) { + if ($USER->uid != $SSO["user"]) { $sso_user = $SSO["user"]; UnitySite::badRequest( "cannot request due to uid mismatch: " . - "USER='{$USER->getUID()}' SSO[user]='$sso_user'" + "USER='{$USER->uid}' SSO[user]='$sso_user'" ); } @@ -65,7 +65,7 @@ getGroups(); -$requests = $SQL->getRequestsByUser($USER->getUID()); +$requests = $SQL->getRequestsByUser($USER->uid); $req_filtered = array(); foreach ($requests as $request) { @@ -83,12 +83,12 @@ $requested_owner = $requested_account->getOwner(); echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; echo "
UsernamegetUID(); ?>uid; ?>
Organization" . $member->getFullname() . "" . $member->getUID() . "" . $member->uid . "" . $member->getMail() . "
" . $requested_owner->getFirstname() . " " . $requested_owner->getLastname() . "" . $requested_account->getPIUID() . "" . $requested_account->gid . "" . $requested_owner->getMail() . "" . date("jS F, Y", strtotime($request['timestamp'])) . ""; echo "
- +
"; @@ -112,7 +112,7 @@ if (count($groups) == 0) { echo "You are not a member of any groups. Request to join a PI using the button below, or request your own PI account on the account settings page"; + "/panel/account.php'>account settings page"; } echo ""; @@ -120,22 +120,22 @@ foreach ($groups as $group) { $owner = $group->getOwner(); - if ($USER->getUID() == $owner->getUID()) { + if ($USER->uid == $owner->uid) { continue; } echo ""; echo - ""; - echo ""; + echo ""; echo ""; echo - ""; @@ -146,7 +146,7 @@ ?> accDeletionRequestExists($USER->getUID())) { +if ($SQL->accDeletionRequestExists($USER->uid)) { echo ""; echo ""; } else { @@ -161,7 +161,7 @@