示例#1
0
 /**
  * @param SJB_GuestAlert $guestAlert
  * @param SJB_TemplateProcessor $tp
  */
 public function saveNewGuestAlert(SJB_GuestAlert $guestAlert, SJB_TemplateProcessor $tp)
 {
     $guestAlert->addDataProperty(serialize($this->criteriaData));
     $guestAlert->addListingTypeIDProperty($this->listingTypeID);
     $guestAlert->save();
     $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($this->listingTypeID);
     SJB_GuestAlertStatistics::saveEventSubscribed($listingTypeSID, $guestAlert->getSID());
     SJB_Notifications::sendConfirmationEmailForGuest($guestAlert);
     $tp->assign('email', $guestAlert->getAlertEmail());
     $this->template = 'alert_created.tpl';
 }
示例#2
0
 public function sendGuestsAlerts()
 {
     $guestEmailsNotified = array();
     $notificationsLimit = (int) SJB_Settings::getSettingByName('num_of_listings_sent_in_email_alerts');
     $listing = new SJB_Listing();
     $listing->addActivationDateProperty();
     $aliasInfoID = $listing->addIDProperty();
     $userNameAliasInfo = $listing->addUsernameProperty();
     $listingTypeIDInfo = $listing->addListingTypeIDProperty();
     $aliases = new SJB_PropertyAliases();
     $aliases->addAlias($aliasInfoID);
     $aliases->addAlias($userNameAliasInfo);
     $aliases->addAlias($listingTypeIDInfo);
     $guestAlertsToNotify = SJB_GuestAlertManager::getGuestAlertsToNotify();
     foreach ($guestAlertsToNotify as $guestAlertInfo) {
         $dataSearch = unserialize($guestAlertInfo['data']);
         $dataSearch['active']['equal'] = 1;
         if (!empty($guestAlertInfo['last_send'])) {
             $dateArr = explode('-', $guestAlertInfo['last_send']);
             $guestAlertInfo['last_send'] = strftime($this->lang['date_format'], mktime(0, 0, 0, $dateArr[1], $dateArr[2], $dateArr[0]));
             $dataSearch['activation_date']['not_less'] = $guestAlertInfo['last_send'];
         }
         $dataSearch['activation_date']['not_more'] = $this->currentDate;
         $listingTypeSID = 0;
         if ($dataSearch['listing_type']['equal']) {
             $listingTypeID = $dataSearch['listing_type']['equal'];
             $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID);
             if (SJB_ListingTypeManager::getWaitApproveSettingByListingType($listingTypeSID)) {
                 $dataSearch['status']['equal'] = 'approved';
             }
         }
         $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($dataSearch, $listing);
         $searcher = new SJB_ListingSearcher();
         $searcher->found_object_sids = array();
         $searcher->setLimit($notificationsLimit);
         $listingsIDsFound = $searcher->getObjectsSIDsByCriteria($criteria, $aliases);
         if (count($listingsIDsFound)) {
             $sentGuestAlertNewListingsFoundLetter = SJB_Notifications::sendGuestAlertNewListingsFoundLetter($listingsIDsFound, $guestAlertInfo, $listingTypeSID);
             if ($sentGuestAlertNewListingsFoundLetter) {
                 SJB_GuestAlertStatistics::saveEventSent($listingTypeSID, $guestAlertInfo['sid']);
                 SJB_GuestAlertManager::markGuestAlertAsSentBySID($guestAlertInfo['sid']);
                 array_push($guestEmailsNotified, $guestAlertInfo['email']);
             }
         }
     }
     return $guestEmailsNotified;
 }