1<?php
2/**
3 * EGgroupware setup - register all hooks
4 *
5 * @link http://www.egroupware.org
6 * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
7 * @package setup
8 * @copyright (c) 2011-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
9 * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
10 * @version $Id$
11 */
12
13/**
14 * setup command: register all hooks
15 */
16class setup_cmd_hooks extends setup_cmd
17{
18	/**
19	 * Constructor
20	 *
21	 * @param string $domain string with domain-name or array with all arguments
22	 * @param string $config_user=null user to config the domain (or header_admin_user)
23	 * @param string $config_passwd=null pw of above user
24	 * @param boolean $verbose=false if true, echos out some status information during the run
25	 */
26	function __construct($domain,$config_user=null,$config_passwd=null)
27	{
28		if (!is_array($domain))
29		{
30			$domain = array(
31				'domain'        => $domain,
32				'config_user'   => $config_user,
33				'config_passwd' => $config_passwd,
34			);
35		}
36		//echo __CLASS__.'::__construct()'; _debug_array($domain);
37		admin_cmd::__construct($domain);
38	}
39
40	/**
41	 * run the command: register all hooks
42	 *
43	 * @param boolean $check_only =false only run the checks (and throw the exceptions), but not the command itself
44	 * @return string success message
45	 * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
46	 * @throws Exception('header.inc.php not found!');
47	 */
48	protected function exec($check_only=false)
49	{
50		if ($check_only) return true;	// nothing to check, no arguments ...
51
52		// instanciate setup object and check authorisation
53		$this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain);
54
55		$this->check_installed($this->domain,15,$this->verbose);
56
57		global $setup_info;
58		foreach($setup_info as $appname => $info)
59		{
60			if ($info['currentver']) self::$egw_setup->register_hooks($appname);
61		}
62		$this->restore_db();
63
64		return lang('All hooks registered');
65	}
66}
67