public function __construct($id, $value, $type) { $this->id = $id; $this->type = $type; switch ($type) { case Config::configType_keyValue: $this->value = NULL != $value ? $this->value = Tools::doubleExplode(':', ',', $value) : NULL; break; case Config::configType_array: $this->value = NULL != $value ? $this->value = explode(',', $value) : NULL; break; default: $this->value = $value; } }
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); return; } $year = Tools::getSecurePOSTIntValue('year', date('Y')); $displayed_teamid = 0; if (isset($_POST['displayed_teamid'])) { $displayed_teamid = Tools::getSecurePOSTIntValue('displayed_teamid', 0); } else { $displayed_teamid = $this->teamid; } // --- Filters $filtersStr = Tools::getSecurePOSTStringValue('checkedFilters', ''); if (!empty($filtersStr)) { $filters = Tools::doubleExplode(':', ',', $filtersStr); } else { $filters = array('isExternalTasks' => 1, 'isSidetasksInactivity' => 1); } $filterInfo = array(); $filterInfo[] = array('filterId' => 'isExternalTasks', 'filterName' => T_('External Tasks'), 'isChecked' => $filters['isExternalTasks']); $filterInfo[] = array('filterId' => 'isSidetasksInactivity', 'filterName' => T_('Sidetasks Inactivity'), 'isChecked' => $filters['isSidetasksInactivity']); $this->smartyHelper->assign('filterInfo', $filterInfo); $this->smartyHelper->assign('checkedFilters', $filtersStr); // --- $teams = SmartyTools::getSmartyArray($this->teamList, $displayed_teamid); #$teams = SmartyTools::getSmartyArray(Team::getTeams(),$displayed_teamid); $this->smartyHelper->assign('availableTeams', $teams); $this->smartyHelper->assign('years', SmartyTools::getYears($year, 2)); if ($displayed_teamid == 0 && count($teams) > 0) { $teamids = array_keys($teams); $displayed_teamid = $teamids[0]; } $team = TeamCache::getInstance()->getTeam($displayed_teamid); $users = $team->getUsers(); $months = array(); for ($i = 1; $i <= 12; $i++) { $monthTimestamp = mktime(0, 0, 0, $i, 1, $year); $nbDaysInMonth = date("t", $monthTimestamp); $endMonthTimestamp = strtotime("last day of this month", $monthTimestamp); $months[$i] = array("name" => Tools::formatDate("%B %Y", $monthTimestamp), "idcaption" => Tools::formatDate("%B", $monthTimestamp), "days" => $this->getDays($nbDaysInMonth, $i, $year), "users" => $this->getDaysUsers($i, $year, $displayed_teamid, $users, $nbDaysInMonth, $filters), "workdays" => Holidays::getInstance()->getWorkdays($monthTimestamp, $endMonthTimestamp), "filename_csv" => date("Ym", $monthTimestamp) . '_' . str_replace(' ', '_', $team->getName()) . '_holidays.csv'); } $this->smartyHelper->assign('months', $months); } }
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 { // if cmdid set in URL, use it. else: // use the commandsetid set in the form, if not defined (first page call) use session commandsetid $cmdid = 0; if (isset($_POST['cmdid'])) { $cmdid = Tools::getSecurePOSTIntValue('cmdid'); $_SESSION['cmdid'] = $cmdid; } else { if (isset($_GET['cmdid'])) { $cmdid = Tools::getSecureGETIntValue('cmdid'); $_SESSION['cmdid'] = $cmdid; } else { if (isset($_SESSION['cmdid'])) { $cmdid = $_SESSION['cmdid']; } } } if (!array_key_exists($this->teamid, $this->teamList)) { $this->teamid = 0; $cmdid = 0; } else { $isManager = $this->session_user->isTeamManager($this->teamid); $isObserver = $this->session_user->isTeamObserver($this->teamid); if ($isManager || $isObserver) { // observers have access to the same info $this->smartyHelper->assign('isManager', true); } } $action = Tools::getSecurePOSTStringValue('action', ''); // --- CmdStateFilters if ('setCmdStateFilters' == $action) { $cmdStateFiltersStr = Tools::getSecurePOSTStringValue('checkedCmdStateFilters'); $this->session_user->setCmdStateFilters($cmdStateFiltersStr, $this->teamid); } else { $cmdStateFiltersStr = $this->session_user->getCmdStateFilters($this->teamid); } if (!empty($cmdStateFiltersStr)) { $cmdStateFilters = Tools::doubleExplode(':', ',', $cmdStateFiltersStr); $this->smartyHelper->assign('isCmdStateFilter', true); } else { $cmdStateFilters = array(); } $cmdStateFilterInfo = array(); foreach (Command::$stateNames as $stateId => $stateName) { $cmdStateFilterInfo[$stateId] = array('stateId' => $stateId, 'stateName' => $stateName, 'isChecked' => array_key_exists($stateId, $cmdStateFilters) ? $cmdStateFilters[$stateId] : 1); } $this->smartyHelper->assign('cmdStateFilterInfo', $cmdStateFilterInfo); // --- commands combobox $commands = $this->getCommands($this->teamid, $cmdid, $cmdStateFilters); $this->smartyHelper->assign('commands', $commands); // check if current cmd should be hidden if (!array_key_exists($cmdid, $commands)) { $cmdid = 0; } // ------ Display Command if (0 != $cmdid) { $cmd = CommandCache::getInstance()->getCommand($cmdid); if ($cmd->getTeamid() == $this->teamid) { $this->smartyHelper->assign('commandid', $cmdid); // get selected filters if (isset($_GET['selectedFilters'])) { $selectedFilters = Tools::getSecureGETStringValue('selectedFilters'); } else { $selectedFilters = $this->session_user->getCommandFilters($cmdid); } // cleanup filters (remove empty lines) $filterList = explode(',', $selectedFilters); $filterList = array_filter($filterList, create_function('$a', 'return $a!="";')); $selectedFilters = implode(',', $filterList); CommandTools::displayCommand($this->smartyHelper, $cmd, $isManager || $isObserver, $selectedFilters); // ConsistencyCheck $consistencyErrors = $this->getConsistencyErrors($cmd); if (count($consistencyErrors) > 0) { $this->smartyHelper->assign('ccheckButtonTitle', count($consistencyErrors) . ' ' . T_("Errors")); $this->smartyHelper->assign('ccheckBoxTitle', count($consistencyErrors) . ' ' . T_("Errors")); $this->smartyHelper->assign('ccheckErrList', $consistencyErrors); } // check if sold days warning should be displayed if (0 != $cmd->getTotalSoldDays()) { $checkTotalSoldDays = $cmd->getTotalSoldDays() - $cmd->getIssueSelection()->mgrEffortEstim - $cmd->getProvisionDays(); $checkTotalSoldDays = round($checkTotalSoldDays, 2); if (0 !== checkTotalSoldDays) { $this->smartyHelper->assign('checkTotalSoldDays', $checkTotalSoldDays); } } // access rights if ($isManager || $this->session_user->isTeamLeader($cmd->getTeamid())) { $this->smartyHelper->assign('isEditGranted', true); } // WBS $this->smartyHelper->assign('wbsRootId', $cmd->getWbsid()); // indicator_plugins (old style plugins - deprecated) $this->smartyHelper->assign('detailedChargesIndicatorFile', DetailedChargesIndicator::getSmartyFilename()); // Dashboard CommandTools::dashboardSettings($this->smartyHelper, $cmd, $this->session_userid); } } else { unset($_SESSION['commandsetid']); unset($_SESSION['servicecontractid']); if ('displayCommand' == $action) { header('Location:command_edit.php?cmdid=0'); } } } } }
protected function display() { if (Tools::isConnectedUser()) { $teamList = $this->session_user->getTeamList(); // only teamMembers & observers can access this page if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) { $this->smartyHelper->assign('accessDenied', TRUE); } else { $pageWidth = Tools::getSecurePOSTIntValue('width', Tools::getSecureGETIntValue('width', 0)); $this->smartyHelper->assign('width', $pageWidth); if (array_key_exists($this->teamid, $teamList)) { $this->smartyHelper->assign('consistencyErrors', $this->getConsistencyErrors($this->teamid)); $team = TeamCache::getInstance()->getTeam($this->teamid); $isManager = $this->session_user->isTeamManager($this->teamid); $isObserver = $this->session_user->isTeamObserver($this->teamid); $this->smartyHelper->assign('isManager', $isManager || $isObserver); // display backlog (unassigned tasks) $unassignedIssues = $team->getUnassignedTasks(); $unassigendSel = new IssueSelection("unassigned from team {$this->teamid}"); $unassigendSel->addIssueList($unassignedIssues); $this->smartyHelper->assign('unassigned_nbIssues', $unassigendSel->getNbIssues()); $this->smartyHelper->assign('unassigned_MEE', $unassigendSel->mgrEffortEstim); $this->smartyHelper->assign('unassigned_EE', $unassigendSel->effortEstim + $unassigendSel->effortAdd); // get planningOptions $keyvalue = Tools::getSecurePOSTStringValue('planningOptions', ''); if (!empty($keyvalue)) { $planningOptions = Tools::doubleExplode(':', ',', $keyvalue); $this->session_user->setPlanningOptions($this->teamid, $planningOptions); } $this->smartyHelper->assign('planningOptions', $this->getPlanningOptions()); $today = mktime(0, 0, 0, date("m"), date("d"), date("Y")); $graphSize = "undefined" != $pageWidth ? $pageWidth - 150 : 800; $allTasksLists = array(); $workloads = array(); $teamMembers = $team->getUsers(); $nbDaysToDisplay = 0; foreach ($teamMembers as $user) { $workload = 0; // show only developper's & manager's tasks if (!$user->isTeamDeveloper($this->teamid) && !$user->isTeamManager($this->teamid)) { if (self::$logger->isDebugEnabled()) { self::$logger->debug("user " . $user->getId() . " excluded from scheduled users on team {$this->teamid}"); } continue; } if (NULL != $user->getDepartureDate($this->teamid) && $user->getDepartureDate($this->teamid) < $today) { continue; } $scheduledTaskList = ScheduledTask::scheduleUser($user, $today, $this->teamid, TRUE); foreach ($scheduledTaskList as $scheduledTask) { $workload += $scheduledTask->getDuration(); } $nbDaysToDisplay = $nbDaysToDisplay < $workload ? $workload : $nbDaysToDisplay; $allTasksLists[$user->getName()] = $scheduledTaskList; $workloads[$user->getName()] = $workload; } $dayPixSize = 0 != $nbDaysToDisplay ? $graphSize / $nbDaysToDisplay : 0; $dayPixSize = round($dayPixSize); #echo "DEBUG dayPixSize = $dayPixSize<br/>\n"; $this->smartyHelper->assign('planning', $this->getPlanning($nbDaysToDisplay, $dayPixSize, $allTasksLists, $workloads, $this->teamid, $this->session_userid, $isManager)); $this->smartyHelper->assign('colors', array("green" => T_("onTime"), "red" => T_("NOT onTime"), "blue" => T_("no deadLine"), "grey" => T_("monitored"))); $this->smartyHelper->assign('dayPixSize', $dayPixSize - 1); } } } }
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 { $team = TeamCache::getInstance()->getTeam($this->teamid); // if first call to this page if (!array_key_exists('nextForm', $_POST)) { $activeMembers = $team->getActiveMembers(); if ($this->session_user->isTeamManager($this->teamid)) { $this->smartyHelper->assign('users', SmartyTools::getSmartyArray($activeMembers, $this->session_userid)); } else { // developper & manager can add timeTracks if (array_key_exists($this->session_userid, $activeMembers)) { $_POST['userid'] = $this->session_userid; $_POST['nextForm'] = "addHolidaysForm"; //$_POST['days'] = 'dayid'; } } } $nextForm = Tools::getSecurePOSTStringValue('nextForm', ''); if ($nextForm == "addHolidaysForm") { $userid = Tools::getSecurePOSTIntValue('userid', $this->session_userid); $managed_user = UserCache::getInstance()->getUser($userid); // dates $startdate = Tools::getSecurePOSTStringValue('startdate', date("Y-m-d")); $enddate = Tools::getSecurePOSTStringValue('enddate', ''); $defaultBugid = Tools::getSecurePOSTIntValue('bugid', 0); $action = Tools::getSecurePOSTStringValue('action', ''); $duration = Tools::getSecurePOSTNumberValue('duree', 0); if ("addHolidays" == $action) { // TODO add tracks ! $job = Tools::getSecurePOSTStringValue('job'); $duration = Tools::getSecurePOSTNumberValue('duree'); $holydays = Holidays::getInstance(); $keyvalue = Tools::getSecurePOSTStringValue('checkedDays'); $checkedDaysList = Tools::doubleExplode(':', ',', $keyvalue); $startTimestamp = Tools::date2timestamp($startdate); $endTimestamp = Tools::date2timestamp($enddate); // save to DB $weekday = date('l', strtotime($startdate)); $timestamp = $startTimestamp; while ($timestamp <= $endTimestamp) { // check if not a fixed holiday if (!$holydays->isHoliday($timestamp)) { // check existing timetracks on $timestamp and adjust duration $availabletime = $managed_user->getAvailableTime($timestamp); // not imput more than possible if ($duration >= $availabletime) { $imput = $availabletime; } else { $imput = $duration; } // check if weekday checkbox is checked if (1 == $checkedDaysList[$weekday]) { if ($duration > 0) { if (self::$logger->isDebugEnabled()) { self::$logger->debug(date("Y-m-d", $timestamp) . " duration {$imput} job {$job}"); } TimeTrack::create($managed_user->getId(), $defaultBugid, $job, $timestamp, $imput, $this->session_userid); } } } $timestamp = strtotime("+1 day", $timestamp); $weekday = date('l', strtotime(date("Y-m-d", $timestamp))); } // We redirect to holidays report, so the user can verify his holidays header('Location:holidays_report.php'); } $this->smartyHelper->assign('startDate', $startdate); $this->smartyHelper->assign('endDate', $enddate); if ($this->session_userid != $managed_user->getId()) { $this->smartyHelper->assign('otherrealname', $managed_user->getRealname()); } // Get Team SideTasks Project List $projList = $team->getProjects(true, false); foreach ($projList as $pid => $pname) { // we want only SideTasks projects try { if (!$team->isSideTasksProject($pid)) { unset($projList[$pid]); } } catch (Exception $e) { self::$logger->error("project {$pid}: " . $e->getMessage()); } } $extproj_id = Config::getInstance()->getValue(Config::id_externalTasksProject); $extProj = ProjectCache::getInstance()->getProject($extproj_id); $projList[$extproj_id] = $extProj->getName(); $defaultProjectid = Tools::getSecurePOSTIntValue('projectid', 0); if ($defaultBugid != 0 && $action == 'setBugId') { // find ProjectId to update categories $issue = IssueCache::getInstance()->getIssue($defaultBugid); $defaultProjectid = $issue->getProjectId(); } $this->smartyHelper->assign('projects', SmartyTools::getSmartyArray($projList, $defaultProjectid)); $this->smartyHelper->assign('issues', $this->getIssues($defaultProjectid, $projList, $extproj_id, $defaultBugid)); $this->smartyHelper->assign('jobs', $this->getJobs($defaultProjectid, $projList)); $this->smartyHelper->assign('duration', SmartyTools::getSmartyArray(TimeTrackingTools::getDurationList($team->getId()), $duration)); $this->smartyHelper->assign('userid', $managed_user->getId()); } } } }
/** * get config from ini file */ public static function parseConfigFile() { // TODO workaround $file = self::$config_file; if (!file_exists($file)) { if (!self::$quiet) { self::$logger->error("ERROR: parseConfigFile() file " . $file . " NOT found !"); echo "ERROR: parseConfigFile() file " . $file . " NOT found !"; } return FALSE; } $ini_array = parse_ini_file($file, true); #print_r($ini_array); $general = $ini_array['general']; self::$codevInstall_timestamp = $general['codevInstall_timestamp']; self::$codevtt_logfile = $general['codevtt_logfile']; self::$codevOutputDir = $general['codevtt_output_dir']; self::$homepage_title = $general['homepage_title']; if (array_key_exists('logo_image', $general)) { self::$logoImage = $general['logo_image']; } self::$codevURL = $general['codevtt_url']; self::$codevRootDir = $general['codevtt_dir']; self::$mantisPath = $general['mantis_dir']; self::$mantisURL = $general['mantis_url']; $database = $ini_array['database']; self::$db_mantis_host = $database['db_mantis_host']; self::$db_mantis_database = $database['db_mantis_database']; self::$db_mantis_user = $database['db_mantis_user']; self::$db_mantis_pass = $database['db_mantis_pass']; $mantis = $ini_array['mantis']; self::$statusNames = Tools::doubleExplode(':', ',', $mantis['status_enum_string']); self::$priority_names = Tools::doubleExplode(':', ',', $mantis['priority_enum_string']); self::$resolution_names = Tools::doubleExplode(':', ',', $mantis['resolution_enum_string']); self::$severity_names = Tools::doubleExplode(':', ',', $mantis['severity_enum_string']); self::$bug_resolved_status_threshold = $mantis['bug_resolved_status_threshold']; self::$status_enum_workflow = json_decode($mantis['status_enum_workflow'], true); // jsonStr to array $status = $ini_array['status']; self::$status_new = $status['status_new']; self::$status_feedback = $status['status_feedback']; #self::$status_acknowledged = $status['status_acknowledged']; self::$status_open = $status['status_open']; self::$status_closed = $status['status_closed']; $resolution = $ini_array['resolution']; self::$resolution_fixed = $resolution['resolution_fixed']; self::$resolution_reopened = $resolution['resolution_reopened']; $relationships = $ini_array['relationships']; self::$relationship_constrained_by = $relationships['relationship_constrained_by']; self::$relationship_constrains = $relationships['relationship_constrains']; define('BUG_CUSTOM_RELATIONSHIP_CONSTRAINED_BY', $relationships['relationship_constrained_by']); define('BUG_CUSTOM_RELATIONSHIP_CONSTRAINS', $relationships['relationship_constrains']); $perf = $ini_array['perf']; if ($perf != null && array_key_exists('max_tooltips_per_page', $perf)) { self::$maxTooltipsPerPage = $perf['max_tooltips_per_page']; } $doodles = $ini_array['doodles']; if (is_array($doodles)) { $today = date("md"); self::$doodles = array(); // remove default doodles foreach ($doodles as $key => $value) { self::$doodles[$key] = $value; if (substr($key, 0, 11) === 'logo_image_' && (substr($key, 11, 4) <= $today && substr($key, 16, 4) >= $today) && file_exists(self::$codevRootDir . DIRECTORY_SEPARATOR . $value)) { self::$logoImage = $value; } } } $timesheets = $ini_array['timesheets']; if (null != $timesheets && array_key_exists('task_duration_list', $timesheets)) { self::$taskDurationList = Tools::doubleExplode(':', ',', $timesheets['task_duration_list']); } $internet = $ini_array['internet']; if (is_array($internet)) { if (array_key_exists('proxy', $internet)) { self::$proxy = $internet['proxy']; } if (array_key_exists('check_latest_version', $internet)) { self::$isCheckLatestVersion = $internet['check_latest_version']; } } $dashboards = $ini_array['dashboardDefaultPlugins']; if (is_array($dashboards)) { foreach ($dashboards as $domain => $plugins) { self::$dashboardDefaultPlugins[$domain] = explode(',', $plugins); } } $emailSettings = $ini_array['email']; if (is_array($emailSettings)) { foreach ($emailSettings as $key => $val) { self::$emailSettings[$key] = $val; } } // ----- /* FIXME WORKAROUND: SQL procedures still use codev_config_table.bug_resolved_status_threshold ! */ $desc = "bug resolved threshold as defined in Mantis (g_bug_resolved_status_threshold)"; self::$logger->warn("WORKAROUND update codev_config_table.bug_resolved_status_threshold = " . self::$bug_resolved_status_threshold); Config::getInstance()->setValue(Config::id_bugResolvedStatusThreshold, self::$bug_resolved_status_threshold, Config::configType_int, $desc); }
/** * get Workflow transitions from Mantis DB * * mantis_config_table - config_id='status_enum_workflow' * @return array[] */ function getWorkflowTransitionsFormatted() { $unserialized = $this->getWorkflowTransitions(); $statusTitles = array(); $wfTrans = array(); // find all statuses foreach ($unserialized as $line => $sList) { $sarr = Tools::doubleExplode(':', ',', $sList); ksort($sarr); $wfTrans[$line] = $sarr; foreach ($sarr as $status => $statusName) { $statusTitles[$status] = $statusName; } } // add titles ksort($statusTitles); $wfTrans[0] = $statusTitles; ksort($wfTrans); return $wfTrans; }
/** * * checks user filter settings in codev_config_table * if not found, use defaults settings defined in constants.php * * id = 'id_timetrackingFilters' * type = keyValue "onlyAssignedTo:0,hideResolved:1,hideDevProjects:0" * * @param string $filterName 'onlyAssignedTo' * @return unknown_type returns filterValue */ function getTimetrackingFilter($filterName) { if (NULL == $this->timetrackingFilters || '' == $this->timetrackingFilters) { $this->timetrackingFilters = Config::getValue(Config::id_timetrackingFilters, array($this->id, 0, 0, 0, 0, 0), true); if ($this->timetrackingFilters == NULL) { $this->timetrackingFilters = Tools::doubleExplode(':', ',', Config::default_timetrackingFilters); } if (self::$logger->isDebugEnabled()) { self::$logger->debug("user {$this->id} timeTrackingFilters = <{$this->timetrackingFilters}>"); } } // get value $value = $this->timetrackingFilters[$filterName]; if (self::$logger->isDebugEnabled()) { self::$logger->debug("user {$this->id} timeTrackingFilter {$filterName} = <{$value}>"); } return $value; }
global $s_resolution_enum_string; // get information from mantis config files $status_enum_string = isset($g_status_enum_string) ? $g_status_enum_string : $s_status_enum_string; $priority_enum_string = isset($g_priority_enum_string) ? $g_priority_enum_string : $s_priority_enum_string; $severity_enum_string = isset($g_severity_enum_string) ? $g_severity_enum_string : $s_severity_enum_string; $resolution_enum_string = isset($g_resolution_enum_string) ? $g_resolution_enum_string : $s_resolution_enum_string; $status_enum_workflow = isset($g_status_enum_workflow) ? $g_status_enum_workflow : $s_status_enum_workflow; // and set codev Config variables echo "<script type=\"text/javascript\">console.log(\"DEBUG add statusNames\");</script>"; Constants::$statusNames = Tools::doubleExplode(':', ',', $status_enum_string); echo "<script type=\"text/javascript\">console.log(\"DEBUG add priorityNames\");</script>"; Constants::$priority_names = Tools::doubleExplode(':', ',', $priority_enum_string); echo "<script type=\"text/javascript\">console.log(\"DEBUG add severityNames\");</script>"; Constants::$severity_names = Tools::doubleExplode(':', ',', $severity_enum_string); echo "<script type=\"text/javascript\">console.log(\"DEBUG add resolutionNames\");</script>"; Constants::$resolution_names = Tools::doubleExplode(':', ',', $resolution_enum_string); $bug_resolved_status_threshold = isset($g_bug_resolved_status_threshold) ? $g_bug_resolved_status_threshold : constant("RESOLVED"); echo "<script type=\"text/javascript\">console.log(\"DEBUG add bug_resolved_status_threshold = {$g_bug_resolved_status_threshold}\");</script>"; Constants::$bug_resolved_status_threshold = $bug_resolved_status_threshold; echo "<script type=\"text/javascript\">console.log(\"DEBUG add status_enum_workflow\");</script>"; Constants::$status_enum_workflow = $status_enum_workflow; if (!is_array(Constants::$status_enum_workflow)) { $errStr .= "Could not retrieve status_enum_workflow form Mantis config files<br>"; } echo "<script type=\"text/javascript\">console.log(\"DEBUG create " . str_replace('\\', '/', Constants::$config_file) . "\");</script>"; $errStr .= createConstantsFile($path_mantis, $url_mantis, $url_codevtt); if (NULL != $errStr) { echo '<script type="text/javascript">'; echo ' document.getElementById("divErrMsg").style.display = "block";'; echo " document.getElementById(\"errorMsg\").innerHTML=\"" . $errStr . "\";"; echo '</script>';
$response['selectedItems'] = $selectedItems; // json encode $jsonResponse = Tools::array2json($response); echo "{$jsonResponse}"; } catch (Exception $e) { Tools::sendBadRequest($e->getMessage()); } } else { 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); } }
protected function display() { if (Tools::isConnectedUser()) { $teamList = NULL; // leadedTeams only, except Admins: they can edit all teams if ($this->session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) { $teamList = Team::getTeams(true); } else { $teamList = $this->session_user->getLeadedTeamList(true); } if (count($teamList) > 0) { if (isset($_POST['deletedteam'])) { $teamidToDelete = Tools::getSecurePOSTIntValue("deletedteam"); if (array_key_exists($teamidToDelete, $teamList)) { $retCode = Team::delete($teamidToDelete); if (!$retCode) { $this->smartyHelper->assign('error', T_("Couldn't delete the team")); } else { if ($teamidToDelete == $_SESSION['teamid']) { unset($_SESSION['teamid']); $this->updateTeamSelector(); } unset($teamList[$teamidToDelete]); } } } // use the teamid set in the form, if not defined (first page call) use session teamid if (isset($_POST['displayed_teamid'])) { $displayed_teamid = Tools::getSecurePOSTIntValue('displayed_teamid'); } else { if (isset($_SESSION['teamid']) && array_key_exists($_SESSION['teamid'], $teamList)) { $displayed_teamid = $_SESSION['teamid']; } else { $teamIds = array_keys($teamList); if (count($teamIds) > 0) { $displayed_teamid = $teamIds[0]; } else { $displayed_teamid = 0; } } } $this->smartyHelper->assign('availableTeams', SmartyTools::getSmartyArray($teamList, $displayed_teamid)); if (array_key_exists($displayed_teamid, $teamList)) { $team = TeamCache::getInstance()->getTeam($displayed_teamid); if ($displayed_teamid != Config::getInstance()->getValue(Config::id_adminTeamId)) { $this->smartyHelper->assign('allowDeleteTeam', 1); } // ----------- actions ---------- $action = isset($_POST['action']) ? $_POST['action'] : ''; if ($action == "updateTeamLeader") { $teamleader_id = Tools::getSecurePOSTIntValue('leaderid'); if (!$team->setLeader($teamleader_id)) { $this->smartyHelper->assign('error', T_("Couldn't update the team leader")); } else { // --- 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); } } elseif ($action == "updateTeamCreationDate") { $formatedDate = Tools::getSecurePOSTStringValue("date_createTeam"); $date_create = Tools::date2timestamp($formatedDate); if (!$team->setCreationDate($date_create)) { $this->smartyHelper->assign('error', T_("Couldn't update the creation date")); } } elseif ($action == "setTeamEnabled") { $isTeamEnabled = 0 == Tools::getSecurePOSTIntValue("isTeamEnabled") ? false : true; if (!$team->setEnabled($isTeamEnabled)) { $this->smartyHelper->assign('error', T_("Couldn't enable/disable team")); } } elseif ($action == "addTeamMember") { $memberid = Tools::getSecurePOSTIntValue('memberid'); $memberAccess = Tools::getSecurePOSTIntValue('member_access'); $formatedDate = Tools::getSecurePOSTStringValue("date1"); $arrivalTimestamp = Tools::date2timestamp($formatedDate); try { // save to DB $team->addMember($memberid, $arrivalTimestamp, $memberAccess); // CodevTT administrators can manage ExternalTasksProject in Mantis if (Config::getInstance()->getValue(Config::id_adminTeamId) == $team->getId()) { $newUser = UserCache::getInstance()->getUser($memberid); $extProjId = Config::getInstance()->getValue(Config::id_externalTasksProject); $access_level = 70; // TODO mantis manager $newUser->setProjectAccessLevel($extProjId, $access_level); } } catch (Exception $e) { $this->smartyHelper->assign('error', "Couldn't add user {$memberid} to the team"); } } elseif ($action == "setMemberDepartureDate") { $formatedDate = Tools::getSecurePOSTStringValue("date2"); $departureTimestamp = Tools::date2timestamp($formatedDate); $memberid = Tools::getSecurePOSTIntValue('memberid'); $team->setMemberDepartureDate($memberid, $departureTimestamp); } elseif ($action == 'addMembersFrom') { $src_teamid = Tools::getSecurePOSTIntValue('f_src_teamid'); // add all members declared in Team $src_teamid (same dates, same access) // except if already declared $team->addMembersFrom($src_teamid); } elseif ($action == 'removeIssueTooltip') { $projectid = Tools::getSecurePOSTIntValue('projectid'); $project = ProjectCache::getInstance()->getProject($projectid); $project->setIssueTooltipFields(NULL, $displayed_teamid); } elseif ($action == 'setConsistencyCheck') { $keyvalue = Tools::getSecurePOSTStringValue('checkItems'); $checkList = Tools::doubleExplode(':', ',', $keyvalue); $team->setConsistencyCheckList($checkList); } elseif ($action == 'setGeneralPrefs') { $keyvalue = Tools::getSecurePOSTStringValue('checkItems'); $checkList = Tools::doubleExplode(':', ',', $keyvalue); $team->setGeneralPrefsList($checkList); } elseif ($action == 'createSideTaskProject') { $stprojName = Tools::getSecurePOSTStringValue('stprojName'); $stproj_id = $team->createSideTaskProject($stprojName); if ($stproj_id > 0) { $stproj = ProjectCache::getInstance()->getProject($stproj_id); // add teamLeader as Mantis manager of the SideTaskProject $leader = UserCache::getInstance()->getUser($team->getLeaderId()); $access_level = 70; // TODO mantis manager $leader->setProjectAccessLevel($stproj_id, $access_level); // add SideTaskProject Categories $stproj->addCategoryProjManagement(T_("Project Management")); $stproj->addCategoryInactivity(T_("Inactivity")); $stproj->addCategoryIncident(T_("Incident")); $stproj->addCategoryTools(T_("Tools")); $stproj->addCategoryWorkshop(T_("Team Workshop")); } } elseif (isset($_POST["deleteValue"])) { $duration = TimeTrackingTools::getDurationList($displayed_teamid); $duration_value = Tools::getSecurePOSTStringValue('deleteValue'); unset($duration[$duration_value]); if (count($duration) == 0) { Config::deleteValue(Config::id_durationList, array(0, 0, $displayed_teamid, 0, 0, 0)); } else { Config::setValue(Config::id_durationList, Tools::doubleImplode(":", ",", $duration), Config::configType_keyValue, NULL, 0, 0, $displayed_teamid); } } elseif (isset($_POST["addValue"])) { $duration = TimeTrackingTools::getDurationList($displayed_teamid); $duration_value = Tools::getSecurePOSTStringValue('addValue'); $duration_display = Tools::getSecurePOSTStringValue('addDisplay'); $duration[$duration_value] = $duration_display; Config::setValue(Config::id_durationList, Tools::doubleImplode(":", ",", $duration), Config::configType_keyValue, NULL, 0, 0, $displayed_teamid); } elseif (isset($_POST["updateValue"])) { $duration = TimeTrackingTools::getDurationList($displayed_teamid); $duration_value = Tools::getSecurePOSTStringValue('updateValue'); $duration_display = Tools::getSecurePOSTStringValue('updateDisplay'); $duration[$duration_value] = $duration_display; Config::setValue(Config::id_durationList, Tools::doubleImplode(":", ",", $duration), Config::configType_keyValue, NULL, 0, 0, $displayed_teamid); } elseif (isset($_POST["deletememberid"])) { $memberid = Tools::getSecurePOSTIntValue('deletememberid'); $query = "DELETE FROM `codev_team_user_table` WHERE id = {$memberid};"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { $this->smartyHelper->assign('error', T_("Couldn't delete the member of the team")); } } elseif (isset($_POST['addedprojectid'])) { $projectid = Tools::getSecurePOSTIntValue('addedprojectid'); if (0 != $projectid) { $projecttype = Tools::getSecurePOSTIntValue('project_type'); try { // prepare Project to CoDev (associate with CoDev customFields if needed) // WARN: Project constructor cannot be used in here. Project::prepareProjectToCodev($projectid); // save to DB if (!$team->addProject($projectid, $projecttype)) { $this->smartyHelper->assign('error', T_("Couldn't add the project to the team")); } } catch (Exception $e) { $this->smartyHelper->assign('error', T_("Couldn't add the project to the team")); } } } elseif (isset($_POST['deletedprojectid'])) { $projectid = Tools::getSecurePOSTIntValue('deletedprojectid'); if (!$team->removeProject($projectid)) { $this->smartyHelper->assign('error', T_("Could NOT remove the project from the team")); } } elseif (isset($_POST['addedastreinte_id'])) { $onduty_id = Tools::getSecurePOSTIntValue('addedastreinte_id'); if (0 != $onduty_id) { $team->addOnDutyTask($onduty_id); } } elseif (isset($_POST['deletedastreinte_id'])) { $onduty_id = Tools::getSecurePOSTIntValue('deletedastreinte_id'); $team->removeOnDutyTask($onduty_id); } $this->smartyHelper->assign('team', $team); $smartyUserList = array(); $userList = User::getUsers(); $selectedUserid = $team->getLeaderId(); foreach ($userList as $id => $name) { $u = UserCache::getInstance()->getUser($id); $uname = $u->getRealname(); if (empty($uname)) { $uname = $name; } $smartyUserList[$id] = array('id' => $id, 'name' => $uname, 'selected' => $id == $selectedUserid); } $this->smartyHelper->assign('users', $smartyUserList); $this->smartyHelper->assign('date', date("Y-m-d", $team->getDate())); $this->smartyHelper->assign('accessLevel', Team::$accessLevelNames); $this->smartyHelper->assign('arrivalDate', date("Y-m-d", time())); $this->smartyHelper->assign('departureDate', date("Y-m-d", time())); $this->smartyHelper->assign('teamMembers', $this->getTeamMembers($displayed_teamid)); $this->smartyHelper->assign('teamEnabled', $team->isEnabled()); $this->smartyHelper->assign('otherProjects', $team->getOtherProjects()); $this->smartyHelper->assign('typeNames', Project::$typeNames); $this->smartyHelper->assign('teamProjects', $this->getTeamProjects($displayed_teamid)); $this->smartyHelper->assign('onDutyCandidates', $this->getOnDutyCandidates($team, $team->getTrueProjects())); $this->smartyHelper->assign('onDutyTasks', $this->getOnDutyTasks($team)); $this->smartyHelper->assign('duration', TimeTrackingTools::getDurationList($displayed_teamid)); $projectList = $this->getTooltipProjectCandidates($team); $this->smartyHelper->assign('tooltipProjectCandidates', $projectList); $this->smartyHelper->assign('issueTooltips', $this->getIssueTooltips($projectList, $displayed_teamid)); $this->smartyHelper->assign('itemSelection_openDialogBtLabel', T_('Configure Tooltips')); $consistencyChecks = $this->getConsistencyChecks($team); $this->smartyHelper->assign('consistencyChecks', $consistencyChecks); $teamGeneralPrefs = $this->getTeamGeneralPrefs($team); $this->smartyHelper->assign('teamGeneralPrefs', $teamGeneralPrefs); } } } }
/** * 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; }
/** * @return string[] */ public static function getDurationList($teamid) { $duration = Config::getValue(Config::id_durationList, array(0, 0, $teamid, 0, 0, 0), true); if ($duration == NULL) { $duration = Constants::$taskDurationList; } elseif (!is_array($duration)) { $duration = Tools::doubleExplode(":", ",", $duration); } if ($duration != NULL && is_array($duration)) { krsort($duration); } return $duration; }
You should have received a copy of the GNU General Public License along with CodevTT. If not, see <http://www.gnu.org/licenses/>. */ require '../path.inc.php'; // Note: i18n is included by the Controler class, but Ajax dos not use it... require_once 'i18n/i18n.inc.php'; if (Tools::isConnectedUser() && (isset($_POST['action']) || isset($_POST['action']))) { if (isset($_POST['action'])) { if ($_POST['action'] == 'saveProvisionChanges') { if (isset($_SESSION['cmdid'])) { $cmdid = $_SESSION['cmdid']; if (0 != $cmdid) { // <provid>:<isInCheckBudget>, $imploded = Tools::getSecurePOSTStringValue("isInCheckBudgetImploded"); $provisions = Tools::doubleExplode(':', ',', $imploded); try { // save Provision changes foreach ($provisions as $provid => $isInCheckBudget) { $prov = new CommandProvision($provid); // securityCheck: does provid belong to this command ? if ($cmdid == $prov->getCommandId()) { $prov->setIsInCheckBudget($isInCheckBudget); } else { // LOG SECURITY ERROR !! Tools::sendBadRequest("Provision {$provid} does not belong to Command {$cmdid} !"); } } } catch (Exception $e) { Tools::sendBadRequest(T_("Provisions updated FAILED !")); }