public function execute() { $guestAlert = new SJB_GuestAlert(array()); $guestAlert->addSubscriptionDateProperty(); $guestAlert->addStatusProperty(); $search_form_builder = new SJB_SearchFormBuilder($guestAlert); $criteria_saver = new SJB_GuestAlertCriteriaSaver(); $criteria = $search_form_builder->extractCriteriaFromRequestData($criteria_saver->getCriteria(), $guestAlert); $sortingField = SJB_Request::getVar('sorting_field', 'subscription_date'); $sortingOrder = SJB_Request::getVar('sorting_order', 'DESC'); $searcher = new SJB_GuestAlertSearcher(false, $sortingField, $sortingOrder); $foundGuestAlerts = $searcher->getObjectsSIDsByCriteria($criteria); foreach ($foundGuestAlerts as $id => $guestAlertSID) { $foundGuestAlerts[$id] = SJB_GuestAlertManager::getGuestAlertInfoBySID($guestAlertSID); } $type = SJB_Request::getVar('type', 'csv'); $fileName = 'guest_alerts_' . date('Y-m-d'); SJB_StatisticsExportController::createExportDirectory(); switch ($type) { case 'csv': $ext = 'csv'; SJB_StatisticsExportController::makeCSVExportFile($foundGuestAlerts, $fileName . '.' . $ext, 'Guest Alerts'); break; default: case 'xls': $ext = 'xls'; SJB_StatisticsExportController::makeXLSExportFile($foundGuestAlerts, $fileName . '.' . $ext, 'Guest Alerts'); break; } SJB_StatisticsExportController::archiveAndSendExportFile($fileName, $ext); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $isFormSubmitted = SJB_Request::getVar('action'); $guestAlert = new SJB_GuestAlert($_REQUEST); $form = new SJB_Form($guestAlert); $form->registerTags($tp); $errors = array(); if ($isFormSubmitted && $form->isDataValid($errors)) { $this->saveNewGuestAlert($guestAlert, $tp); } else { $form_fields = $form->getFormFieldsInfo(); $tp->assign('form_fields', $form_fields); $tp->assign('searchId', $this->searchID); if ($this->isDuplicateEmailError($errors)) { $email = $guestAlert->getAlertEmail(); $unSubscribedGuestAlertSID = SJB_GuestAlertManager::isGuestAlertUnSubscribedByEmail($email); if ($unSubscribedGuestAlertSID > 0) { SJB_GuestAlertManager::deleteGuestAlertBySID($unSubscribedGuestAlertSID); $this->saveNewGuestAlert($guestAlert, $tp); } else { $this->template = 'replace.tpl'; } } else { $tp->assign('errors', $errors); $this->template = 'create.tpl'; } } $tp->display($this->template); }
/** * @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; }
public function execute() { $guestAlert = new SJB_GuestAlert($_REQUEST); $guestAlert->addDataProperty(serialize($this->criteriaData)); $tp = SJB_System::getTemplateProcessor(); try { $guestAlertSID = SJB_GuestAlertManager::getGuestAlertSIDByEmail($guestAlert->getAlertEmail()); $guestAlert->setSID($guestAlertSID); $guestAlert->update(); } catch (Exception $e) { $tp->assign('error', $e->getMessage()); } $tp->display('alert_replaced.tpl'); }
public function execute() { $key = SJB_Request::getVar('key', '', 'GET'); $tp = SJB_System::getTemplateProcessor(); $error = ''; try { $guestAlert = SJB_GuestAlertManager::getGuestAlertByKey($key); $guestAlert->setStatusActiveFromUnconfirmed(); $guestAlert->update(); SJB_Notifications::sendGuestAlertWelcomeEmail($guestAlert); } catch (Exception $e) { $error = $e->getMessage(); } $tp->assign('error', $error); $tp->display('confirm.tpl'); }
public function execute() { $key = SJB_Request::getVar('key', '', 'GET'); $tp = SJB_System::getTemplateProcessor(); $error = ''; try { $guestAlert = SJB_GuestAlertManager::getGuestAlertByKey($key); $guestAlert->setStatusUnSubscribed(); $guestAlert->update(); $tp->assign('email', $guestAlert->getAlertEmail()); } catch (Exception $e) { $error = $e->getMessage(); } $tp->assign('error', $error); $tp->display('unsubscribe.tpl'); }
/** * @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'); }
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; }
/** * @param SJB_GuestAlert $guestAlert */ public function delete(SJB_GuestAlert $guestAlert) { SJB_GuestAlertManager::deleteGuestAlertBySID($guestAlert->getSID()); }