1<?php 2// Copyright 2012 Andreas Parschalk 3 4// This program is free software: you can redistribute it and/or modify 5// it under the terms of the GNU General Public License as published by 6// the Free Software Foundation, either version 3 of the License, or 7// (at your option) any later version. 8 9// This program is distributed in the hope that it will be useful, 10// but WITHOUT ANY WARRANTY; without even the implied warranty of 11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12// GNU General Public License for more details. 13 14// You should have received a copy of the GNU General Public License 15// along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17class BzBug { 18 private $id; 19 private $product; 20 private $shortDesc; 21 private $dateCreated; 22 private $assignedTo; 23 private $reportedBy; 24 private $status; 25 private $priority; 26 private $severity; 27 28 public function getId() { 29 return $this->id; 30 } 31 public function getProduct() { 32 return $this->product; 33 } 34 public function getShortDesc() { 35 return $this->shortDesc; 36 } 37 public function getDateCreated() { 38 return $this->dateCreated; 39 } 40 public function getAssignedTo() { 41 return $this->assignedTo; 42 } 43 public function getReportedBy() { 44 return $this->reportedBy; 45 } 46 public function getStatus() { 47 return $this->status; 48 } 49 public function getPriority() { 50 return $this->priority; 51 } 52 public function getSeverity() { 53 return $this->severity; 54 } 55 56 public function setId($id) { 57 return $this->id = $id; 58 } 59 public function setProduct($p) { 60 return $this->product = $p; 61 } 62 public function setShortDesc($d) { 63 return $this->shortDesc = $d; 64 } 65 public function setDateCreated($d) { 66 return $this->dateCreated = $d; 67 } 68 public function setAssignedTo($a) { 69 return $this->assignedTo = $a; 70 } 71 public function setReportedBy($r) { 72 return $this->reportedBy = $r; 73 } 74 public function setStatus($s) { 75 return $this->status = $s; 76 } 77 public function setPriority($p) { 78 return $this->priority = $p; 79 } 80 public function setSeverity($s) { 81 return $this->severity = $s; 82 } 83 84 85 public function unmarshall($xmlBugString) { 86 $bugArray = array(); 87 try { 88 $xml = simplexml_load_string($xmlBugString); 89 $bugs = $xml->bug; 90 //echo "FETCHED ".sizeof($bugs). "BUGS!<br /><br />"; 91 foreach ($bugs as $bug) { 92 93 $b = new BzBug(); 94 $b->setId((string)$bug->bug_id); 95 $b->setDateCreated((string)$bug->creation_ts); 96 $b->setAssignedTo((string)$bug->assigned_to); 97 $b->setReportedBy((string)$bug->reporter); 98 $b->setShortDesc((string)$bug->short_desc); 99 $b->setProduct((string)$bug->product); 100 $b->setStatus((string)$bug->bug_status); 101 $b->setSeverity((string)$bug->bug_severity); 102 $b->setPriority((string)$bug->priority); 103 $bugArray[] = $b; 104 } 105 } catch (Exception $e) { 106 //invalid xml string 107 die("ERROR unmarshalling xml from bugzilla:".$e->getMessage()); 108 } 109 return $bugArray; 110 } 111} 112?> 113