示例#1
0
 public function addAction()
 {
     $form_comments = new Default_Form_Comments();
     $form_comments->setDecorators(array('ViewScript', array('ViewScript', array('viewScript' => 'forms/comments.phtml'))));
     $this->view->plugin_form_comments = $form_comments;
     if ($this->getRequest()->isPost()) {
         $model = new Default_Model_Comments();
         $action = $this->getRequest()->getPost('action');
         if ($form_comments->isValid($this->getRequest()->getPost())) {
             $model->setOptions($form_comments->getValues());
             $saved_comment = $model->save();
             /*$emailArray = array();
             
             				$emailArray['subject']			= 'Intrebare';
             				$emailArray['content']			= $this->getRequest()->getPost('mesaj');
             				$emailArray['toEmail']			= EMAIL_QUESTION_NOTIFICATION;
             				$emailArray['toName']			= INSTITUTION_NAME;
             				$emailArray['fromEmail']		= $this->getRequest()->getPost('email');
             				$emailArray['fromName']			= $this->getRequest()->getPost('nume');
             				$emailArray['SMTP_USERNAME']	= SMTP_USERNAME;
             				$emailArray['SMTP_PASSWORD']	= SMTP_PASSWORD;
             				$emailArray['SMTP_PORT']		= SMTP_PORT;
             				$emailArray['SMTP_URL']			= SMTP_URL;
             				$sent = Needs_Tools::sendEmail($emailArray);*/
             if ($saved_comment) {
                 $this->_flashMessenger->addMessage("<div class='success  canhide'><p>The comment was added successfully!</p><a href='javascript:;'></a></div>");
             } else {
                 $this->_flashMessenger->addMessage("<div class='failure canhide'><p>The comment was not added successfully!</p><a href='javascript:;'></a></div>");
             }
             $this->_redirect(WEBROOT . '/comments');
         }
     }
 }
 public function detailsAction()
 {
     $userId = null;
     $auth = Zend_Auth::getInstance();
     $authAccount = $auth->getStorage()->read();
     if (null != $authAccount) {
         if (null != $authAccount->getId()) {
             $this->view->userlogat = $authAccount;
         }
     }
     $id = (int) $this->getRequest()->getParam('id');
     if ($id) {
         // BEGIN: Find model
         $model = new Default_Model_RecurrentExpenses();
         if ($model->find($id)) {
             $this->view->result = $model;
         }
         $select = $model->getMapper()->getDbTable()->select()->where('NOT deleted')->order(array('created DESC'));
         $result = $model->fetchAll($select);
         // END: Find model
         //START: Adaugare comment
         $form_comments = new Default_Form_Comments();
         $form_comments->setDecorators(array('ViewScript', array('ViewScript', array('viewScript' => 'forms/comments.phtml'))));
         $this->view->plugin_form_comments = $form_comments;
         if ($this->getRequest()->isPost()) {
             $model = new Default_Model_Comments();
             $action = $this->getRequest()->getPost('action');
             if ($form_comments->isValid($this->getRequest()->getPost())) {
                 $model->setOptions($form_comments->getValues());
                 $model->setIdProject($id);
                 $saved_comment = $model->save();
                 if ($saved_comment) {
                     $admins = Needs_Tools::findAdmins();
                     $adminIds = Needs_Tools::findAdmins('id');
                     foreach ($adminIds as $adminId) {
                         $emailTemplate = new Default_Model_EmailTemplates();
                     }
                     $auth = Zend_Auth::getInstance();
                     $authAccount = $auth->getStorage()->read();
                     if (null != $authAccount) {
                         if (null != $authAccount->getId()) {
                             $user = new Default_Model_Users();
                             $user->find($authAccount->getId());
                         }
                     }
                     $select = $emailTemplate->getMapper()->getDbTable()->select()->where('const = ?', 'adaugare_comentariu_admin')->limit(1);
                     $emailTemplate->fetchRow($select);
                     if (NULL != $emailTemplate->getContent()) {
                         $emailArray = array();
                         $name = $user->name . ' ' . $user->surname;
                         $message = $emailTemplate->getContent();
                         $message = str_replace("{" . "\$" . "name}", $name, $message);
                         $notification = new Default_Model_NotificationMessages();
                         $notification->setIdUser($authAccount->getId());
                         $notification->setIdProject($id);
                         $notification->setSubject($emailTemplate->getSubject());
                         $notification->setMessage($message);
                         if ($idNotification = $notification->save()) {
                             $notify = new Default_Model_NotificationTo();
                             $notify->setIdNotification($idNotification);
                             $notify->setStatus('1');
                             foreach ($adminIds as $adminId) {
                                 $notify->setIdUserTo($adminId);
                                 $notify->save();
                             }
                         } else {
                             $this->_flashMessenger->addMessage("<div class='failure canhide'><p>Notificarile nu au fost salvate cu succes<a href='javascript:;'></a></p></div>");
                         }
                         $emailArray['subject'] = $emailTemplate->getSubject();
                         $emailArray['content'] = $message;
                         $emailArray['toEmail'] = $admins;
                         $emailArray['toName'] = $name;
                         $emailArray['fromEmail'] = EMAIL;
                         $emailArray['fromName'] = FROM_NAME;
                         $emailArray['SMTP_USERNAME'] = SMTP_USERNAME;
                         $emailArray['SMTP_PASSWORD'] = SMTP_PASSWORD;
                         $emailArray['SMTP_PORT'] = SMTP_PORT;
                         $emailArray['SMTP_URL'] = SMTP_URL;
                         Needs_Tools::sendEmail($emailArray);
                     }
                     $this->_flashMessenger->addMessage("<div class='success  canhide'><p>The comment was added successfully!<a href='javascript:;'></a></p></div>");
                 } else {
                     $this->_flashMessenger->addMessage("<div class='failure canhide'><p>The comment was not added successfully!<a href='javascript:;'></a></p></div>");
                 }
                 $this->_redirect(WEBROOT . '/recurrent-expenses/details/id/' . $id);
             }
         }
         //end adaugare comment
         //$modelc = new Default_Model_Comments();
         //			$select = $modelc->getMapper()->getDbTable()->select()
         //			->from(array('c' => 'comment'), array('c.*'))
         //			->where("NOT c.deleted")
         //			->where("c.idParent IS NULL")
         //			->where("c.idProduct=?",$model->getId())
         //			->order(array('c.created DESC'));
         //			$resultc = $modelc->fetchAll($select);
         //
         //			if(NULL != $resultc)
         //			{
         //				$paginator = Zend_Paginator::factory($resultc);
         //				$paginator->setItemCountPerPage(25);
         //				$paginator->setCurrentPageNumber($this->_getParam('page'));
         //				$paginator->setPageRange(5);
         //				$this->view->resultc = $paginator;
         //				$this->view->itemCountPerPage = $paginator->getItemCountPerPage();
         //				$this->view->totalItemCount = $paginator->getTotalItemCount();
         //
         //				Zend_Paginator::setDefaultScrollingStyle('Sliding');
         //				Zend_View_Helper_PaginationControl::setDefaultViewPartial('_pagination.phtml');
         //			}
     }
 }
示例#3
0
文件: Comments.php 项目: valizr/MMA
 public function fetchRow($select, Default_Model_Comments $model)
 {
     $result = $this->getDbTable()->fetchRow($select);
     if (0 == count($result)) {
         return;
     }
     $model->setOptions($result->toArray());
     return $model;
 }