* @author Duck <duck@obala.net>
*/
-define('BEATNIK_BASE', dirname(__FILE__));
-require_once BEATNIK_BASE . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+$beatnik = Horde_Registry::appInit('beatnik');
+
require_once BEATNIK_BASE . '/lib/Forms/Autogenerate.php';
$viewurl = Horde::applicationUrl('viewzone.php');
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*/
-define('BEATNIK_BASE', dirname(__FILE__));
-require_once BEATNIK_BASE . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+$beatnik = Horde_Registry::appInit('beatnik');
+
require_once BEATNIK_BASE . '/lib/Forms/EditRecord.php';
$domains = array();
} elseif (Horde_Util::getGet('domain') == 'all') {
$url = Horde::applicationUrl('listzones.php');
foreach (Beatnik::needCommit() as $domain) {
- $domains[] = $beatnik_driver->getDomain($domain);
+ $domains[] = $beatnik->driver->getDomain($domain);
}
}
$form->getInfo($vars, $info);
try {
- $result = $beatnik_driver->saveRecord($info);
+ $result = $beatnik->driver->saveRecord($info);
} catch (Exception $e) {
$notification->push($e->getMessage(), 'horde.error');
}
* did not receive this file, see http://cvs.horde.org/co.php/merk/LICENSE.
*/
-define('BEATNIK_BASE', dirname(__FILE__));
-require_once BEATNIK_BASE . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+$beatnik = Horde_Registry::appInit('beatnik');
+
require_once BEATNIK_BASE . '/lib/Forms/DeleteRecord.php';
$vars = Horde_Variables::getDefaultVariables();
-list($type, $record) = $beatnik_driver->getRecord(Horde_Util::getFormData('id'));
+list($type, $record) = $beatnik->driver->getRecord(Horde_Util::getFormData('id'));
$form = new DeleteRecord($vars);
$form->getInfo($vars, $info);
if (Horde_Util::getFormData('submitbutton') == _("Delete")) {
try {
- $result = $beatnik_driver->deleteRecord($info);
+ $result = $beatnik->driver->deleteRecord($info);
} catch (Exception $e) {
$notification->push($e->getMessage(), 'horde.error');
header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('viewzone.php'), $info));
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*/
-define('BEATNIK_BASE', dirname(__FILE__));
-require_once BEATNIK_BASE . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+$beatnik = Horde_Registry::appInit('beatnik');
+
require_once BEATNIK_BASE . '/lib/Forms/EditRecord.php';
$vars = Horde_Variables::getDefaultVariables();
$url = Horde::applicationUrl('editrec.php');
-list($type, $record) = $beatnik_driver->getRecord(Horde_Util::getFormData('id'));
+list($type, $record) = $beatnik->driver->getRecord(Horde_Util::getFormData('id'));
$form = new EditRecord($vars);
$form->getInfo($vars, $info);
try {
- $result = $beatnik_driver->saveRecord($info);
+ $result = $beatnik->driver->saveRecord($info);
} catch (Exception $e) {
$notification->push($e->getMessage(), 'horde.error');
}
<?php
/**
- * Beatnik application API.
+ * Beatnik application interface.
*
+ * This file defines Horde's application interface. Other Horde libraries
+ * and applications can interact with Beatnik through this API.
+ *
+ * Copyright 2006-2010 Alkaloid Networks, LLC (http://projects.alkaloid.net/)
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you did not
+ * did not receive this file, see
+ * http://www.opensource.org/licenses/bsd-license.html.
+ *
+ * @author Ben Klang <ben@alkaloid.net>
* @package Beatnik
*/
+
+if (!defined('BEATNIK_BASE')) {
+ define('BEATNIK_BASE', dirname(__FILE__). '/..');
+}
+
+if (!defined('HORDE_BASE')) {
+ /* If horde does not live directly under the app directory, the HORDE_BASE
+ * constant should be defined in config/horde.local.php. */
+ if (file_exists(BEATNIK_BASE. '/config/horde.local.php')) {
+ include BEATNIK_BASE . '/config/horde.local.php';
+ } else {
+ define('HORDE_BASE', BEATNIK_BASE . '/..');
+ }
+}
+
+/* Load the Horde Framework core (needed to autoload
+ * Horde_Registry_Application::). */
+require_once HORDE_BASE . '/lib/core.php';
+
+
class Beatnik_Application extends Horde_Registry_Application
{
public $version = 'H4 (1.0-git)';
+ public $driver = null;
+ public $domains = null;
+
+ function _init()
+ {
+ $this->driver = Beatnik_Driver::factory();
+
+ // Get a list of domains to work with
+ $this->domains = $this->driver->getDomains();
+
+ // Jump to new domain
+ if (Horde_Util::getFormData('curdomain') !== null && !empty($this->domains)) {
+ try {
+ $domain = $this->driver->getDomain(Horde_Util::getFormData('curdomain'));
+ } catch (Exception $e) {
+ $notification->push($e->getMessage(), 'horde.error');
+ $domain = $domains[0];
+ }
+
+ $_SESSION['beatnik']['curdomain'] = $domain;
+ }
+
+ // Determine if the user should see basic or advanced options
+ if (!isset($_SESSION['beatnik']['expertmode'])) {
+ $_SESSION['beatnik']['expertmode'] = false;
+ } elseif (Horde_Util::getFormData('expertmode') == 'toggle') {
+ if ($_SESSION['beatnik']['expertmode']) {
+ $notification->push(_('Expert Mode off'), 'horde.message');
+ $_SESSION['beatnik']['expertmode'] = false;
+ } else {
+ $notification->push(_('Expert Mode ON'), 'horde.warning');
+ $_SESSION['beatnik']['expertmode'] = true;
+ }
+ }
+
+ // Initialize the page marker
+ if (!isset($_SESSION['beatnik']['curpage'])) {
+ $_SESSION['beatnik']['curpage'] = 0;
+ }
+ }
/**
* Returns a list of available permissions.
$perms['title']['beatnik:domains'] = _("Domains");
// Run through every domain
- foreach ($GLOBALS['beatnik_driver']->getDomains() as $domain) {
+ foreach ($beatnik->driver->getDomains() as $domain) {
$perms['tree']['beatnik']['domains'][$domain['zonename']] = false;
$perms['title']['beatnik:domains:' . $domain['zonename']] = $domain['zonename'];
}
'txt' => _("TXT (Text Record)"),
);
- return array_merge($records, $GLOBALS['beatnik_driver']->getRecDriverTypes());
+ return array_merge($records, $beatnik->driver->getRecDriverTypes());
}
/**
// 'default': the default value of the field.
// 'index': Crude sort ordering. Lower means show higher in the group
+ global $beatnik;
+
// Attempt to return cached results.
static $recset = array();
'default' => $GLOBALS['prefs']->getValue('default_ttl')
);
- $recset[$recordtype] = array_merge($recset[$recordtype], $GLOBALS['beatnik_driver']->getRecDriverFields($recordtype));
+ //$recset[$recordtype] = array_merge($recset[$recordtype], $beatnik->driver->getRecDriverFields($recordtype));
uasort($recset[$recordtype], array('Beatnik', 'fieldSort'));
return $recset[$recordtype];
*/
function autogenerate(&$vars)
{
+ global $beatnik;
require BEATNIK_BASE . '/config/autogenerate.php';
$template = $templates[$vars->get('template')];
try {
- $zonedata = $GLOBALS['beatnik_driver']->getRecords($_SESSION['beatnik']['curdomain']['zonename']);
+ $zonedata = $beatnik->driver->getRecords($_SESSION['beatnik']['curdomain']['zonename']);
} catch (Exception $e) {
$GLOBALS['notification']->push($e);
}
case 'all':
foreach ($zonedata[$rectype] as $record) {
try {
- $result = $GLOBALS['beatnik_driver']->deleteRecord($record);
+ $result = $beatnik->driver->deleteRecord($record);
} catch (Exception $e) {
$GLOBALS['notification']->push($e);
}
foreach ($definitions['records'] as $Trecord) {
if ($record['hostname'] == $Trecord['hostname']) {
try {
- $result = $GLOBALS['beatnik_driver']->deleteRecord($record);
+ $result = $beatnik->driver->deleteRecord($record);
} catch (Exception $e) {
$GLOBALS['notification']->push($e);
}
$defaults = array('rectype' => $rectype,
'zonename'=> $_SESSION['beatnik']['curdomain']['zonename']);
foreach ($definitions['records'] as $info) {
- if ($GLOBALS['beatnik_driver']->recordExists($info, $rectype)) {
+ if ($beatnik->driver->recordExists($info, $rectype)) {
$GLOBALS['notification']->push(_("Skipping existing identical record"));
continue;
}
try {
- $result = $GLOBALS['beatnik_driver']->saveRecord(array_merge($defaults, $info));
+ $result = $beatnik->driver->saveRecord(array_merge($defaults, $info));
} catch (Exception $e) {
$GLOBALS['notification']->push($result->getMessage() . ': ' . $result->getDebugInfo(), 'horde.error');
}
-class Beatnik_Exception extends Horde_Exception {}
\ No newline at end of file
+<?php class Beatnik_Exception extends Horde_Exception {}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Beatnik base inclusion file.
- *
- * Copyright 2005-2007 Alkaloid Networks <http://www.alkaloid.net>
- *
- * This file brings in all of the dependencies that every Beatnik
- * script will need and sets up objects that all scripts use.
- *
- * @author Ben Klang <ben@alkaloid.net>
- * @package Beatnik
- */
-
-// Check for a prior definition of HORDE_BASE (perhaps by an
-// auto_prepend_file definition for site customization).
-if (!defined('HORDE_BASE')) {
- define('HORDE_BASE', dirname(__FILE__) . '/../..');
-}
-// Load the Horde Framework core, and set up inclusion paths.
-require_once HORDE_BASE . '/lib/core.php';
-
-// Registry.
-$registry = new Horde_Registry();
-
-try {
- $registry->pushApp('beatnik', array('check_perms' => (Horde_Util::nonInputVar('beatnik_authentication') != 'none')));
-} catch (Horde_Exception $e) {
- if ($e->getCode() == Horde_Registry::PERMISSION_DENIED) {
- Horde_Auth::authenticateFailure('beatnik', $e);
- }
- Horde::fatal($e, __FILE__, __LINE__, false);
-}
-
-$conf = &$GLOBALS['conf'];
-define('BEATNIK_TEMPLATES', $registry->get('templates'));
-
-// Find the base file path of Beatnik.
-if (!defined('BEATNIK_BASE')) {
- define('BEATNIK_BASE', dirname(__FILE__) . '/..');
-}
-
-// Beatnik base libraries.
-require_once BEATNIK_BASE . '/lib/Beatnik.php';
-require_once BEATNIK_BASE . '/lib/Driver.php';
-
-try {
- $GLOBALS['beatnik_driver'] = Beatnik_Driver::factory();
-} catch (Exception $e) {
- Horde::fatal($e, __FILE__, __LINE__);
-}
-
-// Get a list of domains to work with
-$domains = $GLOBALS['beatnik_driver']->getDomains();
-
-// Jump to new domain
-if (Horde_Util::getFormData('curdomain') !== null && !empty($domains)) {
- try {
- $domain = $GLOBALS['beatnik_driver']->getDomain(Horde_Util::getFormData('curdomain'));
- } catch (Exception $e) {
- $notification->push($e->getMessage(), 'horde.error');
- $domain = $domains[0];
- }
-
- $_SESSION['beatnik']['curdomain'] = $domain;
-}
-
-// Determine if the user should see basic or advanced options
-if (!isset($_SESSION['beatnik']['expertmode'])) {
- $_SESSION['beatnik']['expertmode'] = false;
-} elseif (Horde_Util::getFormData('expertmode') == 'toggle') {
- if ($_SESSION['beatnik']['expertmode']) {
- $notification->push(_('Expert Mode off'), 'horde.message');
- $_SESSION['beatnik']['expertmode'] = false;
- } else {
- $notification->push(_('Expert Mode ON'), 'horde.warning');
- $_SESSION['beatnik']['expertmode'] = true;
- }
-}
-
-// Initialize the page marker
-if (!isset($_SESSION['beatnik']['curpage'])) {
- $_SESSION['beatnik']['curpage'] = 0;
-}
-
-// Start output compression.
-if (!Horde_Util::nonInputVar('no_compress')) {
- Horde::compressOutput();
-}
-
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+$beatnik = Horde_Registry::appInit('beatnik');
// Unset the current domain since we are generating a zone list
$_SESSION['beatnik']['curdomain'] = null;
$pager_vars->set('page', $page);
$perpage = $prefs->getValue('domains_perpage');
$pager = new Horde_Ui_Pager('page', $pager_vars,
- array('num' => count($domains),
+ array('num' => count($beatnik->domains),
'url' => 'listzones.php',
'page_count' => 10,
'perpage' => $perpage));
// Limit the domain list to the current page
-$domains = array_slice($domains, $page*$perpage, $perpage);
+$domains = array_slice($beatnik->domains, $page*$perpage, $perpage);
$img_dir = $registry->getImageDir('horde');
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*/
-define('BEATNIK_BASE', dirname(__FILE__));
-require_once BEATNIK_BASE . '/lib/base.php';
-require_once BEATNIK_BASE . '/lib/Beatnik.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+$beatnik = Horde_Registry::appInit('beatnik');
try {
- $zonedata = $beatnik_driver->getRecords($_SESSION['beatnik']['curdomain']['zonename']);
+ $zonedata = $beatnik->driver->getRecords($_SESSION['beatnik']['curdomain']['zonename']);
} catch (Exception $e) {
$notification->push($e, 'horde.error');
header('Location:' . Horde::applicationUrl('listzones.php'));