From c08d835cc061a0ea3aa4266cfcbe260bc390e434 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Tue, 3 Oct 2017 23:26:48 +0000 Subject: [PATCH] Add uncomitted sync-google-attachment-permissions.php changes --- .../sync-google-attachment-permissions.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/event-handlers/Slate/CBL/Tasks/Task/afterRecordTransaction/sync-google-attachment-permissions.php b/event-handlers/Slate/CBL/Tasks/Task/afterRecordTransaction/sync-google-attachment-permissions.php index 9d5bd08a9..8bf610abc 100644 --- a/event-handlers/Slate/CBL/Tasks/Task/afterRecordTransaction/sync-google-attachment-permissions.php +++ b/event-handlers/Slate/CBL/Tasks/Task/afterRecordTransaction/sync-google-attachment-permissions.php @@ -7,6 +7,7 @@ $Task = $_EVENT['Record']; $GoogleDriveClass = GoogleDriveFile::class; $attachments = []; +$newAttachments = []; $students = []; // sync google drive file permssions for when creating new tasks, or editing a task with new attachments @@ -23,13 +24,19 @@ } } - if (count($students)) { - foreach ($Task->Attachments as $Attachment) { - if ($Attachment->isA(GoogleDriveFile::class)) { + foreach ($Task->Attachments as $Attachment) { + if ($Attachment->isA(GoogleDriveFile::class)) { + if ($Attachment->isNew) { + $newAttachments[] = $Attachment; + } elseif (count($students)) { $attachments[] = $Attachment; } } } + + if (count($newAttachments)) { + GoogleDriveFile::syncUsersPermissions($newAttachments); + } } if (!empty($attachments)) {