protected function display() { if (Tools::isConnectedUser()) { // Admins only $session_user = UserCache::getInstance()->getUser($_SESSION['userid']); if ($session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) { if (isset($_POST['projects']) && !empty($_POST['projects'])) { $selectedProjects = $_POST['projects']; $result = array(); foreach ($selectedProjects as $projectid) { $project = ProjectCache::getInstance()->getProject($projectid); $result[$projectid] = $project->getName(); Project::prepareProjectToCodev($projectid); } $this->smartyHelper->assign('result', $result); } $this->smartyHelper->assign('projects', $this->getProjectList()); } } }
} // Set default Issue tooltip content echo "DEBUG 14/16 Set default content for Issue tooltip <br/>"; $customField_type = Config::getInstance()->getValue(Config::id_customField_type); $backlogField = Config::getInstance()->getValue(Config::id_customField_backlog); $fieldList = array('project_id', 'category_id', 'custom_' . $customField_type, 'codevtt_elapsed', 'custom_' . $backlogField, 'codevtt_drift'); $serialized = serialize($fieldList); Config::setValue('issue_tooltip_fields', $serialized, Config::configType_string, 'fields to be displayed in issue tooltip'); // Add custom fields to existing projects echo "DEBUG 15/16 Prepare existing projects<br/>"; if (isset($_POST['projects']) && !empty($_POST['projects'])) { $selectedProjects = $_POST['projects']; foreach ($selectedProjects as $projectid) { $project = ProjectCache::getInstance()->getProject($projectid); echo "DEBUG prepare project: " . $project->getName() . "<br/>"; Project::prepareProjectToCodev($projectid); } } echo "DEBUG 16/16 Install Mantis plugins<br/>"; installMantisPlugin('CodevTT', true); installMantisPlugin('FilterBugList', false); echo "DEBUG done.<br/>"; // load homepage #echo ("<script type='text/javascript'> alert('install done.'); </script>"); echo "<script type='text/javascript'> parent.location.replace('install_step4.php'); </script>"; } // ----- DISPLAY PAGE #displayStepInfo(); #echo "<hr align='left' width='20%'/>\n"; $extIdCustomFieldCandidates = getExtIdCustomFieldCandidates(); displayForm($originPage, $codevOutputDir, $checkReportsDirError, $isJob2, $isJob3, $isJob4, $isJob5, $job2, $job3, $job4, $job5, $job_support, $job_sideTasks, $jobSupport_color, $jobNA_color, $job2_color, $job3_color, $job4_color, $job5_color, $projectList, $groupExtID, $extIdCustomFieldCandidates, $extIdCustomField, $userList, $admin_id, $statusList, $status_new, $status_feedback, $status_open, $status_closed, $is_modified);
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); } } } }