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:  * Base class for the Horde bundle API.
  4:  *
  5:  * Copyright 2011-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  Jan Schneider <chuck@horde.org>
 11:  * @package Core
 12:  */
 13: abstract class Horde_Core_Bundle
 14: {
 15:     /**
 16:      * @var Horde_Core_Cli
 17:      */
 18:     protected $_cli;
 19: 
 20:     /**
 21:      * @var Horde_Config
 22:      */
 23:     protected $_config;
 24: 
 25:     /**
 26:      * Path to the PEAR configuration file.
 27:      *
 28:      * @var string
 29:      */
 30:     protected $_pearconf;
 31: 
 32:     /**
 33:      * Constructor.
 34:      */
 35:     public function __construct(Horde_Core_Cli $cli, $pearconf = null)
 36:     {
 37:         $this->_cli = $cli;
 38:         $this->_pearconf = $pearconf;
 39:     }
 40: 
 41:     /**
 42:      * Creates and loads a basic conf.php configuration file.
 43:      */
 44:     public function init()
 45:     {
 46:         // Check if conf.php is writeable.
 47:         if ((file_exists(HORDE_BASE . '/config/conf.php') &&
 48:              !is_writable(HORDE_BASE . '/config/conf.php')) ||
 49:             !is_writable(HORDE_BASE . '/config')) {
 50:             $this->_cli->message(Horde_Util::realPath(HORDE_BASE . '/config/conf.php') . ' is not writable.', 'cli.error');
 51:         }
 52: 
 53:         // We need a valid conf.php to instantiate the registry.
 54:         if (!file_exists(HORDE_BASE . '/config/conf.php')) {
 55:             copy(HORDE_BASE . '/config/conf.php.dist', HORDE_BASE . '/config/conf.php');
 56:         }
 57: 
 58:         // Initialization
 59:         $umask = umask();
 60:         Horde_Registry::appInit('horde', array('nocompress' => true, 'authentication' => 'none'));
 61:         $this->_config = new Horde_Config();
 62:         umask($umask);
 63:     }
 64: 
 65:     /**
 66:      * Asks for the database settings and creates the SQL configuration.
 67:      */
 68:     public function configDb()
 69:     {
 70:         $this->_cli->writeln();
 71:         $this->_cli->writeln($this->_cli->bold('Configuring database settings'));
 72:         $this->_cli->writeln();
 73: 
 74:         $sql_config = $this->_config->configSQL('');
 75:         $vars = new Horde_Variables();
 76:         new Horde_Config_Form($vars, 'horde', true);
 77:         $this->_cli->question(
 78:             $vars,
 79:             'sql',
 80:             'phptype',
 81:             $sql_config['switch']['custom']['fields']['phptype']);
 82: 
 83:         $this->writeConfig($vars);
 84:     }
 85: 
 86:     /**
 87:      * Creates or updates the database tables.
 88:      *
 89:      * @throws Horde_Db_Exception
 90:      */
 91:     public function migrateDb()
 92:     {
 93:         $this->_cli->writeln();
 94:         echo 'Creating and updating database tables...';
 95: 
 96:         $migration = new Horde_Core_Db_Migration(null, $this->_pearconf);
 97: 
 98:         // Try twice to work around unresolved migration dependencies.
 99:         for ($i = 0; $i < 2; $i++) {
100:             $error = null;
101:             foreach ($migration->apps as $app) {
102:                 $migrator = $migration->getMigrator($app);
103:                 if ($migrator->getTargetVersion() <= $migrator->getCurrentVersion()) {
104:                     continue;
105:                 }
106:                 try {
107:                     $migrator->up();
108:                 } catch (Exception $error) {
109:                     if ($i) {
110:                         throw $error;
111:                     }
112:                 }
113:             }
114:             if (!$error) {
115:                 break;
116:             }
117:         }
118: 
119:         $this->_cli->writeln($this->_cli->green(' done.'));
120:     }
121: 
122:     /**
123:      * Asks for the administrator settings and creates the authentication
124:      * configuration.
125:      */
126:     public function configAuth()
127:     {
128:         $vars = new Horde_Variables();
129:         new Horde_Config_Form($vars, 'horde', true);
130:         $this->_cli->writeln();
131:         $this->_cli->writeln($this->_cli->bold('Configuring administrator settings'));
132:         $admin_user = $this->_configAuth($vars);
133:         $vars->auth__admins = $admin_user;
134:         $this->writeConfig($vars);
135:     }
136: 
137:     /**
138:      * Asks for the administrator settings.
139:      */
140:     abstract protected function _configAuth(Horde_Variables $vars);
141: 
142:     /**
143:      * Writes the current configuration to the conf.php file.
144:      *
145:      * @throws Horde_Exception
146:      */
147:     public function writeConfig(Horde_Variables $vars)
148:     {
149:         $this->_cli->writeln();
150:         echo 'Writing main configuration file...';
151: 
152:         $php_config = $this->_config->generatePHPConfig($vars, $GLOBALS['conf']);
153:         $configFile = $this->_config->configFile();
154:         $fp = fopen($configFile, 'w');
155:         if (!$fp) {
156:             throw new Horde_Exception('Cannot write configuration file ' . Horde_Util::realPath($configFile));
157:         }
158:         fwrite($fp, $php_config);
159:         fclose($fp);
160: 
161:         // Reload configuration.
162:         include $configFile;
163:         $GLOBALS['conf'] = $conf;
164: 
165:         $this->_cli->writeln($this->_cli->green(' done.'));
166:     }
167: 
168:     /**
169:      * Creates default configuration files for all installed applications.
170:      *
171:      * @throws Horde_Exception
172:      */
173:     public function writeAllConfigs()
174:     {
175:         foreach ($GLOBALS['registry']->listAllApps() as $app) {
176:             if ($app == 'horde' ||
177:                 !file_exists($GLOBALS['registry']->get('fileroot', $app) . '/config/conf.xml')) {
178:                 continue;
179:             }
180:             $config = new Horde_Config($app);
181:             $configFile = $config->configFile();
182:             if (!$config->writePHPConfig(new Horde_Variables())) {
183:                 throw new Horde_Exception('Cannot write configuration file ' . Horde_Util::realPath($configFile));
184:             }
185:         }
186:     }
187: }
188: 
API documentation generated by ApiGen