diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ac6b07a5..3ff6fc6b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: entry: phpcbf language: system files: \.php$ - args: [--standard=PSR2, --colors] + args: [--standard=PSR12, --colors] # linters (work required) ######################################################################## # - repo: https://github.com/pre-commit/pre-commit-hooks @@ -41,7 +41,7 @@ repos: entry: phpcs language: system files: \.php$ - args: [--standard=PSR2, --colors] + args: [--standard=PSR12, --colors] - id: php-l name: php -l entry: php diff --git a/resources/lib/UnityGroup.php b/resources/lib/UnityGroup.php index 5eadb0f2..27b201e1 100644 --- a/resources/lib/UnityGroup.php +++ b/resources/lib/UnityGroup.php @@ -24,9 +24,9 @@ class UnityGroup /** * Constructor for the object * - * @param string $gid PI UID in the format - * @param LDAP $LDAP LDAP Connection - * @param SQL $SQL SQL Connection + * @param string $gid PI UID in the format + * @param LDAP $LDAP LDAP Connection + * @param SQL $SQL SQL Connection */ public function __construct($gid, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK) { diff --git a/resources/lib/UnityLDAP.php b/resources/lib/UnityLDAP.php index a4ac6ac8..69a67c3e 100644 --- a/resources/lib/UnityLDAP.php +++ b/resources/lib/UnityLDAP.php @@ -10,7 +10,7 @@ */ class UnityLDAP extends ldapConn { - // User Specific Constants + // User Specific Constants private const RDN = "cn"; // The defauls RDN for LDAP entries is set to "common name" public const POSIX_ACCOUNT_CLASS = array( @@ -25,7 +25,7 @@ class UnityLDAP extends ldapConn "top" ); - // string vars for OUs + // string vars for OUs private $STR_BASEOU; private $STR_USEROU; private $STR_GROUPOU; @@ -33,7 +33,7 @@ class UnityLDAP extends ldapConn private $STR_ORGGROUPOU; private $STR_ADMINGROUP; - // Instance vars for various ldapEntry objects + // Instance vars for various ldapEntry objects private $baseOU; private $userOU; private $groupOU; @@ -69,7 +69,7 @@ public function __construct( $this->STR_ORGGROUPOU = $orggroup_ou; $this->STR_ADMINGROUP = $admin_group; - // Get Global Entries + // Get Global Entries $this->baseOU = $this->getEntry($base_ou); $this->userOU = $this->getEntry($user_ou); $this->groupOU = $this->getEntry($group_ou); @@ -83,9 +83,9 @@ public function __construct( $this->def_user_shell = $def_user_shell; } - // - // Get methods for OU - // + // + // Get methods for OU + // public function getUserOU() { return $this->userOU; @@ -121,9 +121,9 @@ public function getDefUserShell() return $this->def_user_shell; } - // - // ID Number selection functions - // + // + // ID Number selection functions + // public function getNextUIDNumber($UnitySQL) { $max_uid = $UnitySQL->getSiteVar('MAX_UID'); @@ -198,7 +198,7 @@ private function IDNumInUse($id) public function getUnassignedID($uid, $UnitySQL) { $netid = strtok($uid, "_"); // extract netid - // scrape all files in custom folder + // scrape all files in custom folder $dir = new \DirectoryIterator($this->custom_mappings_path); foreach ($dir as $fileinfo) { if ($fileinfo->getExtension() == "csv") { @@ -218,7 +218,7 @@ public function getUnassignedID($uid, $UnitySQL) } } - // didn't find anything from existing mappings, use next available + // didn't find anything from existing mappings, use next available $next_uid = $this->getNextUIDNumber($UnitySQL); return $next_uid; @@ -231,9 +231,9 @@ public function getAllUsersUIDs() return $this->userGroup->getAttribute("memberuid"); } - // - // Functions that return user/group objects - // + // + // Functions that return user/group objects + // public function getAllUsers($UnitySQL, $UnityMailer, $UnityRedis, $UnityWebhook, $ignorecache = false) { $out = array(); @@ -292,14 +292,17 @@ public function getAllPIGroups($UnitySQL, $UnityMailer, $UnityRedis, $UnityWebho $pi_groups = $this->pi_groupOU->getChildren(true); foreach ($pi_groups as $pi_group) { - array_push($out, new UnityGroup( - $pi_group->getAttribute("cn")[0], - $this, - $UnitySQL, - $UnityMailer, - $UnityRedis, - $UnityWebhook - )); + array_push( + $out, + new UnityGroup( + $pi_group->getAttribute("cn")[0], + $this, + $UnitySQL, + $UnityMailer, + $UnityRedis, + $UnityWebhook + ) + ); } return $out; @@ -341,7 +344,9 @@ public function getAllPIGroupOwnerAttributes($attributes) return $owner_attributes; } - /** Returns an associative array where keys are UIDs and values are arrays of PI GIDs */ + /** + * Returns an associative array where keys are UIDs and values are arrays of PI GIDs + */ public function getAllUID2PIGIDs() { // initialize output so each UID is a key with an empty array as its value @@ -375,14 +380,17 @@ public function getAllOrgGroups($UnitySQL, $UnityMailer, $UnityRedis, $UnityWebh $org_groups = $this->org_groupOU->getChildren(true); foreach ($org_groups as $org_group) { - array_push($out, new UnityOrg( - $org_group->getAttribute("cn")[0], - $this, - $UnitySQL, - $UnityMailer, - $UnityRedis, - $UnityWebhook - )); + array_push( + $out, + new UnityOrg( + $org_group->getAttribute("cn")[0], + $this, + $UnitySQL, + $UnityMailer, + $UnityRedis, + $UnityWebhook + ) + ); } return $out; diff --git a/resources/lib/UnitySite.php b/resources/lib/UnitySite.php index a1b5a53e..1a3e5204 100644 --- a/resources/lib/UnitySite.php +++ b/resources/lib/UnitySite.php @@ -105,9 +105,9 @@ public static function testValidSSHKey($key_str) try { PublicKeyLoader::load($key_str); return true; - // phpseclib should throw only NoKeyLoadedException but that is not the case - // https://github.com/phpseclib/phpseclib/pull/2078 - // } catch (\phpseclib3\Exception\NoKeyLoadedException $e) { + // phpseclib should throw only NoKeyLoadedException but that is not the case + // https://github.com/phpseclib/phpseclib/pull/2078 + // } catch (\phpseclib3\Exception\NoKeyLoadedException $e) { } catch (\Throwable $e) { return false; } diff --git a/resources/lib/UnityUser.php b/resources/lib/UnityUser.php index 3f0f4d8f..f500374f 100644 --- a/resources/lib/UnityUser.php +++ b/resources/lib/UnityUser.php @@ -49,11 +49,11 @@ public function __toString() /** * This is the method that is run when a new account is created * - * @param string $firstname First name of new account - * @param string $lastname Last name of new account - * @param string $email email of new account - * @param string $org organization name of new account - * @param bool $isPI boolean value for if the user checked the "I am a PI box" + * @param string $firstname First name of new account + * @param string $lastname Last name of new account + * @param string $email email of new account + * @param string $org organization name of new account + * @param bool $isPI boolean value for if the user checked the "I am a PI box" * @return void */ public function init($firstname, $lastname, $email, $org, $send_mail = true) @@ -575,6 +575,7 @@ public function getOrgGroup() /** * Gets the groups this user is assigned to, can be more than one + * * @return string[] */ public function getPIGroupGIDs($ignorecache = false) @@ -621,11 +622,11 @@ public function hasRequestedAccountDeletion() /** * Checks whether a user is in a group or not - * @param string $uid uid of the user + * + * @param string $uid uid of the user * @param string or object $group group to check * @return boolean true if user is in group, false if not */ - public function isInGroup($uid, $group) { if (gettype($group) == "string") { diff --git a/resources/lib/exceptions/PhpUnitNoDieException.php b/resources/lib/exceptions/PhpUnitNoDieException.php index b9eba417..c8a0a0eb 100644 --- a/resources/lib/exceptions/PhpUnitNoDieException.php +++ b/resources/lib/exceptions/PhpUnitNoDieException.php @@ -1,4 +1,5 @@ Support"; echo "Account Settings"; echo "My PIs"; if (isset($_SESSION["is_pi"]) && $_SESSION["is_pi"]) { - // PI only pages + // PI only pages echo "My Users"; } - // additional branding items + // additional branding items $num_additional_items = count($CONFIG["menuitems_secure"]["labels"]); for ($i = 0; $i < $num_additional_items; $i++) { echo "" . $CONFIG["menuitems_secure"]["labels"][$i] . ""; } - // admin pages + // admin pages if (isset($_SESSION["is_admin"]) && $_SESSION["is_admin"] && !isset($_SESSION["viewUser"])) { echo ""; - // Admin only pages + // Admin only pages echo "User Management"; echo "PI Management"; echo "Cluster Notices"; @@ -132,7 +133,8 @@

Page Content Management

@@ -67,4 +67,4 @@

Cluster Notice Management

@@ -153,4 +153,4 @@

PI Management

@@ -136,4 +136,4 @@

User Management

@@ -74,4 +74,4 @@ diff --git a/webroot/panel/account.php b/webroot/panel/account.php index 742c2800..8bef6f56 100644 --- a/webroot/panel/account.php +++ b/webroot/panel/account.php @@ -90,7 +90,7 @@ } } -include $LOC_HEADER; +require $LOC_HEADER; $uid = $USER->uid; $org = $USER->getOrg(); diff --git a/webroot/panel/groups.php b/webroot/panel/groups.php index 2b3289f9..3f11740d 100644 --- a/webroot/panel/groups.php +++ b/webroot/panel/groups.php @@ -56,7 +56,7 @@ } } -include $LOC_HEADER; +require $LOC_HEADER; ?>

My Principal Investigators

@@ -192,4 +192,4 @@ getPIGroup()->cancelGroupRequest(); } else { $pi_group = new UnityGroup($request["request_for"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK); - $pi_group->cancelGroupJoinRequest($user=$USER); + $pi_group->cancelGroupJoinRequest($user = $USER); } } } } -include $LOC_HEADER; +require $LOC_HEADER; ?>

Request Account

diff --git a/webroot/panel/pi.php b/webroot/panel/pi.php index 675733ad..614c4314 100644 --- a/webroot/panel/pi.php +++ b/webroot/panel/pi.php @@ -33,7 +33,7 @@ } } -include $LOC_HEADER; +require $LOC_HEADER; ?>

My Users

@@ -110,4 +110,4 @@ ?>

Support

diff --git a/workers/clear-audit-log.php b/workers/clear-audit-log.php index 66dab341..1ae1bae0 100644 --- a/workers/clear-audit-log.php +++ b/workers/clear-audit-log.php @@ -3,7 +3,7 @@ require_once __DIR__ . "/../resources/autoload.php"; require_once __DIR__ . "/../resources/init.php"; -# Days to keep +// Days to keep $days = 30; $daysAgo = date('Y-m-d', strtotime("-$days days")); diff --git a/workers/group_user_request_owner_reminder.php b/workers/group_user_request_owner_reminder.php index 6b84c735..30e140ca 100644 --- a/workers/group_user_request_owner_reminder.php +++ b/workers/group_user_request_owner_reminder.php @@ -3,7 +3,7 @@ /** Emails PIs that have oustanding member requests once a week for 4 weeks. Removes the request after 34 days have passed. -*/ + */ require_once __DIR__ . "/../resources/autoload.php"; use UnityWebPortal\lib\UnityGroup;