Example #1
0
 public function save($params = '*', $tsl_params = '*')
 {
     $db = Zend_Registry::get('db');
     $mapper = new SxModule_Subscribe_Email_Mapper();
     $data = $mapper->toArray($this, 'item');
     $tslData = $mapper->toArray($this, 'tsl');
     if (is_array($params)) {
         $data = $mapper->fromInput($data, $params);
     }
     if (is_array($tsl_params)) {
         $tslData = $mapper->fromInput($tslData, $tsl_params);
     }
     if ($this->getId()) {
         $id = $this->getId();
         $db->update('SubscribeMail', $data, 'id = ' . (int) $id);
         $db->update('SubscribeMailTsl', $tslData, 'mail_id = ' . (int) $id . ' AND lng = ' . $db->quote($this->getLng()));
     } else {
         $db->insert('SubscribeMail', $data);
         $id = $db->lastInsertId();
         $config = Zend_Registry::get('config');
         foreach ($config->system->language as $lng => $slng) {
             $tslData['lng'] = $lng;
             $tslData['mail_id'] = (int) $id;
             $db->insert('SubscribeMailTsl', $tslData);
         }
     }
     return $this;
 }
 public function editemailAction()
 {
     $proxy = new SxModule_Subscribe_Email_Proxy();
     $item = $proxy->getById((int) $this->_getParam('id'), $_SESSION['System']['lng']);
     if ($this->getRequest()->isPost()) {
         $mapper = new SxModule_Subscribe_Email_Mapper();
         $fields = $mapper->fromInput($this->_getAllParams(), $this->_editablefields());
         $data = $mapper->toObject($fields, $item);
         $data->setLng($_SESSION['System']['lng']);
         $validator = new SxModule_Subscribe_Email_Validator();
         if ($validator->validate($data)) {
             $data->save();
             $cache = Zend_Registry::get('cache');
             $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('SxModule_Subscribe'));
             $flashMessenger = $this->_helper->getHelper('FlashMessenger');
             $flashMessenger->addMessage($this->admin_tmx->_('itemcreated'));
             $this->_helper->redirector->gotoSimple('indexmail', 'subscribe');
         }
         $item = $data;
     }
     $this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Subscribe');
     $this->view->item = $item;
 }