Exemplo n.º 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
             $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');
                 }
             }
         }
     }
 }