Overview

Packages

  • Beatnik
  • None

Classes

  • Beatnik_Application
  • Beatnik_Exception
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Beatnik application interface.
  4:  *
  5:  * This file defines Horde's application interface. Other Horde libraries
  6:  * and applications can interact with Beatnik through this API.
  7:  *
  8:  * Copyright 2006-2012 Horde LLC (http://www.horde.org/)
  9:  *
 10:  * See the enclosed file LICENSE for license information (GPL). If you did not
 11:  * did not receive this file, see http://www.horde.org/licenses/gpl
 12:  *
 13:  * @author  Ben Klang <bklang@horde.org>
 14:  * @package Beatnik
 15:  */
 16: 
 17: if (!defined('BEATNIK_BASE')) {
 18:     define('BEATNIK_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(BEATNIK_BASE. '/config/horde.local.php')) {
 25:         include BEATNIK_BASE . '/config/horde.local.php';
 26:     } else {
 27:         define('HORDE_BASE', BEATNIK_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: 
 36: class Beatnik_Application extends Horde_Registry_Application
 37: {
 38:     public $version = 'H4 (1.0-git)';
 39:     public $driver = null;
 40:     public $domains = null;
 41: 
 42:     function _init()
 43:     {
 44:         $this->driver = Beatnik_Driver::factory();
 45: 
 46:         // Get a list of domains to work with
 47:         $this->domains = $this->driver->getDomains();
 48: 
 49:         // Jump to new domain
 50:         if (Horde_Util::getFormData('curdomain') !== null && !empty($this->domains)) {
 51:             try {
 52:                 $domain = $this->driver->getDomain(Horde_Util::getFormData('curdomain'));
 53:             } catch (Exception $e) {
 54:                 $notification->push($e->getMessage(), 'horde.error');
 55:                 $domain = $domains[0];
 56:             }
 57: 
 58:             $_SESSION['beatnik']['curdomain'] = $domain;
 59:         }
 60: 
 61:         // Determine if the user should see basic or advanced options
 62:         if (!isset($_SESSION['beatnik']['expertmode'])) {
 63:             $_SESSION['beatnik']['expertmode'] = false;
 64:         } elseif (Horde_Util::getFormData('expertmode') == 'toggle') {
 65:             if ($_SESSION['beatnik']['expertmode']) {
 66:                 $notification->push(_('Expert Mode off'), 'horde.message');
 67:                 $_SESSION['beatnik']['expertmode'] = false;
 68:             } else {
 69:                 $notification->push(_('Expert Mode ON'), 'horde.warning');
 70:                 $_SESSION['beatnik']['expertmode'] = true;
 71:             }
 72:         }
 73: 
 74:         // Initialize the page marker
 75:         if (!isset($_SESSION['beatnik']['curpage'])) {
 76:             $_SESSION['beatnik']['curpage'] = 0;
 77:         }
 78:     }
 79: 
 80:     /**
 81:      */
 82:     public function perms()
 83:     {
 84:         $perms = array(
 85:             'domains' => array(
 86:                 'title' => _("Domains")
 87:             ),
 88:         );
 89: 
 90:         // Run through every domain
 91:         foreach ($beatnik->driver->getDomains() as $domain) {
 92:             $perms['domains:' . $domain['zonename']] = array(
 93:                 'title' => $domain['zonename']
 94:             );
 95:         }
 96: 
 97:         return $perms;
 98:     }
 99: 
100:     /**
101:      */
102:     public function menu($menu)
103:     {
104:         return Beatnik::getMenu();
105:     }
106: 
107: }
108: 
API documentation generated by ApiGen