/** * set the ProjectInfo filters * @param string $filters (comma separated) */ public function setProjectFilters($filters, $projectid = 0) { $this->getProjectFilters($projectid); if ($filters != $this->projectFilters) { if (self::$logger->isDebugEnabled()) { self::$logger->debug("User {$this->id} Set ProjectFilters : {$filters}"); } if ($filters == NULL || empty($filters)) { Config::deleteValue(Config::id_projectFilters, array($this->id, $projectid, 0, 0, 0, 0)); } else { Config::setValue(Config::id_projectFilters, $filters, Config::configType_int, "filters in ProjectInfo page", $projectid, $this->id); } } $this->projectFilters = $filters; }
/** * store fields to display in the Issue tooltip * * fields can be * - mantis_bug_table columns (ex: project_id, status) * - customField id prefixed with 'custom_' (ex: custom_23) * - CodevTT fields prefixed with 'codevtt_' (ex: codevtt_commands) * * if $fieldList == NULL, delete IssueTooltip custo for this project * * @param array $fieldList * @param int $teamid * @param int $userid */ public function setIssueTooltipFields($fieldList = NULL, $teamid = 0, $userid = 0) { if (!is_null($fieldList)) { $serialized = serialize($fieldList); Config::setValue('issue_tooltip_fields', $serialized, Config::configType_string, 'fields to be displayed in issue tooltip', $this->id, $userid, $teamid); $key = 'team' . $teamid . '_user' . $userid; if (is_null($this->issueTooltipFieldsCache)) { $this->issueTooltipFieldsCache = array(); } $this->issueTooltipFieldsCache[$key] = $fieldList; } else { // if $fieldList NULL, remove issueTooltip custo fot this project Config::deleteValue(Config::id_issueTooltipFields, array($userid, $this->id, $teamid, 0, 0, 0)); unset($this->issueTooltipFieldsCache[$key]); } }
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); } } } }