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 $commandsetid = 0; if (isset($_POST['commandsetid'])) { $commandsetid = Tools::getSecurePOSTIntValue('commandsetid'); $_SESSION['commandsetid'] = $commandsetid; } else { if (isset($_GET['commandsetid'])) { $commandsetid = Tools::getSecureGETIntValue('commandsetid'); $_SESSION['commandsetid'] = $commandsetid; } else { if (isset($_SESSION['commandsetid'])) { $commandsetid = $_SESSION['commandsetid']; } } } // Managed + Observed teams only $oTeamList = $this->session_user->getObservedTeamList(); $mTeamList = $this->session_user->getManagedTeamList(); $teamList = $oTeamList + $mTeamList; // array_merge does not work ?! if (empty($teamList) || !array_key_exists($this->teamid, $teamList)) { // only managers (and observers) can access this page. return; } $isManager = $this->session_user->isTeamManager($this->teamid); $isObserver = $this->session_user->isTeamObserver($this->teamid); if ($isManager || $isObserver) { $this->smartyHelper->assign('isManager', true); } $this->smartyHelper->assign('commandsets', CommandSetTools::getCommandSets($this->teamid, $commandsetid)); if (0 != $commandsetid) { $commandset = CommandSetCache::getInstance()->getCommandSet($commandsetid); if ($this->teamid == $commandset->getTeamid()) { $this->smartyHelper->assign('commandsetid', $commandsetid); // set CommandSets I belong to $this->smartyHelper->assign('parentContracts', CommandSetTools::getParentContracts($commandset)); // get selected filters $selectedFilters = ""; if (isset($_GET['selectedFilters'])) { $selectedFilters = Tools::getSecureGETStringValue('selectedFilters'); } else { $selectedFilters = $this->session_user->getCommandSetFilters($commandsetid); } CommandSetTools::displayCommandSet($this->smartyHelper, $commandset, $isManager || $isObserver, $selectedFilters); // ConsistencyCheck $consistencyErrors = $this->getConsistencyErrors($commandset); if (0 != $consistencyErrors) { $this->smartyHelper->assign('ccheckButtonTitle', count($consistencyErrors) . ' ' . T_("Errors")); $this->smartyHelper->assign('ccheckBoxTitle', count($consistencyErrors) . ' ' . T_("Errors affecting the CommandSet")); $this->smartyHelper->assign('ccheckErrList', $consistencyErrors); } // access rights if ($this->session_user->isTeamManager($commandset->getTeamid()) || $this->session_user->isTeamLeader($commandset->getTeamid())) { $this->smartyHelper->assign('isEditGranted', true); } // old-stype plugins (deprecated) $this->smartyHelper->assign('detailedChargesIndicatorFile', DetailedChargesIndicator::getSmartyFilename()); // Dashboard CommandSetTools::dashboardSettings($this->smartyHelper, $commandset, $this->session_userid); } } else { unset($_SESSION['cmdid']); unset($_SESSION['servicecontractid']); $action = filter_input(INPUT_POST, 'action'); if ('displayCommandSet' == $action) { header('Location:commandset_edit.php?commandsetid=0'); } } } } }
protected function display() { if (Tools::isConnectedUser()) { if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) { $this->smartyHelper->assign('isEditGranted', FALSE); } else { // only managers can edit the SC $isManager = $this->session_user->isTeamManager($this->teamid); if (!$isManager) { return; } $this->smartyHelper->assign('isEditGranted', true); // use the commandsetid set in the form, if not defined (first page call) use session commandsetid $commandsetid = 0; if (isset($_POST['commandsetid'])) { $commandsetid = $_POST['commandsetid']; $_SESSION['commandsetid'] = $commandsetid; } else { if (isset($_GET['commandsetid'])) { $commandsetid = $_GET['commandsetid']; $_SESSION['commandsetid'] = $commandsetid; } else { if (isset($_SESSION['commandsetid'])) { $commandsetid = $_SESSION['commandsetid']; } } } $action = filter_input(INPUT_POST, 'action'); if (0 == $commandsetid) { // -------- CREATE CMDSET ------- if ("createCmdset" == $action) { if (self::$logger->isDebugEnabled()) { self::$logger->debug("create new CommandSet for team {$this->teamid}<br>"); } $cmdsetName = Tools::escape_string($_POST['commandsetName']); try { $commandsetid = CommandSet::create($cmdsetName, $this->teamid); $cmdset = CommandSetCache::getInstance()->getCommandSet($commandsetid); } catch (Exception $e) { // Smartify echo "Can't create the CommandSet because the CommandSet name is already used"; } } // Display Empty Command Form // Note: this will be overridden by the 'update' section if the 'createCommandset' action has been called. $this->smartyHelper->assign('cmdsetInfoFormBtText', T_('Create')); $this->smartyHelper->assign('cmdsetInfoFormAction', 'createCmdset'); } if (0 != $commandsetid) { // -------- UPDATE CMDSET ------- $cmdset = CommandSetCache::getInstance()->getCommandSet($commandsetid); // ------ Actions if ("addCommand" == $action) { # TODO $cmdid = SmartyTools::checkNumericValue($_POST['cmdid']); if (0 == $cmdid) { #$_SESSION['cmdid'] = 0; header('Location:command_edit.php?cmdid=0'); } else { $cmdset->addCommand($cmdid, Command::type_general); } } else { if ("removeCmd" == $action) { $cmdid = SmartyTools::checkNumericValue($_POST['cmdid']); $cmdset->removeCommand($cmdid); } else { if ("updateCmdsetInfo" == $action) { $this->updateCommandSetInfo($cmdset); header('Location:commandset_info.php'); } else { if ("deleteCommandSet" == $action) { if (self::$logger->isDebugEnabled()) { self::$logger->debug("delete CommandSet {$commandsetid} (" . $cmdset->getName() . ")"); } CommandSet::delete($commandsetid); unset($_SESSION['commandsetid']); header('Location:commandset_info.php'); } } } } // Display CommandSet $this->smartyHelper->assign('commandsetid', $commandsetid); $this->smartyHelper->assign('cmdsetInfoFormBtText', T_('Save')); $this->smartyHelper->assign('cmdsetInfoFormAction', 'updateCmdsetInfo'); $this->smartyHelper->assign('isAddCmdForm', true); $cmdCandidates = $this->getCmdSetCandidates($cmdset, $this->session_user); $this->smartyHelper->assign('cmdCandidates', $cmdCandidates); $this->smartyHelper->assign('isAddCmdSetForm', true); // set CommandSets I belong to $this->smartyHelper->assign('parentContracts', CommandSetTools::getParentContracts($cmdset)); $isManager = $this->session_user->isTeamManager($cmdset->getTeamid()); CommandSetTools::displayCommandSet($this->smartyHelper, $cmdset, $isManager); } // you can create OR move SC only to managed teams $mTeamList = $this->session_user->getManagedTeamList(); $this->smartyHelper->assign('grantedTeams', SmartyTools::getSmartyArray($mTeamList, $this->teamid)); } } }