public function save($params = '*', $tsl_params = '*') { $db = Zend_Registry::get('db'); $mapper = new SxModule_Members_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()) { $db->update('MemberMail', $data, 'id = ' . (int) $this->getId()); $db->update('MemberMailTsl', $tslData, 'mail_id = ' . (int) $this->getId() . ' AND lng = ' . $db->quote($this->getLng())); } else { $db->insert('MemberMail', $data); $tslData['mail_id'] = $db->lastInsertId(); $config = Zend_Registry::get('config'); foreach ($config->system->language as $lng => $slng) { $tslData['lng'] = $lng; $db->insert('MemberMailTsl', $tslData); } } return $this; }
public function editemailAction() { SxCms_Acl::requireAcl('members', 'members.edit'); $proxy = new SxModule_Members_Email_Proxy(); $item = $proxy->getById((int) $this->_getParam('id'), $_SESSION['System']['lng']); $item->setTmx($this->tmx); if ($this->getRequest()->isPost()) { $mapper = new SxModule_Members_Email_Mapper(); $fields = $mapper->fromInput($this->_getAllParams(), $this->_email_editablefields()); $data = $mapper->toObject($fields, $item); $validator = new SxModule_Members_Email_Validator(); if ($validator->validate($data)) { $data->save(); $flashMessenger = $this->_helper->getHelper('FlashMessenger'); $flashMessenger->addMessage($this->admin_tmx->_('mailedited')); $this->_helper->redirector->gotoSimple('indexmail', 'member'); } $item = $data; } $this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Members_Email'); $this->view->item = $item; }