From 3d4ad99931c97a663de42c0631ceab7ca5bdb378 Mon Sep 17 00:00:00 2001 From: Kevin Bryan Date: Fri, 1 Mar 2024 15:22:32 -0500 Subject: [PATCH 1/3] Send weekly reminders to PIs for 4 weeks 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. --- workers/group_user_request_owner_reminder.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 workers/group_user_request_owner_reminder.php diff --git a/workers/group_user_request_owner_reminder.php b/workers/group_user_request_owner_reminder.php new file mode 100644 index 0000000..addb25a --- /dev/null +++ b/workers/group_user_request_owner_reminder.php @@ -0,0 +1,38 @@ +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() + ) + ); + } + } +} From 1b5adfd0bf1e390d67d0047ce0a428dbc90d8a91 Mon Sep 17 00:00:00 2001 From: Kevin Bryan Date: Fri, 1 Mar 2024 15:35:30 -0500 Subject: [PATCH 2/3] Reformat for codesniff --- workers/group_user_request_owner_reminder.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/workers/group_user_request_owner_reminder.php b/workers/group_user_request_owner_reminder.php index addb25a..444157b 100644 --- a/workers/group_user_request_owner_reminder.php +++ b/workers/group_user_request_owner_reminder.php @@ -1,5 +1,5 @@ 34) { - # No interface in UnityGroup for this, so use DB directly + // No interface in UnityGroup for this, so use DB directly $SQL->removeRequest($request[0], $pi_group->getPIUID()); - } - elseif ($daysDifference > 1 && $daysDifference % 7 == 0) { + } elseif ($daysDifference > 1 && $daysDifference % 7 == 0) { $new_user = $request[0]; // send email to PI $MAILER->sendMail( From 3c1ee4f040415ed9741c02cde8a61968b206b26a Mon Sep 17 00:00:00 2001 From: Kevin Bryan Date: Fri, 1 Mar 2024 15:38:03 -0500 Subject: [PATCH 3/3] Add a blank line --- workers/group_user_request_owner_reminder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/workers/group_user_request_owner_reminder.php b/workers/group_user_request_owner_reminder.php index 444157b..921fa11 100644 --- a/workers/group_user_request_owner_reminder.php +++ b/workers/group_user_request_owner_reminder.php @@ -1,4 +1,5 @@