Overview

Packages

  • Horde
  • None

Classes

  • Horde_Application
  • Horde_Test

Functions

  • _
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Horde application API.
  4:  *
  5:  * This file defines Horde's core API interface. Other core Horde libraries
  6:  * can interact with Horde through this API.
  7:  *
  8:  * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
  9:  *
 10:  * See the enclosed file COPYING for license information (LGPL). If you
 11:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 12:  *
 13:  * @package Horde
 14:  */
 15: 
 16: /* Load the Horde Framework core (needed to autoload
 17:  * Horde_Registry_Application::). */
 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:         // Destroy any session-only temp files (since Horde_Core 1.7.0).
 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) {/*what to do if this fails?*/}
 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($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:         /* Remove user from all groups */
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:         /* Remove the user from all application permissions */
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:                     // The Horde_Perms::ALL is used if this is a matrix perm,
166:                     // otherwise it's ignored in the method and the entry is
167:                     // totally removed.
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: 
API documentation generated by ApiGen