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:  * Whups application API.
  4:  *
  5:  * This file defines Horde's core API interface. Other core Horde libraries
  6:  * can interact with Whups through this API.
  7:  *
  8:  * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
  9:  *
 10:  * See the enclosed file COPYING for license information (GPL). If you
 11:  * did not receive this file, see http://www.horde.org/licenses/gpl.
 12:  *
 13:  * @package Whups
 14:  */
 15: 
 16: /* Determine the base directories. */
 17: if (!defined('WHUPS_BASE')) {
 18:     define('WHUPS_BASE', dirname(__FILE__) . '/..');
 19: }
 20: 
 21: if (!defined('HORDE_BASE')) {
 22:     /* If Horde does not live directly under the app directory, the HORDE_BASE
 23:      * constant should be defined in config/horde.local.php. */
 24:     if (file_exists(WHUPS_BASE . '/config/horde.local.php')) {
 25:         include WHUPS_BASE . '/config/horde.local.php';
 26:     } else {
 27:         define('HORDE_BASE', WHUPS_BASE . '/..');
 28:     }
 29: }
 30: 
 31: /* Load the Horde Framework core (needed to autoload
 32:  * Horde_Registry_Application::). */
 33: require_once HORDE_BASE . '/lib/core.php';
 34: 
 35: class Whups_Application extends Horde_Registry_Application
 36: {
 37:     /**
 38:      */
 39:     public $version = 'H4 (2.0.3-git)';
 40: 
 41:     /**
 42:      * Global variables defined:
 43:      * - $whups_driver: The global Whups driver object.
 44:      * - $linkTags:     <link> tags for common-header.inc.
 45:      */
 46:     protected function _init()
 47:     {
 48:         $GLOBALS['whups_driver'] = $GLOBALS['injector']->getInstance('Whups_Factory_Driver')->create();
 49:         $GLOBALS['linkTags'] = array('<link href="' . Horde::url('opensearch.php', true, -1) . '" rel="search" type="application/opensearchdescription+xml" title="' . $GLOBALS['registry']->get('name') . ' (' . Horde::url('', true) . ')" />');
 50: 
 51:         /* Set the timezone variable, if available. */
 52:         $GLOBALS['registry']->setTimeZone();
 53:     }
 54: 
 55:     /**
 56:      */
 57:     public function perms()
 58:     {
 59:         /* Available Whups permissions. */
 60:         $perms = array(
 61:             'admin' => array(
 62:                 'title' => _("Administration")
 63:             ),
 64:             'hiddenComments' => array(
 65:                 'title' => _("Hidden Comments")
 66:             ),
 67:             'queues' => array(
 68:                 'title' => _("Queues")
 69:             ),
 70:             'replies' => array(
 71:                 'title' => _("Form Replies")
 72:             )
 73:         );
 74: 
 75:         /* Loop through queues and add their titles. */
 76:         $queues = $GLOBALS['whups_driver']->getQueues();
 77:         foreach ($queues as $id => $name) {
 78:             $perms['queues:' . $id] = array(
 79:                 'title' => $name
 80:             );
 81: 
 82:             $entries = array(
 83:                 'assign' => _("Assign"),
 84:                 'requester' => _("Set Requester"),
 85:                 'update' => _("Update")
 86:             );
 87: 
 88:             foreach ($entries as $key => $val) {
 89:                 $perms['queues:' . $id . ':' . $key] = array(
 90:                     'title' => $val,
 91:                     'type' => 'boolean'
 92:                 );
 93:             }
 94:         }
 95: 
 96:         /* Loop through type and replies and add their titles. */
 97:         foreach ($GLOBALS['whups_driver']->getAllTypes() as $type_id => $type_name) {
 98:             foreach ($GLOBALS['whups_driver']->getReplies($type_id) as $reply_id => $reply) {
 99:                 $perms['replies:' . $reply_id] = array(
100:                     'title' => $type_name . ': ' . $reply['reply_name']
101:                 );
102:             }
103:         }
104: 
105:         return $perms;
106:     }
107: 
108:     /**
109:      */
110:     public function menu($menu)
111:     {
112:         $menu->add(Horde::url('mybugs.php'), sprintf(_("_My %s"), $GLOBALS['registry']->get('name')), 'whups.png', null, null, null, $GLOBALS['prefs']->getValue('whups_default_view') == 'mybugs' && strpos($_SERVER['PHP_SELF'], $GLOBALS['registry']->get('webroot') . '/index.php') !== false ? 'current' : null);
113:         $menu->add(Horde::url('search.php'), _("_Search"), 'search.png', null, null, null, $GLOBALS['prefs']->getValue('whups_default_view') == 'search' && strpos($_SERVER['PHP_SELF'], $GLOBALS['registry']->get('webroot') . '/index.php') !== false ? 'current' : null);
114:         $menu->add(Horde::url('ticket/create.php'), _("_New Ticket"), 'create.png', null, null, null, $GLOBALS['prefs']->getValue('whups_default_view') == 'ticket/create' && basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null);
115:         $menu->add(Horde::url('query/index.php'), _("_Query Builder"), 'query.png');
116:         $menu->add(Horde::url('reports.php'), _("_Reports"), 'reports.png');
117: 
118:         /* Administration. */
119:         if ($GLOBALS['registry']->isAdmin(array('permission' => 'whups:admin'))) {
120:             $menu->add(Horde::url('admin/'), _("_Admin"), 'admin.png');
121:         }
122:     }
123: 
124:     /**
125:      */
126:     public function prefsInit($ui)
127:     {
128:         if (!$GLOBALS['registry']->hasMethod('contacts/sources')) {
129:             $ui->suppressGroups[] = 'addressbooks';
130:         }
131:     }
132: 
133:     /**
134:      */
135:     public function prefsGroup($ui)
136:     {
137:         foreach ($ui->getChangeablePrefs() as $val) {
138:             switch ($val) {
139:             case 'sourceselect':
140:                 Horde_Core_Prefs_Ui_Widgets::addressbooksInit();
141:                 break;
142:             }
143:         }
144:     }
145: 
146:     /**
147:      */
148:     public function prefsSpecial($ui, $item)
149:     {
150:         switch ($item) {
151:         case 'sourceselect':
152:             $search = Whups::getAddressbookSearchParams();
153:             return Horde_Core_Prefs_Ui_Widgets::addressbooks(array(
154:                 'fields' => $search['fields'],
155:                 'sources' => $search['sources']
156:             ));
157:         }
158: 
159:         return '';
160:     }
161: 
162:     /**
163:      */
164:     public function prefsSpecialUpdate($ui, $item)
165:     {
166:         $updated = false;
167: 
168:         switch ($item) {
169:         case 'sourceselect':
170:             $data = Horde_Core_Prefs_Ui_Widgets::addressbooksUpdate($ui);
171: 
172:             if (isset($data['sources'])) {
173:                 $GLOBALS['prefs']->setValue('search_sources', $data['sources']);
174:                 $updated = true;
175:             }
176: 
177:             if (isset($data['fields'])) {
178:                 $GLOBALS['prefs']->setValue('search_fields', $data['fields']);
179:                 $updated = true;
180:             }
181:             break;
182:         }
183: 
184:         return $updated;
185:     }
186: 
187:     /* Sidebar method. */
188: 
189:     /**
190:      */
191:     public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
192:                                   array $params = array())
193:     {
194:         $tree->addNode(
195:             $parent . '__new',
196:             $parent,
197:             _("New Ticket"),
198:             1,
199:             false,
200:             array(
201:                 'icon' => Horde_Themes::img('create.png'),
202:                 'url' => Horde::url('ticket/create.php')
203:             )
204:         );
205: 
206:         $tree->addNode(
207:             $parent . '__search',
208:             $parent,
209:             _("Search"),
210:             1,
211:             false,
212:             array(
213:                 'icon' => Horde_Themes::img('search.png'),
214:                 'url' => Horde::url('search.php')
215:             )
216:         );
217:     }
218: 
219: }
220: 
API documentation generated by ApiGen