@@ -30,14 +30,12 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Shows the contactform and stores the submitted data |
32 | 32 | * |
33 | - * @param array $content=null submitted eTemplate content |
|
34 | - * @param int $addressbook=null int owner-id of addressbook to save contacts too |
|
35 | - * @param array $fields=null field-names to show |
|
36 | - * @param string $msg=null message to show after submitting the form |
|
37 | - * @param string $email=null comma-separated email addresses |
|
38 | - * @param string $tpl_name=null custom etemplate to use |
|
39 | - * @param string $subject=null subject for email |
|
40 | - * @param string $copytoreceiver=false send a copy of notification to receiver |
|
33 | + * @param array $content submitted eTemplate content |
|
34 | + * @param int $addressbook int owner-id of addressbook to save contacts too |
|
35 | + * @param array $fields field-names to show |
|
36 | + * @param string $tpl_name custom etemplate to use |
|
37 | + * @param string $subject subject for email |
|
38 | + * @param string $copytoreceiver send a copy of notification to receiver |
|
41 | 39 | * @return string html content |
42 | 40 | */ |
43 | 41 | function display(array $content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) |
@@ -49,13 +47,11 @@ discard block |
||
49 | 47 | * Shows the contactform and stores the submitted data ($content is a var parameter, eg. for extending classes) |
50 | 48 | * |
51 | 49 | * @param array &$content=null submitted eTemplate content |
52 | - * @param int $addressbook=null int owner-id of addressbook to save contacts too |
|
53 | - * @param array $fields=null field-names to show |
|
54 | - * @param string $msg=null message to show after submitting the form |
|
55 | - * @param string $email=null comma-separated email addresses |
|
56 | - * @param string $tpl_name=null custom etemplate to use |
|
57 | - * @param string $subject=null subject for email |
|
58 | - * @param string $copytoreceiver=false send a copy of notification to receiver |
|
50 | + * @param int $addressbook int owner-id of addressbook to save contacts too |
|
51 | + * @param array $fields field-names to show |
|
52 | + * @param string $tpl_name custom etemplate to use |
|
53 | + * @param string $subject subject for email |
|
54 | + * @param string $copytoreceiver send a copy of notification to receiver |
|
59 | 55 | * @return string html content |
60 | 56 | */ |
61 | 57 | function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * @param string $copytoreceiver=false send a copy of notification to receiver |
37 | 37 | * @return string html content |
38 | 38 | */ |
39 | - function display(array $content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) |
|
39 | + function display(array $content = null, $addressbook = null, $fields = null, $msg = null, $email = null, $tpl_name = null, $subject = null, $copytoreceiver = false, $sel_options = array()) |
|
40 | 40 | { |
41 | - return $this->display_var($content,$addressbook,$fields,$msg,$email,$tpl_name,$subject,$copytoreceiver,$sel_options); |
|
41 | + return $this->display_var($content, $addressbook, $fields, $msg, $email, $tpl_name, $subject, $copytoreceiver, $sel_options); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -54,23 +54,23 @@ discard block |
||
54 | 54 | * @param string $copytoreceiver=false send a copy of notification to receiver |
55 | 55 | * @return string html content |
56 | 56 | */ |
57 | - function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) |
|
57 | + function display_var(array &$content = null, $addressbook = null, $fields = null, $msg = null, $email = null, $tpl_name = null, $subject = null, $copytoreceiver = false, $sel_options = array()) |
|
58 | 58 | { |
59 | 59 | #error_log( "<p>addressbook_contactform::display(".print_r($content,true).",$addressbook,".print_r($fields,true).",$msg,$tpl_name)</p>\n"); |
60 | - if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name =$content['tpl_form_name']; |
|
60 | + if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name = $content['tpl_form_name']; |
|
61 | 61 | $tpl = new etemplate($tpl_name ? $tpl_name : 'addressbook.contactform'); |
62 | 62 | // initializing some fields |
63 | - if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha'); |
|
63 | + if (!$fields) $fields = array('org_name', 'n_fn', 'email', 'tel_work', 'url', 'note', 'captcha'); |
|
64 | 64 | $submitted = false; |
65 | 65 | // check if submitted |
66 | 66 | if (is_array($content)) |
67 | 67 | { |
68 | - if ((isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) || // no correct captcha OR |
|
69 | - (time() - $content['start_time'] < 10 && // bot indicator (less then 10 sec to fill out the form and |
|
68 | + if ((isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) || // no correct captcha OR |
|
69 | + (time() - $content['start_time'] < 10 && // bot indicator (less then 10 sec to fill out the form and |
|
70 | 70 | !$GLOBALS['egw_info']['etemplate']['java_script'])) // javascript disabled) |
71 | 71 | { |
72 | 72 | $submitted = "truebutfalse"; |
73 | - $tpl->set_validation_error('captcha',lang('Wrong - try again ...')); |
|
73 | + $tpl->set_validation_error('captcha', lang('Wrong - try again ...')); |
|
74 | 74 | } |
75 | 75 | elseif ($content['submitit']) |
76 | 76 | { |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | $contact = new addressbook_bo(); |
79 | 79 | if ($content['owner']) // save the contact in the addressbook |
80 | 80 | { |
81 | - $content['private'] = 0; // in case default_private is set |
|
81 | + $content['private'] = 0; // in case default_private is set |
|
82 | 82 | if (($id = $contact->save($content))) |
83 | 83 | { |
84 | 84 | // check for fileuploads and attach the found files |
85 | - foreach($content as $name => $value) |
|
85 | + foreach ($content as $name => $value) |
|
86 | 86 | { |
87 | 87 | if (is_array($value) && isset($value['tmp_name']) && is_readable($value['tmp_name'])) |
88 | 88 | { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // edit rights for the addressbook used to store the new entry, |
92 | 92 | // which is clearly not wanted securitywise |
93 | 93 | egw_vfs::$is_root = true; |
94 | - egw_link::link('addressbook',$id,egw_link::VFS_APPNAME,$value,$name); |
|
94 | + egw_link::link('addressbook', $id, egw_link::VFS_APPNAME, $value, $name); |
|
95 | 95 | egw_vfs::$is_root = false; |
96 | 96 | } |
97 | 97 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.addressbook_tracking.inc.php'); |
112 | 112 | $tracking = new addressbook_tracking($contact); |
113 | 113 | } |
114 | - if ($tracking->do_notifications($contact->data2db($content),null)) |
|
114 | + if ($tracking->do_notifications($contact->data2db($content), null)) |
|
115 | 115 | { |
116 | 116 | return '<p align="center">'.$content['msg'].'</p>'; |
117 | 117 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $preserv['email_copytoreceiver'] = $copytoreceiver; |
135 | 135 | #if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha'); |
136 | 136 | $custom = 1; |
137 | - foreach($fields as $name) |
|
137 | + foreach ($fields as $name) |
|
138 | 138 | { |
139 | 139 | if ($name[0] == '#') // custom field |
140 | 140 | { |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | } |
146 | 146 | $content['show']['custom'.$custom] = true; |
147 | 147 | $content['customfield'][$custom] = $name; |
148 | - $content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label']; |
|
148 | + $content['customlabel'][$custom] = $contact->customfields[substr($name, 1)]['label']; |
|
149 | 149 | ++$custom; |
150 | 150 | } |
151 | - elseif($name == 'adr_one_locality') |
|
151 | + elseif ($name == 'adr_one_locality') |
|
152 | 152 | { |
153 | 153 | if (!($content['show'][$name] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format'])) |
154 | 154 | { |
@@ -169,18 +169,18 @@ discard block |
||
169 | 169 | unset($content['submitit']); |
170 | 170 | $custom = 1; |
171 | 171 | // fieldnames are "defined" by the commit attempt, that way, we do not have to remember them |
172 | - foreach($content as $name => $value) { |
|
173 | - $preserv[$name]=$value; |
|
172 | + foreach ($content as $name => $value) { |
|
173 | + $preserv[$name] = $value; |
|
174 | 174 | if ($name[0] == '#') // custom field |
175 | 175 | { |
176 | 176 | static $contact; |
177 | 177 | if (is_null($contact)) $contact = new addressbook_bo(); |
178 | 178 | $content['show']['custom'.$custom] = true; |
179 | 179 | $content['customfield'][$custom] = $name; |
180 | - $content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label']; |
|
180 | + $content['customlabel'][$custom] = $contact->customfields[substr($name, 1)]['label']; |
|
181 | 181 | ++$custom; |
182 | 182 | } |
183 | - elseif($name == 'adr_one_locality') |
|
183 | + elseif ($name == 'adr_one_locality') |
|
184 | 184 | { |
185 | 185 | if (!($content['show'][$name] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format'])) |
186 | 186 | { |
@@ -201,17 +201,17 @@ discard block |
||
201 | 201 | if ($msg) $preserv['msg'] = $msg; |
202 | 202 | |
203 | 203 | // a simple calculation captcha |
204 | - $num1 = rand(1,99); |
|
205 | - $num2 = rand(1,99); |
|
204 | + $num1 = rand(1, 99); |
|
205 | + $num2 = rand(1, 99); |
|
206 | 206 | if ($num2 > $num1) // keep the result positive |
207 | 207 | { |
208 | 208 | $n = $num1; $num1 = $num2; $num2 = $n; |
209 | 209 | } |
210 | - if (in_array('captcha',$fields)) |
|
210 | + if (in_array('captcha', $fields)) |
|
211 | 211 | { |
212 | - $content['captcha_task'] = sprintf('%d - %d =',$num1,$num2); |
|
213 | - $preserv['captcha_result'] = $num1-$num2; |
|
212 | + $content['captcha_task'] = sprintf('%d - %d =', $num1, $num2); |
|
213 | + $preserv['captcha_result'] = $num1 - $num2; |
|
214 | 214 | } |
215 | - return $tpl->exec($this->callback,$content,$sel_options,array(),$preserv); |
|
215 | + return $tpl->exec($this->callback, $content, $sel_options, array(), $preserv); |
|
216 | 216 | } |
217 | 217 | } |
@@ -57,28 +57,41 @@ discard block |
||
57 | 57 | function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) |
58 | 58 | { |
59 | 59 | #error_log( "<p>addressbook_contactform::display(".print_r($content,true).",$addressbook,".print_r($fields,true).",$msg,$tpl_name)</p>\n"); |
60 | - if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name =$content['tpl_form_name']; |
|
60 | + if (empty($tpl_name) && !empty($content['tpl_form_name'])) |
|
61 | + { |
|
62 | + $tpl_name =$content['tpl_form_name']; |
|
63 | + } |
|
61 | 64 | $tpl = new etemplate($tpl_name ? $tpl_name : 'addressbook.contactform'); |
62 | 65 | // initializing some fields |
63 | - if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha'); |
|
66 | + if (!$fields) |
|
67 | + { |
|
68 | + $fields = array('org_name','n_fn','email','tel_work','url','note','captcha'); |
|
69 | + } |
|
64 | 70 | $submitted = false; |
65 | 71 | // check if submitted |
66 | 72 | if (is_array($content)) |
67 | 73 | { |
68 | 74 | if ((isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) || // no correct captcha OR |
69 | 75 | (time() - $content['start_time'] < 10 && // bot indicator (less then 10 sec to fill out the form and |
70 | - !$GLOBALS['egw_info']['etemplate']['java_script'])) // javascript disabled) |
|
76 | + !$GLOBALS['egw_info']['etemplate']['java_script'])) |
|
77 | + { |
|
78 | + // javascript disabled) |
|
71 | 79 | { |
72 | 80 | $submitted = "truebutfalse"; |
81 | + } |
|
73 | 82 | $tpl->set_validation_error('captcha',lang('Wrong - try again ...')); |
74 | 83 | } |
75 | 84 | elseif ($content['submitit']) |
76 | 85 | { |
77 | 86 | $submitted = true; |
78 | 87 | $contact = new addressbook_bo(); |
79 | - if ($content['owner']) // save the contact in the addressbook |
|
88 | + if ($content['owner']) |
|
89 | + { |
|
90 | + // save the contact in the addressbook |
|
80 | 91 | { |
81 | - $content['private'] = 0; // in case default_private is set |
|
92 | + $content['private'] = 0; |
|
93 | + } |
|
94 | + // in case default_private is set |
|
82 | 95 | if (($id = $contact->save($content))) |
83 | 96 | { |
84 | 97 | // check for fileuploads and attach the found files |
@@ -136,9 +149,12 @@ discard block |
||
136 | 149 | $custom = 1; |
137 | 150 | foreach($fields as $name) |
138 | 151 | { |
139 | - if ($name[0] == '#') // custom field |
|
152 | + if ($name[0] == '#') |
|
153 | + { |
|
154 | + // custom field |
|
140 | 155 | { |
141 | 156 | static $contact; |
157 | + } |
|
142 | 158 | if (is_null($contact)) |
143 | 159 | { |
144 | 160 | $contact = new addressbook_bo(); |
@@ -169,12 +185,19 @@ discard block |
||
169 | 185 | unset($content['submitit']); |
170 | 186 | $custom = 1; |
171 | 187 | // fieldnames are "defined" by the commit attempt, that way, we do not have to remember them |
172 | - foreach($content as $name => $value) { |
|
188 | + foreach($content as $name => $value) |
|
189 | + { |
|
173 | 190 | $preserv[$name]=$value; |
174 | - if ($name[0] == '#') // custom field |
|
191 | + if ($name[0] == '#') |
|
192 | + { |
|
193 | + // custom field |
|
175 | 194 | { |
176 | 195 | static $contact; |
177 | - if (is_null($contact)) $contact = new addressbook_bo(); |
|
196 | + } |
|
197 | + if (is_null($contact)) |
|
198 | + { |
|
199 | + $contact = new addressbook_bo(); |
|
200 | + } |
|
178 | 201 | $content['show']['custom'.$custom] = true; |
179 | 202 | $content['customfield'][$custom] = $name; |
180 | 203 | $content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label']; |
@@ -197,15 +220,25 @@ discard block |
||
197 | 220 | } |
198 | 221 | $content['addr_format'] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format']; |
199 | 222 | |
200 | - if ($addressbook) $preserv['owner'] = $addressbook; |
|
201 | - if ($msg) $preserv['msg'] = $msg; |
|
223 | + if ($addressbook) |
|
224 | + { |
|
225 | + $preserv['owner'] = $addressbook; |
|
226 | + } |
|
227 | + if ($msg) |
|
228 | + { |
|
229 | + $preserv['msg'] = $msg; |
|
230 | + } |
|
202 | 231 | |
203 | 232 | // a simple calculation captcha |
204 | 233 | $num1 = rand(1,99); |
205 | 234 | $num2 = rand(1,99); |
206 | - if ($num2 > $num1) // keep the result positive |
|
235 | + if ($num2 > $num1) |
|
236 | + { |
|
237 | + // keep the result positive |
|
207 | 238 | { |
208 | - $n = $num1; $num1 = $num2; $num2 = $n; |
|
239 | + $n = $num1; |
|
240 | + } |
|
241 | + $num1 = $num2; $num2 = $n; |
|
209 | 242 | } |
210 | 243 | if (in_array('captcha',$fields)) |
211 | 244 | { |
@@ -44,9 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | /** |
46 | 46 | * imports entries according to given definition object. |
47 | - * @param resource $_stream |
|
48 | - * @param string $_charset |
|
49 | - * @param definition $_definition |
|
47 | + * @param importexport_definition $_definition |
|
50 | 48 | */ |
51 | 49 | public function init(importexport_definition &$_definition ) { |
52 | 50 | |
@@ -84,7 +82,7 @@ discard block |
||
84 | 82 | * |
85 | 83 | * Updates the count of actions taken |
86 | 84 | * |
87 | - * @return boolean success |
|
85 | + * @return null|boolean success |
|
88 | 86 | */ |
89 | 87 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
90 | 88 | { |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | private $bocontacts; |
30 | 30 | |
31 | 31 | /** |
32 | - * For figuring out if a contact has changed |
|
33 | - */ |
|
32 | + * For figuring out if a contact has changed |
|
33 | + */ |
|
34 | 34 | protected $tracking; |
35 | 35 | |
36 | 36 | /** |
@@ -377,39 +377,39 @@ discard block |
||
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
380 | - * Returns warnings that were encountered during importing |
|
381 | - * Maximum of one warning message per record, but you can append if you need to |
|
382 | - * |
|
383 | - * @return Array ( |
|
384 | - * record_# => warning message |
|
385 | - * ) |
|
386 | - */ |
|
387 | - public function get_warnings() { |
|
380 | + * Returns warnings that were encountered during importing |
|
381 | + * Maximum of one warning message per record, but you can append if you need to |
|
382 | + * |
|
383 | + * @return Array ( |
|
384 | + * record_# => warning message |
|
385 | + * ) |
|
386 | + */ |
|
387 | + public function get_warnings() { |
|
388 | 388 | return $this->warnings; |
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
392 | - * Returns errors that were encountered during importing |
|
393 | - * Maximum of one error message per record, but you can append if you need to |
|
394 | - * |
|
395 | - * @return Array ( |
|
396 | - * record_# => error message |
|
397 | - * ) |
|
398 | - */ |
|
399 | - public function get_errors() { |
|
392 | + * Returns errors that were encountered during importing |
|
393 | + * Maximum of one error message per record, but you can append if you need to |
|
394 | + * |
|
395 | + * @return Array ( |
|
396 | + * record_# => error message |
|
397 | + * ) |
|
398 | + */ |
|
399 | + public function get_errors() { |
|
400 | 400 | return $this->errors; |
401 | 401 | } |
402 | 402 | |
403 | 403 | /** |
404 | - * Returns a list of actions taken, and the number of records for that action. |
|
405 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
406 | - * |
|
407 | - * @return Array ( |
|
408 | - * action => record count |
|
409 | - * ) |
|
410 | - */ |
|
411 | - public function get_results() { |
|
412 | - return $this->results; |
|
413 | - } |
|
404 | + * Returns a list of actions taken, and the number of records for that action. |
|
405 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
406 | + * |
|
407 | + * @return Array ( |
|
408 | + * action => record count |
|
409 | + * ) |
|
410 | + */ |
|
411 | + public function get_results() { |
|
412 | + return $this->results; |
|
413 | + } |
|
414 | 414 | } // end of iface_export_plugin |
415 | 415 | ?> |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * class import_csv for addressbook |
16 | 16 | */ |
17 | -class addressbook_import_contacts_csv extends importexport_basic_import_csv { |
|
17 | +class addressbook_import_contacts_csv extends importexport_basic_import_csv { |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * conditions for actions |
21 | 21 | * |
22 | 22 | * @var array |
23 | 23 | */ |
24 | - protected static $conditions = array( 'exists', 'equal' ); |
|
24 | + protected static $conditions = array('exists', 'equal'); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @var bocontacts |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param string $_charset |
46 | 46 | * @param definition $_definition |
47 | 47 | */ |
48 | - public function init(importexport_definition &$_definition ) { |
|
48 | + public function init(importexport_definition&$_definition) { |
|
49 | 49 | |
50 | 50 | // fetch the addressbook bo |
51 | 51 | $this->bocontacts = new addressbook_bo(); |
@@ -56,17 +56,17 @@ discard block |
||
56 | 56 | $this->lookups = array( |
57 | 57 | 'tid' => array('n'=>'contact') |
58 | 58 | ); |
59 | - foreach($this->bocontacts->content_types as $tid => $data) |
|
59 | + foreach ($this->bocontacts->content_types as $tid => $data) |
|
60 | 60 | { |
61 | 61 | $this->lookups['tid'][$tid] = $data['name']; |
62 | 62 | } |
63 | 63 | |
64 | 64 | // set contact owner |
65 | - $contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ? |
|
65 | + $contact_owner = isset($_definition->plugin_options['contact_owner']) ? |
|
66 | 66 | $_definition->plugin_options['contact_owner'] : $this->user; |
67 | 67 | |
68 | 68 | // Import into importer's personal addressbook |
69 | - if($contact_owner == 'personal') |
|
69 | + if ($contact_owner == 'personal') |
|
70 | 70 | { |
71 | 71 | $contact_owner = $this->user; |
72 | 72 | } |
@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return boolean success |
85 | 85 | */ |
86 | - protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
|
86 | + protected function import_record(importexport_iface_egw_record&$record, &$import_csv) |
|
87 | 87 | { |
88 | 88 | |
89 | 89 | // Set owner, unless it's supposed to come from CSV file |
90 | - if($this->definition->plugin_options['owner_from_csv'] && $record->owner) { |
|
91 | - if(!is_numeric($record->owner)) { |
|
90 | + if ($this->definition->plugin_options['owner_from_csv'] && $record->owner) { |
|
91 | + if (!is_numeric($record->owner)) { |
|
92 | 92 | // Automatically handle text owner without explicit translation |
93 | 93 | $new_owner = importexport_helper_functions::account_name2id($record->owner); |
94 | - if($new_owner == '') { |
|
94 | + if ($new_owner == '') { |
|
95 | 95 | $this->errors[$import_csv->get_current_position()] = lang( |
96 | 96 | 'Unable to convert "%1" to account ID. Using plugin setting (%2) for owner.', |
97 | 97 | $record->owner, |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | // Check that owner (addressbook) is allowed |
110 | - if(!array_key_exists($record->owner, $this->bocontacts->get_addressbooks())) |
|
110 | + if (!array_key_exists($record->owner, $this->bocontacts->get_addressbooks())) |
|
111 | 111 | { |
112 | 112 | $this->errors[$import_csv->get_current_position()] = lang("Unable to import into %1, using %2", |
113 | 113 | common::grab_owner_name($record->owner), |
@@ -118,18 +118,18 @@ discard block |
||
118 | 118 | |
119 | 119 | // Do not allow owner == 0 (accounts) without an account_id |
120 | 120 | // It causes the contact to be filed as an account, and can't delete |
121 | - if(!$record->owner && !$record->account_id) |
|
121 | + if (!$record->owner && !$record->account_id) |
|
122 | 122 | { |
123 | 123 | $record->owner = $GLOBALS['egw_info']['user']['account_id']; |
124 | 124 | } |
125 | 125 | |
126 | 126 | // Do not import into non-existing type, warn and change |
127 | - if(!$record->tid || !$this->lookups['tid'][$record->tid]) |
|
127 | + if (!$record->tid || !$this->lookups['tid'][$record->tid]) |
|
128 | 128 | { |
129 | 129 | // Avoid lots of warnings about type (2 types are contact and deleted) |
130 | - if(!$this->type_warned || count($this->lookups['tid']) == 2 ) |
|
130 | + if (!$this->type_warned || count($this->lookups['tid']) == 2) |
|
131 | 131 | { |
132 | - $this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2',$record->tid,lang($this->lookups['tid']['n'])); |
|
132 | + $this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2', $record->tid, lang($this->lookups['tid']['n'])); |
|
133 | 133 | $this->type_warned = true; |
134 | 134 | } |
135 | 135 | $record->tid = 'n'; |
@@ -138,45 +138,45 @@ discard block |
||
138 | 138 | // Also handle categories in their own field |
139 | 139 | $record_array = $record->get_record_array(); |
140 | 140 | $more_categories = array(); |
141 | - foreach($this->definition->plugin_options['field_mapping'] as $number => $field_name) { |
|
142 | - if(!array_key_exists($field_name, $record_array) || |
|
143 | - substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue; |
|
141 | + foreach ($this->definition->plugin_options['field_mapping'] as $number => $field_name) { |
|
142 | + if (!array_key_exists($field_name, $record_array) || |
|
143 | + substr($field_name, 0, 3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue; |
|
144 | 144 | list($cat, $cat_id) = explode('-', $field_name); |
145 | - if(is_numeric($record->$field_name) && $record->$field_name != 1) { |
|
145 | + if (is_numeric($record->$field_name) && $record->$field_name != 1) { |
|
146 | 146 | // Column has a single category ID |
147 | 147 | $more_categories[] = $record->$field_name; |
148 | - } elseif($record->$field_name == '1' || |
|
148 | + } elseif ($record->$field_name == '1' || |
|
149 | 149 | (!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) { |
150 | 150 | // Each category got its own column. '1' is the database value, lang('yes') is the human value |
151 | 151 | $more_categories[] = $cat_id; |
152 | 152 | } else { |
153 | 153 | // Text categories |
154 | - $more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id)); |
|
154 | + $more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',', $record->$field_name), $cat_id)); |
|
155 | 155 | } |
156 | 156 | } |
157 | - if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories); |
|
157 | + if (count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',', $record->cat_id), $more_categories); |
|
158 | 158 | |
159 | 159 | // Private set but missing causes hidden entries |
160 | - if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private); |
|
160 | + if (array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private); |
|
161 | 161 | |
162 | 162 | // Format birthday as backend requires - converter should give timestamp |
163 | - if($record->bday && is_numeric($record->bday)) |
|
163 | + if ($record->bday && is_numeric($record->bday)) |
|
164 | 164 | { |
165 | 165 | $time = new egw_time($record->bday); |
166 | 166 | $record->bday = $time->format('Y-m-d'); |
167 | 167 | } |
168 | 168 | |
169 | - if ( $this->definition->plugin_options['conditions'] ) { |
|
170 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
169 | + if ($this->definition->plugin_options['conditions']) { |
|
170 | + foreach ($this->definition->plugin_options['conditions'] as $condition) { |
|
171 | 171 | $contacts = array(); |
172 | - switch ( $condition['type'] ) { |
|
172 | + switch ($condition['type']) { |
|
173 | 173 | // exists |
174 | 174 | case 'exists' : |
175 | - if($record_array[$condition['string']]) { |
|
176 | - $searchcondition = array( $condition['string'] => $record_array[$condition['string']]); |
|
175 | + if ($record_array[$condition['string']]) { |
|
176 | + $searchcondition = array($condition['string'] => $record_array[$condition['string']]); |
|
177 | 177 | // if we use account_id for the condition, we need to set the owner for filtering, as this |
178 | 178 | // enables addressbook_so to decide what backend is to be used |
179 | - if ($condition['string']=='account_id') $searchcondition['owner']=0; |
|
179 | + if ($condition['string'] == 'account_id') $searchcondition['owner'] = 0; |
|
180 | 180 | $contacts = $this->bocontacts->search( |
181 | 181 | //array( $condition['string'] => $record[$condition['string']],), |
182 | 182 | '', |
@@ -185,37 +185,37 @@ discard block |
||
185 | 185 | $searchcondition |
186 | 186 | ); |
187 | 187 | } |
188 | - if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) { |
|
188 | + if (is_array($contacts) && count(array_keys($contacts)) >= 1) { |
|
189 | 189 | // apply action to all contacts matching this exists condition |
190 | 190 | $action = $condition['true']; |
191 | - foreach ( (array)$contacts as $contact ) { |
|
191 | + foreach ((array)$contacts as $contact) { |
|
192 | 192 | $record->id = $contact['id']; |
193 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
194 | - if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] ); |
|
195 | - if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id ); |
|
196 | - $record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) ); |
|
193 | + if ($this->definition->plugin_options['update_cats'] == 'add') { |
|
194 | + if (!is_array($contact['cat_id'])) $contact['cat_id'] = explode(',', $contact['cat_id']); |
|
195 | + if (!is_array($record_array['cat_id'])) $record->cat_id = explode(',', $record->cat_id); |
|
196 | + $record->cat_id = implode(',', array_unique(array_merge($record->cat_id, $contact['cat_id']))); |
|
197 | 197 | } |
198 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
198 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
199 | 199 | } |
200 | 200 | } else { |
201 | 201 | $action = $condition['false']; |
202 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
202 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
203 | 203 | } |
204 | 204 | break; |
205 | 205 | case 'equal': |
206 | 206 | // Match on field |
207 | 207 | $result = $this->equal($record, $condition, $matches); |
208 | - if($result) |
|
208 | + if ($result) |
|
209 | 209 | { |
210 | 210 | // Apply true action to any matching records found |
211 | 211 | $action = $condition['true']; |
212 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
212 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
213 | 213 | } |
214 | 214 | else |
215 | 215 | { |
216 | 216 | // Apply false action if no matching records found |
217 | 217 | $action = $condition['false']; |
218 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
218 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
219 | 219 | } |
220 | 220 | break; |
221 | 221 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | } |
229 | 229 | } else { |
230 | 230 | // unconditional insert |
231 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
231 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
232 | 232 | } |
233 | 233 | return $success; |
234 | 234 | } |
@@ -240,21 +240,21 @@ discard block |
||
240 | 240 | * @param importexport_iface_egw_record $record contact data for the action |
241 | 241 | * @return bool success or not |
242 | 242 | */ |
243 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) { |
|
243 | + protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0) { |
|
244 | 244 | $_data = $record->get_record_array(); |
245 | 245 | switch ($_action) { |
246 | 246 | case 'none' : |
247 | 247 | return true; |
248 | 248 | case 'delete': |
249 | - if($_data['id']) |
|
249 | + if ($_data['id']) |
|
250 | 250 | { |
251 | - if ( $this->dry_run ) { |
|
251 | + if ($this->dry_run) { |
|
252 | 252 | //print_r($_data); |
253 | 253 | $this->results[$_action]++; |
254 | 254 | return true; |
255 | 255 | } |
256 | 256 | $result = $this->bocontacts->delete($_data); |
257 | - if($result && $result === true) |
|
257 | + if ($result && $result === true) |
|
258 | 258 | { |
259 | 259 | $this->results[$_action]++; |
260 | 260 | } |
@@ -269,13 +269,13 @@ discard block |
||
269 | 269 | // Only update if there are changes |
270 | 270 | $old = $this->bocontacts->read($_data['id']); |
271 | 271 | // if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes. |
272 | - foreach(array('adr_one_', 'adr_two_') as $c_prefix) { |
|
273 | - if (strlen(trim($_data[$c_prefix.'countryname']))==2) $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']),$translated=true); |
|
272 | + foreach (array('adr_one_', 'adr_two_') as $c_prefix) { |
|
273 | + if (strlen(trim($_data[$c_prefix.'countryname'])) == 2) $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), $translated = true); |
|
274 | 274 | } |
275 | 275 | // Don't change a user account into a contact |
276 | - if($old['owner'] == 0) { |
|
276 | + if ($old['owner'] == 0) { |
|
277 | 277 | unset($_data['owner']); |
278 | - } elseif(!$this->definition->plugin_options['change_owner']) { |
|
278 | + } elseif (!$this->definition->plugin_options['change_owner']) { |
|
279 | 279 | // Don't change addressbook of an existing contact |
280 | 280 | unset($_data['owner']); |
281 | 281 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | // Merge to deal with fields not in import record |
284 | 284 | $_data = array_merge($old, $_data); |
285 | 285 | $changed = $this->tracking->changed_fields($_data, $old); |
286 | - if(count($changed) == 0) { |
|
286 | + if (count($changed) == 0) { |
|
287 | 287 | return true; |
288 | 288 | } else { |
289 | 289 | //error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')'); |
@@ -294,22 +294,22 @@ discard block |
||
294 | 294 | |
295 | 295 | // Fall through |
296 | 296 | case 'insert' : |
297 | - if($_action == 'insert') { |
|
297 | + if ($_action == 'insert') { |
|
298 | 298 | // Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag |
299 | 299 | unset($_data['id']); |
300 | 300 | } |
301 | - if(!isset($_data['org_name'])) { |
|
301 | + if (!isset($_data['org_name'])) { |
|
302 | 302 | // org_name is a trigger to update n_fileas |
303 | 303 | $_data['org_name'] = ''; |
304 | 304 | } |
305 | 305 | |
306 | - if ( $this->dry_run ) { |
|
306 | + if ($this->dry_run) { |
|
307 | 307 | //print_r($_data); |
308 | 308 | $this->results[$_action]++; |
309 | 309 | return true; |
310 | 310 | } else { |
311 | - $result = $this->bocontacts->save( $_data, $this->is_admin); |
|
312 | - if(!$result) { |
|
311 | + $result = $this->bocontacts->save($_data, $this->is_admin); |
|
312 | + if (!$result) { |
|
313 | 313 | $this->errors[$record_num] = $this->bocontacts->error; |
314 | 314 | } else { |
315 | 315 | $this->results[$_action]++; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | return $result; |
320 | 320 | } |
321 | 321 | default: |
322 | - throw new egw_exception('Unsupported action: '. $_action); |
|
322 | + throw new egw_exception('Unsupported action: '.$_action); |
|
323 | 323 | |
324 | 324 | } |
325 | 325 | } |
@@ -14,7 +14,8 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * class import_csv for addressbook |
16 | 16 | */ |
17 | -class addressbook_import_contacts_csv extends importexport_basic_import_csv { |
|
17 | +class addressbook_import_contacts_csv extends importexport_basic_import_csv |
|
18 | +{ |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * conditions for actions |
@@ -45,7 +46,8 @@ discard block |
||
45 | 46 | * @param string $_charset |
46 | 47 | * @param definition $_definition |
47 | 48 | */ |
48 | - public function init(importexport_definition &$_definition ) { |
|
49 | + public function init(importexport_definition &$_definition ) |
|
50 | + { |
|
49 | 51 | |
50 | 52 | // fetch the addressbook bo |
51 | 53 | $this->bocontacts = new addressbook_bo(); |
@@ -87,22 +89,29 @@ discard block |
||
87 | 89 | { |
88 | 90 | |
89 | 91 | // Set owner, unless it's supposed to come from CSV file |
90 | - if($this->definition->plugin_options['owner_from_csv'] && $record->owner) { |
|
91 | - if(!is_numeric($record->owner)) { |
|
92 | + if($this->definition->plugin_options['owner_from_csv'] && $record->owner) |
|
93 | + { |
|
94 | + if(!is_numeric($record->owner)) |
|
95 | + { |
|
92 | 96 | // Automatically handle text owner without explicit translation |
93 | 97 | $new_owner = importexport_helper_functions::account_name2id($record->owner); |
94 | - if($new_owner == '') { |
|
98 | + if($new_owner == '') |
|
99 | + { |
|
95 | 100 | $this->errors[$import_csv->get_current_position()] = lang( |
96 | 101 | 'Unable to convert "%1" to account ID. Using plugin setting (%2) for owner.', |
97 | 102 | $record->owner, |
98 | 103 | common::grab_owner_name($this->user) |
99 | 104 | ); |
100 | 105 | $record->owner = $this->user; |
101 | - } else { |
|
106 | + } |
|
107 | + else |
|
108 | + { |
|
102 | 109 | $record->owner = $new_owner; |
103 | 110 | } |
104 | 111 | } |
105 | - } else { |
|
112 | + } |
|
113 | + else |
|
114 | + { |
|
106 | 115 | $record->owner = $this->user; |
107 | 116 | } |
108 | 117 | |
@@ -138,26 +147,41 @@ discard block |
||
138 | 147 | // Also handle categories in their own field |
139 | 148 | $record_array = $record->get_record_array(); |
140 | 149 | $more_categories = array(); |
141 | - foreach($this->definition->plugin_options['field_mapping'] as $number => $field_name) { |
|
150 | + foreach($this->definition->plugin_options['field_mapping'] as $number => $field_name) |
|
151 | + { |
|
142 | 152 | if(!array_key_exists($field_name, $record_array) || |
143 | - substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue; |
|
153 | + substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') |
|
154 | + { |
|
155 | + continue; |
|
156 | + } |
|
144 | 157 | list($cat, $cat_id) = explode('-', $field_name); |
145 | - if(is_numeric($record->$field_name) && $record->$field_name != 1) { |
|
158 | + if(is_numeric($record->$field_name) && $record->$field_name != 1) |
|
159 | + { |
|
146 | 160 | // Column has a single category ID |
147 | 161 | $more_categories[] = $record->$field_name; |
148 | - } elseif($record->$field_name == '1' || |
|
149 | - (!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) { |
|
162 | + } |
|
163 | + elseif($record->$field_name == '1' || |
|
164 | + (!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) |
|
165 | + { |
|
150 | 166 | // Each category got its own column. '1' is the database value, lang('yes') is the human value |
151 | 167 | $more_categories[] = $cat_id; |
152 | - } else { |
|
168 | + } |
|
169 | + else |
|
170 | + { |
|
153 | 171 | // Text categories |
154 | 172 | $more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id)); |
155 | 173 | } |
156 | 174 | } |
157 | - if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories); |
|
175 | + if(count($more_categories) > 0) |
|
176 | + { |
|
177 | + $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories); |
|
178 | + } |
|
158 | 179 | |
159 | 180 | // Private set but missing causes hidden entries |
160 | - if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private); |
|
181 | + if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) |
|
182 | + { |
|
183 | + unset($record->private); |
|
184 | + } |
|
161 | 185 | |
162 | 186 | // Format birthday as backend requires - converter should give timestamp |
163 | 187 | if($record->bday && is_numeric($record->bday)) |
@@ -166,17 +190,24 @@ discard block |
||
166 | 190 | $record->bday = $time->format('Y-m-d'); |
167 | 191 | } |
168 | 192 | |
169 | - if ( $this->definition->plugin_options['conditions'] ) { |
|
170 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
193 | + if ( $this->definition->plugin_options['conditions'] ) |
|
194 | + { |
|
195 | + foreach ( $this->definition->plugin_options['conditions'] as $condition ) |
|
196 | + { |
|
171 | 197 | $contacts = array(); |
172 | - switch ( $condition['type'] ) { |
|
198 | + switch ( $condition['type'] ) |
|
199 | + { |
|
173 | 200 | // exists |
174 | 201 | case 'exists' : |
175 | - if($record_array[$condition['string']]) { |
|
202 | + if($record_array[$condition['string']]) |
|
203 | + { |
|
176 | 204 | $searchcondition = array( $condition['string'] => $record_array[$condition['string']]); |
177 | 205 | // if we use account_id for the condition, we need to set the owner for filtering, as this |
178 | 206 | // enables addressbook_so to decide what backend is to be used |
179 | - if ($condition['string']=='account_id') $searchcondition['owner']=0; |
|
207 | + if ($condition['string']=='account_id') |
|
208 | + { |
|
209 | + $searchcondition['owner']=0; |
|
210 | + } |
|
180 | 211 | $contacts = $this->bocontacts->search( |
181 | 212 | //array( $condition['string'] => $record[$condition['string']],), |
182 | 213 | '', |
@@ -185,19 +216,30 @@ discard block |
||
185 | 216 | $searchcondition |
186 | 217 | ); |
187 | 218 | } |
188 | - if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) { |
|
219 | + if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) |
|
220 | + { |
|
189 | 221 | // apply action to all contacts matching this exists condition |
190 | 222 | $action = $condition['true']; |
191 | - foreach ( (array)$contacts as $contact ) { |
|
223 | + foreach ( (array)$contacts as $contact ) |
|
224 | + { |
|
192 | 225 | $record->id = $contact['id']; |
193 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
194 | - if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] ); |
|
195 | - if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id ); |
|
226 | + if ( $this->definition->plugin_options['update_cats'] == 'add' ) |
|
227 | + { |
|
228 | + if ( !is_array( $contact['cat_id'] ) ) |
|
229 | + { |
|
230 | + $contact['cat_id'] = explode( ',', $contact['cat_id'] ); |
|
231 | + } |
|
232 | + if ( !is_array( $record_array['cat_id'] ) ) |
|
233 | + { |
|
234 | + $record->cat_id = explode( ',', $record->cat_id ); |
|
235 | + } |
|
196 | 236 | $record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) ); |
197 | 237 | } |
198 | 238 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
199 | 239 | } |
200 | - } else { |
|
240 | + } |
|
241 | + else |
|
242 | + { |
|
201 | 243 | $action = $condition['false']; |
202 | 244 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
203 | 245 | } |
@@ -224,9 +266,14 @@ discard block |
||
224 | 266 | die('condition / action not supported!!!'); |
225 | 267 | break; |
226 | 268 | } |
227 | - if ($action['stop']) break; |
|
269 | + if ($action['stop']) |
|
270 | + { |
|
271 | + break; |
|
272 | + } |
|
228 | 273 | } |
229 | - } else { |
|
274 | + } |
|
275 | + else |
|
276 | + { |
|
230 | 277 | // unconditional insert |
231 | 278 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
232 | 279 | } |
@@ -240,15 +287,18 @@ discard block |
||
240 | 287 | * @param importexport_iface_egw_record $record contact data for the action |
241 | 288 | * @return bool success or not |
242 | 289 | */ |
243 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) { |
|
290 | + protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
|
291 | + { |
|
244 | 292 | $_data = $record->get_record_array(); |
245 | - switch ($_action) { |
|
293 | + switch ($_action) |
|
294 | + { |
|
246 | 295 | case 'none' : |
247 | 296 | return true; |
248 | 297 | case 'delete': |
249 | 298 | if($_data['id']) |
250 | 299 | { |
251 | - if ( $this->dry_run ) { |
|
300 | + if ( $this->dry_run ) |
|
301 | + { |
|
252 | 302 | //print_r($_data); |
253 | 303 | $this->results[$_action]++; |
254 | 304 | return true; |
@@ -269,13 +319,20 @@ discard block |
||
269 | 319 | // Only update if there are changes |
270 | 320 | $old = $this->bocontacts->read($_data['id']); |
271 | 321 | // if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes. |
272 | - foreach(array('adr_one_', 'adr_two_') as $c_prefix) { |
|
273 | - if (strlen(trim($_data[$c_prefix.'countryname']))==2) $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']),$translated=true); |
|
322 | + foreach(array('adr_one_', 'adr_two_') as $c_prefix) |
|
323 | + { |
|
324 | + if (strlen(trim($_data[$c_prefix.'countryname']))==2) |
|
325 | + { |
|
326 | + $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']),$translated=true); |
|
327 | + } |
|
274 | 328 | } |
275 | 329 | // Don't change a user account into a contact |
276 | - if($old['owner'] == 0) { |
|
330 | + if($old['owner'] == 0) |
|
331 | + { |
|
277 | 332 | unset($_data['owner']); |
278 | - } elseif(!$this->definition->plugin_options['change_owner']) { |
|
333 | + } |
|
334 | + elseif(!$this->definition->plugin_options['change_owner']) |
|
335 | + { |
|
279 | 336 | // Don't change addressbook of an existing contact |
280 | 337 | unset($_data['owner']); |
281 | 338 | } |
@@ -283,9 +340,12 @@ discard block |
||
283 | 340 | // Merge to deal with fields not in import record |
284 | 341 | $_data = array_merge($old, $_data); |
285 | 342 | $changed = $this->tracking->changed_fields($_data, $old); |
286 | - if(count($changed) == 0) { |
|
343 | + if(count($changed) == 0) |
|
344 | + { |
|
287 | 345 | return true; |
288 | - } else { |
|
346 | + } |
|
347 | + else |
|
348 | + { |
|
289 | 349 | //error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')'); |
290 | 350 | } |
291 | 351 | |
@@ -294,24 +354,32 @@ discard block |
||
294 | 354 | |
295 | 355 | // Fall through |
296 | 356 | case 'insert' : |
297 | - if($_action == 'insert') { |
|
357 | + if($_action == 'insert') |
|
358 | + { |
|
298 | 359 | // Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag |
299 | 360 | unset($_data['id']); |
300 | 361 | } |
301 | - if(!isset($_data['org_name'])) { |
|
362 | + if(!isset($_data['org_name'])) |
|
363 | + { |
|
302 | 364 | // org_name is a trigger to update n_fileas |
303 | 365 | $_data['org_name'] = ''; |
304 | 366 | } |
305 | 367 | |
306 | - if ( $this->dry_run ) { |
|
368 | + if ( $this->dry_run ) |
|
369 | + { |
|
307 | 370 | //print_r($_data); |
308 | 371 | $this->results[$_action]++; |
309 | 372 | return true; |
310 | - } else { |
|
373 | + } |
|
374 | + else |
|
375 | + { |
|
311 | 376 | $result = $this->bocontacts->save( $_data, $this->is_admin); |
312 | - if(!$result) { |
|
377 | + if(!$result) |
|
378 | + { |
|
313 | 379 | $this->errors[$record_num] = $this->bocontacts->error; |
314 | - } else { |
|
380 | + } |
|
381 | + else |
|
382 | + { |
|
315 | 383 | $this->results[$_action]++; |
316 | 384 | // This does nothing (yet?) but update the identifier |
317 | 385 | $record->save($result); |
@@ -329,7 +397,8 @@ discard block |
||
329 | 397 | * |
330 | 398 | * @return string name |
331 | 399 | */ |
332 | - public static function get_name() { |
|
400 | + public static function get_name() |
|
401 | + { |
|
333 | 402 | return lang('Addressbook CSV import'); |
334 | 403 | } |
335 | 404 | |
@@ -338,7 +407,8 @@ discard block |
||
338 | 407 | * |
339 | 408 | * @return string descriprion |
340 | 409 | */ |
341 | - public static function get_description() { |
|
410 | + public static function get_description() |
|
411 | + { |
|
342 | 412 | return lang("Imports contacts into your Addressbook from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators."); |
343 | 413 | } |
344 | 414 | |
@@ -347,7 +417,8 @@ discard block |
||
347 | 417 | * |
348 | 418 | * @return string suffix (comma seperated) |
349 | 419 | */ |
350 | - public static function get_filesuffix() { |
|
420 | + public static function get_filesuffix() |
|
421 | + { |
|
351 | 422 | return 'csv'; |
352 | 423 | } |
353 | 424 | |
@@ -363,7 +434,8 @@ discard block |
||
363 | 434 | * preserv => array, |
364 | 435 | * ) |
365 | 436 | */ |
366 | - public function get_options_etpl() { |
|
437 | + public function get_options_etpl() |
|
438 | + { |
|
367 | 439 | // lets do it! |
368 | 440 | } |
369 | 441 | |
@@ -372,7 +444,8 @@ discard block |
||
372 | 444 | * |
373 | 445 | * @return string etemplate name |
374 | 446 | */ |
375 | - public function get_selectors_etpl() { |
|
447 | + public function get_selectors_etpl() |
|
448 | + { |
|
376 | 449 | // lets do it! |
377 | 450 | } |
378 | 451 | |
@@ -384,7 +457,8 @@ discard block |
||
384 | 457 | * record_# => warning message |
385 | 458 | * ) |
386 | 459 | */ |
387 | - public function get_warnings() { |
|
460 | + public function get_warnings() |
|
461 | + { |
|
388 | 462 | return $this->warnings; |
389 | 463 | } |
390 | 464 | |
@@ -396,7 +470,8 @@ discard block |
||
396 | 470 | * record_# => error message |
397 | 471 | * ) |
398 | 472 | */ |
399 | - public function get_errors() { |
|
473 | + public function get_errors() |
|
474 | + { |
|
400 | 475 | return $this->errors; |
401 | 476 | } |
402 | 477 | |
@@ -408,7 +483,8 @@ discard block |
||
408 | 483 | * action => record count |
409 | 484 | * ) |
410 | 485 | */ |
411 | - public function get_results() { |
|
486 | + public function get_results() |
|
487 | + { |
|
412 | 488 | return $this->results; |
413 | 489 | } |
414 | 490 | } // end of iface_export_plugin |
@@ -255,11 +255,10 @@ |
||
255 | 255 | * |
256 | 256 | * @param type $action |
257 | 257 | * @param type $checked |
258 | - * @param type $use_all |
|
259 | 258 | * @param type $success |
260 | 259 | * @param int $failed |
261 | 260 | * @param type $action_msg |
262 | - * @return type number of failed |
|
261 | + * @return boolean number of failed |
|
263 | 262 | */ |
264 | 263 | function action($action,$checked,&$success,&$failed,&$action_msg) |
265 | 264 | { |
@@ -67,9 +67,13 @@ discard block |
||
67 | 67 | { |
68 | 68 | $heartbeat_limit = Api\Session::heartbeat_limit(); |
69 | 69 | |
70 | - if ($query['session_list']) // filter active sessions |
|
70 | + if ($query['session_list']) |
|
71 | + { |
|
72 | + // filter active sessions |
|
71 | 73 | { |
72 | - $query['col_filter']['lo'] = null; // not logged out |
|
74 | + $query['col_filter']['lo'] = null; |
|
75 | + } |
|
76 | + // not logged out |
|
73 | 77 | $query['col_filter'][0] = 'session_dla > '.(int)(time() - $GLOBALS['egw_info']['server']['sessions_timeout']); |
74 | 78 | switch((string)$query['session_list']) |
75 | 79 | { |
@@ -100,12 +104,16 @@ discard block |
||
100 | 104 | { |
101 | 105 | $row['sessionstatus'] = $row['session_php']; |
102 | 106 | } |
103 | - if ($row['lo']) { |
|
107 | + if ($row['lo']) |
|
108 | + { |
|
104 | 109 | $row['total'] = ($row['lo'] - $row['li']) / 60; |
105 | 110 | $row['sessionstatus'] = 'logged out'; |
106 | 111 | } |
107 | 112 | // eg. for bad login or password |
108 | - if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none')); |
|
113 | + if (!$row['account_id']) |
|
114 | + { |
|
115 | + $row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none')); |
|
116 | + } |
|
109 | 117 | |
110 | 118 | // do not allow to kill or select own session |
111 | 119 | if ($GLOBALS['egw']->session->sessionid_access_log == $row['sessionid'] && $query['session_list']) |
@@ -142,7 +150,10 @@ discard block |
||
142 | 150 | function index(array $content=null, $msg='', $sessions_list=false) |
143 | 151 | { |
144 | 152 | |
145 | - if (is_array($content)) $sessions_list = $content['nm']['session_list']; |
|
153 | + if (is_array($content)) |
|
154 | + { |
|
155 | + $sessions_list = $content['nm']['session_list']; |
|
156 | + } |
|
146 | 157 | |
147 | 158 | // check if user has access to requested functionality |
148 | 159 | if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces',1,'admin')) |
@@ -215,7 +226,8 @@ discard block |
||
215 | 226 | $success = $failed = $action = $action_msg = null; |
216 | 227 | if ($this->action($content['nm']['action'],$content['nm']['selected'] |
217 | 228 | ,$success,$failed,$action_msg,$msg)) |
218 | - { // In case of action success |
|
229 | + { |
|
230 | +// In case of action success |
|
219 | 231 | switch ($action_msg) |
220 | 232 | { |
221 | 233 | case'deleted': |
@@ -225,12 +237,15 @@ discard block |
||
225 | 237 | $msg = lang('%1 sessions killed',$success); |
226 | 238 | } |
227 | 239 | } |
228 | - elseif($failed) // In case of action failiure |
|
240 | + elseif($failed) |
|
241 | + { |
|
242 | + // In case of action failiure |
|
229 | 243 | { |
230 | 244 | switch ($action_msg) |
231 | 245 | { |
232 | 246 | case'deleted': |
233 | 247 | $msg = lang('Error deleting log entry!'); |
248 | + } |
|
234 | 249 | break; |
235 | 250 | case'killed': |
236 | 251 | $msg = lang('Permission denied!'); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | function __construct() |
49 | 49 | { |
50 | - $this->so = new so_sql(self::APP,self::TABLE,null,'',true); |
|
50 | + $this->so = new so_sql(self::APP, self::TABLE, null, '', true); |
|
51 | 51 | $this->so->timestamps = array('li', 'lo', 'session_dla', 'notification_heartbeat'); |
52 | 52 | } |
53 | 53 | |
@@ -60,19 +60,19 @@ discard block |
||
60 | 60 | * @param array &$readonlys eg. to disable buttons based on acl, not use here, maybe in a derived class |
61 | 61 | * @return int total number of rows |
62 | 62 | */ |
63 | - function get_rows($query,&$rows,&$readonlys) |
|
63 | + function get_rows($query, &$rows, &$readonlys) |
|
64 | 64 | { |
65 | 65 | $heartbeat_limit = egw_session::heartbeat_limit(); |
66 | 66 | |
67 | 67 | if ($query['session_list']) // filter active sessions |
68 | 68 | { |
69 | - $query['col_filter']['lo'] = null; // not logged out |
|
69 | + $query['col_filter']['lo'] = null; // not logged out |
|
70 | 70 | $query['col_filter'][0] = 'session_dla > '.(int)(time() - $GLOBALS['egw_info']['server']['sessions_timeout']); |
71 | - switch((string)$query['session_list']) |
|
71 | + switch ((string)$query['session_list']) |
|
72 | 72 | { |
73 | 73 | case 'active': // remove status != 'active', eg. CalDAV/eSync |
74 | 74 | $query['col_filter'][1] = "notification_heartbeat > $heartbeat_limit"; |
75 | - $query['col_filter'][3] = "session_php NOT LIKE '% %'"; // remove blocked, bad login, etc |
|
75 | + $query['col_filter'][3] = "session_php NOT LIKE '% %'"; // remove blocked, bad login, etc |
|
76 | 76 | break; |
77 | 77 | default: |
78 | 78 | $query['col_filter'][1] = "(notification_heartbeat IS NULL OR notification_heartbeat > $heartbeat_limit)"; |
@@ -80,20 +80,20 @@ discard block |
||
80 | 80 | } |
81 | 81 | $query['col_filter'][2] = 'account_id>0'; |
82 | 82 | } |
83 | - $total = $this->so->get_rows($query,$rows,$readonlys); |
|
83 | + $total = $this->so->get_rows($query, $rows, $readonlys); |
|
84 | 84 | |
85 | 85 | $heartbeat_limit_user = egw_time::server2user($heartbeat_limit, 'ts'); |
86 | 86 | |
87 | - foreach($rows as &$row) |
|
87 | + foreach ($rows as &$row) |
|
88 | 88 | { |
89 | 89 | $row['sessionstatus'] = 'success'; |
90 | 90 | if ($row['notification_heartbeat'] > $heartbeat_limit_user) |
91 | 91 | { |
92 | 92 | $row['sessionstatus'] = 'active'; |
93 | 93 | } |
94 | - if (stripos($row['session_php'],'blocked') !== false || |
|
95 | - stripos($row['session_php'],'bad login') !== false || |
|
96 | - strpos($row['session_php'],' ') !== false) |
|
94 | + if (stripos($row['session_php'], 'blocked') !== false || |
|
95 | + stripos($row['session_php'], 'bad login') !== false || |
|
96 | + strpos($row['session_php'], ' ') !== false) |
|
97 | 97 | { |
98 | 98 | $row['sessionstatus'] = $row['session_php']; |
99 | 99 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $row['sessionstatus'] = 'logged out'; |
103 | 103 | } |
104 | 104 | // eg. for bad login or password |
105 | - if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none')); |
|
105 | + if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid'] ? $row['loginid'] : lang('none')); |
|
106 | 106 | |
107 | 107 | // do not allow to kill or select own session |
108 | 108 | if ($GLOBALS['egw']->session->sessionid_access_log == $row['sessionid'] && $query['session_list']) |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | $row['class'] .= ' rowNoDelete '; |
111 | 111 | } |
112 | 112 | // do not allow to delete access log off active sessions |
113 | - if (!$row['lo'] && $row['session_dla'] > time()-$GLOBALS['egw_info']['server']['sessions_timeout'] && |
|
113 | + if (!$row['lo'] && $row['session_dla'] > time() - $GLOBALS['egw_info']['server']['sessions_timeout'] && |
|
114 | 114 | in_array($row['sessionstatus'], array('active', 'success')) && !$query['session_list']) |
115 | 115 | { |
116 | 116 | $row['class'] .= ' rowNoDelete '; |
117 | 117 | } |
118 | 118 | $row['sessionstatus'] = lang($row['sessionstatus']); |
119 | - unset($row['session_php']); // for security reasons, do NOT give real PHP sessionid to UI |
|
119 | + unset($row['session_php']); // for security reasons, do NOT give real PHP sessionid to UI |
|
120 | 120 | } |
121 | 121 | if ($query['session_list']) |
122 | 122 | { |
@@ -136,33 +136,33 @@ discard block |
||
136 | 136 | * @param string $msg ='' |
137 | 137 | * @param boolean $sessions_list =false |
138 | 138 | */ |
139 | - function index(array $content=null, $msg='', $sessions_list=false) |
|
139 | + function index(array $content = null, $msg = '', $sessions_list = false) |
|
140 | 140 | { |
141 | 141 | |
142 | 142 | if (is_array($content)) $sessions_list = $content['nm']['session_list']; |
143 | 143 | |
144 | 144 | // check if user has access to requested functionality |
145 | - if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces',1,'admin')) |
|
145 | + if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces', 1, 'admin')) |
|
146 | 146 | { |
147 | 147 | $GLOBALS['egw']->redirect_link('/index.php'); |
148 | 148 | } |
149 | 149 | |
150 | - if(!isset($content)) |
|
150 | + if (!isset($content)) |
|
151 | 151 | { |
152 | 152 | $content['nm'] = array( |
153 | - 'get_rows' => 'admin.admin_accesslog.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
154 | - 'no_filter' => True, // I disable the 1. filter |
|
155 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
156 | - 'no_cat' => True, // I disable the cat-selectbox |
|
157 | - 'header_left' => false, // I template to show left of the range-value, left-aligned (optional) |
|
158 | - 'header_right' => false, // I template to show right of the range-value, right-aligned (optional) |
|
159 | - 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entries |
|
160 | - 'lettersearch' => false, // I show a lettersearch |
|
161 | - 'start' => 0, // IO position in list |
|
162 | - 'order' => 'li', // IO name of the column to sort after (optional for the sortheaders) |
|
163 | - 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
153 | + 'get_rows' => 'admin.admin_accesslog.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
154 | + 'no_filter' => True, // I disable the 1. filter |
|
155 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
156 | + 'no_cat' => True, // I disable the cat-selectbox |
|
157 | + 'header_left' => false, // I template to show left of the range-value, left-aligned (optional) |
|
158 | + 'header_right' => false, // I template to show right of the range-value, right-aligned (optional) |
|
159 | + 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entries |
|
160 | + 'lettersearch' => false, // I show a lettersearch |
|
161 | + 'start' => 0, // IO position in list |
|
162 | + 'order' => 'li', // IO name of the column to sort after (optional for the sortheaders) |
|
163 | + 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
164 | 164 | //'default_cols' => // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
165 | - 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
|
165 | + 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
|
166 | 166 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
167 | 167 | 'actions' => $this->get_actions($sessions_list), |
168 | 168 | 'placeholder_actions' => false, |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | 'col_filter' => $content['nm']['col_filter'] |
194 | 194 | ); |
195 | 195 | |
196 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
197 | - $query['num_rows'] = -1; // all |
|
196 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
197 | + $query['num_rows'] = -1; // all |
|
198 | 198 | $all = $readonlys = array(); |
199 | - $this->get_rows($query,$all,$readonlys); |
|
199 | + $this->get_rows($query, $all, $readonlys); |
|
200 | 200 | $content['nm']['selected'] = array(); |
201 | - foreach($all as $session) |
|
201 | + foreach ($all as $session) |
|
202 | 202 | { |
203 | 203 | $content['nm']['selected'][] = $session[$content['nm']['row_id']]; |
204 | 204 | } |
@@ -210,19 +210,19 @@ discard block |
||
210 | 210 | else |
211 | 211 | { |
212 | 212 | $success = $failed = $action = $action_msg = null; |
213 | - if ($this->action($content['nm']['action'],$content['nm']['selected'] |
|
214 | - ,$success,$failed,$action_msg,$msg)) |
|
213 | + if ($this->action($content['nm']['action'], $content['nm']['selected'] |
|
214 | + ,$success, $failed, $action_msg, $msg)) |
|
215 | 215 | { // In case of action success |
216 | 216 | switch ($action_msg) |
217 | 217 | { |
218 | 218 | case'deleted': |
219 | - $msg = lang('%1 log entries deleted.',$success); |
|
219 | + $msg = lang('%1 log entries deleted.', $success); |
|
220 | 220 | break; |
221 | 221 | case'killed': |
222 | - $msg = lang('%1 sessions killed',$success); |
|
222 | + $msg = lang('%1 sessions killed', $success); |
|
223 | 223 | } |
224 | 224 | } |
225 | - elseif($failed) // In case of action failiure |
|
225 | + elseif ($failed) // In case of action failiure |
|
226 | 226 | { |
227 | 227 | switch ($action_msg) |
228 | 228 | { |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $content['msg'] = $msg; |
240 | 240 | $content['percent'] = 100.0 * $GLOBALS['egw']->db->query( |
241 | 241 | 'SELECT ((SELECT COUNT(*) FROM '.self::TABLE.' WHERE lo != 0) / COUNT(*)) FROM '.self::TABLE, |
242 | - __LINE__,__FILE__)->fetchColumn(); |
|
242 | + __LINE__, __FILE__)->fetchColumn(); |
|
243 | 243 | |
244 | 244 | $tmpl = new etemplate_new('admin.accesslog'); |
245 | 245 | $tmpl->exec('admin.admin_accesslog.index', $content, array(), $readonlys, array( |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @param type $action_msg |
259 | 259 | * @return type number of failed |
260 | 260 | */ |
261 | - function action($action,$checked,&$success,&$failed,&$action_msg) |
|
261 | + function action($action, $checked, &$success, &$failed, &$action_msg) |
|
262 | 262 | { |
263 | 263 | $success = $failed = 0; |
264 | 264 | //error_log(__METHOD__.'selected:' . array2string($checked). 'action:' . $action); |
@@ -266,14 +266,14 @@ discard block |
||
266 | 266 | { |
267 | 267 | case "delete": |
268 | 268 | $action_msg = "deleted"; |
269 | - $del_msg= $this->so->delete(array('sessionid' => $checked)); |
|
269 | + $del_msg = $this->so->delete(array('sessionid' => $checked)); |
|
270 | 270 | if ($checked && $del_msg) |
271 | 271 | { |
272 | 272 | $success = $del_msg; |
273 | 273 | } |
274 | 274 | else |
275 | 275 | { |
276 | - $failed ++; |
|
276 | + $failed++; |
|
277 | 277 | } |
278 | 278 | break; |
279 | 279 | case "kill": |
@@ -281,19 +281,19 @@ discard block |
||
281 | 281 | $sessionid = $checked; |
282 | 282 | if (($key = array_search($GLOBALS['egw']->session->sessionid_access_log, $sessionid))) |
283 | 283 | { |
284 | - unset($sessionid[$key]); // dont allow to kill own sessions |
|
284 | + unset($sessionid[$key]); // dont allow to kill own sessions |
|
285 | 285 | } |
286 | - if ($GLOBALS['egw']->acl->check('current_sessions',8,'admin')) |
|
286 | + if ($GLOBALS['egw']->acl->check('current_sessions', 8, 'admin')) |
|
287 | 287 | { |
288 | - $failed ++; |
|
288 | + $failed++; |
|
289 | 289 | } |
290 | 290 | else |
291 | 291 | { |
292 | - foreach((array)$sessionid as $id) |
|
292 | + foreach ((array)$sessionid as $id) |
|
293 | 293 | { |
294 | 294 | $GLOBALS['egw']->session->destroy($id); |
295 | 295 | } |
296 | - $success= count($sessionid); |
|
296 | + $success = count($sessionid); |
|
297 | 297 | } |
298 | 298 | break; |
299 | 299 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | if ($sessions_list) |
314 | 314 | { |
315 | 315 | // error_log(__METHOD__. $sessions_list); |
316 | - $actions= array( |
|
316 | + $actions = array( |
|
317 | 317 | 'kill' => array( |
318 | 318 | 'caption' => 'Kill', |
319 | 319 | 'confirm' => 'Kill this session', |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | } |
327 | 327 | else |
328 | 328 | { |
329 | - $actions= array( |
|
329 | + $actions = array( |
|
330 | 330 | 'delete' => array( |
331 | 331 | 'caption' => 'Delete', |
332 | 332 | 'confirm' => 'Delete this entry', |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @param array $content =null |
359 | 359 | * @param string $msg ='' |
360 | 360 | */ |
361 | - function sessions(array $content=null, $msg='') |
|
361 | + function sessions(array $content = null, $msg = '') |
|
362 | 362 | { |
363 | 363 | return $this->index($content, $msg, true); |
364 | 364 | } |
@@ -679,6 +679,8 @@ |
||
679 | 679 | * @param int &$failed number of failed actions (not enought permissions) |
680 | 680 | * @param string &$action_msg translated verb for the actions, to be used in a message like '%1 entries deleted' |
681 | 681 | * @param array $query get_rows parameter |
682 | + * @param integer $success |
|
683 | + * @param integer $failed |
|
682 | 684 | * @return boolean true if all actions succeded, false otherwise |
683 | 685 | */ |
684 | 686 | function action($_action, $checked, $use_all, &$success, &$failed, &$action_msg, array $query) |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | throw new egw_exception_no_permission_admin(); |
59 | 59 | } |
60 | - if ($GLOBALS['egw']->acl->check('global_categorie',1,'admin')) |
|
60 | + if ($GLOBALS['egw']->acl->check('global_categorie', 1, 'admin')) |
|
61 | 61 | { |
62 | 62 | $GLOBALS['egw']->redirect_link('/index.php'); |
63 | 63 | } |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | { |
72 | 72 | if (is_null(self::$acl_search)) |
73 | 73 | { |
74 | - self::$acl_search = !$GLOBALS['egw']->acl->check('global_categorie',2,'admin'); |
|
75 | - self::$acl_add = !$GLOBALS['egw']->acl->check('global_categorie',4,'admin'); |
|
76 | - self::$acl_view = !$GLOBALS['egw']->acl->check('global_categorie',8,'admin'); |
|
77 | - self::$acl_edit = !$GLOBALS['egw']->acl->check('global_categorie',16,'admin'); |
|
78 | - self::$acl_delete = !$GLOBALS['egw']->acl->check('global_categorie',32,'admin'); |
|
79 | - self::$acl_add_sub= !$GLOBALS['egw']->acl->check('global_categorie',64,'admin'); |
|
74 | + self::$acl_search = !$GLOBALS['egw']->acl->check('global_categorie', 2, 'admin'); |
|
75 | + self::$acl_add = !$GLOBALS['egw']->acl->check('global_categorie', 4, 'admin'); |
|
76 | + self::$acl_view = !$GLOBALS['egw']->acl->check('global_categorie', 8, 'admin'); |
|
77 | + self::$acl_edit = !$GLOBALS['egw']->acl->check('global_categorie', 16, 'admin'); |
|
78 | + self::$acl_delete = !$GLOBALS['egw']->acl->check('global_categorie', 32, 'admin'); |
|
79 | + self::$acl_add_sub = !$GLOBALS['egw']->acl->check('global_categorie', 64, 'admin'); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | * @param array $content = null |
87 | 87 | * @param string $msg = '' |
88 | 88 | */ |
89 | - public function edit(array $content=null,$msg='') |
|
89 | + public function edit(array $content = null, $msg = '') |
|
90 | 90 | { |
91 | 91 | // read the session, as the global_cats param is stored with it. |
92 | - $appname = $content['appname'] ? $content['appname'] : ($_GET['appname']?$_GET['appname']:categories::GLOBAL_APPNAME); |
|
93 | - $session = egw_cache::getSession(__CLASS__.$appname,'nm'); |
|
92 | + $appname = $content['appname'] ? $content['appname'] : ($_GET['appname'] ? $_GET['appname'] : categories::GLOBAL_APPNAME); |
|
93 | + $session = egw_cache::getSession(__CLASS__.$appname, 'nm'); |
|
94 | 94 | unset($session); |
95 | 95 | if (!isset($content)) |
96 | 96 | { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | ($content = categories::read($_GET['cat_id'])))) |
99 | 99 | { |
100 | 100 | $content = array('data' => array()); |
101 | - if(isset($_GET['parent']) && $_GET['parent'] > 0) |
|
101 | + if (isset($_GET['parent']) && $_GET['parent'] > 0) |
|
102 | 102 | { |
103 | 103 | // Sub-category - set some defaults from parent |
104 | 104 | $content['parent'] = (int)$_GET['parent']; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $appname = categories::GLOBAL_APPNAME; |
115 | 115 | } |
116 | 116 | } |
117 | - elseif ($content['appname'] != $appname || !self::$acl_edit || ( $content['owner'] != $GLOBALS['egw_info']['user']['account_id'] && $this->appname != 'admin')) |
|
117 | + elseif ($content['appname'] != $appname || !self::$acl_edit || ($content['owner'] != $GLOBALS['egw_info']['user']['account_id'] && $this->appname != 'admin')) |
|
118 | 118 | { |
119 | 119 | // only allow to view category |
120 | 120 | $readonlys['__ALL__'] = true; |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | } |
125 | 125 | elseif ($content['button'] || $content['delete']) |
126 | 126 | { |
127 | - $cats = new categories($content['owner'] ? $content['owner'] : categories::GLOBAL_ACCOUNT,$content['appname']); |
|
127 | + $cats = new categories($content['owner'] ? $content['owner'] : categories::GLOBAL_ACCOUNT, $content['appname']); |
|
128 | 128 | |
129 | 129 | if ($content['delete']['delete'] || $content['delete']['subs']) |
130 | 130 | { |
131 | 131 | $button = 'delete'; |
132 | - $delete_subs = $content['delete']['subs']?true:false; |
|
132 | + $delete_subs = $content['delete']['subs'] ? true : false; |
|
133 | 133 | } |
134 | 134 | else |
135 | 135 | { |
@@ -140,29 +140,29 @@ discard block |
||
140 | 140 | |
141 | 141 | $refresh_app = $this->appname == 'preferences' ? $content['appname'] : $this->appname; |
142 | 142 | |
143 | - switch($button) |
|
143 | + switch ($button) |
|
144 | 144 | { |
145 | 145 | case 'save': |
146 | 146 | case 'apply': |
147 | - if(is_array($content['owner'])) $content['owner'] = implode(',',$content['owner']); |
|
148 | - if($content['owner'] == '') $content['owner'] = 0; |
|
147 | + if (is_array($content['owner'])) $content['owner'] = implode(',', $content['owner']); |
|
148 | + if ($content['owner'] == '') $content['owner'] = 0; |
|
149 | 149 | if ($content['id'] && self::$acl_edit) |
150 | 150 | { |
151 | 151 | |
152 | 152 | // If color changed, we need to do an edit 'refresh' instead of 'update' |
153 | 153 | // to reload the whole nextmatch instead of just the row |
154 | - $data = $cats->id2name($content['id'],'data'); |
|
154 | + $data = $cats->id2name($content['id'], 'data'); |
|
155 | 155 | $change_color = ($data['color'] != $content['data']['color']); |
156 | 156 | // Nicely reload just the category window / iframe |
157 | - if($change_color) |
|
157 | + if ($change_color) |
|
158 | 158 | { |
159 | - if(egw_json_response::isJSONResponse()) |
|
159 | + if (egw_json_response::isJSONResponse()) |
|
160 | 160 | { |
161 | 161 | // Update category styles |
162 | - egw_json_response::get()->apply('opener.egw.includeCSS',array(categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app))); |
|
163 | - if($this->appname != 'admin') |
|
162 | + egw_json_response::get()->apply('opener.egw.includeCSS', array(categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app))); |
|
163 | + if ($this->appname != 'admin') |
|
164 | 164 | { |
165 | - egw_json_response::get()->apply('opener.egw.show_preferences',array( |
|
165 | + egw_json_response::get()->apply('opener.egw.show_preferences', array( |
|
166 | 166 | 'cats', |
167 | 167 | $this->appname == 'admin' ? categories::GLOBAL_APPNAME : array($refresh_app) |
168 | 168 | )); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | else |
172 | 172 | { |
173 | 173 | categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app); |
174 | - egw_json_response::get()->apply('opener.app.admin.load',array( |
|
174 | + egw_json_response::get()->apply('opener.app.admin.load', array( |
|
175 | 175 | egw_framework::link('/index.php', array( |
176 | 176 | 'menuaction' => $this->list_link, |
177 | 177 | 'appname' => $appname |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | } |
193 | 193 | catch (egw_exception_wrong_userinput $e) |
194 | 194 | { |
195 | - $msg = lang('Unwilling to save category with current settings. Check for inconsistency:').$e->getMessage(); // display conflicts etc. |
|
195 | + $msg = lang('Unwilling to save category with current settings. Check for inconsistency:').$e->getMessage(); // display conflicts etc. |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | elseif (!$content['id'] && ( |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | case 'delete': |
218 | 218 | if (self::$acl_delete) |
219 | 219 | { |
220 | - $cats->delete($content['id'],$delete_subs,!$delete_subs); |
|
220 | + $cats->delete($content['id'], $delete_subs, !$delete_subs); |
|
221 | 221 | $msg = lang('Category deleted.'); |
222 | 222 | |
223 | - egw_framework::refresh_opener($msg, $refresh_app, $content['id'],'delete', $this->appname); |
|
223 | + egw_framework::refresh_opener($msg, $refresh_app, $content['id'], 'delete', $this->appname); |
|
224 | 224 | egw_framework::window_close(); |
225 | 225 | return; |
226 | 226 | } |
@@ -234,19 +234,19 @@ discard block |
||
234 | 234 | egw_framework::refresh_opener($msg, $change_color ? null : $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname); |
235 | 235 | } |
236 | 236 | $content['msg'] = $msg; |
237 | - if(!$content['appname']) $content['appname'] = $appname; |
|
238 | - if($content['data']['icon']) |
|
237 | + if (!$content['appname']) $content['appname'] = $appname; |
|
238 | + if ($content['data']['icon']) |
|
239 | 239 | { |
240 | - $content['icon_url'] = $content['base_url'] . $content['data']['icon']; |
|
240 | + $content['icon_url'] = $content['base_url'].$content['data']['icon']; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | $sel_options['icon'] = self::get_icons(); |
244 | 244 | $sel_options['owner'] = array(); |
245 | 245 | |
246 | 246 | // User's category - add current value to be able to preserve owner |
247 | - if(!$content['id']) |
|
247 | + if (!$content['id']) |
|
248 | 248 | { |
249 | - if($this->appname != 'admin') |
|
249 | + if ($this->appname != 'admin') |
|
250 | 250 | { |
251 | 251 | $content['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
252 | 252 | } |
@@ -256,35 +256,35 @@ discard block |
||
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | - if($this->appname != 'admin' && $content['owner'] > 0 ) |
|
259 | + if ($this->appname != 'admin' && $content['owner'] > 0) |
|
260 | 260 | { |
261 | 261 | $sel_options['owner'][$content['owner']] = common::grab_owner_name($content['owner']); |
262 | 262 | } |
263 | 263 | // Add 'All users', in case owner is readonlys |
264 | - if($content['id'] && $content['owner'] == 0) |
|
264 | + if ($content['id'] && $content['owner'] == 0) |
|
265 | 265 | { |
266 | 266 | $sel_options['owner'][0] = lang('All users'); |
267 | 267 | } |
268 | - if($this->appname == 'admin' || ($content['id'] && !((int)$content['owner'] > 0))) |
|
268 | + if ($this->appname == 'admin' || ($content['id'] && !((int)$content['owner'] > 0))) |
|
269 | 269 | { |
270 | - if($content['owner'] > 0) |
|
270 | + if ($content['owner'] > 0) |
|
271 | 271 | { |
272 | 272 | $content['msg'] .= "\n".lang('owner "%1" removed, please select group-owner', common::grab_owner_name($content['owner'])); |
273 | 273 | $content['owner'] = 0; |
274 | 274 | } |
275 | 275 | $sel_options['owner'][0] = lang('All users'); |
276 | 276 | $accs = $GLOBALS['egw']->accounts->get_list('groups'); |
277 | - foreach($accs as $acc) |
|
277 | + foreach ($accs as $acc) |
|
278 | 278 | { |
279 | 279 | if ($acc['account_type'] == 'g') |
280 | 280 | { |
281 | - $sel_options['owner'][$acc['account_id']] = ExecMethod2('etemplate.select_widget.accountInfo',$acc['account_id'],$acc); |
|
281 | + $sel_options['owner'][$acc['account_id']] = ExecMethod2('etemplate.select_widget.accountInfo', $acc['account_id'], $acc); |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | $content['no_private'] = true; |
285 | 285 | } |
286 | 286 | |
287 | - if($this->appname == 'admin') |
|
287 | + if ($this->appname == 'admin') |
|
288 | 288 | { |
289 | 289 | $content['access'] = 'public'; |
290 | 290 | // Allow admins access to all categories as parent |
@@ -295,17 +295,17 @@ discard block |
||
295 | 295 | $readonlys['access'] = $content['owner'] != $GLOBALS['egw_info']['user']['account_id']; |
296 | 296 | } |
297 | 297 | |
298 | - egw_framework::validate_file('.','global_categories','admin'); |
|
298 | + egw_framework::validate_file('.', 'global_categories', 'admin'); |
|
299 | 299 | |
300 | - $readonlys['button[delete]'] = !$content['id'] || !self::$acl_delete || // cant delete not yet saved category |
|
300 | + $readonlys['button[delete]'] = !$content['id'] || !self::$acl_delete || // cant delete not yet saved category |
|
301 | 301 | $appname != $content['appname'] || // Can't edit a category from a different app |
302 | 302 | ($this->appname != 'admin' && $content['owner'] != $GLOBALS['egw_info']['user']['account_id']); |
303 | 303 | // Make sure $content['owner'] is an array otherwise it wont show up values in the multiselectbox |
304 | - if (!is_array($content['owner'])) $content['owner'] = explode(',',$content['owner']); |
|
304 | + if (!is_array($content['owner'])) $content['owner'] = explode(',', $content['owner']); |
|
305 | 305 | $tmpl = new etemplate_new('admin.categories.edit'); |
306 | - $tmpl->exec($this->edit_link,$content,$sel_options,$readonlys,$content+array( |
|
306 | + $tmpl->exec($this->edit_link, $content, $sel_options, $readonlys, $content + array( |
|
307 | 307 | 'old_parent' => $content['old_parent'] ? $content['old_parent'] : $content['parent'], 'appname' => $appname |
308 | - ),2); |
|
308 | + ), 2); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * @param string $icon = '' filename |
315 | 315 | * @return string url |
316 | 316 | */ |
317 | - static function icon_url($icon='') |
|
317 | + static function icon_url($icon = '') |
|
318 | 318 | { |
319 | 319 | return $GLOBALS['egw_info']['server']['webserver_url'].self::ICON_PATH.'/'.$icon; |
320 | 320 | } |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | $dir = dir(EGW_SERVER_ROOT.self::ICON_PATH); |
330 | 330 | $icons = array(); |
331 | 331 | $matches = null; |
332 | - while(($file = $dir->read())) |
|
332 | + while (($file = $dir->read())) |
|
333 | 333 | { |
334 | - if (preg_match('/^(.*)\\.(png|gif|jpe?g)$/i',$file,$matches)) |
|
334 | + if (preg_match('/^(.*)\\.(png|gif|jpe?g)$/i', $file, $matches)) |
|
335 | 335 | { |
336 | 336 | $icons[$file] = ucfirst($matches[1]); |
337 | 337 | } |
@@ -350,13 +350,13 @@ discard block |
||
350 | 350 | * @param array &$readonlys eg. to disable buttons based on acl, not use here, maybe in a derived class |
351 | 351 | * @return int total number of rows |
352 | 352 | */ |
353 | - public function get_rows(&$query,&$rows,&$readonlys) |
|
353 | + public function get_rows(&$query, &$rows, &$readonlys) |
|
354 | 354 | { |
355 | 355 | self::init_static(); |
356 | 356 | |
357 | 357 | $filter = array(); |
358 | 358 | $globalcat = ($query['filter'] === categories::GLOBAL_ACCOUNT || !$query['filter']); |
359 | - if (isset($query['global_cats']) && $query['global_cats']===false) |
|
359 | + if (isset($query['global_cats']) && $query['global_cats'] === false) |
|
360 | 360 | { |
361 | 361 | $globalcat = false; |
362 | 362 | } |
@@ -364,49 +364,49 @@ discard block |
||
364 | 364 | // new column-filter access has highest priority |
365 | 365 | if (!empty($query['col_filter']['access']))$filter['access'] = $query['col_filter']['access']; |
366 | 366 | |
367 | - egw_cache::setSession(__CLASS__.$query['appname'],'nm',$query); |
|
367 | + egw_cache::setSession(__CLASS__.$query['appname'], 'nm', $query); |
|
368 | 368 | |
369 | - if($query['filter'] > 0 || $query['col_filter']['owner']) |
|
369 | + if ($query['filter'] > 0 || $query['col_filter']['owner']) |
|
370 | 370 | { |
371 | 371 | $owner = $query['col_filter']['owner'] ? $query['col_filter']['owner'] : $query['filter']; |
372 | 372 | } |
373 | - if($query['col_filter']['app']) |
|
373 | + if ($query['col_filter']['app']) |
|
374 | 374 | { |
375 | 375 | $filter['appname'] = $query['col_filter']['app']; |
376 | 376 | } |
377 | - $GLOBALS['egw']->categories = $cats = new categories($filter['owner'],$query['appname']); |
|
378 | - $globals = isset($GLOBALS['egw_info']['user']['apps']['admin']) ? 'all_no_acl' : $globalcat; // ignore acl only for admins |
|
377 | + $GLOBALS['egw']->categories = $cats = new categories($filter['owner'], $query['appname']); |
|
378 | + $globals = isset($GLOBALS['egw_info']['user']['apps']['admin']) ? 'all_no_acl' : $globalcat; // ignore acl only for admins |
|
379 | 379 | $parent = $query['search'] ? false : 0; |
380 | - $rows = $cats->return_sorted_array($query['start'],false,$query['search'],$query['sort'],$query['order'],$globals,$parent,true,$filter); |
|
380 | + $rows = $cats->return_sorted_array($query['start'], false, $query['search'], $query['sort'], $query['order'], $globals, $parent, true, $filter); |
|
381 | 381 | $count = $cats->total_records; |
382 | - foreach($rows as $key => &$row) |
|
382 | + foreach ($rows as $key => &$row) |
|
383 | 383 | { |
384 | - $row['owner'] = explode(',',$row['owner']); |
|
385 | - if(($owner && !in_array($owner, $row['owner'])) || ((string)$query['filter'] === (string)categories::GLOBAL_ACCOUNT && $row['owner'][0] > 0)) |
|
384 | + $row['owner'] = explode(',', $row['owner']); |
|
385 | + if (($owner && !in_array($owner, $row['owner'])) || ((string)$query['filter'] === (string)categories::GLOBAL_ACCOUNT && $row['owner'][0] > 0)) |
|
386 | 386 | { |
387 | 387 | unset($rows[$key]); |
388 | 388 | $count--; |
389 | 389 | continue; |
390 | 390 | } |
391 | 391 | |
392 | - $row['level_spacer'] = str_repeat(' ',$row['level']); |
|
392 | + $row['level_spacer'] = str_repeat(' ', $row['level']); |
|
393 | 393 | |
394 | 394 | if ($row['data']['icon']) $row['icon_url'] = self::icon_url($row['data']['icon']); |
395 | 395 | |
396 | 396 | $row['subs'] = count($row['children']); |
397 | 397 | |
398 | 398 | $row['class'] = 'level'.$row['level']; |
399 | - if($row['owner'][0] > 0 && !$GLOBALS['egw_info']['user']['apps']['admin'] && $row['owner'][0] != $GLOBALS['egw_info']['user']['account_id']) |
|
399 | + if ($row['owner'][0] > 0 && !$GLOBALS['egw_info']['user']['apps']['admin'] && $row['owner'][0] != $GLOBALS['egw_info']['user']['account_id']) |
|
400 | 400 | { |
401 | 401 | $row['class'] .= ' rowNoEdit rowNoDelete '; |
402 | 402 | } |
403 | 403 | else if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
404 | 404 | { |
405 | - if(!$cats->check_perms(EGW_ACL_EDIT, $row['id']) || !self::$acl_edit) |
|
405 | + if (!$cats->check_perms(EGW_ACL_EDIT, $row['id']) || !self::$acl_edit) |
|
406 | 406 | { |
407 | 407 | $row['class'] .= ' rowNoEdit'; |
408 | 408 | } |
409 | - if(!$cats->check_perms(EGW_ACL_DELETE, $row['id']) || !self::$acl_delete || |
|
409 | + if (!$cats->check_perms(EGW_ACL_DELETE, $row['id']) || !self::$acl_delete || |
|
410 | 410 | // Only admins can delete globals |
411 | 411 | $cats->is_global($row['id']) && !$GLOBALS['egw_info']['user']['apps']['admin']) |
412 | 412 | { |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | } |
415 | 415 | } |
416 | 416 | // Can only edit (via context menu) categories for the selected app (backend restriction) |
417 | - if($row['appname'] != $query['appname'] || (array_sum($row['owner']) > 0)) |
|
417 | + if ($row['appname'] != $query['appname'] || (array_sum($row['owner']) > 0)) |
|
418 | 418 | { |
419 | 419 | $row['class'] .= ' rowNoEdit '; |
420 | 420 | } |
@@ -442,60 +442,60 @@ discard block |
||
442 | 442 | * @param array $content = null |
443 | 443 | * @param string $msg = '' |
444 | 444 | */ |
445 | - public function index(array $content=null,$msg='') |
|
445 | + public function index(array $content = null, $msg = '') |
|
446 | 446 | { |
447 | 447 | //_debug_array($_GET); |
448 | - if ($this->appname != 'admin') translation::add_app('admin'); // need admin translations |
|
448 | + if ($this->appname != 'admin') translation::add_app('admin'); // need admin translations |
|
449 | 449 | |
450 | - if(!isset($content)) |
|
450 | + if (!isset($content)) |
|
451 | 451 | { |
452 | 452 | if (isset($_GET['msg'])) $msg = $_GET['msg']; |
453 | 453 | |
454 | 454 | $appname = categories::GLOBAL_APPNAME; |
455 | - foreach(array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field) |
|
455 | + foreach (array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field) |
|
456 | 456 | { |
457 | - if($field) |
|
457 | + if ($field) |
|
458 | 458 | { |
459 | 459 | $appname = $field; |
460 | 460 | break; |
461 | 461 | } |
462 | 462 | } |
463 | - $content['nm'] = egw_cache::getSession(__CLASS__.$appname,'nm'); |
|
463 | + $content['nm'] = egw_cache::getSession(__CLASS__.$appname, 'nm'); |
|
464 | 464 | if (!is_array($content['nm'])) |
465 | 465 | { |
466 | 466 | $content['nm'] = array( |
467 | - 'get_rows' => $this->get_rows, // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
467 | + 'get_rows' => $this->get_rows, // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
468 | 468 | 'options-filter' => array( |
469 | 469 | '' => lang('All categories'), |
470 | 470 | categories::GLOBAL_ACCOUNT => lang('Global categories'), |
471 | 471 | $GLOBALS['egw_info']['user']['account_id'] => lang('Own categories'), |
472 | 472 | ), |
473 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
474 | - 'no_cat' => True, // I disable the cat-selectbox |
|
475 | - 'header_left' => false, // I template to show left of the range-value, left-aligned (optional) |
|
476 | - 'header_right' => false, // I template to show right of the range-value, right-aligned (optional) |
|
477 | - 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entries |
|
478 | - 'lettersearch' => false, // I show a lettersearch |
|
479 | - 'start' => 0, // IO position in list |
|
480 | - 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
481 | - 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
482 | - 'default_cols' => '!color,last_mod,subs,legacy_actions', // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
|
483 | - 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
|
473 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
474 | + 'no_cat' => True, // I disable the cat-selectbox |
|
475 | + 'header_left' => false, // I template to show left of the range-value, left-aligned (optional) |
|
476 | + 'header_right' => false, // I template to show right of the range-value, right-aligned (optional) |
|
477 | + 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entries |
|
478 | + 'lettersearch' => false, // I show a lettersearch |
|
479 | + 'start' => 0, // IO position in list |
|
480 | + 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
481 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
482 | + 'default_cols' => '!color,last_mod,subs,legacy_actions', // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
|
483 | + 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
|
484 | 484 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
485 | 485 | 'no_search' => !self::$acl_search, |
486 | 486 | 'row_id' => 'id', |
487 | 487 | 'dataStorePrefix' => 'categories' // Avoid conflict with user list when in admin |
488 | 488 | ); |
489 | - $content['nm']['filter'] = $this->appname == 'admin'?categories::GLOBAL_ACCOUNT:$GLOBALS['egw_info']['user']['account_id']; |
|
489 | + $content['nm']['filter'] = $this->appname == 'admin' ? categories::GLOBAL_ACCOUNT : $GLOBALS['egw_info']['user']['account_id']; |
|
490 | 490 | } |
491 | 491 | else |
492 | 492 | { |
493 | - $content['nm']['start']=0; |
|
493 | + $content['nm']['start'] = 0; |
|
494 | 494 | } |
495 | 495 | $content['nm']['appname'] = $appname = $_GET['appname'] ? $_GET['appname'] : $appname; |
496 | 496 | $content['nm']['actions'] = $this->get_actions($appname); |
497 | 497 | // switch filter off for super-global categories |
498 | - if($appname == 'phpgw') |
|
498 | + if ($appname == 'phpgw') |
|
499 | 499 | { |
500 | 500 | $content['nm']['no_filter'] = true; |
501 | 501 | // Make sure filter is set properly, could be different if user was looking at something else |
@@ -503,18 +503,18 @@ discard block |
||
503 | 503 | } |
504 | 504 | |
505 | 505 | $content['nm']['global_cats'] = true; |
506 | - if (isset($_GET['global_cats']) && empty($_GET['global_cats'] )) |
|
506 | + if (isset($_GET['global_cats']) && empty($_GET['global_cats'])) |
|
507 | 507 | { |
508 | 508 | $content['nm']['global_cats'] = false; |
509 | 509 | } |
510 | 510 | } |
511 | - elseif($content['nm']['action']) |
|
511 | + elseif ($content['nm']['action']) |
|
512 | 512 | { |
513 | 513 | $appname = $content['nm']['appname']; |
514 | 514 | // Old buttons |
515 | - foreach(array('delete') as $button) |
|
515 | + foreach (array('delete') as $button) |
|
516 | 516 | { |
517 | - if(isset($content['nm']['rows'][$button])) |
|
517 | + if (isset($content['nm']['rows'][$button])) |
|
518 | 518 | { |
519 | 519 | list($id) = @each($content['nm']['rows'][$button]); |
520 | 520 | $content['nm']['action'] = $button; |
@@ -529,39 +529,39 @@ discard block |
||
529 | 529 | else |
530 | 530 | { |
531 | 531 | // Action has an additional action - add / delete, etc. Buttons named <multi-action>_action[action_name] |
532 | - if(in_array($content['nm']['action'], array('owner'))) |
|
532 | + if (in_array($content['nm']['action'], array('owner'))) |
|
533 | 533 | { |
534 | 534 | $action = $content['nm']['action']; |
535 | 535 | if ($content[$action.'_popup']) |
536 | 536 | { |
537 | - $content = array_merge($content,$content[$action.'_popup']); |
|
537 | + $content = array_merge($content, $content[$action.'_popup']); |
|
538 | 538 | } |
539 | - $content['nm']['action'] .= '_' . key($content[$action . '_action']); |
|
539 | + $content['nm']['action'] .= '_'.key($content[$action.'_action']); |
|
540 | 540 | |
541 | - if(is_array($content[$action])) |
|
541 | + if (is_array($content[$action])) |
|
542 | 542 | { |
543 | - $content[$action] = implode(',',$content[$action]); |
|
543 | + $content[$action] = implode(',', $content[$action]); |
|
544 | 544 | } |
545 | - $content['nm']['action'] .= '_' . $content[$action]; |
|
545 | + $content['nm']['action'] .= '_'.$content[$action]; |
|
546 | 546 | } |
547 | 547 | $success = $failed = 0; |
548 | 548 | $action_msg = null; |
549 | - if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'], |
|
550 | - $success,$failed,$action_msg,$content['nm'])) |
|
549 | + if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'], |
|
550 | + $success, $failed, $action_msg, $content['nm'])) |
|
551 | 551 | { |
552 | - $msg .= lang('%1 category(s) %2',$success,$action_msg); |
|
552 | + $msg .= lang('%1 category(s) %2', $success, $action_msg); |
|
553 | 553 | } |
554 | - elseif(empty($msg)) |
|
554 | + elseif (empty($msg)) |
|
555 | 555 | { |
556 | - $msg .= lang('%1 category(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
556 | + $msg .= lang('%1 category(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
557 | 557 | } |
558 | 558 | egw_framework::refresh_opener($msg, $this->appname); |
559 | 559 | $msg = ''; |
560 | 560 | } |
561 | 561 | } |
562 | 562 | $content['msg'] = $msg; |
563 | - $content['nm']['add_link']= egw_framework::link('/index.php','menuaction='.$this->add_link . '&cat_id=&appname='.$appname); |
|
564 | - $content['edit_link']= $this->edit_link.'&appname='.$appname; |
|
563 | + $content['nm']['add_link'] = egw_framework::link('/index.php', 'menuaction='.$this->add_link.'&cat_id=&appname='.$appname); |
|
564 | + $content['edit_link'] = $this->edit_link.'&appname='.$appname; |
|
565 | 565 | $content['owner'] = ''; |
566 | 566 | |
567 | 567 | $sel_options['appname'] = $this->get_app_list(); |
@@ -576,39 +576,39 @@ discard block |
||
576 | 576 | |
577 | 577 | $sel_options['owner'][0] = lang('All users'); |
578 | 578 | $accs = $GLOBALS['egw']->accounts->get_list('groups'); |
579 | - foreach($accs as $acc) |
|
579 | + foreach ($accs as $acc) |
|
580 | 580 | { |
581 | 581 | if ($acc['account_type'] == 'g') |
582 | 582 | { |
583 | - $sel_options['owner'][$acc['account_id']] = ExecMethod2('etemplate.select_widget.accountInfo',$acc['account_id'],$acc); |
|
583 | + $sel_options['owner'][$acc['account_id']] = ExecMethod2('etemplate.select_widget.accountInfo', $acc['account_id'], $acc); |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | 587 | $readonlys['add'] = !self::$acl_add; |
588 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
588 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
589 | 589 | { |
590 | 590 | $readonlys['nm']['rows']['owner'] = true; |
591 | 591 | $readonlys['nm']['col_filter']['owner'] = true; |
592 | 592 | } |
593 | - if($appname == categories::GLOBAL_APPNAME) { |
|
593 | + if ($appname == categories::GLOBAL_APPNAME) { |
|
594 | 594 | $sel_options['app'] = array(''=>''); |
595 | 595 | $readonlys['nm']['rows']['app'] = true; |
596 | 596 | } |
597 | 597 | |
598 | 598 | $tmpl = new etemplate_new('admin.categories.index'); |
599 | 599 | |
600 | - if($tmpl instanceof etemplate_widget_template) |
|
600 | + if ($tmpl instanceof etemplate_widget_template) |
|
601 | 601 | { |
602 | 602 | // Category styles |
603 | 603 | categories::css($appname); |
604 | 604 | } |
605 | 605 | |
606 | - $tmpl->exec($this->list_link,$content,$sel_options,$readonlys,array( |
|
606 | + $tmpl->exec($this->list_link, $content, $sel_options, $readonlys, array( |
|
607 | 607 | 'nm' => $content['nm'], |
608 | 608 | )); |
609 | 609 | } |
610 | 610 | |
611 | - protected function get_actions($appname=categories::GLOBAL_APPNAME) { |
|
611 | + protected function get_actions($appname = categories::GLOBAL_APPNAME) { |
|
612 | 612 | |
613 | 613 | $actions = array( |
614 | 614 | 'open' => array( // does edit if allowed, otherwise view |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | 'allowOnMultiple' => false, |
618 | 618 | 'url' => 'menuaction='.$this->edit_link.'&cat_id=$id&appname='.$appname, |
619 | 619 | 'popup' => '600x380', |
620 | - 'group' => $group=1, |
|
620 | + 'group' => $group = 1, |
|
621 | 621 | ), |
622 | 622 | 'add' => array( |
623 | 623 | 'caption' => 'Add', |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | ), |
653 | 653 | ); |
654 | 654 | |
655 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
655 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
656 | 656 | { |
657 | 657 | unset($actions['owner']); |
658 | 658 | } |
@@ -678,14 +678,14 @@ discard block |
||
678 | 678 | $success = $failed = 0; |
679 | 679 | if ($use_all) |
680 | 680 | { |
681 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
682 | - $query['num_rows'] = -1; // all |
|
681 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
682 | + $query['num_rows'] = -1; // all |
|
683 | 683 | $result = $readonlys = array(); |
684 | - $this->get_rows($query,$result,$readonlys); |
|
684 | + $this->get_rows($query, $result, $readonlys); |
|
685 | 685 | $checked = array(); |
686 | - foreach($result as $key => $info) |
|
686 | + foreach ($result as $key => $info) |
|
687 | 687 | { |
688 | - if(is_numeric($key)) |
|
688 | + if (is_numeric($key)) |
|
689 | 689 | { |
690 | 690 | $checked[] = $info['id']; |
691 | 691 | } |
@@ -693,19 +693,19 @@ discard block |
||
693 | 693 | } |
694 | 694 | $owner = $query['col_filter']['owner'] ? $query['col_filter']['owner'] : $query['filter']; |
695 | 695 | $app = $query['col_filter']['app'] ? $query['col_filter']['app'] : $query['appname']; |
696 | - $cats = new categories($owner,$app); |
|
696 | + $cats = new categories($owner, $app); |
|
697 | 697 | |
698 | 698 | list($action, $settings) = explode('_', $_action, 2); |
699 | 699 | |
700 | - switch($action) |
|
700 | + switch ($action) |
|
701 | 701 | { |
702 | 702 | case 'delete': |
703 | 703 | $action_msg = lang('deleted'); |
704 | - foreach($checked as $id) |
|
704 | + foreach ($checked as $id) |
|
705 | 705 | { |
706 | - if($cats->check_perms(EGW_ACL_DELETE, $id, (boolean)$GLOBALS['egw_info']['user']['apps']['admin'])) |
|
706 | + if ($cats->check_perms(EGW_ACL_DELETE, $id, (boolean)$GLOBALS['egw_info']['user']['apps']['admin'])) |
|
707 | 707 | { |
708 | - $cats->delete($id,$settings == 'sub',$settings != 'sub'); |
|
708 | + $cats->delete($id, $settings == 'sub', $settings != 'sub'); |
|
709 | 709 | $success++; |
710 | 710 | } |
711 | 711 | else |
@@ -719,20 +719,19 @@ discard block |
||
719 | 719 | list($add_remove, $ids_csv) = explode('_', $settings, 2); |
720 | 720 | $ids = explode(',', $ids_csv); |
721 | 721 | // Adding 'All users' removes all the others |
722 | - if($add_remove == 'add' && array_search(categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(categories::GLOBAL_ACCOUNT); |
|
722 | + if ($add_remove == 'add' && array_search(categories::GLOBAL_ACCOUNT, $ids) !== false) $ids = array(categories::GLOBAL_ACCOUNT); |
|
723 | 723 | |
724 | - foreach($checked as $id) |
|
724 | + foreach ($checked as $id) |
|
725 | 725 | { |
726 | 726 | if (!$data = $cats->read($id)) continue; |
727 | - $data['owner'] = explode(',',$data['owner']); |
|
728 | - if(array_search(categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0) |
|
727 | + $data['owner'] = explode(',', $data['owner']); |
|
728 | + if (array_search(categories::GLOBAL_ACCOUNT, $data['owner']) !== false || $data['owner'][0] > 0) |
|
729 | 729 | { |
730 | 730 | $data['owner'] = array(); |
731 | 731 | } |
732 | 732 | $data['owner'] = $add_remove == 'add' ? |
733 | - $ids == array(categories::GLOBAL_ACCOUNT) ? $ids : array_merge($data['owner'],$ids) : |
|
734 | - array_diff($data['owner'],$ids); |
|
735 | - $data['owner'] = implode(',',array_unique($data['owner'])); |
|
733 | + $ids == array(categories::GLOBAL_ACCOUNT) ? $ids : array_merge($data['owner'], $ids) : array_diff($data['owner'], $ids); |
|
734 | + $data['owner'] = implode(',', array_unique($data['owner'])); |
|
736 | 735 | |
737 | 736 | if ($cats->edit($data)) |
738 | 737 | { |
@@ -763,7 +762,7 @@ discard block |
||
763 | 762 | continue; |
764 | 763 | } |
765 | 764 | // Skip apps that don't show in the app bar, they [usually] don't have categories |
766 | - if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue; |
|
765 | + if ($data['status'] > 1 || in_array($app, array('home', 'admin', 'felamimail', 'sitemgr', 'sitemgr-link'))) continue; |
|
767 | 766 | if ($GLOBALS['egw_info']['user']['apps'][$app]) |
768 | 767 | { |
769 | 768 | $apps[$app] = $data['title'] ? $data['title'] : lang($app); |
@@ -144,8 +144,14 @@ discard block |
||
144 | 144 | { |
145 | 145 | case 'save': |
146 | 146 | case 'apply': |
147 | - if(is_array($content['owner'])) $content['owner'] = implode(',',$content['owner']); |
|
148 | - if($content['owner'] == '') $content['owner'] = 0; |
|
147 | + if(is_array($content['owner'])) |
|
148 | + { |
|
149 | + $content['owner'] = implode(',',$content['owner']); |
|
150 | + } |
|
151 | + if($content['owner'] == '') |
|
152 | + { |
|
153 | + $content['owner'] = 0; |
|
154 | + } |
|
149 | 155 | if ($content['id'] && self::$acl_edit) |
150 | 156 | { |
151 | 157 | |
@@ -234,7 +240,10 @@ discard block |
||
234 | 240 | egw_framework::refresh_opener($msg, $change_color ? null : $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname); |
235 | 241 | } |
236 | 242 | $content['msg'] = $msg; |
237 | - if(!$content['appname']) $content['appname'] = $appname; |
|
243 | + if(!$content['appname']) |
|
244 | + { |
|
245 | + $content['appname'] = $appname; |
|
246 | + } |
|
238 | 247 | if($content['data']['icon']) |
239 | 248 | { |
240 | 249 | $content['icon_url'] = $content['base_url'] . $content['data']['icon']; |
@@ -290,7 +299,9 @@ discard block |
||
290 | 299 | // Allow admins access to all categories as parent |
291 | 300 | $content['all_cats'] = 'all_no_acl'; |
292 | 301 | $readonlys['owner'] = false; |
293 | - } else { |
|
302 | + } |
|
303 | + else |
|
304 | + { |
|
294 | 305 | $readonlys['owner'] = true; |
295 | 306 | $readonlys['access'] = $content['owner'] != $GLOBALS['egw_info']['user']['account_id']; |
296 | 307 | } |
@@ -301,7 +312,10 @@ discard block |
||
301 | 312 | $appname != $content['appname'] || // Can't edit a category from a different app |
302 | 313 | ($this->appname != 'admin' && $content['owner'] != $GLOBALS['egw_info']['user']['account_id']); |
303 | 314 | // Make sure $content['owner'] is an array otherwise it wont show up values in the multiselectbox |
304 | - if (!is_array($content['owner'])) $content['owner'] = explode(',',$content['owner']); |
|
315 | + if (!is_array($content['owner'])) |
|
316 | + { |
|
317 | + $content['owner'] = explode(',',$content['owner']); |
|
318 | + } |
|
305 | 319 | $tmpl = new etemplate_new('admin.categories.edit'); |
306 | 320 | $tmpl->exec($this->edit_link,$content,$sel_options,$readonlys,$content+array( |
307 | 321 | 'old_parent' => $content['old_parent'] ? $content['old_parent'] : $content['parent'], 'appname' => $appname |
@@ -360,9 +374,15 @@ discard block |
||
360 | 374 | { |
361 | 375 | $globalcat = false; |
362 | 376 | } |
363 | - if ($globalcat && $query['filter']) $filter['access'] = 'public'; |
|
377 | + if ($globalcat && $query['filter']) |
|
378 | + { |
|
379 | + $filter['access'] = 'public'; |
|
380 | + } |
|
364 | 381 | // new column-filter access has highest priority |
365 | - if (!empty($query['col_filter']['access']))$filter['access'] = $query['col_filter']['access']; |
|
382 | + if (!empty($query['col_filter']['access'])) |
|
383 | + { |
|
384 | + $filter['access'] = $query['col_filter']['access']; |
|
385 | + } |
|
366 | 386 | |
367 | 387 | egw_cache::setSession(__CLASS__.$query['appname'],'nm',$query); |
368 | 388 | |
@@ -391,7 +411,10 @@ discard block |
||
391 | 411 | |
392 | 412 | $row['level_spacer'] = str_repeat(' ',$row['level']); |
393 | 413 | |
394 | - if ($row['data']['icon']) $row['icon_url'] = self::icon_url($row['data']['icon']); |
|
414 | + if ($row['data']['icon']) |
|
415 | + { |
|
416 | + $row['icon_url'] = self::icon_url($row['data']['icon']); |
|
417 | + } |
|
395 | 418 | |
396 | 419 | $row['subs'] = count($row['children']); |
397 | 420 | |
@@ -422,13 +445,19 @@ discard block |
||
422 | 445 | $readonlys['nm']["add[$row[id]]"] = !self::$acl_add_sub; |
423 | 446 | $readonlys['nm']["delete[$row[id]]"] = !self::$acl_delete; |
424 | 447 | } |
425 | - if (true) $rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']); |
|
448 | + if (true) |
|
449 | + { |
|
450 | + $rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']); |
|
451 | + } |
|
426 | 452 | // make appname available for actions |
427 | 453 | $rows['appname'] = $query['appname']; |
428 | 454 | $rows['edit_link'] = $this->edit_link; |
429 | 455 | |
430 | 456 | // disable access column for global categories |
431 | - if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin') $rows['no_access'] = true; |
|
457 | + if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin') |
|
458 | + { |
|
459 | + $rows['no_access'] = true; |
|
460 | + } |
|
432 | 461 | |
433 | 462 | $GLOBALS['egw_info']['flags']['app_header'] = lang($this->appname).' - '.lang('categories'). |
434 | 463 | ($query['appname'] != categories::GLOBAL_APPNAME ? ': '.lang($query['appname']) : ''); |
@@ -445,11 +474,18 @@ discard block |
||
445 | 474 | public function index(array $content=null,$msg='') |
446 | 475 | { |
447 | 476 | //_debug_array($_GET); |
448 | - if ($this->appname != 'admin') translation::add_app('admin'); // need admin translations |
|
477 | + if ($this->appname != 'admin') |
|
478 | + { |
|
479 | + translation::add_app('admin'); |
|
480 | + } |
|
481 | + // need admin translations |
|
449 | 482 | |
450 | 483 | if(!isset($content)) |
451 | 484 | { |
452 | - if (isset($_GET['msg'])) $msg = $_GET['msg']; |
|
485 | + if (isset($_GET['msg'])) |
|
486 | + { |
|
487 | + $msg = $_GET['msg']; |
|
488 | + } |
|
453 | 489 | |
454 | 490 | $appname = categories::GLOBAL_APPNAME; |
455 | 491 | foreach(array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field) |
@@ -590,7 +626,8 @@ discard block |
||
590 | 626 | $readonlys['nm']['rows']['owner'] = true; |
591 | 627 | $readonlys['nm']['col_filter']['owner'] = true; |
592 | 628 | } |
593 | - if($appname == categories::GLOBAL_APPNAME) { |
|
629 | + if($appname == categories::GLOBAL_APPNAME) |
|
630 | + { |
|
594 | 631 | $sel_options['app'] = array(''=>''); |
595 | 632 | $readonlys['nm']['rows']['app'] = true; |
596 | 633 | } |
@@ -608,7 +645,8 @@ discard block |
||
608 | 645 | )); |
609 | 646 | } |
610 | 647 | |
611 | - protected function get_actions($appname=categories::GLOBAL_APPNAME) { |
|
648 | + protected function get_actions($appname=categories::GLOBAL_APPNAME) |
|
649 | + { |
|
612 | 650 | |
613 | 651 | $actions = array( |
614 | 652 | 'open' => array( // does edit if allowed, otherwise view |
@@ -719,11 +757,17 @@ discard block |
||
719 | 757 | list($add_remove, $ids_csv) = explode('_', $settings, 2); |
720 | 758 | $ids = explode(',', $ids_csv); |
721 | 759 | // Adding 'All users' removes all the others |
722 | - if($add_remove == 'add' && array_search(categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(categories::GLOBAL_ACCOUNT); |
|
760 | + if($add_remove == 'add' && array_search(categories::GLOBAL_ACCOUNT,$ids) !== false) |
|
761 | + { |
|
762 | + $ids = array(categories::GLOBAL_ACCOUNT); |
|
763 | + } |
|
723 | 764 | |
724 | 765 | foreach($checked as $id) |
725 | 766 | { |
726 | - if (!$data = $cats->read($id)) continue; |
|
767 | + if (!$data = $cats->read($id)) |
|
768 | + { |
|
769 | + continue; |
|
770 | + } |
|
727 | 771 | $data['owner'] = explode(',',$data['owner']); |
728 | 772 | if(array_search(categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0) |
729 | 773 | { |
@@ -763,7 +807,10 @@ discard block |
||
763 | 807 | continue; |
764 | 808 | } |
765 | 809 | // Skip apps that don't show in the app bar, they [usually] don't have categories |
766 | - if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue; |
|
810 | + if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) |
|
811 | + { |
|
812 | + continue; |
|
813 | + } |
|
767 | 814 | if ($GLOBALS['egw_info']['user']['apps'][$app]) |
768 | 815 | { |
769 | 816 | $apps[$app] = $data['title'] ? $data['title'] : lang($app); |
@@ -291,7 +291,7 @@ |
||
291 | 291 | * Check if next submission is due, in which case we call submit and NOT return to the admin hook |
292 | 292 | * |
293 | 293 | * @param boolean $redirect should we redirect or return true |
294 | - * @return boolean true if statistic submission is due |
|
294 | + * @return boolean|null true if statistic submission is due |
|
295 | 295 | */ |
296 | 296 | public static function check($redirect=true) |
297 | 297 | { |
@@ -203,9 +203,12 @@ discard block |
||
203 | 203 | { |
204 | 204 | continue; // --> ignore to not submit too much |
205 | 205 | } |
206 | - if (($users = self::gather_app_users($app))) // ignore apps noone is allowed to run |
|
206 | + if (($users = self::gather_app_users($app))) |
|
207 | + { |
|
208 | + // ignore apps noone is allowed to run |
|
207 | 209 | { |
208 | 210 | $data['apps'][$app] = $app.':'.round(100.0*$users/$data['users']).'%'; |
211 | + } |
|
209 | 212 | if (($entries = self::gather_app_entries($app))) |
210 | 213 | { |
211 | 214 | $data['apps'][$app] .= ':'.$entries; |
@@ -302,7 +305,10 @@ discard block |
||
302 | 305 | { |
303 | 306 | return false; |
304 | 307 | } |
305 | - if (!$redirect) return true; |
|
308 | + if (!$redirect) |
|
309 | + { |
|
310 | + return true; |
|
311 | + } |
|
306 | 312 | |
307 | 313 | //die('Due for new statistics submission: last_submit='.$config[self::CONFIG_LAST_SUBMIT ].', postpone='.$config[self::CONFIG_POSTPONE_SUBMIT].', '.function_backtrace()); |
308 | 314 | Egw::redirect_link('/index.php',array( |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | const SUBMIT_URL = 'https://www.egroupware.org/usage-statistic'; |
27 | 27 | const STATISTIC_URL = 'http://www.egroupware.org/usage-statistic'; |
28 | 28 | |
29 | - const SUBMISION_RATE = 2592000; // 30 days |
|
29 | + const SUBMISION_RATE = 2592000; // 30 days |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Which methods of this class can be called as menuation |
@@ -42,27 +42,27 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param array $_content =null |
44 | 44 | */ |
45 | - public function submit($_content=null) |
|
45 | + public function submit($_content = null) |
|
46 | 46 | { |
47 | 47 | if (is_array($_content)) |
48 | 48 | { |
49 | 49 | $config = new config(self::CONFIG_APP); |
50 | 50 | if ($_content['postpone']) |
51 | 51 | { |
52 | - config::save_value(self::CONFIG_POSTPONE_SUBMIT,time()+$_content['postpone'],self::CONFIG_APP); |
|
52 | + config::save_value(self::CONFIG_POSTPONE_SUBMIT, time() + $_content['postpone'], self::CONFIG_APP); |
|
53 | 53 | $what = 'postpone'; |
54 | 54 | } |
55 | - elseif(!$_content['cancel']) |
|
55 | + elseif (!$_content['cancel']) |
|
56 | 56 | { |
57 | - config::save_value(self::CONFIG_LAST_SUBMIT,time(),self::CONFIG_APP); |
|
58 | - config::save_value(self::CONFIG_SUBMIT_ID,empty($_content['submit_id']) ? '***none***' : $_content['submit_id'],self::CONFIG_APP); |
|
59 | - config::save_value(self::CONFIG_COUNTRY,empty($_content['country']) ? '***multinational***' : $_content['country'],self::CONFIG_APP); |
|
60 | - config::save_value(self::CONFIG_USAGE_TYPE,$_content['usage_type'],self::CONFIG_APP); |
|
61 | - config::save_value(self::CONFIG_INSTALL_TYPE,$_content['install_type'],self::CONFIG_APP); |
|
62 | - config::save_value(self::CONFIG_POSTPONE_SUBMIT,null,self::CONFIG_APP); // remove evtl. postpone time |
|
57 | + config::save_value(self::CONFIG_LAST_SUBMIT, time(), self::CONFIG_APP); |
|
58 | + config::save_value(self::CONFIG_SUBMIT_ID, empty($_content['submit_id']) ? '***none***' : $_content['submit_id'], self::CONFIG_APP); |
|
59 | + config::save_value(self::CONFIG_COUNTRY, empty($_content['country']) ? '***multinational***' : $_content['country'], self::CONFIG_APP); |
|
60 | + config::save_value(self::CONFIG_USAGE_TYPE, $_content['usage_type'], self::CONFIG_APP); |
|
61 | + config::save_value(self::CONFIG_INSTALL_TYPE, $_content['install_type'], self::CONFIG_APP); |
|
62 | + config::save_value(self::CONFIG_POSTPONE_SUBMIT, null, self::CONFIG_APP); // remove evtl. postpone time |
|
63 | 63 | $what = 'submitted'; |
64 | 64 | } |
65 | - egw::redirect_link('/admin/index.php','ajax=true&statistics='.($what ? $what : 'canceled'),'admin'); |
|
65 | + egw::redirect_link('/admin/index.php', 'ajax=true&statistics='.($what ? $what : 'canceled'), 'admin'); |
|
66 | 66 | } |
67 | 67 | $sel_options['usage_type'] = array( |
68 | 68 | 'commercial' => lang('Commercial: all sorts of companies'), |
@@ -82,19 +82,19 @@ discard block |
||
82 | 82 | $sel_options['postpone'] = array( |
83 | 83 | //10 => '10 secs', |
84 | 84 | 3600 => lang('one hour'), |
85 | - 2*3600 => lang('two hours'), |
|
86 | - 24*3600 => lang('one day'), |
|
87 | - 2*24*3600 => lang('two days'), |
|
88 | - 7*24*3600 => lang('one week'), |
|
89 | - 14*24*3600 => lang('two weeks'), |
|
90 | - 30*24*3600 => lang('one month'), |
|
91 | - 60*24*3600 => lang('two months'), |
|
85 | + 2 * 3600 => lang('two hours'), |
|
86 | + 24 * 3600 => lang('one day'), |
|
87 | + 2 * 24 * 3600 => lang('two days'), |
|
88 | + 7 * 24 * 3600 => lang('one week'), |
|
89 | + 14 * 24 * 3600 => lang('two weeks'), |
|
90 | + 30 * 24 * 3600 => lang('one month'), |
|
91 | + 60 * 24 * 3600 => lang('two months'), |
|
92 | 92 | ); |
93 | 93 | $config = config::read(self::CONFIG_APP); |
94 | 94 | //_debug_array($config); |
95 | - $content = array_merge(self::gather_data(),array( |
|
95 | + $content = array_merge(self::gather_data(), array( |
|
96 | 96 | 'statistic_url' => self::STATISTIC_URL, |
97 | - 'submit_host' => parse_url(self::SUBMIT_URL,PHP_URL_HOST), |
|
97 | + 'submit_host' => parse_url(self::SUBMIT_URL, PHP_URL_HOST), |
|
98 | 98 | 'submit_url' => self::SUBMIT_URL, |
99 | 99 | 'last_submitted' => $config[self::CONFIG_LAST_SUBMIT], |
100 | 100 | )); |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | $sel_options['install_type'] = array($content['install_type'] => $sel_options['install_type'][$content['install_type']]); |
122 | 122 | } |
123 | 123 | // else default to previous type |
124 | - elseif($config[self::CONFIG_INSTALL_TYPE]) |
|
124 | + elseif ($config[self::CONFIG_INSTALL_TYPE]) |
|
125 | 125 | { |
126 | 126 | $content['install_type'] = $config[self::CONFIG_INSTALL_TYPE]; |
127 | 127 | } |
128 | 128 | // check if we are due for a new submission |
129 | - if (!isset($config[self::CONFIG_LAST_SUBMIT]) || $config[self::CONFIG_LAST_SUBMIT ] <= time()-self::SUBMISION_RATE) |
|
129 | + if (!isset($config[self::CONFIG_LAST_SUBMIT]) || $config[self::CONFIG_LAST_SUBMIT] <= time() - self::SUBMISION_RATE) |
|
130 | 130 | { |
131 | 131 | // clear etemplate_exec_id and replace form.action, before submitting the form |
132 | 132 | $content['onclick'] = "return app.admin.submit_statistic(this.form,'$content[submit_url]');"; |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | { |
136 | 136 | $readonlys['submit'] = $readonlys['postpone'] = true; |
137 | 137 | $content['msg'] = lang('Your last submission was less then %1 days ago!', |
138 | - ceil((time()-$config[self::CONFIG_LAST_SUBMIT])/24/3600)); |
|
138 | + ceil((time() - $config[self::CONFIG_LAST_SUBMIT]) / 24 / 3600)); |
|
139 | 139 | } |
140 | 140 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Submit statistic information'); |
141 | 141 | $tmpl = new etemplate_new('admin.statistics'); |
142 | - $tmpl->exec('admin.admin_statistics.submit',$content,$sel_options,$readonlys); |
|
142 | + $tmpl->exec('admin.admin_statistics.submit', $content, $sel_options, $readonlys); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $data['version'] .= ' '.$GLOBALS['egw_info']['apps']['stylite']['version'].'EPL'; |
163 | 163 | } |
164 | 164 | // sessions in the last 30 days |
165 | - $data['sessions'] = $GLOBALS['egw']->db->query('SELECT COUNT(*) FROM egw_access_log WHERE li > '.(time()-30*24*3600))->fetchColumn(); |
|
165 | + $data['sessions'] = $GLOBALS['egw']->db->query('SELECT COUNT(*) FROM egw_access_log WHERE li > '.(time() - 30 * 24 * 3600))->fetchColumn(); |
|
166 | 166 | |
167 | 167 | // total accounts from accounts table or ldap |
168 | 168 | $GLOBALS['egw']->accounts->search(array( |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | // @ required to get ride of warning, if files are outside of open_basedir |
177 | 177 | if (@file_exists($file = '/etc/SuSE-release') || @file_exists($file = '/etc/redhat-release') || @file_exists($file = '/etc/debian_version')) |
178 | 178 | { |
179 | - $data['os'] .= ': '.str_replace(array("\n","\r"),'',implode(',',file($file))); |
|
179 | + $data['os'] .= ': '.str_replace(array("\n", "\r"), '', implode(',', file($file))); |
|
180 | 180 | } |
181 | - if(file_exists(EGW_INCLUDE_ROOT.'/.git')) |
|
181 | + if (file_exists(EGW_INCLUDE_ROOT.'/.git')) |
|
182 | 182 | { |
183 | 183 | $data['install_type'] = 'git'; |
184 | 184 | } |
@@ -186,22 +186,22 @@ discard block |
||
186 | 186 | { |
187 | 187 | $data['install_type'] = 'svn'; |
188 | 188 | } |
189 | - elseif(EGW_INCLUDE_ROOT == '/usr/share/egroupware' && PHP_OS == 'Linux' && is_link('/usr/share/egroupware/header.inc.php')) |
|
189 | + elseif (EGW_INCLUDE_ROOT == '/usr/share/egroupware' && PHP_OS == 'Linux' && is_link('/usr/share/egroupware/header.inc.php')) |
|
190 | 190 | { |
191 | 191 | $data['install_type'] = 'package'; |
192 | 192 | } |
193 | - foreach(array_keys($GLOBALS['egw_info']['apps']) as $app) |
|
193 | + foreach (array_keys($GLOBALS['egw_info']['apps']) as $app) |
|
194 | 194 | { |
195 | - if (in_array($app,array( |
|
196 | - 'admin','phpgwapi','emailadmin','sambaadmin','developer_tools', |
|
197 | - 'home','preferences','etemplate','registration','manual','egw-pear', |
|
195 | + if (in_array($app, array( |
|
196 | + 'admin', 'phpgwapi', 'emailadmin', 'sambaadmin', 'developer_tools', |
|
197 | + 'home', 'preferences', 'etemplate', 'registration', 'manual', 'egw-pear', |
|
198 | 198 | ))) |
199 | 199 | { |
200 | - continue; // --> ignore to not submit too much |
|
200 | + continue; // --> ignore to not submit too much |
|
201 | 201 | } |
202 | 202 | if (($users = self::gather_app_users($app))) // ignore apps noone is allowed to run |
203 | 203 | { |
204 | - $data['apps'][$app] = $app.':'.round(100.0*$users/$data['users']).'%'; |
|
204 | + $data['apps'][$app] = $app.':'.round(100.0 * $users / $data['users']).'%'; |
|
205 | 205 | if (($entries = self::gather_app_entries($app))) |
206 | 206 | { |
207 | 207 | $data['apps'][$app] .= ':'.$entries; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | } |
210 | 210 | } |
211 | 211 | ksort($data['apps']); |
212 | - $data['apps'] = implode("\n",$data['apps']); |
|
212 | + $data['apps'] = implode("\n", $data['apps']); |
|
213 | 213 | |
214 | 214 | return $data; |
215 | 215 | } |
@@ -223,17 +223,17 @@ discard block |
||
223 | 223 | static function gather_app_users($app) |
224 | 224 | { |
225 | 225 | $users = array(); |
226 | - if (($access = $GLOBALS['egw']->acl->get_ids_for_location('run',1,$app))) |
|
226 | + if (($access = $GLOBALS['egw']->acl->get_ids_for_location('run', 1, $app))) |
|
227 | 227 | { |
228 | - foreach($access as $uid) |
|
228 | + foreach ($access as $uid) |
|
229 | 229 | { |
230 | 230 | if ($uid > 0) |
231 | 231 | { |
232 | 232 | $users[] = $uid; |
233 | 233 | } |
234 | - elseif (($members = $GLOBALS['egw']->accounts->members($uid,true))) |
|
234 | + elseif (($members = $GLOBALS['egw']->accounts->members($uid, true))) |
|
235 | 235 | { |
236 | - $users = array_merge($users,$members); |
|
236 | + $users = array_merge($users, $members); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | $users = array_unique($users); |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | 'infolog' => 'egw_infolog', |
258 | 258 | 'filemanager' => 'egw_sqlfs', |
259 | 259 | 'gallery' => 'g2_Item', |
260 | - 'news_admin' => 'egw_news WHERE news_submittedby > 0', // exclude imported rss feeds |
|
260 | + 'news_admin' => 'egw_news WHERE news_submittedby > 0', // exclude imported rss feeds |
|
261 | 261 | 'polls' => 'egw_polls', |
262 | 262 | 'projectmanager' => 'egw_pm_projects', |
263 | 263 | 'phpbrain' => 'egw_kb_articles', |
@@ -275,8 +275,8 @@ discard block |
||
275 | 275 | $entries = (int)$GLOBALS['egw']->db->query('SELECT COUNT(*) FROM '.$table)->fetchColumn(); |
276 | 276 | //echo "$app ($table): $entries<br />\n"; |
277 | 277 | } |
278 | - catch(egw_exception_db $e) { |
|
279 | - unset($e); // not used |
|
278 | + catch (egw_exception_db $e) { |
|
279 | + unset($e); // not used |
|
280 | 280 | $entries = null; |
281 | 281 | } |
282 | 282 | } |
@@ -289,19 +289,19 @@ discard block |
||
289 | 289 | * @param boolean $redirect should we redirect or return true |
290 | 290 | * @return boolean true if statistic submission is due |
291 | 291 | */ |
292 | - public static function check($redirect=true) |
|
292 | + public static function check($redirect = true) |
|
293 | 293 | { |
294 | 294 | $config = config::read(self::CONFIG_APP); |
295 | 295 | |
296 | 296 | if (isset($config[self::CONFIG_POSTPONE_SUBMIT]) && $config[self::CONFIG_POSTPONE_SUBMIT] > time() || |
297 | - isset($config[self::CONFIG_LAST_SUBMIT ]) && $config[self::CONFIG_LAST_SUBMIT ] > time()-self::SUBMISION_RATE) |
|
297 | + isset($config[self::CONFIG_LAST_SUBMIT]) && $config[self::CONFIG_LAST_SUBMIT] > time() - self::SUBMISION_RATE) |
|
298 | 298 | { |
299 | 299 | return false; |
300 | 300 | } |
301 | 301 | if (!$redirect) return true; |
302 | 302 | |
303 | 303 | //die('Due for new statistics submission: last_submit='.$config[self::CONFIG_LAST_SUBMIT ].', postpone='.$config[self::CONFIG_POSTPONE_SUBMIT].', '.function_backtrace()); |
304 | - egw::redirect_link('/index.php',array( |
|
304 | + egw::redirect_link('/index.php', array( |
|
305 | 305 | 'menuaction' => 'admin.admin_ui.index', |
306 | 306 | 'ajax' => 'true', |
307 | 307 | 'load' => 'admin.admin_statistics.submit', |
@@ -491,6 +491,10 @@ |
||
491 | 491 | protected static function call_hook() |
492 | 492 | { |
493 | 493 | self::$hook_data = array(); |
494 | + |
|
495 | + /** |
|
496 | + * @param string $appname |
|
497 | + */ |
|
494 | 498 | function display_section($appname,$file,$file2=False) |
495 | 499 | { |
496 | 500 | admin_ui::$hook_data[$appname] = $file2 ? $file2 : $file; |
@@ -48,7 +48,10 @@ discard block |
||
48 | 48 | } |
49 | 49 | $tpl = new Etemplate('admin.index'); |
50 | 50 | |
51 | - if (!is_array($content)) $content = array(); |
|
51 | + if (!is_array($content)) |
|
52 | + { |
|
53 | + $content = array(); |
|
54 | + } |
|
52 | 55 | $content['nm'] = array( |
53 | 56 | 'get_rows' => 'admin_ui::get_users', |
54 | 57 | 'no_cat' => true, |
@@ -132,7 +135,9 @@ discard block |
||
132 | 135 | 'group' => 2, |
133 | 136 | ), |
134 | 137 | ); |
135 | - if (!$GLOBALS['egw']->acl->check('account_access',64,'admin')) // no rights to set ACL-rights |
|
138 | + if (!$GLOBALS['egw']->acl->check('account_access',64,'admin')) |
|
139 | + { |
|
140 | + // no rights to set ACL-rights |
|
136 | 141 | { |
137 | 142 | $actions['deny'] = array( |
138 | 143 | 'caption' => 'Deny access', |
@@ -143,6 +148,7 @@ discard block |
||
143 | 148 | 'group' => 2, |
144 | 149 | ); |
145 | 150 | } |
151 | + } |
|
146 | 152 | $group = 5; // allow to place actions in different groups by hook, this is the default |
147 | 153 | // supporting both old way using $GLOBALS['menuData'] and new just returning data in hook |
148 | 154 | $apps = array_unique(array_merge(array('admin'), Api\Hooks::implemented('edit_group'))); |
@@ -150,7 +156,10 @@ discard block |
||
150 | 156 | { |
151 | 157 | $GLOBALS['menuData'] = $data = array(); |
152 | 158 | $data = Api\Hooks::single('edit_group', $app); |
153 | - if (!is_array($data)) $data = $GLOBALS['menuData']; |
|
159 | + if (!is_array($data)) |
|
160 | + { |
|
161 | + $data = $GLOBALS['menuData']; |
|
162 | + } |
|
154 | 163 | //error_log(__METHOD__."() app $app returned ".array2string($data)); |
155 | 164 | foreach($data as $item) |
156 | 165 | { |
@@ -170,15 +179,33 @@ discard block |
||
170 | 179 | { |
171 | 180 | $item['popup'] = $matches[2].'x'.$matches[3]; |
172 | 181 | $item['onExecute'] = 'javaScript:nm_action'; |
173 | - if (isset($matches[5])) $item['tooltip'] = $matches[5]; |
|
182 | + if (isset($matches[5])) |
|
183 | + { |
|
184 | + $item['tooltip'] = $matches[5]; |
|
185 | + } |
|
174 | 186 | unset($item['options']); |
175 | 187 | } |
176 | 188 | } |
177 | - if (empty($item['icon'])) $item['icon'] = $app.'/navbar'; |
|
178 | - if (empty($item['group'])) $item['group'] = $group; |
|
179 | - if (empty($item['onExecute'])) $item['onExecute'] = 'javaScript:app.admin.group'; |
|
180 | - if (!isset($item['allowOnMultiple'])) $item['allowOnMultiple'] = false; |
|
181 | - if (!isset($item['enableId'])) $item['enableId'] = '^/groups/-\\d+'; |
|
189 | + if (empty($item['icon'])) |
|
190 | + { |
|
191 | + $item['icon'] = $app.'/navbar'; |
|
192 | + } |
|
193 | + if (empty($item['group'])) |
|
194 | + { |
|
195 | + $item['group'] = $group; |
|
196 | + } |
|
197 | + if (empty($item['onExecute'])) |
|
198 | + { |
|
199 | + $item['onExecute'] = 'javaScript:app.admin.group'; |
|
200 | + } |
|
201 | + if (!isset($item['allowOnMultiple'])) |
|
202 | + { |
|
203 | + $item['allowOnMultiple'] = false; |
|
204 | + } |
|
205 | + if (!isset($item['enableId'])) |
|
206 | + { |
|
207 | + $item['enableId'] = '^/groups/-\\d+'; |
|
208 | + } |
|
182 | 209 | |
183 | 210 | $actions[$item['id']] = $item; |
184 | 211 | } |
@@ -231,7 +258,10 @@ discard block |
||
231 | 258 | { |
232 | 259 | $GLOBALS['menuData'] = $data = array(); |
233 | 260 | $data = Api\Hooks::single('edit_user', $app); |
234 | - if (!is_array($data)) $data = $GLOBALS['menuData']; |
|
261 | + if (!is_array($data)) |
|
262 | + { |
|
263 | + $data = $GLOBALS['menuData']; |
|
264 | + } |
|
235 | 265 | foreach($data as $item) |
236 | 266 | { |
237 | 267 | // allow hook to return "real" actions, but still support legacy: description, url, extradata, options |
@@ -249,15 +279,30 @@ discard block |
||
249 | 279 | if ($item['options'] && preg_match('/(egw_openWindowCentered2?|window.open)\([^)]+,(\d+),(\d+).*(title="([^"]+)")?/', $item['options'], $matches)) |
250 | 280 | { |
251 | 281 | $item['popup'] = $matches[2].'x'.$matches[3]; |
252 | - if (isset($matches[5])) $item['tooltip'] = $matches[5]; |
|
282 | + if (isset($matches[5])) |
|
283 | + { |
|
284 | + $item['tooltip'] = $matches[5]; |
|
285 | + } |
|
253 | 286 | unset($item['options']); |
254 | 287 | } |
255 | 288 | } |
256 | - if (empty($item['icon'])) $item['icon'] = $app.'/navbar'; |
|
257 | - if (empty($item['group'])) $item['group'] = $group; |
|
258 | - if (empty($item['onExecute'])) $item['onExecute'] = $item['popup'] ? |
|
289 | + if (empty($item['icon'])) |
|
290 | + { |
|
291 | + $item['icon'] = $app.'/navbar'; |
|
292 | + } |
|
293 | + if (empty($item['group'])) |
|
294 | + { |
|
295 | + $item['group'] = $group; |
|
296 | + } |
|
297 | + if (empty($item['onExecute'])) |
|
298 | + { |
|
299 | + $item['onExecute'] = $item['popup'] ? |
|
259 | 300 | 'javaScript:nm_action' : 'javaScript:app.admin.iframe_location'; |
260 | - if (!isset($item['allowOnMultiple'])) $item['allowOnMultiple'] = false; |
|
301 | + } |
|
302 | + if (!isset($item['allowOnMultiple'])) |
|
303 | + { |
|
304 | + $item['allowOnMultiple'] = false; |
|
305 | + } |
|
261 | 306 | |
262 | 307 | $actions[$item['id']] = $item; |
263 | 308 | } |
@@ -313,7 +358,10 @@ discard block |
||
313 | 358 | ($row['account_expires'] != -1 ? lang('Expires').' '.Api\DateTime::to($row['account_expires'], true) : |
314 | 359 | lang('Enabled'))); |
315 | 360 | |
316 | - if (!self::$accounts->is_active($row)) $row['status_class'] = 'adminAccountInactive'; |
|
361 | + if (!self::$accounts->is_active($row)) |
|
362 | + { |
|
363 | + $row['status_class'] = 'adminAccountInactive'; |
|
364 | + } |
|
317 | 365 | } |
318 | 366 | |
319 | 367 | return self::$accounts->total; |
@@ -367,7 +415,10 @@ discard block |
||
367 | 415 | 'link' => $data, |
368 | 416 | ); |
369 | 417 | } |
370 | - if (empty($data['text'])) $data['text'] = $text; |
|
418 | + if (empty($data['text'])) |
|
419 | + { |
|
420 | + $data['text'] = $text; |
|
421 | + } |
|
371 | 422 | if (empty($data['id'])) |
372 | 423 | { |
373 | 424 | $data['id'] = $root.($app == 'admin' ? 'admin' : 'apps/'.$app).'/'; |
@@ -392,7 +443,11 @@ discard block |
||
392 | 443 | unset($data['icon']); |
393 | 444 | $parent =& $tree['item']; |
394 | 445 | $parts = explode('/', $data['id']); |
395 | - if ($data['id'][0] == '/') array_shift($parts); // remove root |
|
446 | + if ($data['id'][0] == '/') |
|
447 | + { |
|
448 | + array_shift($parts); |
|
449 | + } |
|
450 | + // remove root |
|
396 | 451 | array_pop($parts); |
397 | 452 | $path = ''; |
398 | 453 | foreach($parts as $part) |
@@ -411,14 +466,23 @@ discard block |
||
411 | 466 | 'item' => array(), |
412 | 467 | 'child' => 1, |
413 | 468 | ); |
414 | - if ($path == '/admin') $parent[$path]['open'] = true; |
|
469 | + if ($path == '/admin') |
|
470 | + { |
|
471 | + $parent[$path]['open'] = true; |
|
472 | + } |
|
415 | 473 | } |
416 | 474 | $parent =& $parent[$path]['item']; |
417 | 475 | } |
418 | 476 | $data['text'] = lang($data['text']); |
419 | - if (!empty($data['tooltip'])) $data['tooltip'] = lang($data['tooltip']); |
|
477 | + if (!empty($data['tooltip'])) |
|
478 | + { |
|
479 | + $data['tooltip'] = lang($data['tooltip']); |
|
480 | + } |
|
420 | 481 | // make sure keys are unique, as we overwrite tree entries otherwise |
421 | - if (isset($parent[$data['id']])) $data['id'] .= md5($data['link']); |
|
482 | + if (isset($parent[$data['id']])) |
|
483 | + { |
|
484 | + $data['id'] .= md5($data['link']); |
|
485 | + } |
|
422 | 486 | $parent[$data['id']] = self::fix_userdata($data); |
423 | 487 | } |
424 | 488 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param array $content |
37 | 37 | */ |
38 | - public function index(array $content=null) |
|
38 | + public function index(array $content = null) |
|
39 | 39 | { |
40 | 40 | if (admin_statistics::check(false)) |
41 | 41 | { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | //$content['msg'] = 'Hi Ralf ;-)'; |
62 | 62 | $sel_options['tree'] = $this->tree_data(); |
63 | 63 | $sel_options['filter'] = array('' => lang('All')); |
64 | - foreach(self::$accounts->search(array( |
|
64 | + foreach (self::$accounts->search(array( |
|
65 | 65 | 'type' => 'groups', |
66 | 66 | 'start' => false, |
67 | 67 | 'order' => 'account_lid', |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | else |
94 | 94 | { |
95 | - $content['iframe'] = 'about:blank'; // we show accounts-list be default now |
|
95 | + $content['iframe'] = 'about:blank'; // we show accounts-list be default now |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $tpl->exec('admin.admin_ui.index', $content, $sel_options); |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | 'caption' => 'Show members', |
114 | 114 | 'enableId' => '^/groups/-\\d+', |
115 | 115 | 'default' => true, |
116 | - 'group' => $group=1, |
|
116 | + 'group' => $group = 1, |
|
117 | 117 | ), |
118 | 118 | 'add' => array( |
119 | 119 | 'group' => $group, |
120 | - )+$user_actions['add'], |
|
120 | + ) + $user_actions['add'], |
|
121 | 121 | 'acl' => array( |
122 | 122 | 'onExecute' => 'javaScript:app.admin.group', |
123 | 123 | 'caption' => 'Access control', |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | 'group' => 2, |
129 | 129 | ), |
130 | 130 | ); |
131 | - if (!$GLOBALS['egw']->acl->check('account_access',64,'admin')) // no rights to set ACL-rights |
|
131 | + if (!$GLOBALS['egw']->acl->check('account_access', 64, 'admin')) // no rights to set ACL-rights |
|
132 | 132 | { |
133 | 133 | $actions['deny'] = array( |
134 | 134 | 'caption' => 'Deny access', |
@@ -139,16 +139,16 @@ discard block |
||
139 | 139 | 'group' => 2, |
140 | 140 | ); |
141 | 141 | } |
142 | - $group = 5; // allow to place actions in different groups by hook, this is the default |
|
142 | + $group = 5; // allow to place actions in different groups by hook, this is the default |
|
143 | 143 | // supporting both old way using $GLOBALS['menuData'] and new just returning data in hook |
144 | 144 | $apps = array_unique(array_merge(array('admin'), $GLOBALS['egw']->hooks->hook_implemented('edit_group'))); |
145 | - foreach($apps as $app) |
|
145 | + foreach ($apps as $app) |
|
146 | 146 | { |
147 | 147 | $GLOBALS['menuData'] = $data = array(); |
148 | 148 | $data = $GLOBALS['egw']->hooks->single('edit_group', $app); |
149 | 149 | if (!is_array($data)) $data = $GLOBALS['menuData']; |
150 | 150 | //error_log(__METHOD__."() app $app returned ".array2string($data)); |
151 | - foreach($data as $item) |
|
151 | + foreach ($data as $item) |
|
152 | 152 | { |
153 | 153 | // allow hook to return "real" actions, but still support legacy: description, url, extradata, options |
154 | 154 | if (empty($item['caption'])) |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | 'default' => true, |
200 | 200 | 'allowOnMultiple' => false, |
201 | 201 | 'onExecute' => 'javaScript:app.admin.account', |
202 | - 'group' => $group=0, |
|
202 | + 'group' => $group = 0, |
|
203 | 203 | ), |
204 | 204 | 'add' => array( |
205 | 205 | 'caption' => 'Add user', |
@@ -210,25 +210,25 @@ discard block |
||
210 | 210 | // generate urls for add/edit accounts via addressbook |
211 | 211 | $edit = egw_link::get_registry('addressbook', 'edit'); |
212 | 212 | $edit['account_id'] = '$id'; |
213 | - foreach($edit as $name => $val) |
|
213 | + foreach ($edit as $name => $val) |
|
214 | 214 | { |
215 | 215 | $actions['edit']['url'] .= ($actions['edit']['url'] ? '&' : '').$name.'='.$val; |
216 | 216 | } |
217 | 217 | unset($edit['account_id']); |
218 | 218 | $edit['owner'] = 0; |
219 | - foreach($edit as $name => $val) |
|
219 | + foreach ($edit as $name => $val) |
|
220 | 220 | { |
221 | 221 | $actions['add']['url'] .= ($actions['edit']['url'] ? '&' : '').$name.'='.$val; |
222 | 222 | } |
223 | 223 | ++$group; |
224 | 224 | // supporting both old way using $GLOBALS['menuData'] and new just returning data in hook |
225 | 225 | $apps = array_unique(array_merge(array('admin'), $GLOBALS['egw']->hooks->hook_implemented('edit_user'))); |
226 | - foreach($apps as $app) |
|
226 | + foreach ($apps as $app) |
|
227 | 227 | { |
228 | 228 | $GLOBALS['menuData'] = $data = array(); |
229 | 229 | $data = $GLOBALS['egw']->hooks->single('edit_user', $app); |
230 | 230 | if (!is_array($data)) $data = $GLOBALS['menuData']; |
231 | - foreach($data as $item) |
|
231 | + foreach ($data as $item) |
|
232 | 232 | { |
233 | 233 | // allow hook to return "real" actions, but still support legacy: description, url, extradata, options |
234 | 234 | if (empty($item['caption'])) |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @param array &$rows=null |
278 | 278 | * @return int total number of rows available |
279 | 279 | */ |
280 | - public static function get_users(array $query, array &$rows=null) |
|
280 | + public static function get_users(array $query, array &$rows = null) |
|
281 | 281 | { |
282 | 282 | $params = array( |
283 | 283 | 'type' => (int)$query['filter'] ? (int)$query['filter'] : 'accounts', |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | $params['query'] = $query['searchletter']; |
293 | 293 | $params['query_type'] = 'start'; |
294 | 294 | } |
295 | - elseif($query['search']) |
|
295 | + elseif ($query['search']) |
|
296 | 296 | { |
297 | 297 | $params['query'] = $query['search']; |
298 | 298 | $params['query_type'] = 'all'; |
@@ -301,13 +301,10 @@ discard block |
||
301 | 301 | $rows = array_values(self::$accounts->search($params)); |
302 | 302 | //error_log(__METHOD__."() accounts->search(".array2string($params).") total=".self::$accounts->total); |
303 | 303 | |
304 | - foreach($rows as &$row) |
|
304 | + foreach ($rows as &$row) |
|
305 | 305 | { |
306 | 306 | $row['status'] = self::$accounts->is_expired($row) ? |
307 | - lang('Expired').' '.egw_time::to($row['account_expires'], true) : |
|
308 | - (!self::$accounts->is_active($row) ? lang('Disabled') : |
|
309 | - ($row['account_expires'] != -1 ? lang('Expires').' '.egw_time::to($row['account_expires'], true) : |
|
310 | - lang('Enabled'))); |
|
307 | + lang('Expired').' '.egw_time::to($row['account_expires'], true) : (!self::$accounts->is_active($row) ? lang('Disabled') : ($row['account_expires'] != -1 ? lang('Expires').' '.egw_time::to($row['account_expires'], true) : lang('Enabled'))); |
|
311 | 308 | |
312 | 309 | if (!self::$accounts->is_active($row)) $row['status_class'] = 'adminAccountInactive'; |
313 | 310 | } |
@@ -348,14 +345,14 @@ discard block |
||
348 | 345 | if ($root == '/') |
349 | 346 | { |
350 | 347 | $hook_data = self::call_hook(); |
351 | - foreach($hook_data as $app => $app_data) |
|
348 | + foreach ($hook_data as $app => $app_data) |
|
352 | 349 | { |
353 | - if(!is_array($app_data)) |
|
350 | + if (!is_array($app_data)) |
|
354 | 351 | { |
355 | 352 | // Application has no data |
356 | 353 | continue; |
357 | 354 | } |
358 | - foreach($app_data as $text => $data) |
|
355 | + foreach ($app_data as $text => $data) |
|
359 | 356 | { |
360 | 357 | if (!is_array($data)) |
361 | 358 | { |
@@ -386,18 +383,17 @@ discard block |
||
386 | 383 | } |
387 | 384 | } |
388 | 385 | unset($data['icon']); |
389 | - $parent =& $tree['item']; |
|
386 | + $parent = & $tree['item']; |
|
390 | 387 | $parts = explode('/', $data['id']); |
391 | - if ($data['id'][0] == '/') array_shift($parts); // remove root |
|
388 | + if ($data['id'][0] == '/') array_shift($parts); // remove root |
|
392 | 389 | array_pop($parts); |
393 | 390 | $path = ''; |
394 | - foreach($parts as $part) |
|
391 | + foreach ($parts as $part) |
|
395 | 392 | { |
396 | 393 | $path .= ($path == '/' ? '' : '/').$part; |
397 | 394 | if (!isset($parent[$path])) |
398 | 395 | { |
399 | - $icon = etemplate_widget_tree::imagePath($part == 'apps' ? common::image('phpgwapi', 'home') : |
|
400 | - (($i=common::image($part, 'navbar')) ? $i : common::image('phpgwapi', 'nonav'))); |
|
396 | + $icon = etemplate_widget_tree::imagePath($part == 'apps' ? common::image('phpgwapi', 'home') : (($i = common::image($part, 'navbar')) ? $i : common::image('phpgwapi', 'nonav'))); |
|
401 | 397 | $parent[$path] = array( |
402 | 398 | 'id' => $path, |
403 | 399 | 'text' => $part == 'apps' ? lang('Applications') : lang($part), |
@@ -409,7 +405,7 @@ discard block |
||
409 | 405 | ); |
410 | 406 | if ($path == '/admin') $parent[$path]['open'] = true; |
411 | 407 | } |
412 | - $parent =& $parent[$path]['item']; |
|
408 | + $parent = & $parent[$path]['item']; |
|
413 | 409 | } |
414 | 410 | $data['text'] = lang($data['text']); |
415 | 411 | if (!empty($data['tooltip'])) $data['tooltip'] = lang($data['tooltip']); |
@@ -421,7 +417,7 @@ discard block |
||
421 | 417 | } |
422 | 418 | elseif ($root == '/groups') |
423 | 419 | { |
424 | - foreach($GLOBALS['egw']->accounts->search(array( |
|
420 | + foreach ($GLOBALS['egw']->accounts->search(array( |
|
425 | 421 | 'type' => 'groups', |
426 | 422 | 'order' => 'account_lid', |
427 | 423 | 'sort' => 'ASC', |
@@ -448,8 +444,8 @@ discard block |
||
448 | 444 | private static function fix_userdata(array $data) |
449 | 445 | { |
450 | 446 | // store link as userdata, maybe we should store everything not directly understood by tree this way ... |
451 | - foreach(array_diff_key($data, array_flip(array( |
|
452 | - 'id','text','tooltip','im0','im1','im2','item','child','select','open','call', |
|
447 | + foreach (array_diff_key($data, array_flip(array( |
|
448 | + 'id', 'text', 'tooltip', 'im0', 'im1', 'im2', 'item', 'child', 'select', 'open', 'call', |
|
453 | 449 | ))) as $name => $content) |
454 | 450 | { |
455 | 451 | $data['userdata'][] = array( |
@@ -469,7 +465,7 @@ discard block |
||
469 | 465 | private static function strip_item_keys(array &$items) |
470 | 466 | { |
471 | 467 | $items = array_values($items); |
472 | - foreach($items as &$item) |
|
468 | + foreach ($items as &$item) |
|
473 | 469 | { |
474 | 470 | if (is_array($item) && isset($item['item'])) |
475 | 471 | { |
@@ -487,7 +483,7 @@ discard block |
||
487 | 483 | protected static function call_hook() |
488 | 484 | { |
489 | 485 | self::$hook_data = array(); |
490 | - function display_section($appname,$file,$file2=False) |
|
486 | + function display_section($appname, $file, $file2 = False) |
|
491 | 487 | { |
492 | 488 | admin_ui::$hook_data[$appname] = $file2 ? $file2 : $file; |
493 | 489 | //error_log(__METHOD__."(".array2string(func_get_args()).")"); |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * |
272 | 272 | * If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now. |
273 | 273 | * |
274 | - * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored. |
|
274 | + * @return boolean TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored. |
|
275 | 275 | */ |
276 | 276 | function stream_flush ( ) |
277 | 277 | { |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * |
508 | 508 | * @param string $url URL that was passed to opendir() and that this object is expected to explore. |
509 | 509 | * @param int $options |
510 | - * @return booelan |
|
510 | + * @return boolean |
|
511 | 511 | */ |
512 | 512 | function dir_opendir ( $url, $options ) |
513 | 513 | { |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | * It should reset the output generated by dir_readdir(). i.e.: |
617 | 617 | * The next call to dir_readdir() should return the first entry in the location returned by dir_opendir(). |
618 | 618 | * |
619 | - * @return boolean |
|
619 | + * @return boolean|null |
|
620 | 620 | */ |
621 | 621 | function dir_rewinddir ( ) |
622 | 622 | { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * Mime type of directories, the old vfs used 'Directory', while eg. WebDAV uses 'httpd/unix-directory' |
53 | 53 | */ |
54 | - const DIR_MIME_TYPE = Vfs::DIR_MIME_TYPE ; |
|
54 | + const DIR_MIME_TYPE = Vfs::DIR_MIME_TYPE; |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * mode-bits, which have to be set for files |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * mode-bits, which have to be set for directories |
62 | 62 | */ |
63 | - const MODE_DIR = 040000; |
|
63 | + const MODE_DIR = 040000; |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * optional context param when opening the stream, null if no context passed |
@@ -123,50 +123,50 @@ discard block |
||
123 | 123 | * @param string $opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set |
124 | 124 | * @return boolean true if the ressource was opened successful, otherwise false |
125 | 125 | */ |
126 | - function stream_open ( $url, $mode, $options, &$opened_path ) |
|
126 | + function stream_open($url, $mode, $options, &$opened_path) |
|
127 | 127 | { |
128 | - unset($opened_path); // not used, but required by interface |
|
128 | + unset($opened_path); // not used, but required by interface |
|
129 | 129 | |
130 | 130 | $this->opened_stream = $this->opened_stream_url = null; |
131 | - $read_only = str_replace('b','',$mode) == 'r'; |
|
131 | + $read_only = str_replace('b', '', $mode) == 'r'; |
|
132 | 132 | |
133 | 133 | // check access rights, based on the eGW mount perms |
134 | - if (!($stat = self::url_stat($url,0)) || $mode[0] == 'x') // file not found or file should NOT exist |
|
134 | + if (!($stat = self::url_stat($url, 0)) || $mode[0] == 'x') // file not found or file should NOT exist |
|
135 | 135 | { |
136 | 136 | $dir = Vfs::dirname($url); |
137 | - if ($mode[0] == 'r' || // does $mode require the file to exist (r,r+) |
|
138 | - $mode[0] == 'x' || // or file should not exist, but does |
|
139 | - !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=self::url_stat($dir,0))) // or we are not allowed to create it |
|
137 | + if ($mode[0] == 'r' || // does $mode require the file to exist (r,r+) |
|
138 | + $mode[0] == 'x' || // or file should not exist, but does |
|
139 | + !Vfs::check_access($dir, Vfs::WRITABLE, $dir_stat = self::url_stat($dir, 0))) // or we are not allowed to create it |
|
140 | 140 | { |
141 | 141 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!"); |
142 | - if (!($options & STREAM_URL_STAT_QUIET)) |
|
142 | + if (!($options&STREAM_URL_STAT_QUIET)) |
|
143 | 143 | { |
144 | - trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!",E_USER_WARNING); |
|
144 | + trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!", E_USER_WARNING); |
|
145 | 145 | } |
146 | 146 | return false; |
147 | 147 | } |
148 | 148 | } |
149 | - elseif (!$read_only && !Vfs::check_access($url,Vfs::WRITABLE,$stat)) // we are not allowed to edit it |
|
149 | + elseif (!$read_only && !Vfs::check_access($url, Vfs::WRITABLE, $stat)) // we are not allowed to edit it |
|
150 | 150 | { |
151 | 151 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file can not be edited!"); |
152 | - if (!($options & STREAM_URL_STAT_QUIET)) |
|
152 | + if (!($options&STREAM_URL_STAT_QUIET)) |
|
153 | 153 | { |
154 | - trigger_error(__METHOD__."($url,$mode,$options) file can not be edited!",E_USER_WARNING); |
|
154 | + trigger_error(__METHOD__."($url,$mode,$options) file can not be edited!", E_USER_WARNING); |
|
155 | 155 | } |
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | if (!$read_only && self::deny_script($url)) |
159 | 159 | { |
160 | 160 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) permission denied, file is a script!"); |
161 | - if (!($options & STREAM_URL_STAT_QUIET)) |
|
161 | + if (!($options&STREAM_URL_STAT_QUIET)) |
|
162 | 162 | { |
163 | - trigger_error(__METHOD__."($url,$mode,$options) permission denied, file is a script!",E_USER_WARNING); |
|
163 | + trigger_error(__METHOD__."($url,$mode,$options) permission denied, file is a script!", E_USER_WARNING); |
|
164 | 164 | } |
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // open the "real" file |
169 | - if (!($this->opened_stream = fopen($path=Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)),$mode,$options))) |
|
169 | + if (!($this->opened_stream = fopen($path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)), $mode, $options))) |
|
170 | 170 | { |
171 | 171 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) fopen('$path','$mode',$options) returned false!"); |
172 | 172 | return false; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * |
182 | 182 | * You must release any resources that were locked or allocated by the stream. |
183 | 183 | */ |
184 | - function stream_close ( ) |
|
184 | + function stream_close( ) |
|
185 | 185 | { |
186 | 186 | $ret = fclose($this->opened_stream); |
187 | 187 | |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | * @param int $count |
202 | 202 | * @return string/false up to count bytes read or false on EOF |
203 | 203 | */ |
204 | - function stream_read ( $count ) |
|
204 | + function stream_read($count) |
|
205 | 205 | { |
206 | - return fread($this->opened_stream,$count); |
|
206 | + return fread($this->opened_stream, $count); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | * @param string $data |
218 | 218 | * @return integer |
219 | 219 | */ |
220 | - function stream_write ( $data ) |
|
220 | + function stream_write($data) |
|
221 | 221 | { |
222 | - return fwrite($this->opened_stream,$data); |
|
222 | + return fwrite($this->opened_stream, $data); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
236 | 236 | */ |
237 | - function stream_eof ( ) |
|
237 | + function stream_eof( ) |
|
238 | 238 | { |
239 | 239 | return feof($this->opened_stream); |
240 | 240 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return integer current read/write position of the stream |
246 | 246 | */ |
247 | - function stream_tell ( ) |
|
247 | + function stream_tell( ) |
|
248 | 248 | { |
249 | 249 | return ftell($this->opened_stream); |
250 | 250 | } |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * SEEK_END - 2 - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.) |
262 | 262 | * @return boolean TRUE if the position was updated, FALSE otherwise. |
263 | 263 | */ |
264 | - function stream_seek ( $offset, $whence ) |
|
264 | + function stream_seek($offset, $whence) |
|
265 | 265 | { |
266 | - return !fseek($this->opened_stream,$offset,$whence); // fseek returns 0 on success and -1 on failure |
|
266 | + return !fseek($this->opened_stream, $offset, $whence); // fseek returns 0 on success and -1 on failure |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored. |
275 | 275 | */ |
276 | - function stream_flush ( ) |
|
276 | + function stream_flush( ) |
|
277 | 277 | { |
278 | 278 | return fflush($this->opened_stream); |
279 | 279 | } |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @return array containing the same values as appropriate for the stream. |
294 | 294 | */ |
295 | - function stream_stat ( ) |
|
295 | + function stream_stat( ) |
|
296 | 296 | { |
297 | - return self::url_stat($this->opened_stream_url,0); |
|
297 | + return self::url_stat($this->opened_stream_url, 0); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -306,15 +306,15 @@ discard block |
||
306 | 306 | * @param string $url |
307 | 307 | * @return boolean TRUE on success or FALSE on failure |
308 | 308 | */ |
309 | - static function unlink ( $url ) |
|
309 | + static function unlink($url) |
|
310 | 310 | { |
311 | - $path = Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)); |
|
311 | + $path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)); |
|
312 | 312 | |
313 | 313 | // check access rights (file need to exist and directory need to be writable |
314 | - if (!file_exists($path) || is_dir($path) || !Vfs::check_access(Vfs::dirname($url),Vfs::WRITABLE)) |
|
314 | + if (!file_exists($path) || is_dir($path) || !Vfs::check_access(Vfs::dirname($url), Vfs::WRITABLE)) |
|
315 | 315 | { |
316 | 316 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
317 | - return false; // no permission or file does not exist |
|
317 | + return false; // no permission or file does not exist |
|
318 | 318 | } |
319 | 319 | return unlink($path); |
320 | 320 | } |
@@ -331,22 +331,22 @@ discard block |
||
331 | 331 | * @param string $url_to |
332 | 332 | * @return boolean TRUE on success or FALSE on failure |
333 | 333 | */ |
334 | - static function rename ( $url_from, $url_to ) |
|
334 | + static function rename($url_from, $url_to) |
|
335 | 335 | { |
336 | 336 | $from = Vfs::parse_url($url_from); |
337 | 337 | $to = Vfs::parse_url($url_to); |
338 | 338 | |
339 | 339 | // check access rights |
340 | - if (!($from_stat = self::url_stat($url_from,0)) || !Vfs::check_access(Vfs::dirname($url_from),Vfs::WRITABLE)) |
|
340 | + if (!($from_stat = self::url_stat($url_from, 0)) || !Vfs::check_access(Vfs::dirname($url_from), Vfs::WRITABLE)) |
|
341 | 341 | { |
342 | 342 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $from[path] permission denied!"); |
343 | - return false; // no permission or file does not exist |
|
343 | + return false; // no permission or file does not exist |
|
344 | 344 | } |
345 | 345 | $to_dir = Vfs::dirname($url_to); |
346 | - if (!Vfs::check_access($to_dir,Vfs::WRITABLE,$to_dir_stat = self::url_stat($to_dir,0))) |
|
346 | + if (!Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = self::url_stat($to_dir, 0))) |
|
347 | 347 | { |
348 | 348 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $to_dir permission denied!"); |
349 | - return false; // no permission or parent-dir does not exist |
|
349 | + return false; // no permission or parent-dir does not exist |
|
350 | 350 | } |
351 | 351 | if (self::deny_script($url_to)) |
352 | 352 | { |
@@ -355,12 +355,12 @@ discard block |
||
355 | 355 | } |
356 | 356 | // the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems |
357 | 357 | // for our vfs too, we abort here with an error, like the filesystem one does |
358 | - if (($to_stat = self::url_stat($to['path'],0)) && |
|
358 | + if (($to_stat = self::url_stat($to['path'], 0)) && |
|
359 | 359 | ($to_stat['mime'] === self::DIR_MIME_TYPE) !== ($from_stat['mime'] === self::DIR_MIME_TYPE)) |
360 | 360 | { |
361 | 361 | $is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no'; |
362 | 362 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) $to[path] is $is_dir directory!"); |
363 | - return false; // no permission or file does not exist |
|
363 | + return false; // no permission or file does not exist |
|
364 | 364 | } |
365 | 365 | // if destination file already exists, delete it |
366 | 366 | if ($to_stat && !self::unlink($url_to)) |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!"); |
369 | 369 | return false; |
370 | 370 | } |
371 | - return rename(Vfs::decodePath($from['path']),Vfs::decodePath($to['path'])); |
|
371 | + return rename(Vfs::decodePath($from['path']), Vfs::decodePath($to['path'])); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -382,12 +382,12 @@ discard block |
||
382 | 382 | * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE |
383 | 383 | * @return boolean TRUE on success or FALSE on failure |
384 | 384 | */ |
385 | - static function mkdir ( $url, $mode, $options ) |
|
385 | + static function mkdir($url, $mode, $options) |
|
386 | 386 | { |
387 | - unset($mode); // not used, but required by interface |
|
387 | + unset($mode); // not used, but required by interface |
|
388 | 388 | |
389 | - $path = Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)); |
|
390 | - $recursive = (bool)($options & STREAM_MKDIR_RECURSIVE); |
|
389 | + $path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)); |
|
390 | + $recursive = (bool)($options&STREAM_MKDIR_RECURSIVE); |
|
391 | 391 | |
392 | 392 | // find the real parent (might be more then one level if $recursive!) |
393 | 393 | do { |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | //echo __METHOD__."($url,$mode,$options) path=$path, recursive=$recursive, parent=$parent, Vfs::check_access(parent_url=$parent_url,Vfs::WRITABLE)=".(int)Vfs::check_access($parent_url,Vfs::WRITABLE)."\n"; |
399 | 399 | |
400 | 400 | // check access rights (in real filesystem AND by mount perms) |
401 | - if (file_exists($path) || !file_exists($parent) || !is_writable($parent) || !Vfs::check_access($parent_url,Vfs::WRITABLE)) |
|
401 | + if (file_exists($path) || !file_exists($parent) || !is_writable($parent) || !Vfs::check_access($parent_url, Vfs::WRITABLE)) |
|
402 | 402 | { |
403 | 403 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
404 | 404 | return false; |
405 | 405 | } |
406 | - return mkdir($path, 0700, $recursive); // setting mode 0700 allows (only) apache to write into the dir |
|
406 | + return mkdir($path, 0700, $recursive); // setting mode 0700 allows (only) apache to write into the dir |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -416,15 +416,15 @@ discard block |
||
416 | 416 | * @param int $options Possible values include STREAM_REPORT_ERRORS. |
417 | 417 | * @return boolean TRUE on success or FALSE on failure. |
418 | 418 | */ |
419 | - static function rmdir ( $url, $options ) |
|
419 | + static function rmdir($url, $options) |
|
420 | 420 | { |
421 | - unset($options); // not used, but required by interface |
|
421 | + unset($options); // not used, but required by interface |
|
422 | 422 | |
423 | - $path = Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)); |
|
423 | + $path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)); |
|
424 | 424 | $parent = dirname($path); |
425 | 425 | |
426 | 426 | // check access rights (in real filesystem AND by mount perms) |
427 | - if (!file_exists($path) || !is_writable($parent) || !Vfs::check_access(Vfs::dirname($url),Vfs::WRITABLE)) |
|
427 | + if (!file_exists($path) || !is_writable($parent) || !Vfs::check_access(Vfs::dirname($url), Vfs::WRITABLE)) |
|
428 | 428 | { |
429 | 429 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
430 | 430 | return false; |
@@ -440,18 +440,18 @@ discard block |
||
440 | 440 | * @param int $atime =null access time (unix timestamp), default null = current time, not implemented in the vfs! |
441 | 441 | * @return boolean true on success, false otherwise |
442 | 442 | */ |
443 | - static function touch($url,$time=null,$atime=null) |
|
443 | + static function touch($url, $time = null, $atime = null) |
|
444 | 444 | { |
445 | - $path = Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)); |
|
445 | + $path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)); |
|
446 | 446 | $parent = dirname($path); |
447 | 447 | |
448 | 448 | // check access rights (in real filesystem AND by mount perms) |
449 | - if (!file_exists($path) || !is_writable($parent) || !Vfs::check_access(Vfs::dirname($url),Vfs::WRITABLE)) |
|
449 | + if (!file_exists($path) || !is_writable($parent) || !Vfs::check_access(Vfs::dirname($url), Vfs::WRITABLE)) |
|
450 | 450 | { |
451 | 451 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
452 | 452 | return false; |
453 | 453 | } |
454 | - return touch($path,$time,$atime); |
|
454 | + return touch($path, $time, $atime); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | /** |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | * @param string $mode mode string see Vfs::mode2int |
464 | 464 | * @return boolean true on success, false otherwise |
465 | 465 | */ |
466 | - static function chmod($path,$mode) |
|
466 | + static function chmod($path, $mode) |
|
467 | 467 | { |
468 | - unset($path, $mode); // not used, but required by interface |
|
468 | + unset($path, $mode); // not used, but required by interface |
|
469 | 469 | |
470 | 470 | return false; |
471 | 471 | } |
@@ -479,9 +479,9 @@ discard block |
||
479 | 479 | * @param int $owner numeric user id |
480 | 480 | * @return boolean true on success, false otherwise |
481 | 481 | */ |
482 | - static function chown($path,$owner) |
|
482 | + static function chown($path, $owner) |
|
483 | 483 | { |
484 | - unset($path, $owner); // not used, but required by interface |
|
484 | + unset($path, $owner); // not used, but required by interface |
|
485 | 485 | |
486 | 486 | return false; |
487 | 487 | } |
@@ -495,9 +495,9 @@ discard block |
||
495 | 495 | * @param int $group numeric group id |
496 | 496 | * @return boolean true on success, false otherwise |
497 | 497 | */ |
498 | - static function chgrp($path,$group) |
|
498 | + static function chgrp($path, $group) |
|
499 | 499 | { |
500 | - unset($path, $group); // not used, but required by interface |
|
500 | + unset($path, $group); // not used, but required by interface |
|
501 | 501 | |
502 | 502 | return false; |
503 | 503 | } |
@@ -509,13 +509,13 @@ discard block |
||
509 | 509 | * @param int $options |
510 | 510 | * @return booelan |
511 | 511 | */ |
512 | - function dir_opendir ( $url, $options ) |
|
512 | + function dir_opendir($url, $options) |
|
513 | 513 | { |
514 | 514 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options)"); |
515 | 515 | |
516 | 516 | $this->opened_dir = null; |
517 | 517 | |
518 | - $path = Vfs::decodePath(Vfs::parse_url($this->opened_dir_url = $url,PHP_URL_PATH)); |
|
518 | + $path = Vfs::decodePath(Vfs::parse_url($this->opened_dir_url = $url, PHP_URL_PATH)); |
|
519 | 519 | |
520 | 520 | // ToDo: check access rights |
521 | 521 | |
@@ -553,31 +553,31 @@ discard block |
||
553 | 553 | * stat triggers it's own warning anyway, so it makes no sense to trigger one by our stream-wrapper! |
554 | 554 | * @return array |
555 | 555 | */ |
556 | - static function url_stat ( $url, $flags ) |
|
556 | + static function url_stat($url, $flags) |
|
557 | 557 | { |
558 | 558 | $parts = Vfs::parse_url($url); |
559 | 559 | $path = Vfs::decodePath($parts['path']); |
560 | 560 | |
561 | - $stat = @stat($path); // suppressed the stat failed warnings |
|
561 | + $stat = @stat($path); // suppressed the stat failed warnings |
|
562 | 562 | |
563 | 563 | if ($stat) |
564 | 564 | { |
565 | 565 | // set owner, group and mode from mount options |
566 | 566 | $uid = $gid = $mode = null; |
567 | - if (!self::parse_query($parts['query'],$uid,$gid,$mode)) |
|
567 | + if (!self::parse_query($parts['query'], $uid, $gid, $mode)) |
|
568 | 568 | { |
569 | 569 | return false; |
570 | 570 | } |
571 | 571 | $stat['uid'] = $stat[4] = $uid; |
572 | 572 | $stat['gid'] = $stat[5] = $gid; |
573 | - $stat['mode'] = $stat[2] = $stat['mode'] & self::MODE_DIR ? self::MODE_DIR | $mode : self::MODE_FILE | ($mode & ~0111); |
|
573 | + $stat['mode'] = $stat[2] = $stat['mode']&self::MODE_DIR ? self::MODE_DIR|$mode : self::MODE_FILE|($mode&~0111); |
|
574 | 574 | // write rights also depend on the write rights of the webserver |
575 | 575 | if (!is_writable($path)) |
576 | 576 | { |
577 | - $stat['mode'] = $stat[2] = $stat['mode'] & ~0222; |
|
577 | + $stat['mode'] = $stat[2] = $stat['mode']&~0222; |
|
578 | 578 | } |
579 | 579 | } |
580 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags) path=$path, mount_mode=".sprintf('0%o',$mode).", mode=".sprintf('0%o',$stat['mode']).'='.Vfs::int2mode($stat['mode'])); |
|
580 | + if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags) path=$path, mount_mode=".sprintf('0%o', $mode).", mode=".sprintf('0%o', $stat['mode']).'='.Vfs::int2mode($stat['mode'])); |
|
581 | 581 | return $stat; |
582 | 582 | } |
583 | 583 | |
@@ -591,13 +591,13 @@ discard block |
||
591 | 591 | * |
592 | 592 | * @return string |
593 | 593 | */ |
594 | - function dir_readdir ( ) |
|
594 | + function dir_readdir( ) |
|
595 | 595 | { |
596 | 596 | do { |
597 | 597 | $file = readdir($this->opened_dir); |
598 | 598 | |
599 | - $ignore = !($file === false || // stop if no more dirs or |
|
600 | - ($file != '.' && $file != '..' )); // file not . or .. |
|
599 | + $ignore = !($file === false || // stop if no more dirs or |
|
600 | + ($file != '.' && $file != '..')); // file not . or .. |
|
601 | 601 | if (self::LOG_LEVEL > 1 && $ignore) error_log(__METHOD__.'() ignoring '.array2string($file)); |
602 | 602 | } |
603 | 603 | while ($ignore); |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | * |
619 | 619 | * @return boolean |
620 | 620 | */ |
621 | - function dir_rewinddir ( ) |
|
621 | + function dir_rewinddir( ) |
|
622 | 622 | { |
623 | 623 | return rewinddir($this->opened_dir); |
624 | 624 | } |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | * |
631 | 631 | * @return boolean |
632 | 632 | */ |
633 | - function dir_closedir ( ) |
|
633 | + function dir_closedir( ) |
|
634 | 634 | { |
635 | 635 | closedir($this->opened_dir); |
636 | 636 | |
@@ -648,18 +648,18 @@ discard block |
||
648 | 648 | * @param int &$mode default if not set is 05 r-x for others |
649 | 649 | * @return boolean true on successfull parse, false on error |
650 | 650 | */ |
651 | - static function parse_query($query,&$uid,&$gid,&$mode) |
|
651 | + static function parse_query($query, &$uid, &$gid, &$mode) |
|
652 | 652 | { |
653 | 653 | $params = null; |
654 | - parse_str(is_array($query) ? $query['query'] : $query,$params); |
|
654 | + parse_str(is_array($query) ? $query['query'] : $query, $params); |
|
655 | 655 | |
656 | 656 | // setting the default perms root.root r-x for other |
657 | 657 | $uid = $gid = 0; |
658 | 658 | $mode = 05; |
659 | 659 | |
660 | - foreach($params as $name => $value) |
|
660 | + foreach ($params as $name => $value) |
|
661 | 661 | { |
662 | - switch($name) |
|
662 | + switch ($name) |
|
663 | 663 | { |
664 | 664 | case 'user': |
665 | 665 | if (!is_numeric($value)) |
@@ -668,10 +668,10 @@ discard block |
||
668 | 668 | { |
669 | 669 | $value = 0; |
670 | 670 | } |
671 | - elseif (($value = $GLOBALS['egw']->accounts->name2id($value,'account_lid','u')) === false) |
|
671 | + elseif (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'u')) === false) |
|
672 | 672 | { |
673 | 673 | error_log(__METHOD__."('$query') unknown user-name '$value'!"); |
674 | - return false; // wrong user-name |
|
674 | + return false; // wrong user-name |
|
675 | 675 | } |
676 | 676 | } |
677 | 677 | // fall-through |
@@ -690,12 +690,12 @@ discard block |
||
690 | 690 | { |
691 | 691 | $value = 0; |
692 | 692 | } |
693 | - elseif (($value = $GLOBALS['egw']->accounts->name2id($value,'account_lid','g')) === false) |
|
693 | + elseif (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'g')) === false) |
|
694 | 694 | { |
695 | 695 | error_log(__METHOD__."('$query') unknown group-name '$value'!"); |
696 | - return false; // wrong group-name |
|
696 | + return false; // wrong group-name |
|
697 | 697 | } |
698 | - $value = -$value; // vfs uses positiv gid's! |
|
698 | + $value = -$value; // vfs uses positiv gid's! |
|
699 | 699 | } |
700 | 700 | // fall-through |
701 | 701 | case 'gid': |
@@ -731,9 +731,9 @@ discard block |
||
731 | 731 | { |
732 | 732 | $parts = Vfs::parse_url($url); |
733 | 733 | $get = null; |
734 | - parse_str($parts['query'],$get); |
|
734 | + parse_str($parts['query'], $get); |
|
735 | 735 | |
736 | - $deny = !$get['exec'] && preg_match(self::SCRIPT_EXTENSIONS_PREG,$parts['path']); |
|
736 | + $deny = !$get['exec'] && preg_match(self::SCRIPT_EXTENSIONS_PREG, $parts['path']); |
|
737 | 737 | |
738 | 738 | if (self::LOG_LEVEL > 1 || self::LOG_LEVEL > 0 && $deny) |
739 | 739 | { |
@@ -753,21 +753,21 @@ discard block |
||
753 | 753 | * @todo get $force_download working through webdav |
754 | 754 | * @return string|false string with full download url or false to use default webdav.php url |
755 | 755 | */ |
756 | - static function download_url($_url,$force_download=false) |
|
756 | + static function download_url($_url, $force_download = false) |
|
757 | 757 | { |
758 | - unset($force_download); // not used, but required by interface |
|
758 | + unset($force_download); // not used, but required by interface |
|
759 | 759 | |
760 | - list($url,$query) = explode('?',$_url,2); |
|
760 | + list($url, $query) = explode('?', $_url, 2); |
|
761 | 761 | $get = null; |
762 | - parse_str($query,$get); |
|
763 | - if (empty($get['url'])) return false; // no download url given for this mount-point |
|
762 | + parse_str($query, $get); |
|
763 | + if (empty($get['url'])) return false; // no download url given for this mount-point |
|
764 | 764 | |
765 | - if (!($mount_url = Vfs::mount_url($_url))) return false; // no mount url found, should not happen |
|
766 | - list($mount_url) = explode('?',$mount_url); |
|
765 | + if (!($mount_url = Vfs::mount_url($_url))) return false; // no mount url found, should not happen |
|
766 | + list($mount_url) = explode('?', $mount_url); |
|
767 | 767 | |
768 | - $relpath = substr($url,strlen($mount_url)); |
|
768 | + $relpath = substr($url, strlen($mount_url)); |
|
769 | 769 | |
770 | - $download_url = Vfs::concat($get['url'],$relpath); |
|
770 | + $download_url = Vfs::concat($get['url'], $relpath); |
|
771 | 771 | if ($download_url[0] == '/') |
772 | 772 | { |
773 | 773 | $download_url = ($_SERVER['HTTPS'] ? 'https://' : 'http://'). |
@@ -80,10 +80,10 @@ |
||
80 | 80 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
81 | 81 | * |
82 | 82 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
83 | - * { |
|
83 | + * { |
|
84 | 84 | * $eof = !$eof; |
85 | 85 | * } |
86 | - * |
|
86 | + * |
|
87 | 87 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
88 | 88 | */ |
89 | 89 | function stream_eof ( ); |
@@ -131,14 +131,20 @@ discard block |
||
131 | 131 | $read_only = str_replace('b','',$mode) == 'r'; |
132 | 132 | |
133 | 133 | // check access rights, based on the eGW mount perms |
134 | - if (!($stat = self::url_stat($url,0)) || $mode[0] == 'x') // file not found or file should NOT exist |
|
134 | + if (!($stat = self::url_stat($url,0)) || $mode[0] == 'x') |
|
135 | + { |
|
136 | + // file not found or file should NOT exist |
|
135 | 137 | { |
136 | 138 | $dir = Vfs::dirname($url); |
139 | + } |
|
137 | 140 | if ($mode[0] == 'r' || // does $mode require the file to exist (r,r+) |
138 | 141 | $mode[0] == 'x' || // or file should not exist, but does |
139 | - !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=self::url_stat($dir,0))) // or we are not allowed to create it |
|
142 | + !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=self::url_stat($dir,0))) |
|
143 | + { |
|
144 | + // or we are not allowed to create it |
|
140 | 145 | { |
141 | 146 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!"); |
147 | + } |
|
142 | 148 | if (!($options & STREAM_URL_STAT_QUIET)) |
143 | 149 | { |
144 | 150 | trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!",E_USER_WARNING); |
@@ -146,9 +152,12 @@ discard block |
||
146 | 152 | return false; |
147 | 153 | } |
148 | 154 | } |
149 | - elseif (!$read_only && !Vfs::check_access($url,Vfs::WRITABLE,$stat)) // we are not allowed to edit it |
|
155 | + elseif (!$read_only && !Vfs::check_access($url,Vfs::WRITABLE,$stat)) |
|
156 | + { |
|
157 | + // we are not allowed to edit it |
|
150 | 158 | { |
151 | 159 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file can not be edited!"); |
160 | + } |
|
152 | 161 | if (!($options & STREAM_URL_STAT_QUIET)) |
153 | 162 | { |
154 | 163 | trigger_error(__METHOD__."($url,$mode,$options) file can not be edited!",E_USER_WARNING); |
@@ -157,7 +166,10 @@ discard block |
||
157 | 166 | } |
158 | 167 | if (!$read_only && self::deny_script($url)) |
159 | 168 | { |
160 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) permission denied, file is a script!"); |
|
169 | + if (self::LOG_LEVEL) |
|
170 | + { |
|
171 | + error_log(__METHOD__."($url,$mode,$options) permission denied, file is a script!"); |
|
172 | + } |
|
161 | 173 | if (!($options & STREAM_URL_STAT_QUIET)) |
162 | 174 | { |
163 | 175 | trigger_error(__METHOD__."($url,$mode,$options) permission denied, file is a script!",E_USER_WARNING); |
@@ -168,7 +180,10 @@ discard block |
||
168 | 180 | // open the "real" file |
169 | 181 | if (!($this->opened_stream = fopen($path=Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)),$mode,$options))) |
170 | 182 | { |
171 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) fopen('$path','$mode',$options) returned false!"); |
|
183 | + if (self::LOG_LEVEL) |
|
184 | + { |
|
185 | + error_log(__METHOD__."($url,$mode,$options) fopen('$path','$mode',$options) returned false!"); |
|
186 | + } |
|
172 | 187 | return false; |
173 | 188 | } |
174 | 189 | $this->opened_stream_url = $url; |
@@ -313,7 +328,10 @@ discard block |
||
313 | 328 | // check access rights (file need to exist and directory need to be writable |
314 | 329 | if (!file_exists($path) || is_dir($path) || !Vfs::check_access(Vfs::dirname($url),Vfs::WRITABLE)) |
315 | 330 | { |
316 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
|
331 | + if (self::LOG_LEVEL) |
|
332 | + { |
|
333 | + error_log(__METHOD__."($url) permission denied!"); |
|
334 | + } |
|
317 | 335 | return false; // no permission or file does not exist |
318 | 336 | } |
319 | 337 | return unlink($path); |
@@ -339,18 +357,27 @@ discard block |
||
339 | 357 | // check access rights |
340 | 358 | if (!($from_stat = self::url_stat($url_from,0)) || !Vfs::check_access(Vfs::dirname($url_from),Vfs::WRITABLE)) |
341 | 359 | { |
342 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $from[path] permission denied!"); |
|
360 | + if (self::LOG_LEVEL) |
|
361 | + { |
|
362 | + error_log(__METHOD__."($url_from,$url_to): $from[path] permission denied!"); |
|
363 | + } |
|
343 | 364 | return false; // no permission or file does not exist |
344 | 365 | } |
345 | 366 | $to_dir = Vfs::dirname($url_to); |
346 | 367 | if (!Vfs::check_access($to_dir,Vfs::WRITABLE,$to_dir_stat = self::url_stat($to_dir,0))) |
347 | 368 | { |
348 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $to_dir permission denied!"); |
|
369 | + if (self::LOG_LEVEL) |
|
370 | + { |
|
371 | + error_log(__METHOD__."($url_from,$url_to): $to_dir permission denied!"); |
|
372 | + } |
|
349 | 373 | return false; // no permission or parent-dir does not exist |
350 | 374 | } |
351 | 375 | if (self::deny_script($url_to)) |
352 | 376 | { |
353 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to) permission denied, file is a script!"); |
|
377 | + if (self::LOG_LEVEL) |
|
378 | + { |
|
379 | + error_log(__METHOD__."($url_from,$url_to) permission denied, file is a script!"); |
|
380 | + } |
|
354 | 381 | return false; |
355 | 382 | } |
356 | 383 | // the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems |
@@ -359,13 +386,19 @@ discard block |
||
359 | 386 | ($to_stat['mime'] === self::DIR_MIME_TYPE) !== ($from_stat['mime'] === self::DIR_MIME_TYPE)) |
360 | 387 | { |
361 | 388 | $is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no'; |
362 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) $to[path] is $is_dir directory!"); |
|
389 | + if (self::LOG_LEVEL) |
|
390 | + { |
|
391 | + error_log(__METHOD__."($url_to,$url_from) $to[path] is $is_dir directory!"); |
|
392 | + } |
|
363 | 393 | return false; // no permission or file does not exist |
364 | 394 | } |
365 | 395 | // if destination file already exists, delete it |
366 | 396 | if ($to_stat && !self::unlink($url_to)) |
367 | 397 | { |
368 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!"); |
|
398 | + if (self::LOG_LEVEL) |
|
399 | + { |
|
400 | + error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!"); |
|
401 | + } |
|
369 | 402 | return false; |
370 | 403 | } |
371 | 404 | return rename(Vfs::decodePath($from['path']),Vfs::decodePath($to['path'])); |
@@ -400,7 +433,10 @@ discard block |
||
400 | 433 | // check access rights (in real filesystem AND by mount perms) |
401 | 434 | if (file_exists($path) || !file_exists($parent) || !is_writable($parent) || !Vfs::check_access($parent_url,Vfs::WRITABLE)) |
402 | 435 | { |
403 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
|
436 | + if (self::LOG_LEVEL) |
|
437 | + { |
|
438 | + error_log(__METHOD__."($url) permission denied!"); |
|
439 | + } |
|
404 | 440 | return false; |
405 | 441 | } |
406 | 442 | return mkdir($path, 0700, $recursive); // setting mode 0700 allows (only) apache to write into the dir |
@@ -426,7 +462,10 @@ discard block |
||
426 | 462 | // check access rights (in real filesystem AND by mount perms) |
427 | 463 | if (!file_exists($path) || !is_writable($parent) || !Vfs::check_access(Vfs::dirname($url),Vfs::WRITABLE)) |
428 | 464 | { |
429 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
|
465 | + if (self::LOG_LEVEL) |
|
466 | + { |
|
467 | + error_log(__METHOD__."($url) permission denied!"); |
|
468 | + } |
|
430 | 469 | return false; |
431 | 470 | } |
432 | 471 | return rmdir($path); |
@@ -448,7 +487,10 @@ discard block |
||
448 | 487 | // check access rights (in real filesystem AND by mount perms) |
449 | 488 | if (!file_exists($path) || !is_writable($parent) || !Vfs::check_access(Vfs::dirname($url),Vfs::WRITABLE)) |
450 | 489 | { |
451 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
|
490 | + if (self::LOG_LEVEL) |
|
491 | + { |
|
492 | + error_log(__METHOD__."($url) permission denied!"); |
|
493 | + } |
|
452 | 494 | return false; |
453 | 495 | } |
454 | 496 | return touch($path,$time,$atime); |
@@ -511,7 +553,10 @@ discard block |
||
511 | 553 | */ |
512 | 554 | function dir_opendir ( $url, $options ) |
513 | 555 | { |
514 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options)"); |
|
556 | + if (self::LOG_LEVEL > 1) |
|
557 | + { |
|
558 | + error_log(__METHOD__."($url,$options)"); |
|
559 | + } |
|
515 | 560 | |
516 | 561 | $this->opened_dir = null; |
517 | 562 | |
@@ -521,7 +566,10 @@ discard block |
||
521 | 566 | |
522 | 567 | if (!($this->opened_dir = opendir($path))) |
523 | 568 | { |
524 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."($url,$options) opendir('$path') failed!"); |
|
569 | + if (self::LOG_LEVEL > 0) |
|
570 | + { |
|
571 | + error_log(__METHOD__."($url,$options) opendir('$path') failed!"); |
|
572 | + } |
|
525 | 573 | return false; |
526 | 574 | } |
527 | 575 | return true; |
@@ -577,7 +625,10 @@ discard block |
||
577 | 625 | $stat['mode'] = $stat[2] = $stat['mode'] & ~0222; |
578 | 626 | } |
579 | 627 | } |
580 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags) path=$path, mount_mode=".sprintf('0%o',$mode).", mode=".sprintf('0%o',$stat['mode']).'='.Vfs::int2mode($stat['mode'])); |
|
628 | + if (self::LOG_LEVEL > 1) |
|
629 | + { |
|
630 | + error_log(__METHOD__."($url,$flags) path=$path, mount_mode=".sprintf('0%o',$mode).", mode=".sprintf('0%o',$stat['mode']).'='.Vfs::int2mode($stat['mode'])); |
|
631 | + } |
|
581 | 632 | return $stat; |
582 | 633 | } |
583 | 634 | |
@@ -598,14 +649,23 @@ discard block |
||
598 | 649 | |
599 | 650 | $ignore = !($file === false || // stop if no more dirs or |
600 | 651 | ($file != '.' && $file != '..' )); // file not . or .. |
601 | - if (self::LOG_LEVEL > 1 && $ignore) error_log(__METHOD__.'() ignoring '.array2string($file)); |
|
652 | + if (self::LOG_LEVEL > 1 && $ignore) |
|
653 | + { |
|
654 | + error_log(__METHOD__.'() ignoring '.array2string($file)); |
|
655 | + } |
|
602 | 656 | } |
603 | 657 | while ($ignore); |
604 | 658 | |
605 | 659 | // encode special chars messing up url's |
606 | - if ($file !== false) $file = Vfs::encodePathComponent($file); |
|
660 | + if ($file !== false) |
|
661 | + { |
|
662 | + $file = Vfs::encodePathComponent($file); |
|
663 | + } |
|
607 | 664 | |
608 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'() returning '.array2string($file)); |
|
665 | + if (self::LOG_LEVEL > 1) |
|
666 | + { |
|
667 | + error_log(__METHOD__.'() returning '.array2string($file)); |
|
668 | + } |
|
609 | 669 | |
610 | 670 | return $file; |
611 | 671 | } |
@@ -760,9 +820,17 @@ discard block |
||
760 | 820 | list($url,$query) = explode('?',$_url,2); |
761 | 821 | $get = null; |
762 | 822 | parse_str($query,$get); |
763 | - if (empty($get['url'])) return false; // no download url given for this mount-point |
|
823 | + if (empty($get['url'])) |
|
824 | + { |
|
825 | + return false; |
|
826 | + } |
|
827 | + // no download url given for this mount-point |
|
764 | 828 | |
765 | - if (!($mount_url = Vfs::mount_url($_url))) return false; // no mount url found, should not happen |
|
829 | + if (!($mount_url = Vfs::mount_url($_url))) |
|
830 | + { |
|
831 | + return false; |
|
832 | + } |
|
833 | + // no mount url found, should not happen |
|
766 | 834 | list($mount_url) = explode('?',$mount_url); |
767 | 835 | |
768 | 836 | $relpath = substr($url,strlen($mount_url)); |
@@ -316,7 +316,7 @@ |
||
316 | 316 | * |
317 | 317 | * @param string $url URL that was passed to opendir() and that this object is expected to explore. |
318 | 318 | * @param $options |
319 | - * @return booelan |
|
319 | + * @return boolean |
|
320 | 320 | */ |
321 | 321 | function dir_opendir ( $url, $options ) |
322 | 322 | { |
@@ -26,7 +26,9 @@ discard block |
||
26 | 26 | */ |
27 | 27 | if (!class_exists('EGroupware\\Api\\Vfs\\Links\\LinksParent', false)) |
28 | 28 | { |
29 | - class LinksParent extends Vfs\Sqlfs\StreamWrapper {} |
|
29 | + class LinksParent extends Vfs\Sqlfs\StreamWrapper |
|
30 | + { |
|
31 | +} |
|
30 | 32 | } |
31 | 33 | |
32 | 34 | /** |
@@ -116,7 +118,10 @@ discard block |
||
116 | 118 | $access = Api\Link::file_access($app,$id,$required,$rel_path,Vfs::$user); |
117 | 119 | $what = "from Api\Link::file_access('$app',$id,$required,'$rel_path,".Vfs::$user.")"; |
118 | 120 | } |
119 | - if (self::DEBUG) error_log(__METHOD__."($url,$check) user=".Vfs::$user." ($what) ".($access?"access granted ($app:$id:$rel_path)":'no access!!!')); |
|
121 | + if (self::DEBUG) |
|
122 | + { |
|
123 | + error_log(__METHOD__."($url,$check) user=".Vfs::$user." ($what) ".($access?"access granted ($app:$id:$rel_path)":'no access!!!')); |
|
124 | + } |
|
120 | 125 | return $access; |
121 | 126 | } |
122 | 127 | |
@@ -180,7 +185,10 @@ discard block |
||
180 | 185 | ); |
181 | 186 | } |
182 | 187 | } |
183 | - if (self::DEBUG) error_log(__METHOD__."('$url', $flags) calling parent::url_stat(,,".array2string($eacl_check).') returning '.array2string($ret)); |
|
188 | + if (self::DEBUG) |
|
189 | + { |
|
190 | + error_log(__METHOD__."('$url', $flags) calling parent::url_stat(,,".array2string($eacl_check).') returning '.array2string($ret)); |
|
191 | + } |
|
184 | 192 | return $ret; |
185 | 193 | } |
186 | 194 | |
@@ -238,19 +246,30 @@ discard block |
||
238 | 246 | |
239 | 247 | if($path[0] != '/') |
240 | 248 | { |
241 | - if (strpos($path,'?') !== false) $query = Vfs::parse_url($path,PHP_URL_QUERY); |
|
249 | + if (strpos($path,'?') !== false) |
|
250 | + { |
|
251 | + $query = Vfs::parse_url($path,PHP_URL_QUERY); |
|
252 | + } |
|
242 | 253 | $path = Vfs::parse_url($path,PHP_URL_PATH).($query ? '?'.$query : ''); |
243 | 254 | } |
244 | 255 | list(,$apps,$app,$id) = explode('/',$path); |
245 | 256 | |
246 | 257 | $ret = false; |
247 | - if ($apps == 'apps' && $app && !$id || self::check_extended_acl($path,Vfs::WRITABLE)) // app directory itself is allways ok |
|
258 | + if ($apps == 'apps' && $app && !$id || self::check_extended_acl($path,Vfs::WRITABLE)) |
|
259 | + { |
|
260 | + // app directory itself is allways ok |
|
248 | 261 | { |
249 | - $current_is_root = Vfs::$is_root; Vfs::$is_root = true; |
|
262 | + $current_is_root = Vfs::$is_root; |
|
263 | + } |
|
264 | + Vfs::$is_root = true; |
|
250 | 265 | $current_user = Vfs::$user; Vfs::$user = 0; |
251 | 266 | |
252 | 267 | $ret = parent::mkdir($path,0,$options|STREAM_MKDIR_RECURSIVE); |
253 | - if ($id) parent::chmod($path,0); // no other rights |
|
268 | + if ($id) |
|
269 | + { |
|
270 | + parent::chmod($path,0); |
|
271 | + } |
|
272 | + // no other rights |
|
254 | 273 | |
255 | 274 | Vfs::$user = $current_user; |
256 | 275 | Vfs::$is_root = $current_is_root; |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | * @param int $check mode to check: one or more or'ed together of: 4 = read, 2 = write, 1 = executable |
77 | 77 | * @return boolean |
78 | 78 | */ |
79 | - static function check_extended_acl($url,$check) |
|
79 | + static function check_extended_acl($url, $check) |
|
80 | 80 | { |
81 | 81 | if (Vfs::$is_root) |
82 | 82 | { |
83 | 83 | return true; |
84 | 84 | } |
85 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
85 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
86 | 86 | |
87 | - list(,$apps,$app,$id,$rel_path) = explode('/',$path,5); |
|
87 | + list(,$apps, $app, $id, $rel_path) = explode('/', $path, 5); |
|
88 | 88 | |
89 | 89 | if ($apps != 'apps') |
90 | 90 | { |
91 | - $access = false; // no access to anything, but /apps |
|
91 | + $access = false; // no access to anything, but /apps |
|
92 | 92 | $what = '!= apps'; |
93 | 93 | } |
94 | 94 | elseif (!$app) |
95 | 95 | { |
96 | - $access = !($check & Vfs::WRITABLE); // always grant read access to /apps |
|
96 | + $access = !($check&Vfs::WRITABLE); // always grant read access to /apps |
|
97 | 97 | $what = '!$app'; |
98 | 98 | } |
99 | - elseif(!isset($GLOBALS['egw_info']['user']['apps'][$app])) |
|
99 | + elseif (!isset($GLOBALS['egw_info']['user']['apps'][$app])) |
|
100 | 100 | { |
101 | - $access = false; // user has no access to the $app application |
|
101 | + $access = false; // user has no access to the $app application |
|
102 | 102 | $what = 'no app-rights'; |
103 | 103 | } |
104 | 104 | elseif (!$id) |
105 | 105 | { |
106 | - $access = true; // grant read&write access to /apps/$app |
|
106 | + $access = true; // grant read&write access to /apps/$app |
|
107 | 107 | $what = 'app dir'; |
108 | 108 | } |
109 | 109 | // allow applications to implement their own access control to the file storage |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | else |
113 | 113 | { |
114 | 114 | // vfs & stream-wrapper use posix rights, egw_link::file_access uses EGW_ACL_{EDIT|READ}! |
115 | - $required = $check & Vfs::WRITABLE ? EGW_ACL_EDIT : EGW_ACL_READ; |
|
116 | - $access = egw_link::file_access($app,$id,$required,$rel_path,Vfs::$user); |
|
115 | + $required = $check&Vfs::WRITABLE ? EGW_ACL_EDIT : EGW_ACL_READ; |
|
116 | + $access = egw_link::file_access($app, $id, $required, $rel_path, Vfs::$user); |
|
117 | 117 | $what = "from egw_link::file_access('$app',$id,$required,'$rel_path,".Vfs::$user.")"; |
118 | 118 | } |
119 | - if (self::DEBUG) error_log(__METHOD__."($url,$check) user=".Vfs::$user." ($what) ".($access?"access granted ($app:$id:$rel_path)":'no access!!!')); |
|
119 | + if (self::DEBUG) error_log(__METHOD__."($url,$check) user=".Vfs::$user." ($what) ".($access ? "access granted ($app:$id:$rel_path)" : 'no access!!!')); |
|
120 | 120 | return $access; |
121 | 121 | } |
122 | 122 | |
@@ -137,19 +137,19 @@ discard block |
||
137 | 137 | * stat triggers it's own warning anyway, so it makes no sense to trigger one by our stream-wrapper! |
138 | 138 | * @return array |
139 | 139 | */ |
140 | - static function url_stat ( $url, $flags ) |
|
140 | + static function url_stat($url, $flags) |
|
141 | 141 | { |
142 | - $eacl_check=self::check_extended_acl($url,Vfs::READABLE); |
|
142 | + $eacl_check = self::check_extended_acl($url, Vfs::READABLE); |
|
143 | 143 | |
144 | 144 | // return vCard as /.entry |
145 | - if ( $eacl_check && substr($url,-7) == '/.entry' && |
|
146 | - (list($app) = array_slice(explode('/',$url),-3,1)) && $app === 'addressbook') |
|
145 | + if ($eacl_check && substr($url, -7) == '/.entry' && |
|
146 | + (list($app) = array_slice(explode('/', $url), -3, 1)) && $app === 'addressbook') |
|
147 | 147 | { |
148 | 148 | $ret = array( |
149 | 149 | 'ino' => md5($url), |
150 | 150 | 'name' => '.entry', |
151 | - 'mode' => self::MODE_FILE|Vfs::READABLE, // required by the stream wrapper |
|
152 | - 'size' => 1024, // fmail does NOT attach files with size 0! |
|
151 | + 'mode' => self::MODE_FILE|Vfs::READABLE, // required by the stream wrapper |
|
152 | + 'size' => 1024, // fmail does NOT attach files with size 0! |
|
153 | 153 | 'uid' => 0, |
154 | 154 | 'gid' => 0, |
155 | 155 | 'mtime' => time(), |
@@ -160,15 +160,15 @@ discard block |
||
160 | 160 | ); |
161 | 161 | } |
162 | 162 | // if entry directory does not exist --> return fake directory |
163 | - elseif (!($ret = parent::url_stat($url,$flags,$eacl_check)) && $eacl_check) |
|
163 | + elseif (!($ret = parent::url_stat($url, $flags, $eacl_check)) && $eacl_check) |
|
164 | 164 | { |
165 | - list(,/*$apps*/,/*$app*/,$id,$rel_path) = explode('/', Vfs::parse_url($url, PHP_URL_PATH), 5); |
|
165 | + list(,/*$apps*/, /*$app*/, $id, $rel_path) = explode('/', Vfs::parse_url($url, PHP_URL_PATH), 5); |
|
166 | 166 | if ($id && !isset($rel_path)) |
167 | 167 | { |
168 | 168 | $ret = array( |
169 | 169 | 'ino' => md5($url), |
170 | 170 | 'name' => $id, |
171 | - 'mode' => self::MODE_DIR, // required by the stream wrapper |
|
171 | + 'mode' => self::MODE_DIR, // required by the stream wrapper |
|
172 | 172 | 'size' => 0, |
173 | 173 | 'uid' => 0, |
174 | 174 | 'gid' => 0, |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | * @param int $fs_id =null fs_id to use, to not query it again (eg. because it's already deleted) |
196 | 196 | * @return boolean true if acl is set/deleted, false on error |
197 | 197 | */ |
198 | - static function eacl($path,$rights=null,$owner=null,$fs_id=null) |
|
198 | + static function eacl($path, $rights = null, $owner = null, $fs_id = null) |
|
199 | 199 | { |
200 | - unset($path, $rights, $owner, $fs_id); // not used, but required by function signature |
|
200 | + unset($path, $rights, $owner, $fs_id); // not used, but required by function signature |
|
201 | 201 | |
202 | 202 | return false; |
203 | 203 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | function get_eacl($path) |
214 | 214 | { |
215 | - unset($path); // not used, but required by function signature |
|
215 | + unset($path); // not used, but required by function signature |
|
216 | 216 | |
217 | 217 | return false; |
218 | 218 | } |
@@ -232,25 +232,25 @@ discard block |
||
232 | 232 | * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE, we allways use recursive! |
233 | 233 | * @return boolean TRUE on success or FALSE on failure |
234 | 234 | */ |
235 | - static function mkdir($path,$mode,$options) |
|
235 | + static function mkdir($path, $mode, $options) |
|
236 | 236 | { |
237 | - unset($mode); // not used, but required by function signature |
|
237 | + unset($mode); // not used, but required by function signature |
|
238 | 238 | |
239 | - if($path[0] != '/') |
|
239 | + if ($path[0] != '/') |
|
240 | 240 | { |
241 | - if (strpos($path,'?') !== false) $query = Vfs::parse_url($path,PHP_URL_QUERY); |
|
242 | - $path = Vfs::parse_url($path,PHP_URL_PATH).($query ? '?'.$query : ''); |
|
241 | + if (strpos($path, '?') !== false) $query = Vfs::parse_url($path, PHP_URL_QUERY); |
|
242 | + $path = Vfs::parse_url($path, PHP_URL_PATH).($query ? '?'.$query : ''); |
|
243 | 243 | } |
244 | - list(,$apps,$app,$id) = explode('/',$path); |
|
244 | + list(,$apps, $app, $id) = explode('/', $path); |
|
245 | 245 | |
246 | 246 | $ret = false; |
247 | - if ($apps == 'apps' && $app && !$id || self::check_extended_acl($path,Vfs::WRITABLE)) // app directory itself is allways ok |
|
247 | + if ($apps == 'apps' && $app && !$id || self::check_extended_acl($path, Vfs::WRITABLE)) // app directory itself is allways ok |
|
248 | 248 | { |
249 | 249 | $current_is_root = Vfs::$is_root; Vfs::$is_root = true; |
250 | 250 | $current_user = Vfs::$user; Vfs::$user = 0; |
251 | 251 | |
252 | - $ret = parent::mkdir($path,0,$options|STREAM_MKDIR_RECURSIVE); |
|
253 | - if ($id) parent::chmod($path,0); // no other rights |
|
252 | + $ret = parent::mkdir($path, 0, $options|STREAM_MKDIR_RECURSIVE); |
|
253 | + if ($id) parent::chmod($path, 0); // no other rights |
|
254 | 254 | |
255 | 255 | Vfs::$user = $current_user; |
256 | 256 | Vfs::$is_root = $current_is_root; |
@@ -274,23 +274,23 @@ discard block |
||
274 | 274 | * @param string $opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set |
275 | 275 | * @return boolean true if the ressource was opened successful, otherwise false |
276 | 276 | */ |
277 | - function stream_open ( $url, $mode, $options, &$opened_path ) |
|
277 | + function stream_open($url, $mode, $options, &$opened_path) |
|
278 | 278 | { |
279 | 279 | // the following call is necessary to fill sqlfs_stream_wrapper::$stat_cache, WITH the extendes ACL! |
280 | - $stat = self::url_stat($url,0); |
|
280 | + $stat = self::url_stat($url, 0); |
|
281 | 281 | //error_log(__METHOD__."('$url', '$mode', $options) stat=".array2string($stat)); |
282 | 282 | |
283 | 283 | // return vCard as /.entry |
284 | - if ($stat && $mode[0] == 'r' && substr($url,-7) === '/.entry' && |
|
285 | - (list($app) = array_slice(explode('/',$url),-3,1)) && $app === 'addressbook') |
|
284 | + if ($stat && $mode[0] == 'r' && substr($url, -7) === '/.entry' && |
|
285 | + (list($app) = array_slice(explode('/', $url), -3, 1)) && $app === 'addressbook') |
|
286 | 286 | { |
287 | - list($id) = array_slice(explode('/',$url),-2,1); |
|
288 | - $ab_vcard = new addressbook_vcal('addressbook','text/vcard'); |
|
287 | + list($id) = array_slice(explode('/', $url), -2, 1); |
|
288 | + $ab_vcard = new addressbook_vcal('addressbook', 'text/vcard'); |
|
289 | 289 | if (!($charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'])) |
290 | 290 | { |
291 | 291 | $charset = 'utf-8'; |
292 | 292 | } |
293 | - if (!($vcard =& $ab_vcard->getVCard($id, $charset))) |
|
293 | + if (!($vcard = & $ab_vcard->getVCard($id, $charset))) |
|
294 | 294 | { |
295 | 295 | error_log(__METHOD__."('$url', '$mode', $options) addressbook_vcal::getVCard($id) returned false!"); |
296 | 296 | return false; |
@@ -302,11 +302,11 @@ discard block |
||
302 | 302 | return true; |
303 | 303 | } |
304 | 304 | // create not existing entry directories on the fly |
305 | - if ($mode[0] != 'r' && !parent::url_stat($dir = Vfs::dirname($url),0) && self::check_extended_acl($dir,Vfs::WRITABLE)) |
|
305 | + if ($mode[0] != 'r' && !parent::url_stat($dir = Vfs::dirname($url), 0) && self::check_extended_acl($dir, Vfs::WRITABLE)) |
|
306 | 306 | { |
307 | - self::mkdir($dir,0,STREAM_MKDIR_RECURSIVE); |
|
307 | + self::mkdir($dir, 0, STREAM_MKDIR_RECURSIVE); |
|
308 | 308 | } |
309 | - return parent::stream_open($url,$mode,$options,$opened_path); |
|
309 | + return parent::stream_open($url, $mode, $options, $opened_path); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @param $options |
319 | 319 | * @return booelan |
320 | 320 | */ |
321 | - function dir_opendir ( $url, $options ) |
|
321 | + function dir_opendir($url, $options) |
|
322 | 322 | { |
323 | 323 | if (!parent::url_stat($url, STREAM_URL_STAT_QUIET) && self::url_stat($url, STREAM_URL_STAT_QUIET)) |
324 | 324 | { |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * |
455 | 455 | * If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now. |
456 | 456 | * |
457 | - * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored. |
|
457 | + * @return boolean TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored. |
|
458 | 458 | */ |
459 | 459 | function stream_flush ( ) |
460 | 460 | { |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | * This method is called immediately when your stream object is created for examining directory contents with opendir(). |
857 | 857 | * |
858 | 858 | * @param string $path URL that was passed to opendir() and that this object is expected to explore. |
859 | - * @return booelan |
|
859 | + * @return boolean |
|
860 | 860 | */ |
861 | 861 | function dir_opendir ( $path, $options ) |
862 | 862 | { |
@@ -1213,7 +1213,7 @@ discard block |
||
1213 | 1213 | * It should reset the output generated by dir_readdir(). i.e.: |
1214 | 1214 | * The next call to dir_readdir() should return the first entry in the location returned by dir_opendir(). |
1215 | 1215 | * |
1216 | - * @return boolean |
|
1216 | + * @return boolean|null |
|
1217 | 1217 | */ |
1218 | 1218 | function dir_rewinddir ( ) |
1219 | 1219 | { |
@@ -1227,7 +1227,7 @@ discard block |
||
1227 | 1227 | * |
1228 | 1228 | * You should release any resources which were locked or allocated during the opening and use of the directory stream. |
1229 | 1229 | * |
1230 | - * @return boolean |
|
1230 | + * @return boolean|null |
|
1231 | 1231 | */ |
1232 | 1232 | function dir_closedir ( ) |
1233 | 1233 | { |
@@ -411,10 +411,10 @@ discard block |
||
411 | 411 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
412 | 412 | * |
413 | 413 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
414 | - * { |
|
414 | + * { |
|
415 | 415 | * $eof = !$eof; |
416 | 416 | * } |
417 | - * |
|
417 | + * |
|
418 | 418 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
419 | 419 | */ |
420 | 420 | function stream_eof ( ) |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1)); |
1054 | 1054 | |
1055 | 1055 | while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) && |
1056 | - ($url = Vfs::dirname($url))) |
|
1056 | + ($url = Vfs::dirname($url))) |
|
1057 | 1057 | { |
1058 | 1058 | if (($stat = self::url_stat($url,0,false,false))) |
1059 | 1059 | { |
@@ -165,7 +165,10 @@ discard block |
||
165 | 165 | { |
166 | 166 | $url = null; |
167 | 167 | $stat = self::check_symlink_components($path,0,$url); |
168 | - if (self::LOG_LEVEL > 1) $log = " (check_symlink_components('$path',0,'$url') = $stat)"; |
|
168 | + if (self::LOG_LEVEL > 1) |
|
169 | + { |
|
170 | + $log = " (check_symlink_components('$path',0,'$url') = $stat)"; |
|
171 | + } |
|
169 | 172 | } |
170 | 173 | else |
171 | 174 | { |
@@ -176,7 +179,10 @@ discard block |
||
176 | 179 | { |
177 | 180 | $url = self::resolve_url(self::parse_url($url,PHP_URL_PATH)); |
178 | 181 | } |
179 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,file_exists=$file_exists,resolve_last_symlink=$resolve_last_symlink) = '$url'$log"); |
|
182 | + if (self::LOG_LEVEL > 1) |
|
183 | + { |
|
184 | + error_log(__METHOD__."($path,file_exists=$file_exists,resolve_last_symlink=$resolve_last_symlink) = '$url'$log"); |
|
185 | + } |
|
180 | 186 | return $url; |
181 | 187 | } |
182 | 188 | |
@@ -204,7 +210,10 @@ discard block |
||
204 | 210 | // we do some caching here |
205 | 211 | if (isset(self::$resolve_url_cache[$path]) && $replace_user_pass_host) |
206 | 212 | { |
207 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '".self::$resolve_url_cache[$path]."' (from cache)"); |
|
213 | + if (self::LOG_LEVEL > 1) |
|
214 | + { |
|
215 | + error_log(__METHOD__."('$path') = '".self::$resolve_url_cache[$path]."' (from cache)"); |
|
216 | + } |
|
208 | 217 | return self::$resolve_url_cache[$path]; |
209 | 218 | } |
210 | 219 | // check if we can already resolve path (or a part of it) with a known symlinks |
@@ -224,14 +233,24 @@ discard block |
||
224 | 233 | ); |
225 | 234 | } |
226 | 235 | $parts = array_merge(self::parse_url($path),$defaults); |
227 | - if (!$parts['host']) $parts['host'] = 'default'; // otherwise we get an invalid url (scheme:///path/to/something)! |
|
236 | + if (!$parts['host']) |
|
237 | + { |
|
238 | + $parts['host'] = 'default'; |
|
239 | + } |
|
240 | + // otherwise we get an invalid url (scheme:///path/to/something)! |
|
228 | 241 | |
229 | 242 | if (!empty($parts['scheme']) && $parts['scheme'] != self::SCHEME) |
230 | 243 | { |
231 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$path' (path is already an url)"); |
|
244 | + if (self::LOG_LEVEL > 1) |
|
245 | + { |
|
246 | + error_log(__METHOD__."('$path') = '$path' (path is already an url)"); |
|
247 | + } |
|
232 | 248 | return $path; // path is already a non-vfs url --> nothing to do |
233 | 249 | } |
234 | - if (empty($parts['path'])) $parts['path'] = '/'; |
|
250 | + if (empty($parts['path'])) |
|
251 | + { |
|
252 | + $parts['path'] = '/'; |
|
253 | + } |
|
235 | 254 | |
236 | 255 | foreach(array_reverse(self::$fstab) as $mounted => $url) |
237 | 256 | { |
@@ -257,17 +276,32 @@ discard block |
||
257 | 276 | { |
258 | 277 | $url = str_replace(array('$user','$pass','$host','$home'),array($parts['user'],$parts['pass'],$parts['host'],$parts['home']),$url); |
259 | 278 | } |
260 | - if ($parts['query']) $url .= '?'.$parts['query']; |
|
261 | - if ($parts['fragment']) $url .= '#'.$parts['fragment']; |
|
279 | + if ($parts['query']) |
|
280 | + { |
|
281 | + $url .= '?'.$parts['query']; |
|
282 | + } |
|
283 | + if ($parts['fragment']) |
|
284 | + { |
|
285 | + $url .= '#'.$parts['fragment']; |
|
286 | + } |
|
262 | 287 | |
263 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$url'"); |
|
288 | + if (self::LOG_LEVEL > 1) |
|
289 | + { |
|
290 | + error_log(__METHOD__."('$path') = '$url'"); |
|
291 | + } |
|
264 | 292 | |
265 | - if ($replace_user_pass_host) self::$resolve_url_cache[$path] = $url; |
|
293 | + if ($replace_user_pass_host) |
|
294 | + { |
|
295 | + self::$resolve_url_cache[$path] = $url; |
|
296 | + } |
|
266 | 297 | |
267 | 298 | return $url; |
268 | 299 | } |
269 | 300 | } |
270 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path') can't resolve path!\n"); |
|
301 | + if (self::LOG_LEVEL > 0) |
|
302 | + { |
|
303 | + error_log(__METHOD__."('$path') can't resolve path!\n"); |
|
304 | + } |
|
271 | 305 | trigger_error(__METHOD__."($path) can't resolve path!\n",E_USER_WARNING); |
272 | 306 | return false; |
273 | 307 | } |
@@ -491,10 +525,13 @@ discard block |
||
491 | 525 | */ |
492 | 526 | static function unlink ( $path ) |
493 | 527 | { |
494 | - if (!($url = self::resolve_url_symlinks($path,true,false))) // true,false file need to exist, but do not resolve last component |
|
528 | + if (!($url = self::resolve_url_symlinks($path,true,false))) |
|
529 | + { |
|
530 | + // true,false file need to exist, but do not resolve last component |
|
495 | 531 | { |
496 | 532 | return false; |
497 | 533 | } |
534 | + } |
|
498 | 535 | if (self::url_is_readonly($url)) |
499 | 536 | { |
500 | 537 | return false; |
@@ -547,7 +584,10 @@ discard block |
||
547 | 584 | $ret = stream_copy_to_stream($from,$to) !== false; |
548 | 585 | fclose($from); |
549 | 586 | fclose($to); |
550 | - if ($ret) self::unlink($path_from); |
|
587 | + if ($ret) |
|
588 | + { |
|
589 | + self::unlink($path_from); |
|
590 | + } |
|
551 | 591 | } |
552 | 592 | else |
553 | 593 | { |
@@ -584,10 +624,13 @@ discard block |
||
584 | 624 | */ |
585 | 625 | static function mkdir ( $path, $mode, $options ) |
586 | 626 | { |
587 | - if (!($url = self::resolve_url_symlinks($path,false))) // false = directory does not need to exists |
|
627 | + if (!($url = self::resolve_url_symlinks($path,false))) |
|
628 | + { |
|
629 | + // false = directory does not need to exists |
|
588 | 630 | { |
589 | 631 | return false; |
590 | 632 | } |
633 | + } |
|
591 | 634 | $ret = mkdir($url,$mode,$options); |
592 | 635 | |
593 | 636 | // call "vfs_mkdir" hook |
@@ -665,7 +708,10 @@ discard block |
||
665 | 708 | return false; |
666 | 709 | } |
667 | 710 | $k=(string)self::parse_url($url,PHP_URL_SCHEME); |
668 | - if (!(is_array($scheme2urls[$k]))) $scheme2urls[$k] = array(); |
|
711 | + if (!(is_array($scheme2urls[$k]))) |
|
712 | + { |
|
713 | + $scheme2urls[$k] = array(); |
|
714 | + } |
|
669 | 715 | $scheme2urls[$k][$path] = $url; |
670 | 716 | } |
671 | 717 | $ret = array(); |
@@ -675,7 +721,10 @@ discard block |
||
675 | 721 | { |
676 | 722 | if (!class_exists($class = self::scheme2class($scheme)) || !method_exists($class,$name)) |
677 | 723 | { |
678 | - if (!$fail_silent) trigger_error("Can't $name for scheme $scheme!\n",E_USER_WARNING); |
|
724 | + if (!$fail_silent) |
|
725 | + { |
|
726 | + trigger_error("Can't $name for scheme $scheme!\n",E_USER_WARNING); |
|
727 | + } |
|
679 | 728 | return false; |
680 | 729 | } |
681 | 730 | if (!is_array($pathes)) |
@@ -793,10 +842,13 @@ discard block |
||
793 | 842 | */ |
794 | 843 | static function symlink($target,$link) |
795 | 844 | { |
796 | - if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1))) // 1=path is in $link! |
|
845 | + if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1))) |
|
846 | + { |
|
847 | + // 1=path is in $link! |
|
797 | 848 | { |
798 | 849 | self::symlinkCache_remove($link); |
799 | 850 | } |
851 | + } |
|
800 | 852 | return $ret; |
801 | 853 | } |
802 | 854 | |
@@ -866,13 +918,19 @@ discard block |
||
866 | 918 | |
867 | 919 | if (!($this->opened_dir_url = self::resolve_url_symlinks($path))) |
868 | 920 | { |
869 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) resolve_url_symlinks() failed!"); |
|
921 | + if (self::LOG_LEVEL > 0) |
|
922 | + { |
|
923 | + error_log(__METHOD__."( $path,$options) resolve_url_symlinks() failed!"); |
|
924 | + } |
|
870 | 925 | return false; |
871 | 926 | } |
872 | 927 | if (!($this->opened_dir = $this->context ? |
873 | 928 | opendir($this->opened_dir_url, $this->context) : opendir($this->opened_dir_url))) |
874 | 929 | { |
875 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!"); |
|
930 | + if (self::LOG_LEVEL > 0) |
|
931 | + { |
|
932 | + error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!"); |
|
933 | + } |
|
876 | 934 | return false; |
877 | 935 | } |
878 | 936 | $this->opened_dir_writable = Vfs::check_access($this->opened_dir_url,Vfs::WRITABLE); |
@@ -890,7 +948,10 @@ discard block |
||
890 | 948 | } |
891 | 949 | |
892 | 950 | |
893 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."( $path,$options): opendir($this->opened_dir_url)=$this->opened_dir, extra_dirs=".array2string($this->extra_dirs).', '.function_backtrace()); |
|
951 | + if (self::LOG_LEVEL > 1) |
|
952 | + { |
|
953 | + error_log(__METHOD__."( $path,$options): opendir($this->opened_dir_url)=$this->opened_dir, extra_dirs=".array2string($this->extra_dirs).', '.function_backtrace()); |
|
954 | + } |
|
894 | 955 | return true; |
895 | 956 | } |
896 | 957 | |
@@ -926,7 +987,10 @@ discard block |
||
926 | 987 | { |
927 | 988 | if (!($url = self::resolve_url($path,!($flags & STREAM_URL_STAT_LINK), $check_symlink_components))) |
928 | 989 | { |
929 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) can NOT resolve path!"); |
|
990 | + if (self::LOG_LEVEL > 0) |
|
991 | + { |
|
992 | + error_log(__METHOD__."('$path',$flags) can NOT resolve path!"); |
|
993 | + } |
|
930 | 994 | return false; |
931 | 995 | } |
932 | 996 | |
@@ -943,18 +1007,27 @@ discard block |
||
943 | 1007 | { |
944 | 1008 | if (!$check_symlink_depth) |
945 | 1009 | { |
946 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) maximum symlink depth exceeded, might be a circular symlink!"); |
|
1010 | + if (self::LOG_LEVEL > 0) |
|
1011 | + { |
|
1012 | + error_log(__METHOD__."('$path',$flags) maximum symlink depth exceeded, might be a circular symlink!"); |
|
1013 | + } |
|
947 | 1014 | $stat = false; |
948 | 1015 | } |
949 | 1016 | elseif (($lpath = self::readlink($url))) |
950 | 1017 | { |
951 | - if ($lpath[0] != '/') // concat relative path |
|
1018 | + if ($lpath[0] != '/') |
|
1019 | + { |
|
1020 | + // concat relative path |
|
952 | 1021 | { |
953 | 1022 | $lpath = Vfs::concat(self::parse_url($path,PHP_URL_PATH),'../'.$lpath); |
954 | 1023 | } |
1024 | + } |
|
955 | 1025 | $u_query = parse_url($url,PHP_URL_QUERY); |
956 | 1026 | $url = Vfs::PREFIX.$lpath; |
957 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$flags) symlif (substr($path,-1) == '/' && $path != '/') $path = substr($path,0,-1); // remove trailing slash eg. added by WebDAVink found and resolved to $url"); |
|
1027 | + if (self::LOG_LEVEL > 1) |
|
1028 | + { |
|
1029 | + error_log(__METHOD__."($path,$flags) symlif (substr($path,-1) == '/' && $path != '/') $path = substr($path,0,-1); // remove trailing slash eg. added by WebDAVink found and resolved to $url"); |
|
1030 | + } |
|
958 | 1031 | // try reading the stat of the link |
959 | 1032 | if (($stat = self::url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth-1))) |
960 | 1033 | { |
@@ -967,7 +1040,11 @@ discard block |
||
967 | 1040 | $stat_query = http_build_query(array_merge($stat_query, $u_query)); |
968 | 1041 | $stat['url'] = $stat_url['scheme'].'://'.$stat_url['host'].$stat_url['path'].'?'.$stat_query; |
969 | 1042 | } |
970 | - if(isset($stat['url'])) $url = $stat['url']; // if stat returns an url use that, as there might be more links ... |
|
1043 | + if(isset($stat['url'])) |
|
1044 | + { |
|
1045 | + $url = $stat['url']; |
|
1046 | + } |
|
1047 | + // if stat returns an url use that, as there might be more links ... |
|
971 | 1048 | self::symlinkCache_add($path,$url); |
972 | 1049 | } |
973 | 1050 | } |
@@ -990,7 +1067,9 @@ discard block |
||
990 | 1067 | // check if a failed url_stat was for a home dir, in that case silently create it |
991 | 1068 | if (!$stat && $try_create_home && Vfs::dirname(self::parse_url($path,PHP_URL_PATH)) == '/home' && |
992 | 1069 | ($id = $GLOBALS['egw']->accounts->name2id(basename($path))) && |
993 | - $GLOBALS['egw']->accounts->id2name($id) == basename($path)) // make sure path has the right case! |
|
1070 | + $GLOBALS['egw']->accounts->id2name($id) == basename($path)) |
|
1071 | + { |
|
1072 | + // make sure path has the right case! |
|
994 | 1073 | { |
995 | 1074 | $hook_data = array( |
996 | 1075 | 'location' => $GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'addgroup' : 'addaccount', |
@@ -998,15 +1077,22 @@ discard block |
||
998 | 1077 | 'account_lid' => basename($path), |
999 | 1078 | 'account_name' => basename($path), |
1000 | 1079 | ); |
1080 | + } |
|
1001 | 1081 | call_user_func(array(__NAMESPACE__.'\\Hooks',$hook_data['location']),$hook_data); |
1002 | 1082 | unset($hook_data); |
1003 | 1083 | $stat = self::url_stat($path,$flags,false); |
1004 | 1084 | } |
1005 | 1085 | $query = parse_url($url, PHP_URL_QUERY); |
1006 | - if (!$stat && $check_symlink_components) // check if there's a symlink somewhere inbetween the path |
|
1086 | + if (!$stat && $check_symlink_components) |
|
1087 | + { |
|
1088 | + // check if there's a symlink somewhere inbetween the path |
|
1007 | 1089 | { |
1008 | 1090 | $stat = self::check_symlink_components($path,$flags,$url); |
1009 | - if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path,$stat['url']); |
|
1091 | + } |
|
1092 | + if ($stat && isset($stat['url']) && !$query) |
|
1093 | + { |
|
1094 | + self::symlinkCache_add($path,$stat['url']); |
|
1095 | + } |
|
1010 | 1096 | } |
1011 | 1097 | elseif(is_array($stat) && !isset($stat['url'])) |
1012 | 1098 | { |
@@ -1021,7 +1107,10 @@ discard block |
||
1021 | 1107 | $stat['url'] .= '?'.$query; |
1022 | 1108 | } |
1023 | 1109 | |
1024 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,try_create_home=$try_create_home,check_symlink_components=$check_symlink_components) returning ".array2string($stat)); |
|
1110 | + if (self::LOG_LEVEL > 1) |
|
1111 | + { |
|
1112 | + error_log(__METHOD__."('$path',$flags,try_create_home=$try_create_home,check_symlink_components=$check_symlink_components) returning ".array2string($stat)); |
|
1113 | + } |
|
1025 | 1114 | |
1026 | 1115 | return $stat; |
1027 | 1116 | |
@@ -1047,10 +1136,16 @@ discard block |
||
1047 | 1136 | { |
1048 | 1137 | if (is_null($url) && !($url = self::resolve_url($path))) |
1049 | 1138 | { |
1050 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags,'$url') can NOT resolve path: ".function_backtrace(1)); |
|
1139 | + if (self::LOG_LEVEL > 0) |
|
1140 | + { |
|
1141 | + error_log(__METHOD__."('$path',$flags,'$url') can NOT resolve path: ".function_backtrace(1)); |
|
1142 | + } |
|
1051 | 1143 | return false; |
1052 | 1144 | } |
1053 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1)); |
|
1145 | + if (self::LOG_LEVEL > 1) |
|
1146 | + { |
|
1147 | + error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1)); |
|
1148 | + } |
|
1054 | 1149 | |
1055 | 1150 | while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) && |
1056 | 1151 | ($url = Vfs::dirname($url))) |
@@ -1059,7 +1154,10 @@ discard block |
||
1059 | 1154 | { |
1060 | 1155 | if (is_link($url) && ($lpath = self::readlink($url))) |
1061 | 1156 | { |
1062 | - if (self::LOG_LEVEL > 1) $log = "rel_path='$rel_path', url='$url': lpath='$lpath'"; |
|
1157 | + if (self::LOG_LEVEL > 1) |
|
1158 | + { |
|
1159 | + $log = "rel_path='$rel_path', url='$url': lpath='$lpath'"; |
|
1160 | + } |
|
1063 | 1161 | |
1064 | 1162 | if ($lpath[0] != '/') |
1065 | 1163 | { |
@@ -1067,15 +1165,24 @@ discard block |
||
1067 | 1165 | } |
1068 | 1166 | //self::symlinkCache_add($path,Vfs::PREFIX.$lpath); |
1069 | 1167 | $url = Vfs::PREFIX.Vfs::concat($lpath,$rel_path); |
1070 | - if (self::LOG_LEVEL > 1) error_log("$log --> lpath='$lpath', url='$url'"); |
|
1168 | + if (self::LOG_LEVEL > 1) |
|
1169 | + { |
|
1170 | + error_log("$log --> lpath='$lpath', url='$url'"); |
|
1171 | + } |
|
1071 | 1172 | return self::url_stat($url,$flags); |
1072 | 1173 | } |
1073 | 1174 | $url = Vfs::concat($url,$rel_path); |
1074 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning null"); |
|
1175 | + if (self::LOG_LEVEL > 1) |
|
1176 | + { |
|
1177 | + error_log(__METHOD__."('$path',$flags,'$url') returning null"); |
|
1178 | + } |
|
1075 | 1179 | return null; |
1076 | 1180 | } |
1077 | 1181 | } |
1078 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning false"); |
|
1182 | + if (self::LOG_LEVEL > 1) |
|
1183 | + { |
|
1184 | + error_log(__METHOD__."('$path',$flags,'$url') returning false"); |
|
1185 | + } |
|
1079 | 1186 | return false; // $path does not exist |
1080 | 1187 | } |
1081 | 1188 | |
@@ -1096,9 +1203,16 @@ discard block |
||
1096 | 1203 | { |
1097 | 1204 | $path = self::get_path($_path); |
1098 | 1205 | |
1099 | - if (isset(self::$symlink_cache[$path])) return; // nothing to do |
|
1206 | + if (isset(self::$symlink_cache[$path])) |
|
1207 | + { |
|
1208 | + return; |
|
1209 | + } |
|
1210 | + // nothing to do |
|
1100 | 1211 | |
1101 | - if ($target[0] != '/') $target = self::parse_url($target,PHP_URL_PATH); |
|
1212 | + if ($target[0] != '/') |
|
1213 | + { |
|
1214 | + $target = self::parse_url($target,PHP_URL_PATH); |
|
1215 | + } |
|
1102 | 1216 | |
1103 | 1217 | self::$symlink_cache[$path] = $target; |
1104 | 1218 | |
@@ -1107,7 +1221,10 @@ discard block |
||
1107 | 1221 | { |
1108 | 1222 | return strlen($a) - strlen($b); |
1109 | 1223 | }); |
1110 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$target) cache now ".array2string(self::$symlink_cache)); |
|
1224 | + if (self::LOG_LEVEL > 1) |
|
1225 | + { |
|
1226 | + error_log(__METHOD__."($path,$target) cache now ".array2string(self::$symlink_cache)); |
|
1227 | + } |
|
1111 | 1228 | } |
1112 | 1229 | |
1113 | 1230 | /** |
@@ -1120,7 +1237,10 @@ discard block |
||
1120 | 1237 | $path = self::get_path($_path); |
1121 | 1238 | |
1122 | 1239 | unset(self::$symlink_cache[$path]); |
1123 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path) cache now ".array2string(self::$symlink_cache)); |
|
1240 | + if (self::LOG_LEVEL > 1) |
|
1241 | + { |
|
1242 | + error_log(__METHOD__."($path) cache now ".array2string(self::$symlink_cache)); |
|
1243 | + } |
|
1124 | 1244 | } |
1125 | 1245 | |
1126 | 1246 | /** |
@@ -1141,11 +1261,18 @@ discard block |
||
1141 | 1261 | |
1142 | 1262 | foreach(self::$symlink_cache as $p => $t) |
1143 | 1263 | { |
1144 | - if (($strlen_p = strlen($p)) > $strlen_path) continue; // $path can NOT start with $p |
|
1264 | + if (($strlen_p = strlen($p)) > $strlen_path) |
|
1265 | + { |
|
1266 | + continue; |
|
1267 | + } |
|
1268 | + // $path can NOT start with $p |
|
1145 | 1269 | |
1146 | 1270 | if ($path == $p) |
1147 | 1271 | { |
1148 | - if ($do_symlink) $target = $t; |
|
1272 | + if ($do_symlink) |
|
1273 | + { |
|
1274 | + $target = $t; |
|
1275 | + } |
|
1149 | 1276 | break; |
1150 | 1277 | } |
1151 | 1278 | elseif (substr($path,0,$strlen_p+1) == $p.'/') |
@@ -1154,7 +1281,10 @@ discard block |
||
1154 | 1281 | break; |
1155 | 1282 | } |
1156 | 1283 | } |
1157 | - if (self::LOG_LEVEL > 1 && isset($target)) error_log(__METHOD__."($path) = $target"); |
|
1284 | + if (self::LOG_LEVEL > 1 && isset($target)) |
|
1285 | + { |
|
1286 | + error_log(__METHOD__."($path) = $target"); |
|
1287 | + } |
|
1158 | 1288 | return isset($target) ? $target : $path; |
1159 | 1289 | } |
1160 | 1290 | |
@@ -1203,7 +1333,10 @@ discard block |
||
1203 | 1333 | self::HIDE_UNREADABLES && !$this->opened_dir_writable && |
1204 | 1334 | !Vfs::check_access(Vfs::concat($this->opened_dir_url,$file),Vfs::READABLE))); |
1205 | 1335 | } |
1206 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."( $this->opened_dir ) = '$file'"); |
|
1336 | + if (self::LOG_LEVEL > 1) |
|
1337 | + { |
|
1338 | + error_log(__METHOD__."( $this->opened_dir ) = '$file'"); |
|
1339 | + } |
|
1207 | 1340 | return $file; |
1208 | 1341 | } |
1209 | 1342 | |
@@ -1306,7 +1439,10 @@ discard block |
||
1306 | 1439 | ) as $class) |
1307 | 1440 | { |
1308 | 1441 | //error_log(__METHOD__."('$scheme') class_exists('$class')=".array2string(class_exists($class))); |
1309 | - if (class_exists($class)) return $class; |
|
1442 | + if (class_exists($class)) |
|
1443 | + { |
|
1444 | + return $class; |
|
1445 | + } |
|
1310 | 1446 | } |
1311 | 1447 | } |
1312 | 1448 | |
@@ -1341,7 +1477,10 @@ discard block |
||
1341 | 1477 | static $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%24', '%2C', '%2F', '%3F', '%23', '%5B', '%5D'); |
1342 | 1478 | static $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "$", ",", "/", "?", "#", "[", "]"); |
1343 | 1479 | static $str_replace = null; |
1344 | - if (!isset($str_replace)) $str_replace = function_exists('mb_str_replace') ? 'mb_str_replace' : 'str_replace'; |
|
1480 | + if (!isset($str_replace)) |
|
1481 | + { |
|
1482 | + $str_replace = function_exists('mb_str_replace') ? 'mb_str_replace' : 'str_replace'; |
|
1483 | + } |
|
1345 | 1484 | |
1346 | 1485 | // Create encoded URL with special URL characters decoded so it can be parsed |
1347 | 1486 | // All other characters will be encoded |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | * @param array|boolean &$stat=null on return: stat of existing file or false for non-existing files |
161 | 161 | * @return string|boolean false if the url cant be resolved, should not happen if fstab has a root entry |
162 | 162 | */ |
163 | - static function resolve_url_symlinks($_path,$file_exists=true,$resolve_last_symlink=true,&$stat=null) |
|
163 | + static function resolve_url_symlinks($_path, $file_exists = true, $resolve_last_symlink = true, &$stat = null) |
|
164 | 164 | { |
165 | 165 | $path = self::get_path($_path); |
166 | 166 | |
167 | - if (!($stat = self::url_stat($path,$resolve_last_symlink?0:STREAM_URL_STAT_LINK)) && !$file_exists) |
|
167 | + if (!($stat = self::url_stat($path, $resolve_last_symlink ? 0 : STREAM_URL_STAT_LINK)) && !$file_exists) |
|
168 | 168 | { |
169 | 169 | $url = null; |
170 | - $stat = self::check_symlink_components($path,0,$url); |
|
170 | + $stat = self::check_symlink_components($path, 0, $url); |
|
171 | 171 | if (self::LOG_LEVEL > 1) $log = " (check_symlink_components('$path',0,'$url') = $stat)"; |
172 | 172 | } |
173 | 173 | else |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | $url = $stat['url']; |
176 | 176 | } |
177 | 177 | // if the url resolves to a symlink to the vfs, resolve this vfs:// url direct |
178 | - if ($url && self::parse_url($url,PHP_URL_SCHEME) == self::SCHEME) |
|
178 | + if ($url && self::parse_url($url, PHP_URL_SCHEME) == self::SCHEME) |
|
179 | 179 | { |
180 | - $url = self::resolve_url(self::parse_url($url,PHP_URL_PATH)); |
|
180 | + $url = self::resolve_url(self::parse_url($url, PHP_URL_PATH)); |
|
181 | 181 | } |
182 | 182 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,file_exists=$file_exists,resolve_last_symlink=$resolve_last_symlink) = '$url'$log"); |
183 | 183 | return $url; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @param boolean $fix_url_query =false true append relativ path to url query parameter, default not |
201 | 201 | * @return string|boolean false if the url cant be resolved, should not happen if fstab has a root entry |
202 | 202 | */ |
203 | - static function resolve_url($_path,$do_symlink=true,$use_symlinkcache=true,$replace_user_pass_host=true,$fix_url_query=false) |
|
203 | + static function resolve_url($_path, $do_symlink = true, $use_symlinkcache = true, $replace_user_pass_host = true, $fix_url_query = false) |
|
204 | 204 | { |
205 | 205 | $path = self::get_path($_path); |
206 | 206 | |
@@ -213,52 +213,52 @@ discard block |
||
213 | 213 | // check if we can already resolve path (or a part of it) with a known symlinks |
214 | 214 | if ($use_symlinkcache) |
215 | 215 | { |
216 | - $path = self::symlinkCache_resolve($path,$do_symlink); |
|
216 | + $path = self::symlinkCache_resolve($path, $do_symlink); |
|
217 | 217 | } |
218 | 218 | // setting default user, passwd and domain, if it's not contained int the url |
219 | - static $defaults=null; |
|
219 | + static $defaults = null; |
|
220 | 220 | if (is_null($defaults)) |
221 | 221 | { |
222 | 222 | $defaults = array( |
223 | 223 | 'user' => $GLOBALS['egw_info']['user']['account_lid'], |
224 | 224 | 'pass' => urlencode($GLOBALS['egw_info']['user']['passwd']), |
225 | 225 | 'host' => $GLOBALS['egw_info']['user']['domain'], |
226 | - 'home' => str_replace(array('\\\\','\\'),array('','/'),$GLOBALS['egw_info']['user']['homedirectory']), |
|
226 | + 'home' => str_replace(array('\\\\', '\\'), array('', '/'), $GLOBALS['egw_info']['user']['homedirectory']), |
|
227 | 227 | ); |
228 | 228 | } |
229 | - $parts = array_merge(self::parse_url($path),$defaults); |
|
230 | - if (!$parts['host']) $parts['host'] = 'default'; // otherwise we get an invalid url (scheme:///path/to/something)! |
|
229 | + $parts = array_merge(self::parse_url($path), $defaults); |
|
230 | + if (!$parts['host']) $parts['host'] = 'default'; // otherwise we get an invalid url (scheme:///path/to/something)! |
|
231 | 231 | |
232 | 232 | if (!empty($parts['scheme']) && $parts['scheme'] != self::SCHEME) |
233 | 233 | { |
234 | 234 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$path' (path is already an url)"); |
235 | - return $path; // path is already a non-vfs url --> nothing to do |
|
235 | + return $path; // path is already a non-vfs url --> nothing to do |
|
236 | 236 | } |
237 | 237 | if (empty($parts['path'])) $parts['path'] = '/'; |
238 | 238 | |
239 | - foreach(array_reverse(self::$fstab) as $mounted => $url) |
|
239 | + foreach (array_reverse(self::$fstab) as $mounted => $url) |
|
240 | 240 | { |
241 | - if ($mounted == '/' || $mounted == $parts['path'] || $mounted.'/' == substr($parts['path'],0,strlen($mounted)+1)) |
|
241 | + if ($mounted == '/' || $mounted == $parts['path'] || $mounted.'/' == substr($parts['path'], 0, strlen($mounted) + 1)) |
|
242 | 242 | { |
243 | - $scheme = self::parse_url($url,PHP_URL_SCHEME); |
|
244 | - if (is_null(self::$wrappers) || !in_array($scheme,self::$wrappers)) |
|
243 | + $scheme = self::parse_url($url, PHP_URL_SCHEME); |
|
244 | + if (is_null(self::$wrappers) || !in_array($scheme, self::$wrappers)) |
|
245 | 245 | { |
246 | 246 | self::load_wrapper($scheme); |
247 | 247 | } |
248 | - if (($relative = substr($parts['path'],strlen($mounted)))) |
|
248 | + if (($relative = substr($parts['path'], strlen($mounted)))) |
|
249 | 249 | { |
250 | - $url = Vfs::concat($url,$relative); |
|
250 | + $url = Vfs::concat($url, $relative); |
|
251 | 251 | } |
252 | 252 | // if url contains url parameter, eg. from filesystem streamwrapper, we need to append relative path here too |
253 | 253 | $matches = null; |
254 | 254 | if ($fix_url_query && preg_match('|([?&]url=)([^&]+)|', $url, $matches)) |
255 | 255 | { |
256 | - $url = str_replace($matches[0], $matches[1].Vfs::concat($matches[2], substr($parts['path'],strlen($mounted))), $url); |
|
256 | + $url = str_replace($matches[0], $matches[1].Vfs::concat($matches[2], substr($parts['path'], strlen($mounted))), $url); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | if ($replace_user_pass_host) |
260 | 260 | { |
261 | - $url = str_replace(array('$user','$pass','$host','$home'),array($parts['user'],$parts['pass'],$parts['host'],$parts['home']),$url); |
|
261 | + $url = str_replace(array('$user', '$pass', '$host', '$home'), array($parts['user'], $parts['pass'], $parts['host'], $parts['home']), $url); |
|
262 | 262 | } |
263 | 263 | if ($parts['query']) $url .= '?'.$parts['query']; |
264 | 264 | if ($parts['fragment']) $url .= '#'.$parts['fragment']; |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | } |
272 | 272 | } |
273 | 273 | if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path') can't resolve path!\n"); |
274 | - trigger_error(__METHOD__."($path) can't resolve path!\n",E_USER_WARNING); |
|
274 | + trigger_error(__METHOD__."($path) can't resolve path!\n", E_USER_WARNING); |
|
275 | 275 | return false; |
276 | 276 | } |
277 | 277 | |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | */ |
284 | 284 | static function mount_url($fullurl) |
285 | 285 | { |
286 | - foreach(array_reverse(self::$fstab) as $url) |
|
286 | + foreach (array_reverse(self::$fstab) as $url) |
|
287 | 287 | { |
288 | - list($url_no_query) = explode('?',$url); |
|
289 | - if (substr($fullurl,0,1+strlen($url_no_query)) === $url_no_query.'/') |
|
288 | + list($url_no_query) = explode('?', $url); |
|
289 | + if (substr($fullurl, 0, 1 + strlen($url_no_query)) === $url_no_query.'/') |
|
290 | 290 | { |
291 | 291 | return $url; |
292 | 292 | } |
@@ -313,13 +313,13 @@ discard block |
||
313 | 313 | * @param string $opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set |
314 | 314 | * @return boolean true if the ressource was opened successful, otherwise false |
315 | 315 | */ |
316 | - function stream_open ( $path, $mode, $options, &$opened_path ) |
|
316 | + function stream_open($path, $mode, $options, &$opened_path) |
|
317 | 317 | { |
318 | - unset($options,$opened_path); // not used but required by function signature |
|
318 | + unset($options, $opened_path); // not used but required by function signature |
|
319 | 319 | $this->opened_stream = null; |
320 | 320 | |
321 | 321 | $stat = null; |
322 | - if (!($url = self::resolve_url_symlinks($path,$mode[0]=='r',true,$stat))) |
|
322 | + if (!($url = self::resolve_url_symlinks($path, $mode[0] == 'r', true, $stat))) |
|
323 | 323 | { |
324 | 324 | return false; |
325 | 325 | } |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * |
355 | 355 | * VFS calls either "vfs_read", "vfs_added" or "vfs_modified" hook |
356 | 356 | */ |
357 | - function stream_close ( ) |
|
357 | + function stream_close( ) |
|
358 | 358 | { |
359 | 359 | $ret = fclose($this->opened_stream); |
360 | 360 | // clear PHP's stat cache, it contains wrong size of just closed file, |
@@ -364,12 +364,11 @@ discard block |
||
364 | 364 | if (isset($GLOBALS['egw']) && isset($GLOBALS['egw']->hooks)) |
365 | 365 | { |
366 | 366 | $GLOBALS['egw']->hooks->process(array( |
367 | - 'location' => str_replace('b','',$this->opened_stream_mode) == 'r' ? 'vfs_read' : |
|
368 | - ($this->opened_stream_is_new ? 'vfs_added' : 'vfs_modified'), |
|
367 | + 'location' => str_replace('b', '', $this->opened_stream_mode) == 'r' ? 'vfs_read' : ($this->opened_stream_is_new ? 'vfs_added' : 'vfs_modified'), |
|
369 | 368 | 'path' => $this->opened_stream_path, |
370 | 369 | 'mode' => $this->opened_stream_mode, |
371 | 370 | 'url' => $this->opened_stream_url, |
372 | - ),'',true); |
|
371 | + ), '', true); |
|
373 | 372 | } |
374 | 373 | $this->opened_stream = $this->opened_stream_mode = $this->opened_stream_path = $this->opened_stream_url = $this->opened_stream_is_new = null; |
375 | 374 | |
@@ -387,9 +386,9 @@ discard block |
||
387 | 386 | * @param int $count |
388 | 387 | * @return string/false up to count bytes read or false on EOF |
389 | 388 | */ |
390 | - function stream_read ( $count ) |
|
389 | + function stream_read($count) |
|
391 | 390 | { |
392 | - return fread($this->opened_stream,$count); |
|
391 | + return fread($this->opened_stream, $count); |
|
393 | 392 | } |
394 | 393 | |
395 | 394 | /** |
@@ -403,9 +402,9 @@ discard block |
||
403 | 402 | * @param string $data |
404 | 403 | * @return integer |
405 | 404 | */ |
406 | - function stream_write ( $data ) |
|
405 | + function stream_write($data) |
|
407 | 406 | { |
408 | - return fwrite($this->opened_stream,$data); |
|
407 | + return fwrite($this->opened_stream, $data); |
|
409 | 408 | } |
410 | 409 | |
411 | 410 | /** |
@@ -420,7 +419,7 @@ discard block |
||
420 | 419 | * |
421 | 420 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
422 | 421 | */ |
423 | - function stream_eof ( ) |
|
422 | + function stream_eof( ) |
|
424 | 423 | { |
425 | 424 | return feof($this->opened_stream); |
426 | 425 | } |
@@ -430,7 +429,7 @@ discard block |
||
430 | 429 | * |
431 | 430 | * @return integer current read/write position of the stream |
432 | 431 | */ |
433 | - function stream_tell ( ) |
|
432 | + function stream_tell( ) |
|
434 | 433 | { |
435 | 434 | return ftell($this->opened_stream); |
436 | 435 | } |
@@ -447,9 +446,9 @@ discard block |
||
447 | 446 | * SEEK_END - 2 - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.) |
448 | 447 | * @return boolean TRUE if the position was updated, FALSE otherwise. |
449 | 448 | */ |
450 | - function stream_seek ( $offset, $whence ) |
|
449 | + function stream_seek($offset, $whence) |
|
451 | 450 | { |
452 | - return !fseek($this->opened_stream,$offset,$whence); // fseek returns 0 on success and -1 on failure |
|
451 | + return !fseek($this->opened_stream, $offset, $whence); // fseek returns 0 on success and -1 on failure |
|
453 | 452 | } |
454 | 453 | |
455 | 454 | /** |
@@ -459,7 +458,7 @@ discard block |
||
459 | 458 | * |
460 | 459 | * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored. |
461 | 460 | */ |
462 | - function stream_flush ( ) |
|
461 | + function stream_flush( ) |
|
463 | 462 | { |
464 | 463 | return fflush($this->opened_stream); |
465 | 464 | } |
@@ -478,7 +477,7 @@ discard block |
||
478 | 477 | * |
479 | 478 | * @return array containing the same values as appropriate for the stream. |
480 | 479 | */ |
481 | - function stream_stat ( ) |
|
480 | + function stream_stat( ) |
|
482 | 481 | { |
483 | 482 | return fstat($this->opened_stream); |
484 | 483 | } |
@@ -492,9 +491,9 @@ discard block |
||
492 | 491 | * @param string $path |
493 | 492 | * @return boolean TRUE on success or FALSE on failure |
494 | 493 | */ |
495 | - static function unlink ( $path ) |
|
494 | + static function unlink($path) |
|
496 | 495 | { |
497 | - if (!($url = self::resolve_url_symlinks($path,true,false))) // true,false file need to exist, but do not resolve last component |
|
496 | + if (!($url = self::resolve_url_symlinks($path, true, false))) // true,false file need to exist, but do not resolve last component |
|
498 | 497 | { |
499 | 498 | return false; |
500 | 499 | } |
@@ -515,7 +514,7 @@ discard block |
||
515 | 514 | 'path' => $path[0] == '/' ? $path : self::parse_url($path, PHP_URL_PATH), |
516 | 515 | 'url' => $url, |
517 | 516 | 'stat' => $stat, |
518 | - ),'',true); |
|
517 | + ), '', true); |
|
519 | 518 | } |
520 | 519 | return $ok; |
521 | 520 | } |
@@ -532,22 +531,22 @@ discard block |
||
532 | 531 | * @param string $path_to |
533 | 532 | * @return boolean TRUE on success or FALSE on failure |
534 | 533 | */ |
535 | - static function rename ( $path_from, $path_to ) |
|
534 | + static function rename($path_from, $path_to) |
|
536 | 535 | { |
537 | - if (!($url_from = self::resolve_url_symlinks($path_from,true,false)) || |
|
538 | - !($url_to = self::resolve_url_symlinks($path_to,false))) |
|
536 | + if (!($url_from = self::resolve_url_symlinks($path_from, true, false)) || |
|
537 | + !($url_to = self::resolve_url_symlinks($path_to, false))) |
|
539 | 538 | { |
540 | 539 | return false; |
541 | 540 | } |
542 | 541 | // if file is moved from one filesystem / wrapper to an other --> copy it (rename fails cross wrappers) |
543 | - if (self::parse_url($url_from,PHP_URL_SCHEME) == self::parse_url($url_to,PHP_URL_SCHEME)) |
|
542 | + if (self::parse_url($url_from, PHP_URL_SCHEME) == self::parse_url($url_to, PHP_URL_SCHEME)) |
|
544 | 543 | { |
545 | 544 | self::symlinkCache_remove($path_from); |
546 | - $ret = rename($url_from,$url_to); |
|
545 | + $ret = rename($url_from, $url_to); |
|
547 | 546 | } |
548 | - elseif (($from = fopen($url_from,'r')) && ($to = fopen($url_to,'w'))) |
|
547 | + elseif (($from = fopen($url_from, 'r')) && ($to = fopen($url_to, 'w'))) |
|
549 | 548 | { |
550 | - $ret = stream_copy_to_stream($from,$to) !== false; |
|
549 | + $ret = stream_copy_to_stream($from, $to) !== false; |
|
551 | 550 | fclose($from); |
552 | 551 | fclose($to); |
553 | 552 | if ($ret) self::unlink($path_from); |
@@ -569,7 +568,7 @@ discard block |
||
569 | 568 | 'to' => $path_to[0] == '/' ? $path_to : self::parse_url($path_to, PHP_URL_PATH), |
570 | 569 | 'url_from' => $url_from, |
571 | 570 | 'url_to' => $url_to, |
572 | - ),'',true); |
|
571 | + ), '', true); |
|
573 | 572 | } |
574 | 573 | return $ret; |
575 | 574 | } |
@@ -585,13 +584,13 @@ discard block |
||
585 | 584 | * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE |
586 | 585 | * @return boolean TRUE on success or FALSE on failure |
587 | 586 | */ |
588 | - static function mkdir ( $path, $mode, $options ) |
|
587 | + static function mkdir($path, $mode, $options) |
|
589 | 588 | { |
590 | - if (!($url = self::resolve_url_symlinks($path,false))) // false = directory does not need to exists |
|
589 | + if (!($url = self::resolve_url_symlinks($path, false))) // false = directory does not need to exists |
|
591 | 590 | { |
592 | 591 | return false; |
593 | 592 | } |
594 | - $ret = mkdir($url,$mode,$options); |
|
593 | + $ret = mkdir($url, $mode, $options); |
|
595 | 594 | |
596 | 595 | // call "vfs_mkdir" hook |
597 | 596 | if ($ret && isset($GLOBALS['egw']) && isset($GLOBALS['egw']->hooks)) |
@@ -600,7 +599,7 @@ discard block |
||
600 | 599 | 'location' => 'vfs_mkdir', |
601 | 600 | 'path' => $path[0] == '/' ? $path : self::parse_url($path, PHP_URL_PATH), |
602 | 601 | 'url' => $url, |
603 | - ),'',true); |
|
602 | + ), '', true); |
|
604 | 603 | } |
605 | 604 | return $ret; |
606 | 605 | } |
@@ -615,9 +614,9 @@ discard block |
||
615 | 614 | * @param int $options Possible values include STREAM_REPORT_ERRORS. |
616 | 615 | * @return boolean TRUE on success or FALSE on failure. |
617 | 616 | */ |
618 | - static function rmdir ( $path, $options ) |
|
617 | + static function rmdir($path, $options) |
|
619 | 618 | { |
620 | - unset($options); // not uses but required by function signature |
|
619 | + unset($options); // not uses but required by function signature |
|
621 | 620 | if (!($url = self::resolve_url_symlinks($path))) |
622 | 621 | { |
623 | 622 | return false; |
@@ -639,7 +638,7 @@ discard block |
||
639 | 638 | 'path' => $path[0] == '/' ? $path : self::parse_url($path, PHP_URL_PATH), |
640 | 639 | 'url' => $url, |
641 | 640 | 'stat' => $stat, |
642 | - ),'',true); |
|
641 | + ), '', true); |
|
643 | 642 | } |
644 | 643 | return $ok; |
645 | 644 | } |
@@ -656,60 +655,60 @@ discard block |
||
656 | 655 | * @param int $path_param_key =0 key in params containing the path, default 0 |
657 | 656 | * @return mixed return value of backend or false if function does not exist on backend |
658 | 657 | */ |
659 | - static protected function _call_on_backend($name,$params,$fail_silent=false,$path_param_key=0) |
|
658 | + static protected function _call_on_backend($name, $params, $fail_silent = false, $path_param_key = 0) |
|
660 | 659 | { |
661 | 660 | $pathes = $params[$path_param_key]; |
662 | 661 | |
663 | 662 | $scheme2urls = array(); |
664 | - foreach(is_array($pathes) ? $pathes : array($pathes) as $path) |
|
663 | + foreach (is_array($pathes) ? $pathes : array($pathes) as $path) |
|
665 | 664 | { |
666 | - if (!($url = self::resolve_url_symlinks($path,false,false))) |
|
665 | + if (!($url = self::resolve_url_symlinks($path, false, false))) |
|
667 | 666 | { |
668 | 667 | return false; |
669 | 668 | } |
670 | - $k=(string)self::parse_url($url,PHP_URL_SCHEME); |
|
669 | + $k = (string)self::parse_url($url, PHP_URL_SCHEME); |
|
671 | 670 | if (!(is_array($scheme2urls[$k]))) $scheme2urls[$k] = array(); |
672 | 671 | $scheme2urls[$k][$path] = $url; |
673 | 672 | } |
674 | 673 | $ret = array(); |
675 | - foreach($scheme2urls as $scheme => $urls) |
|
674 | + foreach ($scheme2urls as $scheme => $urls) |
|
676 | 675 | { |
677 | 676 | if ($scheme) |
678 | 677 | { |
679 | - if (!class_exists($class = self::scheme2class($scheme)) || !method_exists($class,$name)) |
|
678 | + if (!class_exists($class = self::scheme2class($scheme)) || !method_exists($class, $name)) |
|
680 | 679 | { |
681 | - if (!$fail_silent) trigger_error("Can't $name for scheme $scheme!\n",E_USER_WARNING); |
|
680 | + if (!$fail_silent) trigger_error("Can't $name for scheme $scheme!\n", E_USER_WARNING); |
|
682 | 681 | return false; |
683 | 682 | } |
684 | 683 | if (!is_array($pathes)) |
685 | 684 | { |
686 | 685 | $params[$path_param_key] = $url; |
687 | 686 | |
688 | - return call_user_func_array(array($class,$name),$params); |
|
687 | + return call_user_func_array(array($class, $name), $params); |
|
689 | 688 | } |
690 | 689 | $params[$path_param_key] = $urls; |
691 | - if (!is_array($r = call_user_func_array(array($class,$name),$params))) |
|
690 | + if (!is_array($r = call_user_func_array(array($class, $name), $params))) |
|
692 | 691 | { |
693 | 692 | return $r; |
694 | 693 | } |
695 | 694 | // we need to re-translate the urls to pathes, as they can eg. contain symlinks |
696 | - foreach($urls as $path => $url) |
|
695 | + foreach ($urls as $path => $url) |
|
697 | 696 | { |
698 | - if (isset($r[$url]) || isset($r[$url=self::parse_url($url,PHP_URL_PATH)])) |
|
697 | + if (isset($r[$url]) || isset($r[$url = self::parse_url($url, PHP_URL_PATH)])) |
|
699 | 698 | { |
700 | 699 | $ret[$path] = $r[$url]; |
701 | 700 | } |
702 | 701 | } |
703 | 702 | } |
704 | 703 | // call the filesystem specific function (dont allow to use arrays!) |
705 | - elseif(!function_exists($name) || is_array($pathes)) |
|
704 | + elseif (!function_exists($name) || is_array($pathes)) |
|
706 | 705 | { |
707 | 706 | return false; |
708 | 707 | } |
709 | 708 | else |
710 | 709 | { |
711 | 710 | $time = null; |
712 | - return $name($url,$time); |
|
711 | + return $name($url, $time); |
|
713 | 712 | } |
714 | 713 | } |
715 | 714 | return $ret; |
@@ -723,9 +722,9 @@ discard block |
||
723 | 722 | * @param int $atime =null access time (unix timestamp), default null = current time, not implemented in the vfs! |
724 | 723 | * @return boolean true on success, false otherwise |
725 | 724 | */ |
726 | - static function touch($path,$time=null,$atime=null) |
|
725 | + static function touch($path, $time = null, $atime = null) |
|
727 | 726 | { |
728 | - return self::_call_on_backend('touch',array($path,$time,$atime)); |
|
727 | + return self::_call_on_backend('touch', array($path, $time, $atime)); |
|
729 | 728 | } |
730 | 729 | |
731 | 730 | /** |
@@ -737,9 +736,9 @@ discard block |
||
737 | 736 | * @param string $mode mode string see Vfs::mode2int |
738 | 737 | * @return boolean true on success, false otherwise |
739 | 738 | */ |
740 | - static function chmod($path,$mode) |
|
739 | + static function chmod($path, $mode) |
|
741 | 740 | { |
742 | - return self::_call_on_backend('chmod',array($path,$mode)); |
|
741 | + return self::_call_on_backend('chmod', array($path, $mode)); |
|
743 | 742 | } |
744 | 743 | |
745 | 744 | /** |
@@ -751,9 +750,9 @@ discard block |
||
751 | 750 | * @param int $owner numeric user id |
752 | 751 | * @return boolean true on success, false otherwise |
753 | 752 | */ |
754 | - static function chown($path,$owner) |
|
753 | + static function chown($path, $owner) |
|
755 | 754 | { |
756 | - return self::_call_on_backend('chown',array($path,$owner)); |
|
755 | + return self::_call_on_backend('chown', array($path, $owner)); |
|
757 | 756 | } |
758 | 757 | |
759 | 758 | /** |
@@ -765,9 +764,9 @@ discard block |
||
765 | 764 | * @param int $group numeric group id |
766 | 765 | * @return boolean true on success, false otherwise |
767 | 766 | */ |
768 | - static function chgrp($path,$group) |
|
767 | + static function chgrp($path, $group) |
|
769 | 768 | { |
770 | - return self::_call_on_backend('chgrp',array($path,$group)); |
|
769 | + return self::_call_on_backend('chgrp', array($path, $group)); |
|
771 | 770 | } |
772 | 771 | |
773 | 772 | /** |
@@ -780,7 +779,7 @@ discard block |
||
780 | 779 | */ |
781 | 780 | static function readlink($path) |
782 | 781 | { |
783 | - $ret = self::_call_on_backend('readlink',array($path),true); // true = fail silent, if backend does not support readlink |
|
782 | + $ret = self::_call_on_backend('readlink', array($path), true); // true = fail silent, if backend does not support readlink |
|
784 | 783 | //error_log(__METHOD__."('$path') returning ".array2string($ret).' '.function_backtrace()); |
785 | 784 | return $ret; |
786 | 785 | } |
@@ -794,9 +793,9 @@ discard block |
||
794 | 793 | * @param string $link path of the link to create |
795 | 794 | * @return boolean true on success, false on error |
796 | 795 | */ |
797 | - static function symlink($target,$link) |
|
796 | + static function symlink($target, $link) |
|
798 | 797 | { |
799 | - if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1))) // 1=path is in $link! |
|
798 | + if (($ret = self::_call_on_backend('symlink', array($target, $link), false, 1))) // 1=path is in $link! |
|
800 | 799 | { |
801 | 800 | self::symlinkCache_remove($link); |
802 | 801 | } |
@@ -816,13 +815,13 @@ discard block |
||
816 | 815 | * @param boolean $recheck =false true = do a new check, false = rely on stored mime type (if existing) |
817 | 816 | * @return string mime-type (self::DIR_MIME_TYPE for directories) |
818 | 817 | */ |
819 | - static function mime_content_type($path,$recheck=false) |
|
818 | + static function mime_content_type($path, $recheck = false) |
|
820 | 819 | { |
821 | 820 | if (!($url = self::resolve_url_symlinks($path))) |
822 | 821 | { |
823 | 822 | return false; |
824 | 823 | } |
825 | - if (($scheme = self::parse_url($url,PHP_URL_SCHEME)) && !$recheck) |
|
824 | + if (($scheme = self::parse_url($url, PHP_URL_SCHEME)) && !$recheck) |
|
826 | 825 | { |
827 | 826 | // check it it's an eGW stream wrapper returning mime-type via url_stat |
828 | 827 | // we need to first check if the constant is defined, as we get a fatal error in php5.3 otherwise |
@@ -830,7 +829,7 @@ discard block |
||
830 | 829 | defined($class.'::STAT_RETURN_MIME_TYPE') && |
831 | 830 | ($mime_attr = constant($class.'::STAT_RETURN_MIME_TYPE'))) |
832 | 831 | { |
833 | - $stat = call_user_func(array($class,'url_stat'),self::parse_url($url,PHP_URL_PATH),0); |
|
832 | + $stat = call_user_func(array($class, 'url_stat'), self::parse_url($url, PHP_URL_PATH), 0); |
|
834 | 833 | if ($stat && $stat[$mime_attr]) |
835 | 834 | { |
836 | 835 | $mime = $stat[$mime_attr]; |
@@ -849,7 +848,7 @@ discard block |
||
849 | 848 | // using EGw's own mime magic (currently only checking the extension!) |
850 | 849 | if (!$mime) |
851 | 850 | { |
852 | - $mime = mime_magic::filename2mime(self::parse_url($url,PHP_URL_PATH)); |
|
851 | + $mime = mime_magic::filename2mime(self::parse_url($url, PHP_URL_PATH)); |
|
853 | 852 | } |
854 | 853 | //error_log(__METHOD__."($path,$recheck) mime=$mime"); |
855 | 854 | return $mime; |
@@ -861,7 +860,7 @@ discard block |
||
861 | 860 | * @param string $path URL that was passed to opendir() and that this object is expected to explore. |
862 | 861 | * @return booelan |
863 | 862 | */ |
864 | - function dir_opendir ( $path, $options ) |
|
863 | + function dir_opendir($path, $options) |
|
865 | 864 | { |
866 | 865 | $this->opened_dir = $this->extra_dirs = null; |
867 | 866 | $this->dir_url_params = array(); |
@@ -878,15 +877,15 @@ discard block |
||
878 | 877 | if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!"); |
879 | 878 | return false; |
880 | 879 | } |
881 | - $this->opened_dir_writable = Vfs::check_access($this->opened_dir_url,Vfs::WRITABLE); |
|
880 | + $this->opened_dir_writable = Vfs::check_access($this->opened_dir_url, Vfs::WRITABLE); |
|
882 | 881 | // check our fstab if we need to add some of the mountpoints |
883 | - $basepath = self::parse_url($path,PHP_URL_PATH); |
|
884 | - foreach(array_keys(self::$fstab) as $mounted) |
|
882 | + $basepath = self::parse_url($path, PHP_URL_PATH); |
|
883 | + foreach (array_keys(self::$fstab) as $mounted) |
|
885 | 884 | { |
886 | 885 | if (((Vfs::dirname($mounted) == $basepath || Vfs::dirname($mounted).'/' == $basepath) && $mounted != '/') && |
887 | 886 | // only return children readable by the user, if dir is not writable |
888 | 887 | (!self::HIDE_UNREADABLES || $this->opened_dir_writable || |
889 | - Vfs::check_access($mounted,Vfs::READABLE))) |
|
888 | + Vfs::check_access($mounted, Vfs::READABLE))) |
|
890 | 889 | { |
891 | 890 | $this->extra_dirs[] = basename($mounted); |
892 | 891 | } |
@@ -925,24 +924,24 @@ discard block |
||
925 | 924 | * @param boolean $check_symlink_components =true check if path contains symlinks in path components other then the last one |
926 | 925 | * @return array |
927 | 926 | */ |
928 | - static function url_stat ( $path, $flags, $try_create_home=false, $check_symlink_components=true, $check_symlink_depth=self::MAX_SYMLINK_DEPTH, $try_reconnect=true ) |
|
927 | + static function url_stat($path, $flags, $try_create_home = false, $check_symlink_components = true, $check_symlink_depth = self::MAX_SYMLINK_DEPTH, $try_reconnect = true) |
|
929 | 928 | { |
930 | - if (!($url = self::resolve_url($path,!($flags & STREAM_URL_STAT_LINK), $check_symlink_components))) |
|
929 | + if (!($url = self::resolve_url($path, !($flags&STREAM_URL_STAT_LINK), $check_symlink_components))) |
|
931 | 930 | { |
932 | 931 | if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) can NOT resolve path!"); |
933 | 932 | return false; |
934 | 933 | } |
935 | 934 | |
936 | 935 | try { |
937 | - if ($flags & STREAM_URL_STAT_LINK) |
|
936 | + if ($flags&STREAM_URL_STAT_LINK) |
|
938 | 937 | { |
939 | - $stat = @lstat($url); // suppressed the stat failed warnings |
|
938 | + $stat = @lstat($url); // suppressed the stat failed warnings |
|
940 | 939 | } |
941 | 940 | else |
942 | 941 | { |
943 | - $stat = @stat($url); // suppressed the stat failed warnings |
|
942 | + $stat = @stat($url); // suppressed the stat failed warnings |
|
944 | 943 | |
945 | - if ($stat && ($stat['mode'] & self::MODE_LINK)) |
|
944 | + if ($stat && ($stat['mode']&self::MODE_LINK)) |
|
946 | 945 | { |
947 | 946 | if (!$check_symlink_depth) |
948 | 947 | { |
@@ -953,25 +952,25 @@ discard block |
||
953 | 952 | { |
954 | 953 | if ($lpath[0] != '/') // concat relative path |
955 | 954 | { |
956 | - $lpath = Vfs::concat(self::parse_url($path,PHP_URL_PATH),'../'.$lpath); |
|
955 | + $lpath = Vfs::concat(self::parse_url($path, PHP_URL_PATH), '../'.$lpath); |
|
957 | 956 | } |
958 | - $u_query = parse_url($url,PHP_URL_QUERY); |
|
957 | + $u_query = parse_url($url, PHP_URL_QUERY); |
|
959 | 958 | $url = Vfs::PREFIX.$lpath; |
960 | 959 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$flags) symlif (substr($path,-1) == '/' && $path != '/') $path = substr($path,0,-1); // remove trailing slash eg. added by WebDAVink found and resolved to $url"); |
961 | 960 | // try reading the stat of the link |
962 | - if (($stat = self::url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth-1))) |
|
961 | + if (($stat = self::url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth - 1))) |
|
963 | 962 | { |
964 | 963 | $stat_query = parse_url($stat['url'], PHP_URL_QUERY); |
965 | - if($u_query || $stat_query) |
|
964 | + if ($u_query || $stat_query) |
|
966 | 965 | { |
967 | 966 | $stat_url = parse_url($stat['url']); |
968 | - parse_str($stat_query,$stat_query); |
|
967 | + parse_str($stat_query, $stat_query); |
|
969 | 968 | parse_str($u_query, $u_query); |
970 | 969 | $stat_query = http_build_query(array_merge($stat_query, $u_query)); |
971 | 970 | $stat['url'] = $stat_url['scheme'].'://'.$stat_url['host'].$stat_url['path'].'?'.$stat_query; |
972 | 971 | } |
973 | - if(isset($stat['url'])) $url = $stat['url']; // if stat returns an url use that, as there might be more links ... |
|
974 | - self::symlinkCache_add($path,$url); |
|
972 | + if (isset($stat['url'])) $url = $stat['url']; // if stat returns an url use that, as there might be more links ... |
|
973 | + self::symlinkCache_add($path, $url); |
|
975 | 974 | } |
976 | 975 | } |
977 | 976 | } |
@@ -991,7 +990,7 @@ discard block |
||
991 | 990 | throw $e; |
992 | 991 | } |
993 | 992 | // check if a failed url_stat was for a home dir, in that case silently create it |
994 | - if (!$stat && $try_create_home && Vfs::dirname(self::parse_url($path,PHP_URL_PATH)) == '/home' && |
|
993 | + if (!$stat && $try_create_home && Vfs::dirname(self::parse_url($path, PHP_URL_PATH)) == '/home' && |
|
995 | 994 | ($id = $GLOBALS['egw']->accounts->name2id(basename($path))) && |
996 | 995 | $GLOBALS['egw']->accounts->id2name($id) == basename($path)) // make sure path has the right case! |
997 | 996 | { |
@@ -1001,25 +1000,25 @@ discard block |
||
1001 | 1000 | 'account_lid' => basename($path), |
1002 | 1001 | 'account_name' => basename($path), |
1003 | 1002 | ); |
1004 | - call_user_func(array('vfs_home_hooks',$hook_data['location']),$hook_data); |
|
1003 | + call_user_func(array('vfs_home_hooks', $hook_data['location']), $hook_data); |
|
1005 | 1004 | unset($hook_data); |
1006 | - $stat = self::url_stat($path,$flags,false); |
|
1005 | + $stat = self::url_stat($path, $flags, false); |
|
1007 | 1006 | } |
1008 | 1007 | $query = parse_url($url, PHP_URL_QUERY); |
1009 | 1008 | if (!$stat && $check_symlink_components) // check if there's a symlink somewhere inbetween the path |
1010 | 1009 | { |
1011 | - $stat = self::check_symlink_components($path,$flags,$url); |
|
1012 | - if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path,$stat['url']); |
|
1010 | + $stat = self::check_symlink_components($path, $flags, $url); |
|
1011 | + if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path, $stat['url']); |
|
1013 | 1012 | } |
1014 | - elseif(is_array($stat) && !isset($stat['url'])) |
|
1013 | + elseif (is_array($stat) && !isset($stat['url'])) |
|
1015 | 1014 | { |
1016 | 1015 | $stat['url'] = $url; |
1017 | 1016 | } |
1018 | - if (($stat['mode'] & 0222) && self::url_is_readonly($stat['url'])) |
|
1017 | + if (($stat['mode']&0222) && self::url_is_readonly($stat['url'])) |
|
1019 | 1018 | { |
1020 | 1019 | $stat['mode'] &= ~0222; |
1021 | 1020 | } |
1022 | - if($stat['url'] && $query && strpos($stat['url'],'?'.$query)===false) |
|
1021 | + if ($stat['url'] && $query && strpos($stat['url'], '?'.$query) === false) |
|
1023 | 1022 | { |
1024 | 1023 | $stat['url'] .= '?'.$query; |
1025 | 1024 | } |
@@ -1046,7 +1045,7 @@ discard block |
||
1046 | 1045 | * @param string &$url=null already resolved path |
1047 | 1046 | * @return array|boolean stat array or false if not found |
1048 | 1047 | */ |
1049 | - static private function check_symlink_components($path,$flags=0,&$url=null) |
|
1048 | + static private function check_symlink_components($path, $flags = 0, &$url = null) |
|
1050 | 1049 | { |
1051 | 1050 | if (is_null($url) && !($url = self::resolve_url($path))) |
1052 | 1051 | { |
@@ -1058,7 +1057,7 @@ discard block |
||
1058 | 1057 | while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) && |
1059 | 1058 | ($url = Vfs::dirname($url))) |
1060 | 1059 | { |
1061 | - if (($stat = self::url_stat($url,0,false,false))) |
|
1060 | + if (($stat = self::url_stat($url, 0, false, false))) |
|
1062 | 1061 | { |
1063 | 1062 | if (is_link($url) && ($lpath = self::readlink($url))) |
1064 | 1063 | { |
@@ -1066,20 +1065,20 @@ discard block |
||
1066 | 1065 | |
1067 | 1066 | if ($lpath[0] != '/') |
1068 | 1067 | { |
1069 | - $lpath = Vfs::concat(self::parse_url($url,PHP_URL_PATH),'../'.$lpath); |
|
1068 | + $lpath = Vfs::concat(self::parse_url($url, PHP_URL_PATH), '../'.$lpath); |
|
1070 | 1069 | } |
1071 | 1070 | //self::symlinkCache_add($path,Vfs::PREFIX.$lpath); |
1072 | - $url = Vfs::PREFIX.Vfs::concat($lpath,$rel_path); |
|
1071 | + $url = Vfs::PREFIX.Vfs::concat($lpath, $rel_path); |
|
1073 | 1072 | if (self::LOG_LEVEL > 1) error_log("$log --> lpath='$lpath', url='$url'"); |
1074 | - return self::url_stat($url,$flags); |
|
1073 | + return self::url_stat($url, $flags); |
|
1075 | 1074 | } |
1076 | - $url = Vfs::concat($url,$rel_path); |
|
1075 | + $url = Vfs::concat($url, $rel_path); |
|
1077 | 1076 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning null"); |
1078 | 1077 | return null; |
1079 | 1078 | } |
1080 | 1079 | } |
1081 | 1080 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning false"); |
1082 | - return false; // $path does not exist |
|
1081 | + return false; // $path does not exist |
|
1083 | 1082 | } |
1084 | 1083 | |
1085 | 1084 | /** |
@@ -1095,18 +1094,18 @@ discard block |
||
1095 | 1094 | * @param string $_path vfs path |
1096 | 1095 | * @param string $target target path |
1097 | 1096 | */ |
1098 | - static protected function symlinkCache_add($_path,$target) |
|
1097 | + static protected function symlinkCache_add($_path, $target) |
|
1099 | 1098 | { |
1100 | 1099 | $path = self::get_path($_path); |
1101 | 1100 | |
1102 | - if (isset(self::$symlink_cache[$path])) return; // nothing to do |
|
1101 | + if (isset(self::$symlink_cache[$path])) return; // nothing to do |
|
1103 | 1102 | |
1104 | - if ($target[0] != '/') $target = self::parse_url($target,PHP_URL_PATH); |
|
1103 | + if ($target[0] != '/') $target = self::parse_url($target, PHP_URL_PATH); |
|
1105 | 1104 | |
1106 | 1105 | self::$symlink_cache[$path] = $target; |
1107 | 1106 | |
1108 | 1107 | // sort longest path first |
1109 | - uksort(self::$symlink_cache,create_function('$b,$a','return strlen($a)-strlen($b);')); |
|
1108 | + uksort(self::$symlink_cache, create_function('$b,$a', 'return strlen($a)-strlen($b);')); |
|
1110 | 1109 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$target) cache now ".array2string(self::$symlink_cache)); |
1111 | 1110 | } |
1112 | 1111 | |
@@ -1132,25 +1131,25 @@ discard block |
||
1132 | 1131 | * @param boolean $do_symlink =true is a direct match allowed, default yes (must be false for a lstat or readlink!) |
1133 | 1132 | * @return string target or path, if path not found |
1134 | 1133 | */ |
1135 | - static public function symlinkCache_resolve($_path,$do_symlink=true) |
|
1134 | + static public function symlinkCache_resolve($_path, $do_symlink = true) |
|
1136 | 1135 | { |
1137 | 1136 | // remove vfs scheme, but no other schemes (eg. filesystem!) |
1138 | 1137 | $path = self::get_path($_path); |
1139 | 1138 | |
1140 | 1139 | $strlen_path = strlen($path); |
1141 | 1140 | |
1142 | - foreach(self::$symlink_cache as $p => $t) |
|
1141 | + foreach (self::$symlink_cache as $p => $t) |
|
1143 | 1142 | { |
1144 | - if (($strlen_p = strlen($p)) > $strlen_path) continue; // $path can NOT start with $p |
|
1143 | + if (($strlen_p = strlen($p)) > $strlen_path) continue; // $path can NOT start with $p |
|
1145 | 1144 | |
1146 | 1145 | if ($path == $p) |
1147 | 1146 | { |
1148 | 1147 | if ($do_symlink) $target = $t; |
1149 | 1148 | break; |
1150 | 1149 | } |
1151 | - elseif (substr($path,0,$strlen_p+1) == $p.'/') |
|
1150 | + elseif (substr($path, 0, $strlen_p + 1) == $p.'/') |
|
1152 | 1151 | { |
1153 | - $target = $t . substr($path,$strlen_p); |
|
1152 | + $target = $t.substr($path, $strlen_p); |
|
1154 | 1153 | break; |
1155 | 1154 | } |
1156 | 1155 | } |
@@ -1168,7 +1167,7 @@ discard block |
||
1168 | 1167 | * |
1169 | 1168 | * @param string $path ='/' path of backend, whos cache to clear |
1170 | 1169 | */ |
1171 | - static function clearstatcache($path='/') |
|
1170 | + static function clearstatcache($path = '/') |
|
1172 | 1171 | { |
1173 | 1172 | //error_log(__METHOD__."('$path')"); |
1174 | 1173 | self::$symlink_cache = self::$resolve_url_cache = array(); |
@@ -1186,7 +1185,7 @@ discard block |
||
1186 | 1185 | * |
1187 | 1186 | * @return string |
1188 | 1187 | */ |
1189 | - function dir_readdir ( ) |
|
1188 | + function dir_readdir( ) |
|
1190 | 1189 | { |
1191 | 1190 | if ($this->extra_dirs && count($this->extra_dirs) > $this->extra_dir_ptr) |
1192 | 1191 | { |
@@ -1198,10 +1197,10 @@ discard block |
||
1198 | 1197 | do { |
1199 | 1198 | $file = readdir($this->opened_dir); |
1200 | 1199 | } |
1201 | - while($file !== false && |
|
1202 | - (is_array($this->extra_dirs) && in_array($file,$this->extra_dirs) || // do NOT return extra_dirs twice |
|
1200 | + while ($file !== false && |
|
1201 | + (is_array($this->extra_dirs) && in_array($file, $this->extra_dirs) || // do NOT return extra_dirs twice |
|
1203 | 1202 | self::HIDE_UNREADABLES && !$this->opened_dir_writable && |
1204 | - !Vfs::check_access(Vfs::concat($this->opened_dir_url,$file),Vfs::READABLE))); |
|
1203 | + !Vfs::check_access(Vfs::concat($this->opened_dir_url, $file), Vfs::READABLE))); |
|
1205 | 1204 | } |
1206 | 1205 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."( $this->opened_dir ) = '$file'"); |
1207 | 1206 | return $file; |
@@ -1215,7 +1214,7 @@ discard block |
||
1215 | 1214 | * |
1216 | 1215 | * @return boolean |
1217 | 1216 | */ |
1218 | - function dir_rewinddir ( ) |
|
1217 | + function dir_rewinddir( ) |
|
1219 | 1218 | { |
1220 | 1219 | $this->extra_dir_ptr = 0; |
1221 | 1220 | |
@@ -1229,7 +1228,7 @@ discard block |
||
1229 | 1228 | * |
1230 | 1229 | * @return boolean |
1231 | 1230 | */ |
1232 | - function dir_closedir ( ) |
|
1231 | + function dir_closedir( ) |
|
1233 | 1232 | { |
1234 | 1233 | $ret = closedir($this->opened_dir); |
1235 | 1234 | |
@@ -1246,9 +1245,9 @@ discard block |
||
1246 | 1245 | */ |
1247 | 1246 | static function load_wrapper($scheme) |
1248 | 1247 | { |
1249 | - if (!in_array($scheme,self::get_wrappers())) |
|
1248 | + if (!in_array($scheme, self::get_wrappers())) |
|
1250 | 1249 | { |
1251 | - switch($scheme) |
|
1250 | + switch ($scheme) |
|
1252 | 1251 | { |
1253 | 1252 | case 'webdav': |
1254 | 1253 | case 'webdavs': |
@@ -1256,16 +1255,16 @@ discard block |
||
1256 | 1255 | self::$wrappers[] = $scheme; |
1257 | 1256 | break; |
1258 | 1257 | case '': |
1259 | - break; // default file, always loaded |
|
1258 | + break; // default file, always loaded |
|
1260 | 1259 | default: |
1261 | 1260 | // check if scheme is buildin in php or one of our own stream wrappers |
1262 | - if (in_array($scheme,stream_get_wrappers()) || class_exists(self::scheme2class($scheme))) |
|
1261 | + if (in_array($scheme, stream_get_wrappers()) || class_exists(self::scheme2class($scheme))) |
|
1263 | 1262 | { |
1264 | 1263 | self::$wrappers[] = $scheme; |
1265 | 1264 | } |
1266 | 1265 | else |
1267 | 1266 | { |
1268 | - trigger_error("Can't load stream-wrapper for scheme '$scheme'!",E_USER_WARNING); |
|
1267 | + trigger_error("Can't load stream-wrapper for scheme '$scheme'!", E_USER_WARNING); |
|
1269 | 1268 | return false; |
1270 | 1269 | } |
1271 | 1270 | } |
@@ -1299,10 +1298,10 @@ discard block |
||
1299 | 1298 | static function scheme2class($scheme) |
1300 | 1299 | { |
1301 | 1300 | list($app, $app_scheme) = explode('.', $scheme); |
1302 | - foreach(array( |
|
1303 | - empty($app_scheme) ? 'EGroupware\\Api\\Vfs\\'.ucfirst($scheme).'\\StreamWrapper' : // streamwrapper in Api\Vfs |
|
1301 | + foreach (array( |
|
1302 | + empty($app_scheme) ? 'EGroupware\\Api\\Vfs\\'.ucfirst($scheme).'\\StreamWrapper' : // streamwrapper in Api\Vfs |
|
1304 | 1303 | 'EGroupware\\'.ucfirst($app).'\\Vfs\\'.ucfirst($app_scheme).'\\StreamWrapper', // streamwrapper in $app\Vfs |
1305 | - str_replace('.','_',$scheme).'_stream_wrapper', // old (flat) name |
|
1304 | + str_replace('.', '_', $scheme).'_stream_wrapper', // old (flat) name |
|
1306 | 1305 | ) as $class) |
1307 | 1306 | { |
1308 | 1307 | //error_log(__METHOD__."('$scheme') class_exists('$class')=".array2string(class_exists($class))); |
@@ -1319,7 +1318,7 @@ discard block |
||
1319 | 1318 | * @param int $component =-1 PHP_URL_* constants |
1320 | 1319 | * @return array|string|boolean on success array or string, if $component given, or false on failure |
1321 | 1320 | */ |
1322 | - static function parse_url($url, $component=-1) |
|
1321 | + static function parse_url($url, $component = -1) |
|
1323 | 1322 | { |
1324 | 1323 | static $component2str = array( |
1325 | 1324 | PHP_URL_SCHEME => 'scheme', |
@@ -1331,9 +1330,9 @@ discard block |
||
1331 | 1330 | PHP_URL_QUERY => 'query', |
1332 | 1331 | PHP_URL_FRAGMENT => 'fragment', |
1333 | 1332 | ); |
1334 | - static $cache = array(); // some caching |
|
1333 | + static $cache = array(); // some caching |
|
1335 | 1334 | |
1336 | - $result =& $cache[$url]; |
|
1335 | + $result = & $cache[$url]; |
|
1337 | 1336 | |
1338 | 1337 | if (!isset($result)) |
1339 | 1338 | { |
@@ -1370,7 +1369,7 @@ discard block |
||
1370 | 1369 | * @param string $only_remove_scheme =self::SCHEME if given only that scheme get's removed |
1371 | 1370 | * @return string path without training slash |
1372 | 1371 | */ |
1373 | - static protected function get_path($path,$only_remove_scheme=self::SCHEME) |
|
1372 | + static protected function get_path($path, $only_remove_scheme = self::SCHEME) |
|
1374 | 1373 | { |
1375 | 1374 | if ($path[0] != '/' && (!$only_remove_scheme || self::parse_url($path, PHP_URL_SCHEME) == $only_remove_scheme)) |
1376 | 1375 | { |
@@ -1381,7 +1380,7 @@ discard block |
||
1381 | 1380 | { |
1382 | 1381 | while (mb_substr($path, -1) == '/' && $path != '/' && ($path[0] == '/' || self::parse_url($path, PHP_URL_PATH) != '/')) |
1383 | 1382 | { |
1384 | - $path = mb_substr($path,0,-1); |
|
1383 | + $path = mb_substr($path, 0, -1); |
|
1385 | 1384 | } |
1386 | 1385 | } |
1387 | 1386 | return $path; |
@@ -1396,7 +1395,7 @@ discard block |
||
1396 | 1395 | static function url_is_readonly($url) |
1397 | 1396 | { |
1398 | 1397 | static $cache = array(); |
1399 | - $ret =& $cache[$url]; |
|
1398 | + $ret = & $cache[$url]; |
|
1400 | 1399 | if (!isset($ret)) |
1401 | 1400 | { |
1402 | 1401 | $matches = null; |
@@ -1411,7 +1410,7 @@ discard block |
||
1411 | 1410 | */ |
1412 | 1411 | static function init_static() |
1413 | 1412 | { |
1414 | - stream_register_wrapper(self::SCHEME,__CLASS__); |
|
1413 | + stream_register_wrapper(self::SCHEME, __CLASS__); |
|
1415 | 1414 | |
1416 | 1415 | if (($fstab = $GLOBALS['egw_info']['server']['vfs_fstab']) && is_array($fstab) && count($fstab)) |
1417 | 1416 | { |