Overview

Packages

  • Auth
  • Core
  • Horde
    • Imsp
  • None
  • Notification

Classes

  • Horde
  • Horde_Config
  • Horde_Config_Form
  • Horde_Core_ActiveSync_Connector
  • Horde_Core_ActiveSync_Driver
  • Horde_Core_Ajax_Application
  • Horde_Core_Ajax_Imple
  • Horde_Core_Ajax_Imple_AutoCompleter
  • Horde_Core_Ajax_Imple_Geocoder_Geonames
  • Horde_Core_Ajax_Imple_SpellChecker
  • Horde_Core_Alarm_Handler_Notify
  • Horde_Core_Auth_Application
  • Horde_Core_Auth_Composite
  • Horde_Core_Auth_Ldap
  • Horde_Core_Auth_Msad
  • Horde_Core_Auth_Shibboleth
  • Horde_Core_Auth_Signup_Base
  • Horde_Core_Auth_Signup_Form
  • Horde_Core_Auth_Signup_Null
  • Horde_Core_Auth_Signup_Sql
  • Horde_Core_Auth_Signup_SqlObject
  • Horde_Core_Autoloader_Callback_Mime
  • Horde_Core_Autoloader_Callback_Nls
  • Horde_Core_Block
  • Horde_Core_Block_Collection
  • Horde_Core_Block_Layout
  • Horde_Core_Block_Layout_Manager
  • Horde_Core_Block_Layout_View
  • Horde_Core_Block_Upgrade
  • Horde_Core_Browser
  • Horde_Core_Bundle
  • Horde_Core_Cli
  • Horde_Core_Controller_NotFound
  • Horde_Core_Controller_RequestConfiguration
  • Horde_Core_Controller_RequestMapper
  • Horde_Core_Controller_SettingsFinder
  • Horde_Core_Db_Migration
  • Horde_Core_Factory_ActiveSyncBackend
  • Horde_Core_Factory_ActiveSyncServer
  • Horde_Core_Factory_ActiveSyncState
  • Horde_Core_Factory_Ajax
  • Horde_Core_Factory_Alarm
  • Horde_Core_Factory_Auth
  • Horde_Core_Factory_AuthSignup
  • Horde_Core_Factory_Base
  • Horde_Core_Factory_BlockCollection
  • Horde_Core_Factory_Browser
  • Horde_Core_Factory_Cache
  • Horde_Core_Factory_Crypt
  • Horde_Core_Factory_Data
  • Horde_Core_Factory_Db
  • Horde_Core_Factory_DbBase
  • Horde_Core_Factory_DbPear
  • Horde_Core_Factory_Dns
  • Horde_Core_Factory_Editor
  • Horde_Core_Factory_Facebook
  • Horde_Core_Factory_Group
  • Horde_Core_Factory_History
  • Horde_Core_Factory_HttpClient
  • Horde_Core_Factory_Identity
  • Horde_Core_Factory_Image
  • Horde_Core_Factory_Imple
  • Horde_Core_Factory_Imsp
  • Horde_Core_Factory_ImspAuth
  • Horde_Core_Factory_Injector
  • Horde_Core_Factory_KolabServer
  • Horde_Core_Factory_KolabSession
  • Horde_Core_Factory_KolabStorage
  • Horde_Core_Factory_Ldap
  • Horde_Core_Factory_Lock
  • Horde_Core_Factory_Logger
  • Horde_Core_Factory_LoginTasks
  • Horde_Core_Factory_Mail
  • Horde_Core_Factory_Mapper
  • Horde_Core_Factory_Matcher
  • Horde_Core_Factory_Memcache
  • Horde_Core_Factory_MimeViewer
  • Horde_Core_Factory_Notification
  • Horde_Core_Factory_Perms
  • Horde_Core_Factory_PermsCore
  • Horde_Core_Factory_Prefs
  • Horde_Core_Factory_Request
  • Horde_Core_Factory_Secret
  • Horde_Core_Factory_SessionHandler
  • Horde_Core_Factory_Share
  • Horde_Core_Factory_ShareBase
  • Horde_Core_Factory_Template
  • Horde_Core_Factory_TextFilter
  • Horde_Core_Factory_ThemesCache
  • Horde_Core_Factory_Token
  • Horde_Core_Factory_Tree
  • Horde_Core_Factory_Twitter
  • Horde_Core_Factory_UrlShortener
  • Horde_Core_Factory_Vfs
  • Horde_Core_Factory_View
  • Horde_Core_Factory_Weather
  • Horde_Core_Group_Ldap
  • Horde_Core_Log_Logger
  • Horde_Core_LoginTasks
  • Horde_Core_LoginTasks_Backend_Horde
  • Horde_Core_LoginTasks_SystemTask_Upgrade
  • Horde_Core_Mime_Viewer_Syntaxhighlighter
  • Horde_Core_Mime_Viewer_Vcard
  • Horde_Core_Notification_Event_Status
  • Horde_Core_Notification_Handler_Decorator_Hordelog
  • Horde_Core_Notification_Storage_Session
  • Horde_Core_Perms
  • Horde_Core_Perms_Ui
  • Horde_Core_Prefs_Cache_Session
  • Horde_Core_Prefs_Identity
  • Horde_Core_Prefs_Storage_Configuration
  • Horde_Core_Prefs_Storage_Hooks
  • Horde_Core_Prefs_Storage_Upgrade
  • Horde_Core_Prefs_Ui
  • Horde_Core_Prefs_Ui_Widgets
  • Horde_Core_Share_Driver
  • Horde_Core_Share_FactoryCallback
  • Horde_Core_Sidebar
  • Horde_Core_Text_Filter_Bbcode
  • Horde_Core_Text_Filter_Emails
  • Horde_Core_Text_Filter_Emoticons
  • Horde_Core_Text_Filter_Highlightquotes
  • Horde_Core_Translation
  • Horde_Core_Tree_Html
  • Horde_Core_Tree_Javascript
  • Horde_Core_Tree_Simplehtml
  • Horde_Core_Ui_FlagImage
  • Horde_Core_Ui_JsCalendar
  • Horde_Core_Ui_Language
  • Horde_Core_Ui_Layout
  • Horde_Core_Ui_ModalFormRenderer
  • Horde_Core_Ui_Pager
  • Horde_Core_Ui_Tabs
  • Horde_Core_Ui_TagCloud
  • Horde_Core_Ui_VarRenderer
  • Horde_Core_Ui_VarRenderer_Html
  • Horde_Core_Ui_VarRenderer_TablesetHtml
  • Horde_Core_Ui_Widget
  • Horde_ErrorHandler
  • Horde_Help
  • Horde_Menu
  • Horde_Registry
  • Horde_Registry_Api
  • Horde_Registry_Application
  • Horde_Registry_Caller
  • Horde_Registry_Nlsconfig
  • Horde_Script_Files
  • Horde_Session
  • Horde_Session_Null
  • Horde_Themes
  • Horde_Themes_Cache
  • Horde_Themes_Css
  • Horde_Themes_Element
  • Horde_Themes_Image
  • Horde_Themes_Sound

Exceptions

  • Horde_Exception_HookNotSet
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Defines the AJAX interface for an application.
  4:  *
  5:  * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
  6:  *
  7:  * See the enclosed file COPYING for license information (LGPL). If you
  8:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
  9:  *
 10:  * @author   Michael Slusarz <slusarz@horde.org>
 11:  * @category Horde
 12:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 13:  * @package  Core
 14:  */
 15: abstract class Horde_Core_Ajax_Application
 16: {
 17:     /**
 18:      * Determines if notification information is sent in response.
 19:      *
 20:      * @var boolean
 21:      */
 22:     public $notify = false;
 23: 
 24:     /**
 25:      * The action to perform.
 26:      *
 27:      * @var string
 28:      */
 29:     protected $_action;
 30: 
 31:     /**
 32:      * The Horde application.
 33:      *
 34:      * @var string
 35:      */
 36:     protected $_app;
 37: 
 38:     /**
 39:      * Default domain.
 40:      *
 41:      * @see parseEmailAddress()
 42:      * @var string
 43:      */
 44:     protected $_defaultDomain;
 45: 
 46:     /**
 47:      * The list of actions that require readonly access to the session.
 48:      *
 49:      * @var array
 50:      */
 51:     protected $_readOnly = array();
 52: 
 53:     /**
 54:      * The request variables.
 55:      *
 56:      * @var Horde_Variables
 57:      */
 58:     protected $_vars;
 59: 
 60:     /**
 61:      * Constructor.
 62:      *
 63:      * @param string $app            The application name.
 64:      * @param Horde_Variables $vars  Form/request data.
 65:      * @param string $action         The AJAX action to perform.
 66:      */
 67:     public function __construct($app, Horde_Variables $vars, $action = null)
 68:     {
 69:         $this->_app = $app;
 70:         $this->_vars = $vars;
 71: 
 72:         if (!is_null($action)) {
 73:             /* Close session if action is labeled as read-only. */
 74:             if (in_array($action, $this->_readOnly)) {
 75:                 $GLOBALS['session']->close();
 76:             }
 77: 
 78:             $this->_action = $action;
 79:         }
 80:     }
 81: 
 82:     /**
 83:      * Performs the AJAX action.
 84:      *
 85:      * @return mixed  The result of the action call.
 86:      * @throws Horde_Exception
 87:      */
 88:     public function doAction()
 89:     {
 90:         if (!$this->_action) {
 91:             return false;
 92:         }
 93: 
 94:         if (method_exists($this, $this->_action)) {
 95:             return call_user_func(array($this, $this->_action));
 96:         }
 97: 
 98:         /* Look for hook in application. */
 99:         try {
100:             return Horde::callHook('ajaxaction', array($this->_action, $this->_vars), $this->_app);
101:         } catch (Horde_Exception_HookNotSet $e) {
102:         } catch (Horde_Exception $e) {
103:         }
104: 
105:         throw new Horde_Exception('Handler for action "' . $this->_action . '" does not exist.');
106:     }
107: 
108:     /**
109:      * Determines the HTTP response output type.
110:      *
111:      * @see Horde::sendHTTPResponse().
112:      *
113:      * @return string  The output type.
114:      */
115:     public function responseType()
116:     {
117:         return 'json';
118:     }
119: 
120:     /**
121:      * Logs the user off the Horde session.
122:      *
123:      * This needs to be done here (server), rather than on the browser,
124:      * because the logout tokens might otherwise expire.
125:      */
126:     public function logOut()
127:     {
128:         Horde::getServiceLink('logout', $this->_app)->setRaw(true)->redirect();
129:     }
130: 
131:     /**
132:      * AJAX actions performed through the endpoint are normally not a good
133:      * URL to return to.  Thus, by default after a session timeout, return
134:      * to the base of the application instead.
135:      *
136:      * @return Horde_Url  The logout Horde_Url object.
137:      */
138:     public function getSessionLogoutUrl()
139:     {
140:         return $GLOBALS['registry']->getLogoutUrl(array(
141:             'reason' => Horde_Auth::REASON_SESSION
142:         ))->add('url', Horde::url('', false, array(
143:             'app' => $this->_app,
144:             'append_session' => -1
145:         )));
146:     }
147: 
148:     /**
149:      * Returns a hash of group IDs and group names that the user has access
150:      * to.
151:      *
152:      * @return object  Object with the following properties:
153:      *   - groups: (array) Groups hash.
154:      */
155:     public function listGroups()
156:     {
157:         $result = new stdClass;
158:         try {
159:             $groups = $GLOBALS['injector']
160:                 ->getInstance('Horde_Group')
161:                 ->listAll(empty($GLOBALS['conf']['share']['any_group'])
162:                           ? $GLOBALS['registry']->getAuth()
163:                           : null);
164:             if ($groups) {
165:                 asort($groups);
166:                 $result->groups = $groups;
167:             }
168:         } catch (Horde_Group_Exception $e) {
169:             Horde::logMessage($e);
170:         }
171: 
172:         return $result;
173:     }
174: 
175:     /**
176:      * Parses a valid email address out of a complete address string.
177:      *
178:      * Variables used:
179:      *   - mbox: (string) The name of the new mailbox.
180:      *   - parent: (string) The parent mailbox.
181:      *
182:      * @return object  Object with the following properties:
183:      *   - email: (string) The parsed email address.
184:      *
185:      * @throws Horde_Exception
186:      * @throws Horde_Mail_Exception
187:      */
188:     public function parseEmailAddress()
189:     {
190:         $rfc822 = new Horde_Mail_Rfc822();
191:         $params = array();
192:         if ($this->_defaultDomain) {
193:             $params['default_domain'] = $this->_defaultDomain;
194:         }
195:         $res = $rfc822->parseAddressList(Horde_Mime::encodeAddress($this->_vars->email, 'UTF-8', $this->_defaultDomain), $params);
196:         if (!count($res)) {
197:             throw new Horde_Exception(Horde_Core_Translation::t("No valid email address found"));
198:         }
199: 
200:         return (object)array(
201:             'email' => Horde_Mime_Address::writeAddress($res[0]->mailbox, $res[0]->host)
202:         );
203:     }
204: 
205:     /**
206:      * Loads a chunk of PHP code (usually an HTML template) from the
207:      * application's templates directory.
208:      *
209:      * @return object  Object with the following properties:
210:      *   - chunk: (string) A chunk of PHP output.
211:      */
212:     public function chunkContent()
213:     {
214:         $chunk = basename(Horde_Util::getPost('chunk'));
215:         $result = new stdClass;
216:         if (!empty($chunk)) {
217:             Horde::startBuffer();
218:             include $GLOBALS['registry']->get('templates', $this->_app) . '/chunks/' . $chunk . '.php';
219:             $result->chunk = Horde::endBuffer();
220:         }
221: 
222:         return $result;
223:     }
224: 
225:     /**
226:      * Sets a preference value.
227:      *
228:      * Variables used:
229:      *   - pref: (string) The preference name.
230:      *   - value: (mixed) The preference value.
231:      *
232:      * @return boolean  True on success.
233:      */
234:     public function setPrefValue()
235:     {
236:         return $GLOBALS['prefs']->setValue($this->_vars->pref, $this->_vars->value);
237:     }
238: 
239: }
240: 
API documentation generated by ApiGen