@@ -28,9 +28,6 @@ |
||
28 | 28 | /** |
29 | 29 | * Constructor |
30 | 30 | * |
31 | - * @param boolean $data=true true: send only the remote_hash, domain and webserver_url, |
|
32 | - * false: the complete header vars, plus install_id and webserver_url from the config table, |
|
33 | - * null: only the header vars |
|
34 | 31 | */ |
35 | 32 | function __construct($data=true,$header_admin_user=null,$header_admin_password=null) |
36 | 33 | { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * false: the complete header vars, plus install_id and webserver_url from the config table, |
33 | 33 | * null: only the header vars |
34 | 34 | */ |
35 | - function __construct($data=true,$header_admin_user=null,$header_admin_password=null) |
|
35 | + function __construct($data = true, $header_admin_user = null, $header_admin_password = null) |
|
36 | 36 | { |
37 | 37 | if (!is_array($data)) |
38 | 38 | { |
@@ -54,16 +54,16 @@ discard block |
||
54 | 54 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
55 | 55 | * @throws Exception('header.inc.php not found!'); |
56 | 56 | */ |
57 | - function exec($check_only=false) |
|
57 | + function exec($check_only = false) |
|
58 | 58 | { |
59 | - if ($this->remote_id && $check_only) return true; // cant check for the remote site locally! |
|
59 | + if ($this->remote_id && $check_only) return true; // cant check for the remote site locally! |
|
60 | 60 | |
61 | 61 | $this->_check_header_access(); |
62 | 62 | |
63 | 63 | if ($check_only) return true; |
64 | 64 | |
65 | 65 | $egw_info_backup = $GLOBALS['egw_info']; |
66 | - $GLOBALS['egw_info'] = array ( |
|
66 | + $GLOBALS['egw_info'] = array( |
|
67 | 67 | 'flags' => array( |
68 | 68 | 'noapi' => true, |
69 | 69 | ), |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | { |
73 | 73 | throw new Exception('header.inc.php not found!'); |
74 | 74 | } |
75 | - eval(str_replace(array('<?php','perfgetmicrotime'),array('','perfgetmicrotime2'),$header)); |
|
75 | + eval(str_replace(array('<?php', 'perfgetmicrotime'), array('', 'perfgetmicrotime2'), $header)); |
|
76 | 76 | |
77 | 77 | // unset the flags, they are not part of the header |
78 | 78 | unset($GLOBALS['egw_info']['flags']); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $GLOBALS['egw_info']['server']['versions']['phpgwapi'] = $egw_info_backup['server']['versions']['phpgwapi']; |
82 | 82 | |
83 | 83 | // fetching the install id's stored in the database |
84 | - foreach($GLOBALS['egw_domain'] as &$data) |
|
84 | + foreach ($GLOBALS['egw_domain'] as &$data) |
|
85 | 85 | { |
86 | 86 | if (!is_null($this->hash_only)) |
87 | 87 | { |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | } |
90 | 90 | try { |
91 | 91 | // it's saver to only send the remote_hash and not install_id and config_pw |
92 | - $data['remote_hash'] = admin_cmd::remote_hash($data['install_id'],$data['config_passwd']); |
|
92 | + $data['remote_hash'] = admin_cmd::remote_hash($data['install_id'], $data['config_passwd']); |
|
93 | 93 | } |
94 | - catch(Exception $e) { |
|
94 | + catch (Exception $e) { |
|
95 | 95 | if ($data['install_id']) $data['error'] .= $e->getMessage(); |
96 | 96 | } |
97 | 97 | if ($this->hash_only) |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | 'remote_hash' => $data['remote_hash'], |
101 | 101 | 'webserver_url' => $data['webserver_url'], |
102 | 102 | 'install_id' => $data['install_id'], |
103 | - )+($data['error'] ? array( |
|
103 | + ) + ($data['error'] ? array( |
|
104 | 104 | 'error' => $data['error'], |
105 | 105 | ) : array()); |
106 | 106 | } |
@@ -133,17 +133,17 @@ discard block |
||
133 | 133 | { |
134 | 134 | $db = new Api\Db(); |
135 | 135 | |
136 | - ob_start(); // not available db connection echos a lot grab ;-) |
|
136 | + ob_start(); // not available db connection echos a lot grab ;-) |
|
137 | 137 | $err_rep = error_reporting(0); |
138 | 138 | |
139 | 139 | $config = array(); |
140 | 140 | try { |
141 | - $db->connect($data['db_name'],$data['db_host'],$data['db_port'],$data['db_user'],$data['db_pass'],$data['db_type']); |
|
141 | + $db->connect($data['db_name'], $data['db_host'], $data['db_port'], $data['db_user'], $data['db_pass'], $data['db_type']); |
|
142 | 142 | $db->set_app('phpgwapi'); |
143 | - $db->select('egw_config','config_name,config_value',array( |
|
144 | - 'config_name'=>array('install_id','webserver_url','account_repository','allow_remote_admin','mail_suffix'), |
|
143 | + $db->select('egw_config', 'config_name,config_value', array( |
|
144 | + 'config_name'=>array('install_id', 'webserver_url', 'account_repository', 'allow_remote_admin', 'mail_suffix'), |
|
145 | 145 | 'config_app'=>'phpgwapi', |
146 | - ),__LINE__,__FILE__); |
|
146 | + ), __LINE__, __FILE__); |
|
147 | 147 | while (($row = $db->row(true))) |
148 | 148 | { |
149 | 149 | $config[$row['config_name']] = $row['config_value']; |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param boolean $set_modifier =true set the current user as modifier or 0 (= run by the system) |
168 | 168 | * @return boolean true on success, false otherwise |
169 | 169 | */ |
170 | - function save($set_modifier=true) |
|
170 | + function save($set_modifier = true) |
|
171 | 171 | { |
172 | 172 | if ($this->remote_id) |
173 | 173 | { |
@@ -56,11 +56,18 @@ discard block |
||
56 | 56 | */ |
57 | 57 | function exec($check_only=false) |
58 | 58 | { |
59 | - if ($this->remote_id && $check_only) return true; // cant check for the remote site locally! |
|
59 | + if ($this->remote_id && $check_only) |
|
60 | + { |
|
61 | + return true; |
|
62 | + } |
|
63 | + // cant check for the remote site locally! |
|
60 | 64 | |
61 | 65 | $this->_check_header_access(); |
62 | 66 | |
63 | - if ($check_only) return true; |
|
67 | + if ($check_only) |
|
68 | + { |
|
69 | + return true; |
|
70 | + } |
|
64 | 71 | |
65 | 72 | $egw_info_backup = $GLOBALS['egw_info']; |
66 | 73 | $GLOBALS['egw_info'] = array ( |
@@ -92,7 +99,10 @@ discard block |
||
92 | 99 | $data['remote_hash'] = admin_cmd::remote_hash($data['install_id'],$data['config_passwd']); |
93 | 100 | } |
94 | 101 | catch(Exception $e) { |
95 | - if ($data['install_id']) $data['error'] .= $e->getMessage(); |
|
102 | + if ($data['install_id']) |
|
103 | + { |
|
104 | + $data['error'] .= $e->getMessage(); |
|
105 | + } |
|
96 | 106 | } |
97 | 107 | if ($this->hash_only) |
98 | 108 | { |
@@ -252,7 +252,7 @@ |
||
252 | 252 | /** |
253 | 253 | * Check if header exists and is up to date |
254 | 254 | * |
255 | - * @return int 1=no header.inc.php, 2=no header admin pw, 3=no instances, 4=need upgrade, 10=ok |
|
255 | + * @return string 1=no header.inc.php, 2=no header admin pw, 3=no instances, 4=need upgrade, 10=ok |
|
256 | 256 | */ |
257 | 257 | function check_header() |
258 | 258 | { |
@@ -65,7 +65,9 @@ discard block |
||
65 | 65 | foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'*',false,__LINE__,__FILE__) as $row) |
66 | 66 | { |
67 | 67 | $app = $row['app_name']; |
68 | - if (!isset($setup_info[$app])) // app source no longer there |
|
68 | + if (!isset($setup_info[$app])) |
|
69 | + { |
|
70 | + // app source no longer there |
|
69 | 71 | { |
70 | 72 | $setup_info[$app] = array( |
71 | 73 | 'name' => $app, |
@@ -73,6 +75,7 @@ discard block |
||
73 | 75 | 'version' => 'deleted', |
74 | 76 | ); |
75 | 77 | } |
78 | + } |
|
76 | 79 | $setup_info[$app]['currentver'] = $row['app_version']; |
77 | 80 | $setup_info[$app]['enabled'] = $row['app_enabled']; |
78 | 81 | } |
@@ -212,7 +215,9 @@ discard block |
||
212 | 215 | if ($setup_info['depends'][$depkey]['status'] == False) |
213 | 216 | { |
214 | 217 | /* Only set this if it has not already failed to upgrade - Milosch */ |
215 | - if($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C') |
|
218 | + if($setup_info[$key]['status'] != 'F') |
|
219 | + { |
|
220 | + //&& $setup_info[$key]['status'] != 'C') |
|
216 | 221 | { |
217 | 222 | /* Added check for status U - uninstalled apps carry this flag (upgrade from nothing == install). |
218 | 223 | * This should fix apps showing post-install dep failure when they are not yet installed. |
@@ -220,6 +225,7 @@ discard block |
||
220 | 225 | if($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U') |
221 | 226 | { |
222 | 227 | $setup_info[$key]['status'] = 'D'; |
228 | + } |
|
223 | 229 | } |
224 | 230 | else |
225 | 231 | { |
@@ -292,7 +298,10 @@ discard block |
||
292 | 298 | */ |
293 | 299 | function check_db($setup_info=null) |
294 | 300 | { |
295 | - if (!$setup_info) $setup_info = $GLOBALS['setup_info']; |
|
301 | + if (!$setup_info) |
|
302 | + { |
|
303 | + $setup_info = $GLOBALS['setup_info']; |
|
304 | + } |
|
296 | 305 | |
297 | 306 | try { // catch DB errors |
298 | 307 | if (!$GLOBALS['egw_setup']->db->Link_ID) |
@@ -482,11 +491,14 @@ discard block |
||
482 | 491 | { |
483 | 492 | echo '<br>check_app_tables(): Checking: ' . $appname . ',table: ' . $val; |
484 | 493 | } |
485 | - if(!in_array($val,$tables) && !in_array(strtolower($val),$tables)) // names in tables might be lowercase |
|
494 | + if(!in_array($val,$tables) && !in_array(strtolower($val),$tables)) |
|
495 | + { |
|
496 | + // names in tables might be lowercase |
|
486 | 497 | { |
487 | 498 | if($GLOBALS['DEBUG']) |
488 | 499 | { |
489 | 500 | echo '<br>check_app_tables(): ' . $val . ' missing!'; |
501 | + } |
|
490 | 502 | } |
491 | 503 | if(!$any) |
492 | 504 | { |
@@ -543,9 +555,12 @@ discard block |
||
543 | 555 | $msg = lang('does not exist'); |
544 | 556 | return false; |
545 | 557 | } |
546 | - if (!@is_writeable($dir) && $_SERVER['HTTP_HOST']) // only do the check if we run by the webserver |
|
558 | + if (!@is_writeable($dir) && $_SERVER['HTTP_HOST']) |
|
559 | + { |
|
560 | + // only do the check if we run by the webserver |
|
547 | 561 | { |
548 | 562 | $msg = lang('is not writeable by the webserver'); |
563 | + } |
|
549 | 564 | return false; |
550 | 565 | } |
551 | 566 | if ($check_in_docroot) |
@@ -464,7 +464,7 @@ |
||
464 | 464 | { |
465 | 465 | /* Make a copy, else we send some callers into an infinite loop */ |
466 | 466 | $copy = $setup_info; |
467 | - $tables = Array(); |
|
467 | + $tables = array(); |
|
468 | 468 | try { |
469 | 469 | $table_names = $GLOBALS['egw_setup']->db->table_names(); |
470 | 470 | foreach($table_names as $key => $val) |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | { |
28 | 28 | $setup_info = array(); |
29 | 29 | $d = dir(EGW_SERVER_ROOT); |
30 | - while($entry=$d->read()) |
|
30 | + while ($entry = $d->read()) |
|
31 | 31 | { |
32 | - if($entry != ".." && $entry != 'setup' && is_dir(EGW_SERVER_ROOT . '/' . $entry)) |
|
32 | + if ($entry != ".." && $entry != 'setup' && is_dir(EGW_SERVER_ROOT.'/'.$entry)) |
|
33 | 33 | { |
34 | - $f = EGW_SERVER_ROOT . '/' . $entry . '/setup/setup.inc.php'; |
|
35 | - if (@file_exists ($f)) |
|
34 | + $f = EGW_SERVER_ROOT.'/'.$entry.'/setup/setup.inc.php'; |
|
35 | + if (@file_exists($f)) |
|
36 | 36 | { |
37 | 37 | include($f); |
38 | 38 | $setup_info[$entry]['filename'] = $f; |
@@ -52,17 +52,17 @@ discard block |
||
52 | 52 | * @param array $setup_info |
53 | 53 | * @return array $setup_info |
54 | 54 | */ |
55 | - function get_db_versions($setup_info=null) |
|
55 | + function get_db_versions($setup_info = null) |
|
56 | 56 | { |
57 | 57 | try { // catch DB errors |
58 | 58 | $GLOBALS['egw_setup']->set_table_names(); |
59 | 59 | |
60 | - if($GLOBALS['egw_setup']->table_exist(array($GLOBALS['egw_setup']->applications_table),true)) |
|
60 | + if ($GLOBALS['egw_setup']->table_exist(array($GLOBALS['egw_setup']->applications_table), true)) |
|
61 | 61 | { |
62 | 62 | /* one of these tables exists. checking for post/pre beta version */ |
63 | - if($GLOBALS['egw_setup']->applications_table != 'applications') |
|
63 | + if ($GLOBALS['egw_setup']->applications_table != 'applications') |
|
64 | 64 | { |
65 | - foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'*',false,__LINE__,__FILE__) as $row) |
|
65 | + foreach ($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table, '*', false, __LINE__, __FILE__) as $row) |
|
66 | 66 | { |
67 | 67 | $app = $row['app_name']; |
68 | 68 | if (!isset($setup_info[$app])) // app source no longer there |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | // new api, dont care about old pre egroupware stuff |
84 | 84 | } |
85 | - elseif(!@$setup_info['phpgwapi']['currentver']) |
|
85 | + elseif (!@$setup_info['phpgwapi']['currentver']) |
|
86 | 86 | { |
87 | 87 | $setup_info['phpgwapi']['currentver'] = $setup_info['admin']['currentver']; |
88 | 88 | $setup_info['phpgwapi']['version'] = $setup_info['admin']['currentver']; |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | } |
102 | 102 | else |
103 | 103 | { |
104 | - foreach($GLOBALS['egw_setup']->db->query('select * from applications') as $row) |
|
104 | + foreach ($GLOBALS['egw_setup']->db->query('select * from applications') as $row) |
|
105 | 105 | { |
106 | - if($row['app_name'] == 'admin') |
|
106 | + if ($row['app_name'] == 'admin') |
|
107 | 107 | { |
108 | 108 | $setup_info['phpgwapi']['currentver'] = $row['app_version']; |
109 | 109 | } |
@@ -136,25 +136,25 @@ discard block |
||
136 | 136 | * V Version mismatch at end of upgrade (Not used, proposed only) |
137 | 137 | * M Missing files at start of upgrade (Not used, proposed only) |
138 | 138 | */ |
139 | - function compare_versions($setup_info,$try_downgrade=false) |
|
139 | + function compare_versions($setup_info, $try_downgrade = false) |
|
140 | 140 | { |
141 | - foreach($setup_info as $key => $value) |
|
141 | + foreach ($setup_info as $key => $value) |
|
142 | 142 | { |
143 | 143 | //echo '<br>'.$value['name'].'STATUS: '.$value['status']; |
144 | 144 | /* Only set this if it has not already failed to upgrade - Milosch */ |
145 | - if(!( (@$value['status'] == 'F') || (@$value['status'] == 'C') )) |
|
145 | + if (!((@$value['status'] == 'F') || (@$value['status'] == 'C'))) |
|
146 | 146 | { |
147 | 147 | //if ($setup_info[$key]['currentver'] > $setup_info[$key]['version']) |
148 | - if(!$try_downgrade && $GLOBALS['egw_setup']->amorethanb($value['currentver'],@$value['version']) || |
|
148 | + if (!$try_downgrade && $GLOBALS['egw_setup']->amorethanb($value['currentver'], @$value['version']) || |
|
149 | 149 | $value['version'] == 'deleted') |
150 | 150 | { |
151 | 151 | $setup_info[$key]['status'] = 'V'; |
152 | 152 | } |
153 | - elseif(@$value['currentver'] == @$value['version']) |
|
153 | + elseif (@$value['currentver'] == @$value['version']) |
|
154 | 154 | { |
155 | 155 | $setup_info[$key]['status'] = 'C'; |
156 | 156 | } |
157 | - elseif($GLOBALS['egw_setup']->alessthanb(@$value['currentver'],@$value['version'])) |
|
157 | + elseif ($GLOBALS['egw_setup']->alessthanb(@$value['currentver'], @$value['version'])) |
|
158 | 158 | { |
159 | 159 | $setup_info[$key]['status'] = 'U'; |
160 | 160 | } |
@@ -171,35 +171,35 @@ discard block |
||
171 | 171 | function check_depends($setup_info) |
172 | 172 | { |
173 | 173 | /* Run the list of apps */ |
174 | - foreach($setup_info as $key => $value) |
|
174 | + foreach ($setup_info as $key => $value) |
|
175 | 175 | { |
176 | 176 | /* Does this app have any depends */ |
177 | - if(isset($value['depends'])) |
|
177 | + if (isset($value['depends'])) |
|
178 | 178 | { |
179 | 179 | /* If so find out which apps it depends on */ |
180 | - foreach($value['depends'] as $depkey => $depvalue) |
|
180 | + foreach ($value['depends'] as $depkey => $depvalue) |
|
181 | 181 | { |
182 | 182 | /* I set this to False until we find a compatible version of this app */ |
183 | 183 | $setup_info['depends'][$depkey]['status'] = False; |
184 | 184 | /* Now we loop thru the versions looking for a compatible version */ |
185 | 185 | |
186 | - foreach($depvalue['versions'] as $depsvalue) |
|
186 | + foreach ($depvalue['versions'] as $depsvalue) |
|
187 | 187 | { |
188 | 188 | $currentver = $setup_info[$depvalue['appname']]['currentver']; |
189 | - if ($depvalue['appname'] == 'phpgwapi' && substr($currentver,0,6) == '0.9.99') |
|
189 | + if ($depvalue['appname'] == 'phpgwapi' && substr($currentver, 0, 6) == '0.9.99') |
|
190 | 190 | { |
191 | 191 | $currentver = '0.9.14.508'; |
192 | 192 | } |
193 | 193 | $major = $GLOBALS['egw_setup']->get_major($currentver); |
194 | - if ($major >= $depsvalue || $major == $depsvalue && substr($major,0,strlen($depsvalue)+1) == $depsvalue.'.') |
|
194 | + if ($major >= $depsvalue || $major == $depsvalue && substr($major, 0, strlen($depsvalue) + 1) == $depsvalue.'.') |
|
195 | 195 | { |
196 | 196 | $setup_info['depends'][$depkey]['status'] = True; |
197 | 197 | } |
198 | 198 | else // check if majors are equal and minors greater or equal |
199 | 199 | { |
200 | 200 | $major_depsvalue = $GLOBALS['egw_setup']->get_major($depsvalue); |
201 | - $tmp = explode('.',$depsvalue); $minor_depsvalue = array_pop($tmp); |
|
202 | - $tmp2 = explode('.',$currentver); $minor = array_pop($tmp2); |
|
201 | + $tmp = explode('.', $depsvalue); $minor_depsvalue = array_pop($tmp); |
|
202 | + $tmp2 = explode('.', $currentver); $minor = array_pop($tmp2); |
|
203 | 203 | if ($major == $major_depsvalue && $minor <= $minor_depsvalue) |
204 | 204 | { |
205 | 205 | $setup_info['depends'][$depkey]['status'] = True; |
@@ -212,17 +212,17 @@ discard block |
||
212 | 212 | Finally, we loop through the dependencies again to look for apps that still have a failure status |
213 | 213 | If we find one, we set the apps overall status as a dependency failure. |
214 | 214 | */ |
215 | - foreach($value['depends'] as $depkey => $depvalue) |
|
215 | + foreach ($value['depends'] as $depkey => $depvalue) |
|
216 | 216 | { |
217 | 217 | if ($setup_info['depends'][$depkey]['status'] == False) |
218 | 218 | { |
219 | 219 | /* Only set this if it has not already failed to upgrade - Milosch */ |
220 | - if($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C') |
|
220 | + if ($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C') |
|
221 | 221 | { |
222 | 222 | /* Added check for status U - uninstalled apps carry this flag (upgrade from nothing == install). |
223 | 223 | * This should fix apps showing post-install dep failure when they are not yet installed. |
224 | 224 | */ |
225 | - if($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U') |
|
225 | + if ($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U') |
|
226 | 226 | { |
227 | 227 | $setup_info[$key]['status'] = 'D'; |
228 | 228 | } |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | */ |
245 | 245 | function upgrade_exclude($setup_info) |
246 | 246 | { |
247 | - foreach($setup_info as $key => $value) |
|
247 | + foreach ($setup_info as $key => $value) |
|
248 | 248 | { |
249 | - if(isset($value['no_mass_update'])) |
|
249 | + if (isset($value['no_mass_update'])) |
|
250 | 250 | { |
251 | 251 | unset($setup_info[$key]); |
252 | 252 | } |
@@ -261,24 +261,24 @@ discard block |
||
261 | 261 | */ |
262 | 262 | function check_header() |
263 | 263 | { |
264 | - if(!file_exists(EGW_SERVER_ROOT.'/header.inc.php') || filesize(EGW_SERVER_ROOT.'/header.inc.php') < 200) |
|
264 | + if (!file_exists(EGW_SERVER_ROOT.'/header.inc.php') || filesize(EGW_SERVER_ROOT.'/header.inc.php') < 200) |
|
265 | 265 | { |
266 | 266 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One'; |
267 | 267 | return '1'; |
268 | 268 | } |
269 | 269 | else |
270 | 270 | { |
271 | - if(!@isset($GLOBALS['egw_info']['server']['header_admin_password'])) |
|
271 | + if (!@isset($GLOBALS['egw_info']['server']['header_admin_password'])) |
|
272 | 272 | { |
273 | 273 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (No header admin password set)'; |
274 | 274 | return '2'; |
275 | 275 | } |
276 | - elseif(!@isset($GLOBALS['egw_domain'])) |
|
276 | + elseif (!@isset($GLOBALS['egw_domain'])) |
|
277 | 277 | { |
278 | 278 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Add domains to your header.inc.php)'; |
279 | 279 | return '3'; |
280 | 280 | } |
281 | - elseif(@$GLOBALS['egw_info']['server']['versions']['header'] != @$GLOBALS['egw_info']['server']['versions']['current_header']) |
|
281 | + elseif (@$GLOBALS['egw_info']['server']['versions']['header'] != @$GLOBALS['egw_info']['server']['versions']['current_header']) |
|
282 | 282 | { |
283 | 283 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Upgrade your header.inc.php)'; |
284 | 284 | return '4'; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | * @param array $setup_info =null default use $GLOBALS['setup_info'] |
296 | 296 | * @return int 1=no database, 3=empty, 4=need upgrade, 10=complete |
297 | 297 | */ |
298 | - function check_db($setup_info=null) |
|
298 | + function check_db($setup_info = null) |
|
299 | 299 | { |
300 | 300 | if (!$setup_info) $setup_info = $GLOBALS['setup_info']; |
301 | 301 | |
@@ -303,14 +303,14 @@ discard block |
||
303 | 303 | if (!$GLOBALS['egw_setup']->db->Link_ID) |
304 | 304 | { |
305 | 305 | $old = error_reporting(); |
306 | - error_reporting($old & ~E_WARNING); // no warnings |
|
306 | + error_reporting($old&~E_WARNING); // no warnings |
|
307 | 307 | $GLOBALS['egw_setup']->db->connect(); |
308 | 308 | error_reporting($old); |
309 | 309 | |
310 | 310 | $GLOBALS['egw_setup']->set_table_names(); |
311 | 311 | } |
312 | 312 | } |
313 | - catch(Api\Db\Exception $e) { |
|
313 | + catch (Api\Db\Exception $e) { |
|
314 | 314 | // ignore error |
315 | 315 | } |
316 | 316 | |
@@ -319,14 +319,14 @@ discard block |
||
319 | 319 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Create Database)'; |
320 | 320 | return 1; |
321 | 321 | } |
322 | - if(!isset($setup_info['api']['currentver'])) |
|
322 | + if (!isset($setup_info['api']['currentver'])) |
|
323 | 323 | { |
324 | 324 | $setup_info = $this->get_db_versions($setup_info); |
325 | 325 | } |
326 | 326 | // first check new api installed and up to date |
327 | 327 | if (isset($setup_info['api']['currentver'])) |
328 | 328 | { |
329 | - if($setup_info['api']['currentver'] == $setup_info['api']['version']) |
|
329 | + if ($setup_info['api']['currentver'] == $setup_info['api']['version']) |
|
330 | 330 | { |
331 | 331 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Tables Complete)'; |
332 | 332 | return 10; |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | // then check old phpgwapi |
341 | 341 | elseif (isset($setup_info['phpgwapi']['currentver'])) |
342 | 342 | { |
343 | - if($setup_info['phpgwapi']['currentver'] == $setup_info['phpgwapi']['version']) |
|
343 | + if ($setup_info['phpgwapi']['currentver'] == $setup_info['phpgwapi']['version']) |
|
344 | 344 | { |
345 | 345 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Tables Complete)'; |
346 | 346 | return 10; |
@@ -375,14 +375,14 @@ discard block |
||
375 | 375 | */ |
376 | 376 | function check_config() |
377 | 377 | { |
378 | - if(@$GLOBALS['egw_info']['setup']['stage']['db'] != 10) |
|
378 | + if (@$GLOBALS['egw_info']['setup']['stage']['db'] != 10) |
|
379 | 379 | { |
380 | 380 | return ''; |
381 | 381 | } |
382 | 382 | |
383 | 383 | try { // catch db errors |
384 | - foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table, |
|
385 | - 'config_name,config_value',array('config_app' => 'phpgwapi'),__LINE__,__FILE__) as $row) |
|
384 | + foreach ($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table, |
|
385 | + 'config_name,config_value', array('config_app' => 'phpgwapi'), __LINE__, __FILE__) as $row) |
|
386 | 386 | { |
387 | 387 | $config[$row['config_name']] = $row['config_value']; |
388 | 388 | } |
@@ -392,21 +392,21 @@ discard block |
||
392 | 392 | // ignore db errors |
393 | 393 | } |
394 | 394 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 2 (Needs Configuration)'; |
395 | - if(!count($config)) |
|
395 | + if (!count($config)) |
|
396 | 396 | { |
397 | 397 | return 1; |
398 | 398 | } |
399 | - $config_errors =& $GLOBALS['egw_info']['setup']['config_errors']; |
|
399 | + $config_errors = & $GLOBALS['egw_info']['setup']['config_errors']; |
|
400 | 400 | $GLOBALS['egw_info']['setup']['config_errors'] = array(); |
401 | 401 | $error_msg = null; |
402 | - if (!$this->check_dir($config['temp_dir'],$error_msg)) |
|
402 | + if (!$this->check_dir($config['temp_dir'], $error_msg)) |
|
403 | 403 | { |
404 | - $config_errors[] = lang("Your temporary directory '%1' %2",$config['temp_dir'],$error_msg); |
|
404 | + $config_errors[] = lang("Your temporary directory '%1' %2", $config['temp_dir'], $error_msg); |
|
405 | 405 | } |
406 | 406 | |
407 | - if (!$this->check_dir($config['files_dir'],$error_msg,true)) |
|
407 | + if (!$this->check_dir($config['files_dir'], $error_msg, true)) |
|
408 | 408 | { |
409 | - $config_errors[] = lang("Your files directory '%1' %2",$config['files_dir'],$error_msg); |
|
409 | + $config_errors[] = lang("Your files directory '%1' %2", $config['files_dir'], $error_msg); |
|
410 | 410 | } |
411 | 411 | // set and create the default backup_dir |
412 | 412 | if (@is_writeable($config['files_dir']) && empty($config['backup_dir'])) |
@@ -414,35 +414,35 @@ discard block |
||
414 | 414 | $config['backup_dir'] = $config['files_dir'].'/db_backup'; |
415 | 415 | if (!is_dir($config['backup_dir']) && mkdir($config['backup_dir'])) |
416 | 416 | { |
417 | - $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array( |
|
417 | + $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array( |
|
418 | 418 | 'config_value' => $config['backup_dir'], |
419 | - ),array( |
|
419 | + ), array( |
|
420 | 420 | 'config_app' => 'phpgwapi', |
421 | 421 | 'config_name' => 'backup_dir', |
422 | - ),__LINE__,__FILE__); |
|
422 | + ), __LINE__, __FILE__); |
|
423 | 423 | } |
424 | 424 | } |
425 | 425 | if (isset($config['backup_mincount'])) |
426 | 426 | { |
427 | - $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array( |
|
427 | + $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array( |
|
428 | 428 | 'config_value' => $config['backup_mincount'], |
429 | - ),array( |
|
429 | + ), array( |
|
430 | 430 | 'config_app' => 'phpgwapi', |
431 | 431 | 'config_name' => 'backup_mincount', |
432 | - ),__LINE__,__FILE__); |
|
432 | + ), __LINE__, __FILE__); |
|
433 | 433 | } |
434 | 434 | if (isset($config['backup_files'])) |
435 | 435 | { |
436 | - $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array( |
|
436 | + $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array( |
|
437 | 437 | 'config_value' => (int)$config['backup_files'], |
438 | - ),array( |
|
438 | + ), array( |
|
439 | 439 | 'config_app' => 'phpgwapi', |
440 | 440 | 'config_name' => 'backup_files', |
441 | - ),__LINE__,__FILE__); |
|
441 | + ), __LINE__, __FILE__); |
|
442 | 442 | } |
443 | - if (!$this->check_dir($config['backup_dir'],$error_msg,true)) |
|
443 | + if (!$this->check_dir($config['backup_dir'], $error_msg, true)) |
|
444 | 444 | { |
445 | - $config_errors[] = lang("Your backup directory '%1' %2",$config['backup_dir'],$error_msg); |
|
445 | + $config_errors[] = lang("Your backup directory '%1' %2", $config['backup_dir'], $error_msg); |
|
446 | 446 | } |
447 | 447 | if ($config_errors) |
448 | 448 | { |
@@ -458,19 +458,19 @@ discard block |
||
458 | 458 | * @param $appname |
459 | 459 | * @param $any optional, set to True to see if any of the apps tables are installed |
460 | 460 | */ |
461 | - function check_app_tables($appname,$any=False) |
|
461 | + function check_app_tables($appname, $any = False) |
|
462 | 462 | { |
463 | 463 | $none = 0; |
464 | 464 | $setup_info = $GLOBALS['setup_info']; |
465 | 465 | |
466 | - if(@$setup_info[$appname]['tables']) |
|
466 | + if (@$setup_info[$appname]['tables']) |
|
467 | 467 | { |
468 | 468 | /* Make a copy, else we send some callers into an infinite loop */ |
469 | 469 | $copy = $setup_info; |
470 | 470 | $tables = Array(); |
471 | 471 | try { |
472 | 472 | $table_names = $GLOBALS['egw_setup']->db->table_names(); |
473 | - foreach($table_names as $key => $val) |
|
473 | + foreach ($table_names as $key => $val) |
|
474 | 474 | { |
475 | 475 | $tables[] = $val['table_name']; |
476 | 476 | } |
@@ -479,19 +479,19 @@ discard block |
||
479 | 479 | unset($e); |
480 | 480 | // ignore db error |
481 | 481 | } |
482 | - foreach($copy[$appname]['tables'] as $key => $val) |
|
482 | + foreach ($copy[$appname]['tables'] as $key => $val) |
|
483 | 483 | { |
484 | - if($GLOBALS['DEBUG']) |
|
484 | + if ($GLOBALS['DEBUG']) |
|
485 | 485 | { |
486 | - echo '<br>check_app_tables(): Checking: ' . $appname . ',table: ' . $val; |
|
486 | + echo '<br>check_app_tables(): Checking: '.$appname.',table: '.$val; |
|
487 | 487 | } |
488 | - if(!in_array($val,$tables) && !in_array(strtolower($val),$tables)) // names in tables might be lowercase |
|
488 | + if (!in_array($val, $tables) && !in_array(strtolower($val), $tables)) // names in tables might be lowercase |
|
489 | 489 | { |
490 | - if($GLOBALS['DEBUG']) |
|
490 | + if ($GLOBALS['DEBUG']) |
|
491 | 491 | { |
492 | - echo '<br>check_app_tables(): ' . $val . ' missing!'; |
|
492 | + echo '<br>check_app_tables(): '.$val.' missing!'; |
|
493 | 493 | } |
494 | - if(!$any) |
|
494 | + if (!$any) |
|
495 | 495 | { |
496 | 496 | return False; |
497 | 497 | } |
@@ -502,9 +502,9 @@ discard block |
||
502 | 502 | } |
503 | 503 | else |
504 | 504 | { |
505 | - if($any) |
|
505 | + if ($any) |
|
506 | 506 | { |
507 | - if($GLOBALS['DEBUG']) |
|
507 | + if ($GLOBALS['DEBUG']) |
|
508 | 508 | { |
509 | 509 | echo '<br>check_app_tables(): Some tables installed'; |
510 | 510 | } |
@@ -513,9 +513,9 @@ discard block |
||
513 | 513 | } |
514 | 514 | } |
515 | 515 | } |
516 | - if($none && $any) |
|
516 | + if ($none && $any) |
|
517 | 517 | { |
518 | - if($GLOBALS['DEBUG']) |
|
518 | + if ($GLOBALS['DEBUG']) |
|
519 | 519 | { |
520 | 520 | echo '<br>check_app_tables(): No tables installed'; |
521 | 521 | } |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | } |
524 | 524 | else |
525 | 525 | { |
526 | - if($GLOBALS['DEBUG']) |
|
526 | + if ($GLOBALS['DEBUG']) |
|
527 | 527 | { |
528 | 528 | echo '<br>check_app_tables(): All tables installed'; |
529 | 529 | } |
@@ -539,9 +539,9 @@ discard block |
||
539 | 539 | * @param boolean $check_in_docroot =false run an optional in docroot check |
540 | 540 | * @return boolean |
541 | 541 | */ |
542 | - static function check_dir($dir,&$msg,$check_in_docroot=false) |
|
542 | + static function check_dir($dir, &$msg, $check_in_docroot = false) |
|
543 | 543 | { |
544 | - if (!@is_dir($dir) && !@mkdir($dir,0700,true)) |
|
544 | + if (!@is_dir($dir) && !@mkdir($dir, 0700, true)) |
|
545 | 545 | { |
546 | 546 | $msg = lang('does not exist'); |
547 | 547 | return false; |
@@ -553,16 +553,16 @@ discard block |
||
553 | 553 | } |
554 | 554 | if ($check_in_docroot) |
555 | 555 | { |
556 | - $docroots = array(realpath(EGW_SERVER_ROOT),realpath($_SERVER['DOCUMENT_ROOT'])); |
|
556 | + $docroots = array(realpath(EGW_SERVER_ROOT), realpath($_SERVER['DOCUMENT_ROOT'])); |
|
557 | 557 | $dir = realpath($dir); |
558 | 558 | |
559 | 559 | foreach ($docroots as $docroot) |
560 | 560 | { |
561 | 561 | $len = strlen($docroot); |
562 | 562 | |
563 | - if ($docroot == substr($dir,0,$len) && $len>0) |
|
563 | + if ($docroot == substr($dir, 0, $len) && $len > 0) |
|
564 | 564 | { |
565 | - $rest = substr($dir,$len); |
|
565 | + $rest = substr($dir, $len); |
|
566 | 566 | |
567 | 567 | if (!strlen($rest) || $rest[0] == DIRECTORY_SEPARATOR) |
568 | 568 | { |
@@ -53,10 +53,7 @@ |
||
53 | 53 | * the mother of all multipass upgrade parental loop functions |
54 | 54 | * |
55 | 55 | * @param array $setup_info array of application info from setup.inc.php files |
56 | - * @param string $type='new' defaults to new(install), could also be 'upgrade' |
|
57 | - * @param boolean $DEBUG=false print debugging info |
|
58 | - * @param boolean $force_en=false install english language files, not used anymore |
|
59 | - * @param string $system_charset=null charset to use |
|
56 | + * @param boolean $force_en install english language files, not used anymore |
|
60 | 57 | * @param array $preset_config=array() |
61 | 58 | */ |
62 | 59 | function pass(array $setup_info,$method='new',$DEBUG=False,$force_en=False,$preset_config=array()) |
@@ -108,7 +108,9 @@ discard block |
||
108 | 108 | while($pass_string != $passing_string) |
109 | 109 | { |
110 | 110 | $passing = array(); |
111 | - if($DEBUG) { echo '<br>process->pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; } |
|
111 | + if($DEBUG) |
|
112 | + { |
|
113 | +echo '<br>process->pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; } |
|
112 | 114 | |
113 | 115 | // Check current versions and dependencies |
114 | 116 | $setup_info = $GLOBALS['egw_setup']->detection->check_depends( |
@@ -143,7 +145,10 @@ discard block |
||
143 | 145 | } |
144 | 146 | /* Create tables and insert new records for each app in this list */ |
145 | 147 | $passing_c = $this->current($pass,$DEBUG); |
146 | - if (isset($pass['api'])) $this->save_minimal_config($preset_config); |
|
148 | + if (isset($pass['api'])) |
|
149 | + { |
|
150 | + $this->save_minimal_config($preset_config); |
|
151 | + } |
|
147 | 152 | $passing = $this->default_records($passing_c,$DEBUG); |
148 | 153 | break; |
149 | 154 | case 'upgrade': |
@@ -162,29 +167,40 @@ discard block |
||
162 | 167 | if($value['status'] == 'C') |
163 | 168 | { |
164 | 169 | $passed[$value['name']] = $passing[$value['name']]; |
165 | - if($DEBUG) { echo '<br>process->pass(): '.$passed[$value['name']]['name'] . ' install completed'."\n"; } |
|
170 | + if($DEBUG) |
|
171 | + { |
|
172 | +echo '<br>process->pass(): '.$passed[$value['name']]['name'] . ' install completed'."\n"; } |
|
166 | 173 | } |
167 | 174 | elseif($value['status'] == 'F') |
168 | 175 | { |
169 | 176 | $setup_info[$value['name']] = $passing[$value['name']]; |
170 | - if($DEBUG) { echo '<br>process->pass(): '.$setup_info[$value['name']]['name'] . ' install failed'."\n"; } |
|
177 | + if($DEBUG) |
|
178 | + { |
|
179 | +echo '<br>process->pass(): '.$setup_info[$value['name']]['name'] . ' install failed'."\n"; } |
|
171 | 180 | } |
172 | 181 | elseif($value['status'] == 'D') |
173 | 182 | { |
174 | 183 | $pass[$value['name']] = $setup_info[$value['name']]; |
175 | - if($DEBUG) { echo '<br>process->pass(): '.$pass[$value['name']]['name'] . ' fails dependency check on this pass'."\n"; } |
|
184 | + if($DEBUG) |
|
185 | + { |
|
186 | +echo '<br>process->pass(): '.$pass[$value['name']]['name'] . ' fails dependency check on this pass'."\n"; } |
|
176 | 187 | } |
177 | 188 | else |
178 | 189 | { |
179 | 190 | $tmp = $passing[$value['name']]['name']; |
180 | - if($DEBUG) { echo '<br>process->pass(): '.$tmp . ' skipped on this pass'."\n"; } |
|
191 | + if($DEBUG) |
|
192 | + { |
|
193 | +echo '<br>process->pass(): '.$tmp . ' skipped on this pass'."\n"; } |
|
181 | 194 | } |
182 | 195 | } |
183 | 196 | |
184 | 197 | $i++; |
185 | - if($i == 20) /* Then oops it broke */ |
|
198 | + if($i == 20) |
|
199 | + { |
|
200 | + /* Then oops it broke */ |
|
186 | 201 | { |
187 | 202 | echo '<br>Setup failure: excess looping in process->pass():'."\n"; |
203 | + } |
|
188 | 204 | echo '<br>Pass:<br>'."\n"; |
189 | 205 | _debug_array($pass); |
190 | 206 | echo '<br>Passed:<br>'."\n"; |
@@ -376,7 +392,9 @@ discard block |
||
376 | 392 | //echo $table; |
377 | 393 | if(in_array($table,$tables)) |
378 | 394 | { |
379 | - if($DEBUG){ echo '<br>process->droptables(): Dropping :'. $app_name . ' table: ' . $table; } |
|
395 | + if($DEBUG) |
|
396 | + { |
|
397 | +echo '<br>process->droptables(): Dropping :'. $app_name . ' table: ' . $table; } |
|
380 | 398 | $GLOBALS['egw_setup']->oProc->DropTable($table); |
381 | 399 | // Update the array values for return below |
382 | 400 | $setup_info[$app_name]['status'] = 'U'; |
@@ -408,13 +426,17 @@ discard block |
||
408 | 426 | $enabled = False; |
409 | 427 | $apptitle = $appdata['title']; |
410 | 428 | |
411 | - if($DEBUG) { echo '<br>process->current(): Incoming status: ' . $appname . ',status: '. $appdata['status']; } |
|
429 | + if($DEBUG) |
|
430 | + { |
|
431 | +echo '<br>process->current(): Incoming status: ' . $appname . ',status: '. $appdata['status']; } |
|
412 | 432 | |
413 | 433 | $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
414 | 434 | |
415 | 435 | if($appdata['tables'] && file_exists($appdir.'tables_current.inc.php')) |
416 | 436 | { |
417 | - if($DEBUG) { echo '<br>process->current(): Including: ' . $appdir.'tables_current.inc.php'; } |
|
437 | + if($DEBUG) |
|
438 | + { |
|
439 | +echo '<br>process->current(): Including: ' . $appdir.'tables_current.inc.php'; } |
|
418 | 440 | $phpgw_baseline = null; |
419 | 441 | include ($appdir.'tables_current.inc.php'); |
420 | 442 | $ret = $this->post_process($phpgw_baseline,$DEBUG); |
@@ -435,13 +457,17 @@ discard block |
||
435 | 457 | else |
436 | 458 | { |
437 | 459 | /* script processing failed */ |
438 | - if($DEBUG) { echo '<br>process->current(): Failed for ' . $appname . ',status: '. $appdata['status']; } |
|
460 | + if($DEBUG) |
|
461 | + { |
|
462 | +echo '<br>process->current(): Failed for ' . $appname . ',status: '. $appdata['status']; } |
|
439 | 463 | $appdata['status'] = 'F'; |
440 | 464 | } |
441 | 465 | } |
442 | 466 | else |
443 | 467 | { |
444 | - if($DEBUG) { echo '<br>process->current(): No current tables for ' . $apptitle . "\n"; } |
|
468 | + if($DEBUG) |
|
469 | + { |
|
470 | +echo '<br>process->current(): No current tables for ' . $apptitle . "\n"; } |
|
445 | 471 | /* |
446 | 472 | Add the app, but disable it if it has tables defined. |
447 | 473 | A manual sql script install is needed, but we do add the hooks |
@@ -462,7 +488,9 @@ discard block |
||
462 | 488 | } |
463 | 489 | $appdata['status'] = 'C'; |
464 | 490 | } |
465 | - if($DEBUG) { echo '<br>process->current(): Outgoing status: ' . $appname . ',status: '. $appdata['status']; } |
|
491 | + if($DEBUG) |
|
492 | + { |
|
493 | +echo '<br>process->current(): Outgoing status: ' . $appname . ',status: '. $appdata['status']; } |
|
466 | 494 | } |
467 | 495 | |
468 | 496 | // update hooks |
@@ -638,9 +666,12 @@ discard block |
||
638 | 666 | { |
639 | 667 | echo '<div style="text-align: left; border: thin dashed black; margin-top: 5px;">'."process->upgrade(): Incoming : appname: $appname, version: $appdata[currentver], status: $appdata[status]\n"; |
640 | 668 | } |
641 | - if($appdata['status'] == 'U' || $appdata['status'] == 'D' ||$appdata['status'] == 'V' || $appdata['status'] == '') // TODO this is not getting set for api upgrade, sometimes ??? |
|
669 | + if($appdata['status'] == 'U' || $appdata['status'] == 'D' ||$appdata['status'] == 'V' || $appdata['status'] == '') |
|
670 | + { |
|
671 | + // TODO this is not getting set for api upgrade, sometimes ??? |
|
642 | 672 | { |
643 | 673 | $currentver = $appdata['currentver']; |
674 | + } |
|
644 | 675 | $targetver = $appdata['version']; // The version we need to match when done |
645 | 676 | $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
646 | 677 | |
@@ -674,11 +705,14 @@ discard block |
||
674 | 705 | } |
675 | 706 | } |
676 | 707 | } |
677 | - if ($currentver == $targetver) // upgrades succesful |
|
708 | + if ($currentver == $targetver) |
|
709 | + { |
|
710 | + // upgrades succesful |
|
678 | 711 | { |
679 | 712 | if($DEBUG) |
680 | 713 | { |
681 | 714 | echo "<br>process->upgrade(): Upgrade of $appname to $targetver is completed.\n"; |
715 | + } |
|
682 | 716 | } |
683 | 717 | $appstatus = 'C'; |
684 | 718 | } |
@@ -700,9 +734,12 @@ discard block |
||
700 | 734 | } |
701 | 735 | $appstatus = 'C'; |
702 | 736 | } |
703 | - if ($appstatus == 'C') // update successful completed |
|
737 | + if ($appstatus == 'C') |
|
738 | + { |
|
739 | + // update successful completed |
|
704 | 740 | { |
705 | 741 | $appdata['currentver'] = $targetver; |
742 | + } |
|
706 | 743 | |
707 | 744 | if($GLOBALS['egw_setup']->app_registered($appname)) |
708 | 745 | { |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | * @param string $system_charset=null charset to use |
60 | 60 | * @param array $preset_config=array() |
61 | 61 | */ |
62 | - function pass(array $setup_info,$method='new',$DEBUG=False,$force_en=False,$preset_config=array()) |
|
62 | + function pass(array $setup_info, $method = 'new', $DEBUG = False, $force_en = False, $preset_config = array()) |
|
63 | 63 | { |
64 | - unset($force_en); // no longer used |
|
64 | + unset($force_en); // no longer used |
|
65 | 65 | |
66 | - if(!$method) |
|
66 | + if (!$method) |
|
67 | 67 | { |
68 | 68 | return False; |
69 | 69 | } |
@@ -94,23 +94,23 @@ discard block |
||
94 | 94 | // ignore emailadmin, it's only there for updates |
95 | 95 | unset($setup_info['emailadmin']); |
96 | 96 | } |
97 | - $pass['admin'] = $setup_info['admin']; |
|
97 | + $pass['admin'] = $setup_info['admin']; |
|
98 | 98 | $pass['preferences'] = $setup_info['preferences']; |
99 | 99 | if (file_exists(EGW_SERVER_ROOT.'/etemplate')) |
100 | 100 | { |
101 | - $pass['etemplate'] = $setup_info['etemplate']; // helps to minimize passes, as many apps depend on it |
|
101 | + $pass['etemplate'] = $setup_info['etemplate']; // helps to minimize passes, as many apps depend on it |
|
102 | 102 | } |
103 | 103 | $this->api_version_target = $setup_info['api']['version']; |
104 | 104 | |
105 | 105 | $i = 1; |
106 | 106 | $passed = array(); |
107 | 107 | $passing = array(); |
108 | - $pass_string = implode (':', $pass); |
|
109 | - $passing_string = implode (':', $passing); |
|
110 | - while($pass_string != $passing_string) |
|
108 | + $pass_string = implode(':', $pass); |
|
109 | + $passing_string = implode(':', $passing); |
|
110 | + while ($pass_string != $passing_string) |
|
111 | 111 | { |
112 | 112 | $passing = array(); |
113 | - if($DEBUG) { echo '<br>process->pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; } |
|
113 | + if ($DEBUG) { echo '<br>process->pass(): #'.$i.' for '.$method.' processing'."\n"; } |
|
114 | 114 | |
115 | 115 | // Check current versions and dependencies |
116 | 116 | $setup_info = $GLOBALS['egw_setup']->detection->check_depends( |
@@ -118,25 +118,25 @@ discard block |
||
118 | 118 | $GLOBALS['egw_setup']->detection->get_db_versions($setup_info), true)); |
119 | 119 | |
120 | 120 | // stuff the rest of the apps, but only those with available upgrades |
121 | - foreach($setup_info as $key => $value) |
|
121 | + foreach ($setup_info as $key => $value) |
|
122 | 122 | { |
123 | 123 | // check if app is either installed or supports the used database |
124 | 124 | if (!isset($value['currentver']) && isset($value['only_db']) && ( |
125 | - is_array($value['only_db']) && !in_array($GLOBALS['egw_setup']->db->Type,$value['only_db']) || |
|
125 | + is_array($value['only_db']) && !in_array($GLOBALS['egw_setup']->db->Type, $value['only_db']) || |
|
126 | 126 | !is_array($value['only_db']) && $GLOBALS['egw_setup']->db->Type != $value['only_db'])) |
127 | 127 | { |
128 | - continue; // app does not support this db-type, dont try installing it |
|
128 | + continue; // app does not support this db-type, dont try installing it |
|
129 | 129 | } |
130 | - if(/*$value['name'] != 'phpgwapi' &&*/ $value['status'] == 'U') |
|
130 | + if (/*$value['name'] != 'phpgwapi' &&*/ $value['status'] == 'U') |
|
131 | 131 | { |
132 | - if($passed[$value['name']]['status'] != 'F' && $passed[$value['name']]['status'] != 'C') |
|
132 | + if ($passed[$value['name']]['status'] != 'F' && $passed[$value['name']]['status'] != 'C') |
|
133 | 133 | { |
134 | 134 | $pass[$value['name']] = $setup_info[$value['name']]; |
135 | 135 | } |
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | - switch($method) |
|
139 | + switch ($method) |
|
140 | 140 | { |
141 | 141 | case 'new': |
142 | 142 | if (empty($GLOBALS['egw_info']['server']['temp_dir'])) |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | $GLOBALS['egw_info']['server']['temp_dir'] = sys_get_temp_dir(); |
145 | 145 | } |
146 | 146 | /* Create tables and insert new records for each app in this list */ |
147 | - $passing_c = $this->current($pass,$DEBUG); |
|
147 | + $passing_c = $this->current($pass, $DEBUG); |
|
148 | 148 | if (isset($pass['api'])) $this->save_minimal_config($preset_config); |
149 | - $passing = $this->default_records($passing_c,$DEBUG); |
|
149 | + $passing = $this->default_records($passing_c, $DEBUG); |
|
150 | 150 | break; |
151 | 151 | case 'upgrade': |
152 | 152 | /* Run upgrade scripts on each app in the list */ |
153 | - $passing = $this->upgrade($pass,$DEBUG); |
|
153 | + $passing = $this->upgrade($pass, $DEBUG); |
|
154 | 154 | //_debug_array($pass);exit; |
155 | 155 | break; |
156 | 156 | default: |
@@ -159,32 +159,32 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | $pass = array(); |
162 | - foreach($passing as $key => $value) |
|
162 | + foreach ($passing as $key => $value) |
|
163 | 163 | { |
164 | - if($value['status'] == 'C') |
|
164 | + if ($value['status'] == 'C') |
|
165 | 165 | { |
166 | 166 | $passed[$value['name']] = $passing[$value['name']]; |
167 | - if($DEBUG) { echo '<br>process->pass(): '.$passed[$value['name']]['name'] . ' install completed'."\n"; } |
|
167 | + if ($DEBUG) { echo '<br>process->pass(): '.$passed[$value['name']]['name'].' install completed'."\n"; } |
|
168 | 168 | } |
169 | - elseif($value['status'] == 'F') |
|
169 | + elseif ($value['status'] == 'F') |
|
170 | 170 | { |
171 | 171 | $setup_info[$value['name']] = $passing[$value['name']]; |
172 | - if($DEBUG) { echo '<br>process->pass(): '.$setup_info[$value['name']]['name'] . ' install failed'."\n"; } |
|
172 | + if ($DEBUG) { echo '<br>process->pass(): '.$setup_info[$value['name']]['name'].' install failed'."\n"; } |
|
173 | 173 | } |
174 | - elseif($value['status'] == 'D') |
|
174 | + elseif ($value['status'] == 'D') |
|
175 | 175 | { |
176 | 176 | $pass[$value['name']] = $setup_info[$value['name']]; |
177 | - if($DEBUG) { echo '<br>process->pass(): '.$pass[$value['name']]['name'] . ' fails dependency check on this pass'."\n"; } |
|
177 | + if ($DEBUG) { echo '<br>process->pass(): '.$pass[$value['name']]['name'].' fails dependency check on this pass'."\n"; } |
|
178 | 178 | } |
179 | 179 | else |
180 | 180 | { |
181 | 181 | $tmp = $passing[$value['name']]['name']; |
182 | - if($DEBUG) { echo '<br>process->pass(): '.$tmp . ' skipped on this pass'."\n"; } |
|
182 | + if ($DEBUG) { echo '<br>process->pass(): '.$tmp.' skipped on this pass'."\n"; } |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | 186 | $i++; |
187 | - if($i == 20) /* Then oops it broke */ |
|
187 | + if ($i == 20) /* Then oops it broke */ |
|
188 | 188 | { |
189 | 189 | echo '<br>Setup failure: excess looping in process->pass():'."\n"; |
190 | 190 | echo '<br>Pass:<br>'."\n"; |
@@ -193,19 +193,19 @@ discard block |
||
193 | 193 | _debug_array($passed); |
194 | 194 | exit; |
195 | 195 | } |
196 | - $pass_string = implode (':', $pass); |
|
197 | - $passing_string = implode (':', $passing); |
|
196 | + $pass_string = implode(':', $pass); |
|
197 | + $passing_string = implode(':', $passing); |
|
198 | 198 | } |
199 | 199 | try { |
200 | 200 | // flush instance cache: also registers hooks and flushes image cache |
201 | 201 | Api\Cache::flush(Api\Cache::INSTANCE); |
202 | 202 | } |
203 | - catch(Exception $e) { |
|
203 | + catch (Exception $e) { |
|
204 | 204 | unset($e); |
205 | 205 | // ignore exception, as during a new install, there's no cache configured and therefore no need to unset |
206 | 206 | } |
207 | 207 | /* now return the list */ |
208 | - return array_merge($setup_info,$passed); |
|
208 | + return array_merge($setup_info, $passed); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -213,20 +213,20 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @param array $preset_config =array() |
215 | 215 | */ |
216 | - function save_minimal_config(array $preset_config=array()) |
|
216 | + function save_minimal_config(array $preset_config = array()) |
|
217 | 217 | { |
218 | - $is_windows = strtoupper(substr(PHP_OS,0,3)) == 'WIN'; |
|
218 | + $is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; |
|
219 | 219 | |
220 | 220 | $current_config['site_title'] = 'EGroupware'; |
221 | - $current_config['hostname'] = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'; |
|
221 | + $current_config['hostname'] = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'; |
|
222 | 222 | |
223 | 223 | // guessing the EGw url |
224 | 224 | if (isset($_SERVER['HTTP_HOST'])) |
225 | 225 | { |
226 | - $parts = explode('/',$_SERVER['PHP_SELF']); |
|
227 | - array_pop($parts); // remove config.php |
|
228 | - array_pop($parts); // remove setup |
|
229 | - $current_config['webserver_url'] = implode('/',$parts); |
|
226 | + $parts = explode('/', $_SERVER['PHP_SELF']); |
|
227 | + array_pop($parts); // remove config.php |
|
228 | + array_pop($parts); // remove setup |
|
229 | + $current_config['webserver_url'] = implode('/', $parts); |
|
230 | 230 | $egroupwareDirName = end($parts); |
231 | 231 | } |
232 | 232 | else // eg. cli install --> use defaults |
@@ -234,9 +234,9 @@ discard block |
||
234 | 234 | $current_config['webserver_url'] = '/egroupware'; |
235 | 235 | $egroupwareDirName = 'egroupware'; |
236 | 236 | } |
237 | - if(!$is_windows) |
|
237 | + if (!$is_windows) |
|
238 | 238 | { |
239 | - if(@is_dir('/tmp')) |
|
239 | + if (@is_dir('/tmp')) |
|
240 | 240 | { |
241 | 241 | $current_config['temp_dir'] = '/tmp'; |
242 | 242 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | else |
252 | 252 | { |
253 | - if(@is_dir('c:\\windows\\temp')) |
|
253 | + if (@is_dir('c:\\windows\\temp')) |
|
254 | 254 | { |
255 | 255 | $current_config['temp_dir'] = 'c:\\windows\\temp'; |
256 | 256 | } |
@@ -271,15 +271,15 @@ discard block |
||
271 | 271 | $current_config['enabled_spellcheck'] = 'YesBrowserBased'; |
272 | 272 | |
273 | 273 | // always enable history logging for calendar, addressbook and infolog |
274 | - $current_config['history'] = 'history'; // addressbook: only admin |
|
275 | - $current_config['calendar_delete_history'] = 'history'; // only admins |
|
274 | + $current_config['history'] = 'history'; // addressbook: only admin |
|
275 | + $current_config['calendar_delete_history'] = 'history'; // only admins |
|
276 | 276 | // infolog does NOT use config_app='phpgwapi', but 'infolog' |
277 | - $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array( |
|
278 | - 'config_value' => 'history_admin_delete', // only admins |
|
279 | - ),array( |
|
277 | + $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array( |
|
278 | + 'config_value' => 'history_admin_delete', // only admins |
|
279 | + ), array( |
|
280 | 280 | 'config_app' => 'infolog', |
281 | 281 | 'config_name' => 'history', |
282 | - ),__FILE__,__LINE__); |
|
282 | + ), __FILE__, __LINE__); |
|
283 | 283 | |
284 | 284 | |
285 | 285 | // RalfBecker: php.net recommend this for security reasons, it should be our default too |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $tz = new DateTimeZone(date_default_timezone_get()); |
296 | 296 | $current_config['server_timezone'] = $tz->getName(); |
297 | 297 | } |
298 | - catch(Exception $e) |
|
298 | + catch (Exception $e) |
|
299 | 299 | { |
300 | 300 | unset($e); |
301 | 301 | // do nothing if new DateTimeZone fails (eg. 'System/Localtime' returned), specially do NOT store it! |
@@ -303,42 +303,42 @@ discard block |
||
303 | 303 | } |
304 | 304 | $current_config['install_id'] = md5($_SERVER['HTTP_HOST'].microtime(true).$GLOBALS['egw_setup']->ConfigDomain); |
305 | 305 | |
306 | - $current_config['postpone_statistics_submit'] = time() + 2 * 30 * 86400; // ask user in 2 month from now, when he has something to report |
|
306 | + $current_config['postpone_statistics_submit'] = time() + 2 * 30 * 86400; // ask user in 2 month from now, when he has something to report |
|
307 | 307 | |
308 | 308 | // use securest password hash by default |
309 | - require_once EGW_SERVER_ROOT.'/setup/inc/hook_config.inc.php'; // for sql_passwdhashes, to get securest available password hash |
|
309 | + require_once EGW_SERVER_ROOT.'/setup/inc/hook_config.inc.php'; // for sql_passwdhashes, to get securest available password hash |
|
310 | 310 | $securest = null; |
311 | 311 | sql_passwdhashes(array(), true, $securest); |
312 | 312 | $current_config['sql_encryption_type'] = $current_config['ldap_encryption_type'] = $securest; |
313 | 313 | |
314 | 314 | if ($preset_config) |
315 | 315 | { |
316 | - $current_config = array_merge($current_config,$preset_config); |
|
316 | + $current_config = array_merge($current_config, $preset_config); |
|
317 | 317 | } |
318 | 318 | |
319 | - foreach($current_config as $name => $value) |
|
319 | + foreach ($current_config as $name => $value) |
|
320 | 320 | { |
321 | 321 | $app = 'phpgwapi'; |
322 | 322 | if ($name == 'postpone_statistics_submit') |
323 | 323 | { |
324 | 324 | $app = 'admin'; |
325 | 325 | } |
326 | - elseif(strpos($name, '/') !== false) |
|
326 | + elseif (strpos($name, '/') !== false) |
|
327 | 327 | { |
328 | 328 | list($app, $name) = explode('/', $name); |
329 | 329 | } |
330 | - $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array( |
|
330 | + $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array( |
|
331 | 331 | 'config_value' => $value, |
332 | - ),array( |
|
332 | + ), array( |
|
333 | 333 | 'config_app' => $app, |
334 | 334 | 'config_name' => $name, |
335 | - ),__FILE__,__LINE__); |
|
335 | + ), __FILE__, __LINE__); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | // so the default_records use the current data |
339 | 339 | $GLOBALS['egw_info']['server'] = array_merge((array)$GLOBALS['egw_info']['server'], $current_config); |
340 | - Api\Cache::flush(); // flush whole instance cache |
|
341 | - Api\Config::init_static(); // flush internal cache of Api\Config class |
|
340 | + Api\Cache::flush(); // flush whole instance cache |
|
341 | + Api\Config::init_static(); // flush internal cache of Api\Config class |
|
342 | 342 | $GLOBALS['egw_setup']->setup_account_object($current_config); |
343 | 343 | } |
344 | 344 | |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | * |
348 | 348 | * @param $setup_info array of application info from setup.inc.php files, etc. |
349 | 349 | */ |
350 | - function droptables(array $setup_info,$DEBUG=False) |
|
350 | + function droptables(array $setup_info, $DEBUG = False) |
|
351 | 351 | { |
352 | - if(!@$GLOBALS['egw_setup']->oProc) |
|
352 | + if (!@$GLOBALS['egw_setup']->oProc) |
|
353 | 353 | { |
354 | 354 | $this->init_process(); |
355 | 355 | } |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | $tablenames = $GLOBALS['egw_setup']->db->table_names(); |
358 | 358 | if (!is_array($setup_info) || !is_array($tablenames)) |
359 | 359 | { |
360 | - return $setup_info; // nothing to do |
|
360 | + return $setup_info; // nothing to do |
|
361 | 361 | } |
362 | 362 | $tables = array(); |
363 | - foreach($tablenames as $data) |
|
363 | + foreach ($tablenames as $data) |
|
364 | 364 | { |
365 | 365 | $tables[] = $data['table_name']; |
366 | 366 | } |
@@ -369,16 +369,16 @@ discard block |
||
369 | 369 | { |
370 | 370 | return $setup_info; |
371 | 371 | } |
372 | - foreach($setup_info as $app_name => $data) |
|
372 | + foreach ($setup_info as $app_name => $data) |
|
373 | 373 | { |
374 | - if(is_array($data['tables'])) |
|
374 | + if (is_array($data['tables'])) |
|
375 | 375 | { |
376 | - foreach($data['tables'] as $table) |
|
376 | + foreach ($data['tables'] as $table) |
|
377 | 377 | { |
378 | 378 | //echo $table; |
379 | - if(in_array($table,$tables)) |
|
379 | + if (in_array($table, $tables)) |
|
380 | 380 | { |
381 | - if($DEBUG){ echo '<br>process->droptables(): Dropping :'. $app_name . ' table: ' . $table; } |
|
381 | + if ($DEBUG) { echo '<br>process->droptables(): Dropping :'.$app_name.' table: '.$table; } |
|
382 | 382 | $GLOBALS['egw_setup']->oProc->DropTable($table); |
383 | 383 | // Update the array values for return below |
384 | 384 | $setup_info[$app_name]['status'] = 'U'; |
@@ -398,31 +398,31 @@ discard block |
||
398 | 398 | * @param boolean $DEBUG =false output further diagnostics |
399 | 399 | * @return array $setup_info |
400 | 400 | */ |
401 | - function current(array $setup_info,$DEBUG=False) |
|
401 | + function current(array $setup_info, $DEBUG = False) |
|
402 | 402 | { |
403 | 403 | //echo __METHOD__; _debug_array($setup_info); |
404 | - if(!isset($GLOBALS['egw_setup']->oProc)) |
|
404 | + if (!isset($GLOBALS['egw_setup']->oProc)) |
|
405 | 405 | { |
406 | 406 | $this->init_process(); |
407 | 407 | } |
408 | - foreach($setup_info as $appname => &$appdata) |
|
408 | + foreach ($setup_info as $appname => &$appdata) |
|
409 | 409 | { |
410 | 410 | $enabled = False; |
411 | 411 | $apptitle = $appdata['title']; |
412 | 412 | |
413 | - if($DEBUG) { echo '<br>process->current(): Incoming status: ' . $appname . ',status: '. $appdata['status']; } |
|
413 | + if ($DEBUG) { echo '<br>process->current(): Incoming status: '.$appname.',status: '.$appdata['status']; } |
|
414 | 414 | |
415 | - $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
|
415 | + $appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/'; |
|
416 | 416 | |
417 | - if($appdata['tables'] && file_exists($appdir.'tables_current.inc.php')) |
|
417 | + if ($appdata['tables'] && file_exists($appdir.'tables_current.inc.php')) |
|
418 | 418 | { |
419 | - if($DEBUG) { echo '<br>process->current(): Including: ' . $appdir.'tables_current.inc.php'; } |
|
419 | + if ($DEBUG) { echo '<br>process->current(): Including: '.$appdir.'tables_current.inc.php'; } |
|
420 | 420 | $phpgw_baseline = null; |
421 | 421 | include ($appdir.'tables_current.inc.php'); |
422 | - $ret = $this->post_process($phpgw_baseline,$DEBUG); |
|
423 | - if($ret) |
|
422 | + $ret = $this->post_process($phpgw_baseline, $DEBUG); |
|
423 | + if ($ret) |
|
424 | 424 | { |
425 | - if($GLOBALS['egw_setup']->app_registered($appname)) |
|
425 | + if ($GLOBALS['egw_setup']->app_registered($appname)) |
|
426 | 426 | { |
427 | 427 | $GLOBALS['egw_setup']->update_app($appname); |
428 | 428 | } |
@@ -437,34 +437,34 @@ discard block |
||
437 | 437 | else |
438 | 438 | { |
439 | 439 | /* script processing failed */ |
440 | - if($DEBUG) { echo '<br>process->current(): Failed for ' . $appname . ',status: '. $appdata['status']; } |
|
440 | + if ($DEBUG) { echo '<br>process->current(): Failed for '.$appname.',status: '.$appdata['status']; } |
|
441 | 441 | $appdata['status'] = 'F'; |
442 | 442 | } |
443 | 443 | } |
444 | 444 | else |
445 | 445 | { |
446 | - if($DEBUG) { echo '<br>process->current(): No current tables for ' . $apptitle . "\n"; } |
|
446 | + if ($DEBUG) { echo '<br>process->current(): No current tables for '.$apptitle."\n"; } |
|
447 | 447 | /* |
448 | 448 | Add the app, but disable it if it has tables defined. |
449 | 449 | A manual sql script install is needed, but we do add the hooks |
450 | 450 | */ |
451 | 451 | $enabled = 99; |
452 | - if($appdata['tables'][0] != '') |
|
452 | + if ($appdata['tables'][0] != '') |
|
453 | 453 | { |
454 | 454 | $enabled = False; |
455 | 455 | } |
456 | - if($GLOBALS['egw_setup']->app_registered($appname)) |
|
456 | + if ($GLOBALS['egw_setup']->app_registered($appname)) |
|
457 | 457 | { |
458 | 458 | $GLOBALS['egw_setup']->update_app($appname); |
459 | 459 | } |
460 | 460 | else |
461 | 461 | { |
462 | - $GLOBALS['egw_setup']->register_app($appname,$enabled); |
|
462 | + $GLOBALS['egw_setup']->register_app($appname, $enabled); |
|
463 | 463 | $GLOBALS['egw_setup']->set_default_preferences($appname); |
464 | 464 | } |
465 | 465 | $appdata['status'] = 'C'; |
466 | 466 | } |
467 | - if($DEBUG) { echo '<br>process->current(): Outgoing status: ' . $appname . ',status: '. $appdata['status']; } |
|
467 | + if ($DEBUG) { echo '<br>process->current(): Outgoing status: '.$appname.',status: '.$appdata['status']; } |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | // update hooks |
@@ -481,25 +481,25 @@ discard block |
||
481 | 481 | * @param boolean $DEBUG =false output further diagnostics |
482 | 482 | * @return array $setup_info |
483 | 483 | */ |
484 | - function default_records(array $setup_info,$DEBUG=False) |
|
484 | + function default_records(array $setup_info, $DEBUG = False) |
|
485 | 485 | { |
486 | 486 | //echo __METHOD__; _debug_array($setup_info); |
487 | - if(!@$GLOBALS['egw_setup']->oProc) |
|
487 | + if (!@$GLOBALS['egw_setup']->oProc) |
|
488 | 488 | { |
489 | 489 | $this->init_process(); |
490 | 490 | } |
491 | - foreach($setup_info as $appname => &$appdata) |
|
491 | + foreach ($setup_info as $appname => &$appdata) |
|
492 | 492 | { |
493 | - $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
|
493 | + $appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/'; |
|
494 | 494 | |
495 | - if(file_exists($appdir.'default_records.inc.php')) |
|
495 | + if (file_exists($appdir.'default_records.inc.php')) |
|
496 | 496 | { |
497 | - if($DEBUG) |
|
497 | + if ($DEBUG) |
|
498 | 498 | { |
499 | - echo '<br>process->default_records(): Including default records for ' . $appname . "\n"; |
|
499 | + echo '<br>process->default_records(): Including default records for '.$appname."\n"; |
|
500 | 500 | } |
501 | 501 | $GLOBALS['egw_setup']->oProc->m_odb->transaction_begin(); |
502 | - $oProc = &$GLOBALS['egw_setup']->oProc; // to be compatible with old apps |
|
502 | + $oProc = &$GLOBALS['egw_setup']->oProc; // to be compatible with old apps |
|
503 | 503 | include ($appdir.'default_records.inc.php'); |
504 | 504 | $GLOBALS['egw_setup']->oProc->m_odb->transaction_commit(); |
505 | 505 | } |
@@ -523,21 +523,21 @@ discard block |
||
523 | 523 | * @param boolean $DEBUG =false output further diagnostics |
524 | 524 | * @return array $setup_info |
525 | 525 | */ |
526 | - function test_data(array $setup_info,$DEBUG=False) |
|
526 | + function test_data(array $setup_info, $DEBUG = False) |
|
527 | 527 | { |
528 | - if(!@$GLOBALS['egw_setup']->oProc) |
|
528 | + if (!@$GLOBALS['egw_setup']->oProc) |
|
529 | 529 | { |
530 | 530 | $this->init_process(); |
531 | 531 | } |
532 | - foreach($setup_info as $appname => &$appdata) |
|
532 | + foreach ($setup_info as $appname => &$appdata) |
|
533 | 533 | { |
534 | - $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
|
534 | + $appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/'; |
|
535 | 535 | |
536 | - if(file_exists($appdir.'test_data.inc.php')) |
|
536 | + if (file_exists($appdir.'test_data.inc.php')) |
|
537 | 537 | { |
538 | - if($DEBUG) |
|
538 | + if ($DEBUG) |
|
539 | 539 | { |
540 | - echo '<br>process->test_data(): Including baseline test data for ' . $appname . "\n"; |
|
540 | + echo '<br>process->test_data(): Including baseline test data for '.$appname."\n"; |
|
541 | 541 | } |
542 | 542 | $GLOBALS['egw_setup']->oProc->m_odb->transaction_begin(); |
543 | 543 | include ($appdir.'test_data.inc.php'); |
@@ -557,35 +557,35 @@ discard block |
||
557 | 557 | * @param boolean $DEBUG =false output further diagnostics |
558 | 558 | * @return array $setup_info |
559 | 559 | */ |
560 | - function baseline(array $setup_info,$DEBUG=False) |
|
560 | + function baseline(array $setup_info, $DEBUG = False) |
|
561 | 561 | { |
562 | - if(!@$GLOBALS['egw_setup']->oProc) |
|
562 | + if (!@$GLOBALS['egw_setup']->oProc) |
|
563 | 563 | { |
564 | 564 | $this->init_process(); |
565 | 565 | } |
566 | - foreach($setup_info as $appname => &$appdata) |
|
566 | + foreach ($setup_info as $appname => &$appdata) |
|
567 | 567 | { |
568 | - $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
|
568 | + $appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/'; |
|
569 | 569 | |
570 | - if(file_exists($appdir.'tables_baseline.inc.php')) |
|
570 | + if (file_exists($appdir.'tables_baseline.inc.php')) |
|
571 | 571 | { |
572 | - if($DEBUG) |
|
572 | + if ($DEBUG) |
|
573 | 573 | { |
574 | - echo '<br>process->baseline(): Including baseline tables for ' . $appname . "\n"; |
|
574 | + echo '<br>process->baseline(): Including baseline tables for '.$appname."\n"; |
|
575 | 575 | } |
576 | 576 | $phpgw_baseline = null; |
577 | 577 | include ($appdir.'tables_baseline.inc.php'); |
578 | 578 | $GLOBALS['egw_setup']->oProc->GenerateScripts($phpgw_baseline, $DEBUG); |
579 | - $this->post_process($phpgw_baseline,$DEBUG); |
|
579 | + $this->post_process($phpgw_baseline, $DEBUG); |
|
580 | 580 | |
581 | 581 | /* Update the array values for return below */ |
582 | 582 | /* $setup_info[$key]['status'] = 'R'; */ |
583 | 583 | } |
584 | 584 | else |
585 | 585 | { |
586 | - if($DEBUG) |
|
586 | + if ($DEBUG) |
|
587 | 587 | { |
588 | - echo '<br>process->baseline(): No baseline tables for ' . $appname . "\n"; |
|
588 | + echo '<br>process->baseline(): No baseline tables for '.$appname."\n"; |
|
589 | 589 | } |
590 | 590 | //$setup_info[$key]['status'] = 'C'; |
591 | 591 | } |
@@ -603,19 +603,19 @@ discard block |
||
603 | 603 | * @param boolean $DEBUG =false output further diagnostics |
604 | 604 | * @return array $setup_info |
605 | 605 | */ |
606 | - function upgrade($setup_info,$DEBUG=False) |
|
606 | + function upgrade($setup_info, $DEBUG = False) |
|
607 | 607 | { |
608 | 608 | //echo __METHOD__; _debug_array($setup_info); |
609 | - if(!@$GLOBALS['egw_setup']->oProc) |
|
609 | + if (!@$GLOBALS['egw_setup']->oProc) |
|
610 | 610 | { |
611 | 611 | $this->init_process(); |
612 | 612 | } |
613 | 613 | $GLOBALS['egw_setup']->oProc->m_odb->HaltOnError = 'yes'; |
614 | 614 | |
615 | - foreach($setup_info as $appname => &$appdata) |
|
615 | + foreach ($setup_info as $appname => &$appdata) |
|
616 | 616 | { |
617 | 617 | // check if app is NOT installed |
618 | - if(!$GLOBALS['egw_setup']->app_registered($appname)) |
|
618 | + if (!$GLOBALS['egw_setup']->app_registered($appname)) |
|
619 | 619 | { |
620 | 620 | // check if app wants to be automatically installed on update to version x or allways |
621 | 621 | if (isset($appdata['autoinstall']) && ($appdata['autoinstall'] === true || |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | continue; |
628 | 628 | } |
629 | 629 | /* Don't try to upgrade an app that is not installed */ |
630 | - if($DEBUG) |
|
630 | + if ($DEBUG) |
|
631 | 631 | { |
632 | 632 | echo "<p>process->upgrade(): Application not installed: $appname</p>\n"; |
633 | 633 | } |
@@ -636,41 +636,41 @@ discard block |
||
636 | 636 | } |
637 | 637 | |
638 | 638 | /* if upgrade required, or if we are running again after an upgrade or dependency failure */ |
639 | - if($DEBUG) |
|
639 | + if ($DEBUG) |
|
640 | 640 | { |
641 | 641 | echo '<div style="text-align: left; border: thin dashed black; margin-top: 5px;">'."process->upgrade(): Incoming : appname: $appname, version: $appdata[currentver], status: $appdata[status]\n"; |
642 | 642 | } |
643 | - if($appdata['status'] == 'U' || $appdata['status'] == 'D' ||$appdata['status'] == 'V' || $appdata['status'] == '') // TODO this is not getting set for api upgrade, sometimes ??? |
|
643 | + if ($appdata['status'] == 'U' || $appdata['status'] == 'D' || $appdata['status'] == 'V' || $appdata['status'] == '') // TODO this is not getting set for api upgrade, sometimes ??? |
|
644 | 644 | { |
645 | 645 | $currentver = $appdata['currentver']; |
646 | - $targetver = $appdata['version']; // The version we need to match when done |
|
647 | - $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
|
646 | + $targetver = $appdata['version']; // The version we need to match when done |
|
647 | + $appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/'; |
|
648 | 648 | |
649 | - if(file_exists($appdir . 'tables_update.inc.php')) |
|
649 | + if (file_exists($appdir.'tables_update.inc.php')) |
|
650 | 650 | { |
651 | 651 | if (!@$this->updateincluded[$appname]) |
652 | 652 | { |
653 | - include ($appdir . 'tables_update.inc.php'); |
|
653 | + include ($appdir.'tables_update.inc.php'); |
|
654 | 654 | $this->updateincluded[$appname] = True; |
655 | 655 | } |
656 | 656 | while ($currentver && $currentver != $targetver && |
657 | - function_exists($function = $appname . '_upgrade' . str_replace('.','_',$currentver))) |
|
657 | + function_exists($function = $appname.'_upgrade'.str_replace('.', '_', $currentver))) |
|
658 | 658 | { |
659 | - if($DEBUG) |
|
659 | + if ($DEBUG) |
|
660 | 660 | { |
661 | 661 | echo "<br>process->upgrade(): $appname($currentver --> $targetver): running $function()\n"; |
662 | 662 | } |
663 | 663 | if (!($currentver = $function())) |
664 | 664 | { |
665 | - if($DEBUG) |
|
665 | + if ($DEBUG) |
|
666 | 666 | { |
667 | 667 | echo "<b>failed!!!</b>\n"; |
668 | 668 | } |
669 | - $appstatus = 'F'; |
|
669 | + $appstatus = 'F'; |
|
670 | 670 | } |
671 | 671 | else |
672 | 672 | { |
673 | - if($DEBUG) |
|
673 | + if ($DEBUG) |
|
674 | 674 | { |
675 | 675 | echo "--> $currentver\n"; |
676 | 676 | } |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | } |
679 | 679 | if ($currentver == $targetver) // upgrades succesful |
680 | 680 | { |
681 | - if($DEBUG) |
|
681 | + if ($DEBUG) |
|
682 | 682 | { |
683 | 683 | echo "<br>process->upgrade(): Upgrade of $appname to $targetver is completed.\n"; |
684 | 684 | } |
@@ -686,27 +686,27 @@ discard block |
||
686 | 686 | } |
687 | 687 | elseif ($currentver) |
688 | 688 | { |
689 | - if($DEBUG) |
|
689 | + if ($DEBUG) |
|
690 | 690 | { |
691 | 691 | echo "<br><b>process->upgrade(): No table upgrade available for appname: $appname, version: $currentver</b>\n"; |
692 | 692 | } |
693 | 693 | $appdate['currentver'] = $targetver; |
694 | - $appstatus = 'F'; |
|
694 | + $appstatus = 'F'; |
|
695 | 695 | } |
696 | 696 | } |
697 | 697 | else |
698 | 698 | { |
699 | - if($DEBUG) |
|
699 | + if ($DEBUG) |
|
700 | 700 | { |
701 | 701 | echo "<br>process->upgrade(): No table upgrade required/availible for $appname\n"; |
702 | 702 | } |
703 | - $appstatus = 'C'; |
|
703 | + $appstatus = 'C'; |
|
704 | 704 | } |
705 | 705 | if ($appstatus == 'C') // update successful completed |
706 | 706 | { |
707 | 707 | $appdata['currentver'] = $targetver; |
708 | 708 | |
709 | - if($GLOBALS['egw_setup']->app_registered($appname)) |
|
709 | + if ($GLOBALS['egw_setup']->app_registered($appname)) |
|
710 | 710 | { |
711 | 711 | $GLOBALS['egw_setup']->update_app($appname); |
712 | 712 | } |
@@ -719,14 +719,14 @@ discard block |
||
719 | 719 | } |
720 | 720 | else |
721 | 721 | { |
722 | - if($DEBUG) |
|
722 | + if ($DEBUG) |
|
723 | 723 | { |
724 | 724 | echo "<br>process->upgrade(): No upgrade required for $appname\n"; |
725 | 725 | } |
726 | - $appstatus = 'C'; |
|
726 | + $appstatus = 'C'; |
|
727 | 727 | } |
728 | 728 | /* Done with this app, update status */ |
729 | - if($DEBUG) |
|
729 | + if ($DEBUG) |
|
730 | 730 | { |
731 | 731 | echo "<br>process->upgrade(): Outgoing : appname: $appname, status: $appstatus</div>\n"; |
732 | 732 | } |
@@ -744,13 +744,13 @@ discard block |
||
744 | 744 | * commit above processing to the db |
745 | 745 | * |
746 | 746 | */ |
747 | - function post_process($tables,$DEBUG=False) |
|
747 | + function post_process($tables, $DEBUG = False) |
|
748 | 748 | { |
749 | - if(!$tables) |
|
749 | + if (!$tables) |
|
750 | 750 | { |
751 | 751 | return False; |
752 | 752 | } |
753 | - return $GLOBALS['egw_setup']->oProc->ExecuteScripts($tables,$DEBUG); |
|
753 | + return $GLOBALS['egw_setup']->oProc->ExecuteScripts($tables, $DEBUG); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | /** |
@@ -758,14 +758,14 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @param $tablename table whose array you want to see |
760 | 760 | */ |
761 | - function sql_to_array($tablename='') |
|
761 | + function sql_to_array($tablename = '') |
|
762 | 762 | { |
763 | - if(!$tablename) |
|
763 | + if (!$tablename) |
|
764 | 764 | { |
765 | 765 | return False; |
766 | 766 | } |
767 | 767 | |
768 | - if(!$GLOBALS['egw_setup']->oProc) |
|
768 | + if (!$GLOBALS['egw_setup']->oProc) |
|
769 | 769 | { |
770 | 770 | $this->init_process(); |
771 | 771 | } |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | $sColumns = null; |
774 | 774 | $GLOBALS['egw_setup']->oProc->m_oTranslator->_GetColumns($GLOBALS['egw_setup']->oProc, $tablename, $sColumns); |
775 | 775 | |
776 | - while(list($key,$tbldata) = each($GLOBALS['egw_setup']->oProc->m_oTranslator->sCol)) |
|
776 | + while (list($key, $tbldata) = each($GLOBALS['egw_setup']->oProc->m_oTranslator->sCol)) |
|
777 | 777 | { |
778 | 778 | $arr .= $tbldata; |
779 | 779 | } |
@@ -782,6 +782,6 @@ discard block |
||
782 | 782 | $ix = $GLOBALS['egw_setup']->oProc->m_oTranslator->ix; |
783 | 783 | $uc = $GLOBALS['egw_setup']->oProc->m_oTranslator->uc; |
784 | 784 | |
785 | - return array($arr,$pk,$fk,$ix,$uc); |
|
785 | + return array($arr, $pk, $fk, $ix, $uc); |
|
786 | 786 | } |
787 | 787 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @param statuses List of statuses to process, with sub-statuses in a 'substatus' array |
263 | 263 | * @param labels Array of labels, pass array() and labels will be built in it |
264 | - * @param depth Current depth |
|
264 | + * @param depth integer depth |
|
265 | 265 | * |
266 | 266 | * @return None, labels are built in labels parameter |
267 | 267 | */ |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @param array|int $data =null use $this->data or $this->data['ts_id'] (to fetch the data) |
307 | 307 | * @param int $user =null for which user to check, default current user |
308 | - * @return boolean true if the rights are ok, false if no rights |
|
308 | + * @return null|boolean true if the rights are ok, false if no rights |
|
309 | 309 | */ |
310 | 310 | function check_statusForEditRights($data=null,$user=null) |
311 | 311 | { |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * @param int $required Acl::READ, EGW_ACL_WRITE, Acl::ADD, Acl::DELETE, EGW_ACL_BUDGET, EGW_ACL_EDIT_BUDGET |
341 | 341 | * @param array|int $data =null project or project-id to use, default the project in $this->data |
342 | 342 | * @param int $user =null for which user to check, default current user |
343 | - * @return boolean true if the rights are ok, null if not found, false if no rights |
|
343 | + * @return null|boolean true if the rights are ok, null if not found, false if no rights |
|
344 | 344 | */ |
345 | 345 | function check_acl($required,$data=null,$user=null) |
346 | 346 | { |
@@ -397,11 +397,11 @@ discard block |
||
397 | 397 | * @param array|string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!) |
398 | 398 | * @param boolean|string $only_keys =true True returns only keys, False returns all cols. comma seperated list of keys to return |
399 | 399 | * @param string $order_by ='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY) |
400 | - * @param string|array $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num" |
|
400 | + * @param string $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num" |
|
401 | 401 | * @param string $wildcard ='' appended befor and after each criteria |
402 | 402 | * @param boolean $empty =false False=empty criteria are ignored in query, True=empty have to be empty in row |
403 | 403 | * @param string $op ='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together |
404 | - * @param mixed $start =false if != false, return only maxmatch rows begining with start, or array($start,$num) |
|
404 | + * @param boolean $start =false if != false, return only maxmatch rows begining with start, or array($start,$num) |
|
405 | 405 | * @param array $filter =null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards |
406 | 406 | * @param string $join ='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or |
407 | 407 | * "LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join! |
@@ -658,8 +658,6 @@ discard block |
||
658 | 658 | * delete / move all timesheets of a given user |
659 | 659 | * |
660 | 660 | * @param array $data |
661 | - * @param int $data['account_id'] owner to change |
|
662 | - * @param int $data['new_owner'] new owner or 0 for delete |
|
663 | 661 | */ |
664 | 662 | function deleteaccount($data) |
665 | 663 | { |
@@ -686,7 +684,7 @@ discard block |
||
686 | 684 | * |
687 | 685 | * @param array $keys =null if given array with col => value pairs to characterise single timesheet or null for $this->data |
688 | 686 | * @param int $status =0 |
689 | - * @return int affected rows, should be 1 if ok, 0 if an error |
|
687 | + * @return boolean affected rows, should be 1 if ok, 0 if an error |
|
690 | 688 | */ |
691 | 689 | function set_status($keys=null, $status=0) |
692 | 690 | { |
@@ -816,7 +814,7 @@ discard block |
||
816 | 814 | * @param int $check Acl::READ for read and Acl::EDIT for write or delete access |
817 | 815 | * @param string $rel_path =null currently not used in InfoLog |
818 | 816 | * @param int $user =null for which user to check, default current user |
819 | - * @return boolean true if access is granted or false otherwise |
|
817 | + * @return null|boolean true if access is granted or false otherwise |
|
820 | 818 | */ |
821 | 819 | function file_access($id,$check,$rel_path=null,$user=null) |
822 | 820 | { |
@@ -152,8 +152,8 @@ |
||
152 | 152 | const EXTRA_TABLE = 'egw_timesheet_extra'; |
153 | 153 | |
154 | 154 | /** |
155 | - * Columns to search when user does a text search |
|
156 | - */ |
|
155 | + * Columns to search when user does a text search |
|
156 | + */ |
|
157 | 157 | var $columns_to_search = array('egw_timesheet.ts_id', 'ts_project', 'ts_title', 'ts_description', 'ts_duration', 'ts_quantity', 'ts_unitprice'); |
158 | 158 | |
159 | 159 | /** |
@@ -792,7 +792,7 @@ |
||
792 | 792 | * @param array $options Array of options for the search |
793 | 793 | * @return array with ts_id - title pairs of the matching entries |
794 | 794 | */ |
795 | - function link_query( $pattern, Array &$options = array() ) |
|
795 | + function link_query( $pattern, array &$options = array() ) |
|
796 | 796 | { |
797 | 797 | $limit = false; |
798 | 798 | $need_count = false; |
@@ -167,12 +167,18 @@ discard block |
||
167 | 167 | { |
168 | 168 | parent::__construct(TIMESHEET_APP,'egw_timesheet',self::EXTRA_TABLE,'','ts_extra_name','ts_extra_value','ts_id'); |
169 | 169 | |
170 | - if ($this->customfields) $this->columns_to_search[] = self::EXTRA_TABLE.'.ts_extra_value'; |
|
170 | + if ($this->customfields) |
|
171 | + { |
|
172 | + $this->columns_to_search[] = self::EXTRA_TABLE.'.ts_extra_value'; |
|
173 | + } |
|
171 | 174 | $this->config_data = Api\Config::read(TIMESHEET_APP); |
172 | 175 | $this->quantity_sum = $this->config_data['quantity_sum'] == 'true'; |
173 | 176 | |
174 | 177 | // Load & process statuses |
175 | - if($this->config_data['status_labels']) $this->load_statuses(); |
|
178 | + if($this->config_data['status_labels']) |
|
179 | + { |
|
180 | + $this->load_statuses(); |
|
181 | + } |
|
176 | 182 | |
177 | 183 | $this->today = mktime(0,0,0,date('m',$this->now),date('d',$this->now),date('Y',$this->now)); |
178 | 184 | |
@@ -190,12 +196,16 @@ discard block |
||
190 | 196 | protected function load_statuses() |
191 | 197 | { |
192 | 198 | $this->status_labels =& $this->config_data['status_labels']; |
193 | - if (!is_array($this->status_labels)) $this->status_labels= array($this->status_labels); |
|
199 | + if (!is_array($this->status_labels)) |
|
200 | + { |
|
201 | + $this->status_labels= array($this->status_labels); |
|
202 | + } |
|
194 | 203 | |
195 | 204 | foreach ($this->status_labels as $status_id => $label) |
196 | 205 | { |
197 | 206 | if (!is_array($label)) |
198 | - { //old values, before parent status |
|
207 | + { |
|
208 | +//old values, before parent status |
|
199 | 209 | $name = $label; |
200 | 210 | $label=array(); |
201 | 211 | $label['name'] = $name; |
@@ -243,7 +253,10 @@ discard block |
||
243 | 253 | */ |
244 | 254 | function get_sub_status($status) |
245 | 255 | { |
246 | - if (!isset($this->status_labels_config)) $this->load_statuses(); |
|
256 | + if (!isset($this->status_labels_config)) |
|
257 | + { |
|
258 | + $this->load_statuses(); |
|
259 | + } |
|
247 | 260 | $stati = array($status); |
248 | 261 | foreach($this->status_labels_config as $stat) |
249 | 262 | { |
@@ -286,7 +299,10 @@ discard block |
||
286 | 299 | */ |
287 | 300 | function grant_list($required=Acl::READ, $hide_deactive=null) |
288 | 301 | { |
289 | - if (!isset($hide_deactive)) $hide_deactive = $required == Acl::EDIT; |
|
302 | + if (!isset($hide_deactive)) |
|
303 | + { |
|
304 | + $hide_deactive = $required == Acl::EDIT; |
|
305 | + } |
|
290 | 306 | |
291 | 307 | $result = array(); |
292 | 308 | foreach($this->grants as $uid => $grant) |
@@ -322,9 +338,16 @@ discard block |
||
322 | 338 | $data = $this->read($data,true); |
323 | 339 | $this->data = $save_data; |
324 | 340 | |
325 | - if (!$data) return null; // entry not found |
|
341 | + if (!$data) |
|
342 | + { |
|
343 | + return null; |
|
344 | + } |
|
345 | + // entry not found |
|
346 | + } |
|
347 | + if (!$user) |
|
348 | + { |
|
349 | + $user = $this->user; |
|
326 | 350 | } |
327 | - if (!$user) $user = $this->user; |
|
328 | 351 | if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $data['ts_status']) |
329 | 352 | { |
330 | 353 | if ($this->status_labels_config[$data['ts_status']]['admin']) |
@@ -357,9 +380,16 @@ discard block |
||
357 | 380 | $data = $this->read($data,true); |
358 | 381 | $this->data = $save_data; |
359 | 382 | |
360 | - if (!$data) return null; // entry not found |
|
383 | + if (!$data) |
|
384 | + { |
|
385 | + return null; |
|
386 | + } |
|
387 | + // entry not found |
|
388 | + } |
|
389 | + if (!$user) |
|
390 | + { |
|
391 | + $user = $this->user; |
|
361 | 392 | } |
362 | - if (!$user) $user = $this->user; |
|
363 | 393 | if ($user == $this->user) |
364 | 394 | { |
365 | 395 | $grants = $this->grants; |
@@ -439,7 +469,10 @@ discard block |
||
439 | 469 | } |
440 | 470 | else |
441 | 471 | { |
442 | - if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']); |
|
472 | + if (!is_array($filter['ts_owner'])) |
|
473 | + { |
|
474 | + $filter['ts_owner'] = array($filter['ts_owner']); |
|
475 | + } |
|
443 | 476 | |
444 | 477 | foreach($filter['ts_owner'] as $key => $owner) |
445 | 478 | { |
@@ -494,7 +527,10 @@ discard block |
||
494 | 527 | $this->summary = $this->summary[0]; |
495 | 528 | $this->summary['max_modified'] = Api\DateTime::server2user($this->summary['max_modified']); |
496 | 529 | |
497 | - if ($only_summary) return $this->summary; |
|
530 | + if ($only_summary) |
|
531 | + { |
|
532 | + return $this->summary; |
|
533 | + } |
|
498 | 534 | |
499 | 535 | if ($this->show_sums && strpos($order_by,'ts_start') !== false && // sums only make sense if ordered by ts_start |
500 | 536 | $this->db->capabilities['union'] && ($from_unixtime_ts_start = $this->db->from_unixtime('ts_start'))) |
@@ -570,7 +606,10 @@ discard block |
||
570 | 606 | */ |
571 | 607 | function save($keys=null,$touch_modified=true,$ignore_acl=false) |
572 | 608 | { |
573 | - if ($keys) $this->data_merge($keys); |
|
609 | + if ($keys) |
|
610 | + { |
|
611 | + $this->data_merge($keys); |
|
612 | + } |
|
574 | 613 | |
575 | 614 | if (!$ignore_acl && $this->data['ts_id'] && !$this->check_acl(Acl::EDIT)) |
576 | 615 | { |
@@ -592,10 +631,13 @@ discard block |
||
592 | 631 | $old =& $this->data; |
593 | 632 | $this->data =& $new; |
594 | 633 | $changed = array(); |
595 | - if (isset($old)) foreach($old as $name => $value) |
|
634 | + if (isset($old)) |
|
635 | + { |
|
636 | + foreach($old as $name => $value) |
|
596 | 637 | { |
597 | 638 | if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name; |
598 | 639 | } |
640 | + } |
|
599 | 641 | } |
600 | 642 | if (!$this->data['ts_created']) |
601 | 643 | { |
@@ -716,7 +758,10 @@ discard block |
||
716 | 758 | } |
717 | 759 | |
718 | 760 | $this->data['ts_status'] = $status; |
719 | - if ($this->save($ts_id)!=0) $ret = false; |
|
761 | + if ($this->save($ts_id)!=0) |
|
762 | + { |
|
763 | + $ret = false; |
|
764 | + } |
|
720 | 765 | |
721 | 766 | return $ret; |
722 | 767 | } |
@@ -760,10 +805,13 @@ discard block |
||
760 | 805 | return $entry; |
761 | 806 | } |
762 | 807 | $format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
763 | - if (date('H:i',$entry['ts_start']) != '00:00') // dont show 00:00 time, as it means date only |
|
808 | + if (date('H:i',$entry['ts_start']) != '00:00') |
|
809 | + { |
|
810 | + // dont show 00:00 time, as it means date only |
|
764 | 811 | { |
765 | 812 | $format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'); |
766 | 813 | } |
814 | + } |
|
767 | 815 | return date($format,$entry['ts_start']).': '.$entry['ts_title']; |
768 | 816 | } |
769 | 817 | |
@@ -809,14 +857,18 @@ discard block |
||
809 | 857 | { |
810 | 858 | $limit = false; |
811 | 859 | $need_count = false; |
812 | - if($options['start'] || $options['num_rows']) { |
|
860 | + if($options['start'] || $options['num_rows']) |
|
861 | + { |
|
813 | 862 | $limit = array($options['start'], $options['num_rows']); |
814 | 863 | $need_count = true; |
815 | 864 | } |
816 | 865 | $result = array(); |
817 | 866 | foreach((array) $this->search($pattern,false,'','','%',false,'OR', $limit, null, '', $need_count) as $ts ) |
818 | 867 | { |
819 | - if ($ts) $result[$ts['ts_id']] = $this->link_title($ts); |
|
868 | + if ($ts) |
|
869 | + { |
|
870 | + $result[$ts['ts_id']] = $this->link_title($ts); |
|
871 | + } |
|
820 | 872 | } |
821 | 873 | $options['total'] = $need_count ? $this->total : count($result); |
822 | 874 | return $result; |
@@ -935,7 +987,10 @@ discard block |
||
935 | 987 | //error_log(__METHOD__."() setting pm_id=$pm_id --> ".array2string($update)); |
936 | 988 | } |
937 | 989 | } |
938 | - if ($backup) $this->data = $backup; |
|
990 | + if ($backup) |
|
991 | + { |
|
992 | + $this->data = $backup; |
|
993 | + } |
|
939 | 994 | } |
940 | 995 | |
941 | 996 | |
@@ -960,7 +1015,10 @@ discard block |
||
960 | 1015 | $first_pm_id = null; |
961 | 1016 | foreach(Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id) |
962 | 1017 | { |
963 | - if (!isset($first_pm_id)) $first_pm_id = $pm_id; |
|
1018 | + if (!isset($first_pm_id)) |
|
1019 | + { |
|
1020 | + $first_pm_id = $pm_id; |
|
1021 | + } |
|
964 | 1022 | if ($data['ts_project'] == Link::title('projectmanager', $pm_id)) |
965 | 1023 | { |
966 | 1024 | $data['pm_id'] = $pm_id; |
@@ -969,7 +1027,10 @@ discard block |
||
969 | 1027 | break; |
970 | 1028 | } |
971 | 1029 | } |
972 | - if (!isset($data['pm_id']) && isset($first_pm_id)) $data['pm_id'] = $first_pm_id; |
|
1030 | + if (!isset($data['pm_id']) && isset($first_pm_id)) |
|
1031 | + { |
|
1032 | + $data['pm_id'] = $first_pm_id; |
|
1033 | + } |
|
973 | 1034 | } |
974 | 1035 | elseif ($data['ts_id'] && $data['pm_id'] && Link::title('projectmanager', $data['pm_id']) == $data['ts_project']) |
975 | 1036 | { |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | if (!defined('TIMESHEET_APP')) |
18 | 18 | { |
19 | - define('TIMESHEET_APP','timesheet'); |
|
19 | + define('TIMESHEET_APP', 'timesheet'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @var boolean |
45 | 45 | */ |
46 | - var $quantity_sum=false; |
|
46 | + var $quantity_sum = false; |
|
47 | 47 | /** |
48 | 48 | * current user |
49 | 49 | * |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @var array |
57 | 57 | */ |
58 | 58 | var $timestamps = array( |
59 | - 'ts_start','ts_created', 'ts_modified' |
|
59 | + 'ts_start', 'ts_created', 'ts_modified' |
|
60 | 60 | ); |
61 | 61 | /** |
62 | 62 | * Start of today in user-time |
@@ -70,17 +70,17 @@ discard block |
||
70 | 70 | * @var array |
71 | 71 | */ |
72 | 72 | var $date_filters = array( // Start: year,month,day,week, End: year,month,day,week |
73 | - 'Today' => array(0,0,0,0, 0,0,1,0), |
|
74 | - 'Yesterday' => array(0,0,-1,0, 0,0,0,0), |
|
75 | - 'This week' => array(0,0,0,0, 0,0,0,1), |
|
76 | - 'Last week' => array(0,0,0,-1, 0,0,0,0), |
|
77 | - 'This month' => array(0,0,0,0, 0,1,0,0), |
|
78 | - 'Last month' => array(0,-1,0,0, 0,0,0,0), |
|
79 | - '2 month ago' => array(0,-2,0,0, 0,-1,0,0), |
|
80 | - 'This year' => array(0,0,0,0, 1,0,0,0), |
|
81 | - 'Last year' => array(-1,0,0,0, 0,0,0,0), |
|
82 | - '2 years ago' => array(-2,0,0,0, -1,0,0,0), |
|
83 | - '3 years ago' => array(-3,0,0,0, -2,0,0,0), |
|
73 | + 'Today' => array(0, 0, 0, 0, 0, 0, 1, 0), |
|
74 | + 'Yesterday' => array(0, 0, -1, 0, 0, 0, 0, 0), |
|
75 | + 'This week' => array(0, 0, 0, 0, 0, 0, 0, 1), |
|
76 | + 'Last week' => array(0, 0, 0, -1, 0, 0, 0, 0), |
|
77 | + 'This month' => array(0, 0, 0, 0, 0, 1, 0, 0), |
|
78 | + 'Last month' => array(0, -1, 0, 0, 0, 0, 0, 0), |
|
79 | + '2 month ago' => array(0, -2, 0, 0, 0, -1, 0, 0), |
|
80 | + 'This year' => array(0, 0, 0, 0, 1, 0, 0, 0), |
|
81 | + 'Last year' => array(-1, 0, 0, 0, 0, 0, 0, 0), |
|
82 | + '2 years ago' => array(-2, 0, 0, 0, -1, 0, 0, 0), |
|
83 | + '3 years ago' => array(-3, 0, 0, 0, -2, 0, 0, 0), |
|
84 | 84 | ); |
85 | 85 | /** |
86 | 86 | * Grants: $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @var array |
107 | 107 | */ |
108 | - var $customfields=array(); |
|
108 | + var $customfields = array(); |
|
109 | 109 | /** |
110 | 110 | * Array with status label |
111 | 111 | * |
@@ -165,21 +165,21 @@ discard block |
||
165 | 165 | |
166 | 166 | function __construct() |
167 | 167 | { |
168 | - parent::__construct(TIMESHEET_APP,'egw_timesheet',self::EXTRA_TABLE,'','ts_extra_name','ts_extra_value','ts_id'); |
|
168 | + parent::__construct(TIMESHEET_APP, 'egw_timesheet', self::EXTRA_TABLE, '', 'ts_extra_name', 'ts_extra_value', 'ts_id'); |
|
169 | 169 | |
170 | 170 | if ($this->customfields) $this->columns_to_search[] = self::EXTRA_TABLE.'.ts_extra_value'; |
171 | 171 | $this->config_data = Api\Config::read(TIMESHEET_APP); |
172 | 172 | $this->quantity_sum = $this->config_data['quantity_sum'] == 'true'; |
173 | 173 | |
174 | 174 | // Load & process statuses |
175 | - if($this->config_data['status_labels']) $this->load_statuses(); |
|
175 | + if ($this->config_data['status_labels']) $this->load_statuses(); |
|
176 | 176 | |
177 | - $this->today = mktime(0,0,0,date('m',$this->now),date('d',$this->now),date('Y',$this->now)); |
|
177 | + $this->today = mktime(0, 0, 0, date('m', $this->now), date('d', $this->now), date('Y', $this->now)); |
|
178 | 178 | |
179 | 179 | // save us in $GLOBALS['timesheet_bo'] for ExecMethod used in hooks |
180 | 180 | if (!is_object($GLOBALS['timesheet_bo'])) |
181 | 181 | { |
182 | - $GLOBALS['timesheet_bo'] =& $this; |
|
182 | + $GLOBALS['timesheet_bo'] = & $this; |
|
183 | 183 | } |
184 | 184 | $this->grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP); |
185 | 185 | } |
@@ -189,15 +189,15 @@ discard block |
||
189 | 189 | */ |
190 | 190 | protected function load_statuses() |
191 | 191 | { |
192 | - $this->status_labels =& $this->config_data['status_labels']; |
|
193 | - if (!is_array($this->status_labels)) $this->status_labels= array($this->status_labels); |
|
192 | + $this->status_labels = & $this->config_data['status_labels']; |
|
193 | + if (!is_array($this->status_labels)) $this->status_labels = array($this->status_labels); |
|
194 | 194 | |
195 | 195 | foreach ($this->status_labels as $status_id => $label) |
196 | 196 | { |
197 | 197 | if (!is_array($label)) |
198 | 198 | { //old values, before parent status |
199 | 199 | $name = $label; |
200 | - $label=array(); |
|
200 | + $label = array(); |
|
201 | 201 | $label['name'] = $name; |
202 | 202 | $label['parent'] = ''; |
203 | 203 | } |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | $map = array( |
210 | 210 | '' => array('substatus' => array()) |
211 | 211 | ); |
212 | - foreach($this->status_labels_config as $id => &$status) |
|
212 | + foreach ($this->status_labels_config as $id => &$status) |
|
213 | 213 | { |
214 | 214 | $status['substatus'] = array(); |
215 | 215 | $map[$id] = &$status; |
216 | 216 | } |
217 | - foreach($this->status_labels_config as &$status) |
|
217 | + foreach ($this->status_labels_config as &$status) |
|
218 | 218 | { |
219 | 219 | $map[$status['parent']]['substatus'][] = &$status; |
220 | 220 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | // Sort Api\Config based on tree |
228 | 228 | $sorted = array(); |
229 | - foreach($this->status_labels as $status_id => $label) |
|
229 | + foreach ($this->status_labels as $status_id => $label) |
|
230 | 230 | { |
231 | 231 | $sorted[$status_id] = $this->status_labels_config[$status_id]; |
232 | 232 | //$sorted[$status_id]['name'] = $label; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | { |
246 | 246 | if (!isset($this->status_labels_config)) $this->load_statuses(); |
247 | 247 | $stati = array($status); |
248 | - foreach($this->status_labels_config as $stat) |
|
248 | + foreach ($this->status_labels_config as $stat) |
|
249 | 249 | { |
250 | 250 | if ($stat['parent'] && in_array($stat['parent'], $stati)) |
251 | 251 | { |
@@ -265,14 +265,14 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return None, labels are built in labels parameter |
267 | 267 | */ |
268 | - protected function make_status_labels($statuses, &$labels, $depth=0) |
|
268 | + protected function make_status_labels($statuses, &$labels, $depth = 0) |
|
269 | 269 | { |
270 | - foreach($statuses as $status) |
|
270 | + foreach ($statuses as $status) |
|
271 | 271 | { |
272 | - $labels[$status['id']] = str_pad('',$depth*12, " ",STR_PAD_LEFT).trim(str_replace(' ','',$status['name'])); |
|
273 | - if(count($status['substatus']) > 0) |
|
272 | + $labels[$status['id']] = str_pad('', $depth * 12, " ", STR_PAD_LEFT).trim(str_replace(' ', '', $status['name'])); |
|
273 | + if (count($status['substatus']) > 0) |
|
274 | 274 | { |
275 | - $this->make_status_labels($status['substatus'], $labels, $depth+1); |
|
275 | + $this->make_status_labels($status['substatus'], $labels, $depth + 1); |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | } |
@@ -286,14 +286,14 @@ discard block |
||
286 | 286 | */ |
287 | 287 | protected function get_status_labels($admin = null) |
288 | 288 | { |
289 | - if(is_null($admin)) |
|
289 | + if (is_null($admin)) |
|
290 | 290 | { |
291 | 291 | $admin = isset($GLOBALS['egw_info']['user']['apps']['admin']); |
292 | 292 | } |
293 | 293 | $labels = array(); |
294 | - foreach($this->status_labels as $status_id => $label) |
|
294 | + foreach ($this->status_labels as $status_id => $label) |
|
295 | 295 | { |
296 | - if($admin || !$admin && !$this->status_labels_config[$status_id]['admin']) |
|
296 | + if ($admin || !$admin && !$this->status_labels_config[$status_id]['admin']) |
|
297 | 297 | { |
298 | 298 | $labels[$status_id] = $label; |
299 | 299 | } |
@@ -308,14 +308,14 @@ discard block |
||
308 | 308 | * @param boolean $hide_deactive =null default only Acl::EDIT hides deactivates users |
309 | 309 | * @return array with uid => Username pairs |
310 | 310 | */ |
311 | - function grant_list($required=Acl::READ, $hide_deactive=null) |
|
311 | + function grant_list($required = Acl::READ, $hide_deactive = null) |
|
312 | 312 | { |
313 | 313 | if (!isset($hide_deactive)) $hide_deactive = $required == Acl::EDIT; |
314 | 314 | |
315 | 315 | $result = array(); |
316 | - foreach($this->grants as $uid => $grant) |
|
316 | + foreach ($this->grants as $uid => $grant) |
|
317 | 317 | { |
318 | - if ($grant & $required && (!$hide_deactive || Api\Accounts::getInstance()->is_active($uid))) |
|
318 | + if ($grant&$required && (!$hide_deactive || Api\Accounts::getInstance()->is_active($uid))) |
|
319 | 319 | { |
320 | 320 | $result[$uid] = Api\Accounts::username($uid); |
321 | 321 | } |
@@ -334,19 +334,19 @@ discard block |
||
334 | 334 | * @param int $user =null for which user to check, default current user |
335 | 335 | * @return boolean true if the rights are ok, false if no rights |
336 | 336 | */ |
337 | - function check_statusForEditRights($data=null,$user=null) |
|
337 | + function check_statusForEditRights($data = null, $user = null) |
|
338 | 338 | { |
339 | 339 | if (is_null($data) || (int)$data == $this->data['ts_id']) |
340 | 340 | { |
341 | - $data =& $this->data; |
|
341 | + $data = & $this->data; |
|
342 | 342 | } |
343 | 343 | if (!is_array($data)) |
344 | 344 | { |
345 | 345 | $save_data = $this->data; |
346 | - $data = $this->read($data,true); |
|
346 | + $data = $this->read($data, true); |
|
347 | 347 | $this->data = $save_data; |
348 | 348 | |
349 | - if (!$data) return null; // entry not found |
|
349 | + if (!$data) return null; // entry not found |
|
350 | 350 | } |
351 | 351 | if (!$user) $user = $this->user; |
352 | 352 | if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $data['ts_status']) |
@@ -369,19 +369,19 @@ discard block |
||
369 | 369 | * @param int $user =null for which user to check, default current user |
370 | 370 | * @return boolean true if the rights are ok, null if not found, false if no rights |
371 | 371 | */ |
372 | - function check_acl($required,$data=null,$user=null) |
|
372 | + function check_acl($required, $data = null, $user = null) |
|
373 | 373 | { |
374 | 374 | if (is_null($data) || (int)$data == $this->data['ts_id']) |
375 | 375 | { |
376 | - $data =& $this->data; |
|
376 | + $data = & $this->data; |
|
377 | 377 | } |
378 | 378 | if (!is_array($data)) |
379 | 379 | { |
380 | 380 | $save_data = $this->data; |
381 | - $data = $this->read($data,true); |
|
381 | + $data = $this->read($data, true); |
|
382 | 382 | $this->data = $save_data; |
383 | 383 | |
384 | - if (!$data) return null; // entry not found |
|
384 | + if (!$data) return null; // entry not found |
|
385 | 385 | } |
386 | 386 | if (!$user) $user = $this->user; |
387 | 387 | if ($user == $this->user) |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | } |
391 | 391 | else |
392 | 392 | { |
393 | - $grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP,true,$user); |
|
393 | + $grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP, true, $user); |
|
394 | 394 | } |
395 | - $ret = $data && !!($grants[$data['ts_owner']] & $required); |
|
395 | + $ret = $data && !!($grants[$data['ts_owner']]&$required); |
|
396 | 396 | |
397 | - if(($required & Acl::DELETE) && $this->config_data['history'] == 'history' && |
|
397 | + if (($required&Acl::DELETE) && $this->config_data['history'] == 'history' && |
|
398 | 398 | $data['ts_status'] == self::DELETED_STATUS) |
399 | 399 | { |
400 | 400 | $ret = !!($GLOBALS['egw_info']['user']['apps']['admin']); |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * @param int &$end |
412 | 412 | * @return string |
413 | 413 | */ |
414 | - function date_filter($name,&$start,&$end) |
|
414 | + function date_filter($name, &$start, &$end) |
|
415 | 415 | { |
416 | 416 | return Api\DateTime::sql_filter($name, $start, $end, 'ts_start', $this->date_filters); |
417 | 417 | } |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | * @param boolean $only_summary =false If true only return the sums as array with keys duration and price, default false |
438 | 438 | * @return array of matching rows (the row is an array of the cols) or False |
439 | 439 | */ |
440 | - function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false,$only_summary=false) |
|
440 | + function &search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter = null, $join = '', $need_full_no_count = false, $only_summary = false) |
|
441 | 441 | { |
442 | 442 | //error_log(__METHOD__."(".print_r($criteria,true).",'$only_keys','$order_by',".print_r($extra_cols,true).",'$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')"); |
443 | 443 | //echo "<p>".__METHOD__."(".print_r($criteria,true).",'$only_keys','$order_by',".print_r($extra_cols,true).",'$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')</p>\n"; |
@@ -446,9 +446,9 @@ discard block |
||
446 | 446 | |
447 | 447 | if (!is_array($extra_cols)) |
448 | 448 | { |
449 | - $extra_cols = $extra_cols ? explode(',',$extra_cols) : array(); |
|
449 | + $extra_cols = $extra_cols ? explode(',', $extra_cols) : array(); |
|
450 | 450 | } |
451 | - if ($only_keys === false || $this->show_sums && strpos($order_by,'ts_start') !== false) |
|
451 | + if ($only_keys === false || $this->show_sums && strpos($order_by, 'ts_start') !== false) |
|
452 | 452 | { |
453 | 453 | $extra_cols[] = $total_sql.' AS ts_total'; |
454 | 454 | } |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | { |
466 | 466 | if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']); |
467 | 467 | |
468 | - foreach($filter['ts_owner'] as $key => $owner) |
|
468 | + foreach ($filter['ts_owner'] as $key => $owner) |
|
469 | 469 | { |
470 | 470 | if (!isset($this->grants[$owner])) |
471 | 471 | { |
@@ -479,8 +479,8 @@ discard block |
||
479 | 479 | } |
480 | 480 | else |
481 | 481 | { |
482 | - $filter[] = '(ts_status ' . ($filter['ts_status'] == self::DELETED_STATUS ? '=':'!= ') . self::DELETED_STATUS . |
|
483 | - ($filter['ts_status'] == self::DELETED_STATUS ? '':' OR ts_status IS NULL') . ')'; |
|
482 | + $filter[] = '(ts_status '.($filter['ts_status'] == self::DELETED_STATUS ? '=' : '!= ').self::DELETED_STATUS. |
|
483 | + ($filter['ts_status'] == self::DELETED_STATUS ? '' : ' OR ts_status IS NULL').')'; |
|
484 | 484 | } |
485 | 485 | if (!count($filter['ts_owner'])) |
486 | 486 | { |
@@ -488,15 +488,15 @@ discard block |
||
488 | 488 | $this->summary = array(); |
489 | 489 | return array(); |
490 | 490 | } |
491 | - if ($only_summary==false && $criteria && $this->show_sums) |
|
491 | + if ($only_summary == false && $criteria && $this->show_sums) |
|
492 | 492 | { |
493 | 493 | // if we have a criteria AND intend to show the sums we first query the affected ids, |
494 | 494 | // then we throw away criteria and filter, and replace the filter with the list of ids |
495 | - $ids = parent::search($criteria,'egw_timesheet.ts_id as id','','',$wildcard,$empty,$op,false,$filter,$join); |
|
495 | + $ids = parent::search($criteria, 'egw_timesheet.ts_id as id', '', '', $wildcard, $empty, $op, false, $filter, $join); |
|
496 | 496 | //_debug_array($ids); |
497 | 497 | if (empty($ids)) |
498 | 498 | { |
499 | - $this->summary = array('duration'=>0,'price'=>null,'quantity'=>0); |
|
499 | + $this->summary = array('duration'=>0, 'price'=>null, 'quantity'=>0); |
|
500 | 500 | return array(); |
501 | 501 | } |
502 | 502 | unset($criteria); |
@@ -520,45 +520,45 @@ discard block |
||
520 | 520 | |
521 | 521 | if ($only_summary) return $this->summary; |
522 | 522 | |
523 | - if ($this->show_sums && strpos($order_by,'ts_start') !== false && // sums only make sense if ordered by ts_start |
|
523 | + if ($this->show_sums && strpos($order_by, 'ts_start') !== false && // sums only make sense if ordered by ts_start |
|
524 | 524 | $this->db->capabilities['union'] && ($from_unixtime_ts_start = $this->db->from_unixtime('ts_start'))) |
525 | 525 | { |
526 | 526 | $sum_sql = array( |
527 | - 'year' => $this->db->date_format($from_unixtime_ts_start,'%Y'), |
|
528 | - 'month' => $this->db->date_format($from_unixtime_ts_start,'%Y%m'), |
|
529 | - 'week' => $this->db->date_format($from_unixtime_ts_start,$GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'] == 'Sunday' ? '%X%V' : '%x%v'), |
|
530 | - 'day' => $this->db->date_format($from_unixtime_ts_start,'%Y-%m-%d'), |
|
527 | + 'year' => $this->db->date_format($from_unixtime_ts_start, '%Y'), |
|
528 | + 'month' => $this->db->date_format($from_unixtime_ts_start, '%Y%m'), |
|
529 | + 'week' => $this->db->date_format($from_unixtime_ts_start, $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'] == 'Sunday' ? '%X%V' : '%x%v'), |
|
530 | + 'day' => $this->db->date_format($from_unixtime_ts_start, '%Y-%m-%d'), |
|
531 | 531 | ); |
532 | - foreach($this->show_sums as $type) |
|
532 | + foreach ($this->show_sums as $type) |
|
533 | 533 | { |
534 | 534 | $extra_cols[] = $sum_sql[$type].' AS ts_'.$type; |
535 | 535 | $extra_cols[] = '0 AS is_sum_'.$type; |
536 | - $sum_extra_cols[] = str_replace('ts_start','MIN(ts_start)',$sum_sql[$type]); // as we dont group by ts_start |
|
536 | + $sum_extra_cols[] = str_replace('ts_start', 'MIN(ts_start)', $sum_sql[$type]); // as we dont group by ts_start |
|
537 | 537 | $sum_extra_cols[$type] = '0 AS is_sum_'.$type; |
538 | 538 | } |
539 | 539 | // regular entries |
540 | - parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count); |
|
540 | + parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, 'UNION', $filter, $join, $need_full_no_count); |
|
541 | 541 | |
542 | - $sort = substr($order_by,8); |
|
542 | + $sort = substr($order_by, 8); |
|
543 | 543 | $union_order = array(); |
544 | - $sum_ts_id = array('year' => -3,'month' => -2,'week' => -1,'day' => 0); |
|
545 | - foreach($this->show_sums as $type) |
|
544 | + $sum_ts_id = array('year' => -3, 'month' => -2, 'week' => -1, 'day' => 0); |
|
545 | + foreach ($this->show_sums as $type) |
|
546 | 546 | { |
547 | - $union_order[] = 'ts_'.$type . ' ' . $sort; |
|
547 | + $union_order[] = 'ts_'.$type.' '.$sort; |
|
548 | 548 | $union_order[] = 'is_sum_'.$type; |
549 | 549 | $sum_extra_cols[$type]{0} = '1'; |
550 | 550 | // the $type sum |
551 | - parent::search($criteria,array( |
|
552 | - (string)$sum_ts_id[$type],"''","''","''",'MIN(ts_start)','SUM(ts_duration) AS ts_duration', |
|
551 | + parent::search($criteria, array( |
|
552 | + (string)$sum_ts_id[$type], "''", "''", "''", 'MIN(ts_start)', 'SUM(ts_duration) AS ts_duration', |
|
553 | 553 | ($this->quantity_sum ? "SUM(ts_quantity) AS ts_quantity" : '0'), |
554 | - '0','NULL','0','0','0','0','0','0',"SUM($total_sql) AS ts_total" |
|
555 | - ),'GROUP BY '.$sum_sql[$type],$sum_extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count); |
|
554 | + '0', 'NULL', '0', '0', '0', '0', '0', '0', "SUM($total_sql) AS ts_total" |
|
555 | + ), 'GROUP BY '.$sum_sql[$type], $sum_extra_cols, $wildcard, $empty, $op, 'UNION', $filter, $join, $need_full_no_count); |
|
556 | 556 | $sum_extra_cols[$type]{0} = '0'; |
557 | 557 | } |
558 | 558 | $union_order[] = 'ts_start '.$sort; |
559 | - return parent::search('','',implode(',',$union_order),'','',false,'',$start); |
|
559 | + return parent::search('', '', implode(',', $union_order), '', '', false, '', $start); |
|
560 | 560 | } |
561 | - return parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count); |
|
561 | + return parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter, $join, $need_full_no_count); |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | /** |
@@ -568,16 +568,16 @@ discard block |
||
568 | 568 | * @param boolean $ignore_acl =false should the Acl be checked |
569 | 569 | * @return array|boolean array with timesheet entry, null if timesheet not found or false if no rights |
570 | 570 | */ |
571 | - function read($ts_id,$ignore_acl=false) |
|
571 | + function read($ts_id, $ignore_acl = false) |
|
572 | 572 | { |
573 | 573 | //error_log(__METHOD__."($ts_id,$ignore_acl) ".function_backtrace()); |
574 | 574 | if (!(int)$ts_id || (int)$ts_id != $this->data['ts_id'] && !parent::read($ts_id)) |
575 | 575 | { |
576 | - return null; // entry not found |
|
576 | + return null; // entry not found |
|
577 | 577 | } |
578 | 578 | if (!$ignore_acl && !($ret = $this->check_acl(Acl::READ))) |
579 | 579 | { |
580 | - return false; // no read rights |
|
580 | + return false; // no read rights |
|
581 | 581 | } |
582 | 582 | return $this->data; |
583 | 583 | } |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | * @param boolean $ignore_acl =false should the Acl be checked, returns true if no edit-rigts |
593 | 593 | * @return int 0 on success and errno != 0 else |
594 | 594 | */ |
595 | - function save($keys=null,$touch_modified=true,$ignore_acl=false) |
|
595 | + function save($keys = null, $touch_modified = true, $ignore_acl = false) |
|
596 | 596 | { |
597 | 597 | if ($keys) $this->data_merge($keys); |
598 | 598 | |
@@ -610,13 +610,13 @@ discard block |
||
610 | 610 | // check if we have a real modification of an existing record |
611 | 611 | if ($this->data['ts_id']) |
612 | 612 | { |
613 | - $new =& $this->data; |
|
613 | + $new = & $this->data; |
|
614 | 614 | unset($this->data); |
615 | 615 | $this->read($new['ts_id']); |
616 | - $old =& $this->data; |
|
617 | - $this->data =& $new; |
|
616 | + $old = & $this->data; |
|
617 | + $this->data = & $new; |
|
618 | 618 | $changed = array(); |
619 | - if (isset($old)) foreach($old as $name => $value) |
|
619 | + if (isset($old)) foreach ($old as $name => $value) |
|
620 | 620 | { |
621 | 621 | if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name; |
622 | 622 | } |
@@ -635,14 +635,14 @@ discard block |
||
635 | 635 | )) |
636 | 636 | { |
637 | 637 | $this->data['ts_project'] = $this->data['pm_id'] ? Link::title('projectmanager', $this->data['pm_id']) : ''; |
638 | - if($this->data['ts_title'] == Link::title('projectmanager', $old['pm_id'])) |
|
638 | + if ($this->data['ts_title'] == Link::title('projectmanager', $old['pm_id'])) |
|
639 | 639 | { |
640 | 640 | $this->data['ts_title'] = $this->data['ts_project']; |
641 | 641 | } |
642 | 642 | } |
643 | 643 | |
644 | 644 | // Check for restore of deleted contact, restore held links |
645 | - if($old && $old['ts_status'] == self::DELETED_STATUS && $new['ts_status'] != self::DELETED_STATUS) |
|
645 | + if ($old && $old['ts_status'] == self::DELETED_STATUS && $new['ts_status'] != self::DELETED_STATUS) |
|
646 | 646 | { |
647 | 647 | Link::restore(TIMESHEET_APP, $new['ts_id']); |
648 | 648 | } |
@@ -655,12 +655,12 @@ discard block |
||
655 | 655 | |
656 | 656 | $this->tracking->html_content_allow = true; |
657 | 657 | } |
658 | - if ($this->tracking->track($this->data,$old,$this->user) === false) |
|
658 | + if ($this->tracking->track($this->data, $old, $this->user) === false) |
|
659 | 659 | { |
660 | - return implode(', ',$this->tracking->errors); |
|
660 | + return implode(', ', $this->tracking->errors); |
|
661 | 661 | } |
662 | 662 | // notify the link-class about the update, as other apps may be subscribt to it |
663 | - Link::notify_update(TIMESHEET_APP,$this->data['ts_id'],$this->data); |
|
663 | + Link::notify_update(TIMESHEET_APP, $this->data['ts_id'], $this->data); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | return $err; |
@@ -673,15 +673,15 @@ discard block |
||
673 | 673 | * @param boolean $ignore_acl =false should the Acl be checked, returns false if no delete-rigts |
674 | 674 | * @return int affected rows, should be 1 if ok, 0 if an error |
675 | 675 | */ |
676 | - function delete($keys=null,$ignore_acl=false) |
|
676 | + function delete($keys = null, $ignore_acl = false) |
|
677 | 677 | { |
678 | - if (!is_array($keys) && (int) $keys) |
|
678 | + if (!is_array($keys) && (int)$keys) |
|
679 | 679 | { |
680 | - $keys = array('ts_id' => (int) $keys); |
|
680 | + $keys = array('ts_id' => (int)$keys); |
|
681 | 681 | } |
682 | 682 | $ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id']; |
683 | 683 | |
684 | - if (!$ignore_acl && !$this->check_acl(Acl::DELETE,$ts_id) || !($old = $this->read($ts_id))) |
|
684 | + if (!$ignore_acl && !$this->check_acl(Acl::DELETE, $ts_id) || !($old = $this->read($ts_id))) |
|
685 | 685 | { |
686 | 686 | return false; |
687 | 687 | } |
@@ -692,12 +692,12 @@ discard block |
||
692 | 692 | $delete = $old; |
693 | 693 | $delete['ts_status'] = self::DELETED_STATUS; |
694 | 694 | $ret = !($this->save($delete)); |
695 | - Link::unlink(0,TIMESHEET_APP,$ts_id,'','','',true); |
|
695 | + Link::unlink(0, TIMESHEET_APP, $ts_id, '', '', '', true); |
|
696 | 696 | } |
697 | 697 | elseif (($ret = parent::delete($keys)) && $ts_id) |
698 | 698 | { |
699 | 699 | // delete all links to timesheet entry $ts_id |
700 | - Link::unlink(0,TIMESHEET_APP,$ts_id); |
|
700 | + Link::unlink(0, TIMESHEET_APP, $ts_id); |
|
701 | 701 | } |
702 | 702 | return $ret; |
703 | 703 | } |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | function deleteaccount($data) |
713 | 713 | { |
714 | 714 | $account_id = $data['account_id']; |
715 | - $new_owner = $data['new_owner']; |
|
715 | + $new_owner = $data['new_owner']; |
|
716 | 716 | |
717 | 717 | if (!$new_owner) |
718 | 718 | { |
@@ -736,22 +736,22 @@ discard block |
||
736 | 736 | * @param int $status =0 |
737 | 737 | * @return int affected rows, should be 1 if ok, 0 if an error |
738 | 738 | */ |
739 | - function set_status($keys=null, $status=0) |
|
739 | + function set_status($keys = null, $status = 0) |
|
740 | 740 | { |
741 | 741 | $ret = true; |
742 | - if (!is_array($keys) && (int) $keys) |
|
742 | + if (!is_array($keys) && (int)$keys) |
|
743 | 743 | { |
744 | - $keys = array('ts_id' => (int) $keys); |
|
744 | + $keys = array('ts_id' => (int)$keys); |
|
745 | 745 | } |
746 | 746 | $ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id']; |
747 | 747 | |
748 | - if (!$this->check_acl(Acl::EDIT,$ts_id) || !$this->read($ts_id,true)) |
|
748 | + if (!$this->check_acl(Acl::EDIT, $ts_id) || !$this->read($ts_id, true)) |
|
749 | 749 | { |
750 | 750 | return false; |
751 | 751 | } |
752 | 752 | |
753 | 753 | $this->data['ts_status'] = $status; |
754 | - if ($this->save($ts_id)!=0) $ret = false; |
|
754 | + if ($this->save($ts_id) != 0) $ret = false; |
|
755 | 755 | |
756 | 756 | return $ret; |
757 | 757 | } |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | { |
769 | 769 | return array('duration' => 0, 'quantity' => 0, 'price' => 0, 'max_modified' => null); |
770 | 770 | } |
771 | - return $this->search(array('ts_id'=>$ids),true,'','','',false,'AND',false,null,'',false,true); |
|
771 | + return $this->search(array('ts_id'=>$ids), true, '', '', '', false, 'AND', false, null, '', false, true); |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | /** |
@@ -779,27 +779,27 @@ discard block |
||
779 | 779 | * @param int|array $entry int ts_id or array with timesheet entry |
780 | 780 | * @return string/boolean string with title, null if timesheet not found, false if no perms to view it |
781 | 781 | */ |
782 | - function link_title( $entry ) |
|
782 | + function link_title($entry) |
|
783 | 783 | { |
784 | 784 | if (!is_array($entry)) |
785 | 785 | { |
786 | 786 | // need to preserve the $this->data |
787 | - $backup =& $this->data; |
|
787 | + $backup = & $this->data; |
|
788 | 788 | unset($this->data); |
789 | - $entry = $this->read( $entry,false,false); |
|
789 | + $entry = $this->read($entry, false, false); |
|
790 | 790 | // restore the data again |
791 | - $this->data =& $backup; |
|
791 | + $this->data = & $backup; |
|
792 | 792 | } |
793 | 793 | if (!$entry) |
794 | 794 | { |
795 | 795 | return $entry; |
796 | 796 | } |
797 | 797 | $format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
798 | - if (date('H:i',$entry['ts_start']) != '00:00') // dont show 00:00 time, as it means date only |
|
798 | + if (date('H:i', $entry['ts_start']) != '00:00') // dont show 00:00 time, as it means date only |
|
799 | 799 | { |
800 | 800 | $format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'); |
801 | 801 | } |
802 | - return date($format,$entry['ts_start']).': '.$entry['ts_title']; |
|
802 | + return date($format, $entry['ts_start']).': '.$entry['ts_title']; |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | /** |
@@ -810,18 +810,18 @@ discard block |
||
810 | 810 | * @param array $ids array with ts_id's |
811 | 811 | * @return array with titles, see link_title |
812 | 812 | */ |
813 | - function link_titles( array $ids ) |
|
813 | + function link_titles(array $ids) |
|
814 | 814 | { |
815 | 815 | $titles = array(); |
816 | - if (($entries = $this->search(array('ts_id' => $ids),'ts_id,ts_title,ts_start'))) |
|
816 | + if (($entries = $this->search(array('ts_id' => $ids), 'ts_id,ts_title,ts_start'))) |
|
817 | 817 | { |
818 | - foreach($entries as $entry) |
|
818 | + foreach ($entries as $entry) |
|
819 | 819 | { |
820 | 820 | $titles[$entry['ts_id']] = $this->link_title($entry); |
821 | 821 | } |
822 | 822 | } |
823 | 823 | // we assume all not returned entries are not readable by the user, as we notify Link about all deletes |
824 | - foreach($ids as $id) |
|
824 | + foreach ($ids as $id) |
|
825 | 825 | { |
826 | 826 | if (!isset($titles[$id])) |
827 | 827 | { |
@@ -840,16 +840,16 @@ discard block |
||
840 | 840 | * @param array $options Array of options for the search |
841 | 841 | * @return array with ts_id - title pairs of the matching entries |
842 | 842 | */ |
843 | - function link_query( $pattern, Array &$options = array() ) |
|
843 | + function link_query($pattern, Array &$options = array()) |
|
844 | 844 | { |
845 | 845 | $limit = false; |
846 | 846 | $need_count = false; |
847 | - if($options['start'] || $options['num_rows']) { |
|
847 | + if ($options['start'] || $options['num_rows']) { |
|
848 | 848 | $limit = array($options['start'], $options['num_rows']); |
849 | 849 | $need_count = true; |
850 | 850 | } |
851 | 851 | $result = array(); |
852 | - foreach((array) $this->search($pattern,false,'','','%',false,'OR', $limit, null, '', $need_count) as $ts ) |
|
852 | + foreach ((array)$this->search($pattern, false, '', '', '%', false, 'OR', $limit, null, '', $need_count) as $ts) |
|
853 | 853 | { |
854 | 854 | if ($ts) $result[$ts['ts_id']] = $this->link_title($ts); |
855 | 855 | } |
@@ -866,11 +866,11 @@ discard block |
||
866 | 866 | * @param int $user =null for which user to check, default current user |
867 | 867 | * @return boolean true if access is granted or false otherwise |
868 | 868 | */ |
869 | - function file_access($id,$check,$rel_path=null,$user=null) |
|
869 | + function file_access($id, $check, $rel_path = null, $user = null) |
|
870 | 870 | { |
871 | - unset($rel_path); // not used, but required by function signature |
|
871 | + unset($rel_path); // not used, but required by function signature |
|
872 | 872 | |
873 | - return $this->check_acl($check,$id,$user); |
|
873 | + return $this->check_acl($check, $id, $user); |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | /** |
@@ -882,16 +882,16 @@ discard block |
||
882 | 882 | * @param string $newtitle => the new title of the project |
883 | 883 | * @return boolean true for success, false for invalid parameters |
884 | 884 | */ |
885 | - function update_ts_project($oldtitle='', $newtitle='') |
|
885 | + function update_ts_project($oldtitle = '', $newtitle = '') |
|
886 | 886 | { |
887 | - if(strlen($oldtitle) > 0 && strlen($newtitle) > 0) |
|
887 | + if (strlen($oldtitle) > 0 && strlen($newtitle) > 0) |
|
888 | 888 | { |
889 | - $this->db->update('egw_timesheet',array( |
|
889 | + $this->db->update('egw_timesheet', array( |
|
890 | 890 | 'ts_project' => $newtitle, |
891 | 891 | 'ts_title' => $newtitle, |
892 | - ),array( |
|
892 | + ), array( |
|
893 | 893 | 'ts_project' => $oldtitle, |
894 | - ),__LINE__,__FILE__,TIMESHEET_APP); |
|
894 | + ), __LINE__, __FILE__, TIMESHEET_APP); |
|
895 | 895 | |
896 | 896 | return true; |
897 | 897 | } |
@@ -904,16 +904,16 @@ discard block |
||
904 | 904 | * @param int $pm_id ID of selected project |
905 | 905 | * @return array containing link_id and ts_id |
906 | 906 | */ |
907 | - function get_ts_links($pm_id=0) |
|
907 | + function get_ts_links($pm_id = 0) |
|
908 | 908 | { |
909 | - if($pm_id && isset($GLOBALS['egw_info']['user']['apps']['projectmanager'])) |
|
909 | + if ($pm_id && isset($GLOBALS['egw_info']['user']['apps']['projectmanager'])) |
|
910 | 910 | { |
911 | - $pm_ids = ExecMethod('projectmanager.projectmanager_bo.children',$pm_id); |
|
911 | + $pm_ids = ExecMethod('projectmanager.projectmanager_bo.children', $pm_id); |
|
912 | 912 | $pm_ids[] = $pm_id; |
913 | - $links = Link\Storage::get_links('projectmanager',$pm_ids,'timesheet'); // Link\Storage::get_links not egw_links::get_links! |
|
913 | + $links = Link\Storage::get_links('projectmanager', $pm_ids, 'timesheet'); // Link\Storage::get_links not egw_links::get_links! |
|
914 | 914 | if ($links) |
915 | 915 | { |
916 | - $links = array_unique(call_user_func_array('array_merge',$links)); |
|
916 | + $links = array_unique(call_user_func_array('array_merge', $links)); |
|
917 | 917 | } |
918 | 918 | return $links; |
919 | 919 | } |
@@ -931,17 +931,17 @@ discard block |
||
931 | 931 | function notify($data) |
932 | 932 | { |
933 | 933 | //error_log(__METHOD__.'('.array2string($data).')'); |
934 | - $backup =& $this->data; // backup internal data in case class got re-used by ExecMethod |
|
934 | + $backup = & $this->data; // backup internal data in case class got re-used by ExecMethod |
|
935 | 935 | unset($this->data); |
936 | 936 | |
937 | 937 | if ($data['target_app'] == 'projectmanager' && $this->read($data['id'])) |
938 | 938 | { |
939 | 939 | $old_title = isset($data['data']) ? $data['data'][Link::OLD_LINK_TITLE] : null; |
940 | - switch($data['type']) |
|
940 | + switch ($data['type']) |
|
941 | 941 | { |
942 | 942 | case 'link': |
943 | 943 | case 'update': |
944 | - if (empty($this->data['ts_project']) || // timesheet has not yet project set --> set just linked one |
|
944 | + if (empty($this->data['ts_project']) || // timesheet has not yet project set --> set just linked one |
|
945 | 945 | isset($old_title) && $this->data['ts_project'] === $old_title) |
946 | 946 | { |
947 | 947 | $pm_id = $data['target_id']; |
@@ -983,17 +983,17 @@ discard block |
||
983 | 983 | * @param array $data =null if given works on that array and returns result, else works on internal data-array |
984 | 984 | * @return array |
985 | 985 | */ |
986 | - function db2data($data=null) |
|
986 | + function db2data($data = null) |
|
987 | 987 | { |
988 | 988 | if (($intern = !is_array($data))) |
989 | 989 | { |
990 | - $data =& $this->data; |
|
990 | + $data = & $this->data; |
|
991 | 991 | } |
992 | 992 | // get pm_id from links and ts_project: either project matching ts_project or first found project |
993 | 993 | if (!isset($data['pm_id']) && $data['ts_id']) |
994 | 994 | { |
995 | 995 | $first_pm_id = null; |
996 | - foreach(Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id) |
|
996 | + foreach (Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id) |
|
997 | 997 | { |
998 | 998 | if (!isset($first_pm_id)) $first_pm_id = $pm_id; |
999 | 999 | if ($data['ts_project'] == Link::title('projectmanager', $pm_id)) |
@@ -1011,7 +1011,7 @@ discard block |
||
1011 | 1011 | $data['ts_project_blur'] = $data['ts_project']; |
1012 | 1012 | $data['ts_project'] = ''; |
1013 | 1013 | } |
1014 | - return parent::db2data($intern ? null : $data); // important to use null, if $intern! |
|
1014 | + return parent::db2data($intern ? null : $data); // important to use null, if $intern! |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | /** |
@@ -1023,17 +1023,17 @@ discard block |
||
1023 | 1023 | * @param array $data =null if given works on that array and returns result, else works on internal data-array |
1024 | 1024 | * @return array |
1025 | 1025 | */ |
1026 | - function data2db($data=null) |
|
1026 | + function data2db($data = null) |
|
1027 | 1027 | { |
1028 | 1028 | if (($intern = !is_array($data))) |
1029 | 1029 | { |
1030 | - $data =& $this->data; |
|
1030 | + $data = & $this->data; |
|
1031 | 1031 | } |
1032 | 1032 | // allways store ts_project to be able to search for it, even if no custom project is set |
1033 | 1033 | if (empty($data['ts_project']) && !is_null($data['ts_project'])) |
1034 | 1034 | { |
1035 | 1035 | $data['ts_project'] = $data['pm_id'] ? Link::title('projectmanager', $data['pm_id']) : ''; |
1036 | 1036 | } |
1037 | - return parent::data2db($intern ? null : $data); // important to use null, if $intern! |
|
1037 | + return parent::data2db($intern ? null : $data); // important to use null, if $intern! |
|
1038 | 1038 | } |
1039 | 1039 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | 'name' => 'Ralf Becker', |
21 | 21 | 'email' => '[email protected]' |
22 | 22 | ); |
23 | -$setup_info['filemanager']['license'] = 'GPL'; |
|
23 | +$setup_info['filemanager']['license'] = 'GPL'; |
|
24 | 24 | |
25 | 25 | /* The hooks this app includes, needed for hooks registration */ |
26 | 26 | $setup_info['filemanager']['hooks']['settings'] = 'filemanager_hooks::settings'; |
@@ -123,7 +123,7 @@ |
||
123 | 123 | } |
124 | 124 | // Custom fields |
125 | 125 | if($content && strpos($content, '#') !== 0) |
126 | - { |
|
126 | + { |
|
127 | 127 | // Expand link-to custom fields |
128 | 128 | $this->cf_link_to_expand($file, $content, $info); |
129 | 129 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | parent::__construct(); |
62 | 62 | |
63 | - if($_dir) |
|
63 | + if ($_dir) |
|
64 | 64 | { |
65 | 65 | $this->dir = $_dir; |
66 | 66 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param string &$content=null content to create some replacements only if they are use |
77 | 77 | * @return array|boolean |
78 | 78 | */ |
79 | - protected function get_replacements($id,&$content=null) |
|
79 | + protected function get_replacements($id, &$content = null) |
|
80 | 80 | { |
81 | 81 | if (!($replacements = $this->filemanager_replacements($id, '', $content))) |
82 | 82 | { |
@@ -92,27 +92,27 @@ discard block |
||
92 | 92 | * @param string $prefix='' prefix like eg. 'erole' |
93 | 93 | * @return array|boolean |
94 | 94 | */ |
95 | - public function filemanager_replacements($id,$prefix='', &$content = null) |
|
95 | + public function filemanager_replacements($id, $prefix = '', &$content = null) |
|
96 | 96 | { |
97 | 97 | $info = array(); |
98 | - $file = Vfs::lstat($id,true); |
|
98 | + $file = Vfs::lstat($id, true); |
|
99 | 99 | |
100 | 100 | $file['mtime'] = Api\DateTime::to($file['mtime']); |
101 | 101 | $file['ctime'] = Api\DateTime::to($file['ctime']); |
102 | 102 | |
103 | 103 | $file['name'] = Vfs::basename($id); |
104 | 104 | $file['dir'] = ($dir = Vfs::dirname($id)) ? Vfs::decodePath($dir) : ''; |
105 | - $dirlist = explode('/',$file['dir']); |
|
105 | + $dirlist = explode('/', $file['dir']); |
|
106 | 106 | $file['folder'] = array_pop($dirlist); |
107 | - $file['folder_file'] = $file['folder'] . '/'.$file['name']; |
|
107 | + $file['folder_file'] = $file['folder'].'/'.$file['name']; |
|
108 | 108 | $file['path'] = $id; |
109 | 109 | $file['rel_path'] = str_replace($this->dir.'/', '', $id); |
110 | 110 | $file['hsize'] = Vfs::hsize($file['size']); |
111 | 111 | $file['mime'] = Vfs::mime_content_type($id); |
112 | - $file['gid'] *= -1; // our widgets use negative gid's |
|
112 | + $file['gid'] *= -1; // our widgets use negative gid's |
|
113 | 113 | if (($props = Vfs::propfind($id))) |
114 | 114 | { |
115 | - foreach($props as $prop) |
|
115 | + foreach ($props as $prop) |
|
116 | 116 | { |
117 | 117 | $file[$prop['name']] = $prop['val']; |
118 | 118 | } |
@@ -122,22 +122,22 @@ discard block |
||
122 | 122 | $file['symlink'] = Vfs::readlink($id); |
123 | 123 | } |
124 | 124 | // Custom fields |
125 | - if($content && strpos($content, '#') !== 0) |
|
125 | + if ($content && strpos($content, '#') !== 0) |
|
126 | 126 | { |
127 | 127 | // Expand link-to custom fields |
128 | 128 | $this->cf_link_to_expand($file, $content, $info); |
129 | 129 | |
130 | - foreach(Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
130 | + foreach (Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
131 | 131 | { |
132 | 132 | // Set any missing custom fields, or the marker will stay |
133 | - if(!$file['#'.$name]) |
|
133 | + if (!$file['#'.$name]) |
|
134 | 134 | { |
135 | 135 | $file['#'.$name] = ''; |
136 | 136 | continue; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Format date cfs per user Api\Preferences |
140 | - if($field['type'] == 'date' || $field['type'] == 'date-time') |
|
140 | + if ($field['type'] == 'date' || $field['type'] == 'date-time') |
|
141 | 141 | { |
142 | 142 | $this->date_fields[] = '#'.$name; |
143 | 143 | $file['#'.$name] = Api\DateTime::to($file['#'.$name], $field['type'] == 'date' ? true : ''); |
@@ -146,51 +146,51 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | // If in apps folder, try for app-specific placeholders |
149 | - if($dirlist[1] == 'apps' && count($dirlist) > 1) |
|
149 | + if ($dirlist[1] == 'apps' && count($dirlist) > 1) |
|
150 | 150 | { |
151 | 151 | // Try this first - a normal path /apps/appname/id/file |
152 | - list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/')+5)); |
|
152 | + list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/') + 5)); |
|
153 | 153 | // Symlink? |
154 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
154 | + if (!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
155 | 155 | // Try resolving just app + ID - /apps/App Name/Record Title/file |
156 | - $resolved = Vfs::resolve_url_symlinks(implode('/',array_slice(explode('/',$file['dir']),0,4))); |
|
157 | - list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
|
156 | + $resolved = Vfs::resolve_url_symlinks(implode('/', array_slice(explode('/', $file['dir']), 0, 4))); |
|
157 | + list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/') + 5)); |
|
158 | 158 | |
159 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
159 | + if (!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
160 | 160 | // Get rid of any virtual folders (eg: All$) and symlinks |
161 | 161 | $resolved = Vfs::resolve_url_symlinks($file['path']); |
162 | - list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
|
162 | + list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/') + 5)); |
|
163 | 163 | } |
164 | 164 | } |
165 | - if($app && $app_id) |
|
165 | + if ($app && $app_id) |
|
166 | 166 | { |
167 | - if($app && $GLOBALS['egw_info']['user']['apps'][$app]) |
|
167 | + if ($app && $GLOBALS['egw_info']['user']['apps'][$app]) |
|
168 | 168 | { |
169 | 169 | $app_merge = null; |
170 | 170 | try |
171 | 171 | { |
172 | - $classname = $app .'_merge'; |
|
173 | - if(class_exists($classname)) |
|
172 | + $classname = $app.'_merge'; |
|
173 | + if (class_exists($classname)) |
|
174 | 174 | { |
175 | 175 | $app_merge = new $classname(); |
176 | - if($app_merge && method_exists($app_merge, 'get_replacements')) |
|
176 | + if ($app_merge && method_exists($app_merge, 'get_replacements')) |
|
177 | 177 | { |
178 | 178 | $app_placeholders = $app_merge->get_replacements($app_id, $content); |
179 | 179 | } |
180 | 180 | } |
181 | 181 | } |
182 | 182 | // Silently discard & continue |
183 | - catch(Exception $e) { |
|
184 | - unset($e); // not used |
|
183 | + catch (Exception $e) { |
|
184 | + unset($e); // not used |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | } |
188 | 188 | } |
189 | 189 | $link = Link::mime_open($file['url'], $file['mime']); |
190 | - if(is_array($link)) |
|
190 | + if (is_array($link)) |
|
191 | 191 | { |
192 | 192 | // Directories have their internal protocol in path here |
193 | - if($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path']; |
|
193 | + if ($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path']; |
|
194 | 194 | $link = Api\Session::link('/index.php', $link); |
195 | 195 | } |
196 | 196 | else |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | $file['url'] = $link; |
210 | 210 | |
211 | 211 | // Add markers |
212 | - foreach($file as $key => &$value) |
|
212 | + foreach ($file as $key => &$value) |
|
213 | 213 | { |
214 | - if(!$value) $value = ''; |
|
215 | - $info['$$'.($prefix ? $prefix.'/':'').$key.'$$'] = $value; |
|
214 | + if (!$value) $value = ''; |
|
215 | + $info['$$'.($prefix ? $prefix.'/' : '').$key.'$$'] = $value; |
|
216 | 216 | } |
217 | - if($app_placeholders) |
|
217 | + if ($app_placeholders) |
|
218 | 218 | { |
219 | 219 | $info = array_merge($app_placeholders, $info); |
220 | 220 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | 'hsize' => 'Size', |
251 | 251 | 'size' => 'Size (in bytes)', |
252 | 252 | ); |
253 | - foreach($fields as $name => $label) |
|
253 | + foreach ($fields as $name => $label) |
|
254 | 254 | { |
255 | 255 | if (!($n&1)) echo '<tr>'; |
256 | 256 | echo '<td>{{'.$name.'}}</td><td>'.lang($label).'</td>'; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>"; |
262 | - foreach(Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
262 | + foreach (Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
263 | 263 | { |
264 | 264 | echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n"; |
265 | 265 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | echo '<tr><td colspan="4">'.lang('For files linked to an application entry (inside /apps/appname/id/) the placeholders for that application are also available. See the specific application for a list of available placeholders.').'</td></tr>'; |
269 | 269 | |
270 | 270 | echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>"; |
271 | - foreach(array( |
|
271 | + foreach (array( |
|
272 | 272 | 'date' => lang('Date'), |
273 | 273 | 'user/n_fn' => lang('Name of current user, all other contact fields are valid too'), |
274 | 274 | 'user/account_lid' => lang('Username'), |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | // Custom fields |
125 | 125 | if($content && strpos($content, '#') !== 0) |
126 | - { |
|
126 | + { |
|
127 | 127 | // Expand link-to custom fields |
128 | 128 | $this->cf_link_to_expand($file, $content, $info); |
129 | 129 | |
@@ -151,12 +151,14 @@ discard block |
||
151 | 151 | // Try this first - a normal path /apps/appname/id/file |
152 | 152 | list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/')+5)); |
153 | 153 | // Symlink? |
154 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
154 | + if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) |
|
155 | + { |
|
155 | 156 | // Try resolving just app + ID - /apps/App Name/Record Title/file |
156 | 157 | $resolved = Vfs::resolve_url_symlinks(implode('/',array_slice(explode('/',$file['dir']),0,4))); |
157 | 158 | list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
158 | 159 | |
159 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
160 | + if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) |
|
161 | + { |
|
160 | 162 | // Get rid of any virtual folders (eg: All$) and symlinks |
161 | 163 | $resolved = Vfs::resolve_url_symlinks($file['path']); |
162 | 164 | list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
@@ -190,7 +192,10 @@ discard block |
||
190 | 192 | if(is_array($link)) |
191 | 193 | { |
192 | 194 | // Directories have their internal protocol in path here |
193 | - if($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path']; |
|
195 | + if($link['path'] && strpos($link['path'], '://') !== false) |
|
196 | + { |
|
197 | + $link['path'] = $file['path']; |
|
198 | + } |
|
194 | 199 | $link = Api\Session::link('/index.php', $link); |
195 | 200 | } |
196 | 201 | else |
@@ -200,7 +205,10 @@ discard block |
||
200 | 205 | } |
201 | 206 | |
202 | 207 | // Prepend site, if missing |
203 | - if ($link[0] == '/') $link = Api\Framework::getUrl($link); |
|
208 | + if ($link[0] == '/') |
|
209 | + { |
|
210 | + $link = Api\Framework::getUrl($link); |
|
211 | + } |
|
204 | 212 | |
205 | 213 | $file['link'] = Api\Html::a_href(Api\Html::htmlspecialchars($file['name']), $link); |
206 | 214 | $file['webdav_url'] = Api\Session::link(Vfs::download_url($file['url'])); |
@@ -209,7 +217,10 @@ discard block |
||
209 | 217 | // Add markers |
210 | 218 | foreach($file as $key => &$value) |
211 | 219 | { |
212 | - if(!$value) $value = ''; |
|
220 | + if(!$value) |
|
221 | + { |
|
222 | + $value = ''; |
|
223 | + } |
|
213 | 224 | $info['$$'.($prefix ? $prefix.'/':'').$key.'$$'] = $value; |
214 | 225 | } |
215 | 226 | if($app_placeholders) |
@@ -251,9 +262,15 @@ discard block |
||
251 | 262 | ); |
252 | 263 | foreach($fields as $name => $label) |
253 | 264 | { |
254 | - if (!($n&1)) echo '<tr>'; |
|
265 | + if (!($n&1)) |
|
266 | + { |
|
267 | + echo '<tr>'; |
|
268 | + } |
|
255 | 269 | echo '<td>{{'.$name.'}}</td><td>'.lang($label).'</td>'; |
256 | - if ($n&1) echo "</tr>\n"; |
|
270 | + if ($n&1) |
|
271 | + { |
|
272 | + echo "</tr>\n"; |
|
273 | + } |
|
257 | 274 | $n++; |
258 | 275 | } |
259 | 276 |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | } |
37 | 37 | //print_r($config); exit; |
38 | 38 | |
39 | -$uglify =& $config['uglify']; |
|
39 | +$uglify = & $config['uglify']; |
|
40 | 40 | |
41 | -foreach(Bundle::all() as $name => $files) |
|
41 | +foreach (Bundle::all() as $name => $files) |
|
42 | 42 | { |
43 | - if ($name == '.ts') continue; // ignore timestamp |
|
43 | + if ($name == '.ts') continue; // ignore timestamp |
|
44 | 44 | |
45 | 45 | // remove leading / from file-names |
46 | 46 | array_walk($files, function(&$path) |
@@ -79,16 +79,16 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | // add css for all templates and themes |
82 | -$cssmin =& $config['cssmin']; |
|
83 | -$GLOBALS['egw_info']['flags']['currentapp'] = '*grunt*'; // to no find any app.css files |
|
84 | -$GLOBALS['egw_info']['server']['debug_minify'] = 'True'; // otherwise we would only get minified file |
|
85 | -foreach(array('pixelegg','jdots')/*array_keys(Framework::list_templates())*/ as $template) |
|
82 | +$cssmin = & $config['cssmin']; |
|
83 | +$GLOBALS['egw_info']['flags']['currentapp'] = '*grunt*'; // to no find any app.css files |
|
84 | +$GLOBALS['egw_info']['server']['debug_minify'] = 'True'; // otherwise we would only get minified file |
|
85 | +foreach (array('pixelegg', 'jdots')/*array_keys(Framework::list_templates())*/ as $template) |
|
86 | 86 | { |
87 | 87 | $GLOBALS['egw_info']['server']['template_set'] = $template; |
88 | 88 | $tpl = Framework::factory(); |
89 | 89 | $themes = $tpl->list_themes(); |
90 | - if ($template == 'pixelegg') $themes[] = 'fw_mobile'; // this is for mobile devices |
|
91 | - foreach($themes as $theme) |
|
90 | + if ($template == 'pixelegg') $themes[] = 'fw_mobile'; // this is for mobile devices |
|
91 | + foreach ($themes as $theme) |
|
92 | 92 | { |
93 | 93 | // skip not working cssmin of pixelegg/traditional: Broken @import declaration of "../../etemplate/templates/default/etemplate2.css" |
94 | 94 | if ($template == 'pixelegg' && $theme == 'traditional') continue; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $new_json = str_replace("\n", "\n\t", |
115 | 115 | preg_replace_callback('/^( *)/m', function($matches) |
116 | 116 | { |
117 | - return str_repeat("\t", strlen($matches[1])/4); |
|
117 | + return str_repeat("\t", strlen($matches[1]) / 4); |
|
118 | 118 | }, json_encode($config, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES))); |
119 | 119 | |
120 | 120 | $new_content = preg_replace('/^(\s*)"([a-z0-9]+)":/mi', '$1$2:', $new_json); |
@@ -13,7 +13,10 @@ discard block |
||
13 | 13 | use EGroupware\Api\Framework; |
14 | 14 | use EGroupware\Api\Framework\Bundle; |
15 | 15 | |
16 | -if (php_sapi_name() !== 'cli') die("This is a commandline ONLY tool!\n"); |
|
16 | +if (php_sapi_name() !== 'cli') |
|
17 | +{ |
|
18 | + die("This is a commandline ONLY tool!\n"); |
|
19 | +} |
|
17 | 20 | |
18 | 21 | $GLOBALS['egw_info'] = array( |
19 | 22 | 'flags' => array( |
@@ -40,12 +43,19 @@ discard block |
||
40 | 43 | |
41 | 44 | foreach(Bundle::all() as $name => $files) |
42 | 45 | { |
43 | - if ($name == '.ts') continue; // ignore timestamp |
|
46 | + if ($name == '.ts') |
|
47 | + { |
|
48 | + continue; |
|
49 | + } |
|
50 | + // ignore timestamp |
|
44 | 51 | |
45 | 52 | // remove leading / from file-names |
46 | 53 | array_walk($files, function(&$path) |
47 | 54 | { |
48 | - if ($path[0] == '/') $path = substr($path, 1); |
|
55 | + if ($path[0] == '/') |
|
56 | + { |
|
57 | + $path = substr($path, 1); |
|
58 | + } |
|
49 | 59 | }); |
50 | 60 | |
51 | 61 | // api/js/jsapi/egw.js loaded via own tag, and we must not load it twice! |
@@ -87,11 +97,18 @@ discard block |
||
87 | 97 | $GLOBALS['egw_info']['server']['template_set'] = $template; |
88 | 98 | $tpl = Framework::factory(); |
89 | 99 | $themes = $tpl->list_themes(); |
90 | - if ($template == 'pixelegg') $themes[] = 'fw_mobile'; // this is for mobile devices |
|
100 | + if ($template == 'pixelegg') |
|
101 | + { |
|
102 | + $themes[] = 'fw_mobile'; |
|
103 | + } |
|
104 | + // this is for mobile devices |
|
91 | 105 | foreach($themes as $theme) |
92 | 106 | { |
93 | 107 | // skip not working cssmin of pixelegg/traditional: Broken @import declaration of "../../etemplate/templates/default/etemplate2.css" |
94 | - if ($template == 'pixelegg' && $theme == 'traditional') continue; |
|
108 | + if ($template == 'pixelegg' && $theme == 'traditional') |
|
109 | + { |
|
110 | + continue; |
|
111 | + } |
|
95 | 112 | $GLOBALS['egw_info']['user']['preferences']['common']['theme'] = $theme; |
96 | 113 | // empty include list by not-existing file plus last true |
97 | 114 | Framework\CssIncludes::add('*grunt*', null, true, true); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'category' => array( |
56 | 56 | 'type' => 'select', |
57 | 57 | 'label' => lang('Choose a category'), |
58 | - 'options' => array(), // specification of options is postponed into the get_user_interface function |
|
58 | + 'options' => array(), // specification of options is postponed into the get_user_interface function |
|
59 | 59 | 'multiple' => true, |
60 | 60 | ), |
61 | 61 | 'numWeeks' => array( |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | function get_user_interface() |
108 | 108 | { |
109 | 109 | // copied from bookmarks module. |
110 | - $cat = createobject('phpgwapi.categories','','calendar'); |
|
111 | - $cats = $cat->return_array('all',0,False,'','cat_name','',True); |
|
110 | + $cat = createobject('phpgwapi.categories', '', 'calendar'); |
|
111 | + $cats = $cat->return_array('all', 0, False, '', 'cat_name', '', True); |
|
112 | 112 | $cat_ids = array(); |
113 | 113 | while (list(,$category) = @each($cats)) |
114 | 114 | { |
@@ -119,12 +119,12 @@ discard block |
||
119 | 119 | $this->arguments['category']['multiple'] = 5; |
120 | 120 | } |
121 | 121 | |
122 | - if (! isset($GLOBALS['egw']->accounts)) |
|
122 | + if (!isset($GLOBALS['egw']->accounts)) |
|
123 | 123 | { |
124 | 124 | $GLOBALS['egw']->accounts = new Api\Accounts(); |
125 | 125 | } |
126 | - $this->accounts =& $GLOBALS['egw']->accounts; |
|
127 | - $search_params=array( |
|
126 | + $this->accounts = & $GLOBALS['egw']->accounts; |
|
127 | + $search_params = array( |
|
128 | 128 | 'type' => 'both', |
129 | 129 | 'app' => 'calendar', |
130 | 130 | ); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | // sort users and groups separately. |
135 | 135 | if (isset($GLOBALS['sitemgr_info']['anonymous_user'])) |
136 | 136 | { |
137 | - $anon_user = $this->accounts->name2id($GLOBALS['sitemgr_info']['anonymous_user'],'account_lid','u'); |
|
137 | + $anon_user = $this->accounts->name2id($GLOBALS['sitemgr_info']['anonymous_user'], 'account_lid', 'u'); |
|
138 | 138 | } |
139 | 139 | else |
140 | 140 | { |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * Get possible sitemgr paths from the HTTP_REFERRER in order to unreveal the |
144 | 144 | * anonymous user for the correct site. |
145 | 145 | */ |
146 | - $sitemgr_path = preg_replace('/^[^\/]+:\/\/[^\/]+\/([^\?]*)(\?.*)*$/',"/\${1}",$_SERVER['HTTP_REFERER']); |
|
146 | + $sitemgr_path = preg_replace('/^[^\/]+:\/\/[^\/]+\/([^\?]*)(\?.*)*$/', "/\${1}", $_SERVER['HTTP_REFERER']); |
|
147 | 147 | // Remove the trailing file- / pathname if any |
148 | 148 | $sitemgr_path = preg_replace('/[^\/]*$/', '', $sitemgr_path); |
149 | 149 | // Add leading slash if it has been lost. |
@@ -155,14 +155,14 @@ discard block |
||
155 | 155 | // Code adapted from sitemgr-site/index.php |
156 | 156 | $site_urls = array(); |
157 | 157 | $site_urls[] = $sitemgr_path; |
158 | - $site_urls[] = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_ADDR'] . $sitemgr_path; |
|
159 | - $site_urls[] = $site_url = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . $sitemgr_path; |
|
158 | + $site_urls[] = ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['SERVER_ADDR'].$sitemgr_path; |
|
159 | + $site_urls[] = $site_url = ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].$sitemgr_path; |
|
160 | 160 | |
161 | - $anon_user = $this->accounts->name2id($GLOBALS['egw']->db->select('egw_sitemgr_sites','anonymous_user,anonymous_passwd,site_id', |
|
162 | - array('site_url' => $site_urls),__LINE__,__FILE__,false,'','sitemgr')->fetchColumn(),'account_lid','u'); |
|
161 | + $anon_user = $this->accounts->name2id($GLOBALS['egw']->db->select('egw_sitemgr_sites', 'anonymous_user,anonymous_passwd,site_id', |
|
162 | + array('site_url' => $site_urls), __LINE__, __FILE__, false, '', 'sitemgr')->fetchColumn(), 'account_lid', 'u'); |
|
163 | 163 | } |
164 | 164 | |
165 | - $anon_groups = $this->accounts->memberships($anon_user,true); |
|
165 | + $anon_groups = $this->accounts->memberships($anon_user, true); |
|
166 | 166 | foreach ($accounts as $entry) |
167 | 167 | { |
168 | 168 | $is_group = false; |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | $acl = new Acl($entry['account_id']); |
171 | 171 | $acl->read_repository(); |
172 | 172 | // get the rights for each account to check whether the anon user has read permissions. |
173 | - $rights = $acl->get_rights($anon_user,'calendar'); |
|
173 | + $rights = $acl->get_rights($anon_user, 'calendar'); |
|
174 | 174 | // also add the anon user if it's his own calendar. |
175 | - if (($rights & Acl::READ) || ($entry['account_id'] == $anon_user)) |
|
175 | + if (($rights&Acl::READ) || ($entry['account_id'] == $anon_user)) |
|
176 | 176 | { |
177 | 177 | $has_read_permissions = true; |
178 | 178 | } |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | // or ass permissions if this is the anon group's calendar. |
183 | 183 | foreach ($anon_groups as $parent_group) |
184 | 184 | { |
185 | - $rights = $acl->get_rights($parent_group,'calendar'); |
|
186 | - if (($rights & Acl::READ) || ($entry['account_id'] == $parent_group)) |
|
185 | + $rights = $acl->get_rights($parent_group, 'calendar'); |
|
186 | + if (($rights&Acl::READ) || ($entry['account_id'] == $parent_group)) |
|
187 | 187 | { |
188 | 188 | $has_read_permissions = true; |
189 | 189 | break; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | else |
201 | 201 | { |
202 | - $users[$entry['account_id']] = Api\Accounts::format_username($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']); |
|
202 | + $users[$entry['account_id']] = Api\Accounts::format_username($entry['account_lid'], $entry['account_firstname'], $entry['account_lastname']); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | return parent::get_user_interface(); |
220 | 220 | } |
221 | 221 | |
222 | - function get_content(&$arguments,$properties) |
|
222 | + function get_content(&$arguments, $properties) |
|
223 | 223 | { |
224 | 224 | $html = ""; |
225 | 225 | Api\Translation::add_app('calendar'); |
@@ -227,33 +227,32 @@ discard block |
||
227 | 227 | $this->ui->allowEdit = false; |
228 | 228 | $this->ui->use_time_grid = isset($arguments['grid']) ? $arguments['grid'] : false; |
229 | 229 | |
230 | - $weeks = $arguments['numWeeks'] ? (int) $arguments['numWeeks'] : 2; |
|
230 | + $weeks = $arguments['numWeeks'] ? (int)$arguments['numWeeks'] : 2; |
|
231 | 231 | |
232 | - if (($arguments['acceptDateParam']) && (get_var('date',array('POST','GET')))) |
|
232 | + if (($arguments['acceptDateParam']) && (get_var('date', array('POST', 'GET')))) |
|
233 | 233 | { |
234 | - $start = (int) (strtotime(get_var('date',array('POST','GET'))) + |
|
234 | + $start = (int)(strtotime(get_var('date', array('POST', 'GET'))) + |
|
235 | 235 | (60 * 60 * 24 * 7 * $dateOffset)); |
236 | 236 | } |
237 | 237 | else |
238 | 238 | { |
239 | - $start = (int) ($this->bo->now_su + |
|
239 | + $start = (int)($this->bo->now_su + |
|
240 | 240 | (60 * 60 * 24 * 7 * $dateOffset)); |
241 | 241 | } |
242 | 242 | $start = new Api\DateTime($start); |
243 | 243 | $start->setWeekstart(); |
244 | 244 | $first = $start->format('ts'); |
245 | - $last = strtotime("+$weeks weeks",$first) - 1; |
|
245 | + $last = strtotime("+$weeks weeks", $first) - 1; |
|
246 | 246 | |
247 | 247 | if ($arguments['showTitle']) |
248 | 248 | { |
249 | 249 | $html .= '<div id="divAppboxHeader">'.$GLOBALS['egw_info']['apps']['calendar']['title'].' - '.lang('Weekview').": "; |
250 | - $html .= lang('After %1',$this->bo->long_date($first)); |
|
250 | + $html .= lang('After %1', $this->bo->long_date($first)); |
|
251 | 251 | $html .= "</div>"; |
252 | 252 | } |
253 | 253 | |
254 | 254 | // set the search parameters |
255 | - $search_params = Array |
|
256 | - ( |
|
255 | + $search_params = Array( |
|
257 | 256 | 'offset' => false, |
258 | 257 | 'order' => 'cal_start ASC', |
259 | 258 | 'start' => $first, |
@@ -288,19 +287,19 @@ discard block |
||
288 | 287 | $html .= '<!-- END Calendar info -->'."\n"; |
289 | 288 | unset($css_file); |
290 | 289 | // we add DAY_s/2 to $this->first (using 12h), to deal with daylight saving changes |
291 | - for ($week_start = $first; $week_start < $last; $week_start = strtotime("+1 week",$week_start)) |
|
290 | + for ($week_start = $first; $week_start < $last; $week_start = strtotime("+1 week", $week_start)) |
|
292 | 291 | { |
293 | 292 | $week = array(); |
294 | 293 | for ($i = 0; $i < 7; ++$i) |
295 | 294 | { |
296 | - $day_ymd = $this->bo->date2string($i ? strtotime("+$i days",$week_start) : $week_start); |
|
295 | + $day_ymd = $this->bo->date2string($i ? strtotime("+$i days", $week_start) : $week_start); |
|
297 | 296 | $week[$day_ymd] = array_shift($rows); |
298 | 297 | } |
299 | 298 | $week_view = array( |
300 | 299 | 'menuaction' => false, |
301 | 300 | 'date' => $this->bo->date2string($week_start), |
302 | 301 | ); |
303 | - $title = lang('Wk').' '.adodb_date('W',$week_start); |
|
302 | + $title = lang('Wk').' '.adodb_date('W', $week_start); |
|
304 | 303 | if (!isset($GLOBALS['egw']->template)) |
305 | 304 | { |
306 | 305 | $GLOBALS['egw']->template = new Framework\Template; |
@@ -115,7 +115,8 @@ |
||
115 | 115 | $cat_ids[$category['id']] = $GLOBALS['egw']->strip_html($category['name']); |
116 | 116 | } |
117 | 117 | $this->arguments['category']['options'] = $cat_ids; |
118 | - if (count($cat_ids) > 5) { |
|
118 | + if (count($cat_ids) > 5) |
|
119 | + { |
|
119 | 120 | $this->arguments['category']['multiple'] = 5; |
120 | 121 | } |
121 | 122 |
@@ -252,7 +252,7 @@ |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | // set the search parameters |
255 | - $search_params = Array |
|
255 | + $search_params = array |
|
256 | 256 | ( |
257 | 257 | 'offset' => false, |
258 | 258 | 'order' => 'cal_start ASC', |
@@ -15,7 +15,7 @@ |
||
15 | 15 | $setup_info['calendar']['enable'] = 1; |
16 | 16 | $setup_info['calendar']['index'] = 'calendar.calendar_uiviews.index&ajax=true'; |
17 | 17 | |
18 | -$setup_info['calendar']['license'] = 'GPL'; |
|
18 | +$setup_info['calendar']['license'] = 'GPL'; |
|
19 | 19 | $setup_info['calendar']['description'] = |
20 | 20 | 'Powerful group calendar with meeting request system and ACL security.'; |
21 | 21 | $setup_info['calendar']['note'] = |
@@ -50,5 +50,5 @@ |
||
50 | 50 | /* Dependencies for this app to work */ |
51 | 51 | $setup_info['calendar']['depends'][] = array( |
52 | 52 | 'appname' => 'api', |
53 | - 'versions' => Array('17.1') |
|
53 | + 'versions' => array('17.1') |
|
54 | 54 | ); |