1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: 17:
18: require_once dirname(__FILE__) . '/core.php';
19:
20: class Horde_Application extends Horde_Registry_Application
21: {
22: 23:
24: public $version = '4.0.17-git';
25:
26: 27:
28: public function logout()
29: {
30:
31: foreach ($GLOBALS['session']->get('horde', 'gc_tempfiles', Horde_Session::TYPE_ARRAY) as $file) {
32: @unlink($file);
33: }
34: }
35:
36: 37:
38: public function perms()
39: {
40: $permissions = array(
41: 'max_blocks' => array(
42: 'title' => _("Maximum Number of Portal Blocks"),
43: 'type' => 'int'
44: ),
45: 'administration' => array(
46: 'title' => _("Administration"),
47: )
48: );
49:
50: try {
51: foreach ($GLOBALS['registry']->callByPackage('horde', 'admin_list') as $perm_key => $perm_details) {
52: $permissions['administration:' . $perm_key] = array('title' => Horde::stripAccessKey($perm_details['name']));
53: }
54: } catch (Horde_Exception $e) {}
55:
56: return $permissions;
57: }
58:
59: 60:
61: public function hasPermission($permission, $allowed, $opts = array())
62: {
63: if (is_array($allowed)) {
64: switch ($permission) {
65: case 'max_blocks':
66: $allowed = max($allowed);
67: break;
68: }
69: }
70: return $allowed;
71: }
72:
73: 74:
75: public function ($menu)
76: {
77: $menu->add(Horde::url('services/portal/', false, array('app' => 'horde')), _("_Home"), 'horde.png');
78: }
79:
80: 81:
82: public function prefsInit($ui)
83: {
84: $GLOBALS['injector']->getInstance('Horde_Prefs_Ui')->prefsInit($ui);
85: }
86:
87: 88:
89: public function prefsGroup($ui)
90: {
91: $GLOBALS['injector']->getInstance('Horde_Prefs_Ui')->prefsGroup($ui);
92: }
93:
94: 95:
96: public function prefsSpecial($ui, $item)
97: {
98: return $GLOBALS['injector']->getInstance('Horde_Prefs_Ui')->prefsSpecial($ui, $item);
99: }
100:
101: 102:
103: public function prefsSpecialUpdate($ui, $item)
104: {
105: return $GLOBALS['injector']->getInstance('Horde_Prefs_Ui')->prefsSpecialUpdate($ui, $item);
106: }
107:
108: 109:
110: public function prefsCallback($ui)
111: {
112: $GLOBALS['injector']->getInstance('Horde_Prefs_Ui')->prefsCallback($ui);
113: }
114:
115: 116:
117: public function configSpecialValues($what)
118: {
119: switch ($what) {
120: case 'apps':
121: $apps = Horde_Array::valuesToKeys($GLOBALS['registry']->listApps(array('active')));
122: asort($apps);
123: return $apps;
124:
125: case 'languages':
126: return array_map(create_function('$val', 'return preg_replace(array("/&#x([0-9a-f]{4});/ie", "/(&[^;]+;)/e"), array("Horde_String::convertCharset(pack(\"H*\", \"$1\"), \"ucs-2\", \"UTF-8\")", "Horde_String::convertCharset(html_entity_decode(\"$1\", ENT_COMPAT, \"iso-8859-1\"), \"iso-8859-1\", \"UTF-8\")"), $val);'), $GLOBALS['registry']->nlsconfig->languages);
127:
128: case 'blocks':
129: return $GLOBALS['injector']->getInstance('Horde_Core_Factory_BlockCollection')->create()->getBlocksList();
130: }
131: }
132:
133: 134:
135: public function removeUserData($user)
136: {
137: $error = false;
138:
139:
140: $groups = $GLOBALS['injector']->getInstance('Horde_Group');
141: try {
142: $allGroups = $groups->listGroups($user);
143: foreach (array_keys($allGroups) as $id) {
144: $groups->removeUser($id, $user);
145: }
146: } catch (Horde_Group_Exception $e) {
147: Horde::logMessage($e, 'NOTICE');
148: $error = true;
149: }
150:
151:
152: $perms = $GLOBALS['injector']->getInstance('Horde_Perms');
153: try {
154: $tree = $perms->getTree();
155: } catch (Horde_Perms_Exception $e) {
156: Horde::logMessage($e, 'NOTICE');
157: $error = true;
158: $tree = array();
159: }
160:
161: foreach (array_keys($tree) as $id) {
162: try {
163: $perm = $perms->getPermissionById($id);
164: if ($perms->getPermissions($perm, $user)) {
165:
166:
167:
168: $perm->removeUserPermission($user, Horde_Perms::ALL, true);
169: }
170: } catch (Horde_Perms_Exception $e) {
171: Horde::logMessage($e, 'NOTICE');
172: $error = true;
173: }
174: }
175:
176: if ($error) {
177: throw new Horde_Exception(sprintf(_("There was an error removing global data for %s. Details have been logged."), $user));
178: }
179: }
180:
181: }
182: