• R/O
  • SSH
  • HTTPS

mantisbtmonitor: Commit


Commit MetaInfo

Revision26 (tree)
Time2017-09-07 06:20:38
Authorderekwildstar

Log Message

- Função que chama o método para anexar arquivos a um caso do WebService do Mantis

Change Summary

Incremental Difference

--- trunk/server/configurations.inc.php (revision 25)
+++ trunk/server/configurations.inc.php (revision 26)
@@ -6,8 +6,9 @@
66 private $dbUserName;
77 private $dbPassword;
88 private $rootMantis;
9+ private $mantisConnectWSDL;
910
10- function __construct($pRootMantis) {
11+ function __construct($aRootMantis, $aMantisConnectWSDL) {
1112 $serverName = $_SERVER["SERVER_NAME"];
1213 $serverIp = $_SERVER["HTTP_HOST"];
1314
@@ -17,6 +18,8 @@
1718 $this->dbDataBase = "mantis";
1819 $this->dbUserName = "kanbanmantis";
1920 $this->dbPassword = "K4nb4n!";
21+ $this->rootMantis = $aRootMantis == null?"":$aRootMantis;;
22+ $this->mantisConnectWSDL = $aMantisConnectWSDL == null?"":$aMantisConnectWSDL;
2023 // --------------------------------------------------------------------------------------
2124 } else if ($serverIp == '???.???.???.??' || $serverName == "???.???.???.???") {
2225 // HOMOLOGAÇÃO --------------------------------------------------------------------------
@@ -24,6 +27,8 @@
2427 $this->dbDataBase = "B";
2528 $this->dbUserName = "C";
2629 $this->dbPassword = "D";
30+ $this->rootMantis = $aRootMantis == null?"":$aRootMantis;
31+ $this->mantisConnectWSDL = $aMantisConnectWSDL == null?"":$aMantisConnectWSDL;
2732 // --------------------------------------------------------------------------------------
2833 } else if ($serverIp == '192.168.251.88' || $serverName == "sdwebtjpetemp.tjpe.gov.br") {
2934 // DESENVOLVIMENTO ----------------------------------------------------------------------
@@ -31,12 +36,12 @@
3136 $this->dbDataBase = "mantis_d";
3237 $this->dbUserName = "mantis_des";
3338 $this->dbPassword = "m4nt15";
39+ $this->rootMantis = $aRootMantis == null?"C:\Inetpub\wwwroot\mantis":$aRootMantis;
40+ $this->mantisConnectWSDL = $aMantisConnectWSDL == null?"http://192.168.251.88/mantis/api/soap/mantisconnect.php?wsdl":$aMantisConnectWSDL;
3441 // --------------------------------------------------------------------------------------
3542 }
3643
3744 $this->configurationsFileName = preg_replace('"\.inc.php$"', '.json', __FILE__);
38-
39- $this->rootMantis = $pRootMantis;
4045 }
4146
4247 public function getConfigurationsFileName() {
@@ -74,10 +79,14 @@
7479 public static function load() {
7580 return unserialize(file_get_contents(preg_replace('"\.inc.php$"', '.json', __FILE__)));
7681 }
82+
83+ public function getMantisConnectWSDL() {
84+ return $this->mantisConnectWSDL;
85+ }
7786 }
7887
79-// Carregando valores padrão
80-$configurations = new Configurations("../mantis");
88+// Carregando valores padrão (de acordo com o servidor atual). Vide construtor da classe
89+$configurations = new Configurations(null,null);
8190
8291 // Carregando um arquivo de configurações existente ou salvando o arquivo de configurações com as configurações padrão
8392 if (file_exists($configurations->getConfigurationsFileName())) {
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
--- trunk/server/index.php (revision 25)
+++ trunk/server/index.php (revision 26)
@@ -7,6 +7,7 @@
77 require_once(file_build_path($configurations->getRootMantis(),"core","config_api.php"));
88 require_once(file_build_path($configurations->getRootMantis(),"custom_strings_inc.php"));
99
10+
1011 $server = new soap_server();
1112 $server->soap_defencoding = "UTF-8";
1213 $server->configureWSDL("mnws");
@@ -81,6 +82,16 @@
8182 ,"Retora os dados de um anexo em base64 identificado pelo seu ID"
8283 );
8384
85+$server->register("addAttachment"
86+ ,array("aUserName" => "xsd:string", "aPassword" => "xsd:string", "aIssueId" => "xsd:integer", "aFileName" => "xsd:string", "aMimeType" => "xsd:string", "aBase64Contents" => "xsd:string")
87+ ,array("return" => "xsd:string")
88+ ,false
89+ ,false
90+ ,"rpc"
91+ ,"encoded"
92+ ,"Usa o webservice do Mantis para anexar um arquivo a um caso"
93+);
94+
8495 $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
8596
8697 $server->service($HTTP_RAW_POST_DATA);
@@ -341,5 +352,22 @@
341352 return $result;
342353 }
343354
344-//echo getAttachmentData(2);
355+function addAttachment($aUserName, $aPassword, $aIssueId, $aFileName, $aMimeType, $aBase64Contents) {
356+ global $configurations;
357+
358+ $client = new SoapClient($configurations->getMantisConnectWSDL(),True);
359+
360+ $result = $client->call("mc_issue_attachment_add",array("username"=>$aUserName
361+ ,"password"=>$aPassword
362+ ,"issue_id"=>$aIssueId
363+ ,"name"=>$aFileName
364+ ,"file_type"=>$aMimeType
365+ ,"content"=>$aBase64Contents));
366+
367+ if (!$result) {
368+ $result = $client->responseData;
369+ }
370+
371+ return $result;
372+}
345373 ?>
\ No newline at end of file
Show on old repository browser