@@ -30,14 +30,20 @@ discard block |
||
30 | 30 | include('../header.inc.php'); |
31 | 31 | } |
32 | 32 | // for an old header we need to setup a reference for the domains |
33 | -if (!is_array($GLOBALS['egw_domain'])) $GLOBALS['egw_domain'] =& $GLOBALS['phpgw_domain']; |
|
33 | +if (!is_array($GLOBALS['egw_domain'])) |
|
34 | +{ |
|
35 | + $GLOBALS['egw_domain'] =& $GLOBALS['phpgw_domain']; |
|
36 | +} |
|
34 | 37 | |
35 | 38 | /* If we included the header.inc.php, but it is somehow broken, cover ourselves... */ |
36 | 39 | if(!defined('EGW_SERVER_ROOT') && !defined('EGW_INCLUDE_ROOT')) |
37 | 40 | { |
38 | - if (defined('PHPGW_SERVER_ROOT') && defined('PHPGW_INCLUDE_ROOT')) // pre 1.2 install |
|
41 | + if (defined('PHPGW_SERVER_ROOT') && defined('PHPGW_INCLUDE_ROOT')) |
|
42 | + { |
|
43 | + // pre 1.2 install |
|
39 | 44 | { |
40 | 45 | define('EGW_SERVER_ROOT',PHPGW_SERVER_ROOT); |
46 | + } |
|
41 | 47 | define('EGW_INCLUDE_ROOT',PHPGW_INCLUDE_ROOT); |
42 | 48 | } |
43 | 49 | else // no install |
@@ -84,7 +90,10 @@ discard block |
||
84 | 90 | |
85 | 91 | if (!function_exists('version_compare') || version_compare(PHP_VERSION,$GLOBALS['egw_setup']->required_php_version,'<')) |
86 | 92 | { |
87 | - if (isset($_SERVER['HTTP_HOST'])) echo "<pre>\n"; |
|
93 | + if (isset($_SERVER['HTTP_HOST'])) |
|
94 | + { |
|
95 | + echo "<pre>\n"; |
|
96 | + } |
|
88 | 97 | echo "EGroupware now requires PHP {$GLOBALS['egw_setup']->required_php_version} or greater.\nYour PHP version is: ".PHP_VERSION."\n"; |
89 | 98 | echo 'Please contact your System Administrator.'; |
90 | 99 | exit; |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | * @version $Id$ |
14 | 14 | */ |
15 | 15 | |
16 | -error_reporting(error_reporting() & ~E_NOTICE & ~E_STRICT); |
|
16 | +error_reporting(error_reporting()&~E_NOTICE & ~E_STRICT); |
|
17 | 17 | |
18 | 18 | // for an old header, we need to setup the reference before including it |
19 | -$GLOBALS['phpgw_info'] =& $GLOBALS['egw_info']; |
|
19 | +$GLOBALS['phpgw_info'] = & $GLOBALS['egw_info']; |
|
20 | 20 | |
21 | 21 | $GLOBALS['egw_info'] = array( |
22 | 22 | 'flags' => array( |
@@ -25,48 +25,48 @@ discard block |
||
25 | 25 | 'currentapp' => 'setup', |
26 | 26 | 'noapi' => True |
27 | 27 | )); |
28 | -if(file_exists('../header.inc.php')) |
|
28 | +if (file_exists('../header.inc.php')) |
|
29 | 29 | { |
30 | 30 | include('../header.inc.php'); |
31 | 31 | } |
32 | 32 | // for an old header we need to setup a reference for the domains |
33 | -if (!is_array($GLOBALS['egw_domain'])) $GLOBALS['egw_domain'] =& $GLOBALS['phpgw_domain']; |
|
33 | +if (!is_array($GLOBALS['egw_domain'])) $GLOBALS['egw_domain'] = & $GLOBALS['phpgw_domain']; |
|
34 | 34 | |
35 | 35 | /* If we included the header.inc.php, but it is somehow broken, cover ourselves... */ |
36 | -if(!defined('EGW_SERVER_ROOT') && !defined('EGW_INCLUDE_ROOT')) |
|
36 | +if (!defined('EGW_SERVER_ROOT') && !defined('EGW_INCLUDE_ROOT')) |
|
37 | 37 | { |
38 | 38 | if (defined('PHPGW_SERVER_ROOT') && defined('PHPGW_INCLUDE_ROOT')) // pre 1.2 install |
39 | 39 | { |
40 | - define('EGW_SERVER_ROOT',PHPGW_SERVER_ROOT); |
|
41 | - define('EGW_INCLUDE_ROOT',PHPGW_INCLUDE_ROOT); |
|
40 | + define('EGW_SERVER_ROOT', PHPGW_SERVER_ROOT); |
|
41 | + define('EGW_INCLUDE_ROOT', PHPGW_INCLUDE_ROOT); |
|
42 | 42 | } |
43 | 43 | else // no install |
44 | 44 | { |
45 | - define('EGW_SERVER_ROOT',realpath('..')); |
|
46 | - define('EGW_INCLUDE_ROOT',realpath('..')); |
|
47 | - define('PHPGW_SERVER_ROOT',realpath('..')); |
|
48 | - define('PHPGW_INCLUDE_ROOT',realpath('..')); |
|
45 | + define('EGW_SERVER_ROOT', realpath('..')); |
|
46 | + define('EGW_INCLUDE_ROOT', realpath('..')); |
|
47 | + define('PHPGW_SERVER_ROOT', realpath('..')); |
|
48 | + define('PHPGW_INCLUDE_ROOT', realpath('..')); |
|
49 | 49 | } |
50 | - define('EGW_API_INC',EGW_SERVER_ROOT.'/phpgwapi/inc'); |
|
50 | + define('EGW_API_INC', EGW_SERVER_ROOT.'/phpgwapi/inc'); |
|
51 | 51 | } |
52 | 52 | |
53 | -require_once(EGW_INCLUDE_ROOT . '/api/src/loader/common.php'); |
|
53 | +require_once(EGW_INCLUDE_ROOT.'/api/src/loader/common.php'); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * function to handle multilanguage support |
57 | 57 | * |
58 | 58 | */ |
59 | -function lang($key,$vars=null) |
|
59 | +function lang($key, $vars = null) |
|
60 | 60 | { |
61 | - if(!is_array($vars)) |
|
61 | + if (!is_array($vars)) |
|
62 | 62 | { |
63 | 63 | $vars = func_get_args(); |
64 | - array_shift($vars); // remove $key |
|
64 | + array_shift($vars); // remove $key |
|
65 | 65 | } |
66 | 66 | return $GLOBALS['egw_setup']->translation->translate("$key", $vars); |
67 | 67 | } |
68 | 68 | |
69 | -if(file_exists(EGW_SERVER_ROOT.'/api/setup/setup.inc.php')) |
|
69 | +if (file_exists(EGW_SERVER_ROOT.'/api/setup/setup.inc.php')) |
|
70 | 70 | { |
71 | 71 | include(EGW_SERVER_ROOT.'/api/setup/setup.inc.php'); /* To set the current core version */ |
72 | 72 | /* This will change to just use setup_info */ |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | |
80 | 80 | $GLOBALS['egw_info']['server']['app_images'] = 'templates/default/images'; |
81 | 81 | |
82 | -CreateObject('setup.setup',True,True); // setup constuctor assigns itself to $GLOBALS['egw_setup'], doing it twice fails on some php4 |
|
83 | -$GLOBALS['phpgw_setup'] =& $GLOBALS['egw_setup']; |
|
82 | +CreateObject('setup.setup', True, True); // setup constuctor assigns itself to $GLOBALS['egw_setup'], doing it twice fails on some php4 |
|
83 | +$GLOBALS['phpgw_setup'] = & $GLOBALS['egw_setup']; |
|
84 | 84 | |
85 | -if (!function_exists('version_compare') || version_compare(PHP_VERSION,$GLOBALS['egw_setup']->required_php_version,'<')) |
|
85 | +if (!function_exists('version_compare') || version_compare(PHP_VERSION, $GLOBALS['egw_setup']->required_php_version, '<')) |
|
86 | 86 | { |
87 | 87 | if (isset($_SERVER['HTTP_HOST'])) echo "<pre>\n"; |
88 | 88 | echo "EGroupware now requires PHP {$GLOBALS['egw_setup']->required_php_version} or greater.\nYour PHP version is: ".PHP_VERSION."\n"; |
@@ -199,5 +199,8 @@ |
||
199 | 199 | { |
200 | 200 | $filter =& $settings['ldap_search_filter']; |
201 | 201 | |
202 | - if ($filter && $filter{0} != '(') $filter = '('.$filter.')'; |
|
203 | -} |
|
202 | + if ($filter && $filter{0} != '(') |
|
203 | + { |
|
204 | + $filter = '('.$filter.')'; |
|
205 | + } |
|
206 | + } |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | */ |
33 | 33 | function auth_type($settings) |
34 | 34 | { |
35 | - switch($settings['auth_type']) |
|
35 | + switch ($settings['auth_type']) |
|
36 | 36 | { |
37 | 37 | case 'mail': |
38 | 38 | if (class_exists('Horde_Imap_Client_Socket') && !in_array($settings['mail_server_type'], array('pop', 'pops'))) |
39 | 39 | { |
40 | - return; // we use Horde code instead of imap extension |
|
40 | + return; // we use Horde code instead of imap extension |
|
41 | 41 | } |
42 | 42 | try { |
43 | 43 | check_load_extension('imap', true); |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | */ |
58 | 58 | function vfs_storage_mode($settings) |
59 | 59 | { |
60 | - switch($settings['vfs_storage_mode']) |
|
60 | + switch ($settings['vfs_storage_mode']) |
|
61 | 61 | { |
62 | 62 | case 'fs': |
63 | - Api\Config::save_value('vfs_fstab','','phpgwapi'); |
|
63 | + Api\Config::save_value('vfs_fstab', '', 'phpgwapi'); |
|
64 | 64 | break; |
65 | 65 | case 'db': |
66 | 66 | Api\Config::save_value('vfs_fstab', array( |
67 | 67 | '/' => 'sqlfs://$host/?storage=db', |
68 | 68 | '/apps' => 'links://$host/apps?storage=db', |
69 | - ),'phpgwapi'); |
|
69 | + ), 'phpgwapi'); |
|
70 | 70 | break; |
71 | 71 | } |
72 | 72 | } |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | function temp_dir($settings) |
75 | 75 | { |
76 | 76 | $error_msg = null; |
77 | - if (!setup_detection::check_dir($settings['temp_dir'],$error_msg)) |
|
77 | + if (!setup_detection::check_dir($settings['temp_dir'], $error_msg)) |
|
78 | 78 | { |
79 | - $GLOBALS['config_error'] = lang("Your temporary directory '%1' %2",$settings['temp_dir'],$error_msg); |
|
79 | + $GLOBALS['config_error'] = lang("Your temporary directory '%1' %2", $settings['temp_dir'], $error_msg); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | 83 | function files_dir($settings) |
84 | 84 | { |
85 | 85 | $error_msg = null; |
86 | - if (!setup_detection::check_dir($settings['files_dir'],$error_msg,true)) |
|
86 | + if (!setup_detection::check_dir($settings['files_dir'], $error_msg, true)) |
|
87 | 87 | { |
88 | - $GLOBALS['config_error'] = lang("Your files directory '%1' %2",$settings['files_dir'],$error_msg); |
|
88 | + $GLOBALS['config_error'] = lang("Your files directory '%1' %2", $settings['files_dir'], $error_msg); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -96,20 +96,20 @@ discard block |
||
96 | 96 | $settings['backup_dir'] = $settings['files_dir'].'/db_backup'; |
97 | 97 | } |
98 | 98 | $error_msg = null; |
99 | - if (!setup_detection::check_dir($settings['backup_dir'],$error_msg,true)) |
|
99 | + if (!setup_detection::check_dir($settings['backup_dir'], $error_msg, true)) |
|
100 | 100 | { |
101 | - $GLOBALS['config_error'] = lang("Your backup directory '%1' %2",$settings['backup_dir'],$error_msg); |
|
101 | + $GLOBALS['config_error'] = lang("Your backup directory '%1' %2", $settings['backup_dir'], $error_msg); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | -function _mcrypt_test_module_mode($module,$mode) |
|
105 | +function _mcrypt_test_module_mode($module, $mode) |
|
106 | 106 | { |
107 | 107 | /* Data */ |
108 | 108 | $key_in = 'this is a very long key, even too long for the cipher'; |
109 | 109 | $plain_text = 'very important data'; |
110 | 110 | |
111 | 111 | /* Open module, and create IV */ |
112 | - if(!$GLOBALS['td'] = @mcrypt_module_open($module, '',$mode, '')) |
|
112 | + if (!$GLOBALS['td'] = @mcrypt_module_open($module, '', $mode, '')) |
|
113 | 113 | { |
114 | 114 | @mcrypt_module_close($GLOBALS['td']); |
115 | 115 | return False; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $iv = @mcrypt_create_iv($iv_size, MCRYPT_RAND); |
120 | 120 | |
121 | 121 | /* Initialize encryption handle */ |
122 | - if(mcrypt_generic_init($GLOBALS['td'], $key, $iv) != -1) |
|
122 | + if (mcrypt_generic_init($GLOBALS['td'], $key, $iv) != -1) |
|
123 | 123 | { |
124 | 124 | /* Encrypt data */ |
125 | 125 | $c_t = mcrypt_generic($GLOBALS['td'], $plain_text); |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | $modes = mcrypt_list_modes(); |
154 | 154 | $algorithms = mcrypt_list_algorithms(); |
155 | 155 | |
156 | - foreach($algorithms as $cipher) |
|
156 | + foreach ($algorithms as $cipher) |
|
157 | 157 | { |
158 | - if(mcrypt_module_self_test($cipher)) |
|
158 | + if (mcrypt_module_self_test($cipher)) |
|
159 | 159 | { |
160 | 160 | $GLOBALS['ciphers'][$cipher] = array(); |
161 | - foreach($modes as $mode) |
|
161 | + foreach ($modes as $mode) |
|
162 | 162 | { |
163 | - if(_mcrypt_test_module_mode($cipher,$mode)) |
|
163 | + if (_mcrypt_test_module_mode($cipher, $mode)) |
|
164 | 164 | { |
165 | 165 | $result = True; |
166 | 166 | } |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | function mcrypt_algo($settings) |
180 | 180 | { |
181 | 181 | /* _debug_array($settings);exit; */ |
182 | - if(@function_exists('mcrypt_list_modes')) |
|
182 | + if (@function_exists('mcrypt_list_modes')) |
|
183 | 183 | { |
184 | 184 | mcrypt_check_sanity(); |
185 | - if(!@$GLOBALS['ciphers'][$settings['mcrypt_algo']][$settings['mcrypt_mode']]) |
|
185 | + if (!@$GLOBALS['ciphers'][$settings['mcrypt_algo']][$settings['mcrypt_mode']]) |
|
186 | 186 | { |
187 | 187 | $GLOBALS['config_error'] = lang('Invalid Mcrypt Algorithm/Mode combination'); |
188 | 188 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | */ |
197 | 197 | function ldap_search_filter(&$settings) |
198 | 198 | { |
199 | - $filter =& $settings['ldap_search_filter']; |
|
199 | + $filter = & $settings['ldap_search_filter']; |
|
200 | 200 | |
201 | 201 | if ($filter && $filter{0} != '(') $filter = '('.$filter.')'; |
202 | 202 | } |
@@ -113,8 +113,14 @@ |
||
113 | 113 | self::$egw_setup->db->Link_ID->SetCharSet($this->charset); |
114 | 114 | $_POST['ConfigLang'] = $this->lang; |
115 | 115 | |
116 | - if ($this->verbose) echo lang('Installation started, this might take a few minutes ...')."\n"; |
|
117 | - if (true) $setup_info = self::$egw_setup->process->pass($setup_info,'new',false,True,$this->config); |
|
116 | + if ($this->verbose) |
|
117 | + { |
|
118 | + echo lang('Installation started, this might take a few minutes ...')."\n"; |
|
119 | + } |
|
120 | + if (true) |
|
121 | + { |
|
122 | + $setup_info = self::$egw_setup->process->pass($setup_info,'new',false,True,$this->config); |
|
123 | + } |
|
118 | 124 | |
119 | 125 | $this->restore_db(); |
120 | 126 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param array $config =array() configuration to preset the defaults during the install, eg. set the account_repository |
35 | 35 | * @param string $lang ='en' |
36 | 36 | */ |
37 | - function __construct($domain,$config_user=null,$config_passwd=null,$backup=null,$charset='utf-8',$verbose=false,array $config=array(),$lang='en') |
|
37 | + function __construct($domain, $config_user = null, $config_passwd = null, $backup = null, $charset = 'utf-8', $verbose = false, array $config = array(), $lang = 'en') |
|
38 | 38 | { |
39 | 39 | if (!is_array($domain)) |
40 | 40 | { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | 'lang' => $lang, |
50 | 50 | ); |
51 | 51 | } |
52 | - elseif(!$domain['charset']) |
|
52 | + elseif (!$domain['charset']) |
|
53 | 53 | { |
54 | 54 | $domain['charset'] = 'utf-8'; |
55 | 55 | } |
@@ -65,24 +65,24 @@ discard block |
||
65 | 65 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
66 | 66 | * @throws Exception('header.inc.php not found!'); |
67 | 67 | */ |
68 | - protected function exec($check_only=false) |
|
68 | + protected function exec($check_only = false) |
|
69 | 69 | { |
70 | - unset($check_only); // not used; |
|
70 | + unset($check_only); // not used; |
|
71 | 71 | global $setup_info; |
72 | 72 | |
73 | 73 | // instanciate setup object and check authorisation |
74 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
74 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
75 | 75 | |
76 | - $this->check_installed($this->domain,array(13,14,20),$this->verbose); |
|
76 | + $this->check_installed($this->domain, array(13, 14, 20), $this->verbose); |
|
77 | 77 | |
78 | 78 | // use uploaded backup, instead installing from scratch |
79 | 79 | if ($this->backup) |
80 | 80 | { |
81 | 81 | $db_backup = new db_backup(); |
82 | 82 | |
83 | - if (!is_resource($f = $db_backup->fopen_backup($this->backup,true))) |
|
83 | + if (!is_resource($f = $db_backup->fopen_backup($this->backup, true))) |
|
84 | 84 | { |
85 | - throw new Api\Exception\WrongUserinput(lang('Restore failed').' ('.$f.')',31); |
|
85 | + throw new Api\Exception\WrongUserinput(lang('Restore failed').' ('.$f.')', 31); |
|
86 | 86 | } |
87 | 87 | if ($this->verbose) |
88 | 88 | { |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | } |
91 | 91 | else |
92 | 92 | { |
93 | - ob_start(); // restore echos the table structure |
|
93 | + ob_start(); // restore echos the table structure |
|
94 | 94 | } |
95 | - $db_backup->restore($f,$this->charset,$this->backup); |
|
95 | + $db_backup->restore($f, $this->charset, $this->backup); |
|
96 | 96 | fclose($f); |
97 | 97 | |
98 | 98 | if (!$this->verbose) |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | // regular (new) install |
105 | 105 | if ($GLOBALS['egw_info']['setup']['stage']['db'] != 3) |
106 | 106 | { |
107 | - throw new Api\Exception\WrongUserinput(lang('EGroupware is already installed!'),30); |
|
107 | + throw new Api\Exception\WrongUserinput(lang('EGroupware is already installed!'), 30); |
|
108 | 108 | } |
109 | 109 | $setup_info = self::$egw_setup->detection->upgrade_exclude($setup_info); |
110 | 110 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $_POST['ConfigLang'] = $this->lang; |
115 | 115 | |
116 | 116 | if ($this->verbose) echo lang('Installation started, this might take a few minutes ...')."\n"; |
117 | - if (true) $setup_info = self::$egw_setup->process->pass($setup_info,'new',false,True,$this->config); |
|
117 | + if (true) $setup_info = self::$egw_setup->process->pass($setup_info, 'new', false, True, $this->config); |
|
118 | 118 | |
119 | 119 | $this->restore_db(); |
120 | 120 |
@@ -70,10 +70,13 @@ discard block |
||
70 | 70 | self::auth_types(true); |
71 | 71 | |
72 | 72 | $values = array(); |
73 | - if ($this->arguments) // we have command line arguments |
|
73 | + if ($this->arguments) |
|
74 | + { |
|
75 | + // we have command line arguments |
|
74 | 76 | { |
75 | 77 | $save_mail_account = $this->_parse_cli_arguments($values); |
76 | 78 | } |
79 | + } |
|
77 | 80 | else |
78 | 81 | { |
79 | 82 | $save_mail_account = $this->_parse_properties($values); |
@@ -82,7 +85,10 @@ discard block |
||
82 | 85 | // store the config |
83 | 86 | foreach($values as $name => $value) |
84 | 87 | { |
85 | - if (substr($name, 0, 4) == 'acc_') continue; |
|
88 | + if (substr($name, 0, 4) == 'acc_') |
|
89 | + { |
|
90 | + continue; |
|
91 | + } |
|
86 | 92 | |
87 | 93 | $app = 'phpgwapi'; |
88 | 94 | if (strpos($name, '/') !== false) |
@@ -98,7 +104,10 @@ discard block |
||
98 | 104 | } |
99 | 105 | if (count($values)) |
100 | 106 | { |
101 | - if ($save_mail_account) $this->_save_mail_account($values); |
|
107 | + if ($save_mail_account) |
|
108 | + { |
|
109 | + $this->_save_mail_account($values); |
|
110 | + } |
|
102 | 111 | |
103 | 112 | // flush instance cache, so above config get read from database not cache |
104 | 113 | Api\Cache::flush(); |
@@ -322,13 +331,19 @@ discard block |
||
322 | 331 | */ |
323 | 332 | private function _parse_value($arg,$n,$data,$value,array &$values) |
324 | 333 | { |
325 | - if ($value === '' && is_array($data) && !isset($data[$n]['default'])) return false; |
|
334 | + if ($value === '' && is_array($data) && !isset($data[$n]['default'])) |
|
335 | + { |
|
336 | + return false; |
|
337 | + } |
|
326 | 338 | |
327 | 339 | $name = is_array($data) || $n ? $data[$n] : $data; |
328 | 340 | |
329 | 341 | if (is_array($name)) |
330 | 342 | { |
331 | - if (!$value && isset($name['default'])) $value = $name['default']; |
|
343 | + if (!$value && isset($name['default'])) |
|
344 | + { |
|
345 | + $value = $name['default']; |
|
346 | + } |
|
332 | 347 | |
333 | 348 | if (isset($name['allowed']) && !in_array($value,$name['allowed'])) |
334 | 349 | { |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $arguments =null array with command line argruments |
32 | 32 | * @param boolean $verbose =false if true, echos out some status information during the run |
33 | 33 | */ |
34 | - function __construct($domain,$config_user=null,$config_passwd=null,$arguments=null,$verbose=false) |
|
34 | + function __construct($domain, $config_user = null, $config_passwd = null, $arguments = null, $verbose = false) |
|
35 | 35 | { |
36 | 36 | if (!is_array($domain)) |
37 | 37 | { |
@@ -55,16 +55,16 @@ discard block |
||
55 | 55 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
56 | 56 | * @throws Exception('header.inc.php not found!'); |
57 | 57 | */ |
58 | - protected function exec($check_only=false) |
|
58 | + protected function exec($check_only = false) |
|
59 | 59 | { |
60 | 60 | if ($check_only && $this->remote_id) |
61 | 61 | { |
62 | - return true; // can only check locally |
|
62 | + return true; // can only check locally |
|
63 | 63 | } |
64 | 64 | // instanciate setup object and check authorisation |
65 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
65 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
66 | 66 | |
67 | - $this->check_installed($this->domain,15,$this->verbose); |
|
67 | + $this->check_installed($this->domain, 15, $this->verbose); |
|
68 | 68 | |
69 | 69 | // fixing authtypes in self::$options |
70 | 70 | self::auth_types(true); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | // store the config |
83 | - foreach($values as $name => $value) |
|
83 | + foreach ($values as $name => $value) |
|
84 | 84 | { |
85 | 85 | if (substr($name, 0, 4) == 'acc_') continue; |
86 | 86 | |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | { |
90 | 90 | list($app, $name) = explode('/', $name); |
91 | 91 | } |
92 | - self::$egw_setup->db->insert(self::$egw_setup->config_table,array( |
|
92 | + self::$egw_setup->db->insert(self::$egw_setup->config_table, array( |
|
93 | 93 | 'config_value' => $value, |
94 | - ),array( |
|
94 | + ), array( |
|
95 | 95 | 'config_app' => $app, |
96 | 96 | 'config_name' => $name, |
97 | - ),__LINE__,__FILE__); |
|
97 | + ), __LINE__, __FILE__); |
|
98 | 98 | } |
99 | 99 | if (count($values)) |
100 | 100 | { |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | * @param boolean $echoit =false if true the config is additionally echo'ed out |
119 | 119 | * @return array with name => value pairs |
120 | 120 | */ |
121 | - static function get_config($echoit=false) |
|
121 | + static function get_config($echoit = false) |
|
122 | 122 | { |
123 | - self::$egw_setup->db->select(self::$egw_setup->config_table,'config_name,config_value',array( |
|
123 | + self::$egw_setup->db->select(self::$egw_setup->config_table, 'config_name,config_value', array( |
|
124 | 124 | 'config_app' => 'phpgwapi', |
125 | 125 | "(config_name LIKE '%\\_dir' OR (config_name LIKE 'mail%' AND config_name != 'mail_footer') OR config_name LIKE 'smtp\\_%' OR config_name LIKE 'ldap%' OR config_name IN ('webserver_url','system_charset','auth_type','account_repository'))", |
126 | - ),__LINE__,__FILE__); |
|
126 | + ), __LINE__, __FILE__); |
|
127 | 127 | |
128 | 128 | $config = array(); |
129 | 129 | while (($row = self::$egw_setup->db->row(true))) |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | if ($echoit) |
134 | 134 | { |
135 | 135 | echo lang('Current configuration:')."\n"; |
136 | - foreach($config as $name => $value) |
|
136 | + foreach ($config as $name => $value) |
|
137 | 137 | { |
138 | - echo str_pad($name.':',22).$value."\n"; |
|
138 | + echo str_pad($name.':', 22).$value."\n"; |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | return $config; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @var array |
148 | 148 | */ |
149 | 149 | static $options = array( |
150 | - '--config' => array(), // name=value,... |
|
150 | + '--config' => array(), // name=value,... |
|
151 | 151 | '--files-dir' => 'files_dir', |
152 | 152 | '--vfs-root-user' => 'vfs_root_user', |
153 | 153 | '--backup-dir' => 'backup_dir', |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | 'acc_imap_host', |
159 | 159 | 'acc_imap_port', |
160 | 160 | 'acc_domain', |
161 | - array('name' => 'acc_imap_logintype','allowed' => array( |
|
161 | + array('name' => 'acc_imap_logintype', 'allowed' => array( |
|
162 | 162 | 'username (standard)' => 'standard', |
163 | 163 | 'username@domain (virtual mail manager)' => 'vmailmgr', |
164 | 164 | 'Username/Password defined by admin' => 'admin', |
165 | 165 | 'userId@domain eg. u123@domain' => 'uidNumber', |
166 | 166 | 'email (Standard Maildomain should be set)' => 'email', |
167 | 167 | )), |
168 | - array('name' => 'acc_imap_ssl','allowed' => array(0,'no',1,'starttls',3,'ssl',2,'tls')), |
|
168 | + array('name' => 'acc_imap_ssl', 'allowed' => array(0, 'no', 1, 'starttls', 3, 'ssl', 2, 'tls')), |
|
169 | 169 | ), |
170 | 170 | '--imap' => array( |
171 | 171 | 'acc_imap_admin_username', |
@@ -173,28 +173,28 @@ discard block |
||
173 | 173 | 'acc_imap_type', |
174 | 174 | ), |
175 | 175 | '--folder' => array( |
176 | - 'acc_folder_sent','acc_folder_trash','acc_folder_draft','acc_folder_template','acc_folder_junk','acc_folder_archive','acc_folder_ham' |
|
176 | + 'acc_folder_sent', 'acc_folder_trash', 'acc_folder_draft', 'acc_folder_template', 'acc_folder_junk', 'acc_folder_archive', 'acc_folder_ham' |
|
177 | 177 | ), |
178 | 178 | '--sieve' => array( |
179 | 179 | array('name' => 'acc_sieve_host'), |
180 | 180 | 'acc_sieve_port', |
181 | 181 | 'acc_sieve_enabled', |
182 | - array('name' => 'acc_sieve_ssl','allowed' => array(0,'no',1,'starttls',3,'ssl',2,'tls')), |
|
182 | + array('name' => 'acc_sieve_ssl', 'allowed' => array(0, 'no', 1, 'starttls', 3, 'ssl', 2, 'tls')), |
|
183 | 183 | ), |
184 | 184 | '--smtp' => array( |
185 | - array('name' => 'editforwardingaddress','allowed' => array('yes',null)), |
|
185 | + array('name' => 'editforwardingaddress', 'allowed' => array('yes', null)), |
|
186 | 186 | 'acc_smtp_type', |
187 | 187 | ), |
188 | 188 | '--smtpserver' => array( //smtp server,[smtp port],[smtp user],[smtp password],[auth session user/pw],[no|starttls|ssl|tls],[user editable],[further identities] |
189 | - 'acc_smtp_host','acc_smtp_port','acc_smtp_username','acc_smtp_passwd','acc_smtp_auth_session', |
|
190 | - array('name' => 'acc_smtp_ssl','allowed' => array(0,'no',1,'starttls',3,'ssl',2,'tls')), |
|
191 | - 'acc_user_editable','acc_further_identities', |
|
189 | + 'acc_smtp_host', 'acc_smtp_port', 'acc_smtp_username', 'acc_smtp_passwd', 'acc_smtp_auth_session', |
|
190 | + array('name' => 'acc_smtp_ssl', 'allowed' => array(0, 'no', 1, 'starttls', 3, 'ssl', 2, 'tls')), |
|
191 | + 'acc_user_editable', 'acc_further_identities', |
|
192 | 192 | ), |
193 | 193 | '--account-auth' => array( |
194 | - array('name' => 'account_repository','allowed' => array('sql','ldap','ads'),'default'=>'sql'), |
|
195 | - array('name' => 'auth_type','allowed' => array('sql','ldap','mail','ads','http','sqlssl','nis','pam'),'default'=>'sql'), |
|
196 | - array('name' => 'sql_encryption','allowed' => array('blowfish_crypt','sha512_crypt','sha256_crypt','md5_crypt','crypt','ssha','smd5','md5'),'default'=>'blowfish_crypt'), |
|
197 | - 'check_save_password','allow_cookie_auth'), |
|
194 | + array('name' => 'account_repository', 'allowed' => array('sql', 'ldap', 'ads'), 'default'=>'sql'), |
|
195 | + array('name' => 'auth_type', 'allowed' => array('sql', 'ldap', 'mail', 'ads', 'http', 'sqlssl', 'nis', 'pam'), 'default'=>'sql'), |
|
196 | + array('name' => 'sql_encryption', 'allowed' => array('blowfish_crypt', 'sha512_crypt', 'sha256_crypt', 'md5_crypt', 'crypt', 'ssha', 'smd5', 'md5'), 'default'=>'blowfish_crypt'), |
|
197 | + 'check_save_password', 'allow_cookie_auth'), |
|
198 | 198 | '--ldap-host' => 'ldap_host', |
199 | 199 | '--ldap-root-dn' => 'ldap_root_dn', |
200 | 200 | '--ldap-root-pw' => 'ldap_root_pw', |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | '--install-id' => 'install_id', |
207 | 207 | '--ads-host' => 'ads_host', |
208 | 208 | '--ads-domain' => 'ads_domain', |
209 | - '--ads-admin-user' => 'ads_domain_admin', // eg. Administrator |
|
209 | + '--ads-admin-user' => 'ads_domain_admin', // eg. Administrator |
|
210 | 210 | '--ads-admin-pw' => 'ads_admin_pw', |
211 | 211 | '--ads-connection' => array( |
212 | 212 | array('name' => 'ads_connection', 'allowed' => array('ssl', 'tls')) |
@@ -252,9 +252,9 @@ discard block |
||
252 | 252 | |
253 | 253 | $save_mail_account = false; |
254 | 254 | $values = array(); |
255 | - foreach(self::$options as $arg => $option) |
|
255 | + foreach (self::$options as $arg => $option) |
|
256 | 256 | { |
257 | - foreach(is_array($option) ? $option : array($option) as $n => $data) |
|
257 | + foreach (is_array($option) ? $option : array($option) as $n => $data) |
|
258 | 258 | { |
259 | 259 | $name = is_array($data) ? $data['name'] : $data; |
260 | 260 | $oldname = array_key_exists($name, $this->old2new); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | } |
267 | 267 | if (isset($this->$name)) |
268 | 268 | { |
269 | - $save_mail_account = $this->_parse_value($arg,$n,$option,$this->$name,$values) || $save_mail_account; |
|
269 | + $save_mail_account = $this->_parse_value($arg, $n, $option, $this->$name, $values) || $save_mail_account; |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | } |
@@ -284,27 +284,27 @@ discard block |
||
284 | 284 | $values = array(); |
285 | 285 | $save_mail_account = false; |
286 | 286 | $args = $this->arguments; |
287 | - while(($arg = array_shift($args))) |
|
287 | + while (($arg = array_shift($args))) |
|
288 | 288 | { |
289 | 289 | if (!isset(self::$options[$arg])) |
290 | 290 | { |
291 | - throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!",$arg),90); |
|
291 | + throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!", $arg), 90); |
|
292 | 292 | } |
293 | - $options = is_array(self::$options[$arg]) ? explode(',',array_shift($args)) : array(array_shift($args)); |
|
293 | + $options = is_array(self::$options[$arg]) ? explode(',', array_shift($args)) : array(array_shift($args)); |
|
294 | 294 | |
295 | 295 | if ($arg == '--config' || $arg == '--setup_cmd_config') |
296 | 296 | { |
297 | - foreach($options as $option) |
|
297 | + foreach ($options as $option) |
|
298 | 298 | { |
299 | - list($name,$value) = explode('=',$option,2); |
|
299 | + list($name, $value) = explode('=', $option, 2); |
|
300 | 300 | $values[$name] = $value; |
301 | 301 | } |
302 | 302 | continue; |
303 | 303 | } |
304 | 304 | $options[] = ''; $options[] = ''; |
305 | - foreach($options as $n => $value) |
|
305 | + foreach ($options as $n => $value) |
|
306 | 306 | { |
307 | - $save_mail_account = $this->_parse_value($arg,$n,self::$options[$arg],$value,$values) || $save_mail_account; |
|
307 | + $save_mail_account = $this->_parse_value($arg, $n, self::$options[$arg], $value, $values) || $save_mail_account; |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | return $save_mail_account; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * @param array &$values where the values get set |
321 | 321 | * @return boolean true if mail-accounts needs to be saved, false if not |
322 | 322 | */ |
323 | - private function _parse_value($arg,$n,$data,$value,array &$values) |
|
323 | + private function _parse_value($arg, $n, $data, $value, array &$values) |
|
324 | 324 | { |
325 | 325 | if ($value === '' && is_array($data) && !isset($data[$n]['default'])) return false; |
326 | 326 | |
@@ -330,15 +330,15 @@ discard block |
||
330 | 330 | { |
331 | 331 | if (!$value && isset($name['default'])) $value = $name['default']; |
332 | 332 | |
333 | - if (isset($name['allowed']) && !in_array($value,$name['allowed'])) |
|
333 | + if (isset($name['allowed']) && !in_array($value, $name['allowed'])) |
|
334 | 334 | { |
335 | - throw new Api\Exception\WrongUserinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!",$value,1+$n,$arg)." ($name[name])",91); |
|
335 | + throw new Api\Exception\WrongUserinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!", $value, 1 + $n, $arg)." ($name[name])", 91); |
|
336 | 336 | } |
337 | 337 | $name = $name['name']; |
338 | 338 | } |
339 | 339 | $values[$name] = $value; |
340 | 340 | |
341 | - return in_array($arg,array('--mailserver','--smtpserver','--imap','--smtp','--sieve','--folder')); |
|
341 | + return in_array($arg, array('--mailserver', '--smtpserver', '--imap', '--smtp', '--sieve', '--folder')); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -349,9 +349,9 @@ discard block |
||
349 | 349 | function _save_mail_account(array $data) |
350 | 350 | { |
351 | 351 | // convert ssl textual values to nummerical ones used in Api\Mail\Account |
352 | - foreach(array('acc_imap_ssl', 'acc_sieve_ssl', 'acc_smtp_ssl') as $name) |
|
352 | + foreach (array('acc_imap_ssl', 'acc_sieve_ssl', 'acc_smtp_ssl') as $name) |
|
353 | 353 | { |
354 | - switch(strtolower($data[$name])) |
|
354 | + switch (strtolower($data[$name])) |
|
355 | 355 | { |
356 | 356 | case 'no': $data[$name] = Api\Mail\Account::SSL_NONE; break; |
357 | 357 | case 'starttls': $data[$name] = Api\Mail\Account::SSL_STARTTLS; break; |
@@ -360,12 +360,12 @@ discard block |
||
360 | 360 | } |
361 | 361 | } |
362 | 362 | // convert 'yes', 'no' to boolean |
363 | - foreach(array('acc_sieve_enabled','acc_user_editable','acc_further_identities','acc_smtp_auth_session') as $name) |
|
363 | + foreach (array('acc_sieve_enabled', 'acc_user_editable', 'acc_further_identities', 'acc_smtp_auth_session') as $name) |
|
364 | 364 | { |
365 | 365 | $data[$name] = $data[$name] && strtolower($data[$name]) != 'no'; |
366 | 366 | } |
367 | 367 | // do NOT write empty usernames |
368 | - foreach(array('acc_imap_username', 'acc_smtp_username') as $name) |
|
368 | + foreach (array('acc_imap_username', 'acc_smtp_username') as $name) |
|
369 | 369 | { |
370 | 370 | if (empty($data[$name])) |
371 | 371 | { |
@@ -375,16 +375,16 @@ discard block |
||
375 | 375 | } |
376 | 376 | |
377 | 377 | $data['acc_name'] = 'Created by setup'; |
378 | - $data['account_id'] = 0; // 0 = valid for all users |
|
378 | + $data['account_id'] = 0; // 0 = valid for all users |
|
379 | 379 | |
380 | 380 | Api\Mail\Account::write($data); |
381 | 381 | |
382 | 382 | if ($this->verbose) |
383 | 383 | { |
384 | 384 | echo "\n".lang('EMailAdmin mail account saved:')."\n"; |
385 | - foreach($data as $name => $value) |
|
385 | + foreach ($data as $name => $value) |
|
386 | 386 | { |
387 | - echo str_pad($name.':',22).$value."\n"; |
|
387 | + echo str_pad($name.':', 22).$value."\n"; |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | } |
@@ -397,11 +397,11 @@ discard block |
||
397 | 397 | static function options() |
398 | 398 | { |
399 | 399 | $options = array(); |
400 | - foreach(self::$options as $option) |
|
400 | + foreach (self::$options as $option) |
|
401 | 401 | { |
402 | 402 | if (is_array($option)) |
403 | 403 | { |
404 | - foreach($option as $data) |
|
404 | + foreach ($option as $data) |
|
405 | 405 | { |
406 | 406 | if (is_array($data) && isset($data['allowed'])) |
407 | 407 | { |
@@ -414,11 +414,11 @@ discard block |
||
414 | 414 | $options[$data['name']] = self::account_repositories(); |
415 | 415 | continue 2; |
416 | 416 | } |
417 | - foreach($data['allowed'] as $label => $value) |
|
417 | + foreach ($data['allowed'] as $label => $value) |
|
418 | 418 | { |
419 | 419 | if (is_int($label)) |
420 | 420 | { |
421 | - $label = (string) $value === '' ? 'No' : strtoupper($value); |
|
421 | + $label = (string)$value === '' ? 'No' : strtoupper($value); |
|
422 | 422 | } |
423 | 423 | $options[$data['name']][$value] = lang($label); |
424 | 424 | } |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | if (!$scan_done++) |
452 | 452 | { |
453 | 453 | // now add auth backends found in filesystem |
454 | - foreach(scandir(EGW_INCLUDE_ROOT.'/api/src/Auth') as $file) |
|
454 | + foreach (scandir(EGW_INCLUDE_ROOT.'/api/src/Auth') as $file) |
|
455 | 455 | { |
456 | 456 | $matches = null; |
457 | 457 | if (preg_match('/^([a-z0-9]+)\.php$/i', $file, $matches) && |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | $auth_types[strtolower($matches[1])] = $matches[1]; |
461 | 461 | } |
462 | 462 | } |
463 | - foreach(self::$options['--account-auth'] as &$param) |
|
463 | + foreach (self::$options['--account-auth'] as &$param) |
|
464 | 464 | { |
465 | 465 | if ($param['name'] == 'auth_type') |
466 | 466 | { |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * @param string $current =null current value, to allways return it |
479 | 479 | * @return array |
480 | 480 | */ |
481 | - static function account_repositories($current=null) |
|
481 | + static function account_repositories($current = null) |
|
482 | 482 | { |
483 | 483 | static $account_repositories = array( |
484 | 484 | 'sql' => 'SQL', |
@@ -489,13 +489,13 @@ discard block |
||
489 | 489 | if (!$scan_done++) |
490 | 490 | { |
491 | 491 | // now add auth backends found in filesystem |
492 | - foreach(scandir(EGW_INCLUDE_ROOT.'/api/src/Accounts') as $file) |
|
492 | + foreach (scandir(EGW_INCLUDE_ROOT.'/api/src/Accounts') as $file) |
|
493 | 493 | { |
494 | 494 | $matches = null; |
495 | 495 | if (preg_match('/^([a-z0-9]+)\.php$/i', $file, $matches) && |
496 | 496 | !isset($account_repositories[strtolower($matches[1])]) && |
497 | - class_exists($class='EGroupware\\Api\\Accounts\\'.$matches[1]) && |
|
498 | - (strtolower($matches[1]) == $current || !is_callable($callable=$class.'::available') || call_user_func($callable))) |
|
497 | + class_exists($class = 'EGroupware\\Api\\Accounts\\'.$matches[1]) && |
|
498 | + (strtolower($matches[1]) == $current || !is_callable($callable = $class.'::available') || call_user_func($callable))) |
|
499 | 499 | { |
500 | 500 | $account_repositories[strtolower($matches[1])] = $matches[1]; |
501 | 501 | } |
@@ -513,11 +513,11 @@ discard block |
||
513 | 513 | { |
514 | 514 | $defaults = array(); |
515 | 515 | // fetch the default from the cli options |
516 | - foreach(self::$options as $option) |
|
516 | + foreach (self::$options as $option) |
|
517 | 517 | { |
518 | 518 | if (is_array($option)) |
519 | 519 | { |
520 | - foreach($option as $data) |
|
520 | + foreach ($option as $data) |
|
521 | 521 | { |
522 | 522 | if (is_array($data) && isset($data['default'])) |
523 | 523 | { |
@@ -545,20 +545,20 @@ discard block |
||
545 | 545 | */ |
546 | 546 | private function _merge_defaults() |
547 | 547 | { |
548 | - foreach(self::defaults() as $name => $default) |
|
548 | + foreach (self::defaults() as $name => $default) |
|
549 | 549 | { |
550 | 550 | if (!$this->$name) |
551 | 551 | { |
552 | 552 | //echo "<p>setting $name='{$this->$name}' to it's default='$default'</p>\n"; |
553 | 553 | $this->set_defaults[$name] = $this->$name = $default; |
554 | 554 | } |
555 | - if (strpos($this->$name,'$') !== false) |
|
555 | + if (strpos($this->$name, '$') !== false) |
|
556 | 556 | { |
557 | 557 | $this->set_defaults[$name] = $this->$name = str_replace(array( |
558 | 558 | '$domain', |
559 | - ),array( |
|
559 | + ), array( |
|
560 | 560 | $this->domain, |
561 | - ),$this->$name); |
|
561 | + ), $this->$name); |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | |
30 | 30 | $GLOBALS['header_template']->set_file(array('header' => 'header.inc.php.template')); |
31 | 31 | $GLOBALS['header_template']->set_block('header','domain','domain'); |
32 | - $var = Array(); |
|
32 | + $var = array(); |
|
33 | 33 | |
34 | 34 | $deletedomain = $_POST['deletedomain']; |
35 | 35 | $domains = $_POST['domains']; |
@@ -28,54 +28,54 @@ discard block |
||
28 | 28 | // variable names with underscores. |
29 | 29 | |
30 | 30 | $GLOBALS['header_template']->set_file(array('header' => 'header.inc.php.template')); |
31 | - $GLOBALS['header_template']->set_block('header','domain','domain'); |
|
31 | + $GLOBALS['header_template']->set_block('header', 'domain', 'domain'); |
|
32 | 32 | $var = Array(); |
33 | 33 | |
34 | 34 | $deletedomain = $_POST['deletedomain']; |
35 | 35 | $domains = $_POST['domains']; |
36 | 36 | |
37 | - foreach($domains as $k => $v) |
|
37 | + foreach ($domains as $k => $v) |
|
38 | 38 | { |
39 | - if(is_array($deletedomain) && isset($deletedomain[$k])) |
|
39 | + if (is_array($deletedomain) && isset($deletedomain[$k])) |
|
40 | 40 | { |
41 | 41 | continue; |
42 | 42 | } |
43 | - $variableName = str_replace('.','_',$k); |
|
43 | + $variableName = str_replace('.', '_', $k); |
|
44 | 44 | $dom = $_POST['setting_'.$variableName]; |
45 | - $GLOBALS['header_template']->set_var('DB_DOMAIN',$v); |
|
46 | - foreach($dom as $x => $y) |
|
45 | + $GLOBALS['header_template']->set_var('DB_DOMAIN', $v); |
|
46 | + foreach ($dom as $x => $y) |
|
47 | 47 | { |
48 | - if(strtoupper($x) == 'CONFIG_PASS') |
|
48 | + if (strtoupper($x) == 'CONFIG_PASS') |
|
49 | 49 | { |
50 | - $GLOBALS['header_template']->set_var(strtoupper($x),md5($y)); |
|
50 | + $GLOBALS['header_template']->set_var(strtoupper($x), md5($y)); |
|
51 | 51 | } |
52 | 52 | else |
53 | 53 | { |
54 | - $GLOBALS['header_template']->set_var(strtoupper($x),$y); |
|
54 | + $GLOBALS['header_template']->set_var(strtoupper($x), $y); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | /* Admin did not type a new password, so use the old one from the hidden field, |
58 | 58 | * which is already md5 encoded. |
59 | 59 | */ |
60 | - if($dom['config_password'] && !$dom['config_pass']) |
|
60 | + if ($dom['config_password'] && !$dom['config_pass']) |
|
61 | 61 | { |
62 | 62 | /* Real == hidden */ |
63 | - $GLOBALS['header_template']->set_var('CONFIG_PASS',$dom['config_password']); |
|
63 | + $GLOBALS['header_template']->set_var('CONFIG_PASS', $dom['config_password']); |
|
64 | 64 | } |
65 | 65 | /* If the admin didn't select a db_port, set to the default */ |
66 | - if(!$dom['db_port']) |
|
66 | + if (!$dom['db_port']) |
|
67 | 67 | { |
68 | - $GLOBALS['header_template']->set_var('DB_PORT',$GLOBALS['default_db_ports'][$dom['db_type']]); |
|
68 | + $GLOBALS['header_template']->set_var('DB_PORT', $GLOBALS['default_db_ports'][$dom['db_type']]); |
|
69 | 69 | } |
70 | - $GLOBALS['header_template']->parse('domains','domain',True); |
|
70 | + $GLOBALS['header_template']->parse('domains', 'domain', True); |
|
71 | 71 | } |
72 | 72 | |
73 | - $GLOBALS['header_template']->set_var('domain',''); |
|
73 | + $GLOBALS['header_template']->set_var('domain', ''); |
|
74 | 74 | |
75 | 75 | $setting = $_POST['setting']; |
76 | - while($setting && list($k,$v) = @each($setting)) |
|
76 | + while ($setting && list($k, $v) = @each($setting)) |
|
77 | 77 | { |
78 | - if(strtoupper($k) == 'HEADER_ADMIN_PASSWORD') |
|
78 | + if (strtoupper($k) == 'HEADER_ADMIN_PASSWORD') |
|
79 | 79 | { |
80 | 80 | $var[strtoupper($k)] = md5($v); |
81 | 81 | } |
@@ -87,21 +87,21 @@ discard block |
||
87 | 87 | /* Admin did not type a new header password, so use the old one from the hidden field, |
88 | 88 | * which is already md5 encoded. |
89 | 89 | */ |
90 | - if($var['HEADER_ADMIN_PASS'] && empty($setting['HEADER_ADMIN_PASSWORD'])) |
|
90 | + if ($var['HEADER_ADMIN_PASS'] && empty($setting['HEADER_ADMIN_PASSWORD'])) |
|
91 | 91 | { |
92 | 92 | /* Real == hidden */ |
93 | 93 | $var['HEADER_ADMIN_PASSWORD'] = $var['HEADER_ADMIN_PASS']; |
94 | 94 | } |
95 | 95 | $GLOBALS['header_template']->set_var($var); |
96 | - return $GLOBALS['header_template']->parse('out','header'); |
|
96 | + return $GLOBALS['header_template']->parse('out', 'header'); |
|
97 | 97 | } |
98 | 98 | |
99 | - static function setup_tpl_dir($app_name='setup') |
|
99 | + static function setup_tpl_dir($app_name = 'setup') |
|
100 | 100 | { |
101 | 101 | /* hack to get tpl dir */ |
102 | 102 | if (is_dir(EGW_SERVER_ROOT)) |
103 | 103 | { |
104 | - $srv_root = EGW_SERVER_ROOT . '/' . $app_name . '/'; |
|
104 | + $srv_root = EGW_SERVER_ROOT.'/'.$app_name.'/'; |
|
105 | 105 | } |
106 | 106 | else |
107 | 107 | { |
@@ -109,16 +109,16 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | $tpl_typical = 'templates/default'; |
112 | - $tpl_root = "$srv_root" ."$tpl_typical"; |
|
112 | + $tpl_root = "$srv_root"."$tpl_typical"; |
|
113 | 113 | return $tpl_root; |
114 | 114 | } |
115 | 115 | |
116 | - static function show_header($title='',$nologoutbutton=False, $logoutfrom='config', $configdomain='') |
|
116 | + static function show_header($title = '', $nologoutbutton = False, $logoutfrom = 'config', $configdomain = '') |
|
117 | 117 | { |
118 | 118 | // add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv) |
119 | 119 | header('Content-type: text/html; charset='.$GLOBALS['egw_setup']->system_charset); |
120 | 120 | |
121 | - $GLOBALS['setup_tpl']->set_var('charset',$GLOBALS['egw_setup']->system_charset); |
|
121 | + $GLOBALS['setup_tpl']->set_var('charset', $GLOBALS['egw_setup']->system_charset); |
|
122 | 122 | $style = array( |
123 | 123 | 'th_bg' => '#486591', |
124 | 124 | 'th_text' => '#FFFFFF', |
@@ -130,34 +130,34 @@ discard block |
||
130 | 130 | $GLOBALS['setup_tpl']->set_var($style); |
131 | 131 | if ($nologoutbutton) |
132 | 132 | { |
133 | - $GLOBALS['setup_tpl']->set_block('T_head','loged_in'); |
|
134 | - $GLOBALS['setup_tpl']->set_var('loged_in',''); |
|
133 | + $GLOBALS['setup_tpl']->set_block('T_head', 'loged_in'); |
|
134 | + $GLOBALS['setup_tpl']->set_var('loged_in', ''); |
|
135 | 135 | } |
136 | 136 | else |
137 | 137 | { |
138 | - $btn_logout = '<a href="index.php?FormLogout=' . $logoutfrom . '" class="link">' . lang('Logout').'</a>'; |
|
138 | + $btn_logout = '<a href="index.php?FormLogout='.$logoutfrom.'" class="link">'.lang('Logout').'</a>'; |
|
139 | 139 | $check_install = '<a class="textsidebox" href="check_install.php">'.lang('Check installation').'</a>'; |
140 | 140 | $register_hooks = '<a class="textsidebox" href="applications.php?hooks=1">'.lang('Clear cache and register hooks').'</a>'; |
141 | 141 | } |
142 | 142 | |
143 | 143 | $GLOBALS['setup_tpl']->set_var('lang_setup', lang('setup')); |
144 | - $GLOBALS['setup_tpl']->set_var('page_title',$title); |
|
144 | + $GLOBALS['setup_tpl']->set_var('page_title', $title); |
|
145 | 145 | if ($configdomain == '') |
146 | 146 | { |
147 | - $GLOBALS['setup_tpl']->set_var('configdomain',''); |
|
147 | + $GLOBALS['setup_tpl']->set_var('configdomain', ''); |
|
148 | 148 | } |
149 | 149 | else |
150 | 150 | { |
151 | - $GLOBALS['setup_tpl']->set_var('configdomain',' - ' . lang('Domain') . ': ' . $configdomain); |
|
151 | + $GLOBALS['setup_tpl']->set_var('configdomain', ' - '.lang('Domain').': '.$configdomain); |
|
152 | 152 | } |
153 | 153 | |
154 | - if(basename($_SERVER['SCRIPT_FILENAME']) != 'index.php') |
|
154 | + if (basename($_SERVER['SCRIPT_FILENAME']) != 'index.php') |
|
155 | 155 | { |
156 | - $index_btn = '<a href="index.php" class="link">' . lang('Setup Main Menu') . '</a>'; |
|
156 | + $index_btn = '<a href="index.php" class="link">'.lang('Setup Main Menu').'</a>'; |
|
157 | 157 | $index_img = '<img src="../api/templates/default/images/bullet.png" />'; |
158 | 158 | } |
159 | 159 | |
160 | - $GLOBALS['setup_tpl']->set_var('lang_version',lang('version')); |
|
160 | + $GLOBALS['setup_tpl']->set_var('lang_version', lang('version')); |
|
161 | 161 | if (!isset($GLOBALS['setup_info']) || !isset($GLOBALS['setup_info']['api']) || |
162 | 162 | !isset($GLOBALS['setup_info']['api']['versions']) || !isset($GLOBALS['setup_info']['api']['versions']['maintenance_release'])) |
163 | 163 | { |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $setup_info = $GLOBALS['setup_info']; |
169 | 169 | } |
170 | 170 | $GLOBALS['setup_tpl']->set_var('pgw_ver', $nologoutbutton ? |
171 | - (double)$setup_info['api']['version'] : // without login only show main version, not maintenance release |
|
171 | + (double)$setup_info['api']['version'] : // without login only show main version, not maintenance release |
|
172 | 172 | $setup_info['api']['versions']['maintenance_release']); |
173 | 173 | |
174 | 174 | $GLOBALS['setup_tpl']->set_var(array( |
@@ -185,56 +185,56 @@ discard block |
||
185 | 185 | 'community_forum' => lang('Community forum'), |
186 | 186 | )); |
187 | 187 | |
188 | - $GLOBALS['setup_tpl']->pparse('out','T_head'); |
|
188 | + $GLOBALS['setup_tpl']->pparse('out', 'T_head'); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | static function show_footer() |
192 | 192 | { |
193 | - $GLOBALS['setup_tpl']->pparse('out','T_footer'); |
|
193 | + $GLOBALS['setup_tpl']->pparse('out', 'T_footer'); |
|
194 | 194 | unset($GLOBALS['setup_tpl']); |
195 | 195 | } |
196 | 196 | |
197 | - static function show_alert_msg($alert_word='Setup alert',$alert_msg='setup alert (generic)') |
|
197 | + static function show_alert_msg($alert_word = 'Setup alert', $alert_msg = 'setup alert (generic)') |
|
198 | 198 | { |
199 | - $GLOBALS['setup_tpl']->set_var('V_alert_word',$alert_word); |
|
200 | - $GLOBALS['setup_tpl']->set_var('V_alert_msg',$alert_msg); |
|
201 | - $GLOBALS['setup_tpl']->pparse('out','T_alert_msg'); |
|
199 | + $GLOBALS['setup_tpl']->set_var('V_alert_word', $alert_word); |
|
200 | + $GLOBALS['setup_tpl']->set_var('V_alert_msg', $alert_msg); |
|
201 | + $GLOBALS['setup_tpl']->pparse('out', 'T_alert_msg'); |
|
202 | 202 | } |
203 | 203 | |
204 | - static function make_frm_btn_simple($pre_frm_blurb='',$frm_method='post',$frm_action='',$input_type='submit',$input_value='',$post_frm_blurb='') |
|
204 | + static function make_frm_btn_simple($pre_frm_blurb = '', $frm_method = 'post', $frm_action = '', $input_type = 'submit', $input_value = '', $post_frm_blurb = '') |
|
205 | 205 | { |
206 | 206 | /* a simple form has simple components */ |
207 | - $simple_form = $pre_frm_blurb ."\n" |
|
208 | - . '<form method="' . $frm_method . '" action="' . $frm_action . '">' . "\n" |
|
209 | - . '<input type="' . $input_type . '" value="' . $input_value . '" />' . "\n" |
|
210 | - . '</form>' . "\n" |
|
211 | - . $post_frm_blurb . "\n"; |
|
207 | + $simple_form = $pre_frm_blurb."\n" |
|
208 | + . '<form method="'.$frm_method.'" action="'.$frm_action.'">'."\n" |
|
209 | + . '<input type="'.$input_type.'" value="'.$input_value.'" />'."\n" |
|
210 | + . '</form>'."\n" |
|
211 | + . $post_frm_blurb."\n"; |
|
212 | 212 | return $simple_form; |
213 | 213 | } |
214 | 214 | |
215 | - static function make_href_link_simple($pre_link_blurb='',$href_link='',$href_text='default text',$post_link_blurb='') |
|
215 | + static function make_href_link_simple($pre_link_blurb = '', $href_link = '', $href_text = 'default text', $post_link_blurb = '') |
|
216 | 216 | { |
217 | 217 | /* a simple href link has simple components */ |
218 | 218 | $simple_link = $pre_link_blurb |
219 | - . '<a href="' . $href_link . '">' . $href_text . '</a> ' |
|
220 | - . $post_link_blurb . "\n"; |
|
219 | + . '<a href="'.$href_link.'">'.$href_text.'</a> ' |
|
220 | + . $post_link_blurb."\n"; |
|
221 | 221 | return $simple_link; |
222 | 222 | } |
223 | 223 | |
224 | 224 | static function login_form() |
225 | 225 | { |
226 | 226 | /* begin use TEMPLATE login_main.tpl */ |
227 | - $GLOBALS['setup_tpl']->set_var('ConfigLoginMSG',@$GLOBALS['egw_info']['setup']['ConfigLoginMSG']); |
|
228 | - $GLOBALS['setup_tpl']->set_var('HeaderLoginMSG',@$GLOBALS['egw_info']['setup']['HeaderLoginMSG']); |
|
229 | - $GLOBALS['setup_tpl']->set_var('lang_header_username',lang('Header Username')); |
|
230 | - $GLOBALS['setup_tpl']->set_var('lang_header_password',lang('Header Password')); |
|
231 | - $GLOBALS['setup_tpl']->set_var('lang_header_login',lang('Header Admin Login')); |
|
232 | - $GLOBALS['setup_tpl']->set_var('lang_config_login',lang('Setup/Config Admin Login')); |
|
233 | - $GLOBALS['setup_tpl']->set_var('lang_config_username',lang('Config Username')); |
|
234 | - $GLOBALS['setup_tpl']->set_var('lang_config_password',lang('Config Password')); |
|
235 | - $GLOBALS['setup_tpl']->set_var('lang_domain',lang('Domain')); |
|
227 | + $GLOBALS['setup_tpl']->set_var('ConfigLoginMSG', @$GLOBALS['egw_info']['setup']['ConfigLoginMSG']); |
|
228 | + $GLOBALS['setup_tpl']->set_var('HeaderLoginMSG', @$GLOBALS['egw_info']['setup']['HeaderLoginMSG']); |
|
229 | + $GLOBALS['setup_tpl']->set_var('lang_header_username', lang('Header Username')); |
|
230 | + $GLOBALS['setup_tpl']->set_var('lang_header_password', lang('Header Password')); |
|
231 | + $GLOBALS['setup_tpl']->set_var('lang_header_login', lang('Header Admin Login')); |
|
232 | + $GLOBALS['setup_tpl']->set_var('lang_config_login', lang('Setup/Config Admin Login')); |
|
233 | + $GLOBALS['setup_tpl']->set_var('lang_config_username', lang('Config Username')); |
|
234 | + $GLOBALS['setup_tpl']->set_var('lang_config_password', lang('Config Password')); |
|
235 | + $GLOBALS['setup_tpl']->set_var('lang_domain', lang('Domain')); |
|
236 | 236 | |
237 | - $GLOBALS['setup_tpl']->set_var('lang_select',self::lang_select()); |
|
237 | + $GLOBALS['setup_tpl']->set_var('lang_select', self::lang_select()); |
|
238 | 238 | |
239 | 239 | if ($GLOBALS['egw_info']['setup']['stage']['header'] == '10') |
240 | 240 | { |
@@ -244,53 +244,53 @@ discard block |
||
244 | 244 | */ |
245 | 245 | if (count($GLOBALS['egw_domain']) > 1) |
246 | 246 | { |
247 | - foreach(array_keys($GLOBALS['egw_domain']) as $domain) |
|
247 | + foreach (array_keys($GLOBALS['egw_domain']) as $domain) |
|
248 | 248 | { |
249 | 249 | $domains .= "<option value=\"$domain\" ".($domain == @$GLOBALS['egw_info']['setup']['LastDomain'] ? ' selected="selected"' : '').">$domain</option>\n"; |
250 | 250 | } |
251 | - $GLOBALS['setup_tpl']->set_var('domains',$domains); |
|
251 | + $GLOBALS['setup_tpl']->set_var('domains', $domains); |
|
252 | 252 | |
253 | 253 | // use BLOCK B_multi_domain inside of login_stage_header |
254 | - $GLOBALS['setup_tpl']->parse('V_multi_domain','B_multi_domain'); |
|
254 | + $GLOBALS['setup_tpl']->parse('V_multi_domain', 'B_multi_domain'); |
|
255 | 255 | // in this case, the single domain block needs to be nothing |
256 | - $GLOBALS['setup_tpl']->set_var('V_single_domain',''); |
|
256 | + $GLOBALS['setup_tpl']->set_var('V_single_domain', ''); |
|
257 | 257 | } |
258 | 258 | else |
259 | 259 | { |
260 | 260 | reset($GLOBALS['egw_domain']); |
261 | 261 | $default_domain = each($GLOBALS['egw_domain']); |
262 | - $GLOBALS['setup_tpl']->set_var('default_domain_zero',$default_domain[0]); |
|
262 | + $GLOBALS['setup_tpl']->set_var('default_domain_zero', $default_domain[0]); |
|
263 | 263 | |
264 | 264 | /* Use BLOCK B_single_domain inside of login_stage_header */ |
265 | - $GLOBALS['setup_tpl']->parse('V_single_domain','B_single_domain'); |
|
265 | + $GLOBALS['setup_tpl']->parse('V_single_domain', 'B_single_domain'); |
|
266 | 266 | /* in this case, the multi domain block needs to be nothing */ |
267 | - $GLOBALS['setup_tpl']->set_var('V_multi_domain',''); |
|
267 | + $GLOBALS['setup_tpl']->set_var('V_multi_domain', ''); |
|
268 | 268 | } |
269 | 269 | /* |
270 | 270 | End use SUB-TEMPLATE login_stage_header |
271 | 271 | put all this into V_login_stage_header for use inside login_main |
272 | 272 | */ |
273 | - $GLOBALS['setup_tpl']->parse('V_login_stage_header','T_login_stage_header'); |
|
273 | + $GLOBALS['setup_tpl']->parse('V_login_stage_header', 'T_login_stage_header'); |
|
274 | 274 | } |
275 | 275 | else |
276 | 276 | { |
277 | 277 | /* begin SKIP SUB-TEMPLATE login_stage_header */ |
278 | - $GLOBALS['setup_tpl']->set_var('V_multi_domain',''); |
|
279 | - $GLOBALS['setup_tpl']->set_var('V_single_domain',''); |
|
280 | - $GLOBALS['setup_tpl']->set_var('V_login_stage_header',''); |
|
278 | + $GLOBALS['setup_tpl']->set_var('V_multi_domain', ''); |
|
279 | + $GLOBALS['setup_tpl']->set_var('V_single_domain', ''); |
|
280 | + $GLOBALS['setup_tpl']->set_var('V_login_stage_header', ''); |
|
281 | 281 | } |
282 | 282 | /* |
283 | 283 | end use TEMPLATE login_main.tpl |
284 | 284 | now out the login_main template |
285 | 285 | */ |
286 | - $GLOBALS['setup_tpl']->pparse('out','T_login_main'); |
|
286 | + $GLOBALS['setup_tpl']->pparse('out', 'T_login_main'); |
|
287 | 287 | } |
288 | 288 | |
289 | - static function lang_select($onChange=False,$ConfigLang='') |
|
289 | + static function lang_select($onChange = False, $ConfigLang = '') |
|
290 | 290 | { |
291 | 291 | if (empty($ConfigLang)) |
292 | 292 | { |
293 | - $ConfigLang = setup::get_lang(true); // true use Accept-Language header |
|
293 | + $ConfigLang = setup::get_lang(true); // true use Accept-Language header |
|
294 | 294 | } |
295 | 295 | return Api\Html::select('ConfigLang', $ConfigLang, Api\Translation::get_available_langs(false), true, |
296 | 296 | $onChange ? ' onchange="this.form.submit();"' : ''); |
@@ -298,19 +298,19 @@ discard block |
||
298 | 298 | |
299 | 299 | static function get_template_list() |
300 | 300 | { |
301 | - $d = dir(EGW_SERVER_ROOT . '/phpgwapi/templates'); |
|
301 | + $d = dir(EGW_SERVER_ROOT.'/phpgwapi/templates'); |
|
302 | 302 | |
303 | 303 | $list = array(); |
304 | - while($entry = $d->read()) |
|
304 | + while ($entry = $d->read()) |
|
305 | 305 | { |
306 | 306 | if ($entry != 'CVS' && $entry != '.' && $entry != '..') |
307 | 307 | { |
308 | 308 | $list[$entry]['name'] = $entry; |
309 | - $f = EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/details.inc.php'; |
|
310 | - if (file_exists ($f)) |
|
309 | + $f = EGW_SERVER_ROOT.'/phpgwapi/templates/'.$entry.'/details.inc.php'; |
|
310 | + if (file_exists($f)) |
|
311 | 311 | { |
312 | 312 | include($f); |
313 | - $list[$entry]['title'] = 'Use ' . $GLOBALS['egw_info']['template'][$entry]['title'] . 'interface'; |
|
313 | + $list[$entry]['title'] = 'Use '.$GLOBALS['egw_info']['template'][$entry]['title'].'interface'; |
|
314 | 314 | } |
315 | 315 | else |
316 | 316 | { |
@@ -319,22 +319,22 @@ discard block |
||
319 | 319 | } |
320 | 320 | } |
321 | 321 | $d->close(); |
322 | - reset ($list); |
|
322 | + reset($list); |
|
323 | 323 | return $list; |
324 | 324 | } |
325 | 325 | |
326 | 326 | static function list_themes() |
327 | 327 | { |
328 | - $dh = dir(EGW_SERVER_ROOT . '/phpgwapi/themes'); |
|
328 | + $dh = dir(EGW_SERVER_ROOT.'/phpgwapi/themes'); |
|
329 | 329 | while ($file = $dh->read()) |
330 | 330 | { |
331 | 331 | if (preg_match('/'."\.theme$".'/i', $file)) |
332 | 332 | { |
333 | - $list[] = substr($file,0,strpos($file,'.')); |
|
333 | + $list[] = substr($file, 0, strpos($file, '.')); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | $dh->close(); |
337 | - reset ($list); |
|
337 | + reset($list); |
|
338 | 338 | return $list; |
339 | 339 | } |
340 | 340 | } |
@@ -196,7 +196,7 @@ |
||
196 | 196 | * |
197 | 197 | * @param filter array of field => settings |
198 | 198 | */ |
199 | - private function set_filter(Array $filter) { |
|
199 | + private function set_filter(array $filter) { |
|
200 | 200 | $this->definition['filter'] = $filter; |
201 | 201 | } |
202 | 202 |
@@ -176,7 +176,6 @@ |
||
176 | 176 | /** |
177 | 177 | * sets options |
178 | 178 | * |
179 | - * @param array $options |
|
180 | 179 | */ |
181 | 180 | private function set_options(array $_plugin_options) { |
182 | 181 | // Check conditions |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param string $_identifier |
67 | 67 | */ |
68 | - public function __construct( $_identifier='' ) { |
|
69 | - $this->so_sql = new Api\Storage\Base(self::_appname ,self::_defintion_talbe); |
|
68 | + public function __construct($_identifier = '') { |
|
69 | + $this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_talbe); |
|
70 | 70 | $this->user = $GLOBALS['egw_info']['user']['user_id']; |
71 | 71 | $this->is_admin = $GLOBALS['egw_info']['user']['apps']['admin'] || $GLOBALS['egw_setup'] ? true : false; |
72 | 72 | // compability to string identifiers |
@@ -74,17 +74,17 @@ discard block |
||
74 | 74 | |
75 | 75 | if ((int)$_identifier != 0) { |
76 | 76 | $this->definition = $this->so_sql->read(array('definition_id' => $_identifier)); |
77 | - if ( empty( $this->definition ) ) { |
|
77 | + if (empty($this->definition)) { |
|
78 | 78 | throw new Exception('Error: No such definition with identifier :"'.$_identifier.'"!'); |
79 | 79 | } |
80 | - if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) { |
|
80 | + if (!(importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) { |
|
81 | 81 | throw new Exception('Error: User "'.$this->user.'" is not permitted to get definition with identifier "'.$_identifier.'"!'); |
82 | 82 | } |
83 | 83 | try |
84 | 84 | { |
85 | - $options_data = importexport_arrayxml::xml2array( $this->definition['plugin_options'] ); |
|
85 | + $options_data = importexport_arrayxml::xml2array($this->definition['plugin_options']); |
|
86 | 86 | $this->definition['plugin_options'] = (array)$options_data['root']; |
87 | - if($this->definition['filter']) $filter = importexport_arrayxml::xml2array( $this->definition['filter'] ); |
|
87 | + if ($this->definition['filter']) $filter = importexport_arrayxml::xml2array($this->definition['filter']); |
|
88 | 88 | $this->definition['filter'] = $filter['root']; |
89 | 89 | } |
90 | 90 | catch (Exception $e) |
@@ -100,22 +100,22 @@ discard block |
||
100 | 100 | * @param string $_name |
101 | 101 | * @return int |
102 | 102 | */ |
103 | - private function name2identifier( $_name ) { |
|
104 | - $identifiers = $this->so_sql->search(array('name' => $_name),true); |
|
103 | + private function name2identifier($_name) { |
|
104 | + $identifiers = $this->so_sql->search(array('name' => $_name), true); |
|
105 | 105 | if (isset($identifiers[1])) { |
106 | - throw new Exception('Error: Definition: "'.$_name. '" is not unique! Can\'t convert to identifier'); |
|
106 | + throw new Exception('Error: Definition: "'.$_name.'" is not unique! Can\'t convert to identifier'); |
|
107 | 107 | } |
108 | - if ( empty( $identifiers[0] ) ) { |
|
108 | + if (empty($identifiers[0])) { |
|
109 | 109 | // not a good idea, till we don't have different exceptions so far |
110 | 110 | // throw new Exception('Error: No such definition :"'.$_name.'"!'); |
111 | - $identifiers = array( array( 'definition_id' => 0 ) ); |
|
111 | + $identifiers = array(array('definition_id' => 0)); |
|
112 | 112 | } |
113 | 113 | return $identifiers[0]['definition_id']; |
114 | 114 | } |
115 | 115 | |
116 | 116 | public function __get($_attribute_name) { |
117 | - if (!array_key_exists($_attribute_name,$this->attributes)) { |
|
118 | - throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion'); |
|
117 | + if (!array_key_exists($_attribute_name, $this->attributes)) { |
|
118 | + throw new Exception('Error: "'.$_attribute_name.'" is not an attribute defintion'); |
|
119 | 119 | } |
120 | 120 | switch ($_attribute_name) { |
121 | 121 | case 'allowed_users' : |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | - public function __set($_attribute_name,$_data) { |
|
133 | - if (!array_key_exists($_attribute_name,$this->attributes)) { |
|
134 | - throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion'); |
|
132 | + public function __set($_attribute_name, $_data) { |
|
133 | + if (!array_key_exists($_attribute_name, $this->attributes)) { |
|
134 | + throw new Exception('Error: "'.$_attribute_name.'" is not an attribute defintion'); |
|
135 | 135 | } |
136 | 136 | switch ($_attribute_name) { |
137 | 137 | case 'allowed_users' : |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @return array |
153 | 153 | */ |
154 | 154 | private function get_allowed_users() { |
155 | - return explode(',',substr($this->definition['allowed_users'],1,-1)); |
|
155 | + return explode(',', substr($this->definition['allowed_users'], 1, -1)); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @param array $_allowed_users |
162 | 162 | */ |
163 | - private function set_allowed_users( $_allowed_users ) { |
|
164 | - $this->definition['allowed_users'] = ','.implode(',',(array)$_allowed_users) .','; |
|
163 | + private function set_allowed_users($_allowed_users) { |
|
164 | + $this->definition['allowed_users'] = ','.implode(',', (array)$_allowed_users).','; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | */ |
181 | 181 | private function set_options(array $_plugin_options) { |
182 | 182 | // Check conditions |
183 | - foreach ( $_plugin_options['conditions'] as $key => $condition ) { |
|
184 | - if(!$condition['string']) |
|
183 | + foreach ($_plugin_options['conditions'] as $key => $condition) { |
|
184 | + if (!$condition['string']) |
|
185 | 185 | { |
186 | 186 | unset($_plugin_options['conditions'][$key]); |
187 | 187 | } |
@@ -237,13 +237,13 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return void |
239 | 239 | */ |
240 | - public function set_record( array $_record ) { |
|
241 | - $this->definition = array_intersect_key( $_record, $this->attributes ); |
|
240 | + public function set_record(array $_record) { |
|
241 | + $this->definition = array_intersect_key($_record, $this->attributes); |
|
242 | 242 | |
243 | 243 | // anything which is not an attribute is perhaps a plugin_option. |
244 | 244 | // If not, it gets whiped out on save time. |
245 | - foreach ( $_record as $attribute => $value) { |
|
246 | - if ( !array_key_exists( $attribute, $this->attributes ) ) { |
|
245 | + foreach ($_record as $attribute => $value) { |
|
246 | + if (!array_key_exists($attribute, $this->attributes)) { |
|
247 | 247 | $this->definition['plugin_options'][$attribute] = $value; |
248 | 248 | } |
249 | 249 | } |
@@ -251,9 +251,9 @@ discard block |
||
251 | 251 | $this->plugin = $_record['plugin']; |
252 | 252 | |
253 | 253 | // convert plugin_options into internal representation |
254 | - $this->set_allowed_users( $this->definition['allowed_users'] ); |
|
255 | - $this->set_options( $this->definition['plugin_options'] ? $this->definition['plugin_options'] : array()); |
|
256 | - $this->set_filter( $this->definition['filter'] ? $this->definition['filter'] : array()); |
|
254 | + $this->set_allowed_users($this->definition['allowed_users']); |
|
255 | + $this->set_options($this->definition['plugin_options'] ? $this->definition['plugin_options'] : array()); |
|
256 | + $this->set_filter($this->definition['filter'] ? $this->definition['filter'] : array()); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @return string Full URL of an icon, or appname/icon_name |
274 | 274 | */ |
275 | 275 | public function get_icon() { |
276 | - return self::_appname . '/navbar'; |
|
276 | + return self::_appname.'/navbar'; |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -281,16 +281,16 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return string identifier |
283 | 283 | */ |
284 | - public function save ( $_dst_identifier ) { |
|
285 | - if ( strlen($this->definition['name']) < 3 ) { |
|
284 | + public function save($_dst_identifier) { |
|
285 | + if (strlen($this->definition['name']) < 3) { |
|
286 | 286 | throw new Exception('Error: Can\'t save definition, no valid name given!'); |
287 | 287 | } |
288 | 288 | |
289 | 289 | $this->so_sql->data = $this->definition; |
290 | - $this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml( $this->definition['plugin_options'] ); |
|
291 | - $this->so_sql->data['filter'] = importexport_arrayxml::array2xml( $this->definition['filter'] ); |
|
290 | + $this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml($this->definition['plugin_options']); |
|
291 | + $this->so_sql->data['filter'] = importexport_arrayxml::array2xml($this->definition['filter']); |
|
292 | 292 | $this->so_sql->data['modified'] = time(); |
293 | - if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier ))) { |
|
293 | + if ($this->so_sql->save(array('definition_id' => $_dst_identifier))) { |
|
294 | 294 | throw new Exception('Error: Api\Storage\Base was not able to save definition: '.$this->get_identifier()); |
295 | 295 | } |
296 | 296 | |
@@ -303,13 +303,13 @@ discard block |
||
303 | 303 | * @param string $_dst_identifier |
304 | 304 | * @return string dst_identifier |
305 | 305 | */ |
306 | - public function copy ( $_dst_identifier ) { |
|
306 | + public function copy($_dst_identifier) { |
|
307 | 307 | $dst_object = clone $this; |
308 | 308 | try { |
309 | 309 | $dst_object->set_owner($this->user); |
310 | 310 | $dst_identifier = $dst_object->save($_dst_identifier); |
311 | 311 | } |
312 | - catch(exception $Exception) { |
|
312 | + catch (exception $Exception) { |
|
313 | 313 | unset($dst_object); |
314 | 314 | throw $Exception; |
315 | 315 | } |
@@ -324,16 +324,16 @@ discard block |
||
324 | 324 | * @param string $_dst_identifier |
325 | 325 | * @return string dst_identifier |
326 | 326 | */ |
327 | - public function move ( $_dst_identifier ) { |
|
327 | + public function move($_dst_identifier) { |
|
328 | 328 | if ($this->user != $this->get_owner() && !$this->is_admin) { |
329 | - throw('Error: User '. $this->user. 'does not have permissions to move definition '.$this->get_identifier()); |
|
329 | + throw('Error: User '.$this->user.'does not have permissions to move definition '.$this->get_identifier()); |
|
330 | 330 | } |
331 | 331 | $old_object = clone $this; |
332 | 332 | try { |
333 | 333 | $dst_identifier = $this->save($_dst_identifier); |
334 | 334 | $old_object->delete(); |
335 | 335 | } |
336 | - catch(exception $Exception) { |
|
336 | + catch (exception $Exception) { |
|
337 | 337 | unset($old_object); |
338 | 338 | throw $Exception; |
339 | 339 | } |
@@ -346,11 +346,11 @@ discard block |
||
346 | 346 | * @return void |
347 | 347 | * |
348 | 348 | */ |
349 | - public function delete () { |
|
350 | - if($this->user != $this->get_owner() && !$this->is_admin) { |
|
351 | - throw('Error: User '. $this->user. 'does not have permissions to delete definition '.$this->get_identifier()); |
|
349 | + public function delete() { |
|
350 | + if ($this->user != $this->get_owner() && !$this->is_admin) { |
|
351 | + throw('Error: User '.$this->user.'does not have permissions to delete definition '.$this->get_identifier()); |
|
352 | 352 | } |
353 | - if(!$this->so_sql->delete()) { |
|
353 | + if (!$this->so_sql->delete()) { |
|
354 | 354 | throw('Error: Api\Storage\Base was not able to delete definition: '.$this->get_identifier()); |
355 | 355 | } |
356 | 356 | } |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | * are in one assiozative array which is complely managed by {Im|Ex}port plugins |
21 | 21 | * @todo testing |
22 | 22 | */ |
23 | -class importexport_definition implements importexport_iface_egw_record { |
|
23 | +class importexport_definition implements importexport_iface_egw_record |
|
24 | +{ |
|
24 | 25 | |
25 | 26 | const _appname = 'importexport'; |
26 | 27 | const _defintion_talbe = 'egw_importexport_definitions'; |
@@ -65,26 +66,36 @@ discard block |
||
65 | 66 | * |
66 | 67 | * @param string $_identifier |
67 | 68 | */ |
68 | - public function __construct( $_identifier='' ) { |
|
69 | + public function __construct( $_identifier='' ) |
|
70 | + { |
|
69 | 71 | $this->so_sql = new Api\Storage\Base(self::_appname ,self::_defintion_talbe); |
70 | 72 | $this->user = $GLOBALS['egw_info']['user']['user_id']; |
71 | 73 | $this->is_admin = $GLOBALS['egw_info']['user']['apps']['admin'] || $GLOBALS['egw_setup'] ? true : false; |
72 | 74 | // compability to string identifiers |
73 | - if (!is_numeric($_identifier) && strlen($_identifier) > 3) $_identifier = $this->name2identifier($_identifier); |
|
75 | + if (!is_numeric($_identifier) && strlen($_identifier) > 3) |
|
76 | + { |
|
77 | + $_identifier = $this->name2identifier($_identifier); |
|
78 | + } |
|
74 | 79 | |
75 | - if ((int)$_identifier != 0) { |
|
80 | + if ((int)$_identifier != 0) |
|
81 | + { |
|
76 | 82 | $this->definition = $this->so_sql->read(array('definition_id' => $_identifier)); |
77 | - if ( empty( $this->definition ) ) { |
|
83 | + if ( empty( $this->definition ) ) |
|
84 | + { |
|
78 | 85 | throw new Exception('Error: No such definition with identifier :"'.$_identifier.'"!'); |
79 | 86 | } |
80 | - if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) { |
|
87 | + if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) |
|
88 | + { |
|
81 | 89 | throw new Exception('Error: User "'.$this->user.'" is not permitted to get definition with identifier "'.$_identifier.'"!'); |
82 | 90 | } |
83 | 91 | try |
84 | 92 | { |
85 | 93 | $options_data = importexport_arrayxml::xml2array( $this->definition['plugin_options'] ); |
86 | 94 | $this->definition['plugin_options'] = (array)$options_data['root']; |
87 | - if($this->definition['filter']) $filter = importexport_arrayxml::xml2array( $this->definition['filter'] ); |
|
95 | + if($this->definition['filter']) |
|
96 | + { |
|
97 | + $filter = importexport_arrayxml::xml2array( $this->definition['filter'] ); |
|
98 | + } |
|
88 | 99 | $this->definition['filter'] = $filter['root']; |
89 | 100 | } |
90 | 101 | catch (Exception $e) |
@@ -100,12 +111,15 @@ discard block |
||
100 | 111 | * @param string $_name |
101 | 112 | * @return int |
102 | 113 | */ |
103 | - private function name2identifier( $_name ) { |
|
114 | + private function name2identifier( $_name ) |
|
115 | + { |
|
104 | 116 | $identifiers = $this->so_sql->search(array('name' => $_name),true); |
105 | - if (isset($identifiers[1])) { |
|
117 | + if (isset($identifiers[1])) |
|
118 | + { |
|
106 | 119 | throw new Exception('Error: Definition: "'.$_name. '" is not unique! Can\'t convert to identifier'); |
107 | 120 | } |
108 | - if ( empty( $identifiers[0] ) ) { |
|
121 | + if ( empty( $identifiers[0] ) ) |
|
122 | + { |
|
109 | 123 | // not a good idea, till we don't have different exceptions so far |
110 | 124 | // throw new Exception('Error: No such definition :"'.$_name.'"!'); |
111 | 125 | $identifiers = array( array( 'definition_id' => 0 ) ); |
@@ -113,11 +127,14 @@ discard block |
||
113 | 127 | return $identifiers[0]['definition_id']; |
114 | 128 | } |
115 | 129 | |
116 | - public function __get($_attribute_name) { |
|
117 | - if (!array_key_exists($_attribute_name,$this->attributes)) { |
|
130 | + public function __get($_attribute_name) |
|
131 | + { |
|
132 | + if (!array_key_exists($_attribute_name,$this->attributes)) |
|
133 | + { |
|
118 | 134 | throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion'); |
119 | 135 | } |
120 | - switch ($_attribute_name) { |
|
136 | + switch ($_attribute_name) |
|
137 | + { |
|
121 | 138 | case 'allowed_users' : |
122 | 139 | return $this->get_allowed_users(); |
123 | 140 | case 'plugin_options' : |
@@ -129,11 +146,14 @@ discard block |
||
129 | 146 | } |
130 | 147 | } |
131 | 148 | |
132 | - public function __set($_attribute_name,$_data) { |
|
133 | - if (!array_key_exists($_attribute_name,$this->attributes)) { |
|
149 | + public function __set($_attribute_name,$_data) |
|
150 | + { |
|
151 | + if (!array_key_exists($_attribute_name,$this->attributes)) |
|
152 | + { |
|
134 | 153 | throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion'); |
135 | 154 | } |
136 | - switch ($_attribute_name) { |
|
155 | + switch ($_attribute_name) |
|
156 | + { |
|
137 | 157 | case 'allowed_users' : |
138 | 158 | return $this->set_allowed_users($_data); |
139 | 159 | case 'plugin_options' : |
@@ -151,7 +171,8 @@ discard block |
||
151 | 171 | * |
152 | 172 | * @return array |
153 | 173 | */ |
154 | - private function get_allowed_users() { |
|
174 | + private function get_allowed_users() |
|
175 | + { |
|
155 | 176 | return explode(',',substr($this->definition['allowed_users'],1,-1)); |
156 | 177 | } |
157 | 178 | |
@@ -160,7 +181,8 @@ discard block |
||
160 | 181 | * |
161 | 182 | * @param array $_allowed_users |
162 | 183 | */ |
163 | - private function set_allowed_users( $_allowed_users ) { |
|
184 | + private function set_allowed_users( $_allowed_users ) |
|
185 | + { |
|
164 | 186 | $this->definition['allowed_users'] = ','.implode(',',(array)$_allowed_users) .','; |
165 | 187 | } |
166 | 188 | |
@@ -169,7 +191,8 @@ discard block |
||
169 | 191 | * |
170 | 192 | * @return array |
171 | 193 | */ |
172 | - private function get_options() { |
|
194 | + private function get_options() |
|
195 | + { |
|
173 | 196 | return $this->definition['plugin_options']; |
174 | 197 | } |
175 | 198 | |
@@ -178,9 +201,11 @@ discard block |
||
178 | 201 | * |
179 | 202 | * @param array $options |
180 | 203 | */ |
181 | - private function set_options(array $_plugin_options) { |
|
204 | + private function set_options(array $_plugin_options) |
|
205 | + { |
|
182 | 206 | // Check conditions |
183 | - foreach ( $_plugin_options['conditions'] as $key => $condition ) { |
|
207 | + foreach ( $_plugin_options['conditions'] as $key => $condition ) |
|
208 | + { |
|
184 | 209 | if(!$condition['string']) |
185 | 210 | { |
186 | 211 | unset($_plugin_options['conditions'][$key]); |
@@ -194,7 +219,8 @@ discard block |
||
194 | 219 | * |
195 | 220 | * @return array |
196 | 221 | */ |
197 | - private function get_filter() { |
|
222 | + private function get_filter() |
|
223 | + { |
|
198 | 224 | return $this->definition['filter']; |
199 | 225 | } |
200 | 226 | |
@@ -203,7 +229,8 @@ discard block |
||
203 | 229 | * |
204 | 230 | * @param filter array of field => settings |
205 | 231 | */ |
206 | - private function set_filter(Array $filter) { |
|
232 | + private function set_filter(Array $filter) |
|
233 | + { |
|
207 | 234 | $this->definition['filter'] = $filter; |
208 | 235 | } |
209 | 236 | |
@@ -215,7 +242,8 @@ discard block |
||
215 | 242 | * |
216 | 243 | * @return array complete record as associative array |
217 | 244 | */ |
218 | - public function get_record_array() { |
|
245 | + public function get_record_array() |
|
246 | + { |
|
219 | 247 | $definition = $this->definition; |
220 | 248 | $definition['allowed_users'] = $this->get_allowed_users(); |
221 | 249 | $definition['plugin_options'] = $this->get_options(); |
@@ -228,7 +256,8 @@ discard block |
||
228 | 256 | * |
229 | 257 | *@return string tiltle |
230 | 258 | */ |
231 | - public function get_title() { |
|
259 | + public function get_title() |
|
260 | + { |
|
232 | 261 | return $this->definition['name']; |
233 | 262 | } |
234 | 263 | |
@@ -237,13 +266,16 @@ discard block |
||
237 | 266 | * |
238 | 267 | * @return void |
239 | 268 | */ |
240 | - public function set_record( array $_record ) { |
|
269 | + public function set_record( array $_record ) |
|
270 | + { |
|
241 | 271 | $this->definition = array_intersect_key( $_record, $this->attributes ); |
242 | 272 | |
243 | 273 | // anything which is not an attribute is perhaps a plugin_option. |
244 | 274 | // If not, it gets whiped out on save time. |
245 | - foreach ( $_record as $attribute => $value) { |
|
246 | - if ( !array_key_exists( $attribute, $this->attributes ) ) { |
|
275 | + foreach ( $_record as $attribute => $value) |
|
276 | + { |
|
277 | + if ( !array_key_exists( $attribute, $this->attributes ) ) |
|
278 | + { |
|
247 | 279 | $this->definition['plugin_options'][$attribute] = $value; |
248 | 280 | } |
249 | 281 | } |
@@ -261,7 +293,8 @@ discard block |
||
261 | 293 | * |
262 | 294 | * @return int identifier of this record |
263 | 295 | */ |
264 | - public function get_identifier() { |
|
296 | + public function get_identifier() |
|
297 | + { |
|
265 | 298 | return $this->definition['definition_id']; |
266 | 299 | } |
267 | 300 | |
@@ -272,7 +305,8 @@ discard block |
||
272 | 305 | * |
273 | 306 | * @return string Full URL of an icon, or appname/icon_name |
274 | 307 | */ |
275 | - public function get_icon() { |
|
308 | + public function get_icon() |
|
309 | + { |
|
276 | 310 | return self::_appname . '/navbar'; |
277 | 311 | } |
278 | 312 | |
@@ -281,8 +315,10 @@ discard block |
||
281 | 315 | * |
282 | 316 | * @return string identifier |
283 | 317 | */ |
284 | - public function save ( $_dst_identifier ) { |
|
285 | - if ( strlen($this->definition['name']) < 3 ) { |
|
318 | + public function save ( $_dst_identifier ) |
|
319 | + { |
|
320 | + if ( strlen($this->definition['name']) < 3 ) |
|
321 | + { |
|
286 | 322 | throw new Exception('Error: Can\'t save definition, no valid name given!'); |
287 | 323 | } |
288 | 324 | |
@@ -290,7 +326,8 @@ discard block |
||
290 | 326 | $this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml( $this->definition['plugin_options'] ); |
291 | 327 | $this->so_sql->data['filter'] = importexport_arrayxml::array2xml( $this->definition['filter'] ); |
292 | 328 | $this->so_sql->data['modified'] = time(); |
293 | - if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier ))) { |
|
329 | + if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier ))) |
|
330 | + { |
|
294 | 331 | throw new Exception('Error: Api\Storage\Base was not able to save definition: '.$this->get_identifier()); |
295 | 332 | } |
296 | 333 | |
@@ -303,7 +340,8 @@ discard block |
||
303 | 340 | * @param string $_dst_identifier |
304 | 341 | * @return string dst_identifier |
305 | 342 | */ |
306 | - public function copy ( $_dst_identifier ) { |
|
343 | + public function copy ( $_dst_identifier ) |
|
344 | + { |
|
307 | 345 | $dst_object = clone $this; |
308 | 346 | try { |
309 | 347 | $dst_object->set_owner($this->user); |
@@ -324,8 +362,10 @@ discard block |
||
324 | 362 | * @param string $_dst_identifier |
325 | 363 | * @return string dst_identifier |
326 | 364 | */ |
327 | - public function move ( $_dst_identifier ) { |
|
328 | - if ($this->user != $this->get_owner() && !$this->is_admin) { |
|
365 | + public function move ( $_dst_identifier ) |
|
366 | + { |
|
367 | + if ($this->user != $this->get_owner() && !$this->is_admin) |
|
368 | + { |
|
329 | 369 | throw('Error: User '. $this->user. 'does not have permissions to move definition '.$this->get_identifier()); |
330 | 370 | } |
331 | 371 | $old_object = clone $this; |
@@ -346,11 +386,14 @@ discard block |
||
346 | 386 | * @return void |
347 | 387 | * |
348 | 388 | */ |
349 | - public function delete () { |
|
350 | - if($this->user != $this->get_owner() && !$this->is_admin) { |
|
389 | + public function delete () |
|
390 | + { |
|
391 | + if($this->user != $this->get_owner() && !$this->is_admin) |
|
392 | + { |
|
351 | 393 | throw('Error: User '. $this->user. 'does not have permissions to delete definition '.$this->get_identifier()); |
352 | 394 | } |
353 | - if(!$this->so_sql->delete()) { |
|
395 | + if(!$this->so_sql->delete()) |
|
396 | + { |
|
354 | 397 | throw('Error: Api\Storage\Base was not able to delete definition: '.$this->get_identifier()); |
355 | 398 | } |
356 | 399 | } |
@@ -359,7 +402,8 @@ discard block |
||
359 | 402 | * destructor |
360 | 403 | * |
361 | 404 | */ |
362 | - public function __destruct() { |
|
405 | + public function __destruct() |
|
406 | + { |
|
363 | 407 | unset($this->so_sql); |
364 | 408 | } |
365 | 409 |
@@ -34,7 +34,8 @@ |
||
34 | 34 | * |
35 | 35 | * get_selector(); //returns array |
36 | 36 | */ |
37 | -interface importexport_iface_export_plugin { |
|
37 | +interface importexport_iface_export_plugin |
|
38 | +{ |
|
38 | 39 | |
39 | 40 | /** |
40 | 41 | * exports entries according to given definition object. |
@@ -87,7 +87,7 @@ |
||
87 | 87 | * preserv => array, |
88 | 88 | * ) |
89 | 89 | */ |
90 | - public function get_options_etpl(importexport_definition &$definition=null); |
|
90 | + public function get_options_etpl(importexport_definition &$definition = null); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * returns etemplate name for slectors of this plugin |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @param $definition Specific definition |
81 | 81 | * |
82 | - * @return array ( |
|
82 | + * @return boolean ( |
|
83 | 83 | * name => string, |
84 | 84 | * content => array, |
85 | 85 | * sel_options => array, |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * and automatic conversions. In most cases they are named <appname>_egw_record, |
110 | 110 | * but projectmanager is an exception to this. |
111 | 111 | * |
112 | - * @return string; |
|
112 | + * @return string |
|
113 | 113 | */ |
114 | 114 | public static function get_egw_record_class(); |
115 | 115 | } // end of iface_export_plugin |
@@ -93,7 +93,8 @@ discard block |
||
93 | 93 | 'get_rows' => 'etemplate.ajax_select_widget.array_rows', |
94 | 94 | 'id_field' => ajax_select_widget::ARRAY_KEY, |
95 | 95 | ); |
96 | - if($field['rows']) { |
|
96 | + if($field['rows']) |
|
97 | + { |
|
97 | 98 | $options['num_rows'] = $field['rows']; |
98 | 99 | } |
99 | 100 | |
@@ -103,7 +104,9 @@ discard block |
||
103 | 104 | { |
104 | 105 | $options['values'] = Api\Storage\Customfields::get_options_from_file($field['values']['@']); |
105 | 106 | unset($field['values']['@']); |
106 | - } else { |
|
107 | + } |
|
108 | + else |
|
109 | + { |
|
107 | 110 | $options['values'] = array_diff_key($field['values'], array_flip(ajax_select_widget::$known_options)); |
108 | 111 | } |
109 | 112 | $options = array_merge($options, array_intersect_key($field['values'], array_flip(ajax_select_widget::$known_options))); |
@@ -38,7 +38,7 @@ |
||
38 | 38 | * |
39 | 39 | * @param string $cname |
40 | 40 | */ |
41 | - public function beforeSendToClient($cname, Array $expand = Array()) |
|
41 | + public function beforeSendToClient($cname, array $expand = array()) |
|
42 | 42 | { |
43 | 43 | $form_name = self::form_name($cname, $this->id); |
44 | 44 | if($this->getElementAttribute($form_name, 'customfields')) |
@@ -41,18 +41,18 @@ discard block |
||
41 | 41 | public function beforeSendToClient($cname, Array $expand = Array()) |
42 | 42 | { |
43 | 43 | $form_name = self::form_name($cname, $this->id); |
44 | - if($this->getElementAttribute($form_name, 'customfields')) |
|
44 | + if ($this->getElementAttribute($form_name, 'customfields')) |
|
45 | 45 | { |
46 | 46 | // Already done? Still need to process, or sel_options may be missing |
47 | 47 | unset(self::$request->modifications[$form_name]); |
48 | 48 | } |
49 | - $value =& self::get_array(self::$request->content, $form_name, true); |
|
49 | + $value = & self::get_array(self::$request->content, $form_name, true); |
|
50 | 50 | $fields = $value['fields']; |
51 | 51 | unset($value['fields']); |
52 | 52 | $relative_dates = $this->attrs['relative_dates']; |
53 | 53 | |
54 | 54 | // Fallback, so there's something there... |
55 | - if(!is_array($fields)) |
|
55 | + if (!is_array($fields)) |
|
56 | 56 | { |
57 | 57 | error_log("$this has no fields"); |
58 | 58 | self::$transformation = array( |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | $this->setElementAttribute($form_name, 'prefix', self::$prefix); |
70 | 70 | |
71 | 71 | $n = 1; |
72 | - foreach($fields as $lname => &$field) |
|
72 | + foreach ($fields as $lname => &$field) |
|
73 | 73 | { |
74 | - $type =& $field['type']; |
|
74 | + $type = & $field['type']; |
|
75 | 75 | |
76 | 76 | // No filters are required |
77 | 77 | $field['needed'] = false; |
78 | 78 | |
79 | - switch($type) |
|
79 | + switch ($type) |
|
80 | 80 | { |
81 | 81 | case 'date': |
82 | 82 | case 'date-time': |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | 'get_rows' => 'etemplate.ajax_select_widget.array_rows', |
94 | 94 | 'id_field' => ajax_select_widget::ARRAY_KEY, |
95 | 95 | ); |
96 | - if($field['rows']) { |
|
96 | + if ($field['rows']) { |
|
97 | 97 | $options['num_rows'] = $field['rows']; |
98 | 98 | } |
99 | 99 | |
@@ -115,22 +115,22 @@ discard block |
||
115 | 115 | // fall through |
116 | 116 | case 'select': |
117 | 117 | default: |
118 | - if(strpos($field['type'],'select') === 0) |
|
118 | + if (strpos($field['type'], 'select') === 0) |
|
119 | 119 | { |
120 | 120 | if (count($field['values']) == 1 && isset($field['values']['@'])) |
121 | 121 | { |
122 | 122 | $field['values'] = Api\Storage\Customfields::get_options_from_file($field['values']['@']); |
123 | 123 | } |
124 | - foreach((array)$field['values'] as $key => $val) |
|
124 | + foreach ((array)$field['values'] as $key => $val) |
|
125 | 125 | { |
126 | - if (substr($val = lang($val),-1) != '*') |
|
126 | + if (substr($val = lang($val), -1) != '*') |
|
127 | 127 | { |
128 | 128 | $field['values'][$key] = $val; |
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | 132 | // We don't want the 'All' or 'Select...' if it's there |
133 | - if(is_array($field['values']) && $field['values']['']) |
|
133 | + if (is_array($field['values']) && $field['values']['']) |
|
134 | 134 | { |
135 | 135 | unset($field['values']['']); |
136 | 136 | } |
@@ -138,27 +138,27 @@ discard block |
||
138 | 138 | $this->setElementAttribute($form_name.'['.self::$prefix.$lname.']', 'tags', TRUE); |
139 | 139 | $this->setElementAttribute($form_name.'['.self::$prefix.$lname.']', 'multiple', TRUE); |
140 | 140 | } |
141 | - else if( $GLOBALS['egw_info']['apps'][$field['type']]) |
|
141 | + else if ($GLOBALS['egw_info']['apps'][$field['type']]) |
|
142 | 142 | { |
143 | 143 | // Links |
144 | 144 | } |
145 | 145 | else |
146 | 146 | { |
147 | - error_log('Trying to filter with unsupported field type ' . $lname . ': ' . $field['type']); |
|
147 | + error_log('Trying to filter with unsupported field type '.$lname.': '.$field['type']); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Send select options |
152 | - if($field['values']) |
|
152 | + if ($field['values']) |
|
153 | 153 | { |
154 | 154 | self::$request->sel_options[self::$prefix.$lname] = $field['values']; |
155 | 155 | } |
156 | 156 | $widget = self::factory($type, '<'.$type.' type="'.$type.'" id="'.self::$prefix.$lname.'"/>', self::$prefix.$lname); |
157 | - if(method_exists($widget, 'beforeSendToClient')) |
|
157 | + if (method_exists($widget, 'beforeSendToClient')) |
|
158 | 158 | { |
159 | 159 | $widget->id = self::$prefix.$lname; |
160 | 160 | $widget->attrs['type'] = $type; |
161 | - if($type == 'link-to') |
|
161 | + if ($type == 'link-to') |
|
162 | 162 | { |
163 | 163 | $widget->attrs['only_app'] = $field['type']; |
164 | 164 | } |
@@ -170,22 +170,22 @@ discard block |
||
170 | 170 | parent::beforeSendToClient($cname, $expand); |
171 | 171 | |
172 | 172 | $this->setElementAttribute($form_name, 'customfields', $fields); |
173 | - $this->setElementAttribute($form_name, 'fields',array_fill_keys(array_keys($fields), true)); |
|
173 | + $this->setElementAttribute($form_name, 'fields', array_fill_keys(array_keys($fields), true)); |
|
174 | 174 | return false; |
175 | 175 | } |
176 | 176 | |
177 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
177 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
178 | 178 | { |
179 | 179 | $form_name = self::form_name($cname, $this->id, $expand); |
180 | 180 | if (!$this->is_readonly($cname, $form_name)) |
181 | 181 | { |
182 | 182 | $value_in = (array)self::get_array($content, $form_name); |
183 | - $valid =& self::get_array($validated, $this->id ? $form_name : $field, true); |
|
183 | + $valid = & self::get_array($validated, $this->id ? $form_name : $field, true); |
|
184 | 184 | |
185 | - foreach($value_in as $key => $value) |
|
185 | + foreach ($value_in as $key => $value) |
|
186 | 186 | { |
187 | 187 | // Client side cf widget automatically prefixes # |
188 | - $valid[substr($key,strlen(self::$prefix))] = $value; |
|
188 | + $valid[substr($key, strlen(self::$prefix))] = $value; |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
@@ -36,7 +36,10 @@ |
||
36 | 36 | */ |
37 | 37 | protected function exec($check_only=false) |
38 | 38 | { |
39 | - if ($check_only) return true; |
|
39 | + if ($check_only) |
|
40 | + { |
|
41 | + return true; |
|
42 | + } |
|
40 | 43 | |
41 | 44 | admin_cmd::_instanciate_accounts(); |
42 | 45 | $deleted = 0; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param array $data =array() default parm from parent class, no real parameters |
22 | 22 | */ |
23 | - function __construct($data=array()) |
|
23 | + function __construct($data = array()) |
|
24 | 24 | { |
25 | 25 | admin_cmd::__construct($data); |
26 | 26 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @throws Exception(lang("Unknown account: %1 !!!",$this->account),15); |
35 | 35 | * @throws Exception(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8); |
36 | 36 | */ |
37 | - protected function exec($check_only=false) |
|
37 | + protected function exec($check_only = false) |
|
38 | 38 | { |
39 | 39 | if ($check_only) return true; |
40 | 40 | |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | if (($all_accounts = admin_cmd::$accounts->search(array('type'=>'both')))) |
44 | 44 | { |
45 | 45 | $ids = array(); |
46 | - foreach($all_accounts as $account) |
|
46 | + foreach ($all_accounts as $account) |
|
47 | 47 | { |
48 | 48 | $ids[] = $account['account_id']; |
49 | 49 | } |
50 | - $GLOBALS['egw']->db->query("DELETE FROM egw_acl WHERE acl_account NOT IN (".implode(',',$ids).") OR acl_appname='phpgw_group' AND acl_location NOT IN ('".implode("','",$ids)."')",__LINE__,__FILE__); |
|
50 | + $GLOBALS['egw']->db->query("DELETE FROM egw_acl WHERE acl_account NOT IN (".implode(',', $ids).") OR acl_appname='phpgw_group' AND acl_location NOT IN ('".implode("','", $ids)."')", __LINE__, __FILE__); |
|
51 | 51 | $deleted = $GLOBALS['egw']->db->affected_rows(); |
52 | 52 | } |
53 | - return lang("%1 ACL records of not (longer) existing accounts deleted.",$deleted); |
|
53 | + return lang("%1 ACL records of not (longer) existing accounts deleted.", $deleted); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |