Skip to content

Commit

Permalink
Horde::loadConfiguration is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Feb 5, 2014
1 parent 69b0c31 commit 152d99b
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 44 deletions.
3 changes: 2 additions & 1 deletion horde/config/hooks.php.dist
Expand Up @@ -767,7 +767,8 @@ class Horde_Hooks
// // this example does is include the attributes.php file from turba.
// // NOTE: You NEED Turba to be correctly installed before you can use
// // this example.
// return Horde::loadConfiguration('attributes.php', 'attributes', 'turba');
// $config = new Horde_Registry_Loadconfig('turba', 'attributes.php', 'attributes');
// return $config->config['attributes'];
// }


Expand Down
3 changes: 2 additions & 1 deletion horde/templates/login/login.inc
Expand Up @@ -91,5 +91,6 @@ $reset_passwd = !empty($conf['auth']['resetpassword']) && $auth->hasCapability('

<?php
try {
echo Horde::loadConfiguration('motd.php', 'motd', null, true);
$config = new Horde_Registry_Loadconfig('horde', 'motd.php');
echo $config->output;
} catch (Horde_Exception $e) {}
3 changes: 2 additions & 1 deletion horde/templates/login/resetpassword.inc
Expand Up @@ -5,5 +5,6 @@

<?php
try {
echo Horde::loadConfiguration('motd.php', 'motd', null, true);
$config = new Horde_Registry_Loadconfig('horde', 'motd.php');
echo $config->output;
} catch (Horde_Exception $e) {}
3 changes: 2 additions & 1 deletion horde/templates/login/signup.inc
Expand Up @@ -5,5 +5,6 @@

<?php
try {
echo Horde::loadConfiguration('motd.php', 'motd', null, true);
$config = new Horde_Registry_Loadconfig('horde', 'motd.php');
echo $config->output;
} catch (Horde_Exception $e) {}
7 changes: 2 additions & 5 deletions imp/lib/Imap.php
Expand Up @@ -877,16 +877,13 @@ static public function loadServerConfig($server = null)
{
if (empty(self::$_backends)) {
try {
$s = Horde::loadConfiguration('backends.php', 'servers', 'imp');
if (is_null($s)) {
return false;
}
$s = new Horde_Registry_Loadconfig('imp', 'backends.php', 'servers');
} catch (Horde_Exception $e) {
Horde::log($e, 'ERR');
return false;
}

foreach ($s as $key => $val) {
foreach ($s->config['servers'] as $key => $val) {
if (empty($val['disabled'])) {
self::$_backends[$key] = new IMP_Imap_Config($val);
}
Expand Down
10 changes: 3 additions & 7 deletions ingo/lib/Application.php
Expand Up @@ -313,9 +313,10 @@ protected function _listRulesets()
return $this->_rulesets;
}

$this->_rulesets = array();

try {
if (!($share = $injector->getInstance('Ingo_Shares'))) {
$this->_rulesets = array();
return $this->_rulesets;
}

Expand All @@ -325,17 +326,12 @@ protected function _listRulesets()
);
} catch (Horde_Share_Exception $e) {
Horde::log($e, 'ERR');
$this->_rulesets = array();
return $this->_rulesets;
}

/* Check if filter backend of the share still exists. */
$backends = Horde::loadConfiguration('backends.php', 'backends', 'ingo');
if (!isset($backends) || !is_array($backends)) {
throw new Ingo_Exception(_("No backends configured in backends.php"));
}
$backends = Ingo::loadBackends();

$this->_rulesets = array();
foreach ($tmp as $id => $ruleset) {
list($backend) = explode(':', $id);
if (isset($backends[$backend]) &&
Expand Down
3 changes: 2 additions & 1 deletion ingo/lib/Basic/Rule.php
Expand Up @@ -56,7 +56,8 @@ protected function _init()
}

/* This provides the $ingo_fields array. */
$ingo_fields = Horde::loadConfiguration('fields.php', 'ingo_fields', 'ingo');
$config = new Horde_Registry_LoadConfig('ingo', 'fields.php', 'ingo_fields');
$ingo_fields = $config->config['ingo_fields'];

/* Get the current rules. */
$ingo_storage = $injector->getInstance('Ingo_Factory_Storage')->create();
Expand Down
17 changes: 17 additions & 0 deletions ingo/lib/Ingo.php
Expand Up @@ -357,4 +357,21 @@ static public function ruleDescription($rule)
return $descrip;
}

/**
* Loads the backends.php configuration file.
*
* @return array Configuration data.
* @throws Horde_Exception
*/
static public function loadBackends()
{
$config = new Horde_Registry_Loadconfig('ingo', 'backends.php', 'backends');
if (empty($config->config['backends']) ||
!is_array($config->config['backends'])) {
throw new Ingo_Exception(_("No backends configured in backends.php"));
}

return $config->config['backends'];
}

}
31 changes: 13 additions & 18 deletions ingo/lib/Session.php
Expand Up @@ -114,41 +114,36 @@ static public function create()
*/
static protected function _getBackend()
{
$backends = Horde::loadConfiguration('backends.php', 'backends', 'ingo');
if (!isset($backends) || !is_array($backends)) {
throw new Ingo_Exception(_("No backends configured in backends.php"));
}

$backend = null;
foreach ($backends as $name => $temp) {
if (!empty($temp['disabled'])) {

foreach (Ingo::loadBackends() as $name => $val) {
if (!empty($val['disabled'])) {
continue;
}

$val['id'] = $name;

if (!isset($backend)) {
$backend = $name;
} elseif (!empty($temp['preferred'])) {
if (is_array($temp['preferred'])) {
foreach ($temp['preferred'] as $val) {
$backend = $val;
} elseif (!empty($val['preferred'])) {
if (is_array($val['preferred'])) {
foreach ($val['preferred'] as $val) {
if (($val == $_SERVER['SERVER_NAME']) ||
($val == $_SERVER['HTTP_HOST'])) {
$backend = $name;
$backend = $val;
}
}
} elseif (($temp['preferred'] == $_SERVER['SERVER_NAME']) ||
($temp['preferred'] == $_SERVER['HTTP_HOST'])) {
$backend = $name;
} elseif (($val['preferred'] == $_SERVER['SERVER_NAME']) ||
($val['preferred'] == $_SERVER['HTTP_HOST'])) {
$backend = $val;
}
}

$backends[$name]['id'] = $name;
}

/* Check for valid backend configuration. */
if (is_null($backend)) {
throw new Ingo_Exception(_("No backend configured for this host"));
}
$backend = $backends[$backend];

foreach (array('script', 'transport') as $val) {
if (empty($backend[$val])) {
Expand Down
2 changes: 1 addition & 1 deletion ingo/package.xml
Expand Up @@ -541,7 +541,7 @@
<package>
<name>Horde_Core</name>
<channel>pear.horde.org</channel>
<min>2.0.0</min>
<min>2.12.0</min>
<max>3.0.0alpha1</max>
<exclude>3.0.0alpha1</exclude>
</package>
Expand Down
10 changes: 5 additions & 5 deletions turba/lib/Api.php
Expand Up @@ -1826,12 +1826,12 @@ public function deleteField($address = '', $field = '', $sources = array())
public function getSourcesConfig($filter = array())
{
$results = array();
$turba_sources = Horde::loadConfiguration('backends.php', 'cfgSources', 'turba');

foreach ($turba_sources as $key => $source) {
if (!empty($filter)) {
if (!empty($source[current(array_keys($filter))]) &&
$source[current(array_keys($filter))] == current($filter)) {
if (!empty($filter)) {
foreach (Turba::availableSources() as $key => $source) {
$curr = current(array_keys($filter));
if (!empty($source[$curr]) &&
($source[$curr] == current($filter))) {
$results[$key] = $source;
}
}
Expand Down
3 changes: 2 additions & 1 deletion turba/lib/Application.php
Expand Up @@ -87,7 +87,8 @@ protected function _init()
}

// Turba source and attribute configuration.
$attributes = Horde::loadConfiguration('attributes.php', 'attributes', 'turba');
$config = new Horde_Registry_Loadconfig('turba', 'attributes.php', 'attributes');
$attributes = $config->config['attributes'];
$cfgSources = Turba::availableSources();

/* UGLY UGLY UGLY - we should NOT be using this as a global
Expand Down
6 changes: 4 additions & 2 deletions turba/lib/Turba.php
Expand Up @@ -42,13 +42,15 @@ class Turba
*/
static public function availableSources()
{
$cfgSources = Horde::loadConfiguration('backends.php', 'cfgSources', 'turba');
$config = new Horde_Registry_Loadconfig('turba', 'backends.php', 'cfgSources');

$sources = array();
foreach ($cfgSources as $key => $source) {
foreach ($config->config['cfgSources'] as $key => $source) {
if (empty($source['disabled'])) {
$sources[$key] = $source;
}
}

return $sources;
}

Expand Down

0 comments on commit 152d99b

Please sign in to comment.