Horde_Registry::appInit('agora', array('authentication' => 'none', 'cli' => true));
/* Open Agora database. */
-$db_agora = &DB::connect($conf['sql']);
-if ($db instanceof PEAR_Error) {
- var_dump($db);
- exit;
-}
-
-/* Open Phorum database. */
-$db_phorum = &DB::connect($conf['sql']);
-if ($db_phorum instanceof PEAR_Error) {
- var_dump($db_phorum);
- exit;
-}
+$db_agora = $db_phorum = $injector->getInstance('Horde_Db_Pear')->getOb();
// We accept the user name on the command-line.
$ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'h:p:a:t:f:c:',
Horde_Registry::appInit('agora', array('authentication' => 'none', 'cli' => true));
/* Open the database. */
-$db = DB::connect($conf['sql']);
-if ($db instanceof PEAR_Error) {
- var_dump($db);
- exit;
-}
-$db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS);
+$db = $injector->getInstance('Horde_Db_Pear')->getOb();
/* Copy forums. */
$max_id = 0;
Horde_Registry::appInit('agora', array('authentication' => 'none', 'cli' => true));
/* Open the database. */
-$db = &DB::connect($conf['sql']);
-if ($db instanceof PEAR_Error) {
- var_dump($db);
- exit;
-}
-$db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS);
+$db = $injector->getInstance('Horde_Db_Pear')->getOb();
/* Get messages. */
$sql = 'SELECT DISTINCT d.datatree_id, d.datatree_parents FROM horde_datatree d, horde_datatree_attributes a '
Horde_Registry::appInit('agora', array('authentication' => 'none', 'cli' => true));
/* Open the database. */
-$db = &DB::connect($conf['sql']);
-if ($db instanceof PEAR_Error) {
- var_dump($db);
- exit;
-}
-$db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS);
+$db = $injector->getInstance('Horde_Db_Pear')->getOb();
/* Get threads. */
$sql = 'SELECT message_id, forum_id FROM agora_messages WHERE message_thread = ?';
*
* @param array $params A hash containing connection parameters.
*/
- function Beatnik_Driver_pdnsgsql($params = array())
+ function __construct($params = array())
{
- parent::Beatnik_Driver($params);
+ $params = array_merge(array(
+ 'domains_table' => 'domains',
+ 'records_table' => 'records'
+ ), $params);
+
+ parent::__construct($params);
}
/**
throw $e;
}
- if (!isset($this->_params['domains_table'])) {
- $this->_params['domains_table'] = 'domains';
- }
- if (!isset($this->_params['records_table'])) {
- $this->_params['records_table'] = 'records';
- }
-
/* Connect to the SQL server using the supplied parameters. */
require_once 'DB.php';
$this->_write_db = &DB::connect($this->_params,
break;
case 'imp':
-
if (Horde_Auth::isAdmin()
|| $group->userIsInGroup($user_uid, 1, false)
|| $group->userIsInGroup($user_uid, 2, false)) {
- $db = DB::connect($GLOBALS['conf']['sql']);
+ $db = $GLOBALS['injector']->getInstance('Horde_Db_Pear')->getOb();
$password = $db->getOne('SELECT password FROM mails.accountuser WHERE username = ?', array($user_uid . '@' . $_SERVER['SERVER_NAME']));
$try = $GLOBALS['registry']->callByPackage('imp', 'authenticate', array($user_uid, array('password' => $password)));
throw new Horde_Exception(_("Username can contain only alphanumeric characters, underscore and minus."));
}
- $_db = DB::connect($GLOBALS['conf']['sql'], true);
+ $_db = $GLOBALS['injector']->getInstance('Horde_Db_Pear')->getOb();
$query = 'SELECT user_uid, user_email FROM folks_users WHERE user_uid = ? OR user_email = ?';
$result = $_db->getRow($query, array($username, $info['extra']['email']), DB_FETCHMODE_ASSOC);
{
global $conf;
- $_db = DB::connect($conf['sql']);
+ $_db = $GLOBALS['injector']->getInstance('Horde_Db_Pear')->getOb();
$fields = array();
$values = array();
foreach ($extra as $field => $value) {
* @package Folks
*/
+// Disabled by default
exit;
-$folks_authentication = 'none';
-require_once dirname(__FILE__) . '/../lib/base.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('folks', array('authentication' => 'none', 'cli' => true));
-// Make sure no one runs this from the web.
-if (!Horde_Cli::runningFromCLI()) {
- exit("Must be run from the command line\n");
-}
-
-// Load the CLI environment.
-$cli = Horde_Cli::init();
-
-$db = DB::connect($conf['sql']);
-if ($db instanceof PEAR_Error) {
- $cli->fatal($db);
+try {
+ $db = $injector->getInstance('Horde_Db_Pear')->getOb();
+} catch (Horde_Exception $e) {
+ $cli->fatal($e);
}
$users = array();
* @package Folks
*/
+// Disabled by default
exit;
-$folks_authentication = 'none';
-require_once dirname(__FILE__) . '/../lib/base.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('folks', array('authentication' => 'none', 'cli' => true));
-$db = DB::connect($conf['sql']);
+try {
+ $db = $injector->getInstance('Horde_Db_Pear')->getOb();
+} catch (Horde_Exception $e) {
+ $cli->fatal($e);
+}
$sql = 'SELECT pref_uid, pref_value, pref_name FROM horde_prefs WHERE '
. ' pref_scope = ? AND (pref_name = ? OR pref_name = ?)'
EOU;
}
-// Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../../lib/core.php';
-
-// Make sure no one runs this from the web.
-if (!Horde_Cli::runningFromCLI()) {
- exit("Must be run from the command line\n");
-}
-
-// Load the CLI environment - make sure there's no time limit, init some
-// variables, etc.
-$cli = Horde_Cli::init();
-
-$horde_authentication = 'none';
-require_once dirname(__FILE__) . '/../lib/base.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('folks', array('authentication' => 'none', 'cli' => true));
// Read command-line parameters.
$info = array();
$from_str = array('Undelivered Mail', 'MAILER-DAEMON', 'root@' . $conf['server']['name']);
// Connect to db
-$dbconf = Horde::getDriverConfig('storage', 'sql');
-$db = DB::connect($dbconf);
+try {
+ $db = $injector->getInstance('Horde_Db_Pear')->getOb();
+} catch (Horde_Exception $e) {
+ $cli->fatal($e);
+}
// get mails
$mails = array();
* @package Folks
*/
-// Do CLI checks and environment setup first.
-require_once 'Horde/Cli.php';
-
-// Make sure no one runs this from the web.
-if (!Horde_Cli::runningFromCLI()) {
- exit("Must be run from the command line\n");
-}
-
-// Load the CLI environment.
-$cli = Horde_Cli::init();
-
-// Load Folks.
-$folks_authentication = 'none';
-$no_compress = true;
-require_once dirname(__FILE__) . '/../lib/base.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('folks', array('authentication' => 'none', 'cli' => true, 'no_compress' => true));
// We accept the user name on the command-line.
$ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'h:u:p:dt:f:c:',
}
// Connect to db
-$dbconf = Horde::getDriverConfig('storage', 'sql');
-$db = DB::connect($dbconf);
+try {
+ $db = $injector->getInstance('Horde_Db_Pear')->getOb();
+} catch (Horde_Exception $e) {
+ $cli->fatal($e);
+}
// Get new messages older time
$query = 'SELECT user_uid, user_email FROM folks_users ORDER BY user_uid ASC';
* @package Folks
*/
+// Disabled by default
exit;
-$folks_authentication = 'none';
-require_once dirname(__FILE__) . '/../lib/base.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('folks', array('authentication' => 'none', 'cli' => true));
-// Make sure no one runs this from the web.
-if (!Horde_Cli::runningFromCLI()) {
- exit("Must be run from the command line\n");
-}
-
-// Load the CLI environment.
-$cli = Horde_Cli::init();
-
-$db = DB::connect($conf['sql']);
-if ($db instanceof PEAR_Error) {
- $cli->fatal($db);
+try {
+ $db = $injector->getInstance('Horde_Db_Pear')->getOb();
+} catch (Horde_Exception $e) {
+ $cli->fatal($e);
}
$users = array();
*
* @param array $params Any parameters the backend might need.
*/
- function SyncML_Backend_Horde($params)
+ function __construct($params)
{
- parent::SyncML_Backend($params);
+ parent::__construct($params);
- $this->_db = DB::connect($GLOBALS['conf']['sql']);
-
- if (is_a($this->_db, 'PEAR_Error')) {
- Horde::logMessage($this->_db, 'ERR');
- }
-
- /* Set DB portability options. */
- if (is_a($this->_db, 'DB_common')) {
- switch ($this->_db->phptype) {
- case 'mssql':
- $this->_db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS | DB_PORTABILITY_RTRIM);
- break;
- default:
- $this->_db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS);
- }
- }
+ $this->_db = $GLOBALS['injector']->getInstance('Horde_Db_Pear')->getOb();
}
/**
switch ($db_lib) {
case 'DB':
- require_once 'DB.php';
- $dbh = DB::connect($conf['sql']);
+ $dbh = $injector->getInstance('Horde_Db_Pear')->getOb();
break;
case 'MDB2':
$name = $cli->prompt(_("Enter value for pref_name:"));
/* Open the database. */
-$db = DB::connect($conf['sql']);
-if (is_a($db, 'PEAR_Error')) {
- var_dump($db);
- exit;
-}
-
-// Set DB portability options.
-switch ($db->phptype) {
-case 'mssql':
- $db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS | DB_PORTABILITY_RTRIM);
- break;
-default:
- $db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS);
-}
+$db = $injector->getInstance('Horde_Db_Pear')->getOb();
if ($live) {
$sql = 'DELETE FROM horde_prefs WHERE pref_scope = ? AND pref_name = ?';
require_once dirname(__FILE__) . '/horde-base.php';
Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
-$dbh = DB::connect($conf['sql']);
-if (is_a($dbh, 'PEAR_Error')) {
- throw new Horde_Exception_Prior($dbh);
-}
-$dbh->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS);
+$dbh = $injector->getInstance('Horde_Db_Pear')->getOb();
// list databases command
// $result = $dbh->getListOf('databases');
<?php
-$dbh = DB::connect($conf['sql']);
-if (is_a($dbh, 'PEAR_Error')) {
- throw new Horde_Exception_Prior($dbh);
-}
-$dbh->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS);
+$dbh = $injector->getInstance('Horde_Db_Pear')->getOb();
if (Horde_Util::getFormData('list-tables')) {
$description = 'LIST TABLES';
// store this in whichever backend you require.
// // NOTE: You NEED Turba to be correctly installed before you can use
// // this example. It also assumes you are using an SQL backend.
-// $db = DB::connect($GLOBALS['conf']['sql'], true);
+// $db = $GLOBALS['injector']->getInstance('Horde_Db_Pear')->getOb();
//
// $fields = $values = array();
// foreach ($extra as $field => $value) {
// switch ($groupName) {
// case 'IT_department':
// $dept = 'IT';
-// $db = DB::connect($conf['sql'], true);
+// $db = $GLOBALS['injector']->getInstance('Horde_Db_Pear')->getOb();
// $query = 'SELECT COUNT(*) FROM departments WHERE user_name = ? AND department = ?';
// $values = array($userName, $dept);
// $result = $db->getOne($query, $values);
function _params()
{
- if (!@include_once 'Services/Weather.php') {
+ if (!class_exists('Services_Weather')) {
Horde::logMessage('The metar block will not work without Services_Weather from PEAR. Run pear install Services_Weather.', 'ERR');
return array(
'error' => array(
global $conf;
// Get locations from the database.
- require_once 'DB.php';
- $db = &DB::connect($conf['sql']);
- if (is_a($db, 'PEAR_Error')) {
- return $db;
- }
-
- // Set DB portability options.
- switch ($db->phptype) {
- case 'mssql':
- $db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS | DB_PORTABILITY_RTRIM);
- break;
- default:
- $db->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS);
- }
+ $db = $injector->getInstance('Horde_Db_Pear')->getOb();
$result = $db->query('SELECT icao, name, country FROM metarAirports ORDER BY country');
if (is_a($result, 'PEAR_Error')) {
(?, ?)
';
-$db = DB::connect($conf['sql']);
+$db = $injector->getInstance('Horde_Db_Pear')->getOb();
foreach ($g->listGroups(true) as $id => $name) {
if ($id == -1) {
(?, ?, ?, ?)
';
-$db = DB::connect($conf['sql']);
+$db = $injector->getInstance('Horde_Db_Pear')->getOb();
foreach ($p->getTree() as $id => $row) {
if ($id == -1) {
/* Prepare DB stuff. */
PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, create_function('$e', 'echo $e->toString()."\n";exit;'));
-$db = DB::connect($conf['sql']);
+$db = $injector->getInstance('Horde_Db_Pear')->getOb();
$result = $db->query('SELECT event_title, event_id, event_creator_id, event_start, event_end, event_allday, event_recurenddate FROM ' . $conf['calendar']['params']['table'] . ' ORDER BY event_creator_id');
$stmt = $db->prepare('UPDATE kronolith_events SET event_start = ?, event_end = ?, event_recurenddate = ? WHERE event_id = ?');
* @author David Cummings <davidcummings@acm.org>
* @package Vilma
*/
-
-require_once 'Horde/SQL.php';
-
class Vilma_Driver_qmailldap extends Vilma_Driver {
/**
* @package Wicked
*/
-/** DB */
-require_once 'DB.php';
-
/**
* Wicked storage implementation for PHP's PEAR database abstraction
* layer.