Skip to content

Commit

Permalink
plugin importRelationshipTreeToCommand: save settings
Browse files Browse the repository at this point in the history
allow in cmd dashboard
  • Loading branch information
lbayle committed Jan 12, 2021
1 parent 058faeb commit e8c3383
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 76 deletions.
1 change: 1 addition & 0 deletions classes/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class Config {
const id_schedulerOptions = 'schedulerOptions';
const id_blogPluginOptions = 'blogPluginOptions';
const id_userGroups = 'userGroups';
const id_importRelationshipTreeToCommandOptions = 'importRelationshipTreeToCommandOptions';

const default_timetrackingFilters = "onlyAssignedTo:0,hideResolved:0,hideForbidenStatus:1";
const default_timetrackingForbidenStatusList = "90"; // 90:closed (do not include 'new')
Expand Down
14 changes: 8 additions & 6 deletions import/import_dashboard.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php
require('../include/session.inc.php');
/*
This file is part of CodevTT
Expand All @@ -20,16 +20,16 @@
require('../path.inc.php');

class ImportDashboardController extends Controller {

/**
* @var Logger The logger
*/
private static $logger;
private static $logger;

public static function staticInit() {
self::$logger = Logger::getLogger(__CLASS__);
}

protected function display() {
if (Tools::isConnectedUser()) {

Expand All @@ -38,9 +38,11 @@ protected function display() {

// feed the PluginDataProvider
$pluginDataProvider = PluginDataProvider::getInstance();
$dashboardDomain = IndicatorPluginInterface::DOMAIN_IMPORT_EXPORT;
$pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_SESSION_USER_ID, $this->session_userid);
$pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_TEAM_ID, $this->teamid);
$pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_PROJECT_ID, $project_id);
$pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_DOMAIN, $dashboardDomain);

$dashboardName = 'Import'.$this->teamid;

Expand All @@ -49,7 +51,7 @@ protected function display() {

// create the Dashboard
$dashboard = new Dashboard($dashboardName);
$dashboard->setDomain(IndicatorPluginInterface::DOMAIN_IMPORT_EXPORT);
$dashboard->setDomain($dashboardDomain);
$dashboard->setCategories(array(
IndicatorPluginInterface::CATEGORY_IMPORT,
));
Expand Down
13 changes: 7 additions & 6 deletions management/command_tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private static function getProvisionList(Command $command, int $type = NULL) {

$formatedSummary = str_replace("'", "\'", $prov->getSummary());
$formatedSummary = str_replace('"', "\'", $formatedSummary);

$provArray["$id"] = array(
'id' => $id,
'date' => date("Y-m-d", $prov->getDate()),
Expand All @@ -122,12 +122,12 @@ private static function getProvisionList(Command $command, int $type = NULL) {
private static function getProvisionTotalList(Command $command, $teamCurrency, int $type = NULL) {

$provTotalArray = NULL;

// compute data
$provisions = $command->getProvisionList($type);

if (!empty($provisions)) {

foreach ($provisions as $id => $prov) {

// a provision
Expand Down Expand Up @@ -295,12 +295,12 @@ public static function displayCommand(SmartyHelper $smartyHelper, Command $cmd,
$cmdIssueSel = $cmd->getIssueSelection();
$smartyHelper->assign('cmdNbIssues', $cmdIssueSel->getNbIssues());
$smartyHelper->assign('cmdIssues', self::getCommandIssues($cmd));

// used to create mantis link to view_all_bug_page.php:
// view_all_set.php?type=1&temporary=y&FilterBugList_list=5079,5073,5108,5107,49396,5006
#$mantisFilterBugList= implode(',', array_keys($cmdIssueSel->getIssueList()));
#$smartyHelper->assign('mantisFilterBugList', $mantisFilterBugList);

}

/**
Expand Down Expand Up @@ -341,6 +341,7 @@ public static function dashboardSettings(SmartyHelper $smartyHelper, Command $cm
IndicatorPluginInterface::CATEGORY_PLANNING,
IndicatorPluginInterface::CATEGORY_RISK,
IndicatorPluginInterface::CATEGORY_FINANCIAL,
IndicatorPluginInterface::CATEGORY_IMPORT,
));
$dashboard->setTeamid($cmd->getTeamid());
$dashboard->setUserid($userid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ImportRelationshipTreeToCommand extends IndicatorPluginAbstract {
const OPTION_IS_ROOT_TASK_LIST = 'isRootTaskList';
const OPTION_IS_INCLUDE_PARENT_ISSUE = 'isIncludeParentIssue';
const OPTION_IS_INCLUDE_PARENT_IN_ITS_OWN_WBS = 'isIncludeParentInItsOwnWbsFolder';
const OPTION_IS_RESET_WBS = 'isResetWBS'; // remove all tasks & folders before the import (full reload)

private static $logger;
private static $domains;
Expand All @@ -41,7 +42,7 @@ class ImportRelationshipTreeToCommand extends IndicatorPluginAbstract {
private $teamId;
private $issueId;
private $bugidList;
private $commandId;
private $commandId = 0;
private $command;
private $isRootTaskList;
private $isIncludeParentIssue;
Expand All @@ -50,6 +51,7 @@ class ImportRelationshipTreeToCommand extends IndicatorPluginAbstract {
// internal
private $sessionUserId;
protected $execData;
private $domain;


/**
Expand All @@ -61,6 +63,7 @@ public static function staticInit() {

self::$domains = array (
self::DOMAIN_IMPORT_EXPORT,
self::DOMAIN_COMMAND,
);
self::$categories = array (
self::CATEGORY_IMPORT
Expand Down Expand Up @@ -123,6 +126,27 @@ public function initialize(PluginDataProviderInterface $pluginDataProv) {
} else {
throw new Exception("Missing parameter: " . PluginDataProviderInterface::PARAM_TEAM_ID);
}

if (NULL != $pluginDataProv->getParam(PluginDataProviderInterface::PARAM_DOMAIN)) {
$this->domain = $pluginDataProv->getParam(PluginDataProviderInterface::PARAM_DOMAIN);
} else {
throw new Exception('Missing parameter: '.PluginDataProviderInterface::PARAM_DOMAIN);
}
switch ($this->domain) {
case IndicatorPluginInterface::DOMAIN_IMPORT_EXPORT:
// none
break;
case IndicatorPluginInterface::DOMAIN_COMMAND:
if (NULL != $pluginDataProv->getParam(PluginDataProviderInterface::PARAM_COMMAND_ID)) {
$this->commandId = $pluginDataProv->getParam(PluginDataProviderInterface::PARAM_COMMAND_ID);
} else {
throw new Exception('Missing parameter: '.PluginDataProviderInterface::PARAM_COMMAND_ID);
}
break;
default:
throw new Exception('Missing parameter related to domain : '.$this->domain);
}

$this->isRootTaskList = false;
$this->isIncludeParentIssue = false;
$this->isIncludeParentInItsOwnWbsFolder = true;
Expand Down Expand Up @@ -257,6 +281,35 @@ private function addChild($issueId, $wbsRootId, $wbsParentId) {
return $strActionLogs;
}

private function getCommandOptions($commandId = 0) {

// default values
$cmdOptions = array(
'isRootTaskList' => 0, // determinates selected radioButton
'bugidList' => '', // comma separated bugId list
'isIncludeParentIssue' => 0,
'isIncludeParentInItsOwnWbsFolder' => 1,
);

if (0 !== $commandId) {
$keyExists = Config::keyExists(Config::id_importRelationshipTreeToCommandOptions, array(0, 0, 0, 0, 0, $commandId));
if (false != $keyExists) {
$jsonOptions = Config::getValue(Config::id_importRelationshipTreeToCommandOptions, array(0, 0, 0, 0, 0, $commandId), true);
if (null != $jsonOptions) {
$options = json_decode($jsonOptions, true);
if (is_null($options)) {
self::$logger->error('ERROR: could not read settings for command '.$commandId);
} else {
$cmdOptions = $options;
$cmdOptions['isRootTaskList'] = 1; // use this option even if only one issue
}
}
}
}
//self::$logger->error("cmdOptions $commandId = ".var_export($cmdOptions, true));
return $cmdOptions;
}

/**
*
*/
Expand All @@ -265,16 +318,21 @@ public function execute() {
// check sesionUser must be Manager !
$sessionUser = UserCache::getInstance()->getUser($this->sessionUserId);
$accessDenied = $sessionUser->isTeamManager($this->teamId) ? '0' : '1';
$team = TeamCache::getInstance()->getTeam($this->teamId);

// --- get command list
$team = TeamCache::getInstance()->getTeam($this->teamId);
$cmdList= $team->getCommands();
$teamCommands = array();
foreach($cmdList as $cmdId => $cmd) {
$teamCommands[$cmdId] = $cmd->getName();
if (IndicatorPluginInterface::DOMAIN_COMMAND === $this->domain) {
$cmd = CommandCache::getInstance()->getCommand($this->commandId);
$teamCommands[$this->commandId] = $cmd->getName();
} else {
$teamCommands[0] = ' '; // default: none selected
$cmdList= $team->getCommands();
foreach($cmdList as $cmdId => $cmd) {
$teamCommands[$cmdId] = $cmd->getName();
}
}


// --- get all tasks (regularProjects + sidetasksProjects)
$hideStatusAndAbove = 0;
$isHideResolved = false;
Expand All @@ -294,9 +352,12 @@ public function execute() {
'teamCommands' => $teamCommands,
'taskList' => $taskList,
'accessDenied' => $accessDenied,
);
return $this->execData;
);

// preset Cmd default values
$cmdOpts = $this->getCommandOptions($this->commandId);
$this->execData = array_merge($this->execData, $cmdOpts);
return $this->execData;
}

/**
Expand All @@ -309,18 +370,20 @@ public function getSmartyVariables($isAjaxCall = false) {
$prefix='ImportRelationshipTreeToCommand_';

$taskListSmarty = SmartyTools::getSmartyArray($this->execData['taskList'], $this->issueId);
$cmdListSmarty = SmartyTools::getSmartyArray($this->execData['teamCommands'], $this->commandId);


$smartyVariables = array(
$prefix.'teamCommands' => $this->execData['teamCommands'],
$prefix.'taskList' => $taskListSmarty,
$prefix.'accessDenied' => $this->execData['accessDenied'],
);
$smartyVariables = array();
foreach($this->execData as $key => $data) {
$smartyVariables[$prefix.$key] = $data;
}
$smartyVariables[$prefix.'taskList'] = $taskListSmarty; // override
$smartyVariables[$prefix.'teamCommands'] = $cmdListSmarty; // override

if (false == $isAjaxCall) {
$smartyVariables[$prefix.'ajaxFile'] = self::getSmartySubFilename();
$smartyVariables[$prefix.'ajaxPhpURL'] = self::getAjaxPhpURL();
}
//self::$logger->error("smartyVariables = ".var_export($smartyVariables, true));
return $smartyVariables;
}

Expand Down
Loading

0 comments on commit e8c3383

Please sign in to comment.