| <?php |
| /** |
| * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (http://www.eclipse.org/legal/epl-v10.html). |
| * ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. |
| * |
| */ |
| |
| /** |
| * |
| */ |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/common/xmlwrapper.class.php"); |
| |
| |
| |
| /** |
| * Models a Bug |
| * |
| * Models a Bug reported in the Eclipse Bugzilla bug tracking system. |
| * |
| * @license http://www.eclipse.org/legal/epl-v10.html Eclipse Public License - v 1.0 |
| * @author Eduardo A. Romero |
| */ |
| class Bug { |
| |
| |
| |
| var $bug_id = 0; |
| var $description = ""; |
| var $reporter = ""; |
| var $severity = ""; |
| var $assignee = ""; |
| var $url = ""; |
| var $status = ""; |
| var $resolution = ""; |
| var $priority = ""; |
| var $votes = 0; |
| var $product = ""; |
| var $classification = ""; |
| var $component = ""; |
| |
| /** |
| * @access public |
| * @return integer The bug id as in Bugzilla |
| */ |
| function getBugID() { |
| return $this->bug_id; |
| } |
| /** |
| * @access public |
| * @return string A paragraph describing the bug |
| */ |
| function getDescription() { |
| $ret = "Bug #" . $this->bug_id; |
| if(strlen( $this->description)>0) |
| $ret = $this->description; |
| return $ret; |
| } |
| /** |
| * @access public |
| * @return string The Name of the Person who reported the bug |
| */ |
| function getReporter() { |
| return $this->reporter; |
| } |
| /** |
| * @access public |
| * @return string The Name of the Person working on this bug |
| */ |
| function getAssignee() { |
| return $this->assignee; |
| } |
| /** |
| * @access public |
| * @return string The Severity of the bug, i.e. critical, blocker... |
| */ |
| function getSeverity() { |
| return $this->severity; |
| } |
| |
| /** |
| * @access public |
| * @return string URL The URL field of the bug |
| */ |
| function getUrl() { |
| return $this->url; |
| } |
| /** |
| * @access public |
| * @return string the Status of the bug. i.e. NEW, RESOLVED, OPEN... |
| */ |
| function getStatus() { |
| return $this->status; |
| } |
| |
| /** |
| * @access public |
| * @return string the Resolution of the bug. i.e. FIXED, DUPLICATED... |
| */ |
| function getResolution() { |
| return $this->resolution; |
| } |
| /** |
| * @access public |
| * @return string the Priority of the bug. i.e. P1, P3... |
| */ |
| function getPriority() { |
| return $this->priority; |
| } |
| /** |
| * @access public |
| * @return integer the number of Votes this bug has |
| */ |
| function getVotes() { |
| return $this->votes; |
| } |
| /** |
| * @access public |
| * @return string The product this bug belongs to |
| */ |
| function getProduct() { |
| return $this->product; |
| } |
| /** |
| * @access public |
| * @return string This bug's classification |
| */ |
| function getClassification() { |
| return $this->classification; |
| } |
| /** |
| * @access public |
| * @return string The component this bug belongs to |
| */ |
| function getComponent() { |
| return $this->component; |
| } |
| |
| /** |
| * Sets the ID of this bug |
| * |
| * @access private |
| * @param integer the bug id |
| */ |
| function setBugID($_bug_id) { |
| $this->bug_id = $_bug_id; |
| } |
| /** |
| * Sets the description of the bug |
| * |
| * @access private |
| * @param string the description of the bug |
| */ |
| function setDescription($_description) { |
| $this->description = $_description; |
| } |
| /** |
| * Sets the reporter of the bug |
| * |
| * @access private |
| * @param string The Name of the person who reported the bug |
| */ |
| function setReporter($_reporter) { |
| $this->reporter = $_reporter; |
| } |
| /** |
| * Sets the severity of the bug |
| * |
| * @access private |
| * @param string The Severity of the bug |
| */ |
| function setSeverity($_severity) { |
| $this->severity = $_severity; |
| } |
| /** |
| * Sets the asignee of the bug |
| * @access private |
| * @param string The Name of the person working on this bug |
| */ |
| function setAssignee($_assignee) { |
| $this->assignee = $_assignee; |
| } |
| |
| /** |
| * Sets the URL of the bug, i.e. a page with a more detailed description of the bug |
| * |
| * @access private |
| * @param string The URL |
| */ |
| function setUrl($_url) { |
| $this->url = $_url; |
| } |
| |
| /** |
| * Sets the Status of the bug |
| * |
| * @access private |
| * @param string The Status of the bug |
| */ |
| function setStatus($_status) { |
| $this->status = $_status; |
| } |
| |
| /** |
| * Sets the Resolution of the bug |
| * |
| * @access private |
| * @param string The Resolution of the bug |
| */ |
| function setResolution($_resolution) { |
| $this->resolution = $_resolution; |
| } |
| |
| /** |
| * Sets the Priority of the bug |
| * |
| * @access private |
| * @param string The Priority of the bug |
| */ |
| function setPriority($_priority){ |
| $this->priority = $_priority; |
| } |
| |
| /** |
| * Sets the number of Votes this bug has |
| * |
| * @access private |
| * @param integer The number of votes the bug has |
| */ |
| function setVotes($_votes){ |
| $this->votes = $_votes; |
| } |
| /** |
| * @access public |
| * @return string The product this bug belongs to |
| */ |
| function setProduct($_product) { |
| $this->product = $_product; |
| } |
| /** |
| * @access public |
| * @return string This bug's classification |
| */ |
| function setClassification($_classification) { |
| $this->classification = $_classification; |
| } |
| /** |
| * @access public |
| * @return string The component this bug belongs to |
| */ |
| function setComponent($_component) { |
| $this->component = $_component; |
| } |
| |
| |
| /** |
| * Constructs a new Bug object from the Eclipse Bugzilla bugtracking system given its bug_id. |
| * |
| * Constructs a new Bug object given its Bugzilla bug id. Unless specified, the bug wont include |
| * the number of votes it has. The constructor will populate the object with the information on |
| * the bugs database. |
| * |
| * @access public |
| * @param integer $_bug_id The bug id number, as in the Eclipse Bugzilla bugtracking system. |
| * @param boolean $_get_votes When set to <em>true</em> another query will be executed to calculate the |
| * number of votes this bug has, this is the default behavior. When set to <em>false</em> the votes |
| * information will be set to zero. |
| * |
| */ |
| function Bug($_bug_id, $_get_votes = false) { |
| $url = "http://www.eclipse.org/projects/web-api/bug.php?bug_id=" . urlencode($_bug_id) . "&votes=". urlencode($_get_votes); |
| |
| $lines = file( $url ); |
| if( $lines == false ) return; |
| $contents = implode( "", $lines ); |
| |
| $contents = preg_replace( "/\<\!--.*?--\>/s", "", $contents ); |
| $XMLWrapper = new XMLWrapper($contents); |
| |
| $this->setBugID (html_entity_decode(@ $XMLWrapper->getElement(array('bug','bug')))); |
| $this->setDescription (html_entity_decode(@ $XMLWrapper->getElement(array('bug','description')))); |
| $this->setReporter (html_entity_decode(@ $XMLWrapper->getElement(array('bug','reporter')))); |
| $this->setSeverity (html_entity_decode(@ $XMLWrapper->getElement(array('bug','severity')))); |
| $this->setAssignee (html_entity_decode(@ $XMLWrapper->getElement(array('bug','assignee')))); |
| $this->setUrl (html_entity_decode(@ $XMLWrapper->getElement(array('bug','url')))); |
| $this->setStatus (html_entity_decode(@ $XMLWrapper->getElement(array('bug','status')))); |
| $this->setPriority (html_entity_decode(@ $XMLWrapper->getElement(array('bug','priority')))); |
| $this->setResolution (html_entity_decode(@ $XMLWrapper->getElement(array('bug','resolution')))); |
| $this->setComponent (html_entity_decode(@ $XMLWrapper->getElement(array('bug','component')))); |
| $this->setProduct (html_entity_decode(@ $XMLWrapper->getElement(array('bug','product')))); |
| $this->setClassification(html_entity_decode(@ $XMLWrapper->getElement(array('bug','classification')))); |
| $this->setVotes (html_entity_decode(@ $XMLWrapper->getElement(array('bug','votes')))); |
| |
| } |
| |
| } |
| ?> |