Skip to content

Made emailing admins for PI requests optional #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2023
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
1 change: 1 addition & 0 deletions defaults/config.ini.default
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ sender = "sender-email@unitywebportal.test" ; The "from" email for all messages
sender_name = "Unity Sender"
pi_approve = "piapproval@unitywebportal.test" ; Only PI approval messages will go to this email
pi_approve_name = "Unity PI Approval"
send_pimesg_to_admins = false

[webhook] ; webhook to send messages to admins
url = "https://hooks.slack.com/services/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"
Expand Down
1 change: 1 addition & 0 deletions resources/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@

$_SESSION["user_exists"] = $USER->exists();
$_SESSION["is_pi"] = $USER->isPI();
$SEND_PIMESG_TO_ADMINS = $CONFIG["mail"]["send_pimesg_to_admins"];

$SQL->addLog(
$OPERATOR->getUID(),
Expand Down
24 changes: 13 additions & 11 deletions resources/lib/UnityGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function exists()
// Portal-facing methods, these are the methods called by scripts in webroot
//

public function requestGroup($send_mail = true)
public function requestGroup($send_mail_to_admins, $send_mail = true)
{
// check for edge cases...
if ($this->exists()) {
Expand All @@ -97,16 +97,18 @@ public function requestGroup($send_mail = true)
)
);

$this->MAILER->sendMail(
"admin",
"group_request_admin",
array(
"user" => $this->getOwner()->getUID(),
"org" => $this->getOwner()->getOrg(),
"name" => $this->getOwner()->getFullname(),
"email" => $this->getOwner()->getMail()
)
);
if ($send_mail_to_admins) {
$this->MAILER->sendMail(
"admin",
"group_request_admin",
array(
"user" => $this->getOwner()->getUID(),
"org" => $this->getOwner()->getOrg(),
"name" => $this->getOwner()->getFullname(),
"email" => $this->getOwner()->getMail()
)
);
}

$this->MAILER->sendMail(
"pi_approve",
Expand Down
2 changes: 1 addition & 1 deletion webroot/panel/account.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
case "pi_request":
if (!$USER->isPI()) {
if (!$SQL->requestExists($USER->getUID())) {
$USER->getPIGroup()->requestGroup();
$USER->getPIGroup()->requestGroup($SEND_PIMESG_TO_ADMINS);
}
}
break;
Expand Down
2 changes: 1 addition & 1 deletion webroot/panel/new_account.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
if (count($errors) == 0) {
if ($_POST["new_user_sel"] == "pi") {
// requesting a PI account
$USER->getPIGroup()->requestGroup();
$USER->getPIGroup()->requestGroup($SEND_PIMESG_TO_ADMINS);
} elseif ($_POST["new_user_sel"] == "not_pi") {
$form_group->newUserRequest($USER);
}
Expand Down