@@ -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()) |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * @param string $copytoreceiver=false send a copy of notification to receiver |
41 | 41 | * @return string html content |
42 | 42 | */ |
43 | - function display(array $content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) |
|
43 | + function display(array $content = null, $addressbook = null, $fields = null, $msg = null, $email = null, $tpl_name = null, $subject = null, $copytoreceiver = false, $sel_options = array()) |
|
44 | 44 | { |
45 | - return $this->display_var($content,$addressbook,$fields,$msg,$email,$tpl_name,$subject,$copytoreceiver,$sel_options); |
|
45 | + return $this->display_var($content, $addressbook, $fields, $msg, $email, $tpl_name, $subject, $copytoreceiver, $sel_options); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -58,25 +58,25 @@ discard block |
||
58 | 58 | * @param string $copytoreceiver=false send a copy of notification to receiver |
59 | 59 | * @return string html content |
60 | 60 | */ |
61 | - function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) |
|
61 | + function display_var(array &$content = null, $addressbook = null, $fields = null, $msg = null, $email = null, $tpl_name = null, $subject = null, $copytoreceiver = false, $sel_options = array()) |
|
62 | 62 | { |
63 | 63 | #error_log( "<p>addressbook_contactform::display(".print_r($content,true).",$addressbook,".print_r($fields,true).",$msg,$tpl_name)</p>\n"); |
64 | - if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name =$content['tpl_form_name']; |
|
64 | + if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name = $content['tpl_form_name']; |
|
65 | 65 | $tpl = new etemplate($tpl_name ? $tpl_name : 'addressbook.contactform'); |
66 | 66 | // initializing some fields |
67 | - if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha'); |
|
67 | + if (!$fields) $fields = array('org_name', 'n_fn', 'email', 'tel_work', 'url', 'note', 'captcha'); |
|
68 | 68 | $submitted = false; |
69 | 69 | // check if submitted |
70 | 70 | if (is_array($content)) |
71 | 71 | { |
72 | - if (isset($_POST['g-recaptcha-response'])) $recaptcha = sitemgr_module::verify_recaptcha ($_POST['g-recaptcha-response']); |
|
72 | + if (isset($_POST['g-recaptcha-response'])) $recaptcha = sitemgr_module::verify_recaptcha($_POST['g-recaptcha-response']); |
|
73 | 73 | $captcha = (isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) || ($recaptcha && $recaptcha->success == false); |
74 | 74 | if ($captcha || // no correct captcha OR |
75 | - (time() - $content['start_time'] < 10 && // bot indicator (less then 10 sec to fill out the form and |
|
75 | + (time() - $content['start_time'] < 10 && // bot indicator (less then 10 sec to fill out the form and |
|
76 | 76 | !$GLOBALS['egw_info']['etemplate']['java_script'])) // javascript disabled) |
77 | 77 | { |
78 | 78 | $submitted = "truebutfalse"; |
79 | - $tpl->set_validation_error('captcha',lang('Wrong - try again ...')); |
|
79 | + $tpl->set_validation_error('captcha', lang('Wrong - try again ...')); |
|
80 | 80 | } |
81 | 81 | elseif ($content['submitit']) |
82 | 82 | { |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | $contact = new Api\Contacts(); |
85 | 85 | if ($content['owner']) // save the contact in the addressbook |
86 | 86 | { |
87 | - $content['private'] = 0; // in case default_private is set |
|
87 | + $content['private'] = 0; // in case default_private is set |
|
88 | 88 | if (($id = $contact->save($content))) |
89 | 89 | { |
90 | 90 | // check for fileuploads and attach the found files |
91 | - foreach($content as $name => $value) |
|
91 | + foreach ($content as $name => $value) |
|
92 | 92 | { |
93 | 93 | if (is_array($value) && isset($value['tmp_name']) && is_readable($value['tmp_name'])) |
94 | 94 | { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | // edit rights for the addressbook used to store the new entry, |
98 | 98 | // which is clearly not wanted securitywise |
99 | 99 | Vfs::$is_root = true; |
100 | - Link::link('addressbook',$id,Link::VFS_APPNAME,$value,$name); |
|
100 | + Link::link('addressbook', $id, Link::VFS_APPNAME, $value, $name); |
|
101 | 101 | Vfs::$is_root = false; |
102 | 102 | } |
103 | 103 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | { |
117 | 117 | $tracking = new Api\Contacts\Tracking($contact); |
118 | 118 | } |
119 | - if ($tracking->do_notifications($contact->data2db($content),null)) |
|
119 | + if ($tracking->do_notifications($contact->data2db($content), null)) |
|
120 | 120 | { |
121 | 121 | return '<p align="center">'.$content['msg'].'</p>'; |
122 | 122 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $preserv['email_copytoreceiver'] = $copytoreceiver; |
140 | 140 | #if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha'); |
141 | 141 | $custom = 1; |
142 | - foreach($fields as $name) |
|
142 | + foreach ($fields as $name) |
|
143 | 143 | { |
144 | 144 | if ($name[0] == '#') // custom field |
145 | 145 | { |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | } |
151 | 151 | $content['show']['custom'.$custom] = true; |
152 | 152 | $content['customfield'][$custom] = $name; |
153 | - $content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label']; |
|
153 | + $content['customlabel'][$custom] = $contact->customfields[substr($name, 1)]['label']; |
|
154 | 154 | ++$custom; |
155 | 155 | } |
156 | - elseif($name == 'adr_one_locality') |
|
156 | + elseif ($name == 'adr_one_locality') |
|
157 | 157 | { |
158 | 158 | if (!($content['show'][$name] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format'])) |
159 | 159 | { |
@@ -174,18 +174,18 @@ discard block |
||
174 | 174 | unset($content['submitit']); |
175 | 175 | $custom = 1; |
176 | 176 | // fieldnames are "defined" by the commit attempt, that way, we do not have to remember them |
177 | - foreach($content as $name => $value) { |
|
178 | - $preserv[$name]=$value; |
|
177 | + foreach ($content as $name => $value) { |
|
178 | + $preserv[$name] = $value; |
|
179 | 179 | if ($name[0] == '#') // custom field |
180 | 180 | { |
181 | 181 | static $contact; |
182 | 182 | if (is_null($contact)) $contact = new Api\Contacts(); |
183 | 183 | $content['show']['custom'.$custom] = true; |
184 | 184 | $content['customfield'][$custom] = $name; |
185 | - $content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label']; |
|
185 | + $content['customlabel'][$custom] = $contact->customfields[substr($name, 1)]['label']; |
|
186 | 186 | ++$custom; |
187 | 187 | } |
188 | - elseif($name == 'adr_one_locality') |
|
188 | + elseif ($name == 'adr_one_locality') |
|
189 | 189 | { |
190 | 190 | if (!($content['show'][$name] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format'])) |
191 | 191 | { |
@@ -207,16 +207,16 @@ discard block |
||
207 | 207 | if (!sitemgr_module::get_recaptcha()) |
208 | 208 | { |
209 | 209 | // a simple calculation captcha |
210 | - $num1 = rand(1,99); |
|
211 | - $num2 = rand(1,99); |
|
210 | + $num1 = rand(1, 99); |
|
211 | + $num2 = rand(1, 99); |
|
212 | 212 | if ($num2 > $num1) // keep the result positive |
213 | 213 | { |
214 | 214 | $n = $num1; $num1 = $num2; $num2 = $n; |
215 | 215 | } |
216 | - if (in_array('captcha',$fields)) |
|
216 | + if (in_array('captcha', $fields)) |
|
217 | 217 | { |
218 | - $content['captcha_task'] = sprintf('%d - %d =',$num1,$num2); |
|
219 | - $preserv['captcha_result'] = $num1-$num2; |
|
218 | + $content['captcha_task'] = sprintf('%d - %d =', $num1, $num2); |
|
219 | + $preserv['captcha_result'] = $num1 - $num2; |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | else |
@@ -232,6 +232,6 @@ discard block |
||
232 | 232 | $content = array_merge($_GET, (array)$content); |
233 | 233 | } |
234 | 234 | |
235 | - return $tpl->exec($this->callback,$content,$sel_options,array(),$preserv); |
|
235 | + return $tpl->exec($this->callback, $content, $sel_options, array(), $preserv); |
|
236 | 236 | } |
237 | 237 | } |
@@ -61,30 +61,46 @@ discard block |
||
61 | 61 | function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) |
62 | 62 | { |
63 | 63 | #error_log( "<p>addressbook_contactform::display(".print_r($content,true).",$addressbook,".print_r($fields,true).",$msg,$tpl_name)</p>\n"); |
64 | - if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name =$content['tpl_form_name']; |
|
64 | + if (empty($tpl_name) && !empty($content['tpl_form_name'])) |
|
65 | + { |
|
66 | + $tpl_name =$content['tpl_form_name']; |
|
67 | + } |
|
65 | 68 | $tpl = new etemplate($tpl_name ? $tpl_name : 'addressbook.contactform'); |
66 | 69 | // initializing some fields |
67 | - if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha'); |
|
70 | + if (!$fields) |
|
71 | + { |
|
72 | + $fields = array('org_name','n_fn','email','tel_work','url','note','captcha'); |
|
73 | + } |
|
68 | 74 | $submitted = false; |
69 | 75 | // check if submitted |
70 | 76 | if (is_array($content)) |
71 | 77 | { |
72 | - if (isset($_POST['g-recaptcha-response'])) $recaptcha = sitemgr_module::verify_recaptcha ($_POST['g-recaptcha-response']); |
|
78 | + if (isset($_POST['g-recaptcha-response'])) |
|
79 | + { |
|
80 | + $recaptcha = sitemgr_module::verify_recaptcha ($_POST['g-recaptcha-response']); |
|
81 | + } |
|
73 | 82 | $captcha = (isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) || ($recaptcha && $recaptcha->success == false); |
74 | 83 | if ($captcha || // no correct captcha OR |
75 | 84 | (time() - $content['start_time'] < 10 && // bot indicator (less then 10 sec to fill out the form and |
76 | - !$GLOBALS['egw_info']['etemplate']['java_script'])) // javascript disabled) |
|
85 | + !$GLOBALS['egw_info']['etemplate']['java_script'])) |
|
86 | + { |
|
87 | + // javascript disabled) |
|
77 | 88 | { |
78 | 89 | $submitted = "truebutfalse"; |
90 | + } |
|
79 | 91 | $tpl->set_validation_error('captcha',lang('Wrong - try again ...')); |
80 | 92 | } |
81 | 93 | elseif ($content['submitit']) |
82 | 94 | { |
83 | 95 | $submitted = true; |
84 | 96 | $contact = new Api\Contacts(); |
85 | - if ($content['owner']) // save the contact in the addressbook |
|
97 | + if ($content['owner']) |
|
98 | + { |
|
99 | + // save the contact in the addressbook |
|
86 | 100 | { |
87 | - $content['private'] = 0; // in case default_private is set |
|
101 | + $content['private'] = 0; |
|
102 | + } |
|
103 | + // in case default_private is set |
|
88 | 104 | if (($id = $contact->save($content))) |
89 | 105 | { |
90 | 106 | // check for fileuploads and attach the found files |
@@ -141,9 +157,12 @@ discard block |
||
141 | 157 | $custom = 1; |
142 | 158 | foreach($fields as $name) |
143 | 159 | { |
144 | - if ($name[0] == '#') // custom field |
|
160 | + if ($name[0] == '#') |
|
161 | + { |
|
162 | + // custom field |
|
145 | 163 | { |
146 | 164 | static $contact; |
165 | + } |
|
147 | 166 | if (is_null($contact)) |
148 | 167 | { |
149 | 168 | $contact = new Api\Contacts(); |
@@ -174,12 +193,19 @@ discard block |
||
174 | 193 | unset($content['submitit']); |
175 | 194 | $custom = 1; |
176 | 195 | // fieldnames are "defined" by the commit attempt, that way, we do not have to remember them |
177 | - foreach($content as $name => $value) { |
|
196 | + foreach($content as $name => $value) |
|
197 | + { |
|
178 | 198 | $preserv[$name]=$value; |
179 | - if ($name[0] == '#') // custom field |
|
199 | + if ($name[0] == '#') |
|
200 | + { |
|
201 | + // custom field |
|
180 | 202 | { |
181 | 203 | static $contact; |
182 | - if (is_null($contact)) $contact = new Api\Contacts(); |
|
204 | + } |
|
205 | + if (is_null($contact)) |
|
206 | + { |
|
207 | + $contact = new Api\Contacts(); |
|
208 | + } |
|
183 | 209 | $content['show']['custom'.$custom] = true; |
184 | 210 | $content['customfield'][$custom] = $name; |
185 | 211 | $content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label']; |
@@ -202,16 +228,26 @@ discard block |
||
202 | 228 | } |
203 | 229 | $content['addr_format'] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format']; |
204 | 230 | |
205 | - if ($addressbook) $preserv['owner'] = $addressbook; |
|
206 | - if ($msg) $preserv['msg'] = $msg; |
|
231 | + if ($addressbook) |
|
232 | + { |
|
233 | + $preserv['owner'] = $addressbook; |
|
234 | + } |
|
235 | + if ($msg) |
|
236 | + { |
|
237 | + $preserv['msg'] = $msg; |
|
238 | + } |
|
207 | 239 | if (!sitemgr_module::get_recaptcha()) |
208 | 240 | { |
209 | 241 | // a simple calculation captcha |
210 | 242 | $num1 = rand(1,99); |
211 | 243 | $num2 = rand(1,99); |
212 | - if ($num2 > $num1) // keep the result positive |
|
244 | + if ($num2 > $num1) |
|
245 | + { |
|
246 | + // keep the result positive |
|
213 | 247 | { |
214 | - $n = $num1; $num1 = $num2; $num2 = $n; |
|
248 | + $n = $num1; |
|
249 | + } |
|
250 | + $num1 = $num2; $num2 = $n; |
|
215 | 251 | } |
216 | 252 | if (in_array('captcha',$fields)) |
217 | 253 | { |
@@ -79,8 +79,6 @@ |
||
79 | 79 | * Here we need to handle any incoming data. Setup is done in the constructor, |
80 | 80 | * output is handled by parent. |
81 | 81 | * |
82 | - * @param type $id |
|
83 | - * @param Etemplate $etemplate |
|
84 | 82 | */ |
85 | 83 | public static function process($values = array()) |
86 | 84 | { |
@@ -25,7 +25,7 @@ |
||
25 | 25 | * Construct the portlet |
26 | 26 | * |
27 | 27 | */ |
28 | - public function __construct(Array &$context = array(), &$need_reload = false) |
|
28 | + public function __construct(array &$context = array(), &$need_reload = false) |
|
29 | 29 | { |
30 | 30 | $context['appname'] = 'addressbook'; |
31 | 31 |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | $context['appname'] = 'addressbook'; |
31 | 31 | |
32 | 32 | // Let parent handle the basic stuff |
33 | - parent::__construct($context,$need_reload); |
|
33 | + parent::__construct($context, $need_reload); |
|
34 | 34 | |
35 | 35 | $ui = new addressbook_ui(); |
36 | 36 | |
37 | 37 | $this->context['template'] = 'addressbook.index.rows'; |
38 | 38 | $this->context['sel_options'] = array(); |
39 | - foreach($ui->content_types as $tid => $data) |
|
39 | + foreach ($ui->content_types as $tid => $data) |
|
40 | 40 | { |
41 | 41 | $this->context['sel_options']['tid'][$tid] = $data['name']; |
42 | 42 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | public function exec($id = null, Etemplate &$etemplate = null) |
53 | 53 | { |
54 | 54 | $ui = new addressbook_ui(); |
55 | - $this->context['sel_options']['filter'] = $this->context['sel_options']['owner'] = $ui->get_addressbooks(Acl::READ,lang('All')); |
|
56 | - $this->context['sel_options']['filter2'] = $ui->get_lists(Acl::READ,array('' => lang('none'))); |
|
55 | + $this->context['sel_options']['filter'] = $this->context['sel_options']['owner'] = $ui->get_addressbooks(Acl::READ, lang('All')); |
|
56 | + $this->context['sel_options']['filter2'] = $ui->get_lists(Acl::READ, array('' => lang('none'))); |
|
57 | 57 | $this->nm_settings['actions'] = $ui->get_actions($this->nm_settings['col_filter']['tid'], $this->nm_settings['org_view']); |
58 | 58 | |
59 | 59 | parent::exec($id, $etemplate); |
@@ -96,27 +96,27 @@ discard block |
||
96 | 96 | { |
97 | 97 | // Some processing to add values in for links and cats |
98 | 98 | $success = $failed = $action_msg = $msg = null; |
99 | - if ($ui->action($values['nm']['action'],$values['nm']['selected'],$values['nm']['select_all'], |
|
100 | - $success,$failed,$action_msg,$values['do_email'] ? 'email' : 'index',$msg,$values['nm']['checkboxes'])) |
|
99 | + if ($ui->action($values['nm']['action'], $values['nm']['selected'], $values['nm']['select_all'], |
|
100 | + $success, $failed, $action_msg, $values['do_email'] ? 'email' : 'index', $msg, $values['nm']['checkboxes'])) |
|
101 | 101 | { |
102 | - $msg .= lang('%1 contact(s) %2',$success,$action_msg); |
|
103 | - Api\Json\Response::get()->apply('egw.message',array($msg,'success')); |
|
104 | - foreach($values['nm']['selected'] as &$id) |
|
102 | + $msg .= lang('%1 contact(s) %2', $success, $action_msg); |
|
103 | + Api\Json\Response::get()->apply('egw.message', array($msg, 'success')); |
|
104 | + foreach ($values['nm']['selected'] as &$id) |
|
105 | 105 | { |
106 | 106 | $id = 'addressbook::'.$id; |
107 | 107 | } |
108 | 108 | // Directly request an update - this will get addressbook tab too |
109 | - Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected'])); |
|
109 | + Api\Json\Response::get()->apply('egw.dataRefreshUIDs', array($values['nm']['selected'])); |
|
110 | 110 | } |
111 | - elseif(is_null($msg)) |
|
111 | + elseif (is_null($msg)) |
|
112 | 112 | { |
113 | - $msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
114 | - Api\Json\Response::get()->apply('egw.message',array($msg,'error')); |
|
113 | + $msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
114 | + Api\Json\Response::get()->apply('egw.message', array($msg, 'error')); |
|
115 | 115 | } |
116 | - elseif($msg) |
|
116 | + elseif ($msg) |
|
117 | 117 | { |
118 | - $msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed); |
|
119 | - Api\Json\Response::get()->apply('egw.message',array($msg,'error')); |
|
118 | + $msg .= "\n".lang('%1 entries %2, %3 failed.', $success, $action_msg, $failed); |
|
119 | + Api\Json\Response::get()->apply('egw.message', array($msg, 'error')); |
|
120 | 120 | } |
121 | 121 | unset($values['nm']['action']); |
122 | 122 | unset($values['nm']['select_all']); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param array &$files |
107 | 107 | * @param int $user account_id |
108 | 108 | * @param string $id ='' |
109 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
109 | + * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
110 | 110 | */ |
111 | 111 | function propfind($path,&$options,&$files,$user,$id='') |
112 | 112 | { |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @param string $path |
190 | 190 | * @param array& $filter |
191 | - * @param array|boolean $start =false false=return all or array(start,num) |
|
191 | + * @param integer[] $start =false false=return all or array(start,num) |
|
192 | 192 | * @return array with "files" array with values for keys path and props |
193 | 193 | */ |
194 | 194 | function &propfind_callback($path,array &$filter,$start=false,$report_not_found_multiget_ids=true) |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | * @param array &$options |
540 | 540 | * @param int $id |
541 | 541 | * @param int $user =null account_id |
542 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
542 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
543 | 543 | */ |
544 | 544 | function get(&$options,$id,$user=null) |
545 | 545 | { |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | * @param int $id |
567 | 567 | * @param int $user =null account_id of owner, default null |
568 | 568 | * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook) |
569 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
569 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
570 | 570 | */ |
571 | 571 | function put(&$options,$id,$user=null,$prefix=null) |
572 | 572 | { |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | * |
1025 | 1025 | * @param int $acl Acl::READ, Acl::EDIT or Acl::DELETE |
1026 | 1026 | * @param array|int $contact contact-array or id |
1027 | - * @return boolean null if entry does not exist, false if no access, true if access permitted |
|
1027 | + * @return null|boolean null if entry does not exist, false if no access, true if access permitted |
|
1028 | 1028 | */ |
1029 | 1029 | function check_access($acl,$contact) |
1030 | 1030 | { |
@@ -85,7 +85,10 @@ discard block |
||
85 | 85 | self::$path_attr = 'carddav_name'; |
86 | 86 | self::$path_extension = ''; |
87 | 87 | } |
88 | - if ($this->debug) error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension); |
|
88 | + if ($this->debug) |
|
89 | + { |
|
90 | + error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension); |
|
91 | + } |
|
89 | 92 | |
90 | 93 | $this->home_set_pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set']; |
91 | 94 | $this->home_set_pref = $this->home_set_pref ? explode(',',$this->home_set_pref) : array(); |
@@ -123,7 +126,10 @@ discard block |
||
123 | 126 | $filter['owner'] = $user; |
124 | 127 | } |
125 | 128 | // should we hide the accounts addressbook |
126 | - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') $filter['account_id'] = null; |
|
129 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') |
|
130 | + { |
|
131 | + $filter['account_id'] = null; |
|
132 | + } |
|
127 | 133 | |
128 | 134 | // process REPORT filters or multiget href's |
129 | 135 | $nresults = null; |
@@ -131,9 +137,16 @@ discard block |
||
131 | 137 | { |
132 | 138 | return false; |
133 | 139 | } |
134 | - if ($id) $path = dirname($path).'/'; // carddav_name get's added anyway in the callback |
|
140 | + if ($id) |
|
141 | + { |
|
142 | + $path = dirname($path).'/'; |
|
143 | + } |
|
144 | + // carddav_name get's added anyway in the callback |
|
135 | 145 | |
136 | - if ($this->debug) error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter)); |
|
146 | + if ($this->debug) |
|
147 | + { |
|
148 | + error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter)); |
|
149 | + } |
|
137 | 150 | |
138 | 151 | // check if we have to return the full contact data or just the etag's |
139 | 152 | if (!($filter['address_data'] = $options['props'] == 'all' && |
@@ -218,16 +231,25 @@ discard block |
||
218 | 231 | |
219 | 232 | if (isset($filter[self::$path_attr])) |
220 | 233 | { |
221 | - if (!is_array($filter[self::$path_attr])) $filter[self::$path_attr] = (array)$filter[self::$path_attr]; |
|
234 | + if (!is_array($filter[self::$path_attr])) |
|
235 | + { |
|
236 | + $filter[self::$path_attr] = (array)$filter[self::$path_attr]; |
|
237 | + } |
|
222 | 238 | $requested_multiget_ids =& $filter[self::$path_attr]; |
223 | 239 | } |
224 | 240 | |
225 | 241 | $files = array(); |
226 | 242 | // we query etag and modified, as LDAP does not have the strong sql etag |
227 | 243 | $cols = array('id','uid','etag','modified','n_fn'); |
228 | - if (!in_array(self::$path_attr,$cols)) $cols[] = self::$path_attr; |
|
244 | + if (!in_array(self::$path_attr,$cols)) |
|
245 | + { |
|
246 | + $cols[] = self::$path_attr; |
|
247 | + } |
|
229 | 248 | // we need tid for sync-collection report |
230 | - if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols)) $cols[] = 'tid'; |
|
249 | + if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols)) |
|
250 | + { |
|
251 | + $cols[] = 'tid'; |
|
252 | + } |
|
231 | 253 | if (($contacts =& $this->bo->search(array(),$cols,$order,'','',False,'AND',$start,$filter))) |
232 | 254 | { |
233 | 255 | foreach($contacts as &$contact) |
@@ -271,7 +293,10 @@ discard block |
||
271 | 293 | { |
272 | 294 | $accounts_filter = $filter_in; |
273 | 295 | $accounts_filter['owner'] = '0'; |
274 | - if ($sync_collection_report) $token_was = $this->sync_collection_token; |
|
296 | + if ($sync_collection_report) |
|
297 | + { |
|
298 | + $token_was = $this->sync_collection_token; |
|
299 | + } |
|
275 | 300 | self::$path_attr = 'id'; |
276 | 301 | self::$path_extension = '.vcf'; |
277 | 302 | $files = array_merge($files, $this->propfind_callback($path, $accounts_filter, false, false)); |
@@ -292,18 +317,27 @@ discard block |
||
292 | 317 | if ($sync_collection_report) |
293 | 318 | { |
294 | 319 | list(,$sync_token) = explode('>', $filter[0]); |
295 | - if ((int)$sync_token) $where[] = 'list_modified>'.$GLOBALS['egw']->db->from_unixtime((int)$sync_token); |
|
320 | + if ((int)$sync_token) |
|
321 | + { |
|
322 | + $where[] = 'list_modified>'.$GLOBALS['egw']->db->from_unixtime((int)$sync_token); |
|
323 | + } |
|
296 | 324 | } |
297 | - if (isset($filter[self::$path_attr])) // multiget report? |
|
325 | + if (isset($filter[self::$path_attr])) |
|
326 | + { |
|
327 | + // multiget report? |
|
298 | 328 | { |
299 | 329 | $where['list_'.self::$path_attr] = $filter[self::$path_attr]; |
300 | 330 | } |
331 | + } |
|
301 | 332 | //error_log(__METHOD__."() filter=".array2string($filter).", do_groups=".in_array('D',$this->home_set_pref).", where=".array2string($where)); |
302 | - if (($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner']))) // limit to contacts in same AB! |
|
333 | + if (($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner']))) |
|
334 | + { |
|
335 | + // limit to contacts in same AB! |
|
303 | 336 | { |
304 | 337 | foreach($lists as $list) |
305 | 338 | { |
306 | 339 | $list[self::$path_attr] = $list['list_carddav_name']; |
340 | + } |
|
307 | 341 | $etag = $list['list_id'].':'.$list['list_etag']; |
308 | 342 | // for all-in-one addressbook, add selected ABs to etag |
309 | 343 | if (isset($filter['owner']) && is_array($filter['owner'])) |
@@ -347,7 +381,10 @@ discard block |
||
347 | 381 | } |
348 | 382 | } |
349 | 383 | |
350 | - if ($this->debug) error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items'); |
|
384 | + if ($this->debug) |
|
385 | + { |
|
386 | + error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items'); |
|
387 | + } |
|
351 | 388 | return $files; |
352 | 389 | } |
353 | 390 | |
@@ -387,7 +424,11 @@ discard block |
||
387 | 424 | $matches = $prop_test = $column = null; |
388 | 425 | foreach($options['filters'] as $n => $filter) |
389 | 426 | { |
390 | - if (!is_int($n)) continue; // eg. attributes of filter xml element |
|
427 | + if (!is_int($n)) |
|
428 | + { |
|
429 | + continue; |
|
430 | + } |
|
431 | + // eg. attributes of filter xml element |
|
391 | 432 | |
392 | 433 | switch((string)$filter['name']) |
393 | 434 | { |
@@ -395,19 +436,28 @@ discard block |
||
395 | 436 | $this->caldav->log(__METHOD__."(...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
396 | 437 | break; |
397 | 438 | case 'prop-filter': // can be multiple prop-filter, see example |
398 | - if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
439 | + if ($matches) |
|
440 | + { |
|
441 | + $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
442 | + } |
|
399 | 443 | $matches = array(); |
400 | 444 | $prop_filter = strtoupper($filter['attrs']['name']); |
401 | 445 | $prop_test = isset($filter['attrs']['test']) ? $filter['attrs']['test'] : 'anyof'; |
402 | - if ($this->debug > 1) error_log(__METHOD__."(...) prop-filter='$prop_filter', test='$prop_test'"); |
|
446 | + if ($this->debug > 1) |
|
447 | + { |
|
448 | + error_log(__METHOD__."(...) prop-filter='$prop_filter', test='$prop_test'"); |
|
449 | + } |
|
403 | 450 | break; |
404 | 451 | case 'is-not-defined': |
405 | 452 | $matches[] = '('.$column."='' OR ".$column.' IS NULL)'; |
406 | 453 | break; |
407 | 454 | case 'text-match': // prop-filter can have multiple text-match, see example |
408 | - if (!isset($this->filter_prop2cal[$prop_filter])) // eg. not existing NICKNAME in EGroupware |
|
455 | + if (!isset($this->filter_prop2cal[$prop_filter])) |
|
456 | + { |
|
457 | + // eg. not existing NICKNAME in EGroupware |
|
409 | 458 | { |
410 | 459 | if ($this->debug || $prop_filter != 'NICKNAME') error_log(__METHOD__."(...) text-match: $prop_filter {$filter['attrs']['match-type']} '{$filter['data']}' unknown property '$prop_filter' --> ignored"); |
460 | + } |
|
411 | 461 | $column = false; // to ignore following data too |
412 | 462 | } |
413 | 463 | else |
@@ -420,8 +470,14 @@ discard block |
||
420 | 470 | break; |
421 | 471 | } |
422 | 472 | $column = $this->filter_prop2cal[strtoupper($prop_filter)]; |
423 | - if (strpos($column, '_') === false) $column = 'contact_'.$column; |
|
424 | - if (!isset($filters['order'])) $filters['order'] = $column; |
|
473 | + if (strpos($column, '_') === false) |
|
474 | + { |
|
475 | + $column = 'contact_'.$column; |
|
476 | + } |
|
477 | + if (!isset($filters['order'])) |
|
478 | + { |
|
479 | + $filters['order'] = $column; |
|
480 | + } |
|
425 | 481 | $match_type = $filter['attrs']['match-type']; |
426 | 482 | $negate_condition = isset($filter['attrs']['negate-condition']) && $filter['attrs']['negate-condition'] == 'yes'; |
427 | 483 | } |
@@ -429,9 +485,12 @@ discard block |
||
429 | 485 | case '': // data of text-match element |
430 | 486 | if (isset($filter['data']) && isset($column)) |
431 | 487 | { |
432 | - if ($column) // false for properties not known to EGroupware |
|
488 | + if ($column) |
|
489 | + { |
|
490 | + // false for properties not known to EGroupware |
|
433 | 491 | { |
434 | 492 | $value = str_replace(array('%', '_'), array('\\%', '\\_'), $filter['data']); |
493 | + } |
|
435 | 494 | switch($match_type) |
436 | 495 | { |
437 | 496 | case 'equals': |
@@ -450,7 +509,10 @@ discard block |
||
450 | 509 | } |
451 | 510 | $matches[] = ($negate_condition ? 'NOT ' : '').$sql_filter; |
452 | 511 | |
453 | - if ($this->debug > 1) error_log(__METHOD__."(...) text-match: $prop_filter $match_type' '{$filter['data']}'"); |
|
512 | + if ($this->debug > 1) |
|
513 | + { |
|
514 | + error_log(__METHOD__."(...) text-match: $prop_filter $match_type' '{$filter['data']}'"); |
|
515 | + } |
|
454 | 516 | } |
455 | 517 | unset($column); |
456 | 518 | break; |
@@ -461,11 +523,17 @@ discard block |
||
461 | 523 | break; |
462 | 524 | } |
463 | 525 | } |
464 | - if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
526 | + if ($matches) |
|
527 | + { |
|
528 | + $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
529 | + } |
|
465 | 530 | if ($prop_filters) |
466 | 531 | { |
467 | 532 | $filters[] = $filter = '(('.implode($filter_test=='allof'?') AND (':') OR (', $prop_filters).'))'; |
468 | - if ($this->debug) error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter"); |
|
533 | + if ($this->debug) |
|
534 | + { |
|
535 | + error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter"); |
|
536 | + } |
|
469 | 537 | } |
470 | 538 | } |
471 | 539 | // parse limit from $options['other'] |
@@ -522,8 +590,14 @@ discard block |
||
522 | 590 | } |
523 | 591 | } |
524 | 592 | } |
525 | - if ($ids) $filters[self::$path_attr] = $ids; |
|
526 | - if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids)); |
|
593 | + if ($ids) |
|
594 | + { |
|
595 | + $filters[self::$path_attr] = $ids; |
|
596 | + } |
|
597 | + if ($this->debug) |
|
598 | + { |
|
599 | + error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids)); |
|
600 | + } |
|
527 | 601 | } |
528 | 602 | elseif ($id) |
529 | 603 | { |
@@ -570,12 +644,18 @@ discard block |
||
570 | 644 | */ |
571 | 645 | function put(&$options,$id,$user=null,$prefix=null) |
572 | 646 | { |
573 | - if ($this->debug) error_log(__METHOD__.'('.array2string($options).",$id,$user)"); |
|
647 | + if ($this->debug) |
|
648 | + { |
|
649 | + error_log(__METHOD__.'('.array2string($options).",$id,$user)"); |
|
650 | + } |
|
574 | 651 | |
575 | 652 | $oldContact = $this->_common_get_put_delete('PUT',$options,$id); |
576 | 653 | if (!is_null($oldContact) && !is_array($oldContact)) |
577 | 654 | { |
578 | - if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact)); |
|
655 | + if ($this->debug) |
|
656 | + { |
|
657 | + error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact)); |
|
658 | + } |
|
579 | 659 | return $oldContact; |
580 | 660 | } |
581 | 661 | |
@@ -666,16 +746,25 @@ discard block |
||
666 | 746 | // done here again, as _common_get_put_delete knows nothing about default addressbooks... |
667 | 747 | if (!($this->bo->grants[$contact['owner']] & Acl::ADD)) |
668 | 748 | { |
669 | - if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'"); |
|
749 | + if ($this->debug) |
|
750 | + { |
|
751 | + error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'"); |
|
752 | + } |
|
670 | 753 | return '403 Forbidden'; |
671 | 754 | } |
672 | 755 | } |
673 | - if ($this->http_if_match) $contact['etag'] = self::etag2value($this->http_if_match); |
|
756 | + if ($this->http_if_match) |
|
757 | + { |
|
758 | + $contact['etag'] = self::etag2value($this->http_if_match); |
|
759 | + } |
|
674 | 760 | |
675 | 761 | $contact['photo_unchanged'] = false; // photo needs saving |
676 | 762 | if (!($save_ok = $is_group ? $this->save_group($contact, $oldContact) : $this->bo->save($contact))) |
677 | 763 | { |
678 | - if ($this->debug) error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok"); |
|
764 | + if ($this->debug) |
|
765 | + { |
|
766 | + error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok"); |
|
767 | + } |
|
679 | 768 | if ($save_ok === 0) |
680 | 769 | { |
681 | 770 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
@@ -705,7 +794,10 @@ discard block |
||
705 | 794 | // send evtl. necessary respose headers: Location, etag, ... |
706 | 795 | $this->put_response_headers($contact, $options['path'], $retval, self::$path_attr != 'id'); |
707 | 796 | |
708 | - if ($this->debug > 1) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval)); |
|
797 | + if ($this->debug > 1) |
|
798 | + { |
|
799 | + error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval)); |
|
800 | + } |
|
709 | 801 | return $retval; |
710 | 802 | } |
711 | 803 | |
@@ -719,7 +811,10 @@ discard block |
||
719 | 811 | function save_group(array &$contact, $oldContact=null) |
720 | 812 | { |
721 | 813 | $data = array('list_name' => $contact['n_fn']); |
722 | - if (!isset($contact['owner'])) $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
814 | + if (!isset($contact['owner'])) |
|
815 | + { |
|
816 | + $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
817 | + } |
|
723 | 818 | foreach(array('id','carddav_name','uid','owner') as $name) |
724 | 819 | { |
725 | 820 | $data['list_'.$name] = $contact[$name]; |
@@ -771,8 +866,14 @@ discard block |
||
771 | 866 | } |
772 | 867 | } |
773 | 868 | //error_log('to_add_ids='.array2string($to_add_ids).', to_delete_ids='.array2string($to_delete_ids)); |
774 | - if ($to_add_ids) $this->bo->add2list($to_add_ids, $list_id, array()); |
|
775 | - if ($to_delete_ids) $this->bo->remove_from_list($to_delete_ids, $list_id); |
|
869 | + if ($to_add_ids) |
|
870 | + { |
|
871 | + $this->bo->add2list($to_add_ids, $list_id, array()); |
|
872 | + } |
|
873 | + if ($to_delete_ids) |
|
874 | + { |
|
875 | + $this->bo->remove_from_list($to_delete_ids, $list_id); |
|
876 | + } |
|
776 | 877 | } |
777 | 878 | // reread as update of list-members updates etag and modified |
778 | 879 | if (($contact = $this->bo->read_list($list_id))) |
@@ -781,7 +882,10 @@ discard block |
||
781 | 882 | $contact = $this->read($contact['list_'.self::$path_attr]); |
782 | 883 | } |
783 | 884 | } |
784 | - if ($this->debug > 1) error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id)); |
|
885 | + if ($this->debug > 1) |
|
886 | + { |
|
887 | + error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id)); |
|
888 | + } |
|
785 | 889 | return $list_id; |
786 | 890 | } |
787 | 891 | |
@@ -795,11 +899,17 @@ discard block |
||
795 | 899 | public function getctag($path,$user) |
796 | 900 | { |
797 | 901 | static $ctags = array(); // a little per request caching, in case ctag and sync-token is both requested |
798 | - if (isset($ctags[$path])) return $ctags[$path]; |
|
902 | + if (isset($ctags[$path])) |
|
903 | + { |
|
904 | + return $ctags[$path]; |
|
905 | + } |
|
799 | 906 | |
800 | 907 | $user_in = $user; |
801 | 908 | // not showing addressbook of a single user? |
802 | - if (is_null($user) || $user === '' || $path == '/addressbook/') $user = null; |
|
909 | + if (is_null($user) || $user === '' || $path == '/addressbook/') |
|
910 | + { |
|
911 | + $user = null; |
|
912 | + } |
|
803 | 913 | |
804 | 914 | // If "Sync selected addressbooks into one" is set --> ctag need to take selected AB's into account too |
805 | 915 | if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref)) |
@@ -1012,16 +1122,22 @@ discard block |
||
1012 | 1122 | $contact['etag'] .= ':'.implode('-',$limit_in_ab); |
1013 | 1123 | } |
1014 | 1124 | } |
1015 | - elseif($contact === array()) // not found from read_lists() |
|
1125 | + elseif($contact === array()) |
|
1126 | + { |
|
1127 | + // not found from read_lists() |
|
1016 | 1128 | { |
1017 | 1129 | $contact = null; |
1018 | 1130 | } |
1131 | + } |
|
1019 | 1132 | |
1020 | 1133 | if ($contact && $contact['tid'] == Api\Contacts::DELETED_TYPE) |
1021 | 1134 | { |
1022 | 1135 | $contact = null; // handle deleted events, as not existing (404 Not Found) |
1023 | 1136 | } |
1024 | - if ($this->debug > 1) error_log(__METHOD__."('$id') returning ".array2string($contact)); |
|
1137 | + if ($this->debug > 1) |
|
1138 | + { |
|
1139 | + error_log(__METHOD__."('$id') returning ".array2string($contact)); |
|
1140 | + } |
|
1025 | 1141 | return $contact; |
1026 | 1142 | } |
1027 | 1143 | |
@@ -1051,7 +1167,10 @@ discard block |
||
1051 | 1167 | // remove add and delete grants for accounts (for admins too) |
1052 | 1168 | // as accounts can not be created as contacts, they eg. need further data |
1053 | 1169 | // and admins might not recognice they delete an account incl. its data |
1054 | - if (isset($grants[0])) $grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE); |
|
1170 | + if (isset($grants[0])) |
|
1171 | + { |
|
1172 | + $grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE); |
|
1173 | + } |
|
1055 | 1174 | |
1056 | 1175 | return $grants; |
1057 | 1176 | } |
@@ -1067,7 +1186,10 @@ discard block |
||
1067 | 1186 | $shared = array(); |
1068 | 1187 | |
1069 | 1188 | // if "Sync all selected addressbook into one" is set --> no (additional) shared addressbooks |
1070 | - if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) return array(); |
|
1189 | + if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) |
|
1190 | + { |
|
1191 | + return array(); |
|
1192 | + } |
|
1071 | 1193 | |
1072 | 1194 | // replace symbolic id's with real nummeric id's |
1073 | 1195 | foreach(array( |
@@ -1134,7 +1256,11 @@ discard block |
||
1134 | 1256 | $user = $hook_data['account_id']; |
1135 | 1257 | $addressbook_bo = new Api\Contacts(); |
1136 | 1258 | $addressbooks += $addressbook_bo->get_addressbooks(Acl::READ, null, $user); |
1137 | - if ($user > 0) unset($addressbooks[$user]); // allways synced |
|
1259 | + if ($user > 0) |
|
1260 | + { |
|
1261 | + unset($addressbooks[$user]); |
|
1262 | + } |
|
1263 | + // allways synced |
|
1138 | 1264 | unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now |
1139 | 1265 | } |
1140 | 1266 |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | // LDAP does NOT have a carddav_name attribute --> stick with id mapped to LDAP attribute uid |
77 | 77 | if (version_compare($GLOBALS['egw_info']['apps']['api']['version'], '1.9.007', '<') || |
78 | 78 | $this->bo->contact_repository != 'sql' || |
79 | - $this->bo->account_repository != 'sql' && strpos($_SERVER['REQUEST_URI'].'/','/addressbook-accounts/') !== false) |
|
79 | + $this->bo->account_repository != 'sql' && strpos($_SERVER['REQUEST_URI'].'/', '/addressbook-accounts/') !== false) |
|
80 | 80 | { |
81 | 81 | self::$path_extension = '.vcf'; |
82 | 82 | } |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | if ($this->debug) error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension); |
89 | 89 | |
90 | 90 | $this->home_set_pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set']; |
91 | - $this->home_set_pref = $this->home_set_pref ? explode(',',$this->home_set_pref) : array(); |
|
91 | + $this->home_set_pref = $this->home_set_pref ? explode(',', $this->home_set_pref) : array(); |
|
92 | 92 | |
93 | 93 | // silently switch "Sync all into one" preference on for OS X addressbook, as it only supports one AB |
94 | 94 | // this restores behavior before Lion (10.7), where AB synced all ABs contained in addressbook-home-set |
95 | - if (substr(self::get_agent(),0,9) == 'cfnetwork' && !in_array('O',$this->home_set_pref)) |
|
95 | + if (substr(self::get_agent(), 0, 9) == 'cfnetwork' && !in_array('O', $this->home_set_pref)) |
|
96 | 96 | { |
97 | 97 | $this->home_set_pref[] = 'O'; |
98 | 98 | } |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | * @param string $id ='' |
109 | 109 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
110 | 110 | */ |
111 | - function propfind($path,&$options,&$files,$user,$id='') |
|
111 | + function propfind($path, &$options, &$files, $user, $id = '') |
|
112 | 112 | { |
113 | 113 | $filter = array(); |
114 | 114 | // If "Sync selected addressbooks into one" is set |
115 | - if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref)) |
|
115 | + if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O', $this->home_set_pref)) |
|
116 | 116 | { |
117 | - $filter['owner'] = array_keys($this->get_shared(true)); // true: ignore all-in-one pref |
|
117 | + $filter['owner'] = array_keys($this->get_shared(true)); // true: ignore all-in-one pref |
|
118 | 118 | $filter['owner'][] = $user; |
119 | 119 | } |
120 | 120 | // show addressbook of a single user? |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | |
128 | 128 | // process REPORT filters or multiget href's |
129 | 129 | $nresults = null; |
130 | - if (($id || $options['root']['name'] != 'propfind') && !$this->_report_filters($options,$filter,$id, $nresults)) |
|
130 | + if (($id || $options['root']['name'] != 'propfind') && !$this->_report_filters($options, $filter, $id, $nresults)) |
|
131 | 131 | { |
132 | 132 | return false; |
133 | 133 | } |
134 | - if ($id) $path = dirname($path).'/'; // carddav_name get's added anyway in the callback |
|
134 | + if ($id) $path = dirname($path).'/'; // carddav_name get's added anyway in the callback |
|
135 | 135 | |
136 | 136 | if ($this->debug) error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter)); |
137 | 137 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | if (!($filter['address_data'] = $options['props'] == 'all' && |
140 | 140 | $options['root']['ns'] == Api\CalDAV::CARDDAV) && is_array($options['props'])) |
141 | 141 | { |
142 | - foreach($options['props'] as $prop) |
|
142 | + foreach ($options['props'] as $prop) |
|
143 | 143 | { |
144 | 144 | if ($prop['name'] == 'address-data') |
145 | 145 | { |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | $this->sync_collection_token = null; |
160 | 160 | |
161 | - $filter['order'] = 'contact_modified ASC'; // return oldest modifications first |
|
161 | + $filter['order'] = 'contact_modified ASC'; // return oldest modifications first |
|
162 | 162 | $filter['sync-collection'] = true; |
163 | 163 | } |
164 | 164 | |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults) |
173 | 173 | { |
174 | 174 | --$this->sync_collection_token; |
175 | - $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
175 | + $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | else |
179 | 179 | { |
180 | 180 | // return iterator, calling ourself to return result in chunks |
181 | - $files['files'] = new Api\CalDAV\PropfindIterator($this,$path,$filter,$files['files']); |
|
181 | + $files['files'] = new Api\CalDAV\PropfindIterator($this, $path, $filter, $files['files']); |
|
182 | 182 | } |
183 | 183 | return true; |
184 | 184 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param array|boolean $start =false false=return all or array(start,num) |
192 | 192 | * @return array with "files" array with values for keys path and props |
193 | 193 | */ |
194 | - function &propfind_callback($path,array &$filter,$start=false,$report_not_found_multiget_ids=true) |
|
194 | + function &propfind_callback($path, array &$filter, $start = false, $report_not_found_multiget_ids = true) |
|
195 | 195 | { |
196 | 196 | //error_log(__METHOD__."('$path', ".array2string($filter).", ".array2string($start).", $report_not_found_multiget_ids)"); |
197 | 197 | $starttime = microtime(true); |
@@ -219,18 +219,18 @@ discard block |
||
219 | 219 | if (isset($filter[self::$path_attr])) |
220 | 220 | { |
221 | 221 | if (!is_array($filter[self::$path_attr])) $filter[self::$path_attr] = (array)$filter[self::$path_attr]; |
222 | - $requested_multiget_ids =& $filter[self::$path_attr]; |
|
222 | + $requested_multiget_ids = & $filter[self::$path_attr]; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | $files = array(); |
226 | 226 | // we query etag and modified, as LDAP does not have the strong sql etag |
227 | - $cols = array('id','uid','etag','modified','n_fn'); |
|
228 | - if (!in_array(self::$path_attr,$cols)) $cols[] = self::$path_attr; |
|
227 | + $cols = array('id', 'uid', 'etag', 'modified', 'n_fn'); |
|
228 | + if (!in_array(self::$path_attr, $cols)) $cols[] = self::$path_attr; |
|
229 | 229 | // we need tid for sync-collection report |
230 | 230 | if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols)) $cols[] = 'tid'; |
231 | - if (($contacts =& $this->bo->search(array(),$cols,$order,'','',False,'AND',$start,$filter))) |
|
231 | + if (($contacts = & $this->bo->search(array(), $cols, $order, '', '', False, 'AND', $start, $filter))) |
|
232 | 232 | { |
233 | - foreach($contacts as &$contact) |
|
233 | + foreach ($contacts as &$contact) |
|
234 | 234 | { |
235 | 235 | // remove contact from requested multiget ids, to be able to report not found urls |
236 | 236 | if ($requested_multiget_ids && ($k = array_search($contact[self::$path_attr], $requested_multiget_ids)) !== false) |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | ); |
251 | 251 | if ($address_data) |
252 | 252 | { |
253 | - $content = $handler->getVCard($contact['id'],$this->charset,false); |
|
253 | + $content = $handler->getVCard($contact['id'], $this->charset, false); |
|
254 | 254 | $props['getcontentlength'] = bytes($content); |
255 | - $props[] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'address-data',$content,true); |
|
255 | + $props[] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'address-data', $content, true); |
|
256 | 256 | } |
257 | 257 | $files[] = $this->add_resource($path, $contact, $props); |
258 | 258 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | } |
264 | 264 | } |
265 | 265 | // last chunk or no chunking: add accounts from different repo and report missing multiget urls |
266 | - if (!$start || (empty($contact)?0:count($contacts)) < $start[1]) |
|
266 | + if (!$start || (empty($contact) ? 0 : count($contacts)) < $start[1]) |
|
267 | 267 | { |
268 | 268 | //error_log(__METHOD__."('$path', ".array2string($filter).", ".array2string($start)."; $report_not_found_multiget_ids) last chunk detected: count()=".count($contacts)." < $start[1]"); |
269 | 269 | // add accounts after contacts, if enabled and stored in different repository |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | } |
284 | 284 | } |
285 | 285 | // add groups after contacts, but only if enabled and NOT for '/addressbook/' (!isset($filter['owner']) |
286 | - if (in_array('D',$this->home_set_pref) && (string)$filter['owner'] !== '0') |
|
286 | + if (in_array('D', $this->home_set_pref) && (string)$filter['owner'] !== '0') |
|
287 | 287 | { |
288 | 288 | $where = array( |
289 | - 'list_owner' => isset($filter['owner'])?$filter['owner']:array_keys($this->bo->grants) |
|
289 | + 'list_owner' => isset($filter['owner']) ? $filter['owner'] : array_keys($this->bo->grants) |
|
290 | 290 | ); |
291 | 291 | // add sync-token to support sync-collection report |
292 | 292 | if ($sync_collection_report) |
@@ -299,20 +299,20 @@ discard block |
||
299 | 299 | $where['list_'.self::$path_attr] = $filter[self::$path_attr]; |
300 | 300 | } |
301 | 301 | //error_log(__METHOD__."() filter=".array2string($filter).", do_groups=".in_array('D',$this->home_set_pref).", where=".array2string($where)); |
302 | - if (($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner']))) // limit to contacts in same AB! |
|
302 | + if (($lists = $this->bo->read_lists($where, 'contact_uid', $where['list_owner']))) // limit to contacts in same AB! |
|
303 | 303 | { |
304 | - foreach($lists as $list) |
|
304 | + foreach ($lists as $list) |
|
305 | 305 | { |
306 | 306 | $list[self::$path_attr] = $list['list_carddav_name']; |
307 | 307 | $etag = $list['list_id'].':'.$list['list_etag']; |
308 | 308 | // for all-in-one addressbook, add selected ABs to etag |
309 | 309 | if (isset($filter['owner']) && is_array($filter['owner'])) |
310 | 310 | { |
311 | - $etag .= ':'.implode('-',$filter['owner']); |
|
311 | + $etag .= ':'.implode('-', $filter['owner']); |
|
312 | 312 | } |
313 | 313 | $props = array( |
314 | 314 | 'getcontenttype' => Api\CalDAV::mkprop('getcontenttype', 'text/vcard'), |
315 | - 'getlastmodified' => Api\DateTime::to($list['list_modified'],'ts'), |
|
315 | + 'getlastmodified' => Api\DateTime::to($list['list_modified'], 'ts'), |
|
316 | 316 | 'displayname' => $list['list_name'], |
317 | 317 | 'getetag' => '"'.$etag.'"', |
318 | 318 | ); |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | { |
321 | 321 | $content = $handler->getGroupVCard($list); |
322 | 322 | $props['getcontentlength'] = bytes($content); |
323 | - $props[] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'address-data',$content,true); |
|
323 | + $props[] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'address-data', $content, true); |
|
324 | 324 | } |
325 | 325 | $files[] = $this->add_resource($path, $list, $props); |
326 | 326 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | unset($requested_multiget_ids[$k]); |
331 | 331 | } |
332 | 332 | |
333 | - if ($sync_collection_report && $this->sync_collection_token < ($ts=$GLOBALS['egw']->db->from_timestamp($list['list_modified']))) |
|
333 | + if ($sync_collection_report && $this->sync_collection_token < ($ts = $GLOBALS['egw']->db->from_timestamp($list['list_modified']))) |
|
334 | 334 | { |
335 | 335 | $this->sync_collection_token = $ts; |
336 | 336 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | // report not found multiget urls |
341 | 341 | if ($report_not_found_multiget_ids && $requested_multiget_ids) |
342 | 342 | { |
343 | - foreach($requested_multiget_ids as $id) |
|
343 | + foreach ($requested_multiget_ids as $id) |
|
344 | 344 | { |
345 | 345 | $files[] = array('path' => $path.$id.self::$path_extension); |
346 | 346 | } |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @param int &$nresult on return limit for number or results or unchanged/null |
361 | 361 | * @return boolean true if filter could be processed |
362 | 362 | */ |
363 | - function _report_filters($options,&$filters,$id, &$nresults) |
|
363 | + function _report_filters($options, &$filters, $id, &$nresults) |
|
364 | 364 | { |
365 | 365 | if ($options['filters']) |
366 | 366 | { |
@@ -385,17 +385,17 @@ discard block |
||
385 | 385 | $prop_filters = array(); |
386 | 386 | |
387 | 387 | $matches = $prop_test = $column = null; |
388 | - foreach($options['filters'] as $n => $filter) |
|
388 | + foreach ($options['filters'] as $n => $filter) |
|
389 | 389 | { |
390 | - if (!is_int($n)) continue; // eg. attributes of filter xml element |
|
390 | + if (!is_int($n)) continue; // eg. attributes of filter xml element |
|
391 | 391 | |
392 | - switch((string)$filter['name']) |
|
392 | + switch ((string)$filter['name']) |
|
393 | 393 | { |
394 | 394 | case 'param-filter': |
395 | 395 | $this->caldav->log(__METHOD__."(...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
396 | 396 | break; |
397 | 397 | case 'prop-filter': // can be multiple prop-filter, see example |
398 | - if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
398 | + if ($matches) $prop_filters[] = implode($prop_test == 'allof' ? ' AND ' : ' OR ', $matches); |
|
399 | 399 | $matches = array(); |
400 | 400 | $prop_filter = strtoupper($filter['attrs']['name']); |
401 | 401 | $prop_test = isset($filter['attrs']['test']) ? $filter['attrs']['test'] : 'anyof'; |
@@ -408,11 +408,11 @@ discard block |
||
408 | 408 | if (!isset($this->filter_prop2cal[$prop_filter])) // eg. not existing NICKNAME in EGroupware |
409 | 409 | { |
410 | 410 | if ($this->debug || $prop_filter != 'NICKNAME') error_log(__METHOD__."(...) text-match: $prop_filter {$filter['attrs']['match-type']} '{$filter['data']}' unknown property '$prop_filter' --> ignored"); |
411 | - $column = false; // to ignore following data too |
|
411 | + $column = false; // to ignore following data too |
|
412 | 412 | } |
413 | 413 | else |
414 | 414 | { |
415 | - switch($filter['attrs']['collation']) // todo: which other collations allowed, we are allways unicode |
|
415 | + switch ($filter['attrs']['collation']) // todo: which other collations allowed, we are allways unicode |
|
416 | 416 | { |
417 | 417 | case 'i;unicode-casemap': |
418 | 418 | default: |
@@ -432,20 +432,20 @@ discard block |
||
432 | 432 | if ($column) // false for properties not known to EGroupware |
433 | 433 | { |
434 | 434 | $value = str_replace(array('%', '_'), array('\\%', '\\_'), $filter['data']); |
435 | - switch($match_type) |
|
435 | + switch ($match_type) |
|
436 | 436 | { |
437 | 437 | case 'equals': |
438 | - $sql_filter = $column . $comp . $GLOBALS['egw']->db->quote($value); |
|
438 | + $sql_filter = $column.$comp.$GLOBALS['egw']->db->quote($value); |
|
439 | 439 | break; |
440 | 440 | default: |
441 | 441 | case 'contains': |
442 | - $sql_filter = $column . $comp . $GLOBALS['egw']->db->quote('%'.$value.'%'); |
|
442 | + $sql_filter = $column.$comp.$GLOBALS['egw']->db->quote('%'.$value.'%'); |
|
443 | 443 | break; |
444 | 444 | case 'starts-with': |
445 | - $sql_filter = $column . $comp . $GLOBALS['egw']->db->quote($value.'%'); |
|
445 | + $sql_filter = $column.$comp.$GLOBALS['egw']->db->quote($value.'%'); |
|
446 | 446 | break; |
447 | 447 | case 'ends-with': |
448 | - $sql_filter = $column . $comp . $GLOBALS['egw']->db->quote('%'.$value); |
|
448 | + $sql_filter = $column.$comp.$GLOBALS['egw']->db->quote('%'.$value); |
|
449 | 449 | break; |
450 | 450 | } |
451 | 451 | $matches[] = ($negate_condition ? 'NOT ' : '').$sql_filter; |
@@ -461,10 +461,10 @@ discard block |
||
461 | 461 | break; |
462 | 462 | } |
463 | 463 | } |
464 | - if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
464 | + if ($matches) $prop_filters[] = implode($prop_test == 'allof' ? ' AND ' : ' OR ', $matches); |
|
465 | 465 | if ($prop_filters) |
466 | 466 | { |
467 | - $filters[] = $filter = '(('.implode($filter_test=='allof'?') AND (':') OR (', $prop_filters).'))'; |
|
467 | + $filters[] = $filter = '(('.implode($filter_test == 'allof' ? ') AND (' : ') OR (', $prop_filters).'))'; |
|
468 | 468 | if ($this->debug) error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter"); |
469 | 469 | } |
470 | 470 | } |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | <B:nresults>10</B:nresults> |
475 | 475 | </B:limit> |
476 | 476 | */ |
477 | - foreach((array)$options['other'] as $option) |
|
477 | + foreach ((array)$options['other'] as $option) |
|
478 | 478 | { |
479 | - switch($option['name']) |
|
479 | + switch ($option['name']) |
|
480 | 480 | { |
481 | 481 | case 'nresults': |
482 | 482 | $nresults = (int)$option['data']; |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | case 'limit': |
486 | 486 | break; |
487 | 487 | case 'href': |
488 | - break; // from addressbook-multiget, handled below |
|
488 | + break; // from addressbook-multiget, handled below |
|
489 | 489 | // rfc 6578 sync-report |
490 | 490 | case 'sync-token': |
491 | 491 | if (!empty($option['data'])) |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | $parts = explode('/', $option['data']); |
494 | 494 | $sync_token = array_pop($parts); |
495 | 495 | $filters[] = 'contact_modified>'.(int)$sync_token; |
496 | - $filters['tid'] = null; // to return deleted entries too |
|
496 | + $filters['tid'] = null; // to return deleted entries too |
|
497 | 497 | } |
498 | 498 | break; |
499 | 499 | case 'sync-level': |
@@ -511,23 +511,23 @@ discard block |
||
511 | 511 | if ($options['root']['name'] == 'addressbook-multiget') |
512 | 512 | { |
513 | 513 | $ids = array(); |
514 | - foreach($options['other'] as $option) |
|
514 | + foreach ($options['other'] as $option) |
|
515 | 515 | { |
516 | 516 | if ($option['name'] == 'href') |
517 | 517 | { |
518 | - $parts = explode('/',$option['data']); |
|
518 | + $parts = explode('/', $option['data']); |
|
519 | 519 | if (($id = urldecode(array_pop($parts)))) |
520 | 520 | { |
521 | - $ids[] = self::$path_extension ? basename($id,self::$path_extension) : $id; |
|
521 | + $ids[] = self::$path_extension ? basename($id, self::$path_extension) : $id; |
|
522 | 522 | } |
523 | 523 | } |
524 | 524 | } |
525 | 525 | if ($ids) $filters[self::$path_attr] = $ids; |
526 | - if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids)); |
|
526 | + if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',', $ids)); |
|
527 | 527 | } |
528 | 528 | elseif ($id) |
529 | 529 | { |
530 | - $filters[self::$path_attr] = self::$path_extension ? basename($id,self::$path_extension) : $id; |
|
530 | + $filters[self::$path_attr] = self::$path_extension ? basename($id, self::$path_extension) : $id; |
|
531 | 531 | } |
532 | 532 | //error_log(__METHOD__."() options[other]=".array2string($options['other'])." --> filters=".array2string($filters)); |
533 | 533 | return true; |
@@ -541,17 +541,16 @@ discard block |
||
541 | 541 | * @param int $user =null account_id |
542 | 542 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
543 | 543 | */ |
544 | - function get(&$options,$id,$user=null) |
|
544 | + function get(&$options, $id, $user = null) |
|
545 | 545 | { |
546 | - unset($user); // not used, but required by function signature |
|
546 | + unset($user); // not used, but required by function signature |
|
547 | 547 | |
548 | - if (!is_array($contact = $this->_common_get_put_delete('GET',$options,$id))) |
|
548 | + if (!is_array($contact = $this->_common_get_put_delete('GET', $options, $id))) |
|
549 | 549 | { |
550 | 550 | return $contact; |
551 | 551 | } |
552 | 552 | $handler = self::_get_handler(); |
553 | - $options['data'] = $contact['list_id'] ? $handler->getGroupVCard($contact) : |
|
554 | - $handler->getVCard($contact['id'],$this->charset,false); |
|
553 | + $options['data'] = $contact['list_id'] ? $handler->getGroupVCard($contact) : $handler->getVCard($contact['id'], $this->charset, false); |
|
555 | 554 | // e.g. Evolution does not understand 'text/vcard' |
556 | 555 | $options['mimetype'] = 'text/x-vcard; charset='.$this->charset; |
557 | 556 | header('Content-Encoding: identity'); |
@@ -568,11 +567,11 @@ discard block |
||
568 | 567 | * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook) |
569 | 568 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
570 | 569 | */ |
571 | - function put(&$options,$id,$user=null,$prefix=null) |
|
570 | + function put(&$options, $id, $user = null, $prefix = null) |
|
572 | 571 | { |
573 | 572 | if ($this->debug) error_log(__METHOD__.'('.array2string($options).",$id,$user)"); |
574 | 573 | |
575 | - $oldContact = $this->_common_get_put_delete('PUT',$options,$id); |
|
574 | + $oldContact = $this->_common_get_put_delete('PUT', $options, $id); |
|
576 | 575 | if (!is_null($oldContact) && !is_array($oldContact)) |
577 | 576 | { |
578 | 577 | if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact)); |
@@ -597,7 +596,7 @@ discard block |
||
597 | 596 | switch (strtolower($key)) |
598 | 597 | { |
599 | 598 | case 'charset': |
600 | - $charset = strtoupper(substr($value,1,-1)); |
|
599 | + $charset = strtoupper(substr($value, 1, -1)); |
|
601 | 600 | } |
602 | 601 | } |
603 | 602 | } |
@@ -624,7 +623,7 @@ discard block |
||
624 | 623 | |
625 | 624 | if (!$is_group && is_array($contact['cat_id'])) |
626 | 625 | { |
627 | - $contact['cat_id'] = implode(',',$this->bo->find_or_add_categories($contact['cat_id'], $contactId)); |
|
626 | + $contact['cat_id'] = implode(',', $this->bo->find_or_add_categories($contact['cat_id'], $contactId)); |
|
628 | 627 | } |
629 | 628 | elseif ($contactId > 0) |
630 | 629 | { |
@@ -648,12 +647,12 @@ discard block |
||
648 | 647 | $contact['carddav_name'] = $id; |
649 | 648 | |
650 | 649 | // only set owner, if user is explicitly specified in URL (check via prefix, NOT for /addressbook/) or sync-all-in-one!) |
651 | - if ($prefix && !in_array('O',$this->home_set_pref) && $user) |
|
650 | + if ($prefix && !in_array('O', $this->home_set_pref) && $user) |
|
652 | 651 | { |
653 | 652 | $contact['owner'] = $user; |
654 | 653 | } |
655 | 654 | // check if default addressbook is synced and not Api\Accounts, if not use (always synced) personal addressbook |
656 | - elseif(!$this->bo->default_addressbook || !in_array($this->bo->default_addressbook,$this->home_set_pref)) |
|
655 | + elseif (!$this->bo->default_addressbook || !in_array($this->bo->default_addressbook, $this->home_set_pref)) |
|
657 | 656 | { |
658 | 657 | $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
659 | 658 | } |
@@ -664,7 +663,7 @@ discard block |
||
664 | 663 | } |
665 | 664 | // check if user has add rights for addressbook |
666 | 665 | // done here again, as _common_get_put_delete knows nothing about default addressbooks... |
667 | - if (!($this->bo->grants[$contact['owner']] & Acl::ADD)) |
|
666 | + if (!($this->bo->grants[$contact['owner']]&Acl::ADD)) |
|
668 | 667 | { |
669 | 668 | if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'"); |
670 | 669 | return '403 Forbidden'; |
@@ -672,7 +671,7 @@ discard block |
||
672 | 671 | } |
673 | 672 | if ($this->http_if_match) $contact['etag'] = self::etag2value($this->http_if_match); |
674 | 673 | |
675 | - $contact['photo_unchanged'] = false; // photo needs saving |
|
674 | + $contact['photo_unchanged'] = false; // photo needs saving |
|
676 | 675 | if (!($save_ok = $is_group ? $this->save_group($contact, $oldContact) : $this->bo->save($contact))) |
677 | 676 | { |
678 | 677 | if ($this->debug) error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok"); |
@@ -682,7 +681,7 @@ discard block |
||
682 | 681 | $this->check_return_representation($options, $id, $user); |
683 | 682 | return '412 Precondition Failed'; |
684 | 683 | } |
685 | - return '403 Forbidden'; // happens when writing new entries in AB's without ADD rights |
|
684 | + return '403 Forbidden'; // happens when writing new entries in AB's without ADD rights |
|
686 | 685 | } |
687 | 686 | |
688 | 687 | if (empty($contact['etag']) || empty($contact['cardav_name'])) |
@@ -716,16 +715,16 @@ discard block |
||
716 | 715 | * @param array|false $oldContact |
717 | 716 | * @return int|boolean $list_id or false on error |
718 | 717 | */ |
719 | - function save_group(array &$contact, $oldContact=null) |
|
718 | + function save_group(array &$contact, $oldContact = null) |
|
720 | 719 | { |
721 | 720 | $data = array('list_name' => $contact['n_fn']); |
722 | 721 | if (!isset($contact['owner'])) $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
723 | - foreach(array('id','carddav_name','uid','owner') as $name) |
|
722 | + foreach (array('id', 'carddav_name', 'uid', 'owner') as $name) |
|
724 | 723 | { |
725 | 724 | $data['list_'.$name] = $contact[$name]; |
726 | 725 | } |
727 | 726 | //error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') data='.array2string($data)); |
728 | - if (($list_id=$this->bo->add_list(empty($contact[self::$path_attr]) ? null : array('list_'.self::$path_attr => $contact[self::$path_attr]), |
|
727 | + if (($list_id = $this->bo->add_list(empty($contact[self::$path_attr]) ? null : array('list_'.self::$path_attr => $contact[self::$path_attr]), |
|
729 | 728 | $contact['owner'], null, $data))) |
730 | 729 | { |
731 | 730 | // update members given in $contact['##X-ADDRESSBOOKSERVER-MEMBER'] |
@@ -738,14 +737,14 @@ discard block |
||
738 | 737 | { |
739 | 738 | $new_members = array($new_members); |
740 | 739 | } |
741 | - foreach($new_members as &$uid) |
|
740 | + foreach ($new_members as &$uid) |
|
742 | 741 | { |
743 | - $uid = substr($uid,9); // cut off "urn:uuid:" prefix |
|
742 | + $uid = substr($uid, 9); // cut off "urn:uuid:" prefix |
|
744 | 743 | } |
745 | 744 | if ($oldContact) |
746 | 745 | { |
747 | - $to_add = array_diff($new_members,$oldContact['members']); |
|
748 | - $to_delete = array_diff($oldContact['members'],$new_members); |
|
746 | + $to_add = array_diff($new_members, $oldContact['members']); |
|
747 | + $to_delete = array_diff($oldContact['members'], $new_members); |
|
749 | 748 | } |
750 | 749 | else |
751 | 750 | { |
@@ -756,9 +755,9 @@ discard block |
||
756 | 755 | { |
757 | 756 | $to_add_ids = $to_delete_ids = array(); |
758 | 757 | $filter = array('uid' => $to_delete ? array_merge($to_add, $to_delete) : $to_add); |
759 | - if (($contacts =& $this->bo->search(array(), array('id', 'uid'),'','','',False,'AND',false,$filter))) |
|
758 | + if (($contacts = & $this->bo->search(array(), array('id', 'uid'), '', '', '', False, 'AND', false, $filter))) |
|
760 | 759 | { |
761 | - foreach($contacts as $c) |
|
760 | + foreach ($contacts as $c) |
|
762 | 761 | { |
763 | 762 | if ($to_delete && in_array($c['uid'], $to_delete)) |
764 | 763 | { |
@@ -792,9 +791,9 @@ discard block |
||
792 | 791 | * @param int $user |
793 | 792 | * @return string |
794 | 793 | */ |
795 | - public function getctag($path,$user) |
|
794 | + public function getctag($path, $user) |
|
796 | 795 | { |
797 | - static $ctags = array(); // a little per request caching, in case ctag and sync-token is both requested |
|
796 | + static $ctags = array(); // a little per request caching, in case ctag and sync-token is both requested |
|
798 | 797 | if (isset($ctags[$path])) return $ctags[$path]; |
799 | 798 | |
800 | 799 | $user_in = $user; |
@@ -802,9 +801,9 @@ discard block |
||
802 | 801 | if (is_null($user) || $user === '' || $path == '/addressbook/') $user = null; |
803 | 802 | |
804 | 803 | // If "Sync selected addressbooks into one" is set --> ctag need to take selected AB's into account too |
805 | - if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref)) |
|
804 | + if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O', $this->home_set_pref)) |
|
806 | 805 | { |
807 | - $user = array_merge((array)$user,array_keys($this->get_shared(true))); // true: ignore all-in-one pref |
|
806 | + $user = array_merge((array)$user, array_keys($this->get_shared(true))); // true: ignore all-in-one pref |
|
808 | 807 | |
809 | 808 | // include accounts ctag, if accounts stored different from contacts (eg.in LDAP or ADS) |
810 | 809 | if ($this->bo->so_accounts && in_array('0', $user)) |
@@ -815,7 +814,7 @@ discard block |
||
815 | 814 | $ctag = $this->bo->get_ctag($user); |
816 | 815 | |
817 | 816 | // include lists-ctag, if enabled |
818 | - if (in_array('D',$this->home_set_pref)) |
|
817 | + if (in_array('D', $this->home_set_pref)) |
|
819 | 818 | { |
820 | 819 | $lists_ctag = $this->bo->lists_ctag($user); |
821 | 820 | } |
@@ -848,34 +847,34 @@ discard block |
||
848 | 847 | * @param int $user =null account_id of owner of collection |
849 | 848 | * @return array |
850 | 849 | */ |
851 | - public function extra_properties(array $props, $displayname, $base_uri=null, $user=null) |
|
850 | + public function extra_properties(array $props, $displayname, $base_uri = null, $user = null) |
|
852 | 851 | { |
853 | - unset($displayname, $base_uri, $user); // not used, but required by function signature |
|
852 | + unset($displayname, $base_uri, $user); // not used, but required by function signature |
|
854 | 853 | |
855 | 854 | if (!isset($props['addressbook-description'])) |
856 | 855 | { |
857 | 856 | // default addressbook description: can be overwritten via PROPPATCH, in which case it's already set |
858 | - $props['addressbook-description'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-description',$props['displayname']); |
|
857 | + $props['addressbook-description'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-description', $props['displayname']); |
|
859 | 858 | } |
860 | 859 | // setting an max image size, so iOS scales the images before transmitting them |
861 | 860 | // we currently scale down to width of 240px, which tests shown to be ~20k |
862 | - $props['max-image-size'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'max-image-size',24*1024); |
|
861 | + $props['max-image-size'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'max-image-size', 24 * 1024); |
|
863 | 862 | |
864 | 863 | // supported reports (required property for CardDAV) |
865 | 864 | $props['supported-report-set'] = array( |
866 | - 'addressbook-query' => Api\CalDAV::mkprop('supported-report',array( |
|
867 | - Api\CalDAV::mkprop('report',array( |
|
868 | - Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-query',''))))), |
|
869 | - 'addressbook-multiget' => Api\CalDAV::mkprop('supported-report',array( |
|
870 | - Api\CalDAV::mkprop('report',array( |
|
871 | - Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-multiget',''))))), |
|
865 | + 'addressbook-query' => Api\CalDAV::mkprop('supported-report', array( |
|
866 | + Api\CalDAV::mkprop('report', array( |
|
867 | + Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-query', ''))))), |
|
868 | + 'addressbook-multiget' => Api\CalDAV::mkprop('supported-report', array( |
|
869 | + Api\CalDAV::mkprop('report', array( |
|
870 | + Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-multiget', ''))))), |
|
872 | 871 | ); |
873 | 872 | // only advertice rfc 6578 sync-collection report, if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted |
874 | 873 | if ($GLOBALS['egw_info']['server']['history']) |
875 | 874 | { |
876 | - $props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array( |
|
877 | - Api\CalDAV::mkprop('report',array( |
|
878 | - Api\CalDAV::mkprop('sync-collection',''))))); |
|
875 | + $props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report', array( |
|
876 | + Api\CalDAV::mkprop('report', array( |
|
877 | + Api\CalDAV::mkprop('sync-collection', ''))))); |
|
879 | 878 | } |
880 | 879 | return $props; |
881 | 880 | } |
@@ -887,7 +886,7 @@ discard block |
||
887 | 886 | */ |
888 | 887 | private function _get_handler() |
889 | 888 | { |
890 | - $handler = new addressbook_vcal('addressbook','text/vcard'); |
|
889 | + $handler = new addressbook_vcal('addressbook', 'text/vcard'); |
|
891 | 890 | $supportedFields = $handler->supportedFields; |
892 | 891 | // Apple iOS or OS X addressbook |
893 | 892 | if ($this->agent == 'cfnetwork' || $this->agent == 'dataaccess') |
@@ -900,11 +899,11 @@ discard block |
||
900 | 899 | unset($supportedFields['TEL;CELL;WORK']); |
901 | 900 | $supportedFields['TEL;IPHONE'] = array('tel_cell_private'); |
902 | 901 | unset($supportedFields['TEL;CELL;HOME']); |
903 | - $databaseFields['X-ABSHOWAS'] = $supportedFields['X-ABSHOWAS'] = array('fileas_type'); // Horde vCard class uses uppercase prop-names! |
|
902 | + $databaseFields['X-ABSHOWAS'] = $supportedFields['X-ABSHOWAS'] = array('fileas_type'); // Horde vCard class uses uppercase prop-names! |
|
904 | 903 | |
905 | 904 | // Apple Addressbook pre Lion (OS X 10.7) messes up CLASS and CATEGORIES (Lion cant set them but leaves them alone) |
906 | 905 | $matches = null; |
907 | - if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'],$matches) && $matches[1] < 520 || |
|
906 | + if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] < 520 || |
|
908 | 907 | // iOS 5.1.1 does not display CLASS or CATEGORY, but wrongly escapes multiple, comma-separated categories |
909 | 908 | // and appends CLASS: PUBLIC to an empty NOTE: field --> leaving them out for iOS |
910 | 909 | $this->agent == 'dataaccess') |
@@ -914,7 +913,7 @@ discard block |
||
914 | 913 | unset($supportedFields['CATEGORIES']); |
915 | 914 | unset($databaseFields['CATEGORIES']); |
916 | 915 | } |
917 | - if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'],$matches) && $matches[1] < 520) |
|
916 | + if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] < 520) |
|
918 | 917 | { |
919 | 918 | // gd cant parse or resize images stored from snow leopard addressbook: gd-jpeg: |
920 | 919 | // - JPEG library reports unrecoverable error |
@@ -926,7 +925,7 @@ discard block |
||
926 | 925 | } |
927 | 926 | $handler->setDatabaseFields($databaseFields); |
928 | 927 | } |
929 | - $handler->setSupportedFields('GroupDAV',$this->agent,$supportedFields); |
|
928 | + $handler->setSupportedFields('GroupDAV', $this->agent, $supportedFields); |
|
930 | 929 | return $handler; |
931 | 930 | } |
932 | 931 | |
@@ -938,11 +937,11 @@ discard block |
||
938 | 937 | * @param int $user account_id of collection owner |
939 | 938 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
940 | 939 | */ |
941 | - function delete(&$options,$id,$user) |
|
940 | + function delete(&$options, $id, $user) |
|
942 | 941 | { |
943 | - unset($user); // not used, but required by function signature |
|
942 | + unset($user); // not used, but required by function signature |
|
944 | 943 | |
945 | - if (!is_array($contact = $this->_common_get_put_delete('DELETE',$options,$id))) |
|
944 | + if (!is_array($contact = $this->_common_get_put_delete('DELETE', $options, $id))) |
|
946 | 945 | { |
947 | 946 | return $contact; |
948 | 947 | } |
@@ -950,7 +949,7 @@ discard block |
||
950 | 949 | { |
951 | 950 | $ok = $this->bo->delete_list($contact['list_id']) !== false; |
952 | 951 | } |
953 | - elseif (($ok = $this->bo->delete($contact['id'],self::etag2value($this->http_if_match))) === 0) |
|
952 | + elseif (($ok = $this->bo->delete($contact['id'], self::etag2value($this->http_if_match))) === 0) |
|
954 | 953 | { |
955 | 954 | return '412 Precondition Failed'; |
956 | 955 | } |
@@ -967,9 +966,9 @@ discard block |
||
967 | 966 | * @param string $path =null |
968 | 967 | * @return array|boolean array with entry, false if no read rights, null if $id does not exist |
969 | 968 | */ |
970 | - function read($id, $path=null) |
|
969 | + function read($id, $path = null) |
|
971 | 970 | { |
972 | - static $non_deleted_tids=null; |
|
971 | + static $non_deleted_tids = null; |
|
973 | 972 | if (is_null($non_deleted_tids)) |
974 | 973 | { |
975 | 974 | $tids = $this->bo->content_types; |
@@ -979,7 +978,7 @@ discard block |
||
979 | 978 | $contact = $this->bo->read(array(self::$path_attr => $id, 'tid' => $non_deleted_tids)); |
980 | 979 | |
981 | 980 | // if contact not found and accounts stored NOT like contacts, try reading it without path-extension as id |
982 | - if (is_null($contact) && $this->bo->so_accounts && ($c = $this->bo->read($test=basename($id, '.vcf')))) |
|
981 | + if (is_null($contact) && $this->bo->so_accounts && ($c = $this->bo->read($test = basename($id, '.vcf')))) |
|
983 | 982 | { |
984 | 983 | $contact = $c; |
985 | 984 | } |
@@ -988,9 +987,9 @@ discard block |
||
988 | 987 | // bo->read_list(..., true) limits returned uid to same owner's addressbook, as iOS and OS X addressbooks |
989 | 988 | // only understands/shows that and if return more, save_lists would delete the others ones on update! |
990 | 989 | $limit_in_ab = true; |
991 | - list(,$account_lid,$app) = explode('/',$path); // eg. /<username>/addressbook/<id> |
|
990 | + list(,$account_lid, $app) = explode('/', $path); // eg. /<username>/addressbook/<id> |
|
992 | 991 | // /<username>/addressbook/ with home_set_prefs containing 'O'=all-in-one contains selected ab's |
993 | - if($account_lid == $GLOBALS['egw_info']['user']['account_lid'] && $app == 'addressbook' && in_array('O',$this->home_set_pref)) |
|
992 | + if ($account_lid == $GLOBALS['egw_info']['user']['account_lid'] && $app == 'addressbook' && in_array('O', $this->home_set_pref)) |
|
994 | 993 | { |
995 | 994 | $limit_in_ab = array_keys($this->get_shared(true)); |
996 | 995 | $limit_in_ab[] = $GLOBALS['egw_info']['user']['account_id']; |
@@ -1001,28 +1000,28 @@ discard block |
||
1001 | 1000 | { |
1002 | 1001 | $limit_in_ab = array_keys($this->bo->grants); |
1003 | 1002 | }*/ |
1004 | - if (!$contact && ($contact = $this->bo->read_lists(array('list_'.self::$path_attr => $id),'contact_uid',$limit_in_ab))) |
|
1003 | + if (!$contact && ($contact = $this->bo->read_lists(array('list_'.self::$path_attr => $id), 'contact_uid', $limit_in_ab))) |
|
1005 | 1004 | { |
1006 | 1005 | $contact = array_shift($contact); |
1007 | 1006 | $contact['n_fn'] = $contact['n_family'] = $contact['list_name']; |
1008 | - foreach(array('owner','id','carddav_name','modified','modifier','created','creator','etag','uid') as $name) |
|
1007 | + foreach (array('owner', 'id', 'carddav_name', 'modified', 'modifier', 'created', 'creator', 'etag', 'uid') as $name) |
|
1009 | 1008 | { |
1010 | 1009 | $contact[$name] = $contact['list_'.$name]; |
1011 | 1010 | } |
1012 | 1011 | // if NOT limited to containing AB ($limit_in_ab === true), add that limit to etag |
1013 | 1012 | if ($limit_in_ab !== true) |
1014 | 1013 | { |
1015 | - $contact['etag'] .= ':'.implode('-',$limit_in_ab); |
|
1014 | + $contact['etag'] .= ':'.implode('-', $limit_in_ab); |
|
1016 | 1015 | } |
1017 | 1016 | } |
1018 | - elseif($contact === array()) // not found from read_lists() |
|
1017 | + elseif ($contact === array()) // not found from read_lists() |
|
1019 | 1018 | { |
1020 | 1019 | $contact = null; |
1021 | 1020 | } |
1022 | 1021 | |
1023 | 1022 | if ($contact && $contact['tid'] == Api\Contacts::DELETED_TYPE) |
1024 | 1023 | { |
1025 | - $contact = null; // handle deleted events, as not existing (404 Not Found) |
|
1024 | + $contact = null; // handle deleted events, as not existing (404 Not Found) |
|
1026 | 1025 | } |
1027 | 1026 | if ($this->debug > 1) error_log(__METHOD__."('$id') returning ".array2string($contact)); |
1028 | 1027 | return $contact; |
@@ -1035,9 +1034,9 @@ discard block |
||
1035 | 1034 | * @param array|int $contact contact-array or id |
1036 | 1035 | * @return boolean null if entry does not exist, false if no access, true if access permitted |
1037 | 1036 | */ |
1038 | - function check_access($acl,$contact) |
|
1037 | + function check_access($acl, $contact) |
|
1039 | 1038 | { |
1040 | - return $this->bo->check_perms($acl, $contact, true); // true = deny to delete accounts |
|
1039 | + return $this->bo->check_perms($acl, $contact, true); // true = deny to delete accounts |
|
1041 | 1040 | } |
1042 | 1041 | |
1043 | 1042 | /** |
@@ -1065,15 +1064,15 @@ discard block |
||
1065 | 1064 | * @param boolean $ignore_all_in_one =false if true, return selected addressbooks and not array() for all-in-one |
1066 | 1065 | * @return array account_id => account_lid pairs |
1067 | 1066 | */ |
1068 | - function get_shared($ignore_all_in_one=false) |
|
1067 | + function get_shared($ignore_all_in_one = false) |
|
1069 | 1068 | { |
1070 | 1069 | $shared = array(); |
1071 | 1070 | |
1072 | 1071 | // if "Sync all selected addressbook into one" is set --> no (additional) shared addressbooks |
1073 | - if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) return array(); |
|
1072 | + if (!$ignore_all_in_one && in_array('O', $this->home_set_pref)) return array(); |
|
1074 | 1073 | |
1075 | 1074 | // replace symbolic id's with real nummeric id's |
1076 | - foreach(array( |
|
1075 | + foreach (array( |
|
1077 | 1076 | 'G' => $GLOBALS['egw_info']['user']['account_primary_group'], |
1078 | 1077 | 'U' => '0', |
1079 | 1078 | ) as $sym => $id) |
@@ -1083,11 +1082,11 @@ discard block |
||
1083 | 1082 | $this->home_set_pref[$key] = $id; |
1084 | 1083 | } |
1085 | 1084 | } |
1086 | - foreach(array_keys($this->bo->get_addressbooks(Acl::READ)) as $id) |
|
1085 | + foreach (array_keys($this->bo->get_addressbooks(Acl::READ)) as $id) |
|
1087 | 1086 | { |
1088 | 1087 | if (($id || $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1') && |
1089 | - $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user and no accounts, if disabled in ab prefs |
|
1090 | - (in_array('A',$this->home_set_pref) || in_array((string)$id,$this->home_set_pref)) && |
|
1088 | + $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user and no accounts, if disabled in ab prefs |
|
1089 | + (in_array('A', $this->home_set_pref) || in_array((string)$id, $this->home_set_pref)) && |
|
1091 | 1090 | is_numeric($id) && ($owner = $id ? $this->accounts->id2name($id) : 'accounts')) |
1092 | 1091 | { |
1093 | 1092 | $shared[$id] = 'addressbook-'.$owner; |
@@ -1107,14 +1106,14 @@ discard block |
||
1107 | 1106 | public static function groupdav_root_props(array $data) |
1108 | 1107 | { |
1109 | 1108 | $data['props']['addressbook-home-set'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-home-set', array( |
1110 | - Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/'.$GLOBALS['egw_info']['user']['account_lid'].'/'))); |
|
1109 | + Api\CalDAV::mkprop('href', $data['caldav']->base_uri.'/'.$GLOBALS['egw_info']['user']['account_lid'].'/'))); |
|
1111 | 1110 | |
1112 | 1111 | $data['props']['principal-address'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'principal-address', |
1113 | 1112 | $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1' ? '' : array( |
1114 | - Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/addressbook-accounts/'.$GLOBALS['egw_info']['user']['person_id'].'.vcf'))); |
|
1113 | + Api\CalDAV::mkprop('href', $data['caldav']->base_uri.'/addressbook-accounts/'.$GLOBALS['egw_info']['user']['person_id'].'.vcf'))); |
|
1115 | 1114 | |
1116 | 1115 | $data['props']['directory-gateway'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'directory-gateway', array( |
1117 | - Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/addressbook/'))); |
|
1116 | + Api\CalDAV::mkprop('href', $data['caldav']->base_uri.'/addressbook/'))); |
|
1118 | 1117 | } |
1119 | 1118 | |
1120 | 1119 | /** |
@@ -1137,8 +1136,8 @@ discard block |
||
1137 | 1136 | $user = $hook_data['account_id']; |
1138 | 1137 | $addressbook_bo = new Api\Contacts(); |
1139 | 1138 | $addressbooks += $addressbook_bo->get_addressbooks(Acl::READ, null, $user); |
1140 | - if ($user > 0) unset($addressbooks[$user]); // allways synced |
|
1141 | - unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now |
|
1139 | + if ($user > 0) unset($addressbooks[$user]); // allways synced |
|
1140 | + unset($addressbooks[$user.'p']); // ignore (optional) private addressbook for now |
|
1142 | 1141 | } |
1143 | 1142 | |
1144 | 1143 | // allow to force no other addressbooks |
@@ -1165,9 +1164,9 @@ discard block |
||
1165 | 1164 | 'label' => 'Addressbooks to sync in addition to personal addressbook', |
1166 | 1165 | 'name' => 'addressbook-home-set', |
1167 | 1166 | 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likely not be supported!'). |
1168 | - '<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CardDAV "addressbook-home-set"'). |
|
1169 | - '<br/>'.lang('Select "%1", if your client does not support multiple addressbooks.',lang('Sync all selected into one')). |
|
1170 | - '<br/>'.lang('Select "%1", if your client support groups, eg. OS X or iOS addressbook.',lang('Distribution lists as groups')), |
|
1167 | + '<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CardDAV "addressbook-home-set"'). |
|
1168 | + '<br/>'.lang('Select "%1", if your client does not support multiple addressbooks.', lang('Sync all selected into one')). |
|
1169 | + '<br/>'.lang('Select "%1", if your client support groups, eg. OS X or iOS addressbook.', lang('Distribution lists as groups')), |
|
1171 | 1170 | 'values' => $addressbooks, |
1172 | 1171 | 'xmlrpc' => True, |
1173 | 1172 | 'admin' => False, |
@@ -532,7 +532,6 @@ |
||
532 | 532 | /** |
533 | 533 | * Read the IMAP ACLs |
534 | 534 | * |
535 | - * @param array $args admin-account[@domain],admin-password,accout_lid[,pw] |
|
536 | 535 | * @return int 0 on success |
537 | 536 | */ |
538 | 537 | function do_subscribe_other($account_lid,$pw=null) |
@@ -17,10 +17,13 @@ discard block |
||
17 | 17 | |
18 | 18 | chdir(dirname(__FILE__)); // to enable our relative pathes to work |
19 | 19 | |
20 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling admin-cli as web-page |
|
20 | +if (php_sapi_name() !== 'cli') |
|
21 | +{ |
|
22 | + // security precaution: forbit calling admin-cli as web-page |
|
21 | 23 | { |
22 | 24 | die('<h1>admin-cli.php must NOT be called as web-page --> exiting !!!</h1>'); |
23 | 25 | } |
26 | +} |
|
24 | 27 | elseif ($_SERVER['argc'] <= 1 || $_SERVER['argc'] == 2 && in_array($_SERVER['argv'][1], array('-h', '--help'))) |
25 | 28 | { |
26 | 29 | usage(); |
@@ -92,13 +95,19 @@ discard block |
||
92 | 95 | foreach($arg0s as $arg) |
93 | 96 | { |
94 | 97 | list($name,$value) = explode('=',$arg,2); |
95 | - if(property_exists('admin_cmd',$name)) // dont allow to overwrite admin_cmd properties |
|
98 | + if(property_exists('admin_cmd',$name)) |
|
99 | + { |
|
100 | + // dont allow to overwrite admin_cmd properties |
|
96 | 101 | { |
97 | 102 | throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90); |
98 | 103 | } |
99 | - if (substr($name,-1) == ']') // allow 1-dim. arrays |
|
104 | + } |
|
105 | + if (substr($name,-1) == ']') |
|
106 | + { |
|
107 | + // allow 1-dim. arrays |
|
100 | 108 | { |
101 | 109 | list($name,$sub) = explode('[',substr($name,0,-1),2); |
110 | + } |
|
102 | 111 | $args[$name][$sub] = $value; |
103 | 112 | } |
104 | 113 | else |
@@ -183,7 +192,10 @@ discard block |
||
183 | 192 | if (!$dry_run) |
184 | 193 | { |
185 | 194 | $url = $GLOBALS['egw_info']['server']['webserver_url'].'/json.php?menuaction=admin.admin_hooks.ajax_clear_cache'; |
186 | - if ($url[0] == '/') $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url; |
|
195 | + if ($url[0] == '/') |
|
196 | + { |
|
197 | + $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url; |
|
198 | + } |
|
187 | 199 | $data = file_get_contents($url, false, Framework::proxy_context($user,$arg0s[1])); |
188 | 200 | //error_log("file_get_contents('$url') returned ".array2string($data)); |
189 | 201 | if ($data && strpos($data, '"success"') !== false) |
@@ -225,10 +237,13 @@ discard block |
||
225 | 237 | echo lang("Wrong admin-account or -password !!!")."\n\n"; |
226 | 238 | usage('',1); |
227 | 239 | } |
228 | - if (!$GLOBALS['egw_info']['user']['apps']['admin']) // will be tested by the header too, but whould give html error-message |
|
240 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
241 | + { |
|
242 | + // will be tested by the header too, but whould give html error-message |
|
229 | 243 | { |
230 | 244 | //fail(2,lang("Permission denied !!!")); |
231 | 245 | echo lang("Permission denied !!!")."\n\n"; |
246 | + } |
|
232 | 247 | usage('',2); |
233 | 248 | } |
234 | 249 | return $sessionid; |
@@ -377,7 +392,11 @@ discard block |
||
377 | 392 | foreach($acc_id ? array(Api\Mail\Account::read($acc_id, $account_id)) : |
378 | 393 | Api\Mail\Account::search($account_id, false) as $account) |
379 | 394 | { |
380 | - if (!isset($acc_id) && !Api\Mail\Account::is_multiple($account)) continue; // no need to waste time on personal accounts |
|
395 | + if (!isset($acc_id) && !Api\Mail\Account::is_multiple($account)) |
|
396 | + { |
|
397 | + continue; |
|
398 | + } |
|
399 | + // no need to waste time on personal accounts |
|
381 | 400 | |
382 | 401 | $args = $arg0s; |
383 | 402 | try { |
@@ -430,7 +449,10 @@ discard block |
||
430 | 449 | $identity['account_id'] = $account_id; // make this a personal identity for $account_id |
431 | 450 | Api\Mail\Account::save_identity($identity); |
432 | 451 | } |
433 | - if ($args) echo "Identity(s) for ".implode(', ', $args)." created.\n"; |
|
452 | + if ($args) |
|
453 | + { |
|
454 | + echo "Identity(s) for ".implode(', ', $args)." created.\n"; |
|
455 | + } |
|
434 | 456 | } |
435 | 457 | } |
436 | 458 | catch(\Exception $e) { |
@@ -456,7 +478,10 @@ discard block |
||
456 | 478 | */ |
457 | 479 | function array_modify(&$arr, array &$mod) |
458 | 480 | { |
459 | - if (!is_array($arr)) $arr = array(); |
|
481 | + if (!is_array($arr)) |
|
482 | + { |
|
483 | + $arr = array(); |
|
484 | + } |
|
460 | 485 | |
461 | 486 | switch($mod[0][0]) |
462 | 487 | { |
@@ -512,10 +537,13 @@ discard block |
||
512 | 537 | try { |
513 | 538 | admin_cmd::parse_account($account,false); |
514 | 539 | |
515 | - foreach($data as &$value) // existing account --> empty values mean dont change, not set them empty! |
|
540 | + foreach($data as &$value) |
|
541 | + { |
|
542 | + // existing account --> empty values mean dont change, not set them empty! |
|
516 | 543 | { |
517 | 544 | if ((string)$value === '') $value = null; |
518 | 545 | } |
546 | + } |
|
519 | 547 | } |
520 | 548 | catch (Exception $e) { // new group |
521 | 549 | unset($e); // not used |
@@ -557,9 +585,12 @@ discard block |
||
557 | 585 | if (($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' || |
558 | 586 | empty($GLOBALS['egw_info']['server']['account_repository']) && $GLOBALS['egw_info']['server']['auth_type'] == 'ldap') && |
559 | 587 | $GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 && // 9 = primary group |
560 | - ($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/') // last argument start with a slash |
|
588 | + ($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/') |
|
589 | + { |
|
590 | + // last argument start with a slash |
|
561 | 591 | { |
562 | 592 | $data['loginshell'] = array_pop($args); |
593 | + } |
|
563 | 594 | $data['homedirectory'] = array_pop($args); |
564 | 595 | } |
565 | 596 | $data += array( |
@@ -577,10 +608,13 @@ discard block |
||
577 | 608 | try { |
578 | 609 | admin_cmd::parse_account($account,true); |
579 | 610 | |
580 | - foreach($data as &$value) // existing account --> empty values mean dont change, not set them empty! |
|
611 | + foreach($data as &$value) |
|
612 | + { |
|
613 | + // existing account --> empty values mean dont change, not set them empty! |
|
581 | 614 | { |
582 | 615 | if ((string)$value === '') $value = null; |
583 | 616 | } |
617 | + } |
|
584 | 618 | } |
585 | 619 | catch (Exception $e) { // new account |
586 | 620 | unset($e); // not used |
@@ -621,7 +655,11 @@ discard block |
||
621 | 655 | */ |
622 | 656 | function do_change_account_id($args) |
623 | 657 | { |
624 | - if (count($args) < 4) usage(); // 4 means at least user,pw,from1,to1 |
|
658 | + if (count($args) < 4) |
|
659 | + { |
|
660 | + usage(); |
|
661 | + } |
|
662 | + // 4 means at least user,pw,from1,to1 |
|
625 | 663 | |
626 | 664 | $ids2change = array(); |
627 | 665 | for($n = 2; $n < count($args); $n += 2) |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | use EGroupware\Api\Framework; |
15 | 15 | use EGroupware\Api\Vfs; |
16 | 16 | |
17 | -chdir(dirname(__FILE__)); // to enable our relative pathes to work |
|
17 | +chdir(dirname(__FILE__)); // to enable our relative pathes to work |
|
18 | 18 | |
19 | 19 | if (php_sapi_name() !== 'cli') // security precaution: forbit calling admin-cli as web-page |
20 | 20 | { |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | // allow to specify instance by using a username with appended @domain-name |
35 | -$arg0s = explode(',',@array_shift($arguments)); |
|
36 | -@list($user,$domain) = explode('@',$arg0s[0].'@'); |
|
37 | -load_egw($user,$arg0s[1],$domain); |
|
35 | +$arg0s = explode(',', @array_shift($arguments)); |
|
36 | +@list($user, $domain) = explode('@', $arg0s[0].'@'); |
|
37 | +load_egw($user, $arg0s[1], $domain); |
|
38 | 38 | |
39 | -switch($action) |
|
39 | +switch ($action) |
|
40 | 40 | { |
41 | 41 | case '--edit-user': |
42 | 42 | return do_edit_user($arg0s); |
43 | 43 | |
44 | 44 | case '--add-user': // like --edit-account, but always runs addaccount hook |
45 | - return do_edit_user($arg0s,true); |
|
45 | + return do_edit_user($arg0s, true); |
|
46 | 46 | |
47 | 47 | case '--edit-alias': |
48 | 48 | case '--edit-forward': |
@@ -53,17 +53,17 @@ discard block |
||
53 | 53 | return do_change_pw($arg0s); |
54 | 54 | |
55 | 55 | case '--delete-user': |
56 | - return do_delete_account($arg0s[2],$arg0s[3]); |
|
56 | + return do_delete_account($arg0s[2], $arg0s[3]); |
|
57 | 57 | |
58 | 58 | case '--edit-group': |
59 | 59 | return do_edit_group($arg0s); |
60 | 60 | |
61 | 61 | case '--delete-group': |
62 | - return do_delete_account($arg0s[2],0,false); |
|
62 | + return do_delete_account($arg0s[2], 0, false); |
|
63 | 63 | |
64 | 64 | case '--allow-app': |
65 | 65 | case '--deny-app': |
66 | - return do_account_app($arg0s,$action == '--allow-app'); |
|
66 | + return do_account_app($arg0s, $action == '--allow-app'); |
|
67 | 67 | |
68 | 68 | case '--change-account-id': |
69 | 69 | return do_change_account_id($arg0s); |
@@ -83,21 +83,21 @@ discard block |
||
83 | 83 | |
84 | 84 | default: |
85 | 85 | // we allow to call admin_cmd classes directly, if they define the constant SETUP_CLI_CALLABLE |
86 | - if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) && |
|
87 | - is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE')) |
|
86 | + if (substr($action, 0, 2) == '--' && class_exists($class = str_replace('-', '_', substr($action, 2))) && |
|
87 | + is_subclass_of($class, 'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE')) |
|
88 | 88 | { |
89 | 89 | $args = array(); |
90 | - $args['domain'] = array_shift($arg0s); // domain must be first argument, to ensure right domain get's selected in header-include |
|
91 | - foreach($arg0s as $arg) |
|
90 | + $args['domain'] = array_shift($arg0s); // domain must be first argument, to ensure right domain get's selected in header-include |
|
91 | + foreach ($arg0s as $arg) |
|
92 | 92 | { |
93 | - list($name,$value) = explode('=',$arg,2); |
|
94 | - if(property_exists('admin_cmd',$name)) // dont allow to overwrite admin_cmd properties |
|
93 | + list($name, $value) = explode('=', $arg, 2); |
|
94 | + if (property_exists('admin_cmd', $name)) // dont allow to overwrite admin_cmd properties |
|
95 | 95 | { |
96 | - throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90); |
|
96 | + throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!", $arg), 90); |
|
97 | 97 | } |
98 | - if (substr($name,-1) == ']') // allow 1-dim. arrays |
|
98 | + if (substr($name, -1) == ']') // allow 1-dim. arrays |
|
99 | 99 | { |
100 | - list($name,$sub) = explode('[',substr($name,0,-1),2); |
|
100 | + list($name, $sub) = explode('[', substr($name, 0, -1), 2); |
|
101 | 101 | $args[$name][$sub] = $value; |
102 | 102 | } |
103 | 103 | else |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | */ |
122 | 122 | function run_command(admin_cmd $cmd) |
123 | 123 | { |
124 | - global $arguments,$user,$arg0s,$domain; |
|
124 | + global $arguments, $user, $arg0s, $domain; |
|
125 | 125 | |
126 | 126 | $skip_checks = false; |
127 | 127 | while ($arguments && ($extra = array_shift($arguments))) |
128 | 128 | { |
129 | - switch($extra) |
|
129 | + switch ($extra) |
|
130 | 130 | { |
131 | 131 | case '--schedule': // schedule the command instead of running it directly |
132 | 132 | $time = admin_cmd::parse_date(array_shift($arguments)); |
@@ -156,15 +156,15 @@ discard block |
||
156 | 156 | case '--header-access': |
157 | 157 | if ($cmd instanceof setup_cmd) |
158 | 158 | { |
159 | - list($user,$pw) = explode(',',array_shift($arguments),2); |
|
160 | - $cmd->set_header_secret($user,$pw); |
|
159 | + list($user, $pw) = explode(',', array_shift($arguments), 2); |
|
160 | + $cmd->set_header_secret($user, $pw); |
|
161 | 161 | } |
162 | 162 | break; |
163 | 163 | |
164 | 164 | default: |
165 | 165 | //fail(99,lang('Unknown option %1',$extra); |
166 | - echo lang('Unknown option %1',$extra)."\n\n"; |
|
167 | - usage('',99); |
|
166 | + echo lang('Unknown option %1', $extra)."\n\n"; |
|
167 | + usage('', 99); |
|
168 | 168 | break; |
169 | 169 | } |
170 | 170 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | { |
184 | 184 | $url = $GLOBALS['egw_info']['server']['webserver_url'].'/json.php?menuaction=admin.admin_hooks.ajax_clear_cache'; |
185 | 185 | if ($url[0] == '/') $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url; |
186 | - $data = file_get_contents($url, false, Framework::proxy_context($user,$arg0s[1])); |
|
186 | + $data = file_get_contents($url, false, Framework::proxy_context($user, $arg0s[1])); |
|
187 | 187 | //error_log("file_get_contents('$url') returned ".array2string($data)); |
188 | 188 | if ($data && strpos($data, '"success"') !== false) |
189 | 189 | { |
@@ -222,13 +222,13 @@ discard block |
||
222 | 222 | { |
223 | 223 | //fail(1,lang("Wrong admin-account or -password !!!")); |
224 | 224 | echo lang("Wrong admin-account or -password !!!")."\n\n"; |
225 | - usage('',1); |
|
225 | + usage('', 1); |
|
226 | 226 | } |
227 | 227 | if (!$GLOBALS['egw_info']['user']['apps']['admin']) // will be tested by the header too, but whould give html error-message |
228 | 228 | { |
229 | 229 | //fail(2,lang("Permission denied !!!")); |
230 | 230 | echo lang("Permission denied !!!")."\n\n"; |
231 | - usage('',2); |
|
231 | + usage('', 2); |
|
232 | 232 | } |
233 | 233 | return $sessionid; |
234 | 234 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @param string $passwd |
241 | 241 | * @param string $domain |
242 | 242 | */ |
243 | -function load_egw($user,$passwd,$domain='default') |
|
243 | +function load_egw($user, $passwd, $domain = 'default') |
|
244 | 244 | { |
245 | 245 | //echo "load_egw($user,$passwd,$domain)\n"; |
246 | 246 | $_REQUEST['domain'] = $domain; |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | |
253 | 253 | if (ini_get('session.save_handler') == 'files' && !is_writable(ini_get('session.save_path')) && is_dir('/tmp') && is_writable('/tmp')) |
254 | 254 | { |
255 | - ini_set('session.save_path','/tmp'); // regular users may have no rights to apache's session dir |
|
255 | + ini_set('session.save_path', '/tmp'); // regular users may have no rights to apache's session dir |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | $GLOBALS['egw_info'] = array( |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | ) |
265 | 265 | ); |
266 | 266 | |
267 | - if (substr($user,0,5) != 'root_') |
|
267 | + if (substr($user, 0, 5) != 'root_') |
|
268 | 268 | { |
269 | 269 | include('../header.inc.php'); |
270 | 270 | } |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | include('../header.inc.php'); |
275 | 275 | |
276 | 276 | if ($user == 'root_'.$GLOBALS['egw_info']['server']['header_admin_user'] && |
277 | - _check_pw($GLOBALS['egw_info']['server']['header_admin_password'],$passwd) || |
|
277 | + _check_pw($GLOBALS['egw_info']['server']['header_admin_password'], $passwd) || |
|
278 | 278 | $user == 'root_'.$GLOBALS['egw_domain'][$_GET['domain']]['config_user'] && |
279 | - _check_pw($GLOBALS['egw_domain'][$_GET['domain']]['config_passwd'],$passwd)) |
|
279 | + _check_pw($GLOBALS['egw_domain'][$_GET['domain']]['config_passwd'], $passwd)) |
|
280 | 280 | { |
281 | 281 | echo "\nRoot access granted!\n"; |
282 | 282 | Vfs::$is_root = true; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | * @param string $pw |
296 | 296 | * @return boolean |
297 | 297 | */ |
298 | -function _check_pw($hash_or_cleartext,$pw) |
|
298 | +function _check_pw($hash_or_cleartext, $pw) |
|
299 | 299 | { |
300 | 300 | return Api\Auth::compare_password($pw, $hash_or_cleartext, |
301 | 301 | // old header.inc.php allows md5 or plain passwords with out {type} prefix, which takes precedence |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @param string $action =null |
309 | 309 | * @param int $ret =0 exit-code |
310 | 310 | */ |
311 | -function usage($action=null,$ret=0) |
|
311 | +function usage($action = null, $ret = 0) |
|
312 | 312 | { |
313 | 313 | unset($action); |
314 | 314 | $cmd = basename($_SERVER['argv'][0]); |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | function do_edit_mail($type, array $arg0s) |
362 | 362 | { |
363 | 363 | array_shift($arg0s); // admin-account |
364 | - array_shift($arg0s); // admin-pw |
|
364 | + array_shift($arg0s); // admin-pw |
|
365 | 365 | list($account, $acc_id) = explode('=', array_shift($arg0s)); |
366 | 366 | $account_id = is_numeric($account) ? (int)$account : $GLOBALS['egw']->accounts->name2id($account); |
367 | 367 | if (!$GLOBALS['egw']->accounts->exists($account_id) && !($account_id = $GLOBALS['egw']->accounts->name2id($account))) |
@@ -370,18 +370,17 @@ discard block |
||
370 | 370 | exit(1); |
371 | 371 | } |
372 | 372 | $found = 0; |
373 | - foreach($acc_id ? array(Api\Mail\Account::read($acc_id, $account_id)) : |
|
374 | - Api\Mail\Account::search($account_id, false) as $account) |
|
373 | + foreach ($acc_id ? array(Api\Mail\Account::read($acc_id, $account_id)) : Api\Mail\Account::search($account_id, false) as $account) |
|
375 | 374 | { |
376 | - if (!isset($acc_id) && !Api\Mail\Account::is_multiple($account)) continue; // no need to waste time on personal accounts |
|
375 | + if (!isset($acc_id) && !Api\Mail\Account::is_multiple($account)) continue; // no need to waste time on personal accounts |
|
377 | 376 | |
378 | 377 | $args = $arg0s; |
379 | 378 | try { |
380 | 379 | if (!($data = $account->getUserData($account_id))) |
381 | 380 | { |
382 | - continue; // not a managed mail-server |
|
381 | + continue; // not a managed mail-server |
|
383 | 382 | } |
384 | - switch($type) |
|
383 | + switch ($type) |
|
385 | 384 | { |
386 | 385 | case 'alias': |
387 | 386 | $create_identity = strtolower(array_shift($args)) === 'yes'; |
@@ -404,7 +403,7 @@ discard block |
||
404 | 403 | if ($type == 'alias' && $create_identity && $args) |
405 | 404 | { |
406 | 405 | // check if user allready has an identity created for given aliases |
407 | - foreach(Api\Mail\Account::identities($account, false, 'ident_email', $account_id) as $ident_id => $email) |
|
406 | + foreach (Api\Mail\Account::identities($account, false, 'ident_email', $account_id) as $ident_id => $email) |
|
408 | 407 | { |
409 | 408 | if (($key = array_search($email, $args)) !== false) |
410 | 409 | { |
@@ -417,19 +416,19 @@ discard block |
||
417 | 416 | } |
418 | 417 | } |
419 | 418 | // create not existing identities by copying standard identity plus alias as email |
420 | - foreach($args as $email) |
|
419 | + foreach ($args as $email) |
|
421 | 420 | { |
422 | 421 | $identity = $account->params; |
423 | 422 | unset($identity['ident_id']); |
424 | 423 | unset($identity['ident_name']); |
425 | 424 | $identity['ident_email'] = $email; |
426 | - $identity['account_id'] = $account_id; // make this a personal identity for $account_id |
|
425 | + $identity['account_id'] = $account_id; // make this a personal identity for $account_id |
|
427 | 426 | Api\Mail\Account::save_identity($identity); |
428 | 427 | } |
429 | 428 | if ($args) echo "Identity(s) for ".implode(', ', $args)." created.\n"; |
430 | 429 | } |
431 | 430 | } |
432 | - catch(\Exception $e) { |
|
431 | + catch (\Exception $e) { |
|
433 | 432 | _egw_log_exception($e); |
434 | 433 | echo $e->getMessage()."\n"; |
435 | 434 | } |
@@ -454,7 +453,7 @@ discard block |
||
454 | 453 | { |
455 | 454 | if (!is_array($arr)) $arr = array(); |
456 | 455 | |
457 | - switch($mod[0][0]) |
|
456 | + switch ($mod[0][0]) |
|
458 | 457 | { |
459 | 458 | case '-': |
460 | 459 | $mod[0] = substr($mod[0], 1); |
@@ -479,14 +478,14 @@ discard block |
||
479 | 478 | * @param boolean $allow true=allow, false=deny |
480 | 479 | * @return int 0 on success |
481 | 480 | */ |
482 | -function do_account_app($args,$allow) |
|
481 | +function do_account_app($args, $allow) |
|
483 | 482 | { |
484 | - array_shift($args); // admin-account |
|
485 | - array_shift($args); // admin-pw |
|
483 | + array_shift($args); // admin-account |
|
484 | + array_shift($args); // admin-pw |
|
486 | 485 | $account = array_shift($args); |
487 | 486 | |
488 | 487 | include_once(EGW_INCLUDE_ROOT.'/admin/inc/class.admin_cmd_account_app.inc.php'); |
489 | - run_command(new admin_cmd_account_app($allow,$account,$args)); |
|
488 | + run_command(new admin_cmd_account_app($allow, $account, $args)); |
|
490 | 489 | } |
491 | 490 | |
492 | 491 | /** |
@@ -496,9 +495,9 @@ discard block |
||
496 | 495 | */ |
497 | 496 | function do_edit_group($args) |
498 | 497 | { |
499 | - array_shift($args); // admin-account |
|
500 | - array_shift($args); // admin-pw |
|
501 | - list($account,$new_account_name) = explode('=',array_shift($args)); // account[=new-account-name] |
|
498 | + array_shift($args); // admin-account |
|
499 | + array_shift($args); // admin-pw |
|
500 | + list($account, $new_account_name) = explode('=', array_shift($args)); // account[=new-account-name] |
|
502 | 501 | |
503 | 502 | $data = array( |
504 | 503 | 'account_lid' => $new_account_name, |
@@ -506,19 +505,19 @@ discard block |
||
506 | 505 | 'account_members' => $args, |
507 | 506 | ); |
508 | 507 | try { |
509 | - admin_cmd::parse_account($account,false); |
|
508 | + admin_cmd::parse_account($account, false); |
|
510 | 509 | |
511 | - foreach($data as &$value) // existing account --> empty values mean dont change, not set them empty! |
|
510 | + foreach ($data as &$value) // existing account --> empty values mean dont change, not set them empty! |
|
512 | 511 | { |
513 | 512 | if ((string)$value === '') $value = null; |
514 | 513 | } |
515 | 514 | } |
516 | 515 | catch (Exception $e) { // new group |
517 | - unset($e); // not used |
|
516 | + unset($e); // not used |
|
518 | 517 | $data['account_lid'] = $account; |
519 | 518 | $account = false; |
520 | 519 | } |
521 | - run_command(new admin_cmd_edit_group($account,$data)); |
|
520 | + run_command(new admin_cmd_edit_group($account, $data)); |
|
522 | 521 | } |
523 | 522 | |
524 | 523 | /** |
@@ -528,12 +527,12 @@ discard block |
||
528 | 527 | */ |
529 | 528 | function do_change_pw($args) |
530 | 529 | { |
531 | - array_shift($args); // admin-account |
|
532 | - array_shift($args); // admin-pw |
|
533 | - $account = array_shift($args); // account |
|
534 | - $password = array_shift($args); // pw |
|
530 | + array_shift($args); // admin-account |
|
531 | + array_shift($args); // admin-pw |
|
532 | + $account = array_shift($args); // account |
|
533 | + $password = array_shift($args); // pw |
|
535 | 534 | |
536 | - run_command(new admin_cmd_change_pw($account,$password)); |
|
535 | + run_command(new admin_cmd_change_pw($account, $password)); |
|
537 | 536 | } |
538 | 537 | |
539 | 538 | /** |
@@ -542,18 +541,18 @@ discard block |
||
542 | 541 | * @param array $args admin-account[@domain],admin-password,account[=new-account-name],first-name,last-name,password,email,expires{never(default)|YYYY-MM-DD|already},can-change-pw{true(default)|false},anon-user{true|false(default)},primary-group{Default(default)|...}[,groups,...][,homedirectory,loginshell] |
543 | 542 | * @param boolean $run_addaccount_hook =null default run hook depending on account existence, true=allways run addaccount hook |
544 | 543 | */ |
545 | -function do_edit_user($args,$run_addaccount_hook=null) |
|
544 | +function do_edit_user($args, $run_addaccount_hook = null) |
|
546 | 545 | { |
547 | - array_shift($args); // admin-account |
|
548 | - array_shift($args); // admin-pw |
|
549 | - list($account,$new_account_name) = explode('=',array_shift($args)); // account[=new-account-name] |
|
546 | + array_shift($args); // admin-account |
|
547 | + array_shift($args); // admin-pw |
|
548 | + list($account, $new_account_name) = explode('=', array_shift($args)); // account[=new-account-name] |
|
550 | 549 | |
551 | 550 | $data = array(); |
552 | 551 | // do we need to support ldap only attributes: homedirectory and loginshell |
553 | 552 | if (($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' || |
554 | 553 | empty($GLOBALS['egw_info']['server']['account_repository']) && $GLOBALS['egw_info']['server']['auth_type'] == 'ldap') && |
555 | - $GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 && // 9 = primary group |
|
556 | - ($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/') // last argument start with a slash |
|
554 | + $GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 && // 9 = primary group |
|
555 | + ($last_arg = array_pop($dummy = $args)) && $last_arg[0] == '/') // last argument start with a slash |
|
557 | 556 | { |
558 | 557 | $data['loginshell'] = array_pop($args); |
559 | 558 | $data['homedirectory'] = array_pop($args); |
@@ -571,19 +570,19 @@ discard block |
||
571 | 570 | 'account_groups' => $args, |
572 | 571 | ); |
573 | 572 | try { |
574 | - admin_cmd::parse_account($account,true); |
|
573 | + admin_cmd::parse_account($account, true); |
|
575 | 574 | |
576 | - foreach($data as &$value) // existing account --> empty values mean dont change, not set them empty! |
|
575 | + foreach ($data as &$value) // existing account --> empty values mean dont change, not set them empty! |
|
577 | 576 | { |
578 | 577 | if ((string)$value === '') $value = null; |
579 | 578 | } |
580 | 579 | } |
581 | 580 | catch (Exception $e) { // new account |
582 | - unset($e); // not used |
|
581 | + unset($e); // not used |
|
583 | 582 | $data['account_lid'] = $account; |
584 | 583 | $account = false; |
585 | 584 | } |
586 | - run_command(new admin_cmd_edit_user($account,$data,null,$run_addaccount_hook)); |
|
585 | + run_command(new admin_cmd_edit_user($account, $data, null, $run_addaccount_hook)); |
|
587 | 586 | } |
588 | 587 | |
589 | 588 | /** |
@@ -594,9 +593,9 @@ discard block |
||
594 | 593 | * @param boolean $is_user =true are we called for a user or group |
595 | 594 | * @return int 0 on success, 2-4 otherwise (see source) |
596 | 595 | */ |
597 | -function do_delete_account($account,$new_user=0,$is_user=true) |
|
596 | +function do_delete_account($account, $new_user = 0, $is_user = true) |
|
598 | 597 | { |
599 | - run_command(new admin_cmd_delete_account($account,$new_user,$is_user)); |
|
598 | + run_command(new admin_cmd_delete_account($account, $new_user, $is_user)); |
|
600 | 599 | } |
601 | 600 | |
602 | 601 | /** |
@@ -617,13 +616,13 @@ discard block |
||
617 | 616 | */ |
618 | 617 | function do_change_account_id($args) |
619 | 618 | { |
620 | - if (count($args) < 4) usage(); // 4 means at least user,pw,from1,to1 |
|
619 | + if (count($args) < 4) usage(); // 4 means at least user,pw,from1,to1 |
|
621 | 620 | |
622 | 621 | $ids2change = array(); |
623 | - for($n = 2; $n < count($args); $n += 2) |
|
622 | + for ($n = 2; $n < count($args); $n += 2) |
|
624 | 623 | { |
625 | 624 | $from = (int)$args[$n]; |
626 | - $to = (int)$args[$n+1]; |
|
625 | + $to = (int)$args[$n + 1]; |
|
627 | 626 | $ids2change[$from] = $to; |
628 | 627 | } |
629 | 628 | run_command(new admin_cmd_change_account_id($ids2change)); |
@@ -639,22 +638,22 @@ discard block |
||
639 | 638 | */ |
640 | 639 | function list_exit_codes() |
641 | 640 | { |
642 | - error_reporting(error_reporting() & ~E_NOTICE); |
|
641 | + error_reporting(error_reporting()&~E_NOTICE); |
|
643 | 642 | |
644 | 643 | $codes = array('Ok'); |
645 | - foreach(file(__FILE__) as $line) |
|
644 | + foreach (file(__FILE__) as $line) |
|
646 | 645 | { |
647 | 646 | $matches = null; |
648 | - if (preg_match('/fail\(([0-9]+),(.*)\);/',$line,$matches)) |
|
647 | + if (preg_match('/fail\(([0-9]+),(.*)\);/', $line, $matches)) |
|
649 | 648 | { |
650 | 649 | //echo "Line $n: $matches[1]: $matches[2]\n"; |
651 | 650 | @eval('$codes['.$matches[1].'] = '.$matches[2].';'); |
652 | 651 | } |
653 | 652 | } |
654 | - ksort($codes,SORT_NUMERIC); |
|
655 | - foreach($codes as $num => $msg) |
|
653 | + ksort($codes, SORT_NUMERIC); |
|
654 | + foreach ($codes as $num => $msg) |
|
656 | 655 | { |
657 | - echo $num."\t".str_replace("\n","\n\t",$msg)."\n"; |
|
656 | + echo $num."\t".str_replace("\n", "\n\t", $msg)."\n"; |
|
658 | 657 | } |
659 | 658 | } |
660 | 659 | |
@@ -664,7 +663,7 @@ discard block |
||
664 | 663 | * @param array $args admin-account[@domain],admin-password,accout_lid[,pw] |
665 | 664 | * @return int 0 on success |
666 | 665 | */ |
667 | -function do_subscribe_other($account_lid,$pw=null) |
|
666 | +function do_subscribe_other($account_lid, $pw = null) |
|
668 | 667 | { |
669 | 668 | unset($account_lid, $pw); |
670 | 669 | /* ToDo: this cant work, not even in 14.x |
@@ -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 | { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | function __construct() |
52 | 52 | { |
53 | - $this->so = new Api\Storage\Base(self::APP,self::TABLE,null,'',true); |
|
53 | + $this->so = new Api\Storage\Base(self::APP, self::TABLE, null, '', true); |
|
54 | 54 | $this->so->timestamps = array('li', 'lo', 'session_dla', 'notification_heartbeat'); |
55 | 55 | } |
56 | 56 | |
@@ -63,19 +63,19 @@ discard block |
||
63 | 63 | * @param array &$readonlys eg. to disable buttons based on acl, not use here, maybe in a derived class |
64 | 64 | * @return int total number of rows |
65 | 65 | */ |
66 | - function get_rows($query,&$rows,&$readonlys) |
|
66 | + function get_rows($query, &$rows, &$readonlys) |
|
67 | 67 | { |
68 | 68 | $heartbeat_limit = Api\Session::heartbeat_limit(); |
69 | 69 | |
70 | 70 | if ($query['session_list']) // filter active sessions |
71 | 71 | { |
72 | - $query['col_filter']['lo'] = null; // not logged out |
|
72 | + $query['col_filter']['lo'] = null; // not logged out |
|
73 | 73 | $query['col_filter'][0] = 'session_dla > '.(int)(time() - $GLOBALS['egw_info']['server']['sessions_timeout']); |
74 | - switch((string)$query['session_list']) |
|
74 | + switch ((string)$query['session_list']) |
|
75 | 75 | { |
76 | 76 | case 'active': // remove status != 'active', eg. CalDAV/eSync |
77 | 77 | $query['col_filter'][1] = "notification_heartbeat > $heartbeat_limit"; |
78 | - $query['col_filter'][3] = "session_php NOT LIKE '% %'"; // remove blocked, bad login, etc |
|
78 | + $query['col_filter'][3] = "session_php NOT LIKE '% %'"; // remove blocked, bad login, etc |
|
79 | 79 | break; |
80 | 80 | default: |
81 | 81 | $query['col_filter'][1] = "(notification_heartbeat IS NULL OR notification_heartbeat > $heartbeat_limit)"; |
@@ -83,20 +83,20 @@ discard block |
||
83 | 83 | } |
84 | 84 | $query['col_filter'][2] = 'account_id>0'; |
85 | 85 | } |
86 | - $total = $this->so->get_rows($query,$rows,$readonlys); |
|
86 | + $total = $this->so->get_rows($query, $rows, $readonlys); |
|
87 | 87 | |
88 | 88 | $heartbeat_limit_user = Api\DateTime::server2user($heartbeat_limit, 'ts'); |
89 | 89 | |
90 | - foreach($rows as &$row) |
|
90 | + foreach ($rows as &$row) |
|
91 | 91 | { |
92 | 92 | $row['sessionstatus'] = 'success'; |
93 | 93 | if ($row['notification_heartbeat'] > $heartbeat_limit_user) |
94 | 94 | { |
95 | 95 | $row['sessionstatus'] = 'active'; |
96 | 96 | } |
97 | - if (stripos($row['session_php'],'blocked') !== false || |
|
98 | - stripos($row['session_php'],'bad login') !== false || |
|
99 | - strpos($row['session_php'],' ') !== false) |
|
97 | + if (stripos($row['session_php'], 'blocked') !== false || |
|
98 | + stripos($row['session_php'], 'bad login') !== false || |
|
99 | + strpos($row['session_php'], ' ') !== false) |
|
100 | 100 | { |
101 | 101 | $row['sessionstatus'] = $row['session_php']; |
102 | 102 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $row['sessionstatus'] = 'logged out'; |
106 | 106 | } |
107 | 107 | // eg. for bad login or password |
108 | - if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none')); |
|
108 | + if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid'] ? $row['loginid'] : lang('none')); |
|
109 | 109 | |
110 | 110 | // do not allow to kill or select own session |
111 | 111 | if ($GLOBALS['egw']->session->sessionid_access_log == $row['sessionid'] && $query['session_list']) |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | $row['class'] .= ' rowNoDelete '; |
114 | 114 | } |
115 | 115 | // do not allow to delete access log off active sessions |
116 | - if (!$row['lo'] && $row['session_dla'] > time()-$GLOBALS['egw_info']['server']['sessions_timeout'] && |
|
116 | + if (!$row['lo'] && $row['session_dla'] > time() - $GLOBALS['egw_info']['server']['sessions_timeout'] && |
|
117 | 117 | in_array($row['sessionstatus'], array('active', 'success')) && !$query['session_list']) |
118 | 118 | { |
119 | 119 | $row['class'] .= ' rowNoDelete '; |
120 | 120 | } |
121 | 121 | $row['sessionstatus'] = lang($row['sessionstatus']); |
122 | - unset($row['session_php']); // for security reasons, do NOT give real PHP sessionid to UI |
|
122 | + unset($row['session_php']); // for security reasons, do NOT give real PHP sessionid to UI |
|
123 | 123 | } |
124 | 124 | if ($query['session_list']) |
125 | 125 | { |
@@ -139,33 +139,33 @@ discard block |
||
139 | 139 | * @param string $msg ='' |
140 | 140 | * @param boolean $sessions_list =false |
141 | 141 | */ |
142 | - function index(array $content=null, $msg='', $sessions_list=false) |
|
142 | + function index(array $content = null, $msg = '', $sessions_list = false) |
|
143 | 143 | { |
144 | 144 | |
145 | 145 | if (is_array($content)) $sessions_list = $content['nm']['session_list']; |
146 | 146 | |
147 | 147 | // check if user has access to requested functionality |
148 | - if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces',1,'admin')) |
|
148 | + if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces', 1, 'admin')) |
|
149 | 149 | { |
150 | 150 | $GLOBALS['egw']->redirect_link('/index.php'); |
151 | 151 | } |
152 | 152 | |
153 | - if(!isset($content)) |
|
153 | + if (!isset($content)) |
|
154 | 154 | { |
155 | 155 | $content['nm'] = array( |
156 | - 'get_rows' => 'admin.admin_accesslog.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
157 | - 'no_filter' => True, // I disable the 1. filter |
|
158 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
159 | - 'no_cat' => True, // I disable the cat-selectbox |
|
160 | - 'header_left' => false, // I template to show left of the range-value, left-aligned (optional) |
|
161 | - 'header_right' => false, // I template to show right of the range-value, right-aligned (optional) |
|
162 | - 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entries |
|
163 | - 'lettersearch' => false, // I show a lettersearch |
|
164 | - 'start' => 0, // IO position in list |
|
165 | - 'order' => 'li', // IO name of the column to sort after (optional for the sortheaders) |
|
166 | - 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
156 | + 'get_rows' => 'admin.admin_accesslog.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
157 | + 'no_filter' => True, // I disable the 1. filter |
|
158 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
159 | + 'no_cat' => True, // I disable the cat-selectbox |
|
160 | + 'header_left' => false, // I template to show left of the range-value, left-aligned (optional) |
|
161 | + 'header_right' => false, // I template to show right of the range-value, right-aligned (optional) |
|
162 | + 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entries |
|
163 | + 'lettersearch' => false, // I show a lettersearch |
|
164 | + 'start' => 0, // IO position in list |
|
165 | + 'order' => 'li', // IO name of the column to sort after (optional for the sortheaders) |
|
166 | + 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
167 | 167 | //'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 |
168 | - 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
|
168 | + 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
|
169 | 169 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
170 | 170 | 'actions' => $this->get_actions($sessions_list), |
171 | 171 | 'placeholder_actions' => false, |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | 'col_filter' => $content['nm']['col_filter'] |
197 | 197 | ); |
198 | 198 | |
199 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
200 | - $query['num_rows'] = -1; // all |
|
199 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
200 | + $query['num_rows'] = -1; // all |
|
201 | 201 | $all = $readonlys = array(); |
202 | - $this->get_rows($query,$all,$readonlys); |
|
202 | + $this->get_rows($query, $all, $readonlys); |
|
203 | 203 | $content['nm']['selected'] = array(); |
204 | - foreach($all as $session) |
|
204 | + foreach ($all as $session) |
|
205 | 205 | { |
206 | 206 | $content['nm']['selected'][] = $session[$content['nm']['row_id']]; |
207 | 207 | } |
@@ -213,19 +213,19 @@ discard block |
||
213 | 213 | else |
214 | 214 | { |
215 | 215 | $success = $failed = $action = $action_msg = null; |
216 | - if ($this->action($content['nm']['action'],$content['nm']['selected'] |
|
217 | - ,$success,$failed,$action_msg,$msg)) |
|
216 | + if ($this->action($content['nm']['action'], $content['nm']['selected'] |
|
217 | + ,$success, $failed, $action_msg, $msg)) |
|
218 | 218 | { // In case of action success |
219 | 219 | switch ($action_msg) |
220 | 220 | { |
221 | 221 | case'deleted': |
222 | - $msg = lang('%1 log entries deleted.',$success); |
|
222 | + $msg = lang('%1 log entries deleted.', $success); |
|
223 | 223 | break; |
224 | 224 | case'killed': |
225 | - $msg = lang('%1 sessions killed',$success); |
|
225 | + $msg = lang('%1 sessions killed', $success); |
|
226 | 226 | } |
227 | 227 | } |
228 | - elseif($failed) // In case of action failiure |
|
228 | + elseif ($failed) // In case of action failiure |
|
229 | 229 | { |
230 | 230 | switch ($action_msg) |
231 | 231 | { |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | $content['msg'] = $msg; |
243 | 243 | $content['percent'] = 100.0 * $GLOBALS['egw']->db->query( |
244 | 244 | 'SELECT ((SELECT COUNT(*) FROM '.self::TABLE.' WHERE lo != 0) / COUNT(*)) FROM '.self::TABLE, |
245 | - __LINE__,__FILE__)->fetchColumn(); |
|
245 | + __LINE__, __FILE__)->fetchColumn(); |
|
246 | 246 | |
247 | 247 | $tmpl = new Etemplate('admin.accesslog'); |
248 | 248 | $tmpl->exec('admin.admin_accesslog.index', $content, array(), $readonlys, array( |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @param type $action_msg |
262 | 262 | * @return type number of failed |
263 | 263 | */ |
264 | - function action($action,$checked,&$success,&$failed,&$action_msg) |
|
264 | + function action($action, $checked, &$success, &$failed, &$action_msg) |
|
265 | 265 | { |
266 | 266 | $success = $failed = 0; |
267 | 267 | //error_log(__METHOD__.'selected:' . array2string($checked). 'action:' . $action); |
@@ -269,14 +269,14 @@ discard block |
||
269 | 269 | { |
270 | 270 | case "delete": |
271 | 271 | $action_msg = "deleted"; |
272 | - $del_msg= $this->so->delete(array('sessionid' => $checked)); |
|
272 | + $del_msg = $this->so->delete(array('sessionid' => $checked)); |
|
273 | 273 | if ($checked && $del_msg) |
274 | 274 | { |
275 | 275 | $success = $del_msg; |
276 | 276 | } |
277 | 277 | else |
278 | 278 | { |
279 | - $failed ++; |
|
279 | + $failed++; |
|
280 | 280 | } |
281 | 281 | break; |
282 | 282 | case "kill": |
@@ -284,19 +284,19 @@ discard block |
||
284 | 284 | $sessionid = $checked; |
285 | 285 | if (($key = array_search($GLOBALS['egw']->session->sessionid_access_log, $sessionid))) |
286 | 286 | { |
287 | - unset($sessionid[$key]); // dont allow to kill own sessions |
|
287 | + unset($sessionid[$key]); // dont allow to kill own sessions |
|
288 | 288 | } |
289 | - if ($GLOBALS['egw']->acl->check('current_sessions',8,'admin')) |
|
289 | + if ($GLOBALS['egw']->acl->check('current_sessions', 8, 'admin')) |
|
290 | 290 | { |
291 | - $failed ++; |
|
291 | + $failed++; |
|
292 | 292 | } |
293 | 293 | else |
294 | 294 | { |
295 | - foreach((array)$sessionid as $id) |
|
295 | + foreach ((array)$sessionid as $id) |
|
296 | 296 | { |
297 | 297 | $GLOBALS['egw']->session->destroy($id); |
298 | 298 | } |
299 | - $success= count($sessionid); |
|
299 | + $success = count($sessionid); |
|
300 | 300 | } |
301 | 301 | break; |
302 | 302 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | if ($sessions_list) |
317 | 317 | { |
318 | 318 | // error_log(__METHOD__. $sessions_list); |
319 | - $actions= array( |
|
319 | + $actions = array( |
|
320 | 320 | 'kill' => array( |
321 | 321 | 'caption' => 'Kill', |
322 | 322 | 'confirm' => 'Kill this session', |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | } |
330 | 330 | else |
331 | 331 | { |
332 | - $actions= array( |
|
332 | + $actions = array( |
|
333 | 333 | 'delete' => array( |
334 | 334 | 'caption' => 'Delete', |
335 | 335 | 'confirm' => 'Delete this entry', |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * @param array $content =null |
362 | 362 | * @param string $msg ='' |
363 | 363 | */ |
364 | - function sessions(array $content=null, $msg='') |
|
364 | + function sessions(array $content = null, $msg = '') |
|
365 | 365 | { |
366 | 366 | return $this->index($content, $msg, true); |
367 | 367 | } |
@@ -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!'); |
@@ -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) |
@@ -150,8 +150,14 @@ discard block |
||
150 | 150 | { |
151 | 151 | case 'save': |
152 | 152 | case 'apply': |
153 | - if(is_array($content['owner'])) $content['owner'] = implode(',',$content['owner']); |
|
154 | - if($content['owner'] == '') $content['owner'] = 0; |
|
153 | + if(is_array($content['owner'])) |
|
154 | + { |
|
155 | + $content['owner'] = implode(',',$content['owner']); |
|
156 | + } |
|
157 | + if($content['owner'] == '') |
|
158 | + { |
|
159 | + $content['owner'] = 0; |
|
160 | + } |
|
155 | 161 | if ($content['id'] && self::$acl_edit) |
156 | 162 | { |
157 | 163 | |
@@ -247,7 +253,10 @@ discard block |
||
247 | 253 | Framework::refresh_opener($msg, $this->appname, $content['id'], $change_color ? null : 'update', $refresh_app); |
248 | 254 | } |
249 | 255 | $content['msg'] = $msg; |
250 | - if(!$content['appname']) $content['appname'] = $appname; |
|
256 | + if(!$content['appname']) |
|
257 | + { |
|
258 | + $content['appname'] = $appname; |
|
259 | + } |
|
251 | 260 | if($content['data']['icon']) |
252 | 261 | { |
253 | 262 | $content['icon_url'] = $content['base_url'] . $content['data']['icon']; |
@@ -302,7 +311,9 @@ discard block |
||
302 | 311 | // Allow admins access to all categories as parent |
303 | 312 | $content['all_cats'] = 'all_no_acl'; |
304 | 313 | $readonlys['owner'] = false; |
305 | - } else { |
|
314 | + } |
|
315 | + else |
|
316 | + { |
|
306 | 317 | $readonlys['owner'] = true; |
307 | 318 | $readonlys['access'] = $content['owner'] != $GLOBALS['egw_info']['user']['account_id']; |
308 | 319 | } |
@@ -313,7 +324,10 @@ discard block |
||
313 | 324 | $appname != $content['appname'] || // Can't edit a category from a different app |
314 | 325 | ($this->appname != 'admin' && $content['owner'] != $GLOBALS['egw_info']['user']['account_id']); |
315 | 326 | // Make sure $content['owner'] is an array otherwise it wont show up values in the multiselectbox |
316 | - if (!is_array($content['owner'])) $content['owner'] = explode(',',$content['owner']); |
|
327 | + if (!is_array($content['owner'])) |
|
328 | + { |
|
329 | + $content['owner'] = explode(',',$content['owner']); |
|
330 | + } |
|
317 | 331 | $tmpl = new Etemplate('admin.categories.edit'); |
318 | 332 | $tmpl->exec($this->edit_link,$content,$sel_options,$readonlys,$content+array( |
319 | 333 | 'old_parent' => $content['old_parent'] ? $content['old_parent'] : $content['parent'], 'appname' => $appname |
@@ -373,9 +387,15 @@ discard block |
||
373 | 387 | { |
374 | 388 | $globalcat = false; |
375 | 389 | } |
376 | - if ($globalcat && $query['filter']) $filter['access'] = 'public'; |
|
390 | + if ($globalcat && $query['filter']) |
|
391 | + { |
|
392 | + $filter['access'] = 'public'; |
|
393 | + } |
|
377 | 394 | // new column-filter access has highest priority |
378 | - if (!empty($query['col_filter']['access']))$filter['access'] = $query['col_filter']['access']; |
|
395 | + if (!empty($query['col_filter']['access'])) |
|
396 | + { |
|
397 | + $filter['access'] = $query['col_filter']['access']; |
|
398 | + } |
|
379 | 399 | |
380 | 400 | Api\Cache::setSession(__CLASS__.$query['appname'],'nm',$query); |
381 | 401 | |
@@ -404,7 +424,10 @@ discard block |
||
404 | 424 | |
405 | 425 | $row['level_spacer'] = str_repeat(' ',$row['level']); |
406 | 426 | |
407 | - if ($row['data']['icon']) $row['icon_url'] = self::icon_url($row['data']['icon']); |
|
427 | + if ($row['data']['icon']) |
|
428 | + { |
|
429 | + $row['icon_url'] = self::icon_url($row['data']['icon']); |
|
430 | + } |
|
408 | 431 | |
409 | 432 | $row['subs'] = count($row['children']); |
410 | 433 | |
@@ -435,13 +458,19 @@ discard block |
||
435 | 458 | $readonlys['nm']["add[$row[id]]"] = !self::$acl_add_sub; |
436 | 459 | $readonlys['nm']["delete[$row[id]]"] = !self::$acl_delete; |
437 | 460 | } |
438 | - if (true) $rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']); |
|
461 | + if (true) |
|
462 | + { |
|
463 | + $rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']); |
|
464 | + } |
|
439 | 465 | // make appname available for actions |
440 | 466 | $rows['appname'] = $query['appname']; |
441 | 467 | $rows['edit_link'] = $this->edit_link; |
442 | 468 | |
443 | 469 | // disable access column for global Categories |
444 | - if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin') $rows['no_access'] = true; |
|
470 | + if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin') |
|
471 | + { |
|
472 | + $rows['no_access'] = true; |
|
473 | + } |
|
445 | 474 | |
446 | 475 | $GLOBALS['egw_info']['flags']['app_header'] = lang($this->appname).' - '.lang('categories'). |
447 | 476 | ($query['appname'] != Categories::GLOBAL_APPNAME ? ': '.lang($query['appname']) : ''); |
@@ -458,11 +487,18 @@ discard block |
||
458 | 487 | public function index(array $content=null,$msg='') |
459 | 488 | { |
460 | 489 | //_debug_array($_GET); |
461 | - if ($this->appname != 'admin') Api\Translation::add_app('admin'); // need admin translations |
|
490 | + if ($this->appname != 'admin') |
|
491 | + { |
|
492 | + Api\Translation::add_app('admin'); |
|
493 | + } |
|
494 | + // need admin translations |
|
462 | 495 | |
463 | 496 | if(!isset($content)) |
464 | 497 | { |
465 | - if (isset($_GET['msg'])) $msg = $_GET['msg']; |
|
498 | + if (isset($_GET['msg'])) |
|
499 | + { |
|
500 | + $msg = $_GET['msg']; |
|
501 | + } |
|
466 | 502 | |
467 | 503 | $appname = Categories::GLOBAL_APPNAME; |
468 | 504 | foreach(array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field) |
@@ -602,7 +638,8 @@ discard block |
||
602 | 638 | $readonlys['nm']['rows']['owner'] = true; |
603 | 639 | $readonlys['nm']['col_filter']['owner'] = true; |
604 | 640 | } |
605 | - if($appname == Categories::GLOBAL_APPNAME) { |
|
641 | + if($appname == Categories::GLOBAL_APPNAME) |
|
642 | + { |
|
606 | 643 | $sel_options['app'] = array(''=>''); |
607 | 644 | $readonlys['nm']['rows']['app'] = true; |
608 | 645 | } |
@@ -620,7 +657,8 @@ discard block |
||
620 | 657 | )); |
621 | 658 | } |
622 | 659 | |
623 | - protected function get_actions($appname=Api\Categories::GLOBAL_APPNAME) { |
|
660 | + protected function get_actions($appname=Api\Categories::GLOBAL_APPNAME) |
|
661 | + { |
|
624 | 662 | |
625 | 663 | $actions = array( |
626 | 664 | 'open' => array( // does edit if allowed, otherwise view |
@@ -731,11 +769,17 @@ discard block |
||
731 | 769 | list($add_remove, $ids_csv) = explode('_', $settings, 2); |
732 | 770 | $ids = explode(',', $ids_csv); |
733 | 771 | // Adding 'All users' removes all the others |
734 | - if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT); |
|
772 | + if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false) |
|
773 | + { |
|
774 | + $ids = array(Categories::GLOBAL_ACCOUNT); |
|
775 | + } |
|
735 | 776 | |
736 | 777 | foreach($checked as $id) |
737 | 778 | { |
738 | - if (!$data = $cats->read($id)) continue; |
|
779 | + if (!$data = $cats->read($id)) |
|
780 | + { |
|
781 | + continue; |
|
782 | + } |
|
739 | 783 | $data['owner'] = explode(',',$data['owner']); |
740 | 784 | if(array_search(Categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0) |
741 | 785 | { |
@@ -775,7 +819,10 @@ discard block |
||
775 | 819 | continue; |
776 | 820 | } |
777 | 821 | // Skip apps that don't show in the app bar, they [usually] don't have Categories |
778 | - if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue; |
|
822 | + if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) |
|
823 | + { |
|
824 | + continue; |
|
825 | + } |
|
779 | 826 | if ($GLOBALS['egw_info']['user']['apps'][$app]) |
780 | 827 | { |
781 | 828 | $apps[$app] = $data['title'] ? $data['title'] : lang($app); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | { |
64 | 64 | throw new Api\Exception\NoPermission\Admin(); |
65 | 65 | } |
66 | - if ($GLOBALS['egw']->acl->check('global_categorie',1,'admin')) |
|
66 | + if ($GLOBALS['egw']->acl->check('global_categorie', 1, 'admin')) |
|
67 | 67 | { |
68 | 68 | $GLOBALS['egw']->redirect_link('/index.php'); |
69 | 69 | } |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | { |
78 | 78 | if (is_null(self::$acl_search)) |
79 | 79 | { |
80 | - self::$acl_search = !$GLOBALS['egw']->acl->check('global_categorie',2,'admin'); |
|
81 | - self::$acl_add = !$GLOBALS['egw']->acl->check('global_categorie',4,'admin'); |
|
82 | - self::$acl_view = !$GLOBALS['egw']->acl->check('global_categorie',8,'admin'); |
|
83 | - self::$acl_edit = !$GLOBALS['egw']->acl->check('global_categorie',16,'admin'); |
|
84 | - self::$acl_delete = !$GLOBALS['egw']->acl->check('global_categorie',32,'admin'); |
|
85 | - self::$acl_add_sub= !$GLOBALS['egw']->acl->check('global_categorie',64,'admin'); |
|
80 | + self::$acl_search = !$GLOBALS['egw']->acl->check('global_categorie', 2, 'admin'); |
|
81 | + self::$acl_add = !$GLOBALS['egw']->acl->check('global_categorie', 4, 'admin'); |
|
82 | + self::$acl_view = !$GLOBALS['egw']->acl->check('global_categorie', 8, 'admin'); |
|
83 | + self::$acl_edit = !$GLOBALS['egw']->acl->check('global_categorie', 16, 'admin'); |
|
84 | + self::$acl_delete = !$GLOBALS['egw']->acl->check('global_categorie', 32, 'admin'); |
|
85 | + self::$acl_add_sub = !$GLOBALS['egw']->acl->check('global_categorie', 64, 'admin'); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | * @param array $content = null |
93 | 93 | * @param string $msg = '' |
94 | 94 | */ |
95 | - public function edit(array $content=null,$msg='') |
|
95 | + public function edit(array $content = null, $msg = '') |
|
96 | 96 | { |
97 | 97 | // read the session, as the global_cats param is stored with it. |
98 | - $appname = $content['appname'] ? $content['appname'] : ($_GET['appname']?$_GET['appname']:Api\Categories::GLOBAL_APPNAME); |
|
99 | - $session = Api\Cache::getSession(__CLASS__.$appname,'nm'); |
|
98 | + $appname = $content['appname'] ? $content['appname'] : ($_GET['appname'] ? $_GET['appname'] : Api\Categories::GLOBAL_APPNAME); |
|
99 | + $session = Api\Cache::getSession(__CLASS__.$appname, 'nm'); |
|
100 | 100 | unset($session); |
101 | 101 | if (!isset($content)) |
102 | 102 | { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | ($content = Categories::read($_GET['cat_id'])))) |
105 | 105 | { |
106 | 106 | $content = array('data' => array()); |
107 | - if(isset($_GET['parent']) && $_GET['parent'] > 0) |
|
107 | + if (isset($_GET['parent']) && $_GET['parent'] > 0) |
|
108 | 108 | { |
109 | 109 | // Sub-category - set some defaults from parent |
110 | 110 | $content['parent'] = (int)$_GET['parent']; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $appname = Categories::GLOBAL_APPNAME; |
121 | 121 | } |
122 | 122 | } |
123 | - elseif ($content['appname'] != $appname || !self::$acl_edit || ( $content['owner'] != $GLOBALS['egw_info']['user']['account_id'] && $this->appname != 'admin')) |
|
123 | + elseif ($content['appname'] != $appname || !self::$acl_edit || ($content['owner'] != $GLOBALS['egw_info']['user']['account_id'] && $this->appname != 'admin')) |
|
124 | 124 | { |
125 | 125 | // only allow to view category |
126 | 126 | $readonlys['__ALL__'] = true; |
@@ -130,12 +130,12 @@ discard block |
||
130 | 130 | } |
131 | 131 | elseif ($content['button'] || $content['delete']) |
132 | 132 | { |
133 | - $cats = new Categories($content['owner'] ? $content['owner'] : Categories::GLOBAL_ACCOUNT,$content['appname']); |
|
133 | + $cats = new Categories($content['owner'] ? $content['owner'] : Categories::GLOBAL_ACCOUNT, $content['appname']); |
|
134 | 134 | |
135 | 135 | if ($content['delete']['delete'] || $content['delete']['subs']) |
136 | 136 | { |
137 | 137 | $button = 'delete'; |
138 | - $delete_subs = $content['delete']['subs']?true:false; |
|
138 | + $delete_subs = $content['delete']['subs'] ?true:false; |
|
139 | 139 | } |
140 | 140 | else |
141 | 141 | { |
@@ -146,23 +146,23 @@ discard block |
||
146 | 146 | |
147 | 147 | $refresh_app = $this->appname == 'preferences' ? $content['appname'] : $this->appname; |
148 | 148 | |
149 | - switch($button) |
|
149 | + switch ($button) |
|
150 | 150 | { |
151 | 151 | case 'save': |
152 | 152 | case 'apply': |
153 | - if(is_array($content['owner'])) $content['owner'] = implode(',',$content['owner']); |
|
154 | - if($content['owner'] == '') $content['owner'] = 0; |
|
153 | + if (is_array($content['owner'])) $content['owner'] = implode(',', $content['owner']); |
|
154 | + if ($content['owner'] == '') $content['owner'] = 0; |
|
155 | 155 | if ($content['id'] && self::$acl_edit) |
156 | 156 | { |
157 | 157 | |
158 | - $data = $cats->id2name($content['id'],'data'); |
|
158 | + $data = $cats->id2name($content['id'], 'data'); |
|
159 | 159 | try { |
160 | 160 | $cats->edit($content); |
161 | 161 | $msg = lang('Category saved.'); |
162 | 162 | } |
163 | 163 | catch (Api\Exception\WrongUserinput $e) |
164 | 164 | { |
165 | - $msg = lang('Unwilling to save category with current settings. Check for inconsistency:').$e->getMessage(); // display conflicts etc. |
|
165 | + $msg = lang('Unwilling to save category with current settings. Check for inconsistency:').$e->getMessage(); // display conflicts etc. |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | elseif (!$content['id'] && ( |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | // to reload the whole nextmatch instead of just the row |
182 | 182 | $change_color = ($data['color'] != $content['data']['color']); |
183 | 183 | // Nicely reload just the category window / iframe |
184 | - if($change_color) |
|
184 | + if ($change_color) |
|
185 | 185 | { |
186 | - if(Api\Json\Response::isJSONResponse()) |
|
186 | + if (Api\Json\Response::isJSONResponse()) |
|
187 | 187 | { |
188 | - if($this->appname != 'admin') |
|
188 | + if ($this->appname != 'admin') |
|
189 | 189 | { |
190 | 190 | // Need to forcably re-load everything to force the CSS to be loaded |
191 | 191 | Api\Json\Response::get()->redirect(Framework::link('/index.php', array( |
@@ -229,10 +229,10 @@ discard block |
||
229 | 229 | case 'delete': |
230 | 230 | if (self::$acl_delete) |
231 | 231 | { |
232 | - $cats->delete($content['id'],$delete_subs,!$delete_subs); |
|
232 | + $cats->delete($content['id'], $delete_subs, !$delete_subs); |
|
233 | 233 | $msg = lang('Category deleted.'); |
234 | 234 | |
235 | - Framework::refresh_opener($msg, $refresh_app, $content['id'],'delete', $this->appname); |
|
235 | + Framework::refresh_opener($msg, $refresh_app, $content['id'], 'delete', $this->appname); |
|
236 | 236 | Framework::window_close(); |
237 | 237 | return; |
238 | 238 | } |
@@ -247,19 +247,19 @@ discard block |
||
247 | 247 | Framework::refresh_opener($msg, $this->appname, $content['id'], $change_color ? null : 'update', $refresh_app); |
248 | 248 | } |
249 | 249 | $content['msg'] = $msg; |
250 | - if(!$content['appname']) $content['appname'] = $appname; |
|
251 | - if($content['data']['icon']) |
|
250 | + if (!$content['appname']) $content['appname'] = $appname; |
|
251 | + if ($content['data']['icon']) |
|
252 | 252 | { |
253 | - $content['icon_url'] = $content['base_url'] . $content['data']['icon']; |
|
253 | + $content['icon_url'] = $content['base_url'].$content['data']['icon']; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | $sel_options['icon'] = self::get_icons(); |
257 | 257 | $sel_options['owner'] = array(); |
258 | 258 | |
259 | 259 | // User's category - add current value to be able to preserve owner |
260 | - if(!$content['id']) |
|
260 | + if (!$content['id']) |
|
261 | 261 | { |
262 | - if($this->appname != 'admin') |
|
262 | + if ($this->appname != 'admin') |
|
263 | 263 | { |
264 | 264 | $content['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
265 | 265 | } |
@@ -269,24 +269,24 @@ discard block |
||
269 | 269 | } |
270 | 270 | } |
271 | 271 | |
272 | - if($this->appname != 'admin' && $content['owner'] > 0 ) |
|
272 | + if ($this->appname != 'admin' && $content['owner'] > 0) |
|
273 | 273 | { |
274 | 274 | $sel_options['owner'][$content['owner']] = Api\Accounts::username($content['owner']); |
275 | 275 | } |
276 | 276 | // Add 'All users', in case owner is readonlys |
277 | - if($content['id'] && $content['owner'] == 0) |
|
277 | + if ($content['id'] && $content['owner'] == 0) |
|
278 | 278 | { |
279 | 279 | $sel_options['owner'][0] = lang('All users'); |
280 | 280 | } |
281 | - if($this->appname == 'admin' || ($content['id'] && !((int)$content['owner'] > 0))) |
|
281 | + if ($this->appname == 'admin' || ($content['id'] && !((int)$content['owner'] > 0))) |
|
282 | 282 | { |
283 | - if($content['owner'] > 0) |
|
283 | + if ($content['owner'] > 0) |
|
284 | 284 | { |
285 | 285 | $content['msg'] .= "\n".lang('owner "%1" removed, please select group-owner', Api\Accounts::username($content['owner'])); |
286 | 286 | $content['owner'] = 0; |
287 | 287 | } |
288 | 288 | $sel_options['owner'][0] = lang('All users'); |
289 | - foreach($GLOBALS['egw']->accounts->search(array('type' => 'groups')) as $acc) |
|
289 | + foreach ($GLOBALS['egw']->accounts->search(array('type' => 'groups')) as $acc) |
|
290 | 290 | { |
291 | 291 | if ($acc['account_type'] == 'g') |
292 | 292 | { |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | $content['no_private'] = true; |
297 | 297 | } |
298 | 298 | |
299 | - if($this->appname == 'admin') |
|
299 | + if ($this->appname == 'admin') |
|
300 | 300 | { |
301 | 301 | $content['access'] = 'public'; |
302 | 302 | // Allow admins access to all categories as parent |
@@ -307,17 +307,17 @@ discard block |
||
307 | 307 | $readonlys['access'] = $content['owner'] != $GLOBALS['egw_info']['user']['account_id']; |
308 | 308 | } |
309 | 309 | |
310 | - Framework::includeJS('.','global_categories','admin'); |
|
310 | + Framework::includeJS('.', 'global_categories', 'admin'); |
|
311 | 311 | |
312 | - $readonlys['button[delete]'] = !$content['id'] || !self::$acl_delete || // cant delete not yet saved category |
|
312 | + $readonlys['button[delete]'] = !$content['id'] || !self::$acl_delete || // cant delete not yet saved category |
|
313 | 313 | $appname != $content['appname'] || // Can't edit a category from a different app |
314 | 314 | ($this->appname != 'admin' && $content['owner'] != $GLOBALS['egw_info']['user']['account_id']); |
315 | 315 | // Make sure $content['owner'] is an array otherwise it wont show up values in the multiselectbox |
316 | - if (!is_array($content['owner'])) $content['owner'] = explode(',',$content['owner']); |
|
316 | + if (!is_array($content['owner'])) $content['owner'] = explode(',', $content['owner']); |
|
317 | 317 | $tmpl = new Etemplate('admin.categories.edit'); |
318 | - $tmpl->exec($this->edit_link,$content,$sel_options,$readonlys,$content+array( |
|
318 | + $tmpl->exec($this->edit_link, $content, $sel_options, $readonlys, $content + array( |
|
319 | 319 | 'old_parent' => $content['old_parent'] ? $content['old_parent'] : $content['parent'], 'appname' => $appname |
320 | - ),2); |
|
320 | + ), 2); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * @param string $icon = '' filename |
327 | 327 | * @return string url |
328 | 328 | */ |
329 | - static function icon_url($icon='') |
|
329 | + static function icon_url($icon = '') |
|
330 | 330 | { |
331 | 331 | return $GLOBALS['egw_info']['server']['webserver_url'].self::ICON_PATH.'/'.$icon; |
332 | 332 | } |
@@ -339,12 +339,12 @@ discard block |
||
339 | 339 | static function get_icons() |
340 | 340 | { |
341 | 341 | $icons = array(); |
342 | - if (file_exists($image_dir=EGW_SERVER_ROOT.self::ICON_PATH) && ($dir = dir($image_dir))) |
|
342 | + if (file_exists($image_dir = EGW_SERVER_ROOT.self::ICON_PATH) && ($dir = dir($image_dir))) |
|
343 | 343 | { |
344 | 344 | $matches = null; |
345 | - while(($file = $dir->read())) |
|
345 | + while (($file = $dir->read())) |
|
346 | 346 | { |
347 | - if (preg_match('/^(.*)\\.(png|gif|jpe?g)$/i',$file,$matches)) |
|
347 | + if (preg_match('/^(.*)\\.(png|gif|jpe?g)$/i', $file, $matches)) |
|
348 | 348 | { |
349 | 349 | $icons[$file] = ucfirst($matches[1]); |
350 | 350 | } |
@@ -363,13 +363,13 @@ discard block |
||
363 | 363 | * @param array &$readonlys eg. to disable buttons based on Acl, not use here, maybe in a derived class |
364 | 364 | * @return int total number of rows |
365 | 365 | */ |
366 | - public function get_rows(&$query,&$rows,&$readonlys) |
|
366 | + public function get_rows(&$query, &$rows, &$readonlys) |
|
367 | 367 | { |
368 | 368 | self::init_static(); |
369 | 369 | |
370 | 370 | $filter = array(); |
371 | 371 | $globalcat = ($query['filter'] === Categories::GLOBAL_ACCOUNT || !$query['filter']); |
372 | - if (isset($query['global_cats']) && $query['global_cats']===false) |
|
372 | + if (isset($query['global_cats']) && $query['global_cats'] === false) |
|
373 | 373 | { |
374 | 374 | $globalcat = false; |
375 | 375 | } |
@@ -377,49 +377,49 @@ discard block |
||
377 | 377 | // new column-filter access has highest priority |
378 | 378 | if (!empty($query['col_filter']['access']))$filter['access'] = $query['col_filter']['access']; |
379 | 379 | |
380 | - Api\Cache::setSession(__CLASS__.$query['appname'],'nm',$query); |
|
380 | + Api\Cache::setSession(__CLASS__.$query['appname'], 'nm', $query); |
|
381 | 381 | |
382 | - if($query['filter'] > 0 || $query['col_filter']['owner']) |
|
382 | + if ($query['filter'] > 0 || $query['col_filter']['owner']) |
|
383 | 383 | { |
384 | 384 | $owner = $query['col_filter']['owner'] ? $query['col_filter']['owner'] : $query['filter']; |
385 | 385 | } |
386 | - if($query['col_filter']['app']) |
|
386 | + if ($query['col_filter']['app']) |
|
387 | 387 | { |
388 | 388 | $filter['appname'] = $query['col_filter']['app']; |
389 | 389 | } |
390 | - $GLOBALS['egw']->categories = $cats = new Categories($filter['owner'],$query['appname']); |
|
391 | - $globals = isset($GLOBALS['egw_info']['user']['apps']['admin']) ? 'all_no_acl' : $globalcat; // ignore Acl only for admins |
|
390 | + $GLOBALS['egw']->categories = $cats = new Categories($filter['owner'], $query['appname']); |
|
391 | + $globals = isset($GLOBALS['egw_info']['user']['apps']['admin']) ? 'all_no_acl' : $globalcat; // ignore Acl only for admins |
|
392 | 392 | $parent = $query['search'] ? false : 0; |
393 | - $rows = $cats->return_sorted_array($query['start'],false,$query['search'],$query['sort'],$query['order'],$globals,$parent,true,$filter); |
|
393 | + $rows = $cats->return_sorted_array($query['start'], false, $query['search'], $query['sort'], $query['order'], $globals, $parent, true, $filter); |
|
394 | 394 | $count = $cats->total_records; |
395 | - foreach($rows as $key => &$row) |
|
395 | + foreach ($rows as $key => &$row) |
|
396 | 396 | { |
397 | - $row['owner'] = explode(',',$row['owner']); |
|
398 | - if(($owner && !in_array($owner, $row['owner'])) || ((string)$query['filter'] === (string)Api\Categories::GLOBAL_ACCOUNT && $row['owner'][0] > 0)) |
|
397 | + $row['owner'] = explode(',', $row['owner']); |
|
398 | + if (($owner && !in_array($owner, $row['owner'])) || ((string)$query['filter'] === (string)Api\Categories::GLOBAL_ACCOUNT && $row['owner'][0] > 0)) |
|
399 | 399 | { |
400 | 400 | unset($rows[$key]); |
401 | 401 | $count--; |
402 | 402 | continue; |
403 | 403 | } |
404 | 404 | |
405 | - $row['level_spacer'] = str_repeat(' ',$row['level']); |
|
405 | + $row['level_spacer'] = str_repeat(' ', $row['level']); |
|
406 | 406 | |
407 | 407 | if ($row['data']['icon']) $row['icon_url'] = self::icon_url($row['data']['icon']); |
408 | 408 | |
409 | 409 | $row['subs'] = count($row['children']); |
410 | 410 | |
411 | 411 | $row['class'] = 'level'.$row['level']; |
412 | - if($row['owner'][0] > 0 && !$GLOBALS['egw_info']['user']['apps']['admin'] && $row['owner'][0] != $GLOBALS['egw_info']['user']['account_id']) |
|
412 | + if ($row['owner'][0] > 0 && !$GLOBALS['egw_info']['user']['apps']['admin'] && $row['owner'][0] != $GLOBALS['egw_info']['user']['account_id']) |
|
413 | 413 | { |
414 | 414 | $row['class'] .= ' rowNoEdit rowNoDelete '; |
415 | 415 | } |
416 | 416 | else if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
417 | 417 | { |
418 | - if(!$cats->check_perms(Acl::EDIT, $row['id']) || !self::$acl_edit) |
|
418 | + if (!$cats->check_perms(Acl::EDIT, $row['id']) || !self::$acl_edit) |
|
419 | 419 | { |
420 | 420 | $row['class'] .= ' rowNoEdit'; |
421 | 421 | } |
422 | - if(!$cats->check_perms(Acl::DELETE, $row['id']) || !self::$acl_delete || |
|
422 | + if (!$cats->check_perms(Acl::DELETE, $row['id']) || !self::$acl_delete || |
|
423 | 423 | // Only admins can delete globals |
424 | 424 | $cats->is_global($row['id']) && !$GLOBALS['egw_info']['user']['apps']['admin']) |
425 | 425 | { |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | } |
428 | 428 | } |
429 | 429 | // Can only edit or delete (via context menu) Categories for the selected app (backend restriction) |
430 | - if($row['appname'] != $query['appname']) |
|
430 | + if ($row['appname'] != $query['appname']) |
|
431 | 431 | { |
432 | 432 | $row['class'] .= ' rowNoEdit rowNoDelete '; |
433 | 433 | } |
@@ -455,60 +455,60 @@ discard block |
||
455 | 455 | * @param array $content = null |
456 | 456 | * @param string $msg = '' |
457 | 457 | */ |
458 | - public function index(array $content=null,$msg='') |
|
458 | + public function index(array $content = null, $msg = '') |
|
459 | 459 | { |
460 | 460 | //_debug_array($_GET); |
461 | - if ($this->appname != 'admin') Api\Translation::add_app('admin'); // need admin translations |
|
461 | + if ($this->appname != 'admin') Api\Translation::add_app('admin'); // need admin translations |
|
462 | 462 | |
463 | - if(!isset($content)) |
|
463 | + if (!isset($content)) |
|
464 | 464 | { |
465 | 465 | if (isset($_GET['msg'])) $msg = $_GET['msg']; |
466 | 466 | |
467 | 467 | $appname = Categories::GLOBAL_APPNAME; |
468 | - foreach(array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field) |
|
468 | + foreach (array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field) |
|
469 | 469 | { |
470 | - if($field) |
|
470 | + if ($field) |
|
471 | 471 | { |
472 | 472 | $appname = $field; |
473 | 473 | break; |
474 | 474 | } |
475 | 475 | } |
476 | - $content['nm'] = Api\Cache::getSession(__CLASS__.$appname,'nm'); |
|
476 | + $content['nm'] = Api\Cache::getSession(__CLASS__.$appname, 'nm'); |
|
477 | 477 | if (!is_array($content['nm'])) |
478 | 478 | { |
479 | 479 | $content['nm'] = array( |
480 | - 'get_rows' => $this->get_rows, // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
480 | + 'get_rows' => $this->get_rows, // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
481 | 481 | 'options-filter' => array( |
482 | 482 | '' => lang('All categories'), |
483 | 483 | Categories::GLOBAL_ACCOUNT => lang('Global categories'), |
484 | 484 | $GLOBALS['egw_info']['user']['account_id'] => lang('Own categories'), |
485 | 485 | ), |
486 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
487 | - 'no_cat' => True, // I disable the cat-selectbox |
|
488 | - 'header_left' => false, // I template to show left of the range-value, left-aligned (optional) |
|
489 | - 'header_right' => false, // I template to show right of the range-value, right-aligned (optional) |
|
490 | - 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entries |
|
491 | - 'lettersearch' => false, // I show a lettersearch |
|
492 | - 'start' => 0, // IO position in list |
|
493 | - 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
494 | - 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
495 | - '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 |
|
496 | - 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
|
486 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
487 | + 'no_cat' => True, // I disable the cat-selectbox |
|
488 | + 'header_left' => false, // I template to show left of the range-value, left-aligned (optional) |
|
489 | + 'header_right' => false, // I template to show right of the range-value, right-aligned (optional) |
|
490 | + 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entries |
|
491 | + 'lettersearch' => false, // I show a lettersearch |
|
492 | + 'start' => 0, // IO position in list |
|
493 | + 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
494 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
495 | + '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 |
|
496 | + 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
|
497 | 497 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
498 | 498 | 'no_search' => !self::$acl_search, |
499 | 499 | 'row_id' => 'id', |
500 | 500 | 'dataStorePrefix' => 'categories' // Avoid conflict with user list when in admin |
501 | 501 | ); |
502 | - $content['nm']['filter'] = $this->appname == 'admin'?Api\Categories::GLOBAL_ACCOUNT:$GLOBALS['egw_info']['user']['account_id']; |
|
502 | + $content['nm']['filter'] = $this->appname == 'admin' ?Api\Categories::GLOBAL_ACCOUNT : $GLOBALS['egw_info']['user']['account_id']; |
|
503 | 503 | } |
504 | 504 | else |
505 | 505 | { |
506 | - $content['nm']['start']=0; |
|
506 | + $content['nm']['start'] = 0; |
|
507 | 507 | } |
508 | 508 | $content['nm']['appname'] = $appname = $_GET['appname'] ? $_GET['appname'] : $appname; |
509 | 509 | $content['nm']['actions'] = $this->get_actions($appname); |
510 | 510 | // switch filter off for super-global categories |
511 | - if($appname == 'phpgw') |
|
511 | + if ($appname == 'phpgw') |
|
512 | 512 | { |
513 | 513 | $content['nm']['no_filter'] = true; |
514 | 514 | // Make sure filter is set properly, could be different if user was looking at something else |
@@ -516,18 +516,18 @@ discard block |
||
516 | 516 | } |
517 | 517 | |
518 | 518 | $content['nm']['global_cats'] = true; |
519 | - if (isset($_GET['global_cats']) && empty($_GET['global_cats'] )) |
|
519 | + if (isset($_GET['global_cats']) && empty($_GET['global_cats'])) |
|
520 | 520 | { |
521 | 521 | $content['nm']['global_cats'] = false; |
522 | 522 | } |
523 | 523 | } |
524 | - elseif($content['nm']['action']) |
|
524 | + elseif ($content['nm']['action']) |
|
525 | 525 | { |
526 | 526 | $appname = $content['nm']['appname']; |
527 | 527 | // Old buttons |
528 | - foreach(array('delete') as $button) |
|
528 | + foreach (array('delete') as $button) |
|
529 | 529 | { |
530 | - if(isset($content['nm']['rows'][$button])) |
|
530 | + if (isset($content['nm']['rows'][$button])) |
|
531 | 531 | { |
532 | 532 | list($id) = @each($content['nm']['rows'][$button]); |
533 | 533 | $content['nm']['action'] = $button; |
@@ -542,39 +542,39 @@ discard block |
||
542 | 542 | else |
543 | 543 | { |
544 | 544 | // Action has an additional action - add / delete, etc. Buttons named <multi-action>_action[action_name] |
545 | - if(in_array($content['nm']['action'], array('owner'))) |
|
545 | + if (in_array($content['nm']['action'], array('owner'))) |
|
546 | 546 | { |
547 | 547 | $action = $content['nm']['action']; |
548 | 548 | if ($content[$action.'_popup']) |
549 | 549 | { |
550 | - $content = array_merge($content,$content[$action.'_popup']); |
|
550 | + $content = array_merge($content, $content[$action.'_popup']); |
|
551 | 551 | } |
552 | - $content['nm']['action'] .= '_' . key($content[$action . '_action']); |
|
552 | + $content['nm']['action'] .= '_'.key($content[$action.'_action']); |
|
553 | 553 | |
554 | - if(is_array($content[$action])) |
|
554 | + if (is_array($content[$action])) |
|
555 | 555 | { |
556 | - $content[$action] = implode(',',$content[$action]); |
|
556 | + $content[$action] = implode(',', $content[$action]); |
|
557 | 557 | } |
558 | - $content['nm']['action'] .= '_' . $content[$action]; |
|
558 | + $content['nm']['action'] .= '_'.$content[$action]; |
|
559 | 559 | } |
560 | 560 | $success = $failed = 0; |
561 | 561 | $action_msg = null; |
562 | - if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'], |
|
563 | - $success,$failed,$action_msg,$content['nm'])) |
|
562 | + if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'], |
|
563 | + $success, $failed, $action_msg, $content['nm'])) |
|
564 | 564 | { |
565 | - $msg .= lang('%1 category(s) %2',$success,$action_msg); |
|
565 | + $msg .= lang('%1 category(s) %2', $success, $action_msg); |
|
566 | 566 | } |
567 | - elseif(empty($msg)) |
|
567 | + elseif (empty($msg)) |
|
568 | 568 | { |
569 | - $msg .= lang('%1 category(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
569 | + $msg .= lang('%1 category(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
570 | 570 | } |
571 | 571 | Framework::refresh_opener($msg, $this->appname); |
572 | 572 | $msg = ''; |
573 | 573 | } |
574 | 574 | } |
575 | 575 | $content['msg'] = $msg; |
576 | - $content['nm']['add_link']= Framework::link('/index.php','menuaction='.$this->add_link . '&cat_id=&appname='.$appname); |
|
577 | - $content['edit_link']= $this->edit_link.'&appname='.$appname; |
|
576 | + $content['nm']['add_link'] = Framework::link('/index.php', 'menuaction='.$this->add_link.'&cat_id=&appname='.$appname); |
|
577 | + $content['edit_link'] = $this->edit_link.'&appname='.$appname; |
|
578 | 578 | $content['owner'] = ''; |
579 | 579 | |
580 | 580 | $sel_options['appname'] = $this->get_app_list(); |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | ); |
589 | 589 | |
590 | 590 | $sel_options['owner'][0] = lang('All users'); |
591 | - foreach($GLOBALS['egw']->accounts->search(array('type' => 'groups')) as $acc) |
|
591 | + foreach ($GLOBALS['egw']->accounts->search(array('type' => 'groups')) as $acc) |
|
592 | 592 | { |
593 | 593 | if ($acc['account_type'] == 'g') |
594 | 594 | { |
@@ -597,12 +597,12 @@ discard block |
||
597 | 597 | } |
598 | 598 | |
599 | 599 | $readonlys['add'] = !self::$acl_add; |
600 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
600 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
601 | 601 | { |
602 | 602 | $readonlys['nm']['rows']['owner'] = true; |
603 | 603 | $readonlys['nm']['col_filter']['owner'] = true; |
604 | 604 | } |
605 | - if($appname == Categories::GLOBAL_APPNAME) { |
|
605 | + if ($appname == Categories::GLOBAL_APPNAME) { |
|
606 | 606 | $sel_options['app'] = array(''=>''); |
607 | 607 | $readonlys['nm']['rows']['app'] = true; |
608 | 608 | } |
@@ -615,12 +615,12 @@ discard block |
||
615 | 615 | // Category styles |
616 | 616 | Categories::css($appname); |
617 | 617 | |
618 | - $tmpl->exec($this->list_link,$content,$sel_options,$readonlys,array( |
|
618 | + $tmpl->exec($this->list_link, $content, $sel_options, $readonlys, array( |
|
619 | 619 | 'nm' => $content['nm'], |
620 | 620 | )); |
621 | 621 | } |
622 | 622 | |
623 | - protected function get_actions($appname=Api\Categories::GLOBAL_APPNAME) { |
|
623 | + protected function get_actions($appname = Api\Categories::GLOBAL_APPNAME) { |
|
624 | 624 | |
625 | 625 | $actions = array( |
626 | 626 | 'open' => array( // does edit if allowed, otherwise view |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | 'allowOnMultiple' => false, |
630 | 630 | 'url' => 'menuaction='.$this->edit_link.'&cat_id=$id&appname='.$appname, |
631 | 631 | 'popup' => '600x380', |
632 | - 'group' => $group=1, |
|
632 | + 'group' => $group = 1, |
|
633 | 633 | ), |
634 | 634 | 'add' => array( |
635 | 635 | 'caption' => 'Add', |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | ), |
665 | 665 | ); |
666 | 666 | |
667 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
667 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
668 | 668 | { |
669 | 669 | unset($actions['owner']); |
670 | 670 | } |
@@ -690,14 +690,14 @@ discard block |
||
690 | 690 | $success = $failed = 0; |
691 | 691 | if ($use_all) |
692 | 692 | { |
693 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
694 | - $query['num_rows'] = -1; // all |
|
693 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
694 | + $query['num_rows'] = -1; // all |
|
695 | 695 | $result = $readonlys = array(); |
696 | - $this->get_rows($query,$result,$readonlys); |
|
696 | + $this->get_rows($query, $result, $readonlys); |
|
697 | 697 | $checked = array(); |
698 | - foreach($result as $key => $info) |
|
698 | + foreach ($result as $key => $info) |
|
699 | 699 | { |
700 | - if(is_numeric($key)) |
|
700 | + if (is_numeric($key)) |
|
701 | 701 | { |
702 | 702 | $checked[] = $info['id']; |
703 | 703 | } |
@@ -705,19 +705,19 @@ discard block |
||
705 | 705 | } |
706 | 706 | $owner = $query['col_filter']['owner'] ? $query['col_filter']['owner'] : $query['filter']; |
707 | 707 | $app = $query['col_filter']['app'] ? $query['col_filter']['app'] : $query['appname']; |
708 | - $cats = new Categories($owner,$app); |
|
708 | + $cats = new Categories($owner, $app); |
|
709 | 709 | |
710 | 710 | list($action, $settings) = explode('_', $_action, 2); |
711 | 711 | |
712 | - switch($action) |
|
712 | + switch ($action) |
|
713 | 713 | { |
714 | 714 | case 'delete': |
715 | 715 | $action_msg = lang('deleted'); |
716 | - foreach($checked as $id) |
|
716 | + foreach ($checked as $id) |
|
717 | 717 | { |
718 | - if($cats->check_perms(Acl::DELETE, $id, (boolean)$GLOBALS['egw_info']['user']['apps']['admin'])) |
|
718 | + if ($cats->check_perms(Acl::DELETE, $id, (boolean)$GLOBALS['egw_info']['user']['apps']['admin'])) |
|
719 | 719 | { |
720 | - $cats->delete($id,$settings == 'sub',$settings != 'sub'); |
|
720 | + $cats->delete($id, $settings == 'sub', $settings != 'sub'); |
|
721 | 721 | $success++; |
722 | 722 | } |
723 | 723 | else |
@@ -731,20 +731,19 @@ discard block |
||
731 | 731 | list($add_remove, $ids_csv) = explode('_', $settings, 2); |
732 | 732 | $ids = explode(',', $ids_csv); |
733 | 733 | // Adding 'All users' removes all the others |
734 | - if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT); |
|
734 | + if ($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT, $ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT); |
|
735 | 735 | |
736 | - foreach($checked as $id) |
|
736 | + foreach ($checked as $id) |
|
737 | 737 | { |
738 | 738 | if (!$data = $cats->read($id)) continue; |
739 | - $data['owner'] = explode(',',$data['owner']); |
|
740 | - if(array_search(Categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0) |
|
739 | + $data['owner'] = explode(',', $data['owner']); |
|
740 | + if (array_search(Categories::GLOBAL_ACCOUNT, $data['owner']) !== false || $data['owner'][0] > 0) |
|
741 | 741 | { |
742 | 742 | $data['owner'] = array(); |
743 | 743 | } |
744 | 744 | $data['owner'] = $add_remove == 'add' ? |
745 | - $ids == array(Categories::GLOBAL_ACCOUNT) ? $ids : array_merge($data['owner'],$ids) : |
|
746 | - array_diff($data['owner'],$ids); |
|
747 | - $data['owner'] = implode(',',array_unique($data['owner'])); |
|
745 | + $ids == array(Categories::GLOBAL_ACCOUNT) ? $ids : array_merge($data['owner'], $ids) : array_diff($data['owner'], $ids); |
|
746 | + $data['owner'] = implode(',', array_unique($data['owner'])); |
|
748 | 747 | |
749 | 748 | if ($cats->edit($data)) |
750 | 749 | { |
@@ -775,7 +774,7 @@ discard block |
||
775 | 774 | continue; |
776 | 775 | } |
777 | 776 | // Skip apps that don't show in the app bar, they [usually] don't have Categories |
778 | - if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue; |
|
777 | + if ($data['status'] > 1 || in_array($app, array('home', 'admin', 'felamimail', 'sitemgr', 'sitemgr-link'))) continue; |
|
779 | 778 | if ($GLOBALS['egw_info']['user']['apps'][$app]) |
780 | 779 | { |
781 | 780 | $apps[$app] = $data['title'] ? $data['title'] : lang($app); |
@@ -443,10 +443,10 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @static |
445 | 445 | * @param array|string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!) |
446 | - * @param boolean|string|array $only_keys =true True returns only keys, False returns all cols. or |
|
446 | + * @param boolean $only_keys =true True returns only keys, False returns all cols. or |
|
447 | 447 | * comma seperated list or array of columns to return |
448 | 448 | * @param string $order_by ='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY) |
449 | - * @param string|array $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num" |
|
449 | + * @param string $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num" |
|
450 | 450 | * @param string $wildcard ='' appended befor and after each criteria |
451 | 451 | * @param boolean $empty =false False=empty criteria are ignored in query, True=empty have to be empty in row |
452 | 452 | * @param string $op ='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | * |
697 | 697 | * @param string|boolean|int $value |
698 | 698 | * @param boolean $default =null |
699 | - * @return boolean |
|
699 | + * @return boolean|null |
|
700 | 700 | * @throws Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!',$value),998); |
701 | 701 | */ |
702 | 702 | static function parse_boolean($value,$default=null) |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | * Read data of a remote instance |
926 | 926 | * |
927 | 927 | * @param array|int $keys |
928 | - * @return array |
|
928 | + * @return string |
|
929 | 929 | */ |
930 | 930 | static function read_remote($keys) |
931 | 931 | { |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | * Check if string is a md5 hash (32 chars of 0-9 or a-f) |
1006 | 1006 | * |
1007 | 1007 | * @param string $str |
1008 | - * @return boolean |
|
1008 | + * @return integer |
|
1009 | 1009 | */ |
1010 | 1010 | static function is_md5($str) |
1011 | 1011 | { |
@@ -239,11 +239,11 @@ |
||
239 | 239 | unset($postdata[$name]); |
240 | 240 | } |
241 | 241 | $opts = array('http' => |
242 | - array( |
|
243 | - 'method' => 'POST', |
|
244 | - 'header' => 'Content-type: application/x-www-form-urlencoded', |
|
245 | - 'content' => http_build_query($postdata), |
|
246 | - ) |
|
242 | + array( |
|
243 | + 'method' => 'POST', |
|
244 | + 'header' => 'Content-type: application/x-www-form-urlencoded', |
|
245 | + 'content' => http_build_query($postdata), |
|
246 | + ) |
|
247 | 247 | ); |
248 | 248 | $url = $remote['remote_url'].'/admin/remote.php?domain='.urlencode($remote['remote_domain']).'&secret='.urlencode($secret); |
249 | 249 | //echo "sending command to $url\n"; _debug_array($opts); |
@@ -183,7 +183,10 @@ discard block |
||
183 | 183 | { |
184 | 184 | $ret = $this->remote_exec($dry_run); |
185 | 185 | } |
186 | - if (is_null($this->status)) $this->status = admin_cmd::successful; |
|
186 | + if (is_null($this->status)) |
|
187 | + { |
|
188 | + $this->status = admin_cmd::successful; |
|
189 | + } |
|
187 | 190 | } |
188 | 191 | catch (Exception $e) { |
189 | 192 | $this->error = $e->getMessage(); |
@@ -277,7 +280,10 @@ discard block |
||
277 | 280 | */ |
278 | 281 | function delete() |
279 | 282 | { |
280 | - if ($this->status != admin_cmd::scheduled) return false; |
|
283 | + if ($this->status != admin_cmd::scheduled) |
|
284 | + { |
|
285 | + return false; |
|
286 | + } |
|
281 | 287 | |
282 | 288 | $this->status = admin_cmd::deleted; |
283 | 289 | |
@@ -303,7 +309,10 @@ discard block |
||
303 | 309 | { |
304 | 310 | $this->modified = time(); |
305 | 311 | $this->modifier = $set_modifier ? $GLOBALS['egw_info']['user']['account_id'] : 0; |
306 | - if ($set_modifier) $this->modifier_email = admin_cmd::user_email(); |
|
312 | + if ($set_modifier) |
|
313 | + { |
|
314 | + $this->modifier_email = admin_cmd::user_email(); |
|
315 | + } |
|
307 | 316 | } |
308 | 317 | if (version_compare(PHP_VERSION,'5.1.2','>')) |
309 | 318 | { |
@@ -411,10 +420,13 @@ discard block |
||
411 | 420 | } |
412 | 421 | $cmd = new $class($data); |
413 | 422 | |
414 | - if ($cmd instanceof admin_cmd) // dont allow others classes to be executed that way! |
|
423 | + if ($cmd instanceof admin_cmd) |
|
424 | + { |
|
425 | + // dont allow others classes to be executed that way! |
|
415 | 426 | { |
416 | 427 | return $cmd; |
417 | 428 | } |
429 | + } |
|
418 | 430 | throw new Api\Exception\WrongParameter(lang('%1 is no command!',$class),0); |
419 | 431 | } |
420 | 432 | |
@@ -564,7 +576,10 @@ discard block |
||
564 | 576 | } |
565 | 577 | } |
566 | 578 | unset($vars['data']); |
567 | - if ($this->data) $vars = array_merge($this->data,$vars); |
|
579 | + if ($this->data) |
|
580 | + { |
|
581 | + $vars = array_merge($this->data,$vars); |
|
582 | + } |
|
568 | 583 | |
569 | 584 | return $vars; |
570 | 585 | } |
@@ -583,10 +598,13 @@ discard block |
||
583 | 598 | admin_cmd::_instanciate_acl($this->creator); |
584 | 599 | // todo: check only if and with $this->creator |
585 | 600 | if (!admin_cmd::$acl->check('run',1,'admin') && // creator is no longer admin |
586 | - $extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin')) // creator is explicitly forbidden to do something |
|
601 | + $extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin')) |
|
602 | + { |
|
603 | + // creator is explicitly forbidden to do something |
|
587 | 604 | { |
588 | 605 | throw new Api\Exception\NoPermission\Admin(); |
589 | 606 | } |
607 | + } |
|
590 | 608 | } |
591 | 609 | } |
592 | 610 | |
@@ -603,11 +621,14 @@ discard block |
||
603 | 621 | { |
604 | 622 | if (!isset($GLOBALS['egw_info']['apps'][$name])) |
605 | 623 | { |
606 | - foreach($GLOBALS['egw_info']['apps'] as $app => $data) // check against title and localised name |
|
624 | + foreach($GLOBALS['egw_info']['apps'] as $app => $data) |
|
625 | + { |
|
626 | + // check against title and localised name |
|
607 | 627 | { |
608 | 628 | if (!strcasecmp($name,$data['title']) || !strcasecmp($name,lang($app))) |
609 | 629 | { |
610 | 630 | $apps[$key] = $name = $app; |
631 | + } |
|
611 | 632 | break; |
612 | 633 | } |
613 | 634 | } |
@@ -642,7 +663,11 @@ discard block |
||
642 | 663 | { |
643 | 664 | throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15); |
644 | 665 | } |
645 | - if ($type == 2 && $id > 0) $id = -$id; // groups use negative id's internally, fix it, if user given the wrong sign |
|
666 | + if ($type == 2 && $id > 0) |
|
667 | + { |
|
668 | + $id = -$id; |
|
669 | + } |
|
670 | + // groups use negative id's internally, fix it, if user given the wrong sign |
|
646 | 671 | |
647 | 672 | return $id; |
648 | 673 | } |
@@ -658,7 +683,10 @@ discard block |
||
658 | 683 | */ |
659 | 684 | static function parse_accounts($accounts,$allow_only_user=null) |
660 | 685 | { |
661 | - if (!$accounts) return null; |
|
686 | + if (!$accounts) |
|
687 | + { |
|
688 | + return null; |
|
689 | + } |
|
662 | 690 | |
663 | 691 | $ids = array(); |
664 | 692 | foreach(is_array($accounts) ? $accounts : explode(',',$accounts) as $account) |
@@ -677,9 +705,12 @@ discard block |
||
677 | 705 | */ |
678 | 706 | static function parse_date($date) |
679 | 707 | { |
680 | - if (!is_numeric($date)) // we allow to input a timestamp |
|
708 | + if (!is_numeric($date)) |
|
709 | + { |
|
710 | + // we allow to input a timestamp |
|
681 | 711 | { |
682 | 712 | $datein = $date; |
713 | + } |
|
683 | 714 | // convert german DD.MM.YYYY format into ISO YYYY-MM-DD format |
684 | 715 | $date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/','\3-\2-\1',$date); |
685 | 716 | |
@@ -837,10 +868,13 @@ discard block |
||
837 | 868 | return false; // no schduled command, no need to setup the job |
838 | 869 | } |
839 | 870 | $next = $jobs[0]; |
840 | - if (($time = $next['scheduled']) < time()) // should run immediatly |
|
871 | + if (($time = $next['scheduled']) < time()) |
|
872 | + { |
|
873 | + // should run immediatly |
|
841 | 874 | { |
842 | 875 | return admin_cmd::run_queued_jobs(); |
843 | 876 | } |
877 | + } |
|
844 | 878 | $async = new Api\Asyncservice(); |
845 | 879 | |
846 | 880 | // we cant use this class as callback, as it's abstract and ExecMethod used by the async service instanciated the class! |
@@ -944,10 +978,13 @@ discard block |
||
944 | 978 | { |
945 | 979 | admin_cmd::_instanciate_remote(); |
946 | 980 | |
947 | - if ($data['install_id'] && $data['config_passwd']) // calculate hash |
|
981 | + if ($data['install_id'] && $data['config_passwd']) |
|
982 | + { |
|
983 | + // calculate hash |
|
948 | 984 | { |
949 | 985 | $data['remote_hash'] = self::remote_hash($data['install_id'],$data['config_passwd']); |
950 | 986 | } |
987 | + } |
|
951 | 988 | elseif (!$data['remote_hash'] && !($data['install_id'] && $data['config_passwd'])) |
952 | 989 | { |
953 | 990 | throw new Api\Exception\WrongUserinput(lang('Either Install ID AND Api\Config password needed OR the remote hash!')); |
@@ -981,7 +1018,10 @@ discard block |
||
981 | 1018 | { |
982 | 1019 | throw new Api\Exception\WrongParameter(empty($config_passwd)?'Empty Api\Config password':'install_id no md5 hash'); |
983 | 1020 | } |
984 | - if (!self::is_md5($config_passwd)) $config_passwd = md5($config_passwd); |
|
1021 | + if (!self::is_md5($config_passwd)) |
|
1022 | + { |
|
1023 | + $config_passwd = md5($config_passwd); |
|
1024 | + } |
|
985 | 1025 | |
986 | 1026 | return md5($config_passwd.$install_id); |
987 | 1027 | } |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | const successful = 2; |
24 | 24 | const failed = 3; |
25 | 25 | const pending = 4; |
26 | - const queued = 5; // command waits to be fetched from remote |
|
26 | + const queued = 5; // command waits to be fetched from remote |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Status which stil need passwords available |
30 | 30 | * |
31 | 31 | * @var array |
32 | 32 | */ |
33 | - static $require_pw_stati = array(self::scheduled,self::pending,self::queued); |
|
33 | + static $require_pw_stati = array(self::scheduled, self::pending, self::queued); |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * The status of the command, one of either scheduled, successful, failed or deleted |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @return string success message |
108 | 108 | * @throws Exception() |
109 | 109 | */ |
110 | - protected abstract function exec($check_only=false); |
|
110 | + protected abstract function exec($check_only = false); |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * Return a title / string representation for a given command, eg. to display it |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | $this->type = get_class($this); |
134 | 134 | |
135 | - foreach($data as $name => $value) |
|
135 | + foreach ($data as $name => $value) |
|
136 | 136 | { |
137 | 137 | $this->$name = $name == 'data' && !is_array($value) ? json_php_unserialize($value) : $value; |
138 | 138 | } |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | * @return mixed return value of the command |
152 | 152 | * @throws Exceptions on error |
153 | 153 | */ |
154 | - function run($time=null,$set_modifier=true,$skip_checks=false,$dry_run=false) |
|
154 | + function run($time = null, $set_modifier = true, $skip_checks = false, $dry_run = false) |
|
155 | 155 | { |
156 | 156 | if (!is_null($time)) |
157 | 157 | { |
158 | 158 | $this->scheduled = $time; |
159 | 159 | $this->status = admin_cmd::scheduled; |
160 | - $ret = lang('Command scheduled to run at %1',date('Y-m-d H:i',$time)); |
|
160 | + $ret = lang('Command scheduled to run at %1', date('Y-m-d H:i', $time)); |
|
161 | 161 | // running the checks of the arguments for local commands, if not explicitly requested to not run them |
162 | 162 | if (!$this->remote_id && !$skip_checks) |
163 | 163 | { |
@@ -220,21 +220,21 @@ discard block |
||
220 | 220 | { |
221 | 221 | if (!($remote = $this->read_remote($this->remote_id))) |
222 | 222 | { |
223 | - throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!',$this->remote_id),997); |
|
223 | + throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!', $this->remote_id), 997); |
|
224 | 224 | } |
225 | 225 | if (!$this->uid) |
226 | 226 | { |
227 | - $this->save(); // to get the uid |
|
227 | + $this->save(); // to get the uid |
|
228 | 228 | } |
229 | 229 | $secret = md5($this->uid.$remote['remote_hash']); |
230 | 230 | |
231 | 231 | $postdata = $this->as_array(); |
232 | 232 | if (is_object($GLOBALS['egw']->translation)) |
233 | 233 | { |
234 | - $postdata = Api\Translation::convert($postdata,Api\Translation::charset(),'utf-8'); |
|
234 | + $postdata = Api\Translation::convert($postdata, Api\Translation::charset(), 'utf-8'); |
|
235 | 235 | } |
236 | 236 | // dont send the id's which have no meaning on the remote install |
237 | - foreach(array('id','creator','modifier','requested','remote_id') as $name) |
|
237 | + foreach (array('id', 'creator', 'modifier', 'requested', 'remote_id') as $name) |
|
238 | 238 | { |
239 | 239 | unset($postdata[$name]); |
240 | 240 | } |
@@ -260,12 +260,12 @@ discard block |
||
260 | 260 | } |
261 | 261 | if (is_object($GLOBALS['egw']->translation)) |
262 | 262 | { |
263 | - $message = Api\Translation::convert($message,'utf-8'); |
|
263 | + $message = Api\Translation::convert($message, 'utf-8'); |
|
264 | 264 | } |
265 | 265 | $matches = null; |
266 | - if (is_string($message) && preg_match('/^([0-9]+) (.*)$/',$message,$matches)) |
|
266 | + if (is_string($message) && preg_match('/^([0-9]+) (.*)$/', $message, $matches)) |
|
267 | 267 | { |
268 | - throw new Api\Exception($matches[2],(int)$matches[1]); |
|
268 | + throw new Api\Exception($matches[2], (int)$matches[1]); |
|
269 | 269 | } |
270 | 270 | return $message; |
271 | 271 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @param boolean $set_modifier =true set the current user as modifier or 0 (= run by the system) |
291 | 291 | * @return boolean true on success, false otherwise |
292 | 292 | */ |
293 | - function save($set_modifier=true) |
|
293 | + function save($set_modifier = true) |
|
294 | 294 | { |
295 | 295 | admin_cmd::_instanciate_sql(); |
296 | 296 | |
@@ -305,13 +305,13 @@ discard block |
||
305 | 305 | $this->modifier = $set_modifier ? $GLOBALS['egw_info']['user']['account_id'] : 0; |
306 | 306 | if ($set_modifier) $this->modifier_email = admin_cmd::user_email(); |
307 | 307 | } |
308 | - if (version_compare(PHP_VERSION,'5.1.2','>')) |
|
308 | + if (version_compare(PHP_VERSION, '5.1.2', '>')) |
|
309 | 309 | { |
310 | - $vars = get_object_vars($this); // does not work in php5.1.2 due a bug |
|
310 | + $vars = get_object_vars($this); // does not work in php5.1.2 due a bug |
|
311 | 311 | } |
312 | 312 | else |
313 | 313 | { |
314 | - foreach(array_keys(get_class_vars(__CLASS__)) as $name) |
|
314 | + foreach (array_keys(get_class_vars(__CLASS__)) as $name) |
|
315 | 315 | { |
316 | 316 | $vars[$name] = $this->$name; |
317 | 317 | } |
@@ -351,13 +351,13 @@ discard block |
||
351 | 351 | * @param boolean $return_serialized =true true: return json serialized string, false: return array |
352 | 352 | * @return string|array see $return_serialized |
353 | 353 | */ |
354 | - static function mask_passwords($data, $return_serialized=true) |
|
354 | + static function mask_passwords($data, $return_serialized = true) |
|
355 | 355 | { |
356 | 356 | if (!is_array($data)) |
357 | 357 | { |
358 | 358 | $data = json_php_unserialize($data); |
359 | 359 | } |
360 | - foreach($data as $key => &$value) |
|
360 | + foreach ($data as $key => &$value) |
|
361 | 361 | { |
362 | 362 | if (is_array($value)) |
363 | 363 | { |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | } |
408 | 408 | if (!class_exists($class = $data['type']) || $class == 'admin_cmd') |
409 | 409 | { |
410 | - throw new Api\Exception\WrongParameter(lang('Unknown command %1!',$class),0); |
|
410 | + throw new Api\Exception\WrongParameter(lang('Unknown command %1!', $class), 0); |
|
411 | 411 | } |
412 | 412 | $cmd = new $class($data); |
413 | 413 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | { |
416 | 416 | return $cmd; |
417 | 417 | } |
418 | - throw new Api\Exception\WrongParameter(lang('%1 is no command!',$class),0); |
|
418 | + throw new Api\Exception\WrongParameter(lang('%1 is no command!', $class), 0); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * @param array $readonlys |
428 | 428 | * @return int |
429 | 429 | */ |
430 | - static function get_rows($query,&$rows,$readonlys) |
|
430 | + static function get_rows($query, &$rows, $readonlys) |
|
431 | 431 | { |
432 | 432 | admin_cmd::_instanciate_sql(); |
433 | 433 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | { |
436 | 436 | $query['col_filter']['remote_id'] = null; |
437 | 437 | } |
438 | - return admin_cmd::$sql->get_rows($query,$rows,$readonlys); |
|
438 | + return admin_cmd::$sql->get_rows($query, $rows, $readonlys); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -454,11 +454,11 @@ discard block |
||
454 | 454 | * @param array $filter =null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards |
455 | 455 | * @return array |
456 | 456 | */ |
457 | - static function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null) |
|
457 | + static function &search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter = null) |
|
458 | 458 | { |
459 | 459 | admin_cmd::_instanciate_sql(); |
460 | 460 | |
461 | - return admin_cmd::$sql->search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter); |
|
461 | + return admin_cmd::$sql->search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | { |
471 | 471 | if (is_null(admin_cmd::$sql)) |
472 | 472 | { |
473 | - admin_cmd::$sql = new Api\Storage\Base('admin','egw_admin_queue',null,'cmd_'); |
|
473 | + admin_cmd::$sql = new Api\Storage\Base('admin', 'egw_admin_queue', null, 'cmd_'); |
|
474 | 474 | } |
475 | 475 | } |
476 | 476 | |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | { |
484 | 484 | if (is_null(admin_cmd::$remote)) |
485 | 485 | { |
486 | - admin_cmd::$remote = new Api\Storage\Base('admin','egw_admin_remote'); |
|
486 | + admin_cmd::$remote = new Api\Storage\Base('admin', 'egw_admin_remote'); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
@@ -495,11 +495,11 @@ discard block |
||
495 | 495 | */ |
496 | 496 | function __get($property) |
497 | 497 | { |
498 | - if (property_exists('admin_cmd',$property)) |
|
498 | + if (property_exists('admin_cmd', $property)) |
|
499 | 499 | { |
500 | - return $this->$property; // making all (non static) class vars readonly available |
|
500 | + return $this->$property; // making all (non static) class vars readonly available |
|
501 | 501 | } |
502 | - switch($property) |
|
502 | + switch ($property) |
|
503 | 503 | { |
504 | 504 | case 'accounts': |
505 | 505 | self::_instanciate_accounts(); |
@@ -518,9 +518,9 @@ discard block |
||
518 | 518 | */ |
519 | 519 | function __isset($property) |
520 | 520 | { |
521 | - if (property_exists('admin_cmd',$property)) |
|
521 | + if (property_exists('admin_cmd', $property)) |
|
522 | 522 | { |
523 | - return isset($this->$property); // making all (non static) class vars readonly available |
|
523 | + return isset($this->$property); // making all (non static) class vars readonly available |
|
524 | 524 | } |
525 | 525 | return isset($this->data[$property]); |
526 | 526 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | * @param mixed $value |
533 | 533 | * @return mixed |
534 | 534 | */ |
535 | - function __set($property,$value) |
|
535 | + function __set($property, $value) |
|
536 | 536 | { |
537 | 537 | $this->data[$property] = $value; |
538 | 538 | } |
@@ -554,19 +554,19 @@ discard block |
||
554 | 554 | */ |
555 | 555 | function as_array() |
556 | 556 | { |
557 | - if (version_compare(PHP_VERSION,'5.1.2','>')) |
|
557 | + if (version_compare(PHP_VERSION, '5.1.2', '>')) |
|
558 | 558 | { |
559 | - $vars = get_object_vars($this); // does not work in php5.1.2 due a bug |
|
559 | + $vars = get_object_vars($this); // does not work in php5.1.2 due a bug |
|
560 | 560 | } |
561 | 561 | else |
562 | 562 | { |
563 | - foreach(array_keys(get_class_vars(__CLASS__)) as $name) |
|
563 | + foreach (array_keys(get_class_vars(__CLASS__)) as $name) |
|
564 | 564 | { |
565 | 565 | $vars[$name] = $this->$name; |
566 | 566 | } |
567 | 567 | } |
568 | 568 | unset($vars['data']); |
569 | - if ($this->data) $vars = array_merge($this->data,$vars); |
|
569 | + if ($this->data) $vars = array_merge($this->data, $vars); |
|
570 | 570 | |
571 | 571 | return $vars; |
572 | 572 | } |
@@ -578,14 +578,14 @@ discard block |
||
578 | 578 | * @param int $extra_deny =null further admin rights to check, eg. 16 = deny edit Api\Accounts |
579 | 579 | * @throws Api\Exception\NoPermission\Admin |
580 | 580 | */ |
581 | - protected function _check_admin($extra_acl=null,$extra_deny=null) |
|
581 | + protected function _check_admin($extra_acl = null, $extra_deny = null) |
|
582 | 582 | { |
583 | 583 | if ($this->creator) |
584 | 584 | { |
585 | 585 | admin_cmd::_instanciate_acl($this->creator); |
586 | 586 | // todo: check only if and with $this->creator |
587 | - if (!admin_cmd::$acl->check('run',1,'admin') && // creator is no longer admin |
|
588 | - $extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin')) // creator is explicitly forbidden to do something |
|
587 | + if (!admin_cmd::$acl->check('run', 1, 'admin') && // creator is no longer admin |
|
588 | + $extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl, $extra_deny, 'admin')) // creator is explicitly forbidden to do something |
|
589 | 589 | { |
590 | 590 | throw new Api\Exception\NoPermission\Admin(); |
591 | 591 | } |
@@ -601,13 +601,13 @@ discard block |
||
601 | 601 | */ |
602 | 602 | static function parse_apps(array $apps) |
603 | 603 | { |
604 | - foreach($apps as $key => $name) |
|
604 | + foreach ($apps as $key => $name) |
|
605 | 605 | { |
606 | 606 | if (!isset($GLOBALS['egw_info']['apps'][$name])) |
607 | 607 | { |
608 | - foreach($GLOBALS['egw_info']['apps'] as $app => $data) // check against title and localised name |
|
608 | + foreach ($GLOBALS['egw_info']['apps'] as $app => $data) // check against title and localised name |
|
609 | 609 | { |
610 | - if (!strcasecmp($name,$data['title']) || !strcasecmp($name,lang($app))) |
|
610 | + if (!strcasecmp($name, $data['title']) || !strcasecmp($name, lang($app))) |
|
611 | 611 | { |
612 | 612 | $apps[$key] = $name = $app; |
613 | 613 | break; |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | } |
617 | 617 | if (!isset($GLOBALS['egw_info']['apps'][$name])) |
618 | 618 | { |
619 | - throw new Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8); |
|
619 | + throw new Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!", $name), 8); |
|
620 | 620 | } |
621 | 621 | } |
622 | 622 | return $apps; |
@@ -631,20 +631,20 @@ discard block |
||
631 | 631 | * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account),15); |
632 | 632 | * @throws Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15); |
633 | 633 | */ |
634 | - static function parse_account($account,$allow_only_user=null) |
|
634 | + static function parse_account($account, $allow_only_user = null) |
|
635 | 635 | { |
636 | 636 | admin_cmd::_instanciate_accounts(); |
637 | 637 | |
638 | 638 | if (!($type = admin_cmd::$accounts->exists($account)) || |
639 | - !is_numeric($id=$account) && !($id = admin_cmd::$accounts->name2id($account))) |
|
639 | + !is_numeric($id = $account) && !($id = admin_cmd::$accounts->name2id($account))) |
|
640 | 640 | { |
641 | - throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account),15); |
|
641 | + throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!", $account), 15); |
|
642 | 642 | } |
643 | 643 | if (!is_null($allow_only_user) && $allow_only_user !== ($type == 1)) |
644 | 644 | { |
645 | - throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15); |
|
645 | + throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!", $account, $allow_only_user ?lang('user') : lang('group')), 15); |
|
646 | 646 | } |
647 | - if ($type == 2 && $id > 0) $id = -$id; // groups use negative id's internally, fix it, if user given the wrong sign |
|
647 | + if ($type == 2 && $id > 0) $id = -$id; // groups use negative id's internally, fix it, if user given the wrong sign |
|
648 | 648 | |
649 | 649 | return $id; |
650 | 650 | } |
@@ -658,14 +658,14 @@ discard block |
||
658 | 658 | * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account),15); |
659 | 659 | * @throws Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only?lang('user'):lang('group')),15); |
660 | 660 | */ |
661 | - static function parse_accounts($accounts,$allow_only_user=null) |
|
661 | + static function parse_accounts($accounts, $allow_only_user = null) |
|
662 | 662 | { |
663 | 663 | if (!$accounts) return null; |
664 | 664 | |
665 | 665 | $ids = array(); |
666 | - foreach(is_array($accounts) ? $accounts : explode(',',$accounts) as $account) |
|
666 | + foreach (is_array($accounts) ? $accounts : explode(',', $accounts) as $account) |
|
667 | 667 | { |
668 | - $ids[] = admin_cmd::parse_account($account,$allow_only_user); |
|
668 | + $ids[] = admin_cmd::parse_account($account, $allow_only_user); |
|
669 | 669 | } |
670 | 670 | return $ids; |
671 | 671 | } |
@@ -683,11 +683,11 @@ discard block |
||
683 | 683 | { |
684 | 684 | $datein = $date; |
685 | 685 | // convert german DD.MM.YYYY format into ISO YYYY-MM-DD format |
686 | - $date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/','\3-\2-\1',$date); |
|
686 | + $date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/', '\3-\2-\1', $date); |
|
687 | 687 | |
688 | - if (($date = strtotime($date)) === false) |
|
688 | + if (($date = strtotime($date)) === false) |
|
689 | 689 | { |
690 | - throw new Api\Exception\WrongUserinput(lang('Invalid formated date "%1"!',$datein),6); |
|
690 | + throw new Api\Exception\WrongUserinput(lang('Invalid formated date "%1"!', $datein), 6); |
|
691 | 691 | } |
692 | 692 | } |
693 | 693 | return (int)$date; |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | * @return boolean |
702 | 702 | * @throws Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!',$value),998); |
703 | 703 | */ |
704 | - static function parse_boolean($value,$default=null) |
|
704 | + static function parse_boolean($value, $default = null) |
|
705 | 705 | { |
706 | 706 | if (is_bool($value) || is_int($value)) |
707 | 707 | { |
@@ -711,15 +711,15 @@ discard block |
||
711 | 711 | { |
712 | 712 | return $default; |
713 | 713 | } |
714 | - if (in_array($value,array('1','yes','true',lang('yes'),lang('true')))) |
|
714 | + if (in_array($value, array('1', 'yes', 'true', lang('yes'), lang('true')))) |
|
715 | 715 | { |
716 | 716 | return true; |
717 | 717 | } |
718 | - if (in_array($value,array('0','no','false',lang('no'),lang('false')))) |
|
718 | + if (in_array($value, array('0', 'no', 'false', lang('no'), lang('false')))) |
|
719 | 719 | { |
720 | 720 | return false; |
721 | 721 | } |
722 | - throw new Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!',$value),998); |
|
722 | + throw new Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!', $value), 998); |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | /** |
@@ -737,9 +737,9 @@ discard block |
||
737 | 737 | 'remote_id' => $id_or_name, |
738 | 738 | 'remote_name' => $id_or_name, |
739 | 739 | 'remote_domain' => $id_or_name, |
740 | - ),true,'','','',false,'OR')) || count($remotes) != 1) |
|
740 | + ), true, '', '', '', false, 'OR')) || count($remotes) != 1) |
|
741 | 741 | { |
742 | - throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!',$id_or_name),997); |
|
742 | + throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!', $id_or_name), 997); |
|
743 | 743 | } |
744 | 744 | return $remotes[0]['remote_id']; |
745 | 745 | } |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | { |
757 | 757 | if (!is_object($GLOBALS['egw']->accounts)) |
758 | 758 | { |
759 | - throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated','accounts'),999); |
|
759 | + throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated', 'accounts'), 999); |
|
760 | 760 | } |
761 | 761 | admin_cmd::$accounts = $GLOBALS['egw']->accounts; |
762 | 762 | } |
@@ -769,13 +769,13 @@ discard block |
||
769 | 769 | * @param int $account =null account_id the class needs to be instanciated for, default need only account-independent methods |
770 | 770 | * @throws Api\Exception\AssertionFailed(lang('%1 class not instanciated','acl'),999); |
771 | 771 | */ |
772 | - protected function _instanciate_acl($account=null) |
|
772 | + protected function _instanciate_acl($account = null) |
|
773 | 773 | { |
774 | 774 | if (!is_object(admin_cmd::$acl) || $account && admin_cmd::$acl->account_id != $account) |
775 | 775 | { |
776 | 776 | if (!is_object($GLOBALS['egw']->acl)) |
777 | 777 | { |
778 | - throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated','acl'),999); |
|
778 | + throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated', 'acl'), 999); |
|
779 | 779 | } |
780 | 780 | if ($account && $GLOBALS['egw']->acl->account_id != $account) |
781 | 781 | { |
@@ -795,20 +795,20 @@ discard block |
||
795 | 795 | * @param $account_id =null account_id, default current user |
796 | 796 | * @return string |
797 | 797 | */ |
798 | - static function user_email($account_id=null) |
|
798 | + static function user_email($account_id = null) |
|
799 | 799 | { |
800 | 800 | if ($account_id) |
801 | 801 | { |
802 | 802 | admin_cmd::_instanciate_accounts(); |
803 | - $fullname = admin_cmd::$accounts->id2name($account_id,'account_fullname'); |
|
804 | - $email = admin_cmd::$accounts->id2name($account_id,'account_email'); |
|
803 | + $fullname = admin_cmd::$accounts->id2name($account_id, 'account_fullname'); |
|
804 | + $email = admin_cmd::$accounts->id2name($account_id, 'account_email'); |
|
805 | 805 | } |
806 | 806 | else |
807 | 807 | { |
808 | 808 | $fullname = $GLOBALS['egw_info']['user']['account_fullname']; |
809 | 809 | $email = $GLOBALS['egw_info']['user']['account_email']; |
810 | 810 | } |
811 | - return $fullname . ($email ? ' <'.$email.'>' : ''); |
|
811 | + return $fullname.($email ? ' <'.$email.'>' : ''); |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | /** |
@@ -832,11 +832,11 @@ discard block |
||
832 | 832 | { |
833 | 833 | return false; |
834 | 834 | } |
835 | - if (!($jobs = admin_cmd::search(array(),false,'cmd_scheduled','','',false,'AND',array(0,1),array( |
|
835 | + if (!($jobs = admin_cmd::search(array(), false, 'cmd_scheduled', '', '', false, 'AND', array(0, 1), array( |
|
836 | 836 | 'cmd_status' => admin_cmd::scheduled, |
837 | 837 | )))) |
838 | 838 | { |
839 | - return false; // no schduled command, no need to setup the job |
|
839 | + return false; // no schduled command, no need to setup the job |
|
840 | 840 | } |
841 | 841 | $next = $jobs[0]; |
842 | 842 | if (($time = $next['scheduled']) < time()) // should run immediatly |
@@ -846,11 +846,11 @@ discard block |
||
846 | 846 | $async = new Api\Asyncservice(); |
847 | 847 | |
848 | 848 | // we cant use this class as callback, as it's abstract and ExecMethod used by the async service instanciated the class! |
849 | - list($app) = explode('_',$class=$next['type']); |
|
849 | + list($app) = explode('_', $class = $next['type']); |
|
850 | 850 | $callback = $app.'.'.$class.'.run_queued_jobs'; |
851 | 851 | |
852 | - $async->cancel_timer(admin_cmd::async_job_id); // we delete it in case a job already exists |
|
853 | - return $async->set_timer($time,admin_cmd::async_job_id,$callback,null,$next['creator']); |
|
852 | + $async->cancel_timer(admin_cmd::async_job_id); // we delete it in case a job already exists |
|
853 | + return $async->set_timer($time, admin_cmd::async_job_id, $callback, null, $next['creator']); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | /** |
@@ -860,27 +860,27 @@ discard block |
||
860 | 860 | */ |
861 | 861 | static function run_queued_jobs() |
862 | 862 | { |
863 | - if (!($jobs = admin_cmd::search(array(),false,'cmd_scheduled','','',false,'AND',false,array( |
|
863 | + if (!($jobs = admin_cmd::search(array(), false, 'cmd_scheduled', '', '', false, 'AND', false, array( |
|
864 | 864 | 'cmd_status' => admin_cmd::scheduled, |
865 | 865 | 'cmd_scheduled <= '.time(), |
866 | 866 | )))) |
867 | 867 | { |
868 | - return false; // no schduled commands, no need to setup the job |
|
868 | + return false; // no schduled commands, no need to setup the job |
|
869 | 869 | } |
870 | - admin_cmd::$running_queued_jobs = true; // stop admin_cmd::run() which calls admin_cmd::save() to install a new job |
|
870 | + admin_cmd::$running_queued_jobs = true; // stop admin_cmd::run() which calls admin_cmd::save() to install a new job |
|
871 | 871 | |
872 | - foreach($jobs as $job) |
|
872 | + foreach ($jobs as $job) |
|
873 | 873 | { |
874 | 874 | try { |
875 | 875 | $cmd = admin_cmd::instanciate($job); |
876 | - $cmd->run(null,false); // false = dont set current user as modifier, as job is run by the queue/system itself |
|
876 | + $cmd->run(null, false); // false = dont set current user as modifier, as job is run by the queue/system itself |
|
877 | 877 | } |
878 | 878 | catch (Exception $e) { // we need to mark that command as failed, to prevent further execution |
879 | 879 | unset($e); |
880 | 880 | admin_cmd::$sql->init($job); |
881 | 881 | admin_cmd::$sql->save(array( |
882 | 882 | 'status' => admin_cmd::failed, |
883 | - 'error' => lang('Unknown command %1!',$job['type']), |
|
883 | + 'error' => lang('Unknown command %1!', $job['type']), |
|
884 | 884 | 'errno' => 0, |
885 | 885 | 'data' => self::mask_passwords($job['data']), |
886 | 886 | )); |
@@ -901,9 +901,9 @@ discard block |
||
901 | 901 | admin_cmd::_instanciate_remote(); |
902 | 902 | |
903 | 903 | $sites = array(lang('local')); |
904 | - if (($remote = admin_cmd::$remote->query_list('remote_name','remote_id'))) |
|
904 | + if (($remote = admin_cmd::$remote->query_list('remote_name', 'remote_id'))) |
|
905 | 905 | { |
906 | - $sites = array_merge($sites,$remote); |
|
906 | + $sites = array_merge($sites, $remote); |
|
907 | 907 | } |
908 | 908 | return $sites; |
909 | 909 | } |
@@ -916,11 +916,11 @@ discard block |
||
916 | 916 | * @param array &$readonlys |
917 | 917 | * @return int |
918 | 918 | */ |
919 | - static function get_remotes($query,&$rows,&$readonlys) |
|
919 | + static function get_remotes($query, &$rows, &$readonlys) |
|
920 | 920 | { |
921 | 921 | admin_cmd::_instanciate_remote(); |
922 | 922 | |
923 | - return admin_cmd::$remote->get_rows($query,$rows,$readonlys); |
|
923 | + return admin_cmd::$remote->get_rows($query, $rows, $readonlys); |
|
924 | 924 | } |
925 | 925 | |
926 | 926 | /** |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | |
949 | 949 | if ($data['install_id'] && $data['config_passwd']) // calculate hash |
950 | 950 | { |
951 | - $data['remote_hash'] = self::remote_hash($data['install_id'],$data['config_passwd']); |
|
951 | + $data['remote_hash'] = self::remote_hash($data['install_id'], $data['config_passwd']); |
|
952 | 952 | } |
953 | 953 | elseif (!$data['remote_hash'] && !($data['install_id'] && $data['config_passwd'])) |
954 | 954 | { |
@@ -960,12 +960,12 @@ discard block |
||
960 | 960 | // check if a unique key constrain would be violated by saving the entry |
961 | 961 | if (($num = admin_cmd::$remote->not_unique())) |
962 | 962 | { |
963 | - $col = admin_cmd::$remote->table_def['uc'][$num-1]; // $num is 1 based! |
|
964 | - throw new egw_exception_db_not_unique(lang('Value for column %1 is not unique!',$this->table_name.'.'.$col),$num); |
|
963 | + $col = admin_cmd::$remote->table_def['uc'][$num - 1]; // $num is 1 based! |
|
964 | + throw new egw_exception_db_not_unique(lang('Value for column %1 is not unique!', $this->table_name.'.'.$col), $num); |
|
965 | 965 | } |
966 | 966 | if (admin_cmd::$remote->save() != 0) |
967 | 967 | { |
968 | - throw new Api\Db\Exception(lang('Error saving to db:').' '.$this->sql->db->Error.' ('.$this->sql->db->Errno.')',$this->sql->db->Errno); |
|
968 | + throw new Api\Db\Exception(lang('Error saving to db:').' '.$this->sql->db->Error.' ('.$this->sql->db->Errno.')', $this->sql->db->Errno); |
|
969 | 969 | } |
970 | 970 | return admin_cmd::$remote->data['remote_id']; |
971 | 971 | } |
@@ -977,11 +977,11 @@ discard block |
||
977 | 977 | * @param string $config_passwd |
978 | 978 | * @return string 32char md5 hash |
979 | 979 | */ |
980 | - static function remote_hash($install_id,$config_passwd) |
|
980 | + static function remote_hash($install_id, $config_passwd) |
|
981 | 981 | { |
982 | 982 | if (empty($config_passwd) || !self::is_md5($install_id)) |
983 | 983 | { |
984 | - throw new Api\Exception\WrongParameter(empty($config_passwd)?'Empty Api\Config password':'install_id no md5 hash'); |
|
984 | + throw new Api\Exception\WrongParameter(empty($config_passwd) ? 'Empty Api\Config password' : 'install_id no md5 hash'); |
|
985 | 985 | } |
986 | 986 | if (!self::is_md5($config_passwd)) $config_passwd = md5($config_passwd); |
987 | 987 | |
@@ -1011,7 +1011,7 @@ discard block |
||
1011 | 1011 | */ |
1012 | 1012 | static function is_md5($str) |
1013 | 1013 | { |
1014 | - return preg_match('/^[0-9a-f]{32}$/',$str); |
|
1014 | + return preg_match('/^[0-9a-f]{32}$/', $str); |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | /** |
@@ -1028,26 +1028,26 @@ discard block |
||
1028 | 1028 | * @param string $config_passwd of the current domain |
1029 | 1029 | * @throws Api\Exception\NoPermission |
1030 | 1030 | */ |
1031 | - function check_remote_access($secret,$config_passwd) |
|
1031 | + function check_remote_access($secret, $config_passwd) |
|
1032 | 1032 | { |
1033 | 1033 | // as a security measure remote administration need to be enabled under Admin > Site configuration |
1034 | - list(,$remote_admin_install_id) = explode('-',$this->uid); |
|
1035 | - $allowed_remote_admin_ids = $GLOBALS['egw_info']['server']['allow_remote_admin'] ? explode(',',$GLOBALS['egw_info']['server']['allow_remote_admin']) : array(); |
|
1034 | + list(,$remote_admin_install_id) = explode('-', $this->uid); |
|
1035 | + $allowed_remote_admin_ids = $GLOBALS['egw_info']['server']['allow_remote_admin'] ? explode(',', $GLOBALS['egw_info']['server']['allow_remote_admin']) : array(); |
|
1036 | 1036 | |
1037 | 1037 | // to authenticate with the installation we use a secret, which is a md5 hash build from the uid |
1038 | 1038 | // of the command (to not allow to send new commands with an earsdroped secret) and the md5 hash |
1039 | 1039 | // of the md5 hash of the Api\Config password and the install_id (egw_admin_remote.remote_hash) |
1040 | - if (is_null($config_passwd) || is_numeric($this->uid) || !in_array($remote_admin_install_id,$allowed_remote_admin_ids) || |
|
1041 | - $secret != ($md5=md5($this->uid.$this->remote_hash($GLOBALS['egw_info']['server']['install_id'],$config_passwd)))) |
|
1040 | + if (is_null($config_passwd) || is_numeric($this->uid) || !in_array($remote_admin_install_id, $allowed_remote_admin_ids) || |
|
1041 | + $secret != ($md5 = md5($this->uid.$this->remote_hash($GLOBALS['egw_info']['server']['install_id'], $config_passwd)))) |
|
1042 | 1042 | { |
1043 | 1043 | //die("secret='$secret' != '$md5', is_null($config_passwd)=".is_null($config_passwd).", uid=$this->uid, remote_install_id=$remote_admin_install_id, allowed: ".implode(', ',$allowed_remote_admin_ids)); |
1044 | 1044 | unset($md5); |
1045 | 1045 | $msg = lang('Permission denied!'); |
1046 | - if (!in_array($remote_admin_install_id,$allowed_remote_admin_ids)) |
|
1046 | + if (!in_array($remote_admin_install_id, $allowed_remote_admin_ids)) |
|
1047 | 1047 | { |
1048 | 1048 | $msg .= "\n".lang('Remote administration need to be enabled in the remote instance under Admin > Site configuration!'); |
1049 | 1049 | } |
1050 | - throw new Api\Exception\NoPermission($msg,0); |
|
1050 | + throw new Api\Exception\NoPermission($msg, 0); |
|
1051 | 1051 | } |
1052 | 1052 | } |
1053 | 1053 | |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | * @param int $len =16 |
1058 | 1058 | * @return string |
1059 | 1059 | */ |
1060 | - static function randomstring($len=16) |
|
1060 | + static function randomstring($len = 16) |
|
1061 | 1061 | { |
1062 | 1062 | return Api\Auth::randomstring($len); |
1063 | 1063 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | /** |
21 | 21 | * Constructor |
22 | 22 | * |
23 | - * @param boolean|array $allow true=give rights, false=remove rights, or array with all 3 params |
|
23 | + * @param boolean $allow true=give rights, false=remove rights, or array with all 3 params |
|
24 | 24 | * @param string|int $account =null account name or id |
25 | 25 | * @param array|string $apps =null app-names |
26 | 26 | */ |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @param string|int $account =null account name or id |
25 | 25 | * @param array|string $apps =null app-names |
26 | 26 | */ |
27 | - function __construct($allow,$account=null,$apps=null) |
|
27 | + function __construct($allow, $account = null, $apps = null) |
|
28 | 28 | { |
29 | 29 | if (!is_array($allow)) |
30 | 30 | { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | } |
37 | 37 | if (isset($allow['apps']) && !is_array($allow['apps'])) |
38 | 38 | { |
39 | - $allow['apps'] = explode(',',$allow['apps']); |
|
39 | + $allow['apps'] = explode(',', $allow['apps']); |
|
40 | 40 | } |
41 | 41 | admin_cmd::__construct($allow); |
42 | 42 | } |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15); |
51 | 51 | * @throws Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8); |
52 | 52 | */ |
53 | - protected function exec($check_only=false) |
|
53 | + protected function exec($check_only = false) |
|
54 | 54 | { |
55 | 55 | $account_id = admin_cmd::parse_account($this->account); |
56 | 56 | // check creator is still admin and not explicitly forbidden to edit accounts/groups |
57 | - if ($this->creator) $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access',16); |
|
57 | + if ($this->creator) $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access', 16); |
|
58 | 58 | |
59 | 59 | $apps = admin_cmd::parse_apps($this->apps); |
60 | 60 | |
@@ -62,15 +62,15 @@ discard block |
||
62 | 62 | |
63 | 63 | //echo "account=$this->account, account_id=$account_id, apps: ".implode(', ',$apps)."\n"; |
64 | 64 | admin_cmd::_instanciate_acl($account_id); |
65 | - foreach($apps as $app) |
|
65 | + foreach ($apps as $app) |
|
66 | 66 | { |
67 | 67 | if ($this->allow) |
68 | 68 | { |
69 | - admin_cmd::$acl->add_repository($app,'run',$account_id,1); |
|
69 | + admin_cmd::$acl->add_repository($app, 'run', $account_id, 1); |
|
70 | 70 | } |
71 | 71 | else |
72 | 72 | { |
73 | - admin_cmd::$acl->delete_repository($app,'run',$account_id); |
|
73 | + admin_cmd::$acl->delete_repository($app, 'run', $account_id); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | return lang('Applications run rights updated.'); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | function __tostring() |
85 | 85 | { |
86 | - return lang('%1 rights for %2 and applications %3',$this->allow ? lang('Grant') : lang('Remove'), |
|
87 | - admin_cmd::display_account($this->account),implode(', ',$this->apps)); |
|
86 | + return lang('%1 rights for %2 and applications %3', $this->allow ? lang('Grant') : lang('Remove'), |
|
87 | + admin_cmd::display_account($this->account), implode(', ', $this->apps)); |
|
88 | 88 | } |
89 | 89 | } |
@@ -54,11 +54,17 @@ |
||
54 | 54 | { |
55 | 55 | $account_id = admin_cmd::parse_account($this->account); |
56 | 56 | // check creator is still admin and not explicitly forbidden to edit accounts/groups |
57 | - if ($this->creator) $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access',16); |
|
57 | + if ($this->creator) |
|
58 | + { |
|
59 | + $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access',16); |
|
60 | + } |
|
58 | 61 | |
59 | 62 | $apps = admin_cmd::parse_apps($this->apps); |
60 | 63 | |
61 | - if ($check_only) return true; |
|
64 | + if ($check_only) |
|
65 | + { |
|
66 | + return true; |
|
67 | + } |
|
62 | 68 | |
63 | 69 | //echo "account=$this->account, account_id=$account_id, apps: ".implode(', ',$apps)."\n"; |
64 | 70 | admin_cmd::_instanciate_acl($account_id); |
@@ -77,8 +77,7 @@ |
||
77 | 77 | /** |
78 | 78 | * imports entries according to given definition object. |
79 | 79 | * @param resource $_stream |
80 | - * @param string $_charset |
|
81 | - * @param definition $_definition |
|
80 | + * @param importexport_definition $_definition |
|
82 | 81 | */ |
83 | 82 | public function import( $_stream, importexport_definition $_definition ) { |
84 | 83 | $import_csv = new importexport_import_csv( $_stream, array( |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * class import_csv for admin (groups) |
17 | 17 | */ |
18 | -class admin_import_groups_csv implements importexport_iface_import_plugin { |
|
18 | +class admin_import_groups_csv implements importexport_iface_import_plugin { |
|
19 | 19 | |
20 | 20 | private static $plugin_options = array( |
21 | - 'fieldsep', // char |
|
22 | - 'charset', // string |
|
21 | + 'fieldsep', // char |
|
22 | + 'charset', // string |
|
23 | 23 | 'num_header_lines', // int number of header lines |
24 | 24 | 'field_conversion', // array( $csv_col_num => conversion) |
25 | - 'field_mapping', // array( $csv_col_num => adb_filed) |
|
26 | - 'conditions', /* => array containing condition arrays: |
|
25 | + 'field_mapping', // array( $csv_col_num => adb_filed) |
|
26 | + 'conditions', /* => array containing condition arrays: |
|
27 | 27 | 'type' => exists, // exists |
28 | 28 | 'string' => '#kundennummer', |
29 | 29 | 'true' => array( |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * actions which could be done to data entries |
42 | 42 | */ |
43 | - protected static $actions = array( 'none', 'update', 'create', 'delete'); |
|
43 | + protected static $actions = array('none', 'update', 'create', 'delete'); |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * conditions for actions |
47 | 47 | * |
48 | 48 | * @var array |
49 | 49 | */ |
50 | - protected static $conditions = array( 'exists' ); |
|
50 | + protected static $conditions = array('exists'); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @var definition |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * @param string $_charset |
81 | 81 | * @param definition $_definition |
82 | 82 | */ |
83 | - public function import( $_stream, importexport_definition $_definition ) { |
|
84 | - $import_csv = new importexport_import_csv( $_stream, array( |
|
83 | + public function import($_stream, importexport_definition $_definition) { |
|
84 | + $import_csv = new importexport_import_csv($_stream, array( |
|
85 | 85 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
86 | 86 | 'charset' => $_definition->plugin_options['charset'], |
87 | 87 | )); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $this->definition = $_definition; |
90 | 90 | |
91 | 91 | // dry run? |
92 | - $this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false; |
|
92 | + $this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false; |
|
93 | 93 | |
94 | 94 | // set FieldMapping. |
95 | 95 | $import_csv->mapping = $_definition->plugin_options['field_mapping']; |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
99 | 99 | |
100 | 100 | //check if file has a header lines |
101 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
101 | + if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
102 | 102 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
103 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
103 | + } elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
104 | 104 | // First method is preferred |
105 | 105 | $import_csv->skip_records(1); |
106 | 106 | } |
@@ -112,22 +112,22 @@ discard block |
||
112 | 112 | // Failures |
113 | 113 | $this->errors = array(); |
114 | 114 | |
115 | - while ( $record = $import_csv->get_record() ) { |
|
115 | + while ($record = $import_csv->get_record()) { |
|
116 | 116 | $success = false; |
117 | 117 | // don't import empty records |
118 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
118 | + if (count(array_unique($record)) < 2) continue; |
|
119 | 119 | |
120 | 120 | importexport_import_csv::convert($record, admin_egw_group_record::$types, 'admin'); |
121 | 121 | |
122 | - if ( $_definition->plugin_options['conditions'] ) { |
|
123 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
124 | - switch ( $condition['type'] ) { |
|
122 | + if ($_definition->plugin_options['conditions']) { |
|
123 | + foreach ($_definition->plugin_options['conditions'] as $condition) { |
|
124 | + switch ($condition['type']) { |
|
125 | 125 | // exists |
126 | 126 | case 'exists' : |
127 | 127 | $accounts = array(); |
128 | 128 | |
129 | 129 | // Skip the search if the field is empty |
130 | - if($record[$condition['string']] !== '') { |
|
130 | + if ($record[$condition['string']] !== '') { |
|
131 | 131 | |
132 | 132 | $accounts = $GLOBALS['egw']->accounts->search(array( |
133 | 133 | 'type' => 'groups', |
@@ -136,25 +136,25 @@ discard block |
||
136 | 136 | )); |
137 | 137 | } |
138 | 138 | // Search looks in the given field, but doesn't do an exact match |
139 | - foreach ( (array)$accounts as $key => $account ) |
|
139 | + foreach ((array)$accounts as $key => $account) |
|
140 | 140 | { |
141 | - if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]); |
|
141 | + if ($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]); |
|
142 | 142 | } |
143 | - if ( is_array( $accounts ) && count( $accounts ) >= 1 ) { |
|
143 | + if (is_array($accounts) && count($accounts) >= 1) { |
|
144 | 144 | $account = current($accounts); |
145 | 145 | // apply action to all contacts matching this exists condition |
146 | 146 | $action = $condition['true']; |
147 | - foreach ( (array)$accounts as $account ) { |
|
147 | + foreach ((array)$accounts as $account) { |
|
148 | 148 | // Read full account, and copy needed info for accounts->save() |
149 | 149 | $account = $GLOBALS['egw']->accounts->read($account['account_id']); |
150 | 150 | $record['account_id'] = $account['account_id']; |
151 | 151 | $record['account_firstname'] = $account['account_firstname']; |
152 | 152 | $record['account_lastname'] = $account['account_lastname']; |
153 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
153 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
154 | 154 | } |
155 | 155 | } else { |
156 | 156 | $action = $condition['false']; |
157 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
157 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
158 | 158 | } |
159 | 159 | break; |
160 | 160 | |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | } |
167 | 167 | } else { |
168 | 168 | // unconditional insert |
169 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
169 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
170 | 170 | } |
171 | - if($success) $count++; |
|
171 | + if ($success) $count++; |
|
172 | 172 | } |
173 | 173 | return $count; |
174 | 174 | } |
@@ -180,18 +180,18 @@ discard block |
||
180 | 180 | * @param array $_data contact data for the action |
181 | 181 | * @return bool success or not |
182 | 182 | */ |
183 | - private function action ( $_action, $_data, $record_num = 0 ) { |
|
183 | + private function action($_action, $_data, $record_num = 0) { |
|
184 | 184 | switch ($_action) { |
185 | 185 | case 'none' : |
186 | 186 | return true; |
187 | 187 | case 'update' : |
188 | 188 | case 'create' : |
189 | - if(count($_data['account_members']) < 1) { |
|
189 | + if (count($_data['account_members']) < 1) { |
|
190 | 190 | $this->errors[$record_num] = lang('You must select at least one group member.'); |
191 | 191 | return false; |
192 | 192 | } |
193 | 193 | $command = new admin_cmd_edit_group($_action == 'create' ? false : $_data['account_lid'], $_data); |
194 | - if($this->dry_run) { |
|
194 | + if ($this->dry_run) { |
|
195 | 195 | $this->results[$_action]++; |
196 | 196 | return true; |
197 | 197 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * preserv => array, |
249 | 249 | * ) |
250 | 250 | */ |
251 | - public function get_options_etpl(importexport_definition &$definition=null) |
|
251 | + public function get_options_etpl(importexport_definition &$definition = null) |
|
252 | 252 | { |
253 | 253 | // lets do it! |
254 | 254 | } |
@@ -15,7 +15,8 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * class import_csv for admin (groups) |
17 | 17 | */ |
18 | -class admin_import_groups_csv implements importexport_iface_import_plugin { |
|
18 | +class admin_import_groups_csv implements importexport_iface_import_plugin |
|
19 | +{ |
|
19 | 20 | |
20 | 21 | private static $plugin_options = array( |
21 | 22 | 'fieldsep', // char |
@@ -80,7 +81,8 @@ discard block |
||
80 | 81 | * @param string $_charset |
81 | 82 | * @param definition $_definition |
82 | 83 | */ |
83 | - public function import( $_stream, importexport_definition $_definition ) { |
|
84 | + public function import( $_stream, importexport_definition $_definition ) |
|
85 | + { |
|
84 | 86 | $import_csv = new importexport_import_csv( $_stream, array( |
85 | 87 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
86 | 88 | 'charset' => $_definition->plugin_options['charset'], |
@@ -98,9 +100,12 @@ discard block |
||
98 | 100 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
99 | 101 | |
100 | 102 | //check if file has a header lines |
101 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
103 | + if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) |
|
104 | + { |
|
102 | 105 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
103 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
106 | + } |
|
107 | + elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) |
|
108 | + { |
|
104 | 109 | // First method is preferred |
105 | 110 | $import_csv->skip_records(1); |
106 | 111 | } |
@@ -112,22 +117,30 @@ discard block |
||
112 | 117 | // Failures |
113 | 118 | $this->errors = array(); |
114 | 119 | |
115 | - while ( $record = $import_csv->get_record() ) { |
|
120 | + while ( $record = $import_csv->get_record() ) |
|
121 | + { |
|
116 | 122 | $success = false; |
117 | 123 | // don't import empty records |
118 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
124 | + if( count( array_unique( $record ) ) < 2 ) |
|
125 | + { |
|
126 | + continue; |
|
127 | + } |
|
119 | 128 | |
120 | 129 | importexport_import_csv::convert($record, admin_egw_group_record::$types, 'admin'); |
121 | 130 | |
122 | - if ( $_definition->plugin_options['conditions'] ) { |
|
123 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
124 | - switch ( $condition['type'] ) { |
|
131 | + if ( $_definition->plugin_options['conditions'] ) |
|
132 | + { |
|
133 | + foreach ( $_definition->plugin_options['conditions'] as $condition ) |
|
134 | + { |
|
135 | + switch ( $condition['type'] ) |
|
136 | + { |
|
125 | 137 | // exists |
126 | 138 | case 'exists' : |
127 | 139 | $accounts = array(); |
128 | 140 | |
129 | 141 | // Skip the search if the field is empty |
130 | - if($record[$condition['string']] !== '') { |
|
142 | + if($record[$condition['string']] !== '') |
|
143 | + { |
|
131 | 144 | |
132 | 145 | $accounts = $GLOBALS['egw']->accounts->search(array( |
133 | 146 | 'type' => 'groups', |
@@ -138,13 +151,18 @@ discard block |
||
138 | 151 | // Search looks in the given field, but doesn't do an exact match |
139 | 152 | foreach ( (array)$accounts as $key => $account ) |
140 | 153 | { |
141 | - if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]); |
|
154 | + if($account[$condition['string']] != $record[$condition['string']]) |
|
155 | + { |
|
156 | + unset($accounts[$key]); |
|
157 | + } |
|
142 | 158 | } |
143 | - if ( is_array( $accounts ) && count( $accounts ) >= 1 ) { |
|
159 | + if ( is_array( $accounts ) && count( $accounts ) >= 1 ) |
|
160 | + { |
|
144 | 161 | $account = current($accounts); |
145 | 162 | // apply action to all contacts matching this exists condition |
146 | 163 | $action = $condition['true']; |
147 | - foreach ( (array)$accounts as $account ) { |
|
164 | + foreach ( (array)$accounts as $account ) |
|
165 | + { |
|
148 | 166 | // Read full account, and copy needed info for accounts->save() |
149 | 167 | $account = $GLOBALS['egw']->accounts->read($account['account_id']); |
150 | 168 | $record['account_id'] = $account['account_id']; |
@@ -152,7 +170,9 @@ discard block |
||
152 | 170 | $record['account_lastname'] = $account['account_lastname']; |
153 | 171 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
154 | 172 | } |
155 | - } else { |
|
173 | + } |
|
174 | + else |
|
175 | + { |
|
156 | 176 | $action = $condition['false']; |
157 | 177 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
158 | 178 | } |
@@ -162,13 +182,21 @@ discard block |
||
162 | 182 | default : |
163 | 183 | die('condition / action not supported!!!'); |
164 | 184 | } |
165 | - if ($action['last']) break; |
|
185 | + if ($action['last']) |
|
186 | + { |
|
187 | + break; |
|
188 | + } |
|
166 | 189 | } |
167 | - } else { |
|
190 | + } |
|
191 | + else |
|
192 | + { |
|
168 | 193 | // unconditional insert |
169 | 194 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
170 | 195 | } |
171 | - if($success) $count++; |
|
196 | + if($success) |
|
197 | + { |
|
198 | + $count++; |
|
199 | + } |
|
172 | 200 | } |
173 | 201 | return $count; |
174 | 202 | } |
@@ -180,24 +208,29 @@ discard block |
||
180 | 208 | * @param array $_data contact data for the action |
181 | 209 | * @return bool success or not |
182 | 210 | */ |
183 | - private function action ( $_action, $_data, $record_num = 0 ) { |
|
184 | - switch ($_action) { |
|
211 | + private function action ( $_action, $_data, $record_num = 0 ) |
|
212 | + { |
|
213 | + switch ($_action) |
|
214 | + { |
|
185 | 215 | case 'none' : |
186 | 216 | return true; |
187 | 217 | case 'update' : |
188 | 218 | case 'create' : |
189 | - if(count($_data['account_members']) < 1) { |
|
219 | + if(count($_data['account_members']) < 1) |
|
220 | + { |
|
190 | 221 | $this->errors[$record_num] = lang('You must select at least one group member.'); |
191 | 222 | return false; |
192 | 223 | } |
193 | 224 | $command = new admin_cmd_edit_group($_action == 'create' ? false : $_data['account_lid'], $_data); |
194 | - if($this->dry_run) { |
|
225 | + if($this->dry_run) |
|
226 | + { |
|
195 | 227 | $this->results[$_action]++; |
196 | 228 | return true; |
197 | 229 | } |
198 | 230 | try { |
199 | 231 | $command->run(); |
200 | - } catch (Exception $e) { |
|
232 | + } |
|
233 | + catch (Exception $e) { |
|
201 | 234 | $this->errors[$record_num] = $e->getMessage(); |
202 | 235 | return false; |
203 | 236 | } |
@@ -214,7 +247,8 @@ discard block |
||
214 | 247 | * |
215 | 248 | * @return string name |
216 | 249 | */ |
217 | - public static function get_name() { |
|
250 | + public static function get_name() |
|
251 | + { |
|
218 | 252 | return lang('Group CSV import'); |
219 | 253 | } |
220 | 254 | |
@@ -223,7 +257,8 @@ discard block |
||
223 | 257 | * |
224 | 258 | * @return string descriprion |
225 | 259 | */ |
226 | - public static function get_description() { |
|
260 | + public static function get_description() |
|
261 | + { |
|
227 | 262 | return lang("Creates / updates user groups from CSV file"); |
228 | 263 | } |
229 | 264 | |
@@ -232,7 +267,8 @@ discard block |
||
232 | 267 | * |
233 | 268 | * @return string suffix (comma seperated) |
234 | 269 | */ |
235 | - public static function get_filesuffix() { |
|
270 | + public static function get_filesuffix() |
|
271 | + { |
|
236 | 272 | return 'csv'; |
237 | 273 | } |
238 | 274 | |
@@ -258,7 +294,8 @@ discard block |
||
258 | 294 | * |
259 | 295 | * @return string etemplate name |
260 | 296 | */ |
261 | - public function get_selectors_etpl() { |
|
297 | + public function get_selectors_etpl() |
|
298 | + { |
|
262 | 299 | // lets do it! |
263 | 300 | } |
264 | 301 | |
@@ -270,7 +307,8 @@ discard block |
||
270 | 307 | * record_# => warning message |
271 | 308 | * ) |
272 | 309 | */ |
273 | - public function get_warnings() { |
|
310 | + public function get_warnings() |
|
311 | + { |
|
274 | 312 | return $this->warnings; |
275 | 313 | } |
276 | 314 | |
@@ -282,7 +320,8 @@ discard block |
||
282 | 320 | * record_# => error message |
283 | 321 | * ) |
284 | 322 | */ |
285 | - public function get_errors() { |
|
323 | + public function get_errors() |
|
324 | + { |
|
286 | 325 | return $this->errors; |
287 | 326 | } |
288 | 327 | |
@@ -294,7 +333,8 @@ discard block |
||
294 | 333 | * action => record count |
295 | 334 | * ) |
296 | 335 | */ |
297 | - public function get_results() { |
|
336 | + public function get_results() |
|
337 | + { |
|
298 | 338 | return $this->results; |
299 | 339 | } |
300 | 340 | } |