Ejemplo n.º 1
0
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->owner->MemberNumber) {
         $this->owner->MemberNumber = Member::get()->sort('ID')->last()->ID + 300;
     }
     if (!$this->owner->JoinedDate && $this->owner->MembershipStatus === 'Verified') {
         $this->owner->JoinedDate = date('Y-m-d');
     }
     if ($this->owner->isChanged('MembershipStatus') && $this->owner->MembershipStatus === 'Verified') {
         $email = new MemberApprovalEmail(RegistrationPage::get_one('RegistrationPage'), $this->owner);
         $email->send();
         $this->Notified = 0;
     }
 }
Ejemplo n.º 2
0
 public function handleExpiredMembers($expiredMembers)
 {
     $register = RegistrationPage::get_one('RegistrationPage');
     $count = 0;
     if ($expiredMembers->Count() > 0) {
         foreach ($expiredMembers as $member) {
             $member->MembershipStatus = 'Expired';
             try {
                 $email = new MemberExpiredEmail($register, $member);
                 $email->send();
                 $member->write();
                 $count++;
                 echo '<p>Email sent to:' . $member->Email . ' </p>';
             } catch (ValidationException $e) {
                 echo '<p>Failed to update record: ' . $member->FirstName . '</p>';
             }
         }
     }
     echo '<p>' . $count . ' members notified of expired membership</p>';
     return $expiredMembers;
 }