Skip to content

Commit

Permalink
Send weekly reminders to PIs for 4 weeks
Browse files Browse the repository at this point in the history
	Meant to be run as a daily cron job, this script will email PIs with outstanding requests.
	After 34 days, requests will be removed from the database.
  • Loading branch information
bryank-cs committed Mar 1, 2024
1 parent a716b8a commit 3d4ad99
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions workers/group_user_request_owner_reminder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

Check failure on line 1 in workers/group_user_request_owner_reminder.php

View workflow job for this annotation

GitHub Actions / PHP_CodeSniffer

workers/group_user_request_owner_reminder.php#L1

Header blocks must be separated by a single blank line (PSR12.Files.FileHeader.SpacingAfterBlock)
/*
Emails PIs that have oustanding member requests once a week for 4 weeks.
Removes the request after 34 days have passed.
*/

require_once "../resources/autoload.php";
use UnityWebPortal\lib\UnityGroup;

$today = time();
$accounts = $LDAP->getAllPIGroups($SQL, $MAILER, $REDIS);
foreach ($accounts as $pi_group) {
$pi_user = $pi_group->getOwner();
$requests = $pi_group->getRequests();
foreach ($requests as $request) {
$request_date = strtotime($request[1]);
$daysDifference = ($today - $request_date) / (60 * 60 * 24);
if ($daysDifference > 34) {
# No interface in UnityGroup for this, so use DB directly
$SQL->removeRequest($request[0], $pi_group->getPIUID());
}

Check failure on line 21 in workers/group_user_request_owner_reminder.php

View workflow job for this annotation

GitHub Actions / PHP_CodeSniffer

workers/group_user_request_owner_reminder.php#L21

Expected 1 space after closing brace; newline found (Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace)
elseif ($daysDifference > 1 && $daysDifference % 7 == 0) {
$new_user = $request[0];
// send email to PI
$MAILER->sendMail(
$pi_user->getMail(),
"group_user_request_owner",
array(
"group" => $pi_group->getPIUID(),
"user" => $new_user->getUID(),
"name" => $new_user->getFullName(),
"email" => $new_user->getMail(),
"org" => $new_user->getOrg()
)
);
}
}
}

0 comments on commit 3d4ad99

Please sign in to comment.