Beispiel #1
0
 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');
                 }
             }
         }
     }
 }