/** * Returns the recipients for this Helpdesk item. * * @return array Array with user IDs. */ public function getTo() { $userId = Phprojekt_Auth::getUserId(); // Gets only the recipients with at least a 'read' right. $recipients = parent::getTo(); // Assigned user if ($this->_model->assigned != $userId) { $recipients[] = $this->_model->assigned; } // Author user if ($this->_model->author != $userId) { $recipients[] = $this->_model->author; } // Owner user if ($this->_model->ownerId != $userId) { $recipients[] = $this->_model->ownerId; } // If the item has been reassigned, add the previous assigned user to the recipients $history = new Phprojekt_History(); $olUser = $history->getLastAssignedUser($this->_model, 'assigned'); if ($olUser > 0) { $recipients[] = $olUser; } // Return without duplicates return array_unique($recipients); }
/** * Returns the fields part of the Notification body. * * @param Zend_Locale $lang Locale for use in translations. * * @return array Array with 'field', 'label' and 'value'. */ public function getBodyFields($lang) { $fields = parent::getBodyFields($lang); foreach ($fields as $k => $f) { if ($f['field'] == 'occurrence' || $f['field'] == 'rrule' || $f['field'] == 'confirmationStatuses') { unset($fields[$k]); } if ($f['field'] == 'participants') { $fields[$k]['value'] = $this->_model->getParticipantsNames(); } } $fields[] = array('field' => 'recurrence', 'label' => Phprojekt::getInstance()->translate('Recurrence'), 'value' => $this->_model->recurrence); return $fields; }
/** * Returns the notification instance used by this phprojekt item. * * @return Phprojekt_Notification An intance of Phprojekt_Notification. */ public function getNotification() { $notification = new Phprojekt_Notification(); $notification->setModel($this); return $notification; }
/** * Overwrites the existing saveFrontendMessage. * Runs a regular save first and if successful, runs a second save for the alert before a meeting starts. * * @return boolean True for a sucessful save. */ public function saveFrontendMessage() { $this->_validFrom = null; $this->_validUntil = null; $this->_controllProcess = null; if (null === $this->_model->rrule || empty($this->_model->rrule)) { // Single events parent::saveFrontendMessage(); } else { // Multiple events // Check if is already saved if (Zend_Registry::isRegistered('keepSavedIds')) { $keepSavedIds = Zend_Registry::get('keepSavedIds'); $isSaved = isset($keepSavedIds[$this->_model->participantId]); } else { $isSaved = false; $keepSavedIds = array(); } // Only save the first one if ($this->_model->parentId != 0 && !$isSaved) { $keepSavedIds[$this->_model->participantId] = true; Zend_Registry::set('keepSavedIds', $keepSavedIds); parent::saveFrontendMessage(); } } $this->_validFrom = $this->getCalendarValidFrom(); $this->_validUntil = $this->getCalendarValidUntil(); $this->_controllProcess = Phprojekt_Notification::LAST_ACTION_REMIND; return parent::saveFrontendMessage(); }
/** * Disables all frontend messages. * * @return void */ public function jsonDisableFrontendMessagesAction() { $notification = new Phprojekt_Notification(); try { $notification->disableFrontendMessages(); $message = Phprojekt::getInstance()->translate(self::DISABLE_FRONTEND_MESSAGES_TRUE_TEXT); $resultType = 'success'; } catch (Exception $error) { Phprojekt::getInstance()->getLog()->debug('Error: ' . $error->getMessage()); $message = Phprojekt::getInstance()->translate(self::DISABLE_FRONTEND_MESSAGES_FALSE_TEXT); $resultType = 'error'; } $return = array('type' => $resultType, 'message' => $message, 'id' => 0); Phprojekt_Converter_Json::echoConvert($return); }
/** * Logout action. * * Logout the user, and redirect them to the login page. * * @return void */ public function logoutAction() { $frontendMessage = new Phprojekt_Notification(); $frontendMessage->setControllProcess(Phprojekt_Notification::LAST_ACTION_LOGOUT); $frontendMessage->saveFrontendMessage(); Phprojekt_Auth::logout(); $config = Phprojekt::getInstance()->getConfig(); $this->_redirect('../../index.php'); die; }