mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
new setup command (object) to register all hooks and adding it to setup-cli.php
This commit is contained in:
parent
37ec659a8f
commit
e2b385ed9c
66
setup/inc/class.setup_cmd_hooks.inc.php
Normal file
66
setup/inc/class.setup_cmd_hooks.inc.php
Normal file
@ -0,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');
|
||||
}
|
||||
}
|
@ -81,6 +81,11 @@ switch($action)
|
||||
do_update($arguments[0]);
|
||||
break;
|
||||
|
||||
case '--register-hooks':
|
||||
case '--register-all-hooks':
|
||||
do_hooks($arguments[0]);
|
||||
break;
|
||||
|
||||
case '--backup':
|
||||
do_backup($arguments[0]);
|
||||
break;
|
||||
@ -161,6 +166,32 @@ function do_config($args)
|
||||
$cmd->get_config(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
@ -503,6 +534,7 @@ function do_usage($what='')
|
||||
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')
|
||||
|
Loading…
Reference in New Issue
Block a user