Esempio n. 1
0
 /**
  * Calls the saveFrontendMessage of the FrontendMessage class
  * to save a message to the corresponding table.
  *
  * @return boolean True for a sucessful save.
  */
 public function saveFrontendMessage()
 {
     $bodyChanges = array();
     $recipients = $this->getRecipients();
     if (null !== $this->_model) {
         // This is only possible if $this->model is not null
         $history = Phprojekt_Loader::getLibraryClass('Phprojekt_History');
         $this->_lastHistory = $history->getLastHistoryData($this->_model);
         $bodyChanges = false === empty($this->_controllProcess) ? array() : $this->getBodyChanges(null, false);
         // If no recipients were added, return immediately
         // allthough a check in FrontendMessage saveFrontendMessage is performed too,
         // but this is earlier and avoids all the set.
         if (true === empty($recipients)) {
             return;
         }
     }
     $process = $this->getProcess();
     $description = $this->getDescription();
     $this->_frontendMessage->setCustomModuleId($this->getModuleId());
     $this->_frontendMessage->setCustomProjectId($this->getProjectId());
     $this->_frontendMessage->setCustomItemId($this->getItemId());
     $this->_frontendMessage->setCustomValidUntil($this->getValidUntil());
     $this->_frontendMessage->setCustomValidFrom($this->getValidFrom());
     $this->_frontendMessage->setCustomRecipients($recipients);
     $this->_frontendMessage->setCustomProcess($process);
     $this->_frontendMessage->setCustomDescription($description);
     $this->_frontendMessage->setCustomDetails($bodyChanges);
     $this->_frontendMessage->setCustomItemName($this->getItemName());
     $return = $this->_frontendMessage->saveFrontendMessage();
     return $return;
 }
Esempio n. 2
0
 /**
  * Returns the frontend (realtime) notification(s) to a user. The return format is JSON.
  *
  * Note:
  * At this point a Zend_Session::writeClose() is needed, to avoid blocking of other requests.
  * See http://www.php.net/manual/en/function.session-write-close.php for more details.
  *
  * @return void
  */
 public function jsonGetFrontendMessageAction()
 {
     try {
         Zend_Session::writeClose(false);
     } catch (Exception $error) {
         Phprojekt::getInstance()->getLog()->debug('Error: ' . $error->getMessage());
     }
     $notification = new Phprojekt_Notification_FrontendMessage();
     $userId = (int) Phprojekt_Auth::getUserId();
     $data = $notification->getFrontendMessage($userId);
     $return = array("data" => $data);
     Phprojekt_Converter_Json::echoConvert($return);
 }