1: <?php
2: /**
3: * Preferences storage implementation that loads the default values from
4: * the configuration files.
5: *
6: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (LGPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
10: *
11: * @author Michael Slusarz <slusarz@horde.org>
12: * @category Horde
13: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
14: * @package Core
15: */
16: class Horde_Core_Prefs_Storage_Configuration extends Horde_Prefs_Storage_Base
17: {
18: /**
19: * The list of preference hooks defined.
20: *
21: * @var array
22: */
23: public $hooks = array();
24:
25: /**
26: */
27: public function get($scope_ob)
28: {
29: /* Read the configuration file.
30: * Values are in the $_prefs array. */
31: try {
32: $result = Horde::loadConfiguration('prefs.php', array('_prefs'), $scope_ob->scope);
33: } catch (Horde_Exception $e) {
34: return $scope_ob;
35: }
36:
37: if (!empty($result) && isset($result['_prefs'])) {
38: foreach ($result['_prefs'] as $name => $pref) {
39: if (!isset($pref['value'])) {
40: continue;
41: }
42:
43: $scope_ob->set($name, $pref['value']);
44: if (!empty($pref['locked'])) {
45: $scope_ob->setLocked($name, true);
46: }
47:
48: if (!empty($pref['hook'])) {
49: $this->hooks[$scope_ob->scope][] = $name;
50: }
51: }
52: }
53:
54: return $scope_ob;
55: }
56:
57: /**
58: */
59: public function store($scope_ob)
60: {
61: // Configuration files are read-only.
62: }
63:
64: /**
65: */
66: public function remove($scope = null, $pref = null)
67: {
68: // Configuration files are read-only.
69: }
70:
71: }
72: