Пример #1
0
 public function execute(IssueSelection $inputIssueSel, array $params = NULL)
 {
     $this->checkParams($inputIssueSel, $params);
     if (is_null($this->outputList)) {
         $privateIssueSel = new IssueSelection(IssuePublicPrivateFilter::tag_private);
         $publicIssueSel = new IssueSelection(IssuePublicPrivateFilter::tag_public);
         $issueList = $inputIssueSel->getIssueList();
         foreach ($issueList as $issue) {
             $isPrivate = $issue->isPrivate();
             if ($isPrivate) {
                 $privateIssueSel->addIssue($issue->getId());
             } else {
                 $publicIssueSel->addIssue($issue->getId());
             }
         }
         $this->outputList = array();
         $this->outputList[IssuePublicPrivateFilter::tag_private] = $privateIssueSel;
         $this->outputList[IssuePublicPrivateFilter::tag_public] = $publicIssueSel;
         if (self::$logger->isDebugEnabled()) {
             self::$logger->debug('input Nb Issues =' . $inputIssueSel->getNbIssues());
             foreach ($this->outputList as $tag => $iSel) {
                 self::$logger->debug('Tag {' . $tag . '} Nb Issues =' . $iSel->getNbIssues());
             }
         }
     }
     return $this->outputList;
 }
Пример #2
0
 /**
  * @return IssueSelection
  */
 public function getIssueSelection()
 {
     if (is_null($this->issueSelection)) {
         $this->issueSelection = new IssueSelection($this->name);
         $issueList = $this->getIssues();
         foreach ($issueList as $issue) {
             try {
                 $this->issueSelection->addIssue($issue->getId());
             } catch (Exception $e) {
                 self::$logger->warn("getIssueSelection: " . $e->getMessage());
             }
         }
     }
     return $this->issueSelection;
 }
Пример #3
0
 private function getResolvedIssues($teamid, $userid = 0, $projects = NULL)
 {
     $team = TeamCache::getInstance()->getTeam($teamid);
     if (is_null($projects)) {
         $projects = $team->getProjects(false, false, false);
         $formattedProjects = implode(',', array_keys($projects));
     } else {
         $formattedProjects = implode(',', array_values($projects));
     }
     $formattedUsers = 0 != $userid ? $userid : implode(',', array_keys($team->getActiveMembers()));
     $query = "SELECT id FROM `mantis_bug_table` " . "WHERE project_id IN ({$formattedProjects}) " . "AND handler_id IN ({$formattedUsers}) " . "AND status >= get_project_resolved_status_threshold(project_id) ";
     $result = SqlWrapper::getInstance()->sql_query($query);
     echo "query = {$query}<br>";
     if (!$result) {
         echo "<span style='color:red'>ERROR: Query FAILED</span>";
         exit;
     }
     $isel = new IssueSelection('resolvedIssues');
     while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
         $isel->addIssue($row->id);
     }
     echo implode(',', array_keys($isel->getIssueList()));
     return $isel;
 }
Пример #4
0
 /**
  *
  * @param type $projectid
  * @param String $categories imploded category_id list
  * @param String $reporteridList imploded userid list
  * @param String $handleridList imploded userid list
  */
 private function getIssueSelection($projectid, $categories = NULL, $formattedReporters = NULL, $formattedHandlers = NULL, $formattedStatuses = false)
 {
     $query = "SELECT id from `mantis_bug_table` WHERE project_id = {$projectid} ";
     if (!empty($categories)) {
         $query .= "AND category_id IN ({$categories}) ";
     }
     if (!empty($formattedReporters)) {
         $query .= "AND reporter_id IN ({$formattedReporters}) ";
     }
     if (!empty($formattedHandlers)) {
         $query .= "AND handler_id IN ({$formattedHandlers}) ";
     }
     if (!empty($formattedStatuses)) {
         $query .= "AND status IN ({$formattedStatuses}) ";
     }
     #if (!$withResolved) {
     #   $query .= "AND status < get_project_resolved_status_threshold(project_id) ";
     #}
     $result = SqlWrapper::getInstance()->sql_query($query);
     if (!$result) {
         echo "<span style='color:red'>ERROR: Query FAILED</span>";
         exit;
     }
     $iSel = new IssueSelection('exportODT');
     while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
         $iSel->addIssue($row->id);
     }
     #$iSel->addIssue(694);
     #echo implode(',', array_keys($iSel->getIssueList())).'<br>';
     return $iSel;
 }
Пример #5
0
 /**
  *
  * @param SmartyHelper $smartyHelper
  * @param Issue $issue
  * @param int $userid
  * @param int $teamid
  */
 public static function dashboardSettings(SmartyHelper $smartyHelper, Issue $issue, $userid, $teamid)
 {
     $isel = new IssueSelection();
     $isel->addIssue($issue->getId());
     $pluginDataProvider = PluginDataProvider::getInstance();
     $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_ISSUE_SELECTION, $isel);
     $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_TEAM_ID, $teamid);
     $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_SESSION_USER_ID, $userid);
     // start date is min(1st_timetrack, issue_creation_date)
     $startT = $issue->getDateSubmission();
     $firstTT = $issue->getFirstTimetrack();
     if (NULL != $firstTT) {
         $startT = min(array($issue->getDateSubmission(), $firstTT->getDate()));
     }
     // end date is last_timetrack or now if none
     $eTs = NULL == $firstTT ? time() : $issue->getLatestTimetrack()->getDate();
     $endT = mktime(23, 59, 59, date('m', $eTs), date('d', $eTs), date('Y', $eTs));
     //echo "start $startT end $endT<br>";
     // Calculate a nice day interval
     $nbWeeks = ($endT - $startT) / 60 / 60 / 24;
     $interval = ceil($nbWeeks / 20);
     $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_START_TIMESTAMP, $startT);
     $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_END_TIMESTAMP, $endT);
     $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_INTERVAL, $interval);
     $dashboardName = 'Tasks_prj' . $issue->getProjectId();
     // save the DataProvider for Ajax calls
     $_SESSION[PluginDataProviderInterface::SESSION_ID . $dashboardName] = serialize($pluginDataProvider);
     // create the Dashboard
     $dashboard = new Dashboard($dashboardName);
     // settings are common all tasks of a project
     $dashboard->setDomain(IndicatorPluginInterface::DOMAIN_TASK);
     $dashboard->setCategories(array(IndicatorPluginInterface::CATEGORY_QUALITY, IndicatorPluginInterface::CATEGORY_ACTIVITY, IndicatorPluginInterface::CATEGORY_ROADMAP, IndicatorPluginInterface::CATEGORY_PLANNING, IndicatorPluginInterface::CATEGORY_RISK));
     $dashboard->setTeamid($teamid);
     $dashboard->setUserid($userid);
     $data = $dashboard->getSmartyVariables($smartyHelper);
     foreach ($data as $smartyKey => $smartyVariable) {
         $smartyHelper->assign($smartyKey, $smartyVariable);
     }
 }
Пример #6
0
 /**
  *
  * returns an array of [user][activity]
  * activity in (elapsed, sidetask, other, external, leave)
  *
  */
 public function execute()
 {
     $team = TeamCache::getInstance()->getTeam($this->teamid);
     $members = $team->getActiveMembers(null, null, true);
     $issueList = $this->inputIssueSel->getIssueList();
     // ---
     $userList = array();
     $formattedTaskListPerUser = array();
     $iSelPerUser = array();
     $iSelOpenTasks = new IssueSelection('nonResolved');
     /* @var $issue Issue */
     foreach ($issueList as $issue) {
         try {
             // for each issue that is not resolved, add reestimated to handler.
             if (!$issue->isResolved()) {
                 $userId = $issue->getHandlerId();
                 if (0 != $userId) {
                     $user = UserCache::getInstance()->getUser($userId);
                     $userList[$userId] = $user->getRealname();
                 } else {
                     $userList[0] = '(unknown 0)';
                 }
                 if (!$this->isExtRef) {
                     $displayedTaskId = NULL;
                 } else {
                     $displayedTaskId = NULL != $issue->getTcId() && false != trim($issue->getTcId()) ? $issue->getTcId() : 'm-' . $issue->getId();
                 }
                 $tooltipAttr = $issue->getTooltipItems($this->teamid, $this->sessionUserid, $this->isManager);
                 // add task summary in front
                 $tooltipAttr = array(T_('Summary') => $issue->getSummary()) + $tooltipAttr;
                 $formattedTaskListPerUser[$userId][] = Tools::issueInfoURL($issue->getId(), $tooltipAttr, FALSE, $displayedTaskId);
                 if (!array_key_exists($userId, $iSelPerUser)) {
                     $iSelPerUser[$userId] = new IssueSelection('user_' . $userId);
                 }
                 $iSelPerUser[$userId]->addIssue($issue->getId());
                 $iSelOpenTasks->addIssue($issue->getId());
             }
         } catch (Exception $e) {
             self::$logger->error("BacklogPerUserIndicator: " . $e->getMessage());
         }
     }
     // sort by name, keep key-val association
     asort($userList);
     asort($members);
     // team members
     $usersActivity = array();
     foreach ($members as $userId => $userName) {
         if (array_key_exists($userId, $iSelPerUser)) {
             $isel = $iSelPerUser[$userId];
             $progress = round($isel->getProgress() * 100);
             $backlog = $isel->duration;
             $taskList = implode(', ', $formattedTaskListPerUser[$userId]);
             $nbTasks = count($formattedTaskListPerUser[$userId]);
         } else {
             $progress = 0;
             $backlog = '';
             $taskList = '';
             $nbTasks = '';
         }
         $usersActivity[$userId] = array('handlerName' => $userName, 'backlog' => $backlog, 'nbTasks' => $nbTasks, 'progress' => $progress, 'taskList' => $taskList);
     }
     // users not in team
     foreach ($userList as $userId => $userName) {
         if (!array_key_exists($userId, $members) && 0 != $userId) {
             $isel = $iSelPerUser[$userId];
             $usersActivity[$userId] = array('handlerName' => '<span class="warn_font">' . $userName . '</span>', 'backlog' => $isel->duration, 'nbTasks' => count($formattedTaskListPerUser[$userId]), 'progress' => round($isel->getProgress() * 100), 'taskList' => implode(', ', $formattedTaskListPerUser[$userId]));
         }
     }
     // unassigned tasks
     if (array_key_exists(0, $userList)) {
         $isel = $iSelPerUser[0];
         $usersActivity[0] = array('handlerName' => '<span class="error_font">' . T_('(unknown 0)') . '</span>', 'backlog' => $isel->duration, 'nbTasks' => count($formattedTaskListPerUser[0]), 'progress' => round($isel->getProgress() * 100), 'taskList' => implode(', ', $formattedTaskListPerUser[0]));
     }
     // Total
     $totalArray = array('handlerName' => T_('TOTAL'), 'backlog' => $iSelOpenTasks->duration, 'nbTasks' => count($iSelOpenTasks->getIssueList()), 'progress' => round($iSelOpenTasks->getProgress() * 100), 'taskList' => '');
     #var_dump($usersActivity);
     $this->execData = array();
     $this->execData['userArray'] = $usersActivity;
     $this->execData['totalArray'] = $totalArray;
 }
Пример #7
0
 /**
  * Split selection in 3 selection, sorted on issue drift.
  *
  * Note: this is a replacement for Timetracking::getIssuesDriftStats()
  *
  * @param int $threshold
  * @param bool $withSupport
  *
  * @return IssueSelection[] array of 3 IssueSelection instances ('negative', 'equal', 'positive')
  */
 public function getDeviationGroupsMgr($threshold = 1, $withSupport = true)
 {
     if (0 == count($this->issueList)) {
         echo "<div style='color:red'>ERROR getDeviationGroupsMgr: Issue List is empty !<br/></div>";
         self::$logger->error("getDeviationGroupsMgr(): Issue List is empty !");
         return NULL;
     }
     $negSubList = new IssueSelection("ahead Mgr");
     $equalSubList = new IssueSelection("in time Mgr");
     $posSubList = new IssueSelection("in drift Mgr");
     foreach ($this->issueList as $bugId => $issue) {
         $issueDrift = $issue->getDriftMgr($withSupport);
         // get drift stats. equal is when drif = +-threshold
         if ($issueDrift < -$threshold) {
             $negSubList->addIssue($bugId);
         } elseif ($issueDrift > $threshold) {
             $posSubList->addIssue($bugId);
         } else {
             $equalSubList->addIssue($bugId);
         }
     }
     return array("negative" => $negSubList, "equal" => $equalSubList, "positive" => $posSubList);
 }
Пример #8
0
 /**
  *
  * @param boolean $hasDetail if true, add [Progress, EffortEstim, Elapsed, Backlog, Drift]
  * @param boolean $isManager
  * @param int $userid
  * @return array
  */
 public function getDynatreeData($hasDetail = false, $isManager = false, $teamid = 0)
 {
     // TODO AND root_id = $this->getRootId()
     $query = "SELECT * FROM `codev_wbs_table` WHERE `parent_id` = " . $this->getId() . " ORDER BY `order`";
     $result = SqlWrapper::getInstance()->sql_query($query);
     //file_put_contents('/tmp/loadWBS.txt', "$query \n", FILE_APPEND);
     if ($result) {
         $parentArray = array();
         while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
             $wbselement = new WBSElement($row->id, $this->getRootId());
             $childArray = array();
             if ($wbselement->isFolder()) {
                 $childArray['isFolder'] = true;
                 $childArray['expand'] = $wbselement->isExpand();
                 $childArray['key'] = $wbselement->getId();
                 $detail = '';
                 if ($hasDetail) {
                     $bugids = $this->getBugidList($wbselement->getId());
                     $isel = new IssueSelection("wbs_" . $wbselement->getId());
                     foreach ($bugids as $bugid) {
                         try {
                             $isel->addIssue($bugid);
                         } catch (Exception $e) {
                             self::$logger->error("Issue {$bugid} does not exist in Mantis DB.");
                         }
                     }
                     if ($isManager) {
                         $effortEstim = $isel->getMgrEffortEstim();
                         $driftInfo = $isel->getDriftMgr();
                         $reestimated = $isel->getReestimated();
                     } else {
                         $effortEstim = $isel->getEffortEstim();
                         $driftInfo = $isel->getDrift();
                         $reestimated = '0';
                     }
                     $detail = '~' . round(100 * $isel->getProgress()) . '~' . $effortEstim . '~' . $reestimated . '~' . $isel->getElapsed() . '~' . $isel->duration . '~' . $driftInfo['nbDays'] . '~' . $isel->getDriftColor($driftInfo['nbDays']);
                 }
                 $childArray['title'] = $wbselement->getTitle() . $detail;
                 $childArray['children'] = $wbselement->getDynatreeData($hasDetail, $isManager, $teamid);
             } else {
                 try {
                     // avoid logging an exception...
                     if (!Issue::exists($wbselement->getBugId())) {
                         $e = new Exception("Issue with id=" . $wbselement->getBugId() . " not found.");
                         throw $e;
                     }
                     $issue = IssueCache::getInstance()->getIssue($wbselement->getBugId());
                     $detail = '';
                     if ($hasDetail) {
                         if ($isManager) {
                             $effortEstim = $issue->getMgrEffortEstim();
                             $drift = $issue->getDriftMgr();
                             $reestimated = $issue->getReestimated();
                         } else {
                             $effortEstim = $issue->getEffortEstim();
                             $drift = $issue->getDrift();
                             $reestimated = '0';
                         }
                         $detail = '~' . round(100 * $issue->getProgress()) . '~' . $effortEstim . '~' . $reestimated . '~' . $issue->getElapsed() . '~' . $issue->getBacklog() . '~' . $drift . '~' . $issue->getDriftColor($drift);
                     }
                     $formattedSummary = '<b>' . $issue->getId() . '</b> ' . $issue->getSummary();
                     //                  if ($hasDetail) {
                     //                     mb_internal_encoding("UTF-8");
                     //                     $formattedSummary = mb_strimwidth($formattedSummary, 0, 70, "...");
                     //                  }
                     $childArray['title'] = $formattedSummary . $detail;
                     $childArray['isFolder'] = false;
                     $childArray['key'] = $issue->getId();
                     // yes, bugid !
                     // add tooltip
                     $user = UserCache::getInstance()->getUser($issue->getHandlerId());
                     $titleAttr = array(T_('Project') => $issue->getProjectName(), T_('Category') => $issue->getCategoryName(), T_('Status') => Constants::$statusNames[$issue->getStatus()], T_('Assigned to') => $user->getRealname(), T_('Tags') => implode(',', $issue->getTagList()));
                     $childArray['href'] = Constants::$codevURL . '/reports/issue_info.php?bugid=' . $issue->getId();
                     #$childArray['htmlTooltip'] = Tools::getTooltip($issue->getTooltipItems($teamid, 0, $isManager));
                     $childArray['htmlTooltip'] = Tools::getTooltip($titleAttr);
                     #$childArray['icon'] = 'mantis_ico.gif';
                 } catch (Exception $e) {
                     //$childArray['title'] = $wbselement->getBugId().' - '.T_('Error: Task not found in Mantis DB !');
                     //$childArray['isFolder'] = false;
                     self::$logger->warn("Issue {$bugid} does not exist in Mantis DB: calling checkWBS()");
                     $childArray = array();
                     // remove from WBS
                     self::checkWBS();
                 }
             }
             if (sizeof($childArray) > 0) {
                 array_push($parentArray, $childArray);
             }
         }
         // root element not only has children !
         if ($this->id === $this->getRootId()) {
             $detail = '';
             if ($hasDetail) {
                 $bugids = $this->getBugidList($this->id);
                 $isel = new IssueSelection("wbs_" . $this->id);
                 foreach ($bugids as $bugid) {
                     try {
                         $isel->addIssue($bugid);
                     } catch (Exception $e) {
                         self::$logger->error("Issue {$bugid} does not exist in Mantis DB.");
                     }
                 }
                 if ($isManager) {
                     $effortEstim = $isel->getMgrEffortEstim();
                     $driftInfo = $isel->getDriftMgr();
                     $reestimated = $isel->getReestimated();
                 } else {
                     $effortEstim = $isel->getEffortEstim();
                     $driftInfo = $isel->getDrift();
                     $reestimated = '0';
                 }
                 $mgrDriftInfo = $isel->getDriftMgr();
                 $detail = '~' . round(100 * $isel->getProgress()) . '~' . $effortEstim . '~' . $reestimated . '~' . $isel->getElapsed() . '~' . $isel->duration . '~' . $driftInfo['nbDays'] . '~' . $isel->getDriftColor($driftInfo['nbDays']);
             }
             $rootArray = array('title' => $this->getTitle() . $detail, 'isFolder' => true, 'expand' => $this->isExpand(), 'key' => $this->getId(), 'children' => $parentArray);
             return $rootArray;
         } else {
             return $parentArray;
         }
     } else {
         self::$logger->error("Query failed!");
     }
 }