/**
  * Return all commits for a given issue
  * @param TBGIssue $issue
  * @return array
  */
 public static function getCommitsByIssue(TBGIssue $issue)
 {
     $data = array();
     if (!is_object(TBGVCSIntegrationIssueLinksTable::getTable()->getByIssueID($issue->getID()))) {
         return array();
     }
     foreach (TBGVCSIntegrationIssueLinksTable::getTable()->getByIssueID($issue->getID())->getAllRows() as $row) {
         $data[] = TBGContext::factory()->TBGVCSIntegrationIssueLink($row->get(TBGVCSIntegrationIssueLinksTable::ID), $row);
     }
     return $data;
 }
Beispiel #2
0
 /**
  * Add a related issue
  * 
  * @param TBGIssue $related_issue
  * 
  * @return boolean
  */
 public function addChildIssue(TBGIssue $related_issue)
 {
     if (!($row = TBGIssueRelationsTable::getTable()->getIssueRelation($this->getID(), $related_issue->getID()))) {
         $res = TBGIssueRelationsTable::getTable()->addChildIssue($this->getID(), $related_issue->getID());
         $this->_child_issues = null;
         $related_issue->addLogEntry(TBGLogTable::LOG_ISSUE_DEPENDS, TBGContext::getI18n()->__('%issuetype %issue_no now depends on the solution of this %this_issuetype', array('%this_issuetype' => $related_issue->getIssueType()->getName(), '%issuetype' => $this->getIssueType()->getName(), '%issue_no' => $this->getFormattedIssueNo())));
         $this->addLogEntry(TBGLogTable::LOG_ISSUE_DEPENDS, TBGContext::getI18n()->__('This %this_issuetype now depends on the solution of %issuetype %issue_no', array('%this_issuetype' => $this->getIssueType()->getName(), '%issuetype' => $related_issue->getIssueType()->getName(), '%issue_no' => $related_issue->getFormattedIssueNo())));
         return true;
     }
     return false;
 }
 /**
  * Add a related issue
  * 
  * @param TBGIssue $related_issue
  * 
  * @return boolean
  */
 public function addChildIssue(TBGIssue $related_issue)
 {
     if (!($row = B2DB::getTable('TBGIssueRelationsTable')->getIssueRelation($this->getID(), $related_issue->getID()))) {
         $res = B2DB::getTable('TBGIssueRelationsTable')->addChildIssue($this->getID(), $related_issue->getID());
         $this->_child_issues = null;
         $related_issue->addLogEntry(TBGLogTable::LOG_ISSUE_DEPENDS, TBGContext::getI18n()->__('%issuetype% %issue_no% now depends on the solution of this %this_issuetype%', array('%this_issuetype%' => $related_issue->getIssueType()->getName(), '%issuetype%' => $this->getIssueType()->getName(), '%issue_no%' => $this->getFormattedIssueNo())));
         $related_issue->addSystemComment(TBGContext::getI18n()->__('Dependancy added'), TBGContext::getI18n()->__('%issuetype% %issue_no% now depends on the solution of this %this_issuetype%', array('%this_issuetype%' => $related_issue->getIssueType()->getName(), '%issuetype%' => $this->getIssueType()->getName(), '%issue_no%' => $this->getFormattedIssueNo())), TBGContext::getUser()->getID());
         $this->addLogEntry(TBGLogTable::LOG_ISSUE_DEPENDS, TBGContext::getI18n()->__('This %this_issuetype% now depends on the solution of %issuetype% %issue_no%', array('%this_issuetype%' => $this->getIssueType()->getName(), '%issuetype%' => $related_issue->getIssueType()->getName(), '%issue_no%' => $related_issue->getFormattedIssueNo())));
         $comment = $this->addSystemComment(TBGContext::getI18n()->__('Dependancy added'), TBGContext::getI18n()->__('This %this_issuetype% now depends on the solution of %issuetype% %issue_no%', array('%this_issuetype%' => $this->getIssueType()->getName(), '%issuetype%' => $related_issue->getIssueType()->getName(), '%issue_no%' => $related_issue->getFormattedIssueNo())), TBGContext::getUser()->getID());
         return $comment instanceof TBGComment ? $comment : true;
     }
     return false;
 }
 protected function _getIssueRelatedUsers(TBGIssue $issue)
 {
     $uids = array();
     $cu = TBGContext::getUser()->getID();
     $ns = $this->getSetting(self::NOTIFY_ISSUE_UPDATED_SELF, $cu);
     // Add all users who's marked this issue as interesting
     $uids = TBGUserIssuesTable::getTable()->getUserIDsByIssueID($issue->getID());
     // Add all users from the team owning the issue if valid
     // or add the owning user if a user owns the issue
     if ($issue->getOwnerType() == TBGIdentifiableClass::TYPE_TEAM) {
         foreach ($issue->getOwner()->getMembers() as $member) {
             if ($member->getID() == $cu && !$ns) {
                 continue;
             }
             $uids[$member->getID()] = $member->getID();
         }
     } elseif ($issue->getOwnerType() == TBGIdentifiableClass::TYPE_USER) {
         if (!($issue->getOwnerID() == $cu && !$ns)) {
             $uids[$issue->getOwnerID()] = $issue->getOwnerID();
         }
     }
     // Add the poster
     if ($this->getSetting(self::NOTIFY_ISSUE_POSTED_UPDATED, $issue->getPostedByID())) {
         if (!($issue->getPostedByID() == $cu && !$ns)) {
             $uids[$issue->getPostedByID()] = $issue->getPostedByID();
         }
     }
     // Add all users from the team assigned to the issue if valid
     // or add the assigned user if a user is assigned to the issue
     if ($issue->getAssigneeType() == TBGIdentifiableClass::TYPE_TEAM) {
         // Get team member IDs
         foreach ($issue->getAssignee()->getMembers() as $member) {
             if ($member->getID() == $cu && !$ns) {
                 continue;
             }
             if (!$this->getSetting(self::NOTIFY_ISSUE_TEAMASSIGNED_UPDATED, $member->getID())) {
                 continue;
             }
             $uids[$member->getID()] = $member->getID();
         }
     } elseif ($issue->getAssigneeType() == TBGIdentifiableClass::TYPE_USER) {
         if (!($issue->getAssigneeID() == $cu && !$ns) && !!$this->getSetting(self::NOTIFY_ISSUE_ASSIGNED_UPDATED, $issue->getAssigneeID())) {
             $uids[$issue->getAssigneeID()] = $issue->getAssigneeID();
         }
     }
     // Add all users in the team who leads the project, if valid
     // or add the user who leads the project, if valid
     if ($issue->getProject()->getLeaderType() == TBGIdentifiableClass::TYPE_TEAM) {
         foreach ($issue->getProject()->getLeader()->getMembers() as $member) {
             if ($member->getID() == $cu && !$ns) {
                 continue;
             }
             if (!$this->getSetting(self::NOTIFY_ISSUE_RELATED_PROJECT_TEAMASSIGNED, $member->getID())) {
                 continue;
             }
             $uids[$member->getID()] = $member->getID();
         }
     } elseif ($issue->getProject()->getLeaderType() == TBGIdentifiableClass::TYPE_USER) {
         if (!($issue->getProject()->getLeaderID() == $cu && !$ns) && !!$this->getSetting(self::NOTIFY_ISSUE_PROJECT_ASSIGNED, $issue->getProject()->getLeaderID())) {
             $uids[$issue->getProject()->getLeaderID()] = $issue->getProject()->getLeaderID();
         }
     }
     // Same for QA
     if ($issue->getProject()->getQaResponsibleType() == TBGIdentifiableClass::TYPE_TEAM) {
         foreach ($issue->getProject()->getQaResponsible()->getMembers() as $member) {
             if ($member->getID() == $cu && !$ns) {
                 continue;
             }
             if (!$this->getSetting(self::NOTIFY_ISSUE_RELATED_PROJECT_TEAMASSIGNED, $member->getID())) {
                 continue;
             }
             $uids[$member->getID()] = $member->getID();
         }
     } elseif ($issue->getProject()->getQaResponsibleType() == TBGIdentifiableClass::TYPE_USER) {
         if (!($issue->getProject()->getQaResponsibleID() == $cu && !$ns) && !!$this->getSetting(self::NOTIFY_ISSUE_PROJECT_ASSIGNED, $issue->getProject()->getQaResponsibleID())) {
             $uids[$issue->getProject()->getQaResponsibleID()] = $issue->getProject()->getQaResponsibleID();
         }
     }
     foreach ($issue->getProject()->getAssignedTeams() as $team_id => $assignments) {
         foreach (TBGContext::factory()->TBGTeam($team_id)->getMembers() as $member) {
             if ($member->getID() == $cu && !$ns) {
                 continue;
             }
             if (!$this->getSetting(self::NOTIFY_ISSUE_RELATED_PROJECT_TEAMASSIGNED, $member->getID())) {
                 continue;
             }
             $uids[$member->getID()] = $member->getID();
         }
     }
     foreach ($issue->getProject()->getAssignedUsers() as $user_id => $assignments) {
         $member = TBGContext::factory()->TBGUser($user_id);
         if (!($member->getID() == $cu && !$ns) && !!$this->getSetting(self::NOTIFY_ISSUE_PROJECT_ASSIGNED, $member->getID())) {
             $uids[$member->getID()] = $member->getID();
         }
     }
     // Add all users relevant for all affected editions
     foreach ($issue->getEditions() as $edition_list) {
         if ($edition_list['edition']->getLeaderType() == TBGIdentifiableClass::TYPE_TEAM) {
             foreach ($edition_list['edition']->getLeader()->getMembers() as $member) {
                 if ($member->getID() == $cu && !$ns) {
                     continue;
                 }
                 if (!$this->getSetting(self::NOTIFY_ISSUE_RELATED_PROJECT_TEAMASSIGNED, $member->getID())) {
                     continue;
                 }
                 $uids[$member->getID()] = $member->getID();
             }
         } elseif ($edition_list['edition']->getLeaderType() == TBGIdentifiableClass::TYPE_USER) {
             if (!($edition_list['edition']->getLeaderID() == $cu && !$ns) && !!$this->getSetting(self::NOTIFY_ISSUE_PROJECT_ASSIGNED, $edition_list['edition']->getLeaderID())) {
                 $uids[$edition_list['edition']->getLeaderID()] = $edition_list['edition']->getLeaderID();
             }
         }
         if ($edition_list['edition']->getQaResponsibleType() == TBGIdentifiableClass::TYPE_TEAM) {
             foreach ($edition_list['edition']->getQaResponsible()->getMembers() as $member) {
                 if ($member->getID() == $cu && !$ns) {
                     continue;
                 }
                 if (!$this->getSetting(self::NOTIFY_ISSUE_RELATED_PROJECT_TEAMASSIGNED, $member->getID())) {
                     continue;
                 }
                 $uids[$member->getID()] = $member->getID();
             }
         } elseif ($edition_list['edition']->getQaResponsibleType() == TBGIdentifiableClass::TYPE_USER) {
             if (!($edition_list['edition']->getQaResponsibleID() == $cu && !$ns) && !!$this->getSetting(self::NOTIFY_ISSUE_PROJECT_ASSIGNED, $edition_list['edition']->getQaResponsibleID())) {
                 $uids[$edition_list['edition']->getQaResponsibleID()] = $edition_list['edition']->getQaResponsibleID();
             }
         }
         foreach ($edition_list['edition']->getAssignedTeams() as $team_id => $assignments) {
             foreach (TBGContext::factory()->TBGTeam($team_id)->getMembers() as $member) {
                 if ($member->getID() == $cu && !$ns) {
                     continue;
                 }
                 if (!$this->getSetting(self::NOTIFY_ISSUE_RELATED_PROJECT_TEAMASSIGNED, $member->getID())) {
                     continue;
                 }
                 $uids[$member->getID()] = $member->getID();
             }
         }
         foreach ($edition_list['edition']->getAssignedUsers() as $user_id => $assignments) {
             $member = TBGContext::factory()->TBGUser($user_id);
             if ($member->getID() == $cu && !$ns) {
                 continue;
             }
             if (!$this->getSetting(self::NOTIFY_ISSUE_PROJECT_ASSIGNED, $member->getID())) {
                 continue;
             }
             $uids[$member->getID()] = $member->getID();
         }
     }
     // Add all users relevant for all affected components
     foreach ($issue->getComponents() as $component_list) {
         foreach ($component_list['component']->getAssignedTeams() as $team_id => $assignments) {
             foreach (TBGContext::factory()->TBGTeam($team_id)->getMembers() as $member) {
                 if ($member->getID() == $cu && !$ns) {
                     continue;
                 }
                 if (!$this->getSetting(self::NOTIFY_ISSUE_RELATED_PROJECT_TEAMASSIGNED, $member->getID())) {
                     continue;
                 }
                 $uids[$member->getID()] = $member->getID();
             }
         }
         foreach ($component_list['component']->getAssignedUsers() as $user_id => $assignments) {
             $member = TBGContext::factory()->TBGUser($user_id);
             if ($member->getID() == $cu && !$ns) {
                 continue;
             }
             if (!$this->getSetting(self::NOTIFY_ISSUE_PROJECT_ASSIGNED, $member->getID())) {
                 continue;
             }
             $uids[$member->getID()] = $member->getID();
         }
     }
     foreach ($uids as $uid => $val) {
         if ($this->getSetting(self::NOTIFY_ISSUE_ONCE, $uid)) {
             if ($this->getSetting(self::NOTIFY_ISSUE_ONCE . '_' . $issue->getID(), $uid)) {
                 unset($uids[$uid]);
                 continue;
             } else {
                 $this->saveSetting(self::NOTIFY_ISSUE_ONCE . '_' . $issue->getID(), 1, $uid);
             }
         }
         $uids[$uid] = TBGContext::factory()->TBGUser($uid);
     }
     return $uids;
 }
 public function getIssueID()
 {
     return is_object($this->_issue_id) ? $this->_issue_id->getID() : (int) $this->_issue_id;
 }
 /**
  * Adds "notify once" settings for necessary issues
  * 
  * @param TBGIssue $issue
  * @param array|TBGUser $users
  */
 protected function _markIssueSent(TBGIssue $issue, $users)
 {
     foreach ($users as $user) {
         if ($user->getNotificationSetting(self::NOTIFY_ITEM_ONCE, false, 'mailing')->isOn()) {
             $user->setNotificationSetting(self::NOTIFY_ITEM_ONCE . '_issue_' . $issue->getID(), true, 'mailing')->save();
         }
     }
 }