Esempio n. 1
0
 public static function getDetailedCharges($projectid, $isManager, $selectedFilters)
 {
     $project = ProjectCache::getInstance()->getProject($projectid);
     $issueSel = $project->getIssueSelection();
     $allFilters = "ProjectVersionFilter,ProjectCategoryFilter,IssueExtIdFilter,IssuePublicPrivateFilter,IssueTagFilter,IssueCodevTypeFilter";
     $params = array('isManager' => $isManager, 'selectedFilters' => $selectedFilters, 'allFilters' => $allFilters, 'maxTooltipsPerPage' => Constants::$maxTooltipsPerPage);
     $detailedChargesIndicator = new DetailedChargesIndicator();
     $detailedChargesIndicator->execute($issueSel, $params);
     $smartyVariable = $detailedChargesIndicator->getSmartyObject();
     $smartyVariable['selectFiltersSrcId'] = $projectid;
     return $smartyVariable;
 }
Esempio n. 2
0
 protected function display()
 {
     // Consistency errors
     if (Tools::isConnectedUser()) {
         // only teamMembers & observers can access this page
         if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) {
             $this->smartyHelper->assign('accessDenied', TRUE);
         } else {
             $consistencyErrors = $this->getTeamConsistencyErrors($this->teamid);
             $this->smartyHelper->assign('teamid', $this->teamid);
             $this->smartyHelper->assign('count', count($consistencyErrors));
             if (isset($consistencyErrors)) {
                 $this->smartyHelper->assign('consistencyErrors', $consistencyErrors);
             }
         }
     }
     // log stats
     IssueCache::getInstance()->logStats();
     ProjectCache::getInstance()->logStats();
 }
Esempio n. 3
0
 /**
  * @param int $projectid
  * @param int $defaultBugid
  * @param array $projList
  * @return mixed[]
  */
 public static function getBugs($projectid = 0, $defaultBugid = 0, array $projList = NULL)
 {
     // Task list
     if (0 != $projectid) {
         $project1 = ProjectCache::getInstance()->getProject($projectid);
         $issueList = $project1->getIssues();
     } else {
         // no project specified: show all tasks
         $issueList = Project::getProjectIssues(array_keys($projList));
     }
     $bugs = NULL;
     foreach ($issueList as $issue) {
         $summary = "";
         if ($issue->getSummary()) {
             $summary = ' : ' . $issue->getSummary();
         }
         $bugs[$issue->getId()] = array('id' => $issue->getId(), 'name' => $issue->getFormattedIds() . $summary, 'selected' => $issue->getId() == $defaultBugid, 'projectid' => $issue->getProjectId());
     }
     return $bugs;
 }
Esempio n. 4
0
File: blog.php Progetto: fg-ok/codev
 /**
  * @param BlogPost[] $postList
  * @return mixed[]
  */
 private function getBlogPosts(array $postList)
 {
     $blogPosts = array();
     foreach ($postList as $id => $bpost) {
         $srcUser = UserCache::getInstance()->getUser($bpost->src_user_id);
         $item = array();
         // TODO
         $item['category'] = Config::getVariableValueFromKey(Config::id_blogCategories, $bpost->category);
         $item['severity'] = BlogPost::getSeverityName($bpost->severity);
         $item['summary'] = $bpost->summary;
         $item['content'] = $bpost->content;
         $item['date_submitted'] = date('Y-m-d G:i', $bpost->date_submitted);
         $item['from'] = $srcUser->getRealname();
         // find receiver
         if (0 != $bpost->dest_user_id) {
             $destUser = UserCache::getInstance()->getUser($bpost->dest_user_id);
             $item['to'] = $destUser->getRealname();
         } else {
             if (0 != $bpost->dest_team_id) {
                 $team = TeamCache::getInstance()->getTeam($bpost->dest_team_id);
                 $item['to'] = $team->getName();
             } else {
                 if (0 != $bpost->dest_project_id) {
                     $destProj = ProjectCache::getInstance()->getProject($bpost->dest_project_id);
                     $item['to'] = $destProj->getName();
                 } else {
                     $item['to'] = '?';
                 }
             }
         }
         $item['activity'] = 'activities...';
         $item['buttons'] = "<input type='button' value='" . T_('Ack') . "' onclick='javascript: ackPost(" . $bpost->id . ")' />";
         $item['buttons'] .= "<input type='button' value='" . T_('Hide') . "' onclick='javascript: hidePost(" . $bpost->id . ")' />";
         // TODO only if i'm the owner
         $item['buttons'] .= "<input type='button' value='" . T_('Delete') . "' onclick='javascript: deletePost(" . $bpost->id . ")' />";
         $item['isHidden'] = '0';
         $blogPosts[$id] = $item;
     }
     return $blogPosts;
 }
Esempio n. 5
0
 /**
  * Get project activity report
  * @param mixed[][][] $projectTracks
  * @param int $teamid The team id
  * @param boolean $isDetailed
  * @return mixed[]
  */
 private function getProjectActivityReport(array $projectTracks, $teamid, $isDetailed)
 {
     $team = TeamCache::getInstance()->getTeam($teamid);
     $projectActivityReport = NULL;
     foreach ($projectTracks as $projectId => $bugList) {
         $project = ProjectCache::getInstance()->getProject($projectId);
         $jobList = $project->getJobList($team->getProjectType($projectId));
         $jobTypeList = array();
         if ($isDetailed) {
             foreach ($jobList as $jobId => $jobName) {
                 $jobTypeList[$jobId] = $jobName;
             }
         }
         // write table content (by bugid)
         $row_id = 0;
         $bugDetailedList = "";
         foreach ($bugList as $bugid => $jobs) {
             $issue = IssueCache::getInstance()->getIssue($bugid);
             $user = UserCache::getInstance()->getUser($issue->getHandlerId());
             $totalTime = 0;
             $tr_class = $row_id & 1 ? "row_even" : "row_odd";
             $subJobList = array();
             foreach ($jobList as $jobId => $jobName) {
                 $jobTime = 0;
                 if (array_key_exists($jobId, $jobs)) {
                     $jobTime = $jobs[$jobId];
                 }
                 if ($isDetailed) {
                     $subJobList[$jobId] = $jobTime;
                 }
                 $totalTime += $jobTime;
             }
             $row_id += 1;
             $bugDetailedList[$bugid] = array('class' => $tr_class, 'description' => SmartyTools::getIssueDescription($bugid, $issue->getTcId(), $issue->getSummary()), 'jobList' => $subJobList, 'category' => $issue->getCategoryName(), 'targetVersion' => $issue->getTargetVersion(), 'currentStatusName' => $issue->getCurrentStatusName(), 'handlerName' => $user->getName(), 'progress' => round(100 * $issue->getProgress()), 'backlog' => $issue->getBacklog(), 'totalTime' => $totalTime);
         }
         $projectActivityReport[$projectId] = array('id' => $projectId, 'name' => $project->getName(), 'jobList' => $jobTypeList, 'bugList' => $bugDetailedList);
     }
     return $projectActivityReport;
 }
Esempio n. 6
0
 /**
  * get all existing projects, except ExternalTasksProject & SideTasksProjects
  * @return string[int] : name[id]
  */
 private function getProjectList()
 {
     $projects = Project::getProjects();
     if ($projects != NULL) {
         $extproj_id = Config::getInstance()->getValue(Config::id_externalTasksProject);
         $smartyProjects = array();
         foreach ($projects as $id => $name) {
             if ($extproj_id != $id) {
                 try {
                     $p = ProjectCache::getInstance()->getProject($id);
                     if (!$p->isSideTasksProject()) {
                         $smartyProjects[$id] = $name;
                     } else {
                         // exclude SideTasksProjects
                         if (self::$logger->isDebugEnabled()) {
                             self::$logger->debug("project {$id}: sideTaskProjects are excluded");
                         }
                     }
                 } catch (Exception $e) {
                     // could not determinate, so the project should be included in the list
                     if (self::$logger->isDebugEnabled()) {
                         self::$logger->debug("project {$id}: Unknown type, project included anyway.");
                     }
                     // nothing to do.
                 }
             } else {
                 // exclude ExternalTasksProject
                 if (self::$logger->isDebugEnabled()) {
                     self::$logger->debug("project {$id}: ExternalTasksProject is excluded");
                 }
             }
         }
         return $smartyProjects;
     } else {
         return NULL;
     }
 }
Esempio n. 7
0
/**
 * get only statuses defined for this project
 *
 * @return array statusId => statusName
 */
function getProjectStatusList($projectid)
{
    $statusList = array();
    $statusList[0] = array('id' => 0, 'name' => T_('(all)'), 'selected' => true);
    if (0 != $projectid) {
        // get only statuses defined for this project
        $project = ProjectCache::getInstance()->getProject($projectid);
        $wfTrans = $project->getWorkflowTransitionsFormatted();
        if (!is_null($wfTrans)) {
            $statusNames = $wfTrans[0];
        } else {
            // if none defined, get all mantis statuses
            $statusNames = Constants::$statusNames;
            ksort($statusNames);
        }
    }
    $statusList[Constants::$status_new] = array('id' => Constants::$status_new, 'name' => Constants::$statusNames[Constants::$status_new], 'selected' => false);
    foreach ($statusNames as $id => $name) {
        if (Constants::$status_new != $id) {
            $statusList[] = array('id' => $id, 'name' => $name, 'selected' => false);
        }
    }
    return $statusList;
}
Esempio n. 8
0
File: sort.php Progetto: fg-ok/codev
   CoDev-Timetracking is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   CoDev-Timetracking is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with CoDev-Timetracking.  If not, see <http://www.gnu.org/licenses/>.
*/
require '../path.inc.php';
$issues = ProjectCache::getInstance()->getProject(14)->getIssues();
echo "Not sorted issued<br>";
foreach ($issues as $issue) {
    echo $issue->getId() . "-";
}
echo "<br><br>";
echo "qsorted issued<br>";
$a = arrayCopy($issues);
$start = microtime(true);
Tools::qsort($a);
$end = microtime(true);
$qsortRes = array();
$i = 0;
foreach ($a as $issue) {
    echo $issue->getId() . "-";
    $issueInfoStr = $issue->getId() . ':' . $issue->getStatus() . '-' . date('Y-m-d', $issue->getDeadLine()) . '-' . $issue->getPriority() . '-' . $issue->getSeverity();
Esempio n. 9
0
 /**
  * Calculates the time each user spends on the teams projects.
  */
 public function getWorkingDaysPerProjectPerUser($withNoStats = true, $withDisabled = true, $sideTasksProjects = true)
 {
     $team = TeamCache::getInstance()->getTeam($this->team_id);
     $projectIds = array_keys($team->getProjects($withNoStats, $withDisabled, $sideTasksProjects));
     $projDataList = array();
     $memberList = array();
     $allProjTotalElapsed = 0;
     // get tracks of Dev/Mgr (active within the timestamp)
     $timeTracks = $this->getTimeTracks();
     foreach ($timeTracks as $timeTrack) {
         try {
             $issue = IssueCache::getInstance()->getIssue($timeTrack->getIssueId());
             $projectId = $issue->getProjectId();
             $userId = $timeTrack->getUserId();
             if (!in_array($projectId, $projectIds)) {
                 continue;
             }
             // create member
             if (!array_key_exists($userId, $memberList)) {
                 $user = UserCache::getInstance()->getUser($userId);
                 $memberList[$userId] = array('name' => $user->getRealname(), 'totalElapsed' => 0);
             }
             // create project
             if (!array_key_exists($projectId, $projDataList)) {
                 $prj = ProjectCache::getInstance()->getProject($projectId);
                 $projDataList[$projectId] = array('name' => $prj->getName(), 'totalElapsed' => 0, 'usersData' => array());
             }
             // process track data
             $elapsed = $timeTrack->getDuration();
             $projDataList[$projectId]['totalElapsed'] += $elapsed;
             $projDataList[$projectId]['usersData'][$userId] += $elapsed;
             $memberList[$userId]['totalElapsed'] += $elapsed;
             $allProjTotalElapsed += $elapsed;
         } catch (Exception $exp) {
             // XXX show some error on the screen since the data is wrong
             self::$logger->warn("getWorkingDaysPerProjectPerUser: issue " . $timeTrack->getIssueId() . " not found in Mantis DB.");
         }
     }
     $data = array('userDataList' => $memberList, 'projDataList' => $projDataList, 'allProjTotalElapsed' => $allProjTotalElapsed);
     //echo nl2br(print_r($data, true));
     return $data;
 }
Esempio n. 10
0
 /**
  * @param int $teamid
  * @param int $startTimestamp
  * @param int $endTimestamp
  * @param int[] $projectIds
  * @return GanttGraph
  */
 private function getGanttGraph($teamid, $startTimestamp, $endTimestamp, array $projectIds)
 {
     $graph = new GanttGraph();
     // set graph title
     $team = TeamCache::getInstance()->getTeam($teamid);
     if (0 != count($projectIds)) {
         $pnameList = "";
         foreach ($projectIds as $pid) {
             if ("" != $pnameList) {
                 $pnameList .= ",";
             }
             $project = ProjectCache::getInstance()->getProject($pid);
             $pnameList .= $project->getName();
         }
         $graph->title->Set(T_('Team') . ' ' . $team->getName() . '    ' . T_('Project(s)') . ': ' . $pnameList);
     } else {
         $graph->title->Set(T_('Team') . ' ' . $team->getName() . '    (' . T_('All projects') . ')');
     }
     // Setup scale
     $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK);
     $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAYWNBR);
     $gantManager = new GanttManager($teamid, $startTimestamp, $endTimestamp);
     $teamActivities = $gantManager->getTeamActivities();
     // mapping to ease constrains building
     // Note: $issueActivityMapping must be completed before calling $a->getJPGraphBar()
     $issueActivityMapping = array();
     $activityIdx = 0;
     foreach ($teamActivities as $a) {
         $a->setActivityIdx($activityIdx);
         $issueActivityMapping[$a->bugid] = $activityIdx;
         ++$activityIdx;
     }
     // Add the specified activities
     foreach ($teamActivities as $a) {
         // FILTER on projects
         if (NULL != $projectIds && 0 != sizeof($projectIds)) {
             $issue = IssueCache::getInstance()->getIssue($a->bugid);
             if (!in_array($issue->getProjectId(), $projectIds)) {
                 // skip activity indexing
                 continue;
             }
         }
         $filterTeamActivities[] = $a;
         // Shorten bar depending on gantt startDate
         if (NULL != $startTimestamp && $a->startTimestamp < $startTimestamp) {
             // leave one day to insert prefixBar
             $newStartTimestamp = $startTimestamp + 60 * 60 * 24;
             if ($newStartTimestamp > $a->endTimestamp) {
                 // there is not enough space for a prefixBar
                 $newStartTimestamp = $startTimestamp;
                 self::$logger->debug("bugid=" . $a->bugid . ": Shorten bar to Gantt start date");
             } else {
                 $formattedStartDate = date('Y-m-d', $startTimestamp);
                 $prefixBar = new GanttBar($a->activityIdx, "", $formattedStartDate, $formattedStartDate, "", 10);
                 $prefixBar->SetBreakStyle(true, 'dotted', 1);
                 $graph->Add($prefixBar);
                 self::$logger->debug("bugid=" . $a->bugid . ": Shorten bar & add prefixBar");
             }
             self::$logger->debug("bugid=" . $a->bugid . ": Shorten bar from " . date('Y-m-d', $a->startTimestamp) . " to " . date('Y-m-d', $newStartTimestamp));
             $a->startTimestamp = $newStartTimestamp;
         }
         $bar = $a->getJPGraphBar($issueActivityMapping);
         $graph->Add($bar);
     }
     return $graph;
 }
Esempio n. 11
0
 private function getIssueTooltips($projects, $teamid)
 {
     $issueTooltips = array();
     foreach ($projects as $id => $name) {
         $project = ProjectCache::getInstance()->getProject($id);
         // do not display projects having no specific tooltips
         $result = Config::getValue(Config::id_issueTooltipFields, array(0, $id, $teamid, 0, 0, 0), true);
         if ($result == NULL) {
             continue;
         }
         $fields = $project->getIssueTooltipFields($teamid);
         $formattedFields = array();
         foreach ($fields as $f) {
             $formattedFields[] = Tools::getTooltipFieldDisplayName($f);
         }
         $strFields = implode(', ', $formattedFields);
         $issueTooltips[$id] = array("projectId" => $id, "projectName" => $name, "tooltipFields" => $strFields);
     }
     return $issueTooltips;
 }
Esempio n. 12
0
 /**
  * Get jobs.
  *
  * Note: only sidetaskProjects & externalTasksProject are in the $projList
  *
  * @param int $defaultProjectid
  * @param array $projList
  * @return mixed[]
  */
 private function getJobs($defaultProjectid, $projList)
 {
     // Job list
     if (0 != $defaultProjectid) {
         $project1 = ProjectCache::getInstance()->getProject($defaultProjectid);
         $jobList = $project1->getJobList(Project::type_sideTaskProject);
     } else {
         $jobList = array();
         foreach ($projList as $pid2 => $pname) {
             $tmpPrj1 = ProjectCache::getInstance()->getProject($pid2);
             $jobList += $tmpPrj1->getJobList(Project::type_sideTaskProject);
         }
     }
     // do not display selector if only one Job
     if (1 == count($jobList)) {
         reset($jobList);
         return key($jobList);
     } else {
         return $jobList;
     }
 }
Esempio n. 13
0
 if ($_GET['action'] == 'processPostSelectionAction') {
     try {
         $selectedTooltips = Tools::getSecureGETStringValue('selectedItems', NULL);
         if (strlen($selectedTooltips) == 0) {
             $selectedTooltips = null;
         }
         $implodedSrcRef = Tools::getSecureGETStringValue('itemSelection_srcRef');
         $srcRefList = Tools::doubleExplode(':', ',', $implodedSrcRef);
         $projectid = $srcRefList['projectid'];
         $teamid = $srcRefList['teamid'];
         // save user preferances
         $tooltips = NULL;
         if ($selectedTooltips != NULL) {
             $tooltips = explode(',', $selectedTooltips);
         }
         $project = ProjectCache::getInstance()->getProject($projectid);
         $project->setIssueTooltipFields($tooltips, $teamid);
         $formattedFields = array();
         if ($tooltips != NULL) {
             foreach ($tooltips as $f) {
                 $formattedFields[] = Tools::getTooltipFieldDisplayName($f);
             }
         }
         $strFields = implode(', ', $formattedFields);
         // return row to add/replace in issueTooltipsTable
         $response = array();
         $response['projectid'] = $projectid;
         $response['projectName'] = $project->getName();
         $response['tooltipFields'] = $strFields;
         // json encode
         $jsonResponse = Tools::array2json($response);
Esempio n. 14
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($this->startTimestamp, $this->endTimestamp);
     $formatedUseridString = implode(', ', array_keys($members));
     $extProjId = Config::getInstance()->getValue(Config::id_externalTasksProject);
     $extTasksCatLeave = Config::getInstance()->getValue(Config::id_externalTasksCat_leave);
     // get timetracks for each Issue,
     $issueList = $this->inputIssueSel->getIssueList();
     $bugidList = array_keys($issueList);
     $query = "SELECT * FROM `codev_timetracking_table` " . "WHERE userid IN (" . $formatedUseridString . ") ";
     if (isset($this->startTimestamp)) {
         $query .= "AND date >= {$this->startTimestamp} ";
     }
     if (isset($this->endTimestamp)) {
         $query .= "AND date <= {$this->endTimestamp} ";
     }
     $query .= " ORDER BY bugid";
     $result = SqlWrapper::getInstance()->sql_query($query);
     if (!$result) {
         echo "<span style='color:red'>ERROR: Query FAILED</span>";
         exit;
     }
     $timeTracks = array();
     while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
         $timeTracks[$row->id] = TimeTrackCache::getInstance()->getTimeTrack($row->id, $row);
     }
     // ---
     // un tablean de users avec repartition temps en categories: regular,external,sidetask
     $teams = array($this->teamid);
     $usersActivity = array();
     foreach ($timeTracks as $tt) {
         $issueId = $tt->getIssueId();
         try {
             $issue = IssueCache::getInstance()->getIssue($issueId);
         } catch (Exception $e) {
             self::$logger->error("execute() skip issue {$issueId} : " . $e->getMessage());
             continue;
         }
         $userid = $tt->getUserId();
         if (!array_key_exists($userid, $usersActivity)) {
             $usersActivity[$userid] = array();
         }
         //$activityList = $usersActivity[$userid];
         $duration = $tt->getDuration();
         try {
             if ($extProjId == $tt->getProjectId()) {
                 #self::$logger->error("external ".$tt->getIssueId());
                 if ($extTasksCatLeave == $issue->getCategoryId()) {
                     if (array_key_exists('leave', $usersActivity[$userid])) {
                         $usersActivity[$userid]['leave'] += $duration;
                     } else {
                         $usersActivity[$userid]['leave'] = $duration;
                     }
                 } else {
                     if (array_key_exists('external', $usersActivity[$userid])) {
                         $usersActivity[$userid]['external'] += $duration;
                     } else {
                         $usersActivity[$userid]['external'] = $duration;
                     }
                 }
             } else {
                 if ($issue->isSideTaskNonProductionIssue($teams)) {
                     #self::$logger->error("execute showSidetasks = ".$this->showSidetasks.' cat='.$cat);
                     // if sideTask is in the IssueSelection, then it is considered as 'normal',
                     // else it should not be included
                     if (in_array($issueId, $bugidList)) {
                         $cat = $this->showSidetasks ? 'sidetask' : 'elapsed';
                         if (array_key_exists($cat, $usersActivity[$userid])) {
                             $usersActivity[$userid][$cat] += $duration;
                         } else {
                             $usersActivity[$userid][$cat] = $duration;
                         }
                     } else {
                         // all sideTasks are in 'other' except inactivity tasks.
                         $project = ProjectCache::getInstance()->getProject($issue->getProjectId());
                         if ($project->getCategory(Project::cat_st_inactivity) == $issue->getCategoryId()) {
                             if (array_key_exists('leave', $usersActivity[$userid])) {
                                 $usersActivity[$userid]['leave'] += $duration;
                             } else {
                                 $usersActivity[$userid]['leave'] = $duration;
                             }
                         } else {
                             if (array_key_exists('other', $usersActivity[$userid])) {
                                 $usersActivity[$userid]['other'] += $duration;
                             } else {
                                 $usersActivity[$userid]['other'] = $duration;
                             }
                         }
                     }
                 } else {
                     if (in_array($issueId, $bugidList)) {
                         #self::$logger->error("selection ".$tt->getIssueId());
                         if (array_key_exists('elapsed', $usersActivity[$userid])) {
                             $usersActivity[$userid]['elapsed'] += $duration;
                         } else {
                             $usersActivity[$userid]['elapsed'] = $duration;
                         }
                     } else {
                         #echo "other ".$tt->getIssueId()."<br>";
                         if (array_key_exists('other', $usersActivity[$userid])) {
                             $usersActivity[$userid]['other'] += $duration;
                         } else {
                             $usersActivity[$userid]['other'] = $duration;
                         }
                     }
                 }
             }
         } catch (Exception $e) {
             // Issue::isSideTaskIssue() throws an Ex if project not found in mantis
             self::$logger->error("Unknown activity for issue {$issueId}, duration ({$duration}) added to 'elapsed'\n" . $e->getMessage());
             $usersActivity[$userid]['elapsed'] += $duration;
             // should it be added in userActivity[$userid]['unknown'] ?
         }
     }
     #var_dump($usersActivity);
     $this->execData = $usersActivity;
 }
Esempio n. 15
0
 private function getMonthlyActivityReport(array $tracks)
 {
     $userList = array();
     // first is 'All', then one per user
     #$userList['0'] = array(); // All users together
     foreach ($tracks as $t) {
         $userid = $t->getUserId();
         $bugid = $t->getIssueId();
         if (!array_key_exists($userid, $userList)) {
             $user = UserCache::getInstance()->getUser($userid);
             $userList["{$userid}"] = array('name' => $user->getName(), 'realname' => $user->getRealname(), 'elapsedInPeriod' => 0, 'tasks' => array());
             #echo "new user $userid<br>";
         }
         if (!array_key_exists($bugid, $userList["{$userid}"]['tasks'])) {
             try {
                 $issue = IssueCache::getInstance()->getIssue($bugid);
                 $project = ProjectCache::getInstance()->getProject($issue->getProjectId());
                 if (!$project->isSideTasksProject(array($this->teamid)) && !$project->isExternalTasksProject()) {
                     $tooltipAttr = $issue->getTooltipItems($this->teamid, $this->session_userid);
                     $infoTooltip = Tools::imgWithTooltip('images/b_info.png', $tooltipAttr);
                     $progress = round(100 * $issue->getProgress());
                     $backlog = $issue->getBacklog();
                 } else {
                     $infoTooltip = NULL;
                     $progress = NULL;
                     $backlog = NULL;
                 }
                 $projectName = $issue->getProjectName();
                 $summary = SmartyTools::getIssueDescription($bugid, $issue->getTcId(), $issue->getSummary());
             } catch (Exception $e) {
                 $infoTooltip = NULL;
                 $progress = NULL;
                 $backlog = NULL;
                 $projectName = '<span class="error_font">' . T_('Error') . '</span>';
                 $summary = $bugid . ' : <span class="error_font">' . T_('Error: Task not found in Mantis DB !') . '</span>';
             }
             $userList["{$userid}"]['tasks']["{$bugid}"] = array('id' => $bugid, 'infoTooltip' => $infoTooltip, 'projectName' => $projectName, 'summary' => $summary, 'progress' => $progress, 'backlog' => $backlog, 'elapsedInPeriod' => 0);
             #echo "new UserTask $bugid : ".$issue->getSummary()."<br>";
         }
         $userList["{$userid}"]['tasks']["{$bugid}"]['elapsedInPeriod'] += $t->getDuration();
         $userList["{$userid}"]['elapsedInPeriod'] += $t->getDuration();
         #echo "user $userid task $bugid elapsedInPeriod = ".$userList["$userid"]['tasks']["$bugid"]['elapsedInPeriod'].'<br>';
     }
     #var_dump($userList);
     return $userList;
 }
Esempio n. 16
0
 /**
  * @param bool $skipIfInCommands SideTasks already declared in a child Commands will be skipped
  * @return IssueSelection[] : array[category_type] = IssueSelection("categoryName")
  */
 function getSidetasksPerCategoryType($skipIfInCommands = false)
 {
     if (NULL == $this->sidetasksPerCategoryType) {
         $this->sidetasksPerCategoryType = array();
     }
     $key = $skipIfInCommands ? 'skip_yes' : 'skip_no';
     if (!array_key_exists($key, $this->sidetasksPerCategoryType)) {
         $this->sidetasksPerCategoryType[$key] = array();
         if ($skipIfInCommands) {
             $cmdidList = array_keys($this->getCommands(CommandSet::type_general, Command::type_general));
         }
         $prjList = $this->getProjects();
         foreach ($prjList as $id => $project) {
             try {
                 if (!$project->isSideTasksProject(array($this->teamid))) {
                     self::$logger->error("getSidetasksPerCategoryType: SKIPPED project {$id} (" . $project->getName() . ") should be a SidetasksProject !");
                     continue;
                 }
             } catch (Exception $e) {
                 self::$logger->error("getSidetasksPerCategoryType: EXCEPTION SKIPPED project {$id} (" . $project->getName() . ") : " . $e->getMessage());
                 continue;
             }
             $issueList = $project->getIssues();
             foreach ($issueList as $issue) {
                 if ($skipIfInCommands) {
                     // compare the Commands of the Issue whit the Commands of this ServiceContract
                     $issueCmdidList = array_keys($issue->getCommandList());
                     $isInCommands = 0 != count(array_intersect($cmdidList, $issueCmdidList));
                     if ($isInCommands) {
                         if (self::$logger->isDebugEnabled()) {
                             self::$logger->debug("getSidetasksPerCategoryType(): skip issue " . $issue->getId() . " because already declared in a Command");
                         }
                         continue;
                     }
                 }
                 // find category type (depends on project)
                 $proj = ProjectCache::getInstance()->getProject($issue->getProjectId());
                 $categoryList = $proj->getCategoryList();
                 $cat_type = array_search($issue->getCategoryId(), $categoryList);
                 if (is_numeric($cat_type)) {
                     $cat = $cat_type;
                     $cat_name = Project::$catTypeNames["{$cat_type}"];
                 } else {
                     $cat = 'CAT_ID_' . $issue->getCategoryId();
                     $cat_name = $issue->getCategoryName();
                 }
                 #echo "cat_type = $cat_type id=".$issue->getCategoryId()." $cat_name<br>";
                 if (!array_key_exists($cat, $this->sidetasksPerCategoryType[$key])) {
                     $this->sidetasksPerCategoryType[$key][$cat] = new IssueSelection($cat_name);
                 }
                 $issueSel = $this->sidetasksPerCategoryType[$key][$cat];
                 $issueSel->addIssue($issue->getId());
             }
         }
     }
     return $this->sidetasksPerCategoryType[$key];
 }
Esempio n. 17
0
 /**
  * creates for each project a table with the following fields:
  * id | TC | startDate | endDate | status | total elapsed | elapsed + Backlog | elapsed in period | Backlog
  * TOTAL
  * @param TimeTracking $timeTracking
  * @param string $myFile
  * @return string
  */
 public static function exportProjectMonthlyActivityToCSV(TimeTracking $timeTracking, $myFile)
 {
     $sepChar = ';';
     $fh = fopen($myFile, 'w');
     // returns : $projectTracks[projectid][bugid][jobid] = duration
     $projectTracks = $timeTracking->getProjectTracks();
     foreach ($projectTracks as $projectId => $bugList) {
         $totalEffortEstim = 0;
         $totalElapsed = 0;
         $totalBacklog = 0;
         $totalElapsedPeriod = 0;
         // write table header
         $project = ProjectCache::getInstance()->getProject($projectId);
         $stringData = $project->getName() . "\n";
         // WARNING i18n: HTML translation like french accents (eacute;) add an unwanted column sepChar (;)
         $stringData .= "ID" . $sepChar;
         $stringData .= "Task" . $sepChar;
         $stringData .= "Ext.ID" . $sepChar;
         $stringData .= "Start date" . $sepChar;
         $stringData .= "End date" . $sepChar;
         $stringData .= "Status" . $sepChar;
         $stringData .= "Total EffortEstim" . $sepChar;
         $stringData .= "Total elapsed" . $sepChar;
         $stringData .= "elapsed + Backlog" . $sepChar;
         $stringData .= "elapsed in period" . $sepChar;
         $stringData .= "BL" . $sepChar;
         $stringData .= "\n";
         // write table content (by bugid)
         foreach ($bugList as $bugid => $jobs) {
             $issue = IssueCache::getInstance()->getIssue($bugid);
             // remove sepChar from summary text
             $formatedSummary = str_replace($sepChar, " ", $issue->getSummary());
             $stringData .= $bugid . $sepChar;
             $stringData .= $formatedSummary . $sepChar;
             $stringData .= $issue->getTcId() . $sepChar;
             $stringData .= date("d/m/Y", $issue->startDate()) . $sepChar;
             $stringData .= date("d/m/Y", $issue->endDate()) . $sepChar;
             $stringData .= $issue->getCurrentStatusName() . $sepChar;
             $stringData .= $issue->getEffortEstim() + $issue->getEffortAdd() . $sepChar;
             $stringData .= $issue->getElapsed() . $sepChar;
             $stringData .= $issue->getElapsed() + $issue->getBacklog() . $sepChar;
             // sum all job durations
             $elapsedInPeriod = 0;
             foreach ($jobs as $jobId => $duration) {
                 $elapsedInPeriod += $duration;
             }
             $stringData .= $elapsedInPeriod . $sepChar;
             $stringData .= $issue->getBacklog() . $sepChar;
             $stringData .= "\n";
             $totalEffortEstim += $issue->getEffortEstim() + $issue->getEffortAdd();
             $totalElapsed += $issue->getElapsed();
             $totalBacklog += $issue->getBacklog();
             $totalElapsedPeriod += $elapsedInPeriod;
         }
         // total per project
         $stringData .= "TOTAL" . $sepChar . $sepChar . $sepChar . $sepChar . $sepChar . $sepChar;
         $stringData .= $totalEffortEstim . $sepChar;
         $stringData .= $totalElapsed . $sepChar;
         $stringData .= $totalElapsed + $totalBacklog . $sepChar;
         $stringData .= $totalElapsedPeriod . $sepChar;
         $stringData .= $totalBacklog . $sepChar;
         $stringData .= "\n";
         $stringData .= "\n";
         fwrite($fh, $stringData);
     }
     fclose($fh);
     return $myFile;
 }
Esempio n. 18
0
 protected function display()
 {
     if (Tools::isConnectedUser()) {
         $user = UserCache::getInstance()->getUser($_SESSION['userid']);
         $teamList = $user->getTeamList();
         if (0 != count($teamList)) {
             // ---- select project
             // define the list of tasks the user can display
             // All projects from teams where I'm a Developper or Manager AND Observers
             $dTeamList = $user->getDevTeamList();
             $devProjList = 0 == count($dTeamList) ? array() : $user->getProjectList($dTeamList);
             $managedTeamList = $user->getManagedTeamList();
             $managedProjList = 0 == count($managedTeamList) ? array() : $user->getProjectList($managedTeamList);
             $oTeamList = $user->getObservedTeamList();
             $observedProjList = 0 == count($oTeamList) ? array() : $user->getProjectList($oTeamList);
             $projList = $devProjList + $managedProjList + $observedProjList;
             if (isset($_GET['projectid'])) {
                 $projectid = Tools::getSecureGETIntValue('projectid');
                 $_SESSION['projectid'] = $projectid;
             } else {
                 if (isset($_SESSION['projectid'])) {
                     $projectid = $_SESSION['projectid'];
                 } else {
                     $projectsid = array_keys($projList);
                     $projectid = $projectsid[0];
                 }
             }
             // get selected filters
             if (isset($_GET['selectedFilters']) && NULL != $_GET['selectedFilters']) {
                 $selectedFilters = Tools::getSecureGETStringValue('selectedFilters');
                 #echo "last = ".$selectedFilters[strlen($selectedFilters)-1];
                 if (',' == $selectedFilters[strlen($selectedFilters) - 1]) {
                     $selectedFilters = substr($selectedFilters, 0, -1);
                     // last char is a ','
                 }
                 $filterList = explode(',', $selectedFilters);
             } else {
                 $selectedFilters = "";
                 $filterList = array();
             }
             $this->smartyHelper->assign('projects', SmartyTools::getSmartyArray($projList, $projectid));
             $project = ProjectCache::getInstance()->getProject($projectid);
             // ----
             $availFilterList = array("ProjectVersionFilter" => "Project Version", "ProjectCategoryFilter" => "Project Category", "IssueExtIdFilter" => "Issue External ID", "IssuePublicPrivateFilter" => "Issue Public / Private", "IssueTagFilter" => "Issue Tags");
             $selectedFilterList = array();
             foreach ($filterList as $id) {
                 $selectedFilterList[$id] = $availFilterList[$id];
                 unset($availFilterList[$id]);
             }
             // do the work ...
             $projectIssueSel = $project->getIssueSelection();
             $filterMgr = new FilterManager($projectIssueSel, $filterList);
             $resultList = $filterMgr->execute();
             $issueSelList = $filterMgr->explodeResults($resultList);
             $smatyObj = $this->getDetailedMgr($issueSelList, $filterList);
             $totalLine = array_shift($smatyObj);
             // first line is rootElem (TOTAL)
             $titleLine = array_pop($smatyObj);
             // last line is the table titles
             $this->smartyHelper->assign('availFilterList', $availFilterList);
             $this->smartyHelper->assign('selectedFilterList', $selectedFilterList);
             $this->smartyHelper->assign('selectedFilters', $selectedFilters);
             $this->smartyHelper->assign('nbFilters', count($filterList));
             $this->smartyHelper->assign('filterResultsTitles', $titleLine);
             $this->smartyHelper->assign('filterResults', $smatyObj);
             $this->smartyHelper->assign('filterResultsTotal', $totalLine);
         }
     }
 }
Esempio n. 19
0
 /**
  * creates for each project a table with the following fields:
  * TaskName | RAF | <Jobs>
  * @param TimeTracking $timeTracking
  * @param string $myFile
  * @return string
  */
 private function exportProjectActivityToCSV(TimeTracking $timeTracking, $myFile)
 {
     $sepChar = ';';
     $team = TeamCache::getInstance()->getTeam($timeTracking->getTeamid());
     if (!is_dir(Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports')) {
         mkdir(Constants::$codevOutputDir . DIRECTORY_SEPARATOR . 'reports', 0755);
     }
     $fh = fopen($myFile, 'w');
     // $projectTracks[projectid][bugid][jobid] = duration
     $projectTracks = $timeTracking->getProjectTracks();
     foreach ($projectTracks as $projectId => $bugList) {
         // write table header
         $project = ProjectCache::getInstance()->getProject($projectId);
         $stringData = $project->getName() . "\n";
         $stringData .= T_("Task") . $sepChar;
         $stringData .= T_("BL") . $sepChar;
         $jobList = $project->getJobList($team->getProjectType($projectId));
         foreach ($jobList as $jobName) {
             $stringData .= $jobName . $sepChar;
         }
         $stringData .= "\n";
         // write table content (by bugid)
         foreach ($bugList as $bugid => $jobs) {
             $issue = IssueCache::getInstance()->getIssue($bugid);
             // remove sepChar from summary text
             $formatedSummary = str_replace($sepChar, " ", $issue->getSummary());
             $stringData .= "{$bugid} / " . $issue->getTcId() . " : " . $formatedSummary . $sepChar;
             $stringData .= $issue->getBacklog() . $sepChar;
             foreach ($jobList as $jobId => $jobName) {
                 $stringData .= $jobs[$jobId] . $sepChar;
             }
             $stringData .= "\n";
         }
         $stringData .= "\n";
         fwrite($fh, $stringData);
     }
     fclose($fh);
     return $myFile;
 }
Esempio n. 20
0
 /**
  * returns an array of Project class instances
  *
  * @param bool $noStatsProject
  * @return Project[]
  */
 public function getTrueProjects($noStatsProject = true, $withDisabled = true)
 {
     if (NULL == $this->projectIdsCache) {
         $this->projectIdsCache = array();
     }
     $key = '' . $noStatsProject;
     if (!array_key_exists($key, $this->projectIdsCache)) {
         $query = "SELECT project.* " . "FROM `mantis_project_table` as project " . "JOIN `codev_team_project_table` as team_project ON project.id = team_project.project_id " . "WHERE team_project.team_id = {$this->id} ";
         if (!$noStatsProject) {
             $query .= "AND team_project.type <> " . Project::type_noStatsProject . " ";
         }
         if (!$withDisabled) {
             $query .= "AND project.enabled = 1 ";
         }
         $query .= "ORDER BY project.name;";
         $result = SqlWrapper::getInstance()->sql_query($query);
         if (!$result) {
             echo "<span style='color:red'>ERROR: Query FAILED</span>";
             exit;
         }
         $projList = array();
         while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
             ProjectCache::getInstance()->getProject($row->id, $row);
             $projList[$row->id] = $row->name;
         }
         $this->projectIdsCache[$key] = $projList;
     }
     $projects = array();
     foreach ($this->projectIdsCache[$key] as $id => $name) {
         $projects[] = ProjectCache::getInstance()->getProject($id);
     }
     return $projects;
 }
Esempio n. 21
0
 /**
  * @param TimeTracking $timeTracking
  * @param bool $isDetailed
  * @param int[] $weekDates
  * @return mixed[]
  */
 private function getWeekDetails(TimeTracking $timeTracking, $isDetailed, $weekDates, $session_userid)
 {
     $team = TeamCache::getInstance()->getTeam($timeTracking->getTeamid());
     $weekDetails = array();
     $session_users = $team->getUsers();
     foreach ($session_users as $session_user) {
         // if user was working on the project during the timestamp
         if ($session_user->isTeamDeveloper($timeTracking->getTeamid(), $timeTracking->getStartTimestamp(), $timeTracking->getEndTimestamp()) || $session_user->isTeamManager($timeTracking->getTeamid(), $timeTracking->getStartTimestamp(), $timeTracking->getEndTimestamp())) {
             // PERIOD week
             //$thisWeekId=date("W");
             $weekTracks = $timeTracking->getWeekDetails($session_user->getId(), !$isDetailed);
             $holidays = Holidays::getInstance();
             $weekJobDetails = array();
             foreach ($weekTracks as $bugid => $jobList) {
                 try {
                     $issue = IssueCache::getInstance()->getIssue($bugid);
                 } catch (Exception $e) {
                     self::$logger->error("getWeekDetails() skip issue {$bugid} : " . $e->getMessage());
                     $weekJobDetails[] = array("description" => '<span class="error_font">' . $bugid . ' : ' . T_('Error: Task not found in Mantis DB !') . '</span>', "duration" => "!", "progress" => "!", "projectName" => "!", "targetVersion" => "!", "jobName" => "!", "daysDetails" => "!", "totalDuration" => "!");
                     continue;
                 }
                 $project = ProjectCache::getInstance()->getProject($issue->getProjectId());
                 if ($isDetailed) {
                     $formatedJobList = implode(', ', array_keys($jobList));
                     $query = 'SELECT id, name FROM `codev_job_table` WHERE id IN (' . $formatedJobList . ');';
                     $result2 = SqlWrapper::getInstance()->sql_query($query);
                     if (!$result2) {
                         continue;
                     }
                     while ($row2 = SqlWrapper::getInstance()->sql_fetch_object($result2)) {
                         $jobName = $row2->name;
                         $dayList = $jobList[$row2->id];
                         $daysDetails = array();
                         $weekDuration = 0;
                         for ($i = 1; $i <= 7; $i++) {
                             $dayDetails = $this->getDaysDetails($i, $holidays, $weekDates, $dayList[$i]);
                             $weekDuration += $dayDetails['duration'];
                             $daysDetails[] = $dayDetails;
                         }
                         if (!$project->isSideTasksProject(array($team->getId())) && !$project->isExternalTasksProject()) {
                             $tooltipAttr = $issue->getTooltipItems($team->getId(), $session_userid);
                             // force some fields
                             #$tooltipAttr[T_('Elapsed')] = $issue->getElapsed();
                             #$tooltipAttr[T_('Backlog')] = $issue->getDuration();
                             #$tooltipAttr[T_('Drift')] = $issue->getDrift();
                             #$tooltipAttr[T_('DriftColor')] = $issue->getDriftColor();
                             $infoTooltip = Tools::imgWithTooltip('images/b_info.png', $tooltipAttr);
                         } else {
                             $infoTooltip = NULL;
                         }
                         // prepare json data for the IssueNoteDialogbox
                         $issueNoteData = $this->getIssueNoteTooltip($project, $team, $issue);
                         $weekJobDetails[] = array('description' => SmartyTools::getIssueDescription($bugid, $issue->getTcId(), $issue->getSummary()), 'duration' => $issue->getDuration(), 'progress' => round(100 * $issue->getProgress()), 'projectName' => $issue->getProjectName(), 'targetVersion' => $issue->getTargetVersion(), 'jobName' => $jobName, 'daysDetails' => $daysDetails, 'totalDuration' => $weekDuration, 'infoTooltip' => $infoTooltip, 'issueNoteId' => $issueNoteData['id'], 'noteTooltip' => $issueNoteData['tooltip']);
                     }
                 } else {
                     // for each day, concat jobs duration
                     $daysDetails = array();
                     $weekDuration = 0;
                     for ($i = 1; $i <= 7; $i++) {
                         $duration = 0;
                         foreach ($jobList as $dayList) {
                             if (array_key_exists($i, $dayList)) {
                                 $duration += $dayList[$i];
                             }
                         }
                         if ($duration == 0) {
                             $duration = "";
                         }
                         $dayDetails = $this->getDaysDetails($i, $holidays, $weekDates, $duration);
                         $weekDuration += $dayDetails['duration'];
                         $daysDetails[] = $dayDetails;
                     }
                     if (!$project->isSideTasksProject(array($team->getId())) && !$project->isExternalTasksProject()) {
                         $tooltipAttr = $issue->getTooltipItems($team->getId(), $session_userid);
                         // force some fields
                         #$tooltipAttr[T_('Elapsed')] = $issue->getElapsed();
                         #$tooltipAttr[T_('Backlog')] = $issue->getDuration();
                         #$tooltipAttr[T_('Drift')] = $issue->getDrift();
                         #$tooltipAttr[T_('DriftColor')] = $issue->getDriftColor();
                         $infoTooltip = Tools::imgWithTooltip('images/b_info.png', $tooltipAttr);
                     } else {
                         $infoTooltip = NULL;
                     }
                     // prepare json data for the IssueNoteDialogbox
                     $issueNoteData = $this->getIssueNoteTooltip($project, $team, $issue);
                     $weekJobDetails[] = array('description' => SmartyTools::getIssueDescription($bugid, $issue->getTcId(), $issue->getSummary()), 'duration' => $issue->getDuration(), 'progress' => round(100 * $issue->getProgress()), 'projectName' => $issue->getProjectName(), 'daysDetails' => $daysDetails, 'totalDuration' => $weekDuration, 'infoTooltip' => $infoTooltip, 'issueNoteId' => $issueNoteData['id'], 'noteTooltip' => $issueNoteData['tooltip']);
                 }
             }
             if (!empty($weekJobDetails)) {
                 $weekDetails[] = array('name' => $session_user->getName(), 'realname' => $session_user->getRealname(), 'forecastWorkload' => $session_user->getForecastWorkload(), 'weekDates' => array(Tools::formatDate("%A\n%d %b", $weekDates[1]), Tools::formatDate("%A\n%d %b", $weekDates[2]), Tools::formatDate("%A\n%d %b", $weekDates[3]), Tools::formatDate("%A\n%d %b", $weekDates[4]), Tools::formatDate("%A\n%d %b", $weekDates[5])), 'weekEndDates' => array(Tools::formatDate("%A\n%d %b", $weekDates[6]), Tools::formatDate("%A\n%d %b", $weekDates[7])), 'weekJobDetails' => $weekJobDetails);
             }
         }
     }
     return $weekDetails;
 }
Esempio n. 22
0
 /**
  * @param int $projectid
  * @return string[]
  */
 private function getProjectTargetVersion($projectid)
 {
     $versions = array();
     if (0 != $projectid) {
         $prj = ProjectCache::getInstance()->getProject($projectid);
         $versions = $prj->getProjectVersions();
     }
     return $versions;
 }
Esempio n. 23
0
     $availableIssues = TimeTrackingTools::getIssues($teamid, $defaultProjectid, $isOnlyAssignedTo, $managedUserid, $projList, $isHideResolved, 0);
     $jobs = TimeTrackingTools::getJobs($defaultProjectid, $teamid);
     $durations = TimeTrackingTools::getDurationList($teamid);
     // return data
     $data = array('availableIssues' => $availableIssues, 'availableJobs' => $jobs, 'availableDurations' => $durations);
     $jsonData = json_encode($data);
     // return data
     echo $jsonData;
 } elseif ($action == 'getUpdateBacklogData') {
     // get info to display the updateBacklog dialogbox
     // (when clicking on the backlog value in WeekTaskDetails)
     // OR clicking the addTrack button in addTrack form (form1)
     $bugid = Tools::getSecurePOSTIntValue('bugid');
     $job = Tools::getSecurePOSTIntValue('trackJobid', 0);
     $issue = IssueCache::getInstance()->getIssue($bugid);
     $project = ProjectCache::getInstance()->getProject($issue->getProjectId());
     if ($job == Jobs::JOB_SUPPORT || ($project->isSideTasksProject(array($teamid)) || $project->isExternalTasksProject())) {
         // no backlog update for this task
         $data = array('diagnostic' => 'BacklogUpdateNotNeeded');
         $updateBacklogJsonData = json_encode($data);
     } else {
         $managedUserid = Tools::getSecurePOSTIntValue('userid', 0);
         $trackDuration = Tools::getSecurePOSTNumberValue('trackDuration', 0);
         $trackDate = Tools::getSecurePOSTStringValue('trackDate', 0);
         $updateBacklogJsonData = TimeTrackingTools::getUpdateBacklogJsonData($bugid, $job, $teamid, $managedUserid, $trackDate, $trackDuration);
     }
     // return data
     echo $updateBacklogJsonData;
 } else {
     if ($action == 'updateBacklog') {
         // updateBacklogDoalogbox with 'updateBacklog' action
Esempio n. 24
0
/**
 * get all existing projects, except ExternalTasksProject & SideTasksProjects
 * @return string[] : name[id]
 */
function getProjectList()
{
    global $logger;
    $projects = Project::getProjects();
    if ($projects != NULL) {
        $extproj_id = Config::getInstance()->getValue(Config::id_externalTasksProject);
        $smartyProjects = array();
        foreach ($projects as $id => $name) {
            // exclude ExternalTasksProject
            if ($extproj_id == $id) {
                echo "<script type=\"text/javascript\">console.log(\"   getProjectList - project {$id}: ExternalTasksProject is excluded\");</script>";
                continue;
            }
            // exclude SideTasksProjects
            try {
                $p = ProjectCache::getInstance()->getProject($id);
                if ($p->isSideTasksProject()) {
                    echo "<script type=\"text/javascript\">console.log(\"   getProjectList - project {$id}: sideTaskProjects are excluded\");</script>";
                    continue;
                }
            } catch (Exception $e) {
                // could not determinate, so the project should be included in the list
                echo "<script type=\"text/javascript\">console.log(\"   getProjectList - project {$id}: Unknown type, project included anyway\");</script>";
                // nothing to do.
            }
            $smartyProjects[$id] = $name;
        }
        return $smartyProjects;
    } else {
        return NULL;
    }
}
Esempio n. 25
0
 protected function display()
 {
     $this->smartyHelper->assign('activeGlobalMenuItem', 'Admin');
     if (Tools::isConnectedUser()) {
         if (!$this->session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
             $this->smartyHelper->assign('accessDenied', TRUE);
         } else {
             if (isset($_POST['team_name'])) {
                 // Form user selections
                 $team_name = Tools::getSecurePOSTStringValue('team_name');
                 $team_desc = Tools::getSecurePOSTStringValue('team_desc', '');
                 $teamleader_id = Tools::getSecurePOSTStringValue('teamleader_id');
                 $formatedDate = date("Y-m-d", time());
                 $now = Tools::date2timestamp($formatedDate);
                 // 1) --- create new Team
                 $teamid = Team::create($team_name, $team_desc, $teamleader_id, $now);
                 if ($teamid > 0) {
                     $team = TeamCache::getInstance()->getTeam($teamid);
                     // --- add teamLeader as 'manager'
                     $team->addMember($teamleader_id, $now, Team::accessLevel_manager);
                     // 2) --- add ExternalTasksProject
                     $team->addExternalTasksProject();
                     $stproj_name = Tools::getSecurePOSTStringValue("stproj_name");
                     if (isset($_POST['cb_createSideTaskProj'])) {
                         // 3) --- add <team> SideTaskProject
                         $stproj_id = $team->createSideTaskProject($stproj_name);
                         if ($stproj_id < 0) {
                             self::$logger->error("SideTaskProject creation FAILED");
                             echo "<span style='color:red'>ERROR: SideTaskProject creation FAILED</span>";
                             exit;
                         } else {
                             $stproj = ProjectCache::getInstance()->getProject($stproj_id);
                             // --- add teamLeader as Mantis manager of the SideTaskProject
                             $leader = UserCache::getInstance()->getUser($teamleader_id);
                             $access_level = 70;
                             // TODO mantis manager
                             $leader->setProjectAccessLevel($stproj_id, $access_level);
                             // 4) --- add SideTaskProject Categories
                             $stproj->addCategoryProjManagement(T_("Project Management"));
                             if (isset($_POST['cb_catInactivity'])) {
                                 $stproj->addCategoryInactivity(T_("Inactivity"));
                             }
                             if (isset($_POST['cb_catIncident'])) {
                                 $stproj->addCategoryIncident(T_("Incident"));
                             }
                             if (isset($_POST['cb_catTools'])) {
                                 $stproj->addCategoryTools(T_("Tools"));
                             }
                             if (isset($_POST['cb_catOther'])) {
                                 $stproj->addCategoryWorkshop(T_("Team Workshop"));
                             }
                             // 5) --- add SideTaskProject default SideTasks
                             if (isset($_POST['cb_taskProjManagement'])) {
                                 $stproj->addIssueProjManagement(Tools::getSecurePOSTStringValue('task_projManagement'));
                             }
                             if (isset($_POST['cb_taskMeeting'])) {
                                 $stproj->addIssueProjManagement(Tools::getSecurePOSTStringValue('task_meeting'));
                             }
                             if (isset($_POST['cb_taskIncident'])) {
                                 $stproj->addIssueIncident(Tools::getSecurePOSTStringValue('task_incident'));
                             }
                             if (isset($_POST['cb_taskTools'])) {
                                 $stproj->addIssueTools(Tools::getSecurePOSTStringValue('task_tools'));
                             }
                             if (isset($_POST['cb_taskOther'])) {
                                 $stproj->addIssueWorkshop(Tools::getSecurePOSTStringValue('task_other1'));
                             }
                         }
                     }
                 }
                 // 6) --- open EditTeam Page
                 header('Location: edit_team.php?teamid=' . $teamid);
             } else {
                 $this->smartyHelper->assign('users', SmartyTools::getSmartyArray(User::getUsers(), $this->session_userid));
             }
         }
     }
 }
Esempio n. 26
0
 protected function display()
 {
     if (Tools::isConnectedUser()) {
         // only teamMembers & observers can access this page
         if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) {
             $this->smartyHelper->assign('accessDenied', TRUE);
         } else {
             $tmpTeamList = array($this->teamid => $this->teamList[$this->teamid]);
             $projList = $this->session_user->getProjectList($tmpTeamList, true, false);
             if (isset($_GET['projectid'])) {
                 $projectid = Tools::getSecureGETIntValue('projectid');
                 $_SESSION['projectid'] = $projectid;
             } else {
                 if (isset($_SESSION['projectid'])) {
                     $projectid = $_SESSION['projectid'];
                 } else {
                     $projectsid = array_keys($projList);
                     $projectid = $projectsid[0];
                 }
             }
             $this->smartyHelper->assign('projects', SmartyTools::getSmartyArray($projList, $projectid));
             // if display project allowed
             if (in_array($projectid, array_keys($projList))) {
                 $this->smartyHelper->assign('projectid', $projectid);
                 // Managers can see detailed view
                 $isManager = $this->session_user->isTeamManager($this->teamid);
                 $isObserver = $this->session_user->isTeamObserver($this->teamid);
                 $this->smartyHelper->assign("isManager", $isManager || $isObserver);
                 $project = ProjectCache::getInstance()->getProject($projectid);
                 $projectIssueSel = $project->getIssueSelection();
                 // --- FILTER TABS -------------
                 // get selected filters
                 if (isset($_GET['selectedFilters'])) {
                     $selectedFilters = Tools::getSecureGETStringValue('selectedFilters');
                 } else {
                     $selectedFilters = $this->session_user->getProjectFilters($projectid);
                 }
                 // cleanup filters (remove empty lines)
                 $filterList = explode(',', $selectedFilters);
                 $filterList = array_filter($filterList, create_function('$a', 'return $a!="";'));
                 $selectedFilters = implode(',', $filterList);
                 // save user preferances
                 $this->session_user->setProjectFilters($selectedFilters, $projectid);
                 // TODO: get allFilters from config.ini
                 $data = ProjectInfoTools::getDetailedCharges($projectid, $isManager || $isObserver, $selectedFilters);
                 foreach ($data as $smartyKey => $smartyVariable) {
                     $this->smartyHelper->assign($smartyKey, $smartyVariable);
                 }
                 // --- DRIFT TABS -------------------
                 $currentIssuesInDrift = NULL;
                 $resolvedIssuesInDrift = NULL;
                 foreach ($projectIssueSel->getIssuesInDrift($isManager || $isObserver) as $issue) {
                     $smartyIssue = $this->getSmartyDirftedIssue($issue, $isManager || $isObserver);
                     if (NULL != $smartyIssue) {
                         if ($issue->isResolved()) {
                             $resolvedIssuesInDrift[] = $smartyIssue;
                         } else {
                             $currentIssuesInDrift[] = $smartyIssue;
                         }
                     }
                 }
                 $this->smartyHelper->assign("currentIssuesInDrift", $currentIssuesInDrift);
                 $this->smartyHelper->assign("resolvedIssuesInDrift", $resolvedIssuesInDrift);
                 // indicator_plugins (old style plugins - deprecated)
                 $this->smartyHelper->assign('detailedChargesIndicatorFile', DetailedChargesIndicator::getSmartyFilename());
                 // Dashboard
                 ProjectInfoTools::dashboardSettings($this->smartyHelper, $project, $this->session_userid, $this->teamid);
             }
         }
     }
 }
Esempio n. 27
0
 /**
  * Check issues that are not referenced in a Command (error)
  * Check issues referenced in more than one Command (warning)
  *
  * Note: SideTasks not checked (they are directly added into the ServiceContract)
  *
  *  @return ConsistencyError2[]
  */
 public function checkIssuesNotInCommand()
 {
     $cerrList = array();
     if (count($this->issueList) > 0) {
         $query = "SELECT bug_id, COUNT(command_id) as count FROM `codev_command_bug_table` WHERE bug_id IN (" . $this->formattedBugidList . ") GROUP BY bug_id;";
         $result = SqlWrapper::getInstance()->sql_query($query);
         if (!$result) {
             echo "<span style='color:red'>ERROR: Query FAILED</span>";
             exit;
         }
         $commandsByIssue = array();
         while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
             $commandsByIssue[$row->bug_id] = $row->count;
         }
         foreach ($this->issueList as $issue) {
             $project = ProjectCache::getInstance()->getProject($issue->getProjectId());
             $teamList = NULL == $this->teamId ? NULL : array($this->teamId);
             try {
                 if ($project->isSideTasksProject($teamList) || $project->isNoStatsProject($teamList)) {
                     // exclude SideTasks: they are not referenced in a command,
                     // they are directly added into the ServiceContract
                     continue;
                 }
             } catch (Exception $e) {
                 self::$logger->error("checkIssuesNotInCommand(): issue " . $issue->getId() . " not checked : " . $e->getMessage());
                 continue;
             }
             $nbTuples = 0;
             if (array_key_exists($issue->getId(), $commandsByIssue)) {
                 $nbTuples = $commandsByIssue[$issue->getId()];
             }
             if (0 == $nbTuples) {
                 $cerr = new ConsistencyError2($issue->getId(), $issue->getHandlerId(), $issue->getCurrentStatus(), $issue->getLastUpdate(), T_("The task is not referenced in any Command."));
                 $cerr->severity = ConsistencyError2::severity_warn;
                 $cerrList[] = $cerr;
             } else {
                 if ($nbTuples > 1) {
                     // a task referenced in 2 Commands is not error if in two != teams
                     $query = "SELECT team_id FROM `codev_command_table`, `codev_command_bug_table` " . "WHERE codev_command_table.id = codev_command_bug_table.command_id " . "AND codev_command_bug_table.bug_id = " . $issue->getId() . ";";
                     $result = SqlWrapper::getInstance()->sql_query($query);
                     if (!$result) {
                         echo "<span style='color:red'>ERROR: Query FAILED</span>";
                         exit;
                     }
                     $tmpTeamId = 0;
                     while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
                         if (0 == $tmpTeamId) {
                             $tmpTeamId = $row->team_id;
                         } else {
                             if ($tmpTeamId == $row->team_id) {
                                 # issue in 2 commands of the same team is a warning
                                 $cerr = new ConsistencyError2($issue->getId(), $issue->getHandlerId(), $issue->getCurrentStatus(), $issue->getLastUpdate(), T_("The task is referenced in {$nbTuples} Commands."));
                                 $cerr->severity = ConsistencyError2::severity_warn;
                                 $cerrList[] = $cerr;
                                 break;
                             }
                         }
                     }
                 }
             }
             if (self::$logger->isDebugEnabled()) {
                 self::$logger->debug("checkIssuesNotInCommand(): issue " . $issue->getId() . " referenced in {$nbTuples} Commands.");
             }
         }
     }
     return $cerrList;
 }
Esempio n. 28
0
 function displayProjectsToRemove()
 {
     $prjList = array();
     // find externalTasks project
     $extproj_id = Config::getInstance()->getValue(Config::id_externalTasksProject);
     $project = ProjectCache::getInstance()->getProject($extproj_id);
     $prjList[$extproj_id] = $project->getName();
     // find sideTasks projects
     $sideTaskProj_id = Project::type_sideTaskProject;
     $query = "SELECT project.id, project.name " . "FROM `mantis_project_table` as project " . "JOIN `codev_team_project_table` as team_project ON project.id = team_project.project_id " . "WHERE team_project.type = {$sideTaskProj_id} " . "ORDER BY project.name DESC;";
     $result = SqlWrapper::getInstance()->sql_query($query);
     if (!$result) {
         return NULL;
     }
     while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
         $prjList[$row->id] = $row->name;
     }
     return $prjList;
 }
Esempio n. 29
0
 /**
  *
  * @param IssueSelection $iSel
  * @param type $projectid
  * @param type $odtTemplate
  * @return string filepath complete path to generated ODT file
  */
 private function generateODT(IssueSelection $iSel, $projectid, $odtTemplate)
 {
     self::$logger->debug("genProjectODT(): project {$projectid} template {$odtTemplate}");
     $project = ProjectCache::getInstance()->getProject($projectid);
     $odf = new odf($odtTemplate);
     try {
         $odf->setVars('today', date('Y-m-d'));
     } catch (Exception $e) {
     }
     try {
         $odf->setVars('selectionName', $project->getName());
     } catch (Exception $e) {
     }
     try {
         $session_user = UserCache::getInstance()->getUser($this->session_userid);
         $odf->setVars('sessionUser', $session_user->getRealname());
     } catch (Exception $e) {
     }
     $issueList = $iSel->getIssueList();
     if (self::$logger->isDebugEnabled()) {
         self::$logger->debug("nb issues = " . count($issueList));
     }
     $q_id = 0;
     try {
         $issueSegment = $odf->setSegment('issueSelection');
     } catch (Exception $e) {
         self::$logger->error("generateODT: TAG 'issueSelection'");
         self::$logger->error("generateODT: " + $e->getMessage());
         return "FAILED: error on segment 'issueSelection'.";
     }
     if (self::$logger->isDebugEnabled()) {
         self::$logger->debug('XML=' . $issueSegment->getXml());
     }
     foreach ($issueList as $issue) {
         $q_id += 1;
         if (0 == $issue->getHandlerId()) {
             $userName = T_('unknown');
         } else {
             $user = UserCache::getInstance()->getUser($issue->getHandlerId());
             $userName = utf8_decode($user->getRealname());
             if (empty($userName)) {
                 $userName = "******" . $issue->getHandlerId();
             }
         }
         if (self::$logger->isDebugEnabled()) {
             self::$logger->debug("issue " . $issue->getId() . ": handlerName = " . $userName);
         }
         if (0 == $issue->getReporterId()) {
             $reporterName = T_('unknown');
         } else {
             $reporter = UserCache::getInstance()->getUser($issue->getReporterId());
             $reporterName = utf8_decode($reporter->getRealname());
             if (empty($reporterName)) {
                 $reporterName = "user_" . $issue->getReporterId();
             }
         }
         if (self::$logger->isDebugEnabled()) {
             self::$logger->debug("issue " . $issue->getId() . ": reporterName = " . $reporterName);
         }
         // add issue
         try {
             $issueSegment->setVars('q_id', $q_id);
         } catch (Exception $e) {
         }
         try {
             $issueSegment->setVars('bugId', $issue->getId());
         } catch (Exception $e) {
             $this->logException($e);
         }
         try {
             $issueSegment->setVars('summary', utf8_decode($issue->getSummary()));
         } catch (Exception $e) {
             $this->logException($e);
         }
         try {
             $issueSegment->setVars('dateSubmission', date('d/m/Y', $issue->getDateSubmission()));
         } catch (Exception $e) {
         }
         try {
             $timestamp = $issue->getLatestStatusOccurrence($issue->getBugResolvedStatusThreshold());
             if (is_null($timestamp)) {
                 $issueSegment->setVars('dateResolved', '');
             } else {
                 $issueSegment->setVars('dateResolved', date('d/m/Y', $timestamp));
             }
         } catch (Exception $e) {
         }
         try {
             $timestamp = $issue->getDeadLine();
             $deadline = 0 == $timestamp ? '' : date('d/m/Y', $issue->getDeadLine());
             $issueSegment->setVars('deadline', $deadline);
         } catch (Exception $e) {
             $this->logException($e);
         }
         try {
             $issueSegment->setVars('currentStatus', Constants::$statusNames[$issue->getCurrentStatus()]);
         } catch (Exception $e) {
         }
         try {
             $issueSegment->setVars('handlerId', $userName);
         } catch (Exception $e) {
         }
         try {
             $issueSegment->setVars('reporterId', $reporterName);
         } catch (Exception $e) {
         }
         try {
             $issueSegment->setVars('reporterName', $reporterName);
         } catch (Exception $e) {
         }
         try {
             $issueSegment->setVars('description', utf8_decode($issue->getDescription()));
         } catch (Exception $e) {
         }
         #try { $issueSegment->setVars('description', utf8_decode(Tools::convertToUTF8($issue->getDescription()))); } catch (Exception $e) { };
         try {
             $issueSegment->setVars('category', $issue->getCategoryName());
         } catch (Exception $e) {
         }
         try {
             $issueSegment->setVars('severity', $issue->getSeverityName());
         } catch (Exception $e) {
         }
         try {
             $issueSegment->setVars('status', Constants::$statusNames[$issue->getStatus()]);
         } catch (Exception $e) {
         }
         try {
             $issueSegment->setVars('extId', $issue->getTcId());
         } catch (Exception $e) {
         }
         // add issueNotes
         $issueNotes = $issue->getIssueNoteList();
         $noteId = 0;
         foreach ($issueNotes as $id => $issueNote) {
             $noteId += 1;
             if (self::$logger->isDebugEnabled()) {
                 self::$logger->debug("issue " . $issue->getId() . ": note {$id} = " . $issueNote->getNote());
             }
             $noteReporter = UserCache::getInstance()->getUser($issueNote->getReporterId());
             try {
                 $noteReporterName = utf8_decode($noteReporter->getRealname());
             } catch (Exception $e) {
             }
             try {
                 $issueSegment->bugnotes->noteId($noteId);
             } catch (Exception $e) {
             }
             try {
                 $issueSegment->bugnotes->noteReporter($noteReporterName);
             } catch (Exception $e) {
             }
             try {
                 $issueSegment->bugnotes->noteDateSubmission(date('d/m/Y', $issueNote->getDateSubmitted()));
             } catch (Exception $e) {
             }
             try {
                 $issueSegment->bugnotes->note(utf8_decode($issueNote->getNote()));
             } catch (Exception $e) {
             }
             try {
                 $issueSegment->bugnotes->merge();
             } catch (Exception $e) {
             }
         }
         $issueSegment->merge();
     }
     $odf->mergeSegment($issueSegment);
     // INFO: the following line is MANDATORY and fixes the following error:
     // "wrong .odt file encoding"
     #ob_end_clean();
     #$odf->exportAsAttachedFile();
     // 2nd solution : show link in page
     $odtFilename = basename($odtTemplate, ".odt") . '_' . $project->getName() . '_' . date('Ymd') . '.odt';
     $filepath = Constants::$codevOutputDir . '/reports/' . $odtFilename;
     if (self::$logger->isDebugEnabled()) {
         self::$logger->debug("save odt file " . $filepath);
     }
     $odf->saveToDisk($filepath);
     return $filepath;
 }
Esempio n. 30
0
 /**
  * depending on project's WorkflowTransistions and current status,
  * return a list of allowed status.
  *  
  */
 function getAvailableStatusList($includeCurrentStatus = false)
 {
     $project = ProjectCache::getInstance()->getProject($this->projectId);
     $wfTrans = $project->getWorkflowTransitions();
     $serialized = $wfTrans[$this->currentStatus];
     $unserialized = Tools::doubleExplode(':', ',', $serialized);
     if ($includeCurrentStatus) {
         $unserialized[$this->currentStatus] = $this->getCurrentStatusName();
         ksort($unserialized);
     }
     #echo "available Status = $serialized<br>";
     return $unserialized;
 }