Exemplo n.º 1
0
 /**
  * View action for contact controller
  * @throws Exception
  */
 public function viewAction()
 {
     // action body
     try {
         $translate = Zend_Registry::get('Zend_Translate');
         $mdlContact = new Contact_Model_Contact();
         $frmContact = new Contact_Form_Contact(array('type' => 'public'));
         $params = $this->getRequest()->getParams();
         $contact = $mdlContact->find((int) $params['contact'])->current();
         if (!$contact) {
             throw new Exception($translate->translate("CONTACT_ROW_NOT_FOUND"));
         }
         if ($this->getRequest()->isPost()) {
             if ($frmContact->isValid($_POST)) {
                 $mdlAccount = new Acl_Model_Account();
                 $account = $mdlAccount->find((int) $contact->account_id)->current();
                 $emailTo = strlen($contact->email_to) > 1 ? $contact->email_to : $account->email;
                 $mail = new Zend_Mail();
                 $mail->setBodyText($frmContact->getElement('message')->getValue())->setFrom($frmContact->getElement('email')->getValue(), $frmContact->getElement('fullname')->getValue())->addTo($emailTo, $account->first_name . ' ' . $account->last_name)->setSubject($translate->translate('CONTACT_DEFAULT_SUBJECT'))->send();
                 $frmContact->reset();
             }
         } else {
             $fields = array();
             foreach ($frmContact->getElements() as $element) {
                 $fields[] = $element->getName();
             }
             $frmContact->addDisplayGroup($fields, 'form', array('legend' => "CONTACT"));
         }
         $frmContact->setAction($this->_request->getBaseUrl() . "/contact/contact/view");
         $this->view->frmContact = $frmContact;
     } catch (Exception $e) {
         #$this->_helper->flashMessenger->addMessage( array('type'=>'error', 'header'=>'', 'message' => $e->getMessage() ) );
         #$this->_helper->redirector( "index", "contact", "contact" );
         echo $e->getMessage();
     }
     return;
 }
Exemplo n.º 2
0
 /**
  * block action for account controller
  * @throws Zend_Exception
  *
  */
 public function blockAction()
 {
     try {
         $translate = Zend_Registry::get('Zend_Translate');
         $mdlAccount = new Acl_Model_Account();
         $id = $this->getRequest()->getParam('id', 0);
         $account = $mdlAccount->find($id)->current();
         if (!$account) {
             throw new Zend_Exception($translate->translate("LABEL_ROW_NOT_FOUND"));
         }
         if ($account->block == 0) {
             $account->block = 1;
             $this->_helper->flashMessenger->addMessage(array('type' => 'info', 'header' => '', 'message' => $translate->translate("ACL_ACCOUNT_BLOCKED_SUCCESSFULLY")));
         } else {
             $account->block = 0;
             $this->_helper->flashMessenger->addMessage(array('type' => 'info', 'header' => '', 'message' => $translate->translate("ACL_ACCOUNT_UNBLOCKED_SUCCESSFULLY")));
         }
         $account->save();
         $this->_helper->redirector("list", "account", "acl");
     } catch (Exception $e) {
         $this->_helper->flashMessenger->addMessage(array('type' => 'error', 'header' => '', 'message' => $e->getMessage()));
         $this->_helper->redirector("list", "account", "acl");
     }
 }