Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 5 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ repos:
# https://github.com/prettier/plugin-php/issues/2430
exclude: workers/.*

- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.4.2
hooks:
- id: prettier
exclude: |
(?x)^(
composer\.json|
composer\.lock|
)$

- repo: local
hooks:
- id: phpcbf
Expand All @@ -43,27 +33,15 @@ repos:
resources/lib/.*|
)$

- repo: local
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.4.2
hooks:
- id: prettier (php)
name: prettier (php)
entry: npx
args:
[
-p,
prettier,
-p,
"@prettier/plugin-php",
prettier,
--plugin=@prettier/plugin-php,
--php-version=8.3,
--write,
]
language: system
files: \.php$
- id: prettier
# exclude impure PHP files
exclude: |
(?x)^(
composer\.json|
composer\.lock|
node_modules/.*|
resources/lib/phpopenldaper/.*|
vendor/.*|
Expand Down
3 changes: 3 additions & 0 deletions prettierrc.yml → .prettierrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ overrides:
- files: ["*.php"]
options:
printWidth: 100
plugins:
- "@prettier/plugin-php"
phpVersion: "8.3"
4 changes: 1 addition & 3 deletions coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

use RobinIngelbrecht\PHPUnitCoverageTools\MinCoverage\MinCoverageRule;

return [
new MinCoverageRule(pattern: "*", minCoverage: 62, exitOnLowCoverage: true),
];
return [new MinCoverageRule(pattern: "*", minCoverage: 62, exitOnLowCoverage: true)];
8 changes: 1 addition & 7 deletions resources/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@

use UnityWebPortal\lib\UnityConfig;

define(
"CONFIG",
UnityConfig::getConfig(
__DIR__ . "/../defaults",
__DIR__ . "/../deployment",
),
);
define("CONFIG", UnityConfig::getConfig(__DIR__ . "/../defaults", __DIR__ . "/../deployment"));
30 changes: 4 additions & 26 deletions resources/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
use UnityWebPortal\lib\UnityHTTPD;

if (CONFIG["site"]["enable_exception_handler"]) {
set_exception_handler([
"UnityWebPortal\lib\UnityHTTPD",
"exceptionHandler",
]);
set_exception_handler(["UnityWebPortal\lib\UnityHTTPD", "exceptionHandler"]);
}

session_start();
Expand All @@ -40,25 +37,11 @@
$SSO = UnitySSO::getSSO();
$_SESSION["SSO"] = $SSO;

$OPERATOR = new UnityUser(
$SSO["user"],
$LDAP,
$SQL,
$MAILER,
$REDIS,
$WEBHOOK,
);
$OPERATOR = new UnityUser($SSO["user"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK);
$_SESSION["is_admin"] = $OPERATOR->isAdmin();

if (isset($_SESSION["viewUser"]) && $_SESSION["is_admin"]) {
$USER = new UnityUser(
$_SESSION["viewUser"],
$LDAP,
$SQL,
$MAILER,
$REDIS,
$WEBHOOK,
);
$USER = new UnityUser($_SESSION["viewUser"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK);
} else {
$USER = $OPERATOR;
}
Expand All @@ -67,12 +50,7 @@
$_SESSION["is_pi"] = $USER->isPI();
$SEND_PIMESG_TO_ADMINS = CONFIG["mail"]["send_pimesg_to_admins"];

$SQL->addLog(
$OPERATOR->uid,
$_SERVER["REMOTE_ADDR"],
"user_login",
$OPERATOR->uid,
);
$SQL->addLog($OPERATOR->uid, $_SERVER["REMOTE_ADDR"], "user_login", $OPERATOR->uid);

if (!$_SESSION["user_exists"]) {
// populate cache
Expand Down
18 changes: 4 additions & 14 deletions resources/lib/UnityConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@

class UnityConfig
{
public static function getConfig(
string $def_config_loc,
string $deploy_loc,
): array {
$CONFIG = parse_ini_file(
$def_config_loc . "/config.ini.default",
true,
INI_SCANNER_TYPED,
);
public static function getConfig(string $def_config_loc, string $deploy_loc): array
{
$CONFIG = parse_ini_file($def_config_loc . "/config.ini.default", true, INI_SCANNER_TYPED);
$CONFIG = self::pullConfig($CONFIG, $deploy_loc);
if (array_key_exists("HTTP_HOST", $_SERVER)) {
$cur_url = $_SERVER["HTTP_HOST"];
Expand All @@ -28,11 +22,7 @@ private static function pullConfig(array $CONFIG, string $loc): array
{
$file_loc = $loc . "/config/config.ini";
if (file_exists($file_loc)) {
$CONFIG_override = parse_ini_file(
$file_loc,
true,
INI_SCANNER_TYPED,
);
$CONFIG_override = parse_ini_file($file_loc, true, INI_SCANNER_TYPED);
return array_replace_recursive($CONFIG, $CONFIG_override);
} else {
return $CONFIG;
Expand Down
Loading