Example #1
0
 /**
  * @param int $commandsetid
  * @param int $type Command::type_general
  * @return mixed[]
  */
 private static function getCommandSetDetailedMgr($commandsetid, $type)
 {
     $csetDetailedMgr = NULL;
     if (0 != $commandsetid) {
         $commandset = CommandSetCache::getInstance()->getCommandSet($commandsetid);
         $issueSelection = $commandset->getIssueSelection($type);
         $csetDetailedMgr = SmartyTools::getIssueSelectionDetailedMgr($issueSelection);
     }
     return $csetDetailedMgr;
 }
Example #2
0
 /**
  * A command can be included in several ComandSet from different teams.
  *
  * This returns the list of CommandSets where this command is defined.
  *
  * @return CommandSet[] array[commandset_id] = commandsetName
  */
 public function getCommandSetList()
 {
     if (NULL == $this->commandSetList) {
         $query = "SELECT commandset.* FROM `codev_commandset_table` as commandset " . "JOIN `codev_commandset_cmd_table` as commandset_cmd ON commandset.id = commandset_cmd.commandset_id " . "WHERE commandset_cmd.command_id = {$this->id};";
         $result = SqlWrapper::getInstance()->sql_query($query);
         if (!$result) {
             echo "<span style='color:red'>ERROR: Query FAILED</span>";
             exit;
         }
         // a Command can belong to more than one commandset
         $this->commandSetList = array();
         while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
             $cmdset = CommandSetCache::getInstance()->getCommandSet($row->id, $row);
             $this->commandSetList[$row->id] = $cmdset;
             if (self::$logger->isDebugEnabled()) {
                 self::$logger->debug("Command {$this->id} is in commandset {$row->id} (" . $cmdset->getName() . ")");
             }
         }
     }
     return $this->commandSetList;
 }
Example #3
0
 /**
  * CommandSets for this team
  * @return CommandSet[] : array id => CommandSet
  */
 public function getCommandSetList()
 {
     if (NULL == $this->commandSetList) {
         $query = "SELECT * FROM `codev_commandset_table` " . "WHERE team_id = {$this->id} " . "ORDER BY reference, name;";
         $result = SqlWrapper::getInstance()->sql_query($query);
         if (!$result) {
             echo "<span style='color:red'>ERROR: Query FAILED</span>";
             exit;
         }
         $this->commandSetList = array();
         while ($row = SqlWrapper::getInstance()->sql_fetch_object($result)) {
             $this->commandSetList[$row->id] = CommandSetCache::getInstance()->getCommandSet($row->id, $row);
         }
     }
     if (self::$logger->isDebugEnabled()) {
         self::$logger->debug("getCommandSetList(teamid={$this->id}) nbCommandSet=" . count($this->commandSetList));
     }
     return $this->commandSetList;
 }
Example #4
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');
                 }
             }
         }
     }
 }
Example #5
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);
             // -------- CHECK  --------
             // this will check all existing commands (from all teams !) and remove issues that have been deleted from mantis
             Command::checkCommands();
             // use the cmdid set in the form, if not defined (first page call) use session cmdid
             $cmdid = 0;
             if (isset($_POST['cmdid'])) {
                 $cmdid = $_POST['cmdid'];
                 $_SESSION['cmdid'] = $cmdid;
             } else {
                 if (isset($_GET['cmdid'])) {
                     $cmdid = $_GET['cmdid'];
                     $_SESSION['cmdid'] = $cmdid;
                 } else {
                     if (isset($_SESSION['cmdid'])) {
                         $cmdid = $_SESSION['cmdid'];
                     }
                 }
             }
             // use the commandsetid set in the form, if not defined (first page call) use session commandsetid
             // Note: It is used for createEnv but will be overridden by the displayed command's commandsetid.
             $commandsetid = 0;
             if (isset($_POST['commandsetid'])) {
                 $commandsetid = $_POST['commandsetid'];
                 $_SESSION['commandsetid'] = $commandsetid;
             } else {
                 if (isset($_SESSION['commandsetid'])) {
                     $commandsetid = $_SESSION['commandsetid'];
                 }
             }
             $action = isset($_POST['action']) ? $_POST['action'] : '';
             if (0 == $cmdid) {
                 // -------- CREATE CMD -------
                 if ("createCmd" == $action) {
                     //$this->teamid = Tools::getSecurePOSTIntValue('teamid');
                     //$_SESSION['teamid'] = $this->teamid;
                     if (self::$logger->isDebugEnabled()) {
                         self::$logger->debug("create new Command for team {$this->teamid}<br>");
                     }
                     $cmdName = Tools::getSecurePOSTStringValue('cmdName');
                     // TODO UGLY WORKAROUND: command name cannot contain commas (,) because it is used as field separator in FilterManager
                     $cmdName = str_replace(",", ' ', $cmdName);
                     try {
                         $cmdid = Command::create($cmdName, $this->teamid);
                         $this->smartyHelper->assign('commandid', $cmdid);
                         $cmd = CommandCache::getInstance()->getCommand($cmdid);
                     } catch (Exception $e) {
                         // Smartify
                         echo "Can't create the command because the command name is already used";
                     }
                 }
                 // ------ Display Empty Command Form
                 // Note: this will be overridden by the 'update' section if the 'createCmd' action has been called.
                 $this->smartyHelper->assign('cmdInfoFormBtText', T_('Create'));
                 $this->smartyHelper->assign('cmdInfoFormAction', 'createCmd');
                 $this->smartyHelper->assign('cmdStateList', CommandTools::getCommandStateList());
                 $this->smartyHelper->assign('commandsetid', $commandsetid);
                 $this->smartyHelper->assign('commandsets', CommandSetTools::getCommandSets($this->teamid, $commandsetid));
             }
             if (0 != $cmdid) {
                 // -------- UPDATE CMD -------
                 $cmd = CommandCache::getInstance()->getCommand($cmdid);
                 // Actions
                 if ("addCmdIssue" == $action) {
                     $bugid = Tools::getSecurePOSTIntValue('bugid');
                     if (self::$logger->isDebugEnabled()) {
                         self::$logger->debug("add Issue {$bugid} on Command {$cmdid} team {$this->teamid}");
                     }
                     $cmd->addIssue($bugid, true);
                     // DBonly
                 } else {
                     if ("addCmdIssueList" == $action) {
                         $bugid_list = $_POST['bugid_list'];
                         if (self::$logger->isDebugEnabled()) {
                             self::$logger->debug("add Issues ({$bugid_list}) on Command {$cmdid} team {$this->teamid}");
                         }
                         $bugids = explode(',', $bugid_list);
                         //$cmd->addIssueList($bugids, true); // DBonly
                         foreach ($bugids as $id) {
                             if (is_numeric(trim($id))) {
                                 $cmd->addIssue(intval($id), true);
                                 // DBonly
                             } else {
                                 self::$logger->error('Attempt to set non_numeric value (' . $id . ')');
                                 die("<span style='color:red'>ERROR: Please contact your CodevTT administrator</span>");
                             }
                         }
                     } else {
                         if ("removeCmdIssue" == $action) {
                             $cmd->removeIssue($_POST['bugid']);
                         } else {
                             if ("addToCmdSet" == $action) {
                                 $commandsetid = $_POST['commandsetid'];
                                 if (self::$logger->isDebugEnabled()) {
                                     self::$logger->debug("add Command {$cmdid} to CommandSet {$commandsetid}");
                                 }
                                 $cmdset = CommandSetCache::getInstance()->getCommandSet($commandsetid);
                                 $cmdset->addCommand($cmdid, Command::type_general);
                             } else {
                                 if ("removeFromCmdSet" == $action) {
                                     $commandsetid = $_POST['commandsetid'];
                                     if (self::$logger->isDebugEnabled()) {
                                         self::$logger->debug("remove Command {$cmdid} from CommandSet {$commandsetid}");
                                     }
                                     $cmdset = CommandSetCache::getInstance()->getCommandSet($commandsetid);
                                     $cmdset->removeCommand($cmdid);
                                 } else {
                                     if ("updateCmdInfo" == $action) {
                                         $this->updateCmdInfo($cmd);
                                         header('Location:command_info.php');
                                     } else {
                                         if ("deleteCommand" == $action) {
                                             if (self::$logger->isDebugEnabled()) {
                                                 self::$logger->debug("delete Command {$cmdid}");
                                             }
                                             Command::delete($cmdid);
                                             unset($_SESSION['cmdid']);
                                             header('Location:command_info.php');
                                         } else {
                                             if ("addProvision" == $action) {
                                                 # TODO check injections
                                                 $prov_date = $_POST['date'];
                                                 $prov_type = $_POST['type'];
                                                 $prov_budget = $_POST['budget'];
                                                 $prov_budgetDays = $_POST['budgetDays'];
                                                 $prov_averageDailyRate = $_POST['averageDailyRate'];
                                                 $prov_summary = $_POST['summary'];
                                                 $isInCheckBudget = 0 == Tools::getSecurePOSTIntValue("isInCheckBudget") ? false : true;
                                                 $timestamp = Tools::date2timestamp($prov_date);
                                                 CommandProvision::create($cmd->getId(), $timestamp, $prov_type, $prov_summary, $prov_budgetDays, $prov_budget, $prov_averageDailyRate, $isInCheckBudget);
                                             } else {
                                                 if ("deleteProvision" == $action) {
                                                     # TODO check injections
                                                     $provid = $_POST['provid'];
                                                     $cmd->deleteProvision($provid);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 // Display Command
                 $this->smartyHelper->assign('commandid', $cmdid);
                 $this->smartyHelper->assign('cmdInfoFormBtText', T_('Save'));
                 $this->smartyHelper->assign('cmdInfoFormAction', 'updateCmdInfo');
                 $this->smartyHelper->assign('isAddIssueForm', true);
                 $parentCmdSets = $this->getParentCmdSetCandidates($this->session_user);
                 $this->smartyHelper->assign('parentCmdSetCandidates', $parentCmdSets);
                 $this->smartyHelper->assign('isAddCmdSetForm', true);
                 $isManager = $this->session_user->isTeamManager($cmd->getTeamid());
                 CommandTools::displayCommand($this->smartyHelper, $cmd, $isManager);
                 $this->smartyHelper->assign('cmdProvisionType', SmartyTools::getSmartyArray(CommandProvision::$provisionNames, 1));
                 // WBS
                 $this->smartyHelper->assign('wbsRootId', $cmd->getWbsid());
                 // multiple selection dialogBox
                 $availableIssueList = $this->getChildIssuesCandidates($this->teamid);
                 $this->smartyHelper->assign('availableIssueList', $availableIssueList);
                 $this->smartyHelper->assign('sendSelectIssuesActionName', "addCmdIssueList");
                 $this->smartyHelper->assign('selectIssuesBoxTitle', T_('Add tasks to Command') . ' \'' . $cmd->getName() . '\'');
                 $this->smartyHelper->assign('openDialogLabel', T_("Add multiple tasks"));
                 $this->smartyHelper->assign('selectIssuesDoneBtText', T_("Add selection"));
                 $this->smartyHelper->assign('selectIssuesBoxDesc', T_("Note: Tasks already assigned to a Command are not displayed."));
                 $this->smartyHelper->assign('selectIssuesConfirmMsg', T_("Add the selected issues to the Command ?"));
             }
             // you can create a command OR move cmd only to managed teams
             $mTeamList = $this->session_user->getManagedTeamList();
             $this->smartyHelper->assign('grantedTeams', SmartyTools::getSmartyArray($mTeamList, $this->teamid));
         }
     }
 }
Example #6
0
 /**
  * add Command to commandset (in DB & current instance)
  *
  * @param int $commandset_id
  * @param int $type CommandSet::type_general
  * @return int id in codev_servicecontract_cmdset_table
  */
 public function addCommandSet($commandset_id, $type)
 {
     try {
         CommandSetCache::getInstance()->getCommandSet($commandset_id);
     } catch (Exception $e) {
         self::$logger->error("addCommandSet({$commandset_id}): CommandSet {$commandset_id} does not exist !");
         echo "<span style='color:red'>ERROR: CommandSet '{$commandset_id}' does not exist !</span>";
         return NULL;
     }
     if (self::$logger->isDebugEnabled()) {
         self::$logger->debug("Add CommandSet {$commandset_id} to ServiceContract {$this->id}");
     }
     if (NULL == $this->getCommandSetIds($type)) {
         $this->cmdsetidByTypeList[$type] = array();
     }
     $this->cmdsetidByTypeList[$type][] = $commandset_id;
     $query = "INSERT INTO `codev_servicecontract_cmdset_table` (`servicecontract_id`, `commandset_id`, `type`) VALUES ({$this->id}, {$commandset_id}, '{$type}');";
     $result = SqlWrapper::getInstance()->sql_query($query);
     if (!$result) {
         echo "<span style='color:red'>ERROR: Query FAILED</span>";
         exit;
     }
     return SqlWrapper::getInstance()->sql_insert_id();
 }
Example #7
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));
         }
     }
 }
Example #8
0
   You should have received a copy of the GNU General Public License
   along with CoDev-Timetracking.  If not, see <http://www.gnu.org/licenses/>.
*/
require '../path.inc.php';
// Note: i18n is included by the Controler class, but Ajax dos not use it...
require_once 'i18n/i18n.inc.php';
if (Tools::isConnectedUser() && (isset($_GET['action']) || isset($_POST['action']))) {
    if (isset($_GET['action'])) {
        $smartyHelper = new SmartyHelper();
        if ($_GET['action'] == 'updateDetailedCharges') {
            $cmdsetid = Tools::getSecureGETIntValue('selectFiltersSrcId');
            $selectedFilters = Tools::getSecureGETStringValue('selectedFilters', '');
            $session_user = UserCache::getInstance()->getUser($_SESSION['userid']);
            $session_user->setCommandSetFilters($selectedFilters, $cmdsetid);
            $cmdSet = CommandSetCache::getInstance()->getCommandSet($cmdsetid);
            $isManager = $session_user->isTeamManager($cmdSet->getTeamid());
            $isObserver = $session_user->isTeamObserver($cmdSet->getTeamid());
            // DetailedChargesIndicator
            $data = CommandSetTools::getDetailedCharges($cmdSet, $isManager || $isObserver, $selectedFilters);
            foreach ($data as $smartyKey => $smartyVariable) {
                $smartyHelper->assign($smartyKey, $smartyVariable);
            }
            $smartyHelper->display(DetailedChargesIndicator::getSmartySubFilename());
        } else {
            Tools::sendNotFoundAccess();
        }
    }
} else {
    Tools::sendUnauthorizedAccess();
}