コード例 #1
0
 public function afterSaveCommit(CakeEvent $cakeEvent, Event $event, ArrayObject $options)
 {
     if (!empty($event->admin_status_override)) {
         return;
     }
     if ($event->isNew() && !empty($event->parent_event_id)) {
         //This is an instantiation of a recurring event, so no further
         //notifications necessary
         return;
     }
     if ($event->status == $event->getOriginal('status') && !$event->isNew()) {
         //No status change, so no further notifications
         return;
     }
     if (empty($event->club) && !empty($event->club_id)) {
         //All notification letters refer to event's Club name,
         //so ensure that club data is available
         $event->club = $this->Clubs->get($event->club_id);
     }
     if ($event->status == 'Pending') {
         $data = ['settings' => ['to' => TableRegistry::get('Users')->roleEmails(['admin', 'student_admin']), 'subject' => "Club Event Submitted - {$event->title}", 'template' => 'Admin/event_submitted', 'emailFormat' => 'both'], 'vars' => ['modified' => $event->getOriginal('status') == 'Modifications Requested', 'event' => $event]];
         QueueBYUEmailTask::createJob($data);
     } elseif ($event->status == 'Advisor Pending') {
         $this->Clubs->notifyAdvisor($event->club_id, 'Club Event Submitted', 'Advisor/event_submitted', compact('event'));
     } elseif ($event->status == 'Modifications Requested') {
         $this->Clubs->notifyPresident($event->club_id, 'Modifications requested for BYU Club Event', 'Officer/event_modifications_requested', compact('event'));
     } elseif ($event->status == 'Approved') {
         //TODO: notfiy advisor AND president
         $this->instantiateRecurrences($event);
     }
 }
コード例 #2
0
 public function afterSaveCommit(Event $event, EventApprovalRequest $request, ArrayObject $options)
 {
     if ($request->isNew()) {
         $data = ['settings' => ['to' => $request->email, 'subject' => 'Club Event Approval Request', 'template' => "Admin/event_approval_request", 'emailFormat' => 'both'], 'vars' => ['request' => $request]];
         QueueBYUEmailTask::createJob($data);
     }
 }
コード例 #3
0
 public function notifyRequested($advisorId)
 {
     $advisor = $this->get($advisorId, ['contain' => ['Users', 'Clubs']]);
     if (empty($advisor->user->email)) {
         return;
     }
     if (empty($advisor->user->name)) {
         $to = $advisor->user->email;
     } else {
         $to = [$advisor->user->email => $advisor->user->name];
     }
     $data = ['settings' => ['to' => $to, 'subject' => 'Club Advisor Request', 'template' => "Advisor/requested", 'emailFormat' => 'both'], 'vars' => ['advisor' => $advisor->toArray()]];
     QueueBYUEmailTask::createJob($data);
 }
コード例 #4
0
 public function afterSaveCommit(Event $event, Transaction $transaction, ArrayObject $options)
 {
     if ($transaction->isNew()) {
         $this->Clubs->notifyAdvisor($transaction->club_id, 'Club Expenditure Request Submitted', 'Advisor/transaction_submitted', compact('transaction'));
         return;
     }
     if ($transaction->status == $transaction->getOriginal('status')) {
         //No status change, so no further notifications
         return;
     }
     if ($transaction->status == 'Pending') {
         $data = ['settings' => ['to' => TableRegistry::get('Users')->roleEmails(['admin', 'student_admin']), 'subject' => 'Club Expenditure Request Submitted', 'template' => "Admin/transaction_submitted", 'emailFormat' => 'both'], 'vars' => ['transaction' => $transaction]];
         QueueBYUEmailTask::createJob($data);
     }
 }
コード例 #5
0
 public function notify($clubId, $type, $appeal = false, $adminForce = false)
 {
     $approval = $this->find()->contain(['Clubs'])->where(['club_id' => $clubId, 'Approvals.type' => $type])->first();
     if (empty($approval)) {
         return false;
     }
     if (!empty($approval->notification_sent) && !$appeal && !$adminForce) {
         //Already sent!
         return false;
     }
     if ($type == 'Dean') {
         if (empty($approval->email)) {
             return false;
         }
         $to = $approval->email;
         if (empty($approval->club->department)) {
             return false;
         }
         $approval->club->department = TableRegistry::get('Departments')->getFullInfo($approval->club->department);
     } else {
         $emails = TableRegistry::get('Users')->roleEmails(strtolower($type));
         if (empty($emails)) {
             return false;
         }
         $to = $emails;
     }
     $data = ['settings' => ['to' => $to, 'subject' => 'Club Approval Requested', 'template' => "{$type}/approve", 'emailFormat' => 'both'], 'vars' => ['club' => $approval->club->toArray(), 'appealed' => $appeal]];
     if ($type == 'Dean') {
         $data['vars']['auth_hash'] = $approval->auth_hash;
     }
     if ($appeal && !empty($approval->appeal_notes)) {
         $data['vars']['appealNotes'] = $approval->appeal_notes;
     }
     if (!QueueBYUEmailTask::createJob($data)) {
         return false;
     }
     $approval->notification_sent = new Time();
     if ($approval->status == 'Not Sent') {
         $approval->status = 'Pending';
     }
     return $this->save($approval);
 }
コード例 #6
0
 protected function notifyAdvisorPresidentIneligible($officer)
 {
     if (empty($officer->member->club->advisor->user->email)) {
         return;
     }
     $data = ['settings' => ['to' => $officer->member->club->advisor->user->email, 'subject' => 'BYU Club President eligibility changed', 'template' => "Advisor/president_ineligible", 'emailFormat' => 'both'], 'vars' => ['officer' => $officer]];
     QueueBYUEmailTask::createJob($data);
 }
コード例 #7
0
 protected function _notifyUsers($users, $subject, $template, $vars = [], $bulk = false)
 {
     $to = [];
     if (!is_array($users)) {
         $users = [$users];
     }
     foreach ($users as $user) {
         if (empty($user->email)) {
             continue;
         }
         if (empty($user->name)) {
             $to[] = $user->email;
         } else {
             $to[$user->email] = $user->name;
         }
     }
     if (empty($to)) {
         return false;
     }
     $data = ['settings' => ['subject' => $subject, 'template' => $template, 'emailFormat' => 'both'], 'vars' => $vars];
     if (!empty($bulk)) {
         $data['settings']['to'] = $bulk;
         $data['settings']['bcc'] = $to;
     } else {
         $data['settings']['to'] = $to;
     }
     return QueueBYUEmailTask::createJob($data);
 }