예제 #1
0
 public function validate(SxModule_Subscribe $object)
 {
     $this->validateTextRequired($object->getName(), 'name', 'content', $this->_namespace);
     $this->validateTextRequired($object->getfirstname(), 'firstname', 'content', $this->_namespace);
     $this->validateEmail($object->getEmail(), 'email', 'content', $this->_namespace);
     $msgr = Sanmax_MessageStack::getInstance($this->_namespace);
     if (!$msgr->getNamespaceMessages()) {
         return true;
     } else {
         return false;
     }
 }
예제 #2
0
 public function formAction()
 {
     $glob_tmx = new Zend_Translate('tmx', APPLICATION_ROOT . '/application/var/locale/global.tmx', $_SESSION['System']['lng']);
     $this->_helper->layout()->disableLayout();
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest()->getPost();
         if (isset($request['action-subscribe'])) {
             $this->_helper->viewRenderer->setNoRender();
             if ($request['action-subscribe'] == "subscribe") {
                 $subscribe = new SxModule_Subscribe();
                 if (empty($request['email-subscribe'])) {
                     echo json_encode(array('err' => 2));
                     die;
                 }
                 $subscribe->setEmail($request['email-subscribe']);
                 $subscribe->setFirstname('First');
                 $subscribe->setName('Name');
                 $subscribe->setLng($this->_getParam('lng', 'nl'));
                 $validator = new SxModule_Subscribe_Validator();
                 if ($validator->validate($subscribe)) {
                     $id = $subscribe->save();
                     $url = $this->hostURL() . '/' . $_SESSION['System']['lng'] . '/subscribe/' . $subscribe->getId();
                     $linkUrl = '<a href="' . $url . '">' . $url . '<a>';
                     $subscribe->sendConfirmation($linkUrl);
                     echo json_encode(array('err' => 0));
                 } else {
                     echo json_encode(array('err' => 1));
                 }
             }
         }
     }
 }
예제 #3
0
 public function toArray(SxModule_Subscribe $item)
 {
     $data = array('id' => $item->getId(), 'lng' => $item->getLng(), 'name' => $item->getName(), 'firstname' => $item->getFirstname(), 'email' => $item->getEmail(), 'active' => $item->getActive());
     return $data;
 }