Overview

Packages

  • Horde
    • Form
    • MIME
      • Viewer
    • Scheduler
  • None
  • Whups
    • UnitTests

Classes

  • Whups_Application
  • Whups_Block_Myqueries
  • Whups_Block_Myrequests
  • Whups_Block_Mytickets
  • Whups_Block_Query
  • Whups_Block_Queuecontents
  • Whups_Block_Queuesummary
  • Whups_Block_Unassigned
  • Whups_Driver_sql
  • Whups_Exception
  • Whups_Factory_Driver
  • Whups_Form_AddListener
  • Whups_Form_DeleteListener
  • Whups_Form_Queue_StepOne
  • Whups_Form_Queue_StepThree
  • Whups_Form_Queue_StepTwo
  • Whups_Form_Renderer_Query
  • Whups_Form_SetTypeStepOne
  • Whups_Form_SetTypeStepTwo
  • Whups_Form_Ticket_Delete
  • Whups_Test_Perms
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Show the open tickets in a queue.
  4:  */
  5: class Whups_Block_Queuecontents extends Horde_Core_Block
  6: {
  7:     /**
  8:      */
  9:     public function __construct($app, $params = array())
 10:     {
 11:         parent::__construct($app, $params);
 12: 
 13:         $this->_name = _("Queue Contents");
 14:     }
 15: 
 16:     /**
 17:      */
 18:     protected function _params()
 19:     {
 20:         global $whups_driver;
 21: 
 22:         $qParams = array();
 23:         $qDefault = null;
 24:         $qParams = Whups::permissionsFilter($whups_driver->getQueues(), 'queue', Horde_Perms::READ);
 25:         if (!$qParams) {
 26:             $qDefault = _("No queues available.");
 27:             $qType = 'error';
 28:         } else {
 29:             $qType = 'enum';
 30:         }
 31: 
 32:         return array(
 33:             'queue' => array(
 34:                 'type' => $qType,
 35:                 'name' => _("Queue"),
 36:                 'default' => $qDefault,
 37:                 'values' => $qParams,
 38:             )
 39:         );
 40:     }
 41: 
 42:     /**
 43:      */
 44:     protected function _title()
 45:     {
 46:         if ($queue = $this->_getQueue()) {
 47:             return sprintf(_("Open Tickets in %s"), htmlspecialchars($queue['name']));
 48:         }
 49: 
 50:         return $this->getName();
 51:     }
 52: 
 53:     /**
 54:      */
 55:     protected function _content()
 56:     {
 57:         global $whups_driver, $prefs;
 58: 
 59:         if (!($queue = $this->_getQueue())) {
 60:             return '<p><em>' . _("No tickets in queue.") . '</em></p>';
 61:         }
 62: 
 63:         $info = array('queue' => $this->_params['queue'],
 64:                       'nores' => true);
 65:         $tickets = $whups_driver->getTicketsByProperties($info);
 66:         if (!$tickets) {
 67:             return '<p><em>' . _("No tickets in queue.") . '</em></p>';
 68:         }
 69: 
 70:         $html = '<thead><tr>';
 71:         $sortby = $prefs->getValue('sortby');
 72:         $sortdirclass = ' class="' . ($prefs->getValue('sortdir') ? 'sortup' : 'sortdown') . '"';
 73:         foreach (Whups::getSearchResultColumns('block') as $name => $column) {
 74:             $html .= '<th' . ($sortby == $column ? $sortdirclass : '') . '>' . $name . '</th>';
 75:         }
 76:         $html .= '</tr></thead><tbody>';
 77: 
 78:         Whups::sortTickets($tickets);
 79:         foreach ($tickets as $ticket) {
 80:             $link = Horde::link(Whups::urlFor('ticket', $ticket['id'], true));
 81:             $html .= '<tr><td>' . $link . htmlspecialchars($ticket['id']) . '</a></td>' .
 82:                 '<td>' . $link . htmlspecialchars($ticket['summary']) . '</a></td>' .
 83:                 '<td>' . htmlspecialchars($ticket['priority_name']) . '</td>' .
 84:                 '<td>' . htmlspecialchars($ticket['state_name']) . '</td></tr>';
 85:         }
 86: 
 87:         Horde::addScriptFile('tables.js', 'horde', true);
 88: 
 89:         return '<table id="whups_block_queue_' . htmlspecialchars($this->_params['queue']) . '" cellspacing="0" class="tickets striped sortable">' . $html . '</tbody></table>';
 90:     }
 91: 
 92:     /**
 93:      */
 94:     private function _getQueue()
 95:     {
 96:         global $whups_driver;
 97: 
 98:         if (empty($this->_params['queue'])) {
 99:             return false;
100:         }
101:         if (!Whups::permissionsFilter(array($this->_params['queue'] => true), 'queue', Horde_Perms::READ)) {
102:             return false;
103:         }
104: 
105:         try {
106:             return $whups_driver->getQueue($this->_params['queue']);
107:         } catch (Whups_Exception $e) {
108:             return false;
109:         }
110:     }
111: 
112: }
113: 
API documentation generated by ApiGen