Overview

Packages

  • Horde
    • Block
  • None
  • Ulaform

Classes

  • Ulaform_Application
  • Ulaform_Test
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Ulaform internal API interface.
 4:  *
 5:  * This file defines Ulaform's internal API interface. Other applications can
 6:  * interact with Ulaform 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 Ulaform
14:  */
15: 
16: /* Determine the base directories. */
17: if (!defined('ULAFORM_BASE')) {
18:     define('ULAFORM_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(ULAFORM_BASE . '/config/horde.local.php')) {
25:         include ULAFORM_BASE . '/config/horde.local.php';
26:     } else {
27:         define('HORDE_BASE', ULAFORM_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 Ulaform_Application extends Horde_Registry_Application
36: {
37:     public $version = 'H4 (1.0-git)';
38: 
39:     /**
40:      * Global variables defined:
41:      *   $ulaform_driver - TODO
42:      */
43:     protected function _init()
44:     {
45:         $GLOBALS['ulaform_driver'] = new Ulaform_Driver($GLOBALS['injector']->getInstance('Horde_Db_Adapter'));
46:     }
47: 
48:     /**
49:      * Returns a list of available permissions.
50:      *
51:      * @return array  An array describing all available permissions.
52:      */
53:     public function perms()
54:     {
55:         $perms['forms'] = array(
56:             'title' => _("Forms")
57:         );
58: 
59:         try {
60:             foreach ($GLOBALS['injector']->getInstance('Ulaform_Factory_Driver')->create()->getAvailableForms() as $form) {
61:                 $perms['forms:' . $form['form_id']] = array(
62:                     'title' => $form['form_name'],
63:                 );
64:             }
65:         } catch (Ulaform_Exception $e) {}
66: 
67:         return $perms;
68:     }
69: 
70:     /**
71:      * Generate the menu to use in ulaform administration pages.
72:      */
73:     public function menu($menu)
74:     {
75:         $menu->setMask(Horde_Menu::MASK_ALL & ~Horde_Menu::MASK_PREFS);
76: 
77:         $menu->add(Horde::url('forms.php'), _("_List Forms"), 'ulaform.png');
78:         $menu->add(Horde::url('edit.php'), _("_New Form"), 'new.png');
79:     }
80: 
81: }
82: 
API documentation generated by ApiGen