Example #1
0
 /**
  * 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);
 }