/** * * @param SmartyHelper $smartyHelper * @param Command $cmdset * @param int $userid */ public static function dashboardSettings(SmartyHelper $smartyHelper, CommandSet $cmdset, $userid) { $pluginDataProvider = PluginDataProvider::getInstance(); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_ISSUE_SELECTION, $cmdset->getIssueSelection(Command::type_general)); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_TEAM_ID, $cmdset->getTeamid()); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_PROVISION_DAYS, $cmdset->getProvisionDays(Command::type_general, TRUE)); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_SESSION_USER_ID, $userid); $params = self::computeTimestampsAndInterval($cmdset); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_START_TIMESTAMP, $params['startTimestamp']); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_END_TIMESTAMP, $params['endTimestamp']); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_INTERVAL, $params['interval']); // save the DataProvider for Ajax calls $_SESSION[PluginDataProviderInterface::SESSION_ID] = serialize($pluginDataProvider); // create the Dashboard $dashboard = new Dashboard('CommandSet' . $cmdset->getId()); $dashboard->setDomain(IndicatorPluginInterface::DOMAIN_COMMAND_SET); $dashboard->setCategories(array(IndicatorPluginInterface::CATEGORY_QUALITY, IndicatorPluginInterface::CATEGORY_ACTIVITY, IndicatorPluginInterface::CATEGORY_ROADMAP, IndicatorPluginInterface::CATEGORY_PLANNING, IndicatorPluginInterface::CATEGORY_RISK)); $dashboard->setTeamid($cmdset->getTeamid()); $dashboard->setUserid($userid); $data = $dashboard->getSmartyVariables($smartyHelper); foreach ($data as $smartyKey => $smartyVariable) { $smartyHelper->assign($smartyKey, $smartyVariable); } }
/** * delete a team (and all it's ServiceContracts,CommandSets,Commands) * @static * @param int $teamidToDelete * @return bool */ public static function delete($teamidToDelete) { try { $team = TeamCache::getInstance()->getTeam($teamidToDelete); $idlist = array_keys($team->getCommands()); foreach ($idlist as $id) { Command::delete($id); } $idlist = array_keys($team->getCommandSetList()); foreach ($idlist as $id) { CommandSet::delete($id); } $idlist = array_keys($team->getServiceContractList()); foreach ($idlist as $id) { ServiceContract::delete($id); } $query = "DELETE FROM `codev_team_project_table` WHERE team_id = {$teamidToDelete};"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "<span style='color:red'>ERROR: Query FAILED</span>\n"; exit; } $query = "DELETE FROM `codev_team_user_table` WHERE team_id = {$teamidToDelete};"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "<span style='color:red'>ERROR: Query FAILED</span>\n"; exit; } $query = "DELETE FROM `codev_team_table` WHERE id = {$teamidToDelete};"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "<span style='color:red'>ERROR: Query FAILED</span>\n"; exit; } } catch (Exception $e) { return false; } return true; }
/** * Initialize complex static variables * @static */ public static function staticInit() { self::$logger = Logger::getLogger(__CLASS__); }
/** * Get consistency errors * @param CommandSet $cmdset * @return mixed[] */ private function getConsistencyErrors(CommandSet $cmdset) { $consistencyErrors = array(); // if null, array_merge fails ! $cerrList = $cmdset->getConsistencyErrors(); if (count($cerrList) > 0) { foreach ($cerrList as $cerr) { if (!is_null($cerr->userId)) { $user = UserCache::getInstance()->getUser($cerr->userId); } else { $user = NULL; } if (Issue::exists($cerr->bugId)) { $issue = IssueCache::getInstance()->getIssue($cerr->bugId); $projName = $issue->getProjectName(); $summary = $issue->getSummary(); } else { $projName = ''; $summary = ''; } $titleAttr = array(T_('Project') => $projName, T_('Summary') => $summary); $consistencyErrors[] = array('issueURL' => Tools::issueInfoURL($cerr->bugId, $titleAttr), 'issueStatus' => Constants::$statusNames[$cerr->status], 'user' => isset($user) ? $user->getName() : '', 'severity' => $cerr->getLiteralSeverity(), 'severityColor' => $cerr->getSeverityColor(), 'desc' => $cerr->desc); } } return $consistencyErrors; }
/** * list the Commands that can be added to this CommandSet. * * This depends on user's teams * @param User $user * @return string[] */ private function getCmdSetCandidates(CommandSet $cmdset, User $user) { $cmdCandidates = array(); $lTeamList = $user->getLeadedTeamList(); $managedTeamList = $user->getManagedTeamList(); $mTeamList = $user->getDevTeamList(); $teamList = $mTeamList + $lTeamList + $managedTeamList; $cmds = $cmdset->getCommands(Command::type_general); foreach ($teamList as $tid => $name) { $team = TeamCache::getInstance()->getTeam($tid); $cmdList = $team->getCommands(); foreach ($cmdList as $cid => $cmd) { // remove Cmds already in this cset. if (!array_key_exists($cid, $cmds)) { $cmdCandidates[$cid] = $cmd->getReference() . " " . $cmd->getName(); } } } asort($cmdCandidates); return $cmdCandidates; }