From dbb0dc264f0f5f1e0b3a4d7fea4ae1d5aa3a9609 Mon Sep 17 00:00:00 2001 From: Julian Date: Tue, 23 Aug 2016 15:37:27 +1200 Subject: [PATCH] progress toward calculating what changes to the emailing will be needed --- code/tasks/ContentReviewEmails.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/code/tasks/ContentReviewEmails.php b/code/tasks/ContentReviewEmails.php index 11fb08f..c1a67de 100644 --- a/code/tasks/ContentReviewEmails.php +++ b/code/tasks/ContentReviewEmails.php @@ -12,9 +12,28 @@ class ContentReviewEmails extends BuildTask { $compatibility = ContentReviewCompatability::start(); + $now = SS_Datetime::now(); + // First grab all the pages with a custom setting $pages = Page::get() - ->filter('NextReviewDate:LessThanOrEqual', SS_Datetime::now()->URLDate()); + ->filter('NextReviewDate:LessThanOrEqual', $now->URLDate()); + + // Calculate whether today is the date a First or Second review should occur + $config = SiteConfig::current_site_config(); + $firstReview = $config->FirstReviewDaysBefore; + $secondReview = $config->SecondReviewDaysBefore; + // Subtract the number of days prior to the review, from the current date + + // Get all pages where the NextReviewDate is still in the future + $pendingPages = Page::get()->filter('NextReviewDate:GreaterThan', $now->URLDate()); + + // for each of these pages, check if today is the date the First or Second reminder should be sent + foreach ($pendingPages as $page) { + $notifyDate1 = date('Y-m-d', strtotime($page->NextReviewDate . ' -' . $firstReview . ' day')); + $notifyDate2 = date('Y-m-d', strtotime($page->NextReviewDate . ' -' . $secondReview . ' day')); + } + + die(); $overduePages = $this->getOverduePagesForOwners($pages); @@ -83,7 +102,9 @@ class ContentReviewEmails extends BuildTask 'Recipient' => $owner, 'Pages' => $pages, )); - $email->send(); + + Debug::show($email); + //$email->send(); } /**