コード例 #1
0
 /**
  * Action called when posting press reviews subscription form
  */
 public function postAction()
 {
     try {
         // Form is not posted correctly, we redirect to the previous page
         if (!$this->getRequest()->isPost()) {
             Flash::addItem(__("Requête invalide.", "s1b"));
             return HTTPHelper::redirectToReferer();
         }
         // Check the form validity
         $form = new PressReviewsSusbcriptionForm();
         if (!$form->isValid($_POST)) {
             Flash::addItems($form->getFailureMessages());
         } else {
             // Try to get an existing PressReviewsSubscriber
             /* @var $existingPressReviewSubscriber PressReviewsSubscriber */
             $existingPressReviewSubscriber = PressReviewsSubscriberDao::getInstance()->getByEmail($form->getEmail());
             if ($existingPressReviewSubscriber) {
                 // Update press reviews subscriber (reactivation)
                 $existingPressReviewSubscriber->setIs_deleted(false);
                 PressReviewsSubscriberDao::getInstance()->update($existingPressReviewSubscriber);
                 // Set success flash message
                 Flash::addItem(__("Votre abonnement a été réactivé.", "s1b"));
             } else {
                 // Add press reviews subscriber to database
                 $pressReviewsSubscribers = new PressReviewsSubscriber();
                 $pressReviewsSubscribers->setEmail($form->getEmail());
                 PressReviewsSubscriberDao::getInstance()->add($pressReviewsSubscribers);
                 // Set success flash message
                 Flash::addItem(__("Votre abonnement a bien été pris en compte.", "s1b"));
             }
         }
         HTTPHelper::redirectToReferer();
     } catch (\Exception $e) {
         Trace::addItem(sprintf("Une erreur s'est produite dans \"%s->%s\", TRACE : %s\"", get_class(), __FUNCTION__, $e->getTraceAsString()));
         $this->forward("error", "error", "default");
     }
 }
コード例 #2
0
 public function IsValid()
 {
     $this->__load();
     return parent::IsValid();
 }