/**
  * @param string $key
  * @return SJB_GuestAlert
  */
 public static function getGuestAlertByKey($key)
 {
     $guestAlertInfoReceived = SJB_GuestAlertManager::getGuestAlertInfoFromKey($key);
     $guestAlertSID = SJB_Array::get($guestAlertInfoReceived, 'sid');
     $keyReceived = SJB_Array::get($guestAlertInfoReceived, 'key');
     $guestAlert = SJB_GuestAlertManager::getObjectBySID($guestAlertSID);
     $guestAlert->validateReceivedKey($keyReceived);
     return $guestAlert;
 }
Exemple #2
0
 /**
  * @param array $listingsSIDs
  * @param array $guestAlertInfo
  * @param int $listingTypeSID
  * @return array|bool|null
  */
 public static function sendGuestAlertNewListingsFoundLetter(array $listingsSIDs, array $guestAlertInfo, $listingTypeSID)
 {
     $emailTplSID = SJB_ListingTypeManager::getListingTypeEmailTemplateForGuestAlert($listingTypeSID);
     $listings = array();
     foreach ($listingsSIDs as $listingSID) {
         $listing = SJB_ListingManager::getObjectBySID($listingSID);
         if ($listing instanceof SJB_Listing) {
             $listing = SJB_ListingManager::createTemplateStructureForListing($listing);
             array_push($listings, $listing);
         }
     }
     try {
         $guestAlert = SJB_GuestAlertManager::getObjectBySID($guestAlertInfo['sid']);
     } catch (Exception $e) {
     }
     $data = array('listings' => $listings, 'key' => $guestAlert->getVerificationKeyForEmail());
     $email = SJB_EmailTemplateEditor::getEmail($guestAlertInfo['email'], $emailTplSID, $data);
     return $email->send('Guest Alert New Listings Found');
 }
Exemple #3
0
 public function callAction($action)
 {
     if (!method_exists($this, $action)) {
         $translatedErrorMessage = SJB_I18N::getInstance()->gettext('Backend', 'Action is not defined in system');
         throw new Exception($translatedErrorMessage . ': ' . $action);
     }
     $guestAlertsSIDs = SJB_Request::getVar('guestAlerts', array());
     if (is_array($guestAlertsSIDs)) {
         foreach ($guestAlertsSIDs as $guestAlertSID) {
             try {
                 $guestAlert = SJB_GuestAlertManager::getObjectBySID($guestAlertSID);
                 $this->{$action}($guestAlert);
             } catch (Exception $e) {
                 $translatedErrorMessage = SJB_I18N::getInstance()->gettext('Backend', $e->getMessage());
                 array_push($this->errors, $translatedErrorMessage . ': ' . $guestAlertSID);
             }
         }
     }
 }