diff --git a/lib/api/xmlrpc/v1/APIErrors.php b/lib/api/xmlrpc/v1/APIErrors.php
index be4b018d73..7921f72477 100644
--- a/lib/api/xmlrpc/v1/APIErrors.php
+++ b/lib/api/xmlrpc/v1/APIErrors.php
@@ -364,6 +364,8 @@
*/
define('ITS_NOT_FOUND',13000);
define('ITS_NOT_FOUND_STR', lang_get('API_ITS_NOT_FOUND',null,1));
+define('NO_ITSID', 13001);
+define('NO_ITSID_STR', lang_get('API_NO_ITSID',null,1));
/**
* 14000 level - Users
diff --git a/lib/api/xmlrpc/v1/sample_clients/php/clientCreateIssueTrackerSystem.php b/lib/api/xmlrpc/v1/sample_clients/php/clientCreateIssueTrackerSystem.php
new file mode 100644
index 0000000000..d51533d0e0
--- /dev/null
+++ b/lib/api/xmlrpc/v1/sample_clients/php/clientCreateIssueTrackerSystem.php
@@ -0,0 +1,43 @@
+
+USERNAME
+PASSWORD
+http://bugzilla.mozilla.org/
+
+BUGZILLA PRODUCT
+BUGZILLA PRODUCT
+
+
+";
+
+$debug=true;
+$client = new IXR_Client($server_url);
+$client->debug=$debug;
+$answer = runTest($client,$method,$args);
\ No newline at end of file
diff --git a/lib/api/xmlrpc/v1/sample_clients/php/clientRemoveTestProjectITS.php b/lib/api/xmlrpc/v1/sample_clients/php/clientRemoveTestProjectITS.php
new file mode 100644
index 0000000000..f6f7b48aa8
--- /dev/null
+++ b/lib/api/xmlrpc/v1/sample_clients/php/clientRemoveTestProjectITS.php
@@ -0,0 +1,27 @@
+debug=$debug;
+$answer = runTest($client,$method,$args);
\ No newline at end of file
diff --git a/lib/api/xmlrpc/v1/sample_clients/php/clientSetTestProjectITS.php b/lib/api/xmlrpc/v1/sample_clients/php/clientSetTestProjectITS.php
new file mode 100644
index 0000000000..9cb2b49574
--- /dev/null
+++ b/lib/api/xmlrpc/v1/sample_clients/php/clientSetTestProjectITS.php
@@ -0,0 +1,28 @@
+debug=$debug;
+$answer = runTest($client,$method,$args);
\ No newline at end of file
diff --git a/lib/api/xmlrpc/v1/sample_clients/php/clientUpdateIssueTrackerSystem.php b/lib/api/xmlrpc/v1/sample_clients/php/clientUpdateIssueTrackerSystem.php
new file mode 100644
index 0000000000..31635dda27
--- /dev/null
+++ b/lib/api/xmlrpc/v1/sample_clients/php/clientUpdateIssueTrackerSystem.php
@@ -0,0 +1,44 @@
+
+USERNAME
+PASSWORD
+http://my.bugzilla.org/
+
+BUGZILLA PRODUCT
+BUGZILLA PRODUCT
+
+
+";
+
+$debug=true;
+$client = new IXR_Client($server_url);
+$client->debug=$debug;
+$answer = runTest($client,$method,$args);
\ No newline at end of file
diff --git a/lib/api/xmlrpc/v1/sample_clients/php/util.php b/lib/api/xmlrpc/v1/sample_clients/php/util.php
index c726286edf..be16440998 100644
--- a/lib/api/xmlrpc/v1/sample_clients/php/util.php
+++ b/lib/api/xmlrpc/v1/sample_clients/php/util.php
@@ -24,7 +24,7 @@ function show_api_db_sample_msg()
function runTest(&$client,$method,$args,$feedback_id=1)
{
- echo __FUNCTION__ . '
';
+ echo __FUNCTION__ . ' -> ' . $method . '
';
new dBug($args);
$html_id="result_{$feedback_id}";
diff --git a/lib/api/xmlrpc/v1/xmlrpc.class.php b/lib/api/xmlrpc/v1/xmlrpc.class.php
index 7e6847f8f6..47fd756263 100644
--- a/lib/api/xmlrpc/v1/xmlrpc.class.php
+++ b/lib/api/xmlrpc/v1/xmlrpc.class.php
@@ -227,6 +227,10 @@ class TestlinkXMLRPCServer extends IXR_Server {
public static $testCaseVersionParamName = "tcversion";
public static $itsNameParamName = "itsname";
public static $itsEnabledParamName = "itsenabled";
+ public static $itsTypeParamName = "type";
+ public static $itsCfgParamName = "cfg";
+ public static $itsIDParamName ="itsid";
+
public static $copyTestersFromBuildParamName = "copytestersfrombuild";
/**
@@ -845,6 +849,31 @@ protected function checkTestSuiteID($messagePrefix = '') {
return $status;
}
+ /**
+ * Helper method to see if the ItsID provided is valid
+ *
+ * This is the only method that should be called directly to check the ItsID
+ *
+ * @param string $messagePrefix
+ * used to be prepended to error message
+ *
+ * @return boolean
+ * @access protected
+ */
+ protected function checkItsID($messagePrefix = '') {
+ $status = true;
+ if(! $this->_isItsIDPresent()) {
+ $this->errors[] = new IXR_Error( NO_ITSID, $messagePrefix . NO_ITSID_STR );
+ $status = false;
+ } else {
+ // See if this ITS ID exists in the db
+ $its = $this->getITSMgr()->getByID( $this->args[self::$itsIDParamName] );
+ $status = ! is_null($its);
+ }
+
+ return $status;
+ }
+
/**
* Helper method to see if the guess is set
*
@@ -987,6 +1016,17 @@ protected function _isTestCaseExternalIDPresent() {
return $status;
}
+ /**
+ * Helper method to see if an itsid is given as one of the arguments
+ *
+ * @return boolean
+ * @access protected
+ */
+ protected function _isItsIDPresent() {
+ $status = isset( $this->args[self::$itsIDParamName] ) ? true : false;
+ return $status;
+ }
+
/**
* Helper method to see if:
* a timestamp is given as one of the arguments
@@ -1425,6 +1465,18 @@ protected function _getLatestBuildForTestPlan($args) {
return $maxbuild;
}
+ /**
+ * ITS manager getter
+ *
+ */
+ private function getITSMgr() {
+ if(is_null( $this->itsMgr )) {
+ $this->itsMgr = new tlIssueTracker( $this->dbObj );
+ }
+
+ return $this->itsMgr;
+ }
+
/**
* Gets the result of LAST EXECUTION for a particular testcase on a test plan.
* If there are no filter criteria regarding platform and build,
@@ -2095,7 +2147,6 @@ public function createTestProject($args) {
$its = null;
if($optional[self::$itsNameParamName] != "") {
- $this->itsMgr = new tlIssueTracker( $this->dbObj );
$its = $this->getIssueTrackerSystem( $this->args, 'internal' );
$itsOK = ! is_null( $its );
@@ -2112,7 +2163,7 @@ public function createTestProject($args) {
// link & enable its?
if($itsOK && $tproject_id > 0) {
// link
- $this->itsMgr->link( $its["id"], $tproject_id );
+ $this->getITSMgr()->link( $its["id"], $tproject_id );
// enable
if($optional[self::$itsEnabledParamName] > 0) {
@@ -8347,12 +8398,7 @@ public function getIssueTrackerSystem($args, $call = null) {
}
}
- $ret = null;
- if(is_null( $this->itsMgr )) {
- $this->itsMgr = new tlIssueTracker( $this->dbObj );
- }
-
- $ret = $this->itsMgr->getByName( $this->args[self::$itsNameParamName] );
+ $ret = $this->getITSMgr()->getByName( $this->args[self::$itsNameParamName] );
$status_ok = ! is_null( $ret );
if(! $status_ok) {
$msg = $msg_prefix . sprintf( ITS_NOT_FOUND_STR, $this->args[self::$itsNameParamName] );
@@ -8954,6 +9000,202 @@ protected function _updateStepsResult($execID = null) {
return $xx;
}
+
+ /**
+ * Create an Issue Tracker System
+ *
+ * @param struct $args
+ * @param string $args["devKey"]
+ * @param string $args["itsname"] ITS name
+ * @param string $args["type"] ITS type
+ * @param string $args["cfg"] ITS config
+ *
+ * @access public
+ * @since 1.9.20
+ */
+ public function createIssueTrackerSystem($args) {
+ $operation=__FUNCTION__;
+ $msg_prefix="({$operation}) - ";
+
+ $this->_setArgs($args);
+
+ $params = array(self::$itsNameParamName,
+ self::$itsTypeParamName,
+ self::$itsCfgParamName);
+
+ $missingArg = false;
+ foreach($params as $param) {
+ $missingArg = $missingArg || ! $this->_isParamPresent($param, $msg_prefix, true);
+ }
+ if ($missingArg) {
+ return $this->errors;
+ }
+
+ if ($this->authenticate($msg_prefix) &&
+ $this->userHasRight("issuetracker_management", self::CHECK_PUBLIC_PRIVATE_ATTR)) {
+
+ $item = new stdClass();
+ $item->name = $this->args[self::$itsNameParamName];
+ $item->type = $this->args[self::$itsTypeParamName];
+ $item->cfg = $this->args[self::$itsCfgParamName];
+
+ return $this->getITSMgr()->create($item);
+ } else {
+ return $this->errors;
+ }
+
+ }
+
+
+ /**
+ * Update Issue Tracker System
+ *
+ * @param struct $args
+ * @param string $args["devKey"]
+ * @param string $args["itsid"] ITS ID
+ * @param string $args["itsname"] ITS name
+ * @param string $args["type"] ITS type
+ * @param string $args["cfg"] ITS config
+ *
+ * @access public
+ * @since 1.9.20
+ */
+ public function updateIssueTrackerSystem($args) {
+ $operation=__FUNCTION__;
+ $msg_prefix="({$operation}) - ";
+
+ $this->_setArgs($args);
+
+ $params = array(self::$itsNameParamName,
+ self::$itsTypeParamName,
+ self::$itsCfgParamName);
+
+ $missingArg = false;
+ foreach($params as $param) {
+ $missingArg = $missingArg || ! $this->_isParamPresent($param, $msg_prefix, true);
+ }
+ if ($missingArg) {
+ return $this->errors;
+ }
+
+ $checkFunctions = array('authenticate',
+ 'checkItsID');
+
+ if ($this->_runChecks($checkFunctions, $msg_prefix) &&
+ $this->userHasRight("issuetracker_management", self::CHECK_PUBLIC_PRIVATE_ATTR)) {
+
+ $item = new stdClass();
+ $item->id = $this->args[self::$itsIDParamName];
+ $item->name = $this->args[self::$itsNameParamName];
+ $item->type = $this->args[self::$itsTypeParamName];
+ $item->cfg = $this->args[self::$itsCfgParamName];
+
+ return $this->getITSMgr()->update($item);
+
+ } else {
+ return $this->errors;
+ }
+
+ }
+
+ /**
+ * Set link between a project and an ITS
+ *
+ * @param struct $args
+ * @param string $args["devKey"]
+ * @param string $args["itsid"] ITS ID
+ * @param string $args["testprojectid"] Project ID
+ * @param boolean $args["itsenabled"] Enable the ITS or not
+ * OPTIONAL default is false
+ *
+ * @access public
+ * @since 1.9.20
+ */
+ public function setTestProjectITS($args) {
+ $operation=__FUNCTION__;
+ $msg_prefix="({$operation}) - ";
+
+ $this->_setArgs($args);
+
+ $checkFunctions = array('authenticate',
+ 'checkTestProjectID',
+ 'checkItsID');
+
+ if($this->_runChecks($checkFunctions, $msg_prefix) && $this->userHasRight( "mgt_modify_product" )) {
+
+ $itsID = intval($this->args[self::$itsIDParamName]);
+ $projectID = intval($this->args[self::$testProjectIDParamName]);
+
+ $this->getITSMgr()->link($itsID, $projectID);
+ $resultInfo = array();
+ $resultInfo[]= array("operation" => "link ITS",
+ "additionalInfo" => "ITS ID " . $itsID,
+ "status" => true,
+ "id" => $projectID,
+ "message" => GENERAL_SUCCESS_STR);
+
+ // enable the ITS if needed
+ $isEnabled = false;
+ if ($this->_isParamPresent(self::$itsEnabledParamName)) {
+ $isEnabled = ($this->args[self::$itsEnabledParamName]);
+ }
+
+ if ($isEnabled) {
+ $this->tprojectMgr->enableIssueTracker($projectID);
+ $resultInfo[]= array("operation" => "enable ITS",
+ "additionalInfo" => null,
+ "status" => true,
+ "id" => $projectID,
+ "message" => GENERAL_SUCCESS_STR);
+ }
+
+ return $resultInfo;
+
+ } else {
+ return $this->errors;
+ }
+ }
+
+ /**
+ * Remove the link between a project and an ITS
+ *
+ * @param struct $args
+ * @param string $args["devKey"]
+ * @param string $args["itsid"] ITS ID
+ * @param string $args["testprojectid"] Project ID
+ *
+ * @access public
+ * @since 1.9.20
+ */
+ public function removeTestProjectITS($args) {
+ $operation=__FUNCTION__;
+ $msg_prefix="({$operation}) - ";
+
+ $this->_setArgs($args);
+
+ $checkFunctions = array('authenticate',
+ 'checkTestProjectID');
+
+ if($this->_runChecks($checkFunctions, $msg_prefix) && $this->userHasRight( "mgt_modify_product" )) {
+
+ $itsID = intval($this->args[self::$itsIDParamName]);
+ $projectID = intval($this->args[self::$testProjectIDParamName]);
+
+ $this->getITSMgr()->unlink($itsID, $projectID);
+ $resultInfo = array();
+ $resultInfo[]= array("operation" => "unlink ITS",
+ "status" => true,
+ "id" => $projectID,
+ "message" => GENERAL_SUCCESS_STR);
+
+ return $resultInfo;
+
+ } else {
+ return $this->errors;
+ }
+ }
+
+
/**
*/
function initMethodYellowPages() {
@@ -8984,6 +9226,10 @@ function initMethodYellowPages() {
'tl.removePlatformFromTestPlan' => 'this:removePlatformFromTestPlan',
'tl.getExecCountersByBuild' => 'this:getExecCountersByBuild',
'tl.getIssueTrackerSystem' => 'this:getIssueTrackerSystem',
+ 'tl.createIssueTrackerSystem' => 'this:createIssueTrackerSystem',
+ 'tl.updateIssueTrackerSystem' => 'this:updateIssueTrackerSystem',
+ 'tl.setTestProjectITS' => 'this:setTestProjectITS',
+ 'tl.removeTestProjectITS' => 'this:removeTestProjectITS',
'tl.getProjects' => 'this:getProjects',
'tl.getProjectKeywords' => 'this:getProjectKeywords',
'tl.getProjectPlatforms' => 'this:getProjectPlatforms',
diff --git a/locale/en_GB/strings.txt b/locale/en_GB/strings.txt
index b67e0c3c9c..73916ce23d 100644
--- a/locale/en_GB/strings.txt
+++ b/locale/en_GB/strings.txt
@@ -3162,6 +3162,7 @@ $TLS_API_NO_TESTSUITEID = "No testsuiteid provided.";
$TLS_API_NO_TPID = "No testplan ID (testplanid) provided.";
$TLS_API_NO_TCID = "No testcase ID (testcaseid) provided.";
$TLS_API_NO_PLATFORMID = "No Platform ID (platformid) provided.";
+$TLS_API_NO_ITSID = "No Issue Tracker System ID (itsid) provided.";
$TLS_API_NO_USERID = "No user ID (userid) provided.";
$TLS_API_NO_ROLEID = "No role ID (roleid) provided.";
diff --git a/locale/fr_FR/strings.txt b/locale/fr_FR/strings.txt
index 32fd01453b..64db224d5c 100644
--- a/locale/fr_FR/strings.txt
+++ b/locale/fr_FR/strings.txt
@@ -3162,6 +3162,7 @@ $TLS_API_NO_TESTSUITEID = "Aucun ID de dossier de test fourni.";
$TLS_API_NO_TPID = "Aucun ID de campagne de test fourni.";
$TLS_API_NO_TCID = "Aucun ID de fiche de test fourni.";
$TLS_API_NO_PLATFORMID = "Aucun ID de plateforme fourni.";
+$TLS_API_NO_ITSID = "Aucun ID de gestionnaire d’anomalie (itsid) fourni.";
$TLS_API_NO_USERID = "Aucun ID utilisateur fourni.";
$TLS_API_NO_ROLEID = "Aucun ID de rĂ´le fourni.";