• R/O
  • SSH
  • HTTPS

mantisbtmonitor: Commit


Commit MetaInfo

Revision29 (tree)
Time2017-09-21 06:32:31
Authorderekwildstar

Log Message

- Obtendo comentários

Change Summary

Incremental Difference

--- trunk/server/index.php (revision 28)
+++ trunk/server/index.php (revision 29)
@@ -92,6 +92,16 @@
9292 ,"Usa o webservice do Mantis para anexar um arquivo a um caso"
9393 );
9494
95+$server->register("getComments"
96+ ,array("aIssueId" => "xsd:integer", "aViewingUserId" => "xsd:integer")
97+ ,array("return" => "xsd:string")
98+ ,false
99+ ,false
100+ ,"rpc"
101+ ,"encoded"
102+ ,"Obtém os comentários do caso passado no parâmetro, desde que o usuário cujo id é passado no segundo parâmetro tenha permissão para visualizá-los"
103+);
104+
95105 $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
96106
97107 $server->service($HTTP_RAW_POST_DATA);
@@ -351,6 +361,60 @@
351361
352362 return $result;
353363 }
364+
365+function getComments($aIssueId, $aViewingUserId) {
366+ global $configurations;
367+
368+ $query = <<<EOS
369+ select but.id
370+ , ust.realname
371+ , date_format(but.last_modified, "%Y-%m-%dT%H:%i:%S-03:00") as last_modified
372+ , if (but.view_state = 50,1,0) as private
373+ , btt.note
374+ from mantis_bugnote_table but
375+ join mantis_user_table ust on but.reporter_id = ust.id
376+ join mantis_bugnote_text_table btt on but.bugnote_text_id = btt.id
377+ where but.bug_id = $aIssueId
378+ and (but.reporter_id = $aViewingUserId or ust.access_level >= but.view_state)
379+order by 1 desc
380+EOS;
381+
382+ $result = "";
383+
384+ /*
385+ <Comments>
386+ <Comment Id="xxxx">
387+ <Reporter>xxx</Reporter>
388+ <Date>xxxx</Date>
389+ <Private>xxxx</Private>
390+ <Note>xxxx</Note>
391+ </Comment>
392+ </Comments>
393+ */
394+
395+
396+ if (($connection = mysql_connect($configurations->getDbHostName(),$configurations->getDbUserName(),$configurations->getDbPassword()))
397+ && (mysql_select_db($configurations->getDbDataBase(),$connection))
398+ && ($dataset = mysql_query($query,$connection))) {
399+ while ($record = mysql_fetch_object($dataset)) {
400+ $note = base64_encode($record->note);
401+
402+ $result .= "<Comment Id=\"{$record->id}\">" .
403+ "<Reporter>{$record->realname}</Reporter>" .
404+ "<Date>{$record->last_modified}</Date>" .
405+ "<Private>{$record->private}</Private>" .
406+ "<Note>{$note}</Note>" .
407+ "</Comment>";
408+ }
409+ }
410+
411+ $result = "<Comments>" . $result . "</Comments>";
412+
413+ return $result;
414+}
415+
416+//echo getComments(66571,238);
417+
354418 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
355419 // Funções wrapper para o webservice do mantis
356420 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
Show on old repository browser