Skip to content

Commit

Permalink
Merge pull request #101 from bryank-cs/reminders
Browse files Browse the repository at this point in the history
Send weekly reminders to PIs for 4 weeks
  • Loading branch information
hakasapl authored Mar 4, 2024
2 parents a716b8a + 3c1ee4f commit dcba20b
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

/**
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());
} 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 dcba20b

Please sign in to comment.