Overview

Packages

  • None
  • Vilma

Classes

  • Vilma_Application
  • Vilma_Exception
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Vilma application interface.
  4:  *
  5:  * This file defines Vilma's external API interface.
  6:  *
  7:  * Copyright 2006-2010 Alkaloid Networks <http://www.alkaloid.net/>
  8:  *
  9:  * See the enclosed file LICENSE for license information (BSD). If you did not
 10:  * did not receive this file, see http://cvs.horde.org/co.php/vilma/LICENSE.
 11:  *
 12:  * @author  Ben Klang <ben@alkaloid.net>
 13:  * @package Vilma
 14:  */
 15: 
 16: /* Determine the base directories. */
 17: if (!defined('VILMA_BASE')) {
 18:     define('VILMA_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(VILMA_BASE . '/config/horde.local.php')) {
 25:         include VILMA_BASE . '/config/horde.local.php';
 26:     } else {
 27:         define('HORDE_BASE', VILMA_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 Vilma_Application extends Horde_Registry_Application
 36: {
 37:     /**
 38:      * The application's version.
 39:      *
 40:      * @var string
 41:      */
 42:     public $version = 'H4 (1.0-git)';
 43: 
 44:     public $driver = null;
 45:     public $curdomain = null;
 46: 
 47:     protected function _init()
 48:     {
 49:         $this->driver = Vilma_Driver::factory();
 50: 
 51:         // Get the currently active domain, possibly storing a change into the
 52:         // session.
 53:         // Domain is passed in by ID, which may or may not be the
 54:         // the same as the actual DNS domain name.
 55:         $domain_id = Horde_Util::getFormData('domain_id');
 56: 
 57:         if (!empty($domain_id)) {
 58:             $domain = $this->driver->getDomain($domain_id);
 59:             if (!is_a($domain, 'PEAR_Error') &&
 60:                 !empty($domain['domain_name'])) {
 61:                 $this->curdomain = $domain;
 62:                 Vilma::setCurDomain($domain);
 63:             }
 64:         } elseif ($domain = $GLOBALS['session']->get('vilma', 'domain')) {
 65:             $this->curdomain = $domain;
 66:         }
 67:     }
 68: 
 69:     public function perms()
 70:     {
 71:         $perms = array(
 72:             'superadmin' => array(
 73:                 'title' => _("Super Administrator")
 74:             )
 75:         );
 76: 
 77:         $domains = $this->driver->getDomains();
 78: 
 79:         // Run through every domain
 80:         foreach ($domains as $domain) {
 81:             $perms['domains:' . $domain['domain_id']] = array(
 82:                 'title' => $domain['name']
 83:             );
 84:         }
 85: 
 86:         return $perms;
 87:     }
 88: 
 89:     /**
 90:      */
 91:     public function menu($menu)
 92:     {
 93:         $menu->add(Horde::url('domains/index.php'), _("_Domains"), 'domain.png');
 94:         if ($GLOBALS['vilma']->curdomain) {
 95:             $domain = $GLOBALS['session']->get('vilma', 'domain');
 96:             $menu->add(Horde::url('users/index.php')->add('domain_id', $domain['domain_id']), $domain['domain_name'], 'domain.png');
 97:             $menu->add(Horde::url('users/edit.php'), _("New _Address"), 'user.png');
 98:         } else {
 99:             $menu->add(Horde::url('domains/edit.php'), _("_New Domain"), 'domain.png');
100:         }
101:     }
102: }
103: 
API documentation generated by ApiGen