@@ -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 | { |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | * Register addressbook for group-acl |
424 | 424 | * |
425 | 425 | * @param array $args hook-params (not used) |
426 | - * @return boolean|string true=standard group acl link, of string with link |
|
426 | + * @return boolean true=standard group acl link, of string with link |
|
427 | 427 | */ |
428 | 428 | static function group_acl($args) |
429 | 429 | { |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | * For which groups should no group acl be used: addressbook always |
438 | 438 | * |
439 | 439 | * @param string|array $data |
440 | - * @return boolean|array true, false or array with group-account_id's |
|
440 | + * @return boolean true, false or array with group-account_id's |
|
441 | 441 | */ |
442 | 442 | static function not_enum_group_acls($data) |
443 | 443 | { |
@@ -153,7 +153,7 @@ |
||
153 | 153 | 'admin' => false, |
154 | 154 | 'default'=> 'org_name: n_family, n_given', |
155 | 155 | ); |
156 | - $settings['link_title_cf'] = array( |
|
156 | + $settings['link_title_cf'] = array( |
|
157 | 157 | 'type' => 'select', |
158 | 158 | 'label' => 'Add a customfield to link title', |
159 | 159 | 'name' => 'link_title_cf', |
@@ -37,37 +37,37 @@ discard block |
||
37 | 37 | 'link' => false, |
38 | 38 | 'icon' => false, |
39 | 39 | ), |
40 | - 'menuOpened' => true, // display it open by default |
|
40 | + 'menuOpened' => true, // display it open by default |
|
41 | 41 | )); |
42 | 42 | } |
43 | 43 | // Magic etemplate2 favorites menu (from nextmatch widget) |
44 | 44 | display_sidebox($appname, lang('Favorites'), egw_framework::favorite_list('addressbook')); |
45 | 45 | |
46 | 46 | $file = array( |
47 | - 'Addressbook list' => egw::link('/index.php',array( |
|
47 | + 'Addressbook list' => egw::link('/index.php', array( |
|
48 | 48 | 'menuaction' => 'addressbook.addressbook_ui.index', |
49 | 49 | 'ajax' => 'true')), |
50 | 50 | array( |
51 | - 'text' => lang('Add %1',lang(egw_link::get_registry($appname, 'entry'))), |
|
51 | + 'text' => lang('Add %1', lang(egw_link::get_registry($appname, 'entry'))), |
|
52 | 52 | 'no_lang' => true, |
53 | 53 | 'link' => "javascript:egw.open('','$appname','add')" |
54 | 54 | ), |
55 | 55 | 'Advanced search' => "javascript:egw_openWindowCentered2('". |
56 | - egw::link('/index.php',array('menuaction' => 'addressbook.addressbook_ui.search'),false). |
|
56 | + egw::link('/index.php', array('menuaction' => 'addressbook.addressbook_ui.search'), false). |
|
57 | 57 | "','_blank',870,480,'yes')", |
58 | - 'Placeholders' => egw::link('/index.php','menuaction=addressbook.addressbook_merge.show_replacements') |
|
58 | + 'Placeholders' => egw::link('/index.php', 'menuaction=addressbook.addressbook_merge.show_replacements') |
|
59 | 59 | ); |
60 | - display_sidebox($appname,lang('Addressbook menu'),$file); |
|
60 | + display_sidebox($appname, lang('Addressbook menu'), $file); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | if ($GLOBALS['egw_info']['user']['apps']['admin'] && $location != 'preferences') |
64 | 64 | { |
65 | 65 | $file = Array( |
66 | - 'Site configuration' => egw::link('/index.php',array( |
|
66 | + 'Site configuration' => egw::link('/index.php', array( |
|
67 | 67 | 'menuaction' => 'admin.uiconfig.index', |
68 | 68 | 'appname' => $appname, |
69 | 69 | )), |
70 | - 'Global Categories' => egw::link('/index.php',array( |
|
70 | + 'Global Categories' => egw::link('/index.php', array( |
|
71 | 71 | 'menuaction' => 'admin.admin_categories.index', |
72 | 72 | 'appname' => $appname, |
73 | 73 | 'global_cats'=> True, |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | // custom fields are not availible in LDAP |
77 | 77 | if ($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap') |
78 | 78 | { |
79 | - $file['Custom fields'] = egw::link('/index.php',array( |
|
79 | + $file['Custom fields'] = egw::link('/index.php', array( |
|
80 | 80 | 'menuaction' => 'admin.customfields.index', |
81 | 81 | 'appname' => $appname, |
82 | 82 | 'use_private'=> 1, |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | } |
86 | 86 | if ($location == 'admin') |
87 | 87 | { |
88 | - display_section($appname,$file); |
|
88 | + display_section($appname, $file); |
|
89 | 89 | } |
90 | 90 | else |
91 | 91 | { |
92 | - display_sidebox($appname,lang('Admin'),$file); |
|
92 | + display_sidebox($appname, lang('Admin'), $file); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | 'label' => 'Default addressbook for adding contacts', |
117 | 117 | 'name' => 'add_default', |
118 | 118 | 'help' => 'Which addressbook should be selected when adding a contact AND you have no add rights to the current addressbook.', |
119 | - 'values' => !$hook_data['setup'] ? ExecMethod('addressbook.addressbook_ui.get_addressbooks',EGW_ACL_ADD) : array(), |
|
119 | + 'values' => !$hook_data['setup'] ? ExecMethod('addressbook.addressbook_ui.get_addressbooks', EGW_ACL_ADD) : array(), |
|
120 | 120 | 'xmlrpc' => True, |
121 | 121 | 'admin' => False, |
122 | 122 | ); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | 'name' => 'link_title', |
148 | 148 | 'values' => array( |
149 | 149 | 'n_fileas' => lang('own sorting').' ('.lang('default').': '.lang('Company').': '.lang('lastname').', '.lang('firstname').')', |
150 | - )+$fileas_options, // plus all fileas types |
|
150 | + ) + $fileas_options, // plus all fileas types |
|
151 | 151 | 'help' => 'What should links to the addressbook display in other applications. Empty values will be left out. You need to log in anew, if you change this setting!', |
152 | 152 | 'xmlrpc' => True, |
153 | 153 | 'admin' => false, |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | '~edit~' => lang('Edit contact'), |
190 | 190 | 'infolog' => lang('Open %1 CRM view', lang('infolog')), |
191 | 191 | ); |
192 | - if($GLOBALS['egw_info']['user']['apps']['tracker']) |
|
192 | + if ($GLOBALS['egw_info']['user']['apps']['tracker']) |
|
193 | 193 | { |
194 | 194 | $crm_list_options['tracker'] = lang('Open %1 CRM view', lang('tracker')); |
195 | 195 | } |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | 'label' => 'Default document to insert contacts', |
221 | 221 | 'name' => 'default_document', |
222 | 222 | 'help' => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.', lang('addressbook')).' '. |
223 | - lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','n_fn').' '. |
|
224 | - lang('The following document-types are supported:'). implode(',',bo_merge::get_file_extensions()), |
|
223 | + lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'n_fn').' '. |
|
224 | + lang('The following document-types are supported:').implode(',', bo_merge::get_file_extensions()), |
|
225 | 225 | 'run_lang' => false, |
226 | 226 | 'xmlrpc' => True, |
227 | 227 | 'admin' => False, |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | 'size' => 60, |
232 | 232 | 'label' => 'Directory with documents to insert contacts', |
233 | 233 | 'name' => 'document_dir', |
234 | - 'help' => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the data inserted.',lang('addressbook')).' '. |
|
235 | - lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','n_fn').' '. |
|
236 | - lang('The following document-types are supported:'). implode(',',bo_merge::get_file_extensions()), |
|
234 | + 'help' => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the data inserted.', lang('addressbook')).' '. |
|
235 | + lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'n_fn').' '. |
|
236 | + lang('The following document-types are supported:').implode(',', bo_merge::get_file_extensions()), |
|
237 | 237 | 'run_lang' => false, |
238 | 238 | 'xmlrpc' => True, |
239 | 239 | 'admin' => False, |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | 'add_app' => 'link_app', |
341 | 341 | 'add_id' => 'link_id', |
342 | 342 | 'add_popup' => '859x550', |
343 | - 'file_access_user' => true, // file_access supports 4th parameter $user |
|
343 | + 'file_access_user' => true, // file_access supports 4th parameter $user |
|
344 | 344 | 'file_access'=> 'addressbook.addressbook_bo.file_access', |
345 | - 'default_types' => array('n' => array('name' => 'contact', 'options' => array('icon' => 'navbar.png','template' => 'addressbook.edit'))), |
|
345 | + 'default_types' => array('n' => array('name' => 'contact', 'options' => array('icon' => 'navbar.png', 'template' => 'addressbook.edit'))), |
|
346 | 346 | // registers an addtional type 'addressbook-email', returning only contacts with email, title has email appended |
347 | 347 | 'additional' => array( |
348 | 348 | 'addressbook-email' => array( |
@@ -381,8 +381,8 @@ discard block |
||
381 | 381 | static function calendar_resources($args) |
382 | 382 | { |
383 | 383 | return array( |
384 | - 'type' => 'c',// one char type-identifiy for this resources |
|
385 | - 'info' => 'addressbook.addressbook_bo.calendar_info',// info method, returns array with id, type & name for a given id |
|
384 | + 'type' => 'c', // one char type-identifiy for this resources |
|
385 | + 'info' => 'addressbook.addressbook_bo.calendar_info', // info method, returns array with id, type & name for a given id |
|
386 | 386 | ); |
387 | 387 | } |
388 | 388 |
@@ -108,7 +108,7 @@ |
||
108 | 108 | |
109 | 109 | if ($GLOBALS['egw_info']['user']['apps']['admin'] && !Api\Header\UserAgent::mobile()) |
110 | 110 | { |
111 | - $file = Array( |
|
111 | + $file = array( |
|
112 | 112 | 'Site configuration' => Egw::link('/index.php',array( |
113 | 113 | 'menuaction' => 'infolog.infolog_ui.admin' )), |
114 | 114 | 'Global Categories' => Egw::link('/index.php',array( |
@@ -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 | { |