Esempio n. 1
0
                        $issueNoteText = trim(IssueNote::removeAllReadByTags($issueNote->getText()));
                    } else {
                        $issueNoteId = 0;
                        $issueNoteText = '';
                    }
                    // return data
                    $data = array('bugid' => $bugid, 'issuenoteid' => $issueNoteId, 'issuenote_text' => $issueNoteText);
                    $jsonData = json_encode($data);
                    // return data
                    echo $jsonData;
                } else {
                    if ($action == 'saveIssueNote') {
                        $bugid = Tools::getSecurePOSTIntValue('bugid');
                        $reporter_id = $session_user;
                        $issueNoteText = filter_input(INPUT_POST, 'issuenote_text');
                        IssueNote::setTimesheetNote($bugid, $issueNoteText, $reporter_id);
                        // return data
                        // the complete WeekTaskDetails Div must be updated
                        $weekid = Tools::getSecurePOSTIntValue('weekid');
                        $year = Tools::getSecurePOSTIntValue('year');
                        $userid = Tools::getSecurePOSTIntValue('userid', $session_user);
                        setWeekTaskDetails($smartyHelper, $weekid, $year, $userid, $teamid);
                        $smartyHelper->display('ajax/weekTaskDetails');
                    }
                }
            }
        }
    }
} else {
    Tools::sendUnauthorizedAccess();
}
Esempio n. 2
0
                $userid = $_SESSION['userid'];
                $issueNote->markAsRead($userid);
                $data = 'OK';
            } else {
                $data = 'ERROR';
                // TODO return ERROR
                Tools::sendBadRequest("Could not mark as read.");
            }
            // return data
            echo $data;
        } else {
            if ($_POST['action'] == 'deleteNote') {
                $userid = $_SESSION['userid'];
                $bugid = Tools::getSecurePOSTIntValue('bugid');
                $bugnoteid = Tools::getSecurePOSTIntValue('bugnote_id');
                $retCode = IssueNote::delete($bugnoteid, $bugid, $userid);
                if ($retCode) {
                    $data = 'OK';
                } else {
                    $data = 'ERROR';
                    // TODO return ERROR
                    Tools::sendBadRequest("Could not delete note.");
                }
                // return data
                echo $data;
            }
        }
    }
} else {
    Tools::sendUnauthorizedAccess();
}
Esempio n. 3
0
 /**
  * Initialize complex static variables
  * @static
  */
 public static function staticInit()
 {
     self::$logger = Logger::getLogger(__CLASS__);
 }
Esempio n. 4
0
 private function getIssueNoteTooltip($project, $team, $issue)
 {
     // prepare json data for the IssueNoteDialogbox
     if (!$project->isSideTasksProject(array($team->getId())) && !$project->isExternalTasksProject()) {
         $issueNote = IssueNote::getTimesheetNote($issue->getId());
         if (!is_null($issueNote)) {
             $issueNoteId = $issueNote->getId();
             $user = UserCache::getInstance()->getUser($issueNote->getReporterId());
             $rawNote = $issueNote->getText();
             $note = trim(IssueNote::removeAllReadByTags($rawNote));
             // used for the tooltip NOT the dialoBox
             $tooltipAttr = array('reporter' => $user->getRealname(), 'date' => date('Y-m-d H:i', $issueNote->getLastModified()), 'Note' => $note);
             $readByList = $issueNote->getReadByList(TRUE);
             if (0 != count($readByList)) {
                 $tooltipAttr['Read by'] = implode(', ', array_keys($readByList));
             }
             $noteTooltip = Tools::imgWithTooltip('images/b_note.png', $tooltipAttr, "bugNote_" . $issueNote->getBugId());
         } else {
             $issueNoteId = 0;
             $noteTooltip = '';
         }
     } else {
         $issueNoteId = 0;
         $noteTooltip = '';
     }
     return array('id' => $issueNoteId, 'tooltip' => $noteTooltip);
 }
Esempio n. 5
0
 /**
  * @param int[] $weekDates
  * @param int $userid
  * @param TimeTracking $timeTracking
  * @param array $incompleteDays
  * @return mixed[]
  */
 public static function getWeekTask(array $weekDates, $teamid, $userid, TimeTracking $timeTracking, array $incompleteDays)
 {
     $totalElapsed = array();
     $todayAtMidnight = mktime(0, 0, 0);
     for ($i = 1; $i <= 7; $i++) {
         $weekDate = $weekDates[$i];
         $totalElapsed[$weekDate] = array("elapsed" => 0, "class" => in_array($weekDate, $incompleteDays) && $weekDate < $todayAtMidnight ? "incompleteDay" : "");
     }
     $jobs = new Jobs();
     $weekTasks = NULL;
     $holidays = Holidays::getInstance();
     $weekTracks = $timeTracking->getWeekDetails($userid);
     foreach ($weekTracks as $bugid => $jobList) {
         try {
             $issue = IssueCache::getInstance()->getIssue($bugid);
             $backlog = $issue->getBacklog();
             $extRef = $issue->getTcId();
             $summary = $issue->getSummary();
             $description = SmartyTools::getIssueDescription($bugid, $extRef, $summary);
             $projectId = $issue->getProjectId();
         } catch (Exception $e) {
             $backlog = '!';
             $extRef = '';
             $summary = '<span class="error_font">' . T_('Error: Task not found in Mantis DB !') . '</span>';
             //$description = SmartyTools::getIssueDescription($bugid,$extRef,$summary);
             $description = Tools::mantisIssueURL($bugid, NULL, TRUE) . ' ' . $bugid . ' : ' . $summary;
             $projectId = -1;
         }
         foreach ($jobList as $jobid => $dayList) {
             // if no backlog set, display a '?' to allow Backlog edition
             if (is_numeric($backlog)) {
                 $formattedBacklog = $backlog;
                 // prepare json data for the BacklogDialogbox
                 $jsonIssueInfo = self::getUpdateBacklogJsonData($bugid, $jobid, $teamid, $userid);
             } else {
                 #if (($team->isSideTasksProject($issue->projectId)) ||
                 #    ($team->isNoStatsProject($issue->projectId))) {
                 // do not allow to edit sideTasks Backlog
                 $formattedBacklog = '';
                 $jsonIssueInfo = '';
                 #} else {
                 #   $formattedBacklog = '?';
                 #}
                 //
             }
             $dayTasks = "";
             for ($i = 1; $i <= 7; $i++) {
                 $title = NULL;
                 $bgColor = NULL;
                 if ($i <= 5) {
                     $h = $holidays->isHoliday($weekDates[$i]);
                     if ($h) {
                         $bgColor = $h->color;
                         #$bgColor = Holidays::$defaultColor;
                         $title = $h->description;
                     }
                 } else {
                     $bgColor = Holidays::$defaultColor;
                 }
                 $day = 0;
                 if (array_key_exists($i, $dayList)) {
                     $day = $dayList[$i];
                 }
                 $dayTasks[] = array('bgColor' => $bgColor, 'title' => $title, 'day' => $day);
                 $totalElapsed[$weekDates[$i]]['elapsed'] += $day;
             }
             /*          
                         $deadline = $issue->getDeadLine();
             
                         if (!is_null($deadline) || (0 != $deadline)) {
                            $formatedDate = Tools::formatDate(T_("%Y-%m-%d"), $deadline);
                         }
             */
             try {
                 $project = ProjectCache::getInstance()->getProject($projectId);
             } catch (Exception $e) {
                 $project = null;
             }
             if ($project != null) {
                 if (!$project->isSideTasksProject(array($teamid)) && !$project->isExternalTasksProject()) {
                     // TODO does $issue belong to current team's project ? what if not ?
                     $tooltipAttr = $issue->getTooltipItems($teamid, $userid);
                     $infoTooltip = Tools::imgWithTooltip('images/b_info.png', $tooltipAttr);
                 } else {
                     $infoTooltip = '';
                 }
             } else {
                 $infoTooltip = '';
             }
             // prepare json data for the IssueNoteDialogbox
             if ($project != null) {
                 if (!$project->isSideTasksProject(array($teamid)) && !$project->isExternalTasksProject()) {
                     $issueNote = IssueNote::getTimesheetNote($issue->getId());
                     if (!is_null($issueNote)) {
                         $issueNoteId = $issueNote->getId();
                         $user = UserCache::getInstance()->getUser($issueNote->getReporterId());
                         $rawNote = $issueNote->getText();
                         $note = trim(IssueNote::removeAllReadByTags($rawNote));
                         // used for the tooltip NOT the dialoBox
                         $tooltipAttr = array('reporter' => $user->getRealname(), 'date' => date('Y-m-d H:i:s', $issueNote->getLastModified()), 'Note' => $note);
                         $readByList = $issueNote->getReadByList(TRUE);
                         if (0 != count($readByList)) {
                             $tooltipAttr['Read by'] = implode(', ', array_keys($readByList));
                         }
                         $noteTooltip = Tools::imgWithTooltip('images/b_note.png', $tooltipAttr, NULL, 'js-add-note-link', ' style="cursor: pointer;" data-bugId="' . $issueNote->getBugId() . '"');
                     } else {
                         $issueNoteId = 0;
                         $noteTooltip = Tools::imgWithTooltip('images/b_note_grey.png', T_('Click to add a note'), NULL, 'js-add-note-link', ' style="cursor: pointer;" data-bugId="' . $issue->getId() . '"');
                     }
                 } else {
                     $noteTooltip = '';
                 }
             } else {
                 $noteTooltip = '';
             }
             // if project not declared in current team, then
             // user cannot add a timetrack by clicking in the weekTasks table
             // Note: (this would generate an error on addTimetrack)
             $team = TeamCache::getInstance()->getTeam($teamid);
             $isTeamProject = !is_null($team->getProjectType($projectId));
             $weekTasks[$bugid . "_" . $jobid] = array('bugid' => $bugid, 'description' => $description, 'formattedBacklog' => $formattedBacklog, 'jobid' => $jobid, 'jobName' => $jobs->getJobName($jobid), 'dayTasks' => $dayTasks, 'infoTooltip' => $infoTooltip, 'summary' => addslashes(htmlspecialchars($summary)), 'updateBacklogJsonData' => $jsonIssueInfo, 'issueNoteId' => $issueNoteId, 'noteTooltip' => $noteTooltip, 'isTeamProject' => $isTeamProject);
         }
     }
     return array("weekTasks" => $weekTasks, "totalElapsed" => $totalElapsed);
 }