From: <ral...@us...> - 2011-06-29 08:40:30
|
Author: ralfbecker Date: Wed Jun 29 10:40:24 2011 New Revision: 35554 URL: http://svn.stylite.de/viewvc/egroupware?rev=35554&view=rev Log: new setup command (object) to register all hooks and adding it to setup-cli.php Added: trunk/setup/inc/class.setup_cmd_hooks.inc.php (with props) Modified: trunk/setup/setup-cli.php Added: trunk/setup/inc/class.setup_cmd_hooks.inc.php URL: http://svn.stylite.de/viewvc/egroupware/trunk/setup/inc/class.setup_cmd_hooks.inc.php?rev=35554&view=auto ============================================================================== --- trunk/setup/inc/class.setup_cmd_hooks.inc.php (added) +++ trunk/setup/inc/class.setup_cmd_hooks.inc.php Wed Jun 29 10:40:24 2011 @@ -1,0 +1,66 @@ +<?php +/** + * EGgroupware setup - register all hooks + * + * @link http://www.egroupware.org + * @author Ralf Becker <RalfBecker-AT-outdoor-training.de> + * @package setup + * @copyright (c) 2011 by Ralf Becker <RalfBecker-AT-outdoor-training.de> + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License + * @version $Id$ + */ + +/** + * setup command: register all hooks + */ +class setup_cmd_hooks extends setup_cmd +{ + /** + * Constructor + * + * @param string $domain string with domain-name or array with all arguments + * @param string $config_user=null user to config the domain (or header_admin_user) + * @param string $config_passwd=null pw of above user + * @param boolean $verbose=false if true, echos out some status information during the run + */ + function __construct($domain,$config_user=null,$config_passwd=null) + { + if (!is_array($domain)) + { + $domain = array( + 'domain' => $domain, + 'config_user' => $config_user, + 'config_passwd' => $config_passwd, + ); + } + //echo __CLASS__.'::__construct()'; _debug_array($domain); + admin_cmd::__construct($domain); + } + + /** + * run the command: register all hooks + * + * @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself + * @return string success message + * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); + * @throws Exception('header.inc.php not found!'); + */ + protected function exec($check_only=false) + { + if ($check_only) return true; // nothing to check, no arguments ... + + // instanciate setup object and check authorisation + $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); + + $this->check_installed($this->domain,15,$this->verbose); + + global $setup_info; + foreach($setup_info as $appname => $info) + { + if ($info['currentver']) self::$egw_setup->register_hooks($appname); + } + $this->restore_db(); + + return lang('All hooks registered'); + } +} Propchange: trunk/setup/inc/class.setup_cmd_hooks.inc.php ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/setup/inc/class.setup_cmd_hooks.inc.php ------------------------------------------------------------------------------ svn:keywords = Author Date Id Rev URL Modified: trunk/setup/setup-cli.php URL: http://svn.stylite.de/viewvc/egroupware/trunk/setup/setup-cli.php?rev=35554&r1=35553&r2=35554&view=diff ============================================================================== --- trunk/setup/setup-cli.php (original) +++ trunk/setup/setup-cli.php Wed Jun 29 10:40:24 2011 @@ -79,6 +79,11 @@ case '--update': do_update($arguments[0]); + break; + + case '--register-hooks': + case '--register-all-hooks': + do_hooks($arguments[0]); break; case '--backup': @@ -162,6 +167,32 @@ } /** + * Register all hooks + * + * @param array $args domain(default),[config user(admin)],password + */ +function do_hooks($arg) +{ + global $setup_info; + + list($domain,$user,$password) = explode(',',$arg); + _fetch_user_password($user,$password); + + $domains = $GLOBALS['egw_domain']; + if ($domain && $domain != 'all') + { + $domains = array($domain => $GLOBALS['egw_domain'][$domain]); + } + + foreach($domains as $domain => $data) + { + $cmd = new setup_cmd_hooks($domain,$user,$password); + echo "$domain: ".$cmd->run()."\n"; + } + echo "\n"; +} + +/** * Updates the default EMailAdmin profile * * @param array $values @@ -503,6 +534,7 @@ echo '--language '.lang('install or update translations: domain(all),[config user(admin)],password,[[+]lang1[,lang2,...]] + adds, no langs update existing ones')."\n"; echo '--backup '.lang('domain(all),[config user(admin)],password,[file-name(default: backup-dir/db_backup-YYYYMMDDHHii)]')."\n"; echo '--update '.lang('run a database schema update (if necessary): domain(all),[config user(admin)],password').'[,[no = no backup][,app to install]]'."\n"; + echo '--register-hooks '.lang('Find and Register all Application Hooks').": domain(all),[config user(admin)],password\n"; echo lang('You can use the header user and password for every domain too. If the password is not set via the commandline, it is read from the enviroment variable EGW_CLI_PASSWORD or queried from the user.')."\n"; } if (!$what || $what == 'header') |