jedi58 / FogbugzIntegration

A PHP class for interacting with the FogBugz API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FogbugzIntegration

A PHP class for interacting with the FogBugz API. FogBugz is issue tracking software developed by Fogcreek (Joel Spolsky). In their own words:

Used by over 20,000 software development teams for issue and bug tracking, project planning and management, collaboration and time tracking. All in one place.

The idea behind this class is that you can use this to pull out information to be used on your own website(s), or have your own web applications interact with it.

Usage

Below are examples for using this class.

  1. Connecting to FogBugz
  2. Closing the API connection
  3. Creating a new issue
  4. Updating an existing issue
  5. Reopening an issue
  6. Resolving an issue
  7. Closing an issue
  8. Retrieving an issue
  9. Searching for an issue
  10. Using filters
  11. Retrieving a list of projects
  12. Retrieving a list of available priorities
  13. Retrieving a list of available areas for a project
  14. Retrieving a list of available issue categories
  15. Retrieving a list of available filters
  16. Retrieve ticket status

Connecting to FogBugz

All requests to the FogBugz API must be authenticated. Unfortunately they do this using a plaintext password (so will appear in the server logs on the remote server - something to bear in mind if you host this yourself).

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');

This will then give you a new FogbugzIntegration object which can be used to make API calls to retrieve or set data.

Closing the API connection

$fb->logout();

Creating a new issue

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$issue_id = $fb->openTicket('My new issue', 'It does not work - please fix');

The openTicket function takes as arguments the title of the issue, a description about it, then an optional array for setting additional properties such as project, area, priority, etc.

Updating an existing issue

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$fb->updateTicket(1, 'An update to my ticket');

As with openTicket, the updateTicket function will take an optional array as it's last parameter for setting other case properties. The only mandatory parameters are for specifying the ticket ID, and the updated message to apply to it. If successful it will return the ID of the ticket.

Reopening an issue

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$fb->reopenTicket(1);

To reopen an issue pass in the ID of the ticket. This too will take an optional array as it's last parameter for setting other case properties. If successful it will return the ID of the ticket.

Resolving an issue

This will mark a ticket as resolved, but will not close it.

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$fb->resolveTicket(1);

If successful it will return the ID of the ticket.

Closing an issue

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$fb->closeTicket(1);

If successful it will return the ID of the ticket.

Retrieving an issue

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$issue = $fb->getTicket(1);

Returns a SimpleXML object containing all details for the issue

Searching for an issue

It is also possible to search for cases by a keyword.

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$issue = $fb->search('example');

This returns a SimpleXML object containing all details for the issue

Using filters

Filters defined in FogBugz can also be utilised if they are available to the user who is signed in to the API.

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$issue = $fb->setFilter(1);

Retrieving a list of projects

The result of this is limited to what the user signed into the API has access to.

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$projects = $fb->getProjectList();

This will retrieve an array where each element is an array of the project name and owner, and is indexed by the ID of the project. Passing in true to this function will return the raw SimpleXML output from the API instead.

Retrieving a list of available priorities

The result of this is limited to what the user signed into the API has access to.

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$priorities = $fb->getAllPriorities();

This will retrieve an array where each element is an array of the priority name and a flag indicating if it's the default, and is indexed by the ID of the priority. Passing in true to this function will return the raw SimpleXML output from the API instead.

Retrieving a list of available areas for a project

The result of this is limited to what the user signed into the API has access to.

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$areas = $fb->getAllAreas(1);

This will retrieve an array where each element is an array of area names indexed by the ID of the area.

Retrieving a list of available issue categories

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$categories = $fb->getAllCategories();

This will retrieve an array where each element is an array of issue categories indexed by the ID of the category.

<a name="getFilters>

Retrieving a list of available filters

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$categories = $fb->getAllFilters();

Retrieve ticket status

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$status = getTicketStatus(1);

This will return the specified status as a SimpleXML element.

Retrieve a list of FogBugz Users for the current install

With FogBugz you have three types of users: normal, virtual, and community. The below example will return normal and virtual users, but will ignore community users.

$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$users = $fb->getAllFogbugzUsers(true, true, false);

This will return an array of users indexed by their ID and containing their name and email address.

About

A PHP class for interacting with the FogBugz API

License:MIT License


Languages

Language:PHP 100.0%