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 SJB_GuestAlert $guestAlert */ public function delete(SJB_GuestAlert $guestAlert) { SJB_GuestAlertManager::deleteGuestAlertBySID($guestAlert->getSID()); }