Overview

Packages

  • None
  • Sesha

Classes

  • Horde_Core_UI_VarRenderer_Stockedit_Html
  • Sesha
  • Sesha_Api
  • Sesha_Driver
  • Sesha_Driver_Sql
  • Sesha_Exception
  • Sesha_Forms_Category
  • Sesha_Forms_CategoryDelete
  • Sesha_Forms_CategoryList
  • Sesha_Forms_Property
  • Sesha_Forms_PropertyDelete
  • Sesha_Forms_PropertyList
  • Sesha_Forms_Search
  • Sesha_Forms_Stock
  • Sesha_Forms_Type_Client
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Sesha external API interface.
  4:  *
  5:  * Copyright 2003-2011 Horde LLC (http://www.horde.org/)
  6:  *
  7:  * This file defines Sesha's external API interface. Other applications can
  8:  * interact with Sesha through this API.
  9:  *
 10:  * @author  Bo Daley <bo@darkwork.net>
 11:  * @package Sesha
 12:  */
 13: 
 14: class Sesha_Api extends Horde_Registry_Api
 15: {
 16: 
 17:    /**
 18:     * List all available categories as queues
 19:     * @return array
 20:     */
 21:     public function listQueues()
 22:     {
 23:         $queues = array();
 24:         $categories = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create()->getCategories();
 25:         foreach ($categories as $category) {
 26:             $queues[$category['category_id']] = $category['category'];
 27:         }
 28:         asort($queues);
 29: 
 30:         return $queues;
 31:     }
 32: 
 33:    /**
 34:     * Retrieve queue details - this is for ticketing integration
 35:     *
 36:     * @param string $queue_id The id of the queue to retrieve
 37:     *
 38:     * @return array
 39:     */
 40:     public function getQueueDetails($queue_id)
 41:     {
 42:         global $registry;
 43: 
 44:         $category = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create()->getCategory($queue_id);
 45: 
 46:         return array('id' => $queue_id,
 47:                  'name' => $category['category'],
 48:                  'description' => $category['description'],
 49:                  'link' => Horde_Util::addParameter(Horde::url('list.php', true), 'display_category', $queue_id - 1, false),
 50:                  'subjectlist' => $GLOBALS['conf']['tickets']['subjects'],
 51:                  'versioned' => $registry->hasMethod('tickets/listVersions') == $registry->getApp(),
 52:                  'readonly' => true);
 53:     }
 54: 
 55:    /**
 56:     * List all versions for the queue
 57:     *
 58:     * @param string $queue_id The id of the queue
 59:     *
 60:     * @return array $versions List of versions
 61:     */
 62:     public function listVersions($queue_id)
 63:     {
 64:         $inventory = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create()->listStock($queue_id);
 65:         $versions = array();
 66:         foreach ($inventory as $item) {
 67:         $versions[] = array('id' => $item['stock_id'],
 68:                             'name' => $item['stock_name'],
 69:                             'description' => $item['note'],
 70:                             'readonly' => true);
 71:         }
 72:         Horde_Array::arraySort($versions, 'name', 0, false);
 73: 
 74:         return $versions;
 75:     }
 76: 
 77:    /**
 78:     * Retrieve item version details 
 79:     *
 80:     * @param string $version_id The id of the version to retrieve
 81:     *
 82:     * @throws Sesha_Exception
 83:     * @return array
 84:     */
 85:     public function getVersionDetails($version_id)
 86:     {
 87:         global $registry;
 88: 
 89:         try {
 90:             $item = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create()->fetch($version_id);
 91:         } catch (Sesha_Exception $e) {
 92:             return array();
 93:         }
 94:         return array('id' => $version_id,
 95:                  'name' => $item['stock_name'],
 96:                  'description' => $item['note'],
 97:                  'link' => Horde_Util::addParameter(Horde::url('stock.php', true), array('stock_id' => $version_id, 'actionId' => 'view_stock'), null, false),
 98:                  'readonly' => true);
 99:     }
100: }
101: 
API documentation generated by ApiGen