@@ -18,4 +18,6 @@ |
||
18 | 18 | /** |
19 | 19 | * Storing the row violates a unique key constrain |
20 | 20 | */ |
21 | -class NotUnique extends Db\Exception { } |
|
21 | +class NotUnique extends Db\Exception |
|
22 | +{ |
|
23 | +} |
@@ -19,4 +19,6 @@ |
||
19 | 19 | * New InvalidSql exception has to extend deprecated egw_exception_db_invalid_sql |
20 | 20 | * to allow legacy code to catch exceptions thrown by Api\Db! |
21 | 21 | */ |
22 | -class InvalidSql extends \egw_exception_db_invalid_sql {} |
|
22 | +class InvalidSql extends \egw_exception_db_invalid_sql |
|
23 | +{ |
|
24 | +} |
@@ -18,4 +18,6 @@ |
||
18 | 18 | /** |
19 | 19 | * EGroupware not (fully) installed, visit setup |
20 | 20 | */ |
21 | -class Setup extends Db\Exception { } |
|
21 | +class Setup extends Db\Exception |
|
22 | +{ |
|
23 | +} |
@@ -18,4 +18,6 @@ |
||
18 | 18 | /** |
19 | 19 | * PHP lacks support for configured database type |
20 | 20 | */ |
21 | -class Support extends Db\Exception { } |
|
21 | +class Support extends Db\Exception |
|
22 | +{ |
|
23 | +} |
@@ -18,4 +18,6 @@ |
||
18 | 18 | /** |
19 | 19 | * Can not connect to database: eg. database down, wrong host, name or credentials |
20 | 20 | */ |
21 | -class Connection extends Db\Exception { } |
|
21 | +class Connection extends Db\Exception |
|
22 | +{ |
|
23 | +} |
@@ -84,7 +84,10 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function calendar_replacements($id,$last_event_too=false) |
86 | 86 | { |
87 | - if (!class_exists('calendar_boupdate')) return array(); |
|
87 | + if (!class_exists('calendar_boupdate')) |
|
88 | + { |
|
89 | + return array(); |
|
90 | + } |
|
88 | 91 | |
89 | 92 | $calendar = new calendar_boupdate(); |
90 | 93 | |
@@ -118,11 +121,17 @@ discard block |
||
118 | 121 | foreach($events as $key => $event) |
119 | 122 | { |
120 | 123 | // Use -1 for previous key |
121 | - if($key < 0) $n = $key; |
|
124 | + if($key < 0) |
|
125 | + { |
|
126 | + $n = $key; |
|
127 | + } |
|
122 | 128 | |
123 | 129 | foreach($calendar->event2array($event) as $name => $data) |
124 | 130 | { |
125 | - if (substr($name,-4) == 'date') $name = substr($name,0,-4); |
|
131 | + if (substr($name,-4) == 'date') |
|
132 | + { |
|
133 | + $name = substr($name,0,-4); |
|
134 | + } |
|
126 | 135 | $replacements['$$calendar/'.$n.'/'.$name.'$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data']; |
127 | 136 | } |
128 | 137 | foreach(array('start','end') as $what) |
@@ -134,7 +143,10 @@ discard block |
||
134 | 143 | ) as $name => $format) |
135 | 144 | { |
136 | 145 | $value = $event[$what] ? date($format,$event[$what]) : ''; |
137 | - if ($format == 'l') $value = lang($value); |
|
146 | + if ($format == 'l') |
|
147 | + { |
|
148 | + $value = lang($value); |
|
149 | + } |
|
138 | 150 | $replacements['$$calendar/'.$n.'/'.$what.$name.'$$'] = $value; |
139 | 151 | } |
140 | 152 | } |
@@ -145,7 +157,8 @@ discard block |
||
145 | 157 | } |
146 | 158 | |
147 | 159 | // Need to set some keys if there is no previous event |
148 | - if($last_event_too && count($events['-1']) == 0) { |
|
160 | + if($last_event_too && count($events['-1']) == 0) |
|
161 | + { |
|
149 | 162 | $replacements['$$calendar/-1/start$$'] = ''; |
150 | 163 | $replacements['$$calendar/-1/end$$'] = ''; |
151 | 164 | $replacements['$$calendar/-1/owner$$'] = ''; |
@@ -170,22 +183,38 @@ discard block |
||
170 | 183 | $n = 0; |
171 | 184 | foreach($this->contacts->contact_fields as $name => $label) |
172 | 185 | { |
173 | - if (in_array($name,array('tid','label','geo'))) continue; // dont show them, as they are not used in the UI atm. |
|
186 | + if (in_array($name,array('tid','label','geo'))) |
|
187 | + { |
|
188 | + continue; |
|
189 | + } |
|
190 | + // dont show them, as they are not used in the UI atm. |
|
174 | 191 | |
175 | - if (in_array($name,array('email','org_name','tel_work','url')) && $n&1) // main values, which should be in the first column |
|
192 | + if (in_array($name,array('email','org_name','tel_work','url')) && $n&1) |
|
193 | + { |
|
194 | + // main values, which should be in the first column |
|
176 | 195 | { |
177 | 196 | echo "</tr>\n"; |
197 | + } |
|
178 | 198 | $n++; |
179 | 199 | } |
180 | - if (!($n&1)) echo '<tr>'; |
|
200 | + if (!($n&1)) |
|
201 | + { |
|
202 | + echo '<tr>'; |
|
203 | + } |
|
181 | 204 | echo '<td>{{'.$name.'}}</td><td>'.$label.'</td>'; |
182 | 205 | if($name == 'cat_id') |
183 | 206 | { |
184 | - if ($n&1) echo "</tr>\n"; |
|
207 | + if ($n&1) |
|
208 | + { |
|
209 | + echo "</tr>\n"; |
|
210 | + } |
|
185 | 211 | echo '<td>{{categories}}</td><td>'.lang('Category path').'</td>'; |
186 | 212 | $n++; |
187 | 213 | } |
188 | - if ($n&1) echo "</tr>\n"; |
|
214 | + if ($n&1) |
|
215 | + { |
|
216 | + echo "</tr>\n"; |
|
217 | + } |
|
189 | 218 | $n++; |
190 | 219 | } |
191 | 220 | |
@@ -242,14 +271,23 @@ discard block |
||
242 | 271 | 'owner' => lang('Owner'), |
243 | 272 | ) as $name => $label) |
244 | 273 | { |
245 | - if (in_array($name,array('start','end')) && $n&1) // main values, which should be in the first column |
|
274 | + if (in_array($name,array('start','end')) && $n&1) |
|
275 | + { |
|
276 | + // main values, which should be in the first column |
|
246 | 277 | { |
247 | 278 | echo "</tr>\n"; |
279 | + } |
|
248 | 280 | $n++; |
249 | 281 | } |
250 | - if (!($n&1)) echo '<tr>'; |
|
282 | + if (!($n&1)) |
|
283 | + { |
|
284 | + echo '<tr>'; |
|
285 | + } |
|
251 | 286 | echo '<td>{{calendar/#/'.$name.'}}</td><td>'.$label.'</td>'; |
252 | - if ($n&1) echo "</tr>\n"; |
|
287 | + if ($n&1) |
|
288 | + { |
|
289 | + echo "</tr>\n"; |
|
290 | + } |
|
253 | 291 | $n++; |
254 | 292 | } |
255 | 293 | echo "</table>\n"; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | use EGroupware\Api; |
17 | 17 | |
18 | 18 | // explicit import not namespaced classes |
19 | -use calendar_boupdate; // we detect if it is not available |
|
19 | +use calendar_boupdate; // we detect if it is not available |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Contacts document merge |
@@ -55,22 +55,22 @@ discard block |
||
55 | 55 | * @param boolean $ignore_acl =false true: no acl check |
56 | 56 | * @return array|boolean |
57 | 57 | */ |
58 | - protected function get_replacements($id,&$content=null,$ignore_acl=false) |
|
58 | + protected function get_replacements($id, &$content = null, $ignore_acl = false) |
|
59 | 59 | { |
60 | - if (!($replacements = $this->contact_replacements($id,'',$ignore_acl, $content))) |
|
60 | + if (!($replacements = $this->contact_replacements($id, '', $ignore_acl, $content))) |
|
61 | 61 | { |
62 | 62 | return false; |
63 | 63 | } |
64 | - if($content && strpos($content, '$$#') !== false) |
|
64 | + if ($content && strpos($content, '$$#') !== false) |
|
65 | 65 | { |
66 | - $this->cf_link_to_expand($this->contacts->read($id, $ignore_acl), $content, $replacements,'addressbook'); |
|
66 | + $this->cf_link_to_expand($this->contacts->read($id, $ignore_acl), $content, $replacements, 'addressbook'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Links |
70 | 70 | $replacements += $this->get_all_links('addressbook', $id, '', $content); |
71 | - if (!(strpos($content,'$$calendar/') === false)) |
|
71 | + if (!(strpos($content, '$$calendar/') === false)) |
|
72 | 72 | { |
73 | - $replacements += $this->calendar_replacements($id,!(strpos($content,'$$calendar/-1/') === false)); |
|
73 | + $replacements += $this->calendar_replacements($id, !(strpos($content, '$$calendar/-1/') === false)); |
|
74 | 74 | } |
75 | 75 | return $replacements; |
76 | 76 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param boolean $last_event_too =false also include information about the last event |
83 | 83 | * @return array |
84 | 84 | */ |
85 | - protected function calendar_replacements($id,$last_event_too=false) |
|
85 | + protected function calendar_replacements($id, $last_event_too = false) |
|
86 | 86 | { |
87 | 87 | if (!class_exists('calendar_boupdate')) return array(); |
88 | 88 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | { |
102 | 102 | $events = array(); |
103 | 103 | } |
104 | - if ($last_event_too==true) |
|
104 | + if ($last_event_too == true) |
|
105 | 105 | { |
106 | 106 | $last = $calendar->search(array( |
107 | 107 | 'end' => $calendar->now_su, |
@@ -111,41 +111,41 @@ discard block |
||
111 | 111 | 'order' => 'cal_start DESC', |
112 | 112 | 'enum_recurring' => true |
113 | 113 | )); |
114 | - $events['-1'] = $last ? array_shift($last) : array(); // returned events are indexed by cal_id! |
|
114 | + $events['-1'] = $last ? array_shift($last) : array(); // returned events are indexed by cal_id! |
|
115 | 115 | } |
116 | 116 | $replacements = array(); |
117 | - $n = 1; // Returned events are indexed by cal_id, need to index sequentially |
|
118 | - foreach($events as $key => $event) |
|
117 | + $n = 1; // Returned events are indexed by cal_id, need to index sequentially |
|
118 | + foreach ($events as $key => $event) |
|
119 | 119 | { |
120 | 120 | // Use -1 for previous key |
121 | - if($key < 0) $n = $key; |
|
121 | + if ($key < 0) $n = $key; |
|
122 | 122 | |
123 | - foreach($calendar->event2array($event) as $name => $data) |
|
123 | + foreach ($calendar->event2array($event) as $name => $data) |
|
124 | 124 | { |
125 | - if (substr($name,-4) == 'date') $name = substr($name,0,-4); |
|
126 | - $replacements['$$calendar/'.$n.'/'.$name.'$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data']; |
|
125 | + if (substr($name, -4) == 'date') $name = substr($name, 0, -4); |
|
126 | + $replacements['$$calendar/'.$n.'/'.$name.'$$'] = is_array($data['data']) ? implode(', ', $data['data']) : $data['data']; |
|
127 | 127 | } |
128 | - foreach(array('start','end') as $what) |
|
128 | + foreach (array('start', 'end') as $what) |
|
129 | 129 | { |
130 | - foreach(array( |
|
130 | + foreach (array( |
|
131 | 131 | 'date' => $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], |
132 | 132 | 'day' => 'l', |
133 | 133 | 'time' => $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i', |
134 | 134 | ) as $name => $format) |
135 | 135 | { |
136 | - $value = $event[$what] ? date($format,$event[$what]) : ''; |
|
136 | + $value = $event[$what] ? date($format, $event[$what]) : ''; |
|
137 | 137 | if ($format == 'l') $value = lang($value); |
138 | 138 | $replacements['$$calendar/'.$n.'/'.$what.$name.'$$'] = $value; |
139 | 139 | } |
140 | 140 | } |
141 | - $duration = ($event['end'] - $event['start'])/60; |
|
142 | - $replacements['$$calendar/'.$n.'/duration$$'] = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
|
141 | + $duration = ($event['end'] - $event['start']) / 60; |
|
142 | + $replacements['$$calendar/'.$n.'/duration$$'] = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : ''); |
|
143 | 143 | |
144 | 144 | ++$n; |
145 | 145 | } |
146 | 146 | |
147 | 147 | // Need to set some keys if there is no previous event |
148 | - if($last_event_too && count($events['-1']) == 0) { |
|
148 | + if ($last_event_too && count($events['-1']) == 0) { |
|
149 | 149 | $replacements['$$calendar/-1/start$$'] = ''; |
150 | 150 | $replacements['$$calendar/-1/end$$'] = ''; |
151 | 151 | $replacements['$$calendar/-1/owner$$'] = ''; |
@@ -168,18 +168,18 @@ discard block |
||
168 | 168 | echo '<tr><td colspan="4"><h3>'.lang('Contact fields:')."</h3></td></tr>"; |
169 | 169 | |
170 | 170 | $n = 0; |
171 | - foreach($this->contacts->contact_fields as $name => $label) |
|
171 | + foreach ($this->contacts->contact_fields as $name => $label) |
|
172 | 172 | { |
173 | - if (in_array($name,array('tid','label','geo'))) continue; // dont show them, as they are not used in the UI atm. |
|
173 | + if (in_array($name, array('tid', 'label', 'geo'))) continue; // dont show them, as they are not used in the UI atm. |
|
174 | 174 | |
175 | - if (in_array($name,array('email','org_name','tel_work','url')) && $n&1) // main values, which should be in the first column |
|
175 | + if (in_array($name, array('email', 'org_name', 'tel_work', 'url')) && $n&1) // main values, which should be in the first column |
|
176 | 176 | { |
177 | 177 | echo "</tr>\n"; |
178 | 178 | $n++; |
179 | 179 | } |
180 | 180 | if (!($n&1)) echo '<tr>'; |
181 | 181 | echo '<td>{{'.$name.'}}</td><td>'.$label.'</td>'; |
182 | - if($name == 'cat_id') |
|
182 | + if ($name == 'cat_id') |
|
183 | 183 | { |
184 | 184 | if ($n&1) echo "</tr>\n"; |
185 | 185 | echo '<td>{{categories}}</td><td>'.lang('Category path').'</td>'; |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>"; |
193 | - foreach($this->contacts->customfields as $name => $field) |
|
193 | + foreach ($this->contacts->customfields as $name => $field) |
|
194 | 194 | { |
195 | 195 | echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n"; |
196 | 196 | } |
197 | 197 | |
198 | 198 | echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>"; |
199 | - foreach(array( |
|
199 | + foreach (array( |
|
200 | 200 | 'link' => lang('HTML link to the current record'), |
201 | 201 | 'links' => lang('Titles of any entries linked to the current record, excluding attached files'), |
202 | 202 | 'attachments' => lang('List of files linked to the current record'), |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | |
224 | 224 | Api\Translation::add_app('calendar'); |
225 | 225 | echo '<tr><td colspan="4"><h3>'.lang('Calendar fields:')." # = 1, 2, ..., 20, -1</h3></td></tr>"; |
226 | - foreach(array( |
|
226 | + foreach (array( |
|
227 | 227 | 'title' => lang('Title'), |
228 | 228 | 'description' => lang('Description'), |
229 | 229 | 'participants' => lang('Participants'), |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | 'owner' => lang('Owner'), |
246 | 246 | ) as $name => $label) |
247 | 247 | { |
248 | - if (in_array($name,array('start','end')) && $n&1) // main values, which should be in the first column |
|
248 | + if (in_array($name, array('start', 'end')) && $n&1) // main values, which should be in the first column |
|
249 | 249 | { |
250 | 250 | echo "</tr>\n"; |
251 | 251 | $n++; |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | * @param int|string $export_limit =null export-limit, default $GLOBALS['egw_info']['server']['export_limit'] |
275 | 275 | * @return array see nextmatch_widget::egw_actions |
276 | 276 | */ |
277 | - public static function document_action($dirs, $group=0, $caption='Insert in document', $prefix='document_', $default_doc='', |
|
278 | - $export_limit=null) |
|
277 | + public static function document_action($dirs, $group = 0, $caption = 'Insert in document', $prefix = 'document_', $default_doc = '', |
|
278 | + $export_limit = null) |
|
279 | 279 | { |
280 | 280 | $actions = parent::document_action($dirs, $group, $caption, $prefix, $default_doc, $export_limit); |
281 | 281 | |
@@ -287,14 +287,14 @@ discard block |
||
287 | 287 | |
288 | 288 | protected static function customise_mail_actions(&$action) |
289 | 289 | { |
290 | - if(strpos($action['egw_open'], 'edit-mail') === 0) |
|
290 | + if (strpos($action['egw_open'], 'edit-mail') === 0) |
|
291 | 291 | { |
292 | 292 | unset($action['confirm_multiple']); |
293 | 293 | $action['onExecute'] = 'javaScript:app.addressbook.merge_mail'; |
294 | 294 | } |
295 | 295 | else if ($action['children']) |
296 | 296 | { |
297 | - foreach($action['children'] as &$child) |
|
297 | + foreach ($action['children'] as &$child) |
|
298 | 298 | { |
299 | 299 | static::customise_mail_actions($child); |
300 | 300 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | 'config_app' => 'phpgwapi', |
119 | 119 | 'config_name' => array('system_charset','install_id','temp_dir'), |
120 | 120 | ),__LINE__,__FILE__) as $row) |
121 | - { |
|
121 | + { |
|
122 | 122 | $GLOBALS['egw_info']['server'][$row['config_name']] = $row['config_value']; |
123 | 123 | } |
124 | 124 | if ($GLOBALS['egw_info']['server']['system_charset'] && $GLOBALS['egw_info']['server']['system_charset'] != 'utf-8') |
@@ -131,11 +131,14 @@ discard block |
||
131 | 131 | // if no server timezone set, use date_default_timezone_get() to determine it once |
132 | 132 | // it fills to log with deprecated warnings under 5.3 otherwise |
133 | 133 | if (empty($GLOBALS['egw_info']['server']['server_timezone']) || |
134 | - $GLOBALS['egw_info']['server']['server_timezone'] == 'System/Localtime') // treat invalid tz like empty! |
|
134 | + $GLOBALS['egw_info']['server']['server_timezone'] == 'System/Localtime') |
|
135 | + { |
|
136 | + // treat invalid tz like empty! |
|
135 | 137 | { |
136 | 138 | try |
137 | 139 | { |
138 | 140 | $tz = new \DateTimeZone(date_default_timezone_get()); |
141 | + } |
|
139 | 142 | Config::save_value('server_timezone',$GLOBALS['egw_info']['server']['server_timezone'] = $tz->getName(),'phpgwapi'); |
140 | 143 | error_log(__METHOD__."() stored server_timezone=".$GLOBALS['egw_info']['server']['server_timezone']); |
141 | 144 | } |
@@ -301,14 +304,20 @@ discard block |
||
301 | 304 | exit; |
302 | 305 | } |
303 | 306 | // check if we have a session, if not try to automatic create one |
304 | - if ($this->session->verify()) return true; |
|
307 | + if ($this->session->verify()) |
|
308 | + { |
|
309 | + return true; |
|
310 | + } |
|
305 | 311 | |
306 | 312 | $account = null; |
307 | 313 | if (($account_callback = $GLOBALS['egw_info']['flags']['autocreate_session_callback']) && is_callable($account_callback) && |
308 | - ($sessionid = call_user_func_array($account_callback,array(&$account))) === true) // $account_call_back returns true, false or a session-id |
|
314 | + ($sessionid = call_user_func_array($account_callback,array(&$account))) === true) |
|
315 | + { |
|
316 | + // $account_call_back returns true, false or a session-id |
|
309 | 317 | { |
310 | 318 | $sessionid = $this->session->create($account); |
311 | 319 | } |
320 | + } |
|
312 | 321 | if (!$sessionid) |
313 | 322 | { |
314 | 323 | //echo "<p>account_callback='$account_callback', account=".print_r($account,true).", sessionid=$sessionid</p>\n"; exit; |
@@ -337,9 +346,15 @@ discard block |
||
337 | 346 | { |
338 | 347 | $redirect = '/login.php?'; |
339 | 348 | // only add "your session could not be verified", if a sessionid is given (cookie or on url) |
340 | - if (Session::get_sessionid()) $redirect .= 'cd=10&'; |
|
349 | + if (Session::get_sessionid()) |
|
350 | + { |
|
351 | + $redirect .= 'cd=10&'; |
|
352 | + } |
|
353 | + } |
|
354 | + if ($relpath) |
|
355 | + { |
|
356 | + $redirect .= 'phpgw_forward='.urlencode($relpath.(!empty($query) ? '?'.$query : '')); |
|
341 | 357 | } |
342 | - if ($relpath) $redirect .= 'phpgw_forward='.urlencode($relpath.(!empty($query) ? '?'.$query : '')); |
|
343 | 358 | self::redirect_link($redirect); |
344 | 359 | } |
345 | 360 | } |
@@ -357,7 +372,9 @@ discard block |
||
357 | 372 | { |
358 | 373 | $this->currentapp = $GLOBALS['egw_info']['flags']['currentapp']; // some apps change it later |
359 | 374 | |
360 | - if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('api','about'))) // give everyone implicit api rights |
|
375 | + if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('api','about'))) |
|
376 | + { |
|
377 | + // give everyone implicit api rights |
|
361 | 378 | { |
362 | 379 | // This will need to use ACL in the future |
363 | 380 | if (!$GLOBALS['egw_info']['user']['apps'][$currentapp = $GLOBALS['egw_info']['flags']['currentapp']] || |
@@ -370,6 +387,7 @@ discard block |
||
370 | 387 | if (($sessionid = Session::get_sessionid(true))) |
371 | 388 | { |
372 | 389 | $GLOBALS['egw']->session->destroy($sessionid); |
390 | + } |
|
373 | 391 | } |
374 | 392 | throw new Exception\Redirect(self::link('/logout.php')); |
375 | 393 | } |
@@ -555,7 +573,10 @@ discard block |
||
555 | 573 | try { |
556 | 574 | //error_log(__METHOD__."() running ".array2string($data)); |
557 | 575 | $callback = array_shift($data); |
558 | - if (!is_array($callback) || strpos($callback[1], 'session') === false) continue; |
|
576 | + if (!is_array($callback) || strpos($callback[1], 'session') === false) |
|
577 | + { |
|
578 | + continue; |
|
579 | + } |
|
559 | 580 | call_user_func_array($callback, $data); |
560 | 581 | } |
561 | 582 | catch (\Exception $ex) { |
@@ -565,7 +586,10 @@ discard block |
||
565 | 586 | } |
566 | 587 | // now we can close the session |
567 | 588 | // without closing the session fastcgi_finish_request() will NOT send output to user |
568 | - if (isset($GLOBALS['egw']->session) && is_object($GLOBALS['egw']->session)) $GLOBALS['egw']->session->commit_session(); |
|
589 | + if (isset($GLOBALS['egw']->session) && is_object($GLOBALS['egw']->session)) |
|
590 | + { |
|
591 | + $GLOBALS['egw']->session->commit_session(); |
|
592 | + } |
|
569 | 593 | |
570 | 594 | // flush all output to user |
571 | 595 | /* does NOT work on Apache :-( |
@@ -593,9 +617,12 @@ discard block |
||
593 | 617 | } |
594 | 618 | } |
595 | 619 | // call the asyncservice check_run function if it is not explicitly set to cron-only |
596 | - if (!$GLOBALS['egw_info']['server']['asyncservice']) // is default |
|
620 | + if (!$GLOBALS['egw_info']['server']['asyncservice']) |
|
621 | + { |
|
622 | + // is default |
|
597 | 623 | { |
598 | 624 | $async = new Asyncservice(); |
625 | + } |
|
599 | 626 | $async->check_run('fallback'); |
600 | 627 | } |
601 | 628 | $this->db->disconnect(); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @var string |
45 | 45 | * @access public |
46 | 46 | */ |
47 | - var $debug = 0; // This will turn on debugging information. |
|
47 | + var $debug = 0; // This will turn on debugging information. |
|
48 | 48 | /** |
49 | 49 | * Instance of the account object |
50 | 50 | * |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | * @author [email protected] |
59 | 59 | * @param array $domain_names array with valid egw-domain names |
60 | 60 | */ |
61 | - function __construct($domain_names=null) |
|
61 | + function __construct($domain_names = null) |
|
62 | 62 | { |
63 | - $GLOBALS['egw'] =& $this; // we need to be immediately available there for the other classes we instantiate |
|
64 | - $this->setup($domain_names,True); |
|
63 | + $GLOBALS['egw'] = & $this; // we need to be immediately available there for the other classes we instantiate |
|
64 | + $this->setup($domain_names, True); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param array|null $domain_names =null array with valid egw-domain names |
72 | 72 | * @param boolean $createsessionobject True to create the session object (default=True) |
73 | 73 | */ |
74 | - function setup($domain_names,$createsessionobject=True) |
|
74 | + function setup($domain_names, $createsessionobject = True) |
|
75 | 75 | { |
76 | 76 | // create the DB-object |
77 | 77 | // as SiteMgr, Wiki, KnowledgeBase and probably more still use eg next_record(), we stick with Db\Deprecated for now |
@@ -85,18 +85,18 @@ discard block |
||
85 | 85 | // check if eGW is already setup, if not redirect to setup/ |
86 | 86 | try { |
87 | 87 | $this->db->connect(); |
88 | - $num_config = $this->db->select(Config::TABLE,'COUNT(config_name)',false,__LINE__,__FILE__)->fetchColumn(); |
|
88 | + $num_config = $this->db->select(Config::TABLE, 'COUNT(config_name)', false, __LINE__, __FILE__)->fetchColumn(); |
|
89 | 89 | } |
90 | - catch(Db\Exception\Connection $e) { |
|
90 | + catch (Db\Exception\Connection $e) { |
|
91 | 91 | // ignore exception, get handled below |
92 | 92 | } |
93 | - catch(Db\Exception\InvalidSql $e1) { |
|
94 | - unset($e1); // not used |
|
93 | + catch (Db\Exception\InvalidSql $e1) { |
|
94 | + unset($e1); // not used |
|
95 | 95 | try { |
96 | - $phpgw_config = $this->db->select('phpgw_config','COUNT(config_name)',false,__LINE__,__FILE__)->fetchColumn(); |
|
96 | + $phpgw_config = $this->db->select('phpgw_config', 'COUNT(config_name)', false, __LINE__, __FILE__)->fetchColumn(); |
|
97 | 97 | } |
98 | 98 | catch (Db\Exception\InvalidSql $e2) { |
99 | - unset($e2); // not used |
|
99 | + unset($e2); // not used |
|
100 | 100 | // ignor error, get handled below |
101 | 101 | } |
102 | 102 | } |
@@ -105,20 +105,20 @@ discard block |
||
105 | 105 | // we check for the old table too, to not scare updating users ;-) |
106 | 106 | if ($phpgw_config) |
107 | 107 | { |
108 | - throw new Exception('You need to update EGroupware before you can continue using it.',999); |
|
108 | + throw new Exception('You need to update EGroupware before you can continue using it.', 999); |
|
109 | 109 | } |
110 | 110 | if ($e) |
111 | 111 | { |
112 | 112 | throw new Db\Exception\Setup('Connection with '.$e->getMessage()."\n\n". |
113 | - 'Maybe you not created a database for EGroupware yet.',999); |
|
113 | + 'Maybe you not created a database for EGroupware yet.', 999); |
|
114 | 114 | } |
115 | - throw new Db\Exception\Setup('It appears that you have not created the database tables for EGroupware.',999); |
|
115 | + throw new Db\Exception\Setup('It appears that you have not created the database tables for EGroupware.', 999); |
|
116 | 116 | } |
117 | 117 | // Set the DB's client charset if a system-charset is set and some other values needed by egw_cache (used in Config::read) |
118 | - foreach($this->db->select(Config::TABLE,'config_name,config_value',array( |
|
118 | + foreach ($this->db->select(Config::TABLE, 'config_name,config_value', array( |
|
119 | 119 | 'config_app' => 'phpgwapi', |
120 | - 'config_name' => array('system_charset','install_id','temp_dir'), |
|
121 | - ),__LINE__,__FILE__) as $row) |
|
120 | + 'config_name' => array('system_charset', 'install_id', 'temp_dir'), |
|
121 | + ), __LINE__, __FILE__) as $row) |
|
122 | 122 | { |
123 | 123 | $GLOBALS['egw_info']['server'][$row['config_name']] = $row['config_value']; |
124 | 124 | } |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | try |
153 | 153 | { |
154 | 154 | $tz = new \DateTimeZone(date_default_timezone_get()); |
155 | - Config::save_value('server_timezone',$GLOBALS['egw_info']['server']['server_timezone'] = $tz->getName(),'phpgwapi'); |
|
155 | + Config::save_value('server_timezone', $GLOBALS['egw_info']['server']['server_timezone'] = $tz->getName(), 'phpgwapi'); |
|
156 | 156 | error_log(__METHOD__."() stored server_timezone=".$GLOBALS['egw_info']['server']['server_timezone']); |
157 | 157 | } |
158 | - catch(Exception $e) |
|
158 | + catch (Exception $e) |
|
159 | 159 | { |
160 | 160 | // do nothing if new DateTimeZone fails (eg. 'System/Localtime' returned), specially do NOT store it! |
161 | 161 | error_log(__METHOD__."() NO valid 'date.timezone' set in your php.ini!"); |
@@ -166,24 +166,24 @@ discard block |
||
166 | 166 | // if phpgwapi exists we prefer accounts and egw_session, as they have some deprecated methods |
167 | 167 | if (file_exists(EGW_SERVER_ROOT.'/phpgwapi')) |
168 | 168 | { |
169 | - $this->accounts = new egw_accounts(); |
|
169 | + $this->accounts = new egw_accounts(); |
|
170 | 170 | /* Do not create the session object if called by the sessions class. This way |
171 | 171 | * we ensure the correct db based on the user domain. |
172 | 172 | */ |
173 | - if($createsessionobject) |
|
173 | + if ($createsessionobject) |
|
174 | 174 | { |
175 | - $this->session = new egw_session($domain_names); |
|
175 | + $this->session = new egw_session($domain_names); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | else |
179 | 179 | { |
180 | - $this->accounts = new Accounts(); |
|
180 | + $this->accounts = new Accounts(); |
|
181 | 181 | /* Do not create the session object if called by the sessions class. This way |
182 | 182 | * we ensure the correct db based on the user domain. |
183 | 183 | */ |
184 | - if($createsessionobject) |
|
184 | + if ($createsessionobject) |
|
185 | 185 | { |
186 | - $this->session = new Session($domain_names); |
|
186 | + $this->session = new Session($domain_names); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | // setup the other subclasses |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login' && $GLOBALS['egw_info']['flags']['currentapp'] != 'logout') |
195 | 195 | { |
196 | 196 | $this->verify_session(); |
197 | - $this->applications->read_installed_apps(); // to get translated app-titles, has to be after verify_session |
|
197 | + $this->applications->read_installed_apps(); // to get translated app-titles, has to be after verify_session |
|
198 | 198 | |
199 | 199 | $this->define_egw_constants(); |
200 | 200 | |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | */ |
216 | 216 | function __wakeup() |
217 | 217 | { |
218 | - $GLOBALS['egw'] =& $this; // we need to be immediately available there for the other classes we instantiate |
|
218 | + $GLOBALS['egw'] = & $this; // we need to be immediately available there for the other classes we instantiate |
|
219 | 219 | // for the migration: reference us to the old phpgw object |
220 | - $GLOBALS['phpgw'] =& $this; |
|
220 | + $GLOBALS['phpgw'] = & $this; |
|
221 | 221 | |
222 | 222 | if ($GLOBALS['egw_info']['server']['system_charset']) |
223 | 223 | { |
@@ -279,15 +279,15 @@ discard block |
||
279 | 279 | if (defined('EGW_APP_INC')) |
280 | 280 | { |
281 | 281 | // Load the (depricated) app include files if they exists |
282 | - if (EGW_APP_INC != "" && ! preg_match ('/phpgwapi/i', EGW_APP_INC) && |
|
283 | - file_exists(EGW_APP_INC . '/functions.inc.php') && !isset($_GET['menuaction'])) |
|
282 | + if (EGW_APP_INC != "" && !preg_match('/phpgwapi/i', EGW_APP_INC) && |
|
283 | + file_exists(EGW_APP_INC.'/functions.inc.php') && !isset($_GET['menuaction'])) |
|
284 | 284 | { |
285 | - include(EGW_APP_INC . '/functions.inc.php'); |
|
285 | + include(EGW_APP_INC.'/functions.inc.php'); |
|
286 | 286 | } |
287 | 287 | if (!@$GLOBALS['egw_info']['flags']['noheader'] && !@$GLOBALS['egw_info']['flags']['noappheader'] && |
288 | - file_exists(EGW_APP_INC . '/header.inc.php') && !isset($_GET['menuaction'])) |
|
288 | + file_exists(EGW_APP_INC.'/header.inc.php') && !isset($_GET['menuaction'])) |
|
289 | 289 | { |
290 | - include(EGW_APP_INC . '/header.inc.php'); |
|
290 | + include(EGW_APP_INC.'/header.inc.php'); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | } |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | */ |
305 | 305 | function verify_session() |
306 | 306 | { |
307 | - if($GLOBALS['egw_info']['server']['enforce_ssl'] === 'redirect' && !$_SERVER['HTTPS']) |
|
307 | + if ($GLOBALS['egw_info']['server']['enforce_ssl'] === 'redirect' && !$_SERVER['HTTPS']) |
|
308 | 308 | { |
309 | - Header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
|
309 | + Header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
310 | 310 | exit; |
311 | 311 | } |
312 | 312 | // check if we have a session, if not try to automatic create one |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | |
315 | 315 | $account = null; |
316 | 316 | if (($account_callback = $GLOBALS['egw_info']['flags']['autocreate_session_callback']) && is_callable($account_callback) && |
317 | - ($sessionid = call_user_func_array($account_callback,array(&$account))) === true) // $account_call_back returns true, false or a session-id |
|
317 | + ($sessionid = call_user_func_array($account_callback, array(&$account))) === true) // $account_call_back returns true, false or a session-id |
|
318 | 318 | { |
319 | 319 | $sessionid = $this->session->create($account); |
320 | 320 | } |
@@ -323,15 +323,15 @@ discard block |
||
323 | 323 | //echo "<p>account_callback='$account_callback', account=".print_r($account,true).", sessionid=$sessionid</p>\n"; exit; |
324 | 324 | // we forward to the same place after the re-login |
325 | 325 | if ($GLOBALS['egw_info']['server']['webserver_url'] && $GLOBALS['egw_info']['server']['webserver_url'] != '/' && |
326 | - ($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'],PHP_URL_PATH)) && $webserver_path != '/') |
|
326 | + ($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'], PHP_URL_PATH)) && $webserver_path != '/') |
|
327 | 327 | { |
328 | 328 | // we have to use only path component, to cope with domains like http://egroupware.domain.com and /egroupware |
329 | - list(,$relpath) = explode($webserver_path,parse_url($_SERVER['PHP_SELF'],PHP_URL_PATH),2); |
|
329 | + list(,$relpath) = explode($webserver_path, parse_url($_SERVER['PHP_SELF'], PHP_URL_PATH), 2); |
|
330 | 330 | } |
331 | 331 | else // the webserver-url is empty or just a slash '/' (eGW is installed in the docroot and no domain given) |
332 | 332 | { |
333 | 333 | $matches = null; |
334 | - if (preg_match('/^https?:\/\/[^\/]*\/(.*)$/',$relpath=$_SERVER['PHP_SELF'],$matches)) |
|
334 | + if (preg_match('/^https?:\/\/[^\/]*\/(.*)$/', $relpath = $_SERVER['PHP_SELF'], $matches)) |
|
335 | 335 | { |
336 | 336 | $relpath = $matches[1]; |
337 | 337 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | header('Pragma: no-cache'); |
344 | 344 | |
345 | 345 | // this removes the sessiondata if its saved in the URL |
346 | - $query = preg_replace('/[&]?sessionid(=|%3D)[^&]+&kp3(=|%3D)[^&]+&domain=.*$/','',$_SERVER['QUERY_STRING']); |
|
346 | + $query = preg_replace('/[&]?sessionid(=|%3D)[^&]+&kp3(=|%3D)[^&]+&domain=.*$/', '', $_SERVER['QUERY_STRING']); |
|
347 | 347 | if ($GLOBALS['egw_info']['server']['http_auth_types']) |
348 | 348 | { |
349 | 349 | $redirect = '/api/ntlm/index.php?'; |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | */ |
371 | 371 | function check_app_rights() |
372 | 372 | { |
373 | - $this->currentapp = $GLOBALS['egw_info']['flags']['currentapp']; // some apps change it later |
|
373 | + $this->currentapp = $GLOBALS['egw_info']['flags']['currentapp']; // some apps change it later |
|
374 | 374 | |
375 | - if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('api','about'))) // give everyone implicit api rights |
|
375 | + if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('api', 'about'))) // give everyone implicit api rights |
|
376 | 376 | { |
377 | 377 | // This will need to use ACL in the future |
378 | 378 | if (!$GLOBALS['egw_info']['user']['apps'][$currentapp = $GLOBALS['egw_info']['flags']['currentapp']] || |
@@ -402,25 +402,25 @@ discard block |
||
402 | 402 | */ |
403 | 403 | function define_egw_constants() |
404 | 404 | { |
405 | - define('EGW_ACL_READ',1); |
|
406 | - define('EGW_ACL_ADD',2); |
|
407 | - define('EGW_ACL_EDIT',4); |
|
408 | - define('EGW_ACL_DELETE',8); |
|
409 | - define('EGW_ACL_PRIVATE',16); |
|
410 | - define('EGW_ACL_GROUP_MANAGERS',32); |
|
411 | - define('EGW_ACL_CUSTOM_1',64); |
|
412 | - define('EGW_ACL_CUSTOM_2',128); |
|
413 | - define('EGW_ACL_CUSTOM_3',256); |
|
405 | + define('EGW_ACL_READ', 1); |
|
406 | + define('EGW_ACL_ADD', 2); |
|
407 | + define('EGW_ACL_EDIT', 4); |
|
408 | + define('EGW_ACL_DELETE', 8); |
|
409 | + define('EGW_ACL_PRIVATE', 16); |
|
410 | + define('EGW_ACL_GROUP_MANAGERS', 32); |
|
411 | + define('EGW_ACL_CUSTOM_1', 64); |
|
412 | + define('EGW_ACL_CUSTOM_2', 128); |
|
413 | + define('EGW_ACL_CUSTOM_3', 256); |
|
414 | 414 | // and the old ones |
415 | - define('PHPGW_ACL_READ',1); |
|
416 | - define('PHPGW_ACL_ADD',2); |
|
417 | - define('PHPGW_ACL_EDIT',4); |
|
418 | - define('PHPGW_ACL_DELETE',8); |
|
419 | - define('PHPGW_ACL_PRIVATE',16); |
|
420 | - define('PHPGW_ACL_GROUP_MANAGERS',32); |
|
421 | - define('PHPGW_ACL_CUSTOM_1',64); |
|
422 | - define('PHPGW_ACL_CUSTOM_2',128); |
|
423 | - define('PHPGW_ACL_CUSTOM_3',256); |
|
415 | + define('PHPGW_ACL_READ', 1); |
|
416 | + define('PHPGW_ACL_ADD', 2); |
|
417 | + define('PHPGW_ACL_EDIT', 4); |
|
418 | + define('PHPGW_ACL_DELETE', 8); |
|
419 | + define('PHPGW_ACL_PRIVATE', 16); |
|
420 | + define('PHPGW_ACL_GROUP_MANAGERS', 32); |
|
421 | + define('PHPGW_ACL_CUSTOM_1', 64); |
|
422 | + define('PHPGW_ACL_CUSTOM_2', 128); |
|
423 | + define('PHPGW_ACL_CUSTOM_3', 256); |
|
424 | 424 | // A few hacker resistant constants that will be used throught the program |
425 | 425 | if (file_exists(EGW_SERVER_ROOT.'/phpgwapi')) |
426 | 426 | { |
@@ -439,14 +439,14 @@ discard block |
||
439 | 439 | define('EGW_IMAGES', common::get_image_path()); |
440 | 440 | define('EGW_APP_IMAGES_DIR', common::get_image_dir()); |
441 | 441 | // and the old ones |
442 | - define('PHPGW_TEMPLATE_DIR',EGW_TEMPLATE_DIR); |
|
443 | - define('PHPGW_IMAGES_DIR',EGW_IMAGES_DIR); |
|
444 | - define('PHPGW_IMAGES_FILEDIR',EGW_IMAGES_FILEDIR); |
|
445 | - define('PHPGW_APP_ROOT',EGW_APP_ROOT); |
|
446 | - define('PHPGW_APP_INC',EGW_APP_INC); |
|
447 | - define('PHPGW_APP_TPL',EGW_APP_TPL); |
|
448 | - define('PHPGW_IMAGES',EGW_IMAGES); |
|
449 | - define('PHPGW_APP_IMAGES_DIR',EGW_APP_IMAGES_DIR); |
|
442 | + define('PHPGW_TEMPLATE_DIR', EGW_TEMPLATE_DIR); |
|
443 | + define('PHPGW_IMAGES_DIR', EGW_IMAGES_DIR); |
|
444 | + define('PHPGW_IMAGES_FILEDIR', EGW_IMAGES_FILEDIR); |
|
445 | + define('PHPGW_APP_ROOT', EGW_APP_ROOT); |
|
446 | + define('PHPGW_APP_INC', EGW_APP_INC); |
|
447 | + define('PHPGW_APP_TPL', EGW_APP_TPL); |
|
448 | + define('PHPGW_IMAGES', EGW_IMAGES); |
|
449 | + define('PHPGW_APP_IMAGES_DIR', EGW_APP_IMAGES_DIR); |
|
450 | 450 | } |
451 | 451 | } |
452 | 452 | |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | * @param string $link_app =null if appname or true, some templates generate a special link-handler url |
486 | 486 | * @return string The full url after processing |
487 | 487 | */ |
488 | - static function link($url, $extravars = '', $link_app=null) |
|
488 | + static function link($url, $extravars = '', $link_app = null) |
|
489 | 489 | { |
490 | 490 | return $GLOBALS['egw']->framework->link($url, $extravars, $link_app); |
491 | 491 | } |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | * @param string $link_app =null if appname or true, some templates generate a special link-handler url |
499 | 499 | * @return string The full url after processing |
500 | 500 | */ |
501 | - static function redirect_link($url, $extravars='', $link_app=null) |
|
501 | + static function redirect_link($url, $extravars = '', $link_app = null) |
|
502 | 502 | { |
503 | 503 | return $GLOBALS['egw']->framework->redirect_link($url, $extravars, $link_app); |
504 | 504 | } |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | * @param string $url url to redirect to |
512 | 512 | * @param string $link_app =null appname to redirect for, default currentapp |
513 | 513 | */ |
514 | - static function redirect($url, $link_app=null) |
|
514 | + static function redirect($url, $link_app = null) |
|
515 | 515 | { |
516 | 516 | Framework::redirect($url, $link_app); |
517 | 517 | } |
@@ -525,14 +525,14 @@ discard block |
||
525 | 525 | * @param string The key for the phrase |
526 | 526 | * @see Translation::translate() |
527 | 527 | */ |
528 | - static function lang($key,$args=null) |
|
528 | + static function lang($key, $args = null) |
|
529 | 529 | { |
530 | 530 | if (!is_array($args)) |
531 | 531 | { |
532 | 532 | $args = func_get_args(); |
533 | 533 | array_shift($args); |
534 | 534 | } |
535 | - return Translation::translate($key,$args); |
|
535 | + return Translation::translate($key, $args); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | * @param callable $callback use array($classname, $method) for static methods |
552 | 552 | * @param array $args =array() |
553 | 553 | */ |
554 | - public static function on_shutdown($callback, array $args=array()) |
|
554 | + public static function on_shutdown($callback, array $args = array()) |
|
555 | 555 | { |
556 | 556 | array_unshift($args, $callback); |
557 | 557 | |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | { |
567 | 567 | if (!defined('EGW_SHUTDOWN')) |
568 | 568 | { |
569 | - define('EGW_SHUTDOWN',True); |
|
569 | + define('EGW_SHUTDOWN', True); |
|
570 | 570 | |
571 | 571 | // send json response BEFORE flushing output |
572 | 572 | if (Json\Request::isJSONRequest()) |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | } |
576 | 576 | |
577 | 577 | // run all on_shutdown callbacks with session in their name (eg. egw_link::save_session_cache), do NOT stop on exceptions |
578 | - foreach(self::$shutdown_callbacks as $n => $data) |
|
578 | + foreach (self::$shutdown_callbacks as $n => $data) |
|
579 | 579 | { |
580 | 580 | try { |
581 | 581 | //error_log(__METHOD__."() running ".array2string($data)); |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | } |
607 | 607 | |
608 | 608 | // run all on_shutdown, do NOT stop on exceptions |
609 | - foreach(self::$shutdown_callbacks as $data) |
|
609 | + foreach (self::$shutdown_callbacks as $data) |
|
610 | 610 | { |
611 | 611 | try { |
612 | 612 | //error_log(__METHOD__."() running ".array2string($data)); |
@@ -1500,7 +1500,7 @@ discard block |
||
1500 | 1500 | * @param array $options Array of options for the search |
1501 | 1501 | * @return array with id - title pairs of the matching entries |
1502 | 1502 | */ |
1503 | - function link_query($pattern, Array &$options = array()) |
|
1503 | + function link_query($pattern, array &$options = array()) |
|
1504 | 1504 | { |
1505 | 1505 | $result = $criteria = array(); |
1506 | 1506 | $limit = false; |
@@ -1553,7 +1553,7 @@ discard block |
||
1553 | 1553 | * @param array $options |
1554 | 1554 | * @return Ambigous <multitype:, string, multitype:Ambigous <multitype:, string> string > |
1555 | 1555 | */ |
1556 | - function link_query_email($pattern, Array &$options = array()) |
|
1556 | + function link_query_email($pattern, array &$options = array()) |
|
1557 | 1557 | { |
1558 | 1558 | if (isset($options['filter']) && !is_array($options['filter'])) |
1559 | 1559 | { |
@@ -152,19 +152,19 @@ discard block |
||
152 | 152 | var $categories; |
153 | 153 | |
154 | 154 | /** |
155 | - * Tracking changes |
|
156 | - * |
|
157 | - * @var Contacts\Tracking |
|
158 | - */ |
|
155 | + * Tracking changes |
|
156 | + * |
|
157 | + * @var Contacts\Tracking |
|
158 | + */ |
|
159 | 159 | protected $tracking; |
160 | 160 | |
161 | 161 | /** |
162 | - * Keep deleted addresses, or really delete them |
|
163 | - * Set in Admin -> Addressbook -> Site Configuration |
|
164 | - * ''=really delete, 'history'=keep, only admins delete, 'userpurge'=keep, users delete |
|
165 | - * |
|
166 | - * @var string |
|
167 | - */ |
|
162 | + * Keep deleted addresses, or really delete them |
|
163 | + * Set in Admin -> Addressbook -> Site Configuration |
|
164 | + * ''=really delete, 'history'=keep, only admins delete, 'userpurge'=keep, users delete |
|
165 | + * |
|
166 | + * @var string |
|
167 | + */ |
|
168 | 168 | protected $delete_history = ''; |
169 | 169 | |
170 | 170 | /** |
@@ -797,13 +797,13 @@ discard block |
||
797 | 797 | } |
798 | 798 | |
799 | 799 | /** |
800 | - * deletes contact in db |
|
801 | - * |
|
802 | - * @param mixed &$contact contact array with key id or (array of) id(s) |
|
803 | - * @param boolean $deny_account_delete =true if true never allow to delete accounts |
|
804 | - * @param int $check_etag =null |
|
805 | - * @return boolean|int true on success or false on failiure, 0 if etag does not match |
|
806 | - */ |
|
800 | + * deletes contact in db |
|
801 | + * |
|
802 | + * @param mixed &$contact contact array with key id or (array of) id(s) |
|
803 | + * @param boolean $deny_account_delete =true if true never allow to delete accounts |
|
804 | + * @param int $check_etag =null |
|
805 | + * @return boolean|int true on success or false on failiure, 0 if etag does not match |
|
806 | + */ |
|
807 | 807 | function delete($contact,$deny_account_delete=true,$check_etag=null) |
808 | 808 | { |
809 | 809 | if (is_array($contact) && isset($contact['id'])) |
@@ -855,13 +855,13 @@ discard block |
||
855 | 855 | } |
856 | 856 | |
857 | 857 | /** |
858 | - * saves contact to db |
|
859 | - * |
|
860 | - * @param array &$contact contact array from etemplate::exec |
|
861 | - * @param boolean $ignore_acl =false should the acl be checked or not |
|
862 | - * @param boolean $touch_modified =true should modified/r be updated |
|
863 | - * @return int/string/boolean id on success, false on failure, the error-message is in $this->error |
|
864 | - */ |
|
858 | + * saves contact to db |
|
859 | + * |
|
860 | + * @param array &$contact contact array from etemplate::exec |
|
861 | + * @param boolean $ignore_acl =false should the acl be checked or not |
|
862 | + * @param boolean $touch_modified =true should modified/r be updated |
|
863 | + * @return int/string/boolean id on success, false on failure, the error-message is in $this->error |
|
864 | + */ |
|
865 | 865 | function save(&$contact, $ignore_acl=false, $touch_modified=true) |
866 | 866 | { |
867 | 867 | // Make sure photo remains unchanged unless its purposely set to be false |
@@ -1110,12 +1110,12 @@ discard block |
||
1110 | 1110 | } |
1111 | 1111 | |
1112 | 1112 | /** |
1113 | - * reads contacts matched by key and puts all cols in the data array |
|
1114 | - * |
|
1115 | - * @param int|string $contact_id |
|
1116 | - * @param boolean $ignore_acl =false true: no acl check |
|
1117 | - * @return array|boolean array with contact data, null if not found or false on no view perms |
|
1118 | - */ |
|
1113 | + * reads contacts matched by key and puts all cols in the data array |
|
1114 | + * |
|
1115 | + * @param int|string $contact_id |
|
1116 | + * @param boolean $ignore_acl =false true: no acl check |
|
1117 | + * @return array|boolean array with contact data, null if not found or false on no view perms |
|
1118 | + */ |
|
1119 | 1119 | function read($contact_id, $ignore_acl=false) |
1120 | 1120 | { |
1121 | 1121 | // get so_sql_cf to read private customfields too, if we ignore acl |
@@ -495,7 +495,6 @@ discard block |
||
495 | 495 | /** |
496 | 496 | * get selectbox options for the customfields |
497 | 497 | * |
498 | - * @param array $field =null |
|
499 | 498 | * @return array with options: |
500 | 499 | */ |
501 | 500 | public static function cf_options() |
@@ -547,7 +546,7 @@ discard block |
||
547 | 546 | * @param string $fileas_type '' or type of $this->fileas_types |
548 | 547 | * @param int $all =false update all contacts or only ones with empty values |
549 | 548 | * @param int &$errors=null on return number of errors |
550 | - * @return int|boolean number of contacts updated, false for wrong fileas type |
|
549 | + * @return string|null number of contacts updated, false for wrong fileas type |
|
551 | 550 | */ |
552 | 551 | function set_all_fileas($fileas_type,$all=false,&$errors=null,$ignore_acl=false) |
553 | 552 | { |
@@ -608,7 +607,7 @@ discard block |
||
608 | 607 | * remove unneeded carriage returns or set empty fields to NULL |
609 | 608 | * |
610 | 609 | * @param int &$errors=null on return number of errors |
611 | - * @return int|boolean number of contacts updated |
|
610 | + * @return string|null number of contacts updated |
|
612 | 611 | */ |
613 | 612 | function set_all_cleanup(&$errors=null,$ignore_acl=false) |
614 | 613 | { |
@@ -1066,7 +1065,7 @@ discard block |
||
1066 | 1065 | * Since birthdays are cached for the instance for BIRTHDAY_CACHE_TIME, we |
1067 | 1066 | * need to clear them if a birthday changes. |
1068 | 1067 | * |
1069 | - * @param type $year |
|
1068 | + * @param integer $year |
|
1070 | 1069 | */ |
1071 | 1070 | protected function clear_birthday_cache($year, $owner) |
1072 | 1071 | { |
@@ -1178,7 +1177,7 @@ discard block |
||
1178 | 1177 | * @param mixed $contact contact as array or the contact-id |
1179 | 1178 | * @param boolean $deny_account_delete =false if true never allow to delete accounts |
1180 | 1179 | * @param int $user =null for which user to check, default current user |
1181 | - * @return boolean true permission granted, false for permission denied, null for contact does not exist |
|
1180 | + * @return null|boolean true permission granted, false for permission denied, null for contact does not exist |
|
1182 | 1181 | */ |
1183 | 1182 | function check_perms($needed,$contact,$deny_account_delete=false,$user=null) |
1184 | 1183 | { |
@@ -1239,7 +1238,7 @@ discard block |
||
1239 | 1238 | * @param int $check Acl::READ for read and Acl::EDIT for write or delete access |
1240 | 1239 | * @param string $rel_path =null currently not used in InfoLog |
1241 | 1240 | * @param int $user =null for which user to check, default current user |
1242 | - * @return boolean true if access is granted or false otherwise |
|
1241 | + * @return null|boolean true if access is granted or false otherwise |
|
1243 | 1242 | */ |
1244 | 1243 | function file_access($id,$check,$rel_path=null,$user=null) |
1245 | 1244 | { |
@@ -2251,6 +2250,9 @@ discard block |
||
2251 | 2250 | return $cat_id_list; |
2252 | 2251 | } |
2253 | 2252 | |
2253 | + /** |
|
2254 | + * @param string $cat_id_list |
|
2255 | + */ |
|
2254 | 2256 | function get_categories($cat_id_list) |
2255 | 2257 | { |
2256 | 2258 | if (!is_object($this->categories)) |
@@ -301,7 +301,10 @@ discard block |
||
301 | 301 | ); |
302 | 302 | //_debug_array($this->contact_fields); |
303 | 303 | $this->own_account_acl = $GLOBALS['egw_info']['server']['own_account_acl']; |
304 | - if (!is_array($this->own_account_acl)) $this->own_account_acl = json_php_unserialize($this->own_account_acl, true); |
|
304 | + if (!is_array($this->own_account_acl)) |
|
305 | + { |
|
306 | + $this->own_account_acl = json_php_unserialize($this->own_account_acl, true); |
|
307 | + } |
|
305 | 308 | // we have only one acl (n_fn) for the whole name, as not all backends store every part in an own field |
306 | 309 | if ($this->own_account_acl && in_array('n_fn',$this->own_account_acl)) |
307 | 310 | { |
@@ -310,7 +313,10 @@ discard block |
||
310 | 313 | if ($GLOBALS['egw_info']['server']['org_fileds_to_update']) |
311 | 314 | { |
312 | 315 | $this->org_fields = $GLOBALS['egw_info']['server']['org_fileds_to_update']; |
313 | - if (!is_array($this->org_fields)) $this->org_fields = unserialize($this->org_fields); |
|
316 | + if (!is_array($this->org_fields)) |
|
317 | + { |
|
318 | + $this->org_fields = unserialize($this->org_fields); |
|
319 | + } |
|
314 | 320 | |
315 | 321 | // Set country code if country name is selected |
316 | 322 | $supported_fields = $this->get_fields('supported',null,0); |
@@ -367,7 +373,10 @@ discard block |
||
367 | 373 | } |
368 | 374 | |
369 | 375 | $addressbooks = $to_sort = array(); |
370 | - if ($extra_label) $addressbooks[''] = $extra_label; |
|
376 | + if ($extra_label) |
|
377 | + { |
|
378 | + $addressbooks[''] = $extra_label; |
|
379 | + } |
|
371 | 380 | $addressbooks[$user] = lang('Personal'); |
372 | 381 | // add all group addressbooks the user has the necessary rights too |
373 | 382 | foreach($grants as $uid => $rights) |
@@ -421,10 +430,19 @@ discard block |
||
421 | 430 | */ |
422 | 431 | function fileas($contact,$type=null, $isUpdate=false) |
423 | 432 | { |
424 | - if (is_null($type)) $type = $contact['fileas_type']; |
|
425 | - if (!$type) $type = $this->prefs['fileas_default'] ? $this->prefs['fileas_default'] : $this->fileas_types[0]; |
|
433 | + if (is_null($type)) |
|
434 | + { |
|
435 | + $type = $contact['fileas_type']; |
|
436 | + } |
|
437 | + if (!$type) |
|
438 | + { |
|
439 | + $type = $this->prefs['fileas_default'] ? $this->prefs['fileas_default'] : $this->fileas_types[0]; |
|
440 | + } |
|
426 | 441 | |
427 | - if (strpos($type,'n_fn') !== false) $contact['n_fn'] = $this->fullname($contact); |
|
442 | + if (strpos($type,'n_fn') !== false) |
|
443 | + { |
|
444 | + $contact['n_fn'] = $this->fullname($contact); |
|
445 | + } |
|
428 | 446 | |
429 | 447 | if($isUpdate) |
430 | 448 | { |
@@ -434,7 +452,10 @@ discard block |
||
434 | 452 | { |
435 | 453 | if(!isset($contact[$field])) |
436 | 454 | { |
437 | - if(is_null($old)) $old = $this->read($contact['id']); |
|
455 | + if(is_null($old)) |
|
456 | + { |
|
457 | + $old = $this->read($contact['id']); |
|
458 | + } |
|
438 | 459 | $contact[$field] = $old[$field]; |
439 | 460 | } |
440 | 461 | } |
@@ -477,7 +498,10 @@ discard block |
||
477 | 498 | */ |
478 | 499 | function fileas_type($contact,$file_as=null) |
479 | 500 | { |
480 | - if (is_null($file_as)) $file_as = $contact['n_fileas']; |
|
501 | + if (is_null($file_as)) |
|
502 | + { |
|
503 | + $file_as = $contact['n_fileas']; |
|
504 | + } |
|
481 | 505 | |
482 | 506 | if ($file_as) |
483 | 507 | { |
@@ -530,7 +554,10 @@ discard block |
||
530 | 554 | ); |
531 | 555 | foreach(array_keys($labels) as $name) |
532 | 556 | { |
533 | - if ($contact[$name]) $labels[$name] = $contact[$name]; |
|
557 | + if ($contact[$name]) |
|
558 | + { |
|
559 | + $labels[$name] = $contact[$name]; |
|
560 | + } |
|
534 | 561 | } |
535 | 562 | foreach($this->fileas_types as $fileas_type) |
536 | 563 | { |
@@ -643,7 +670,11 @@ discard block |
||
643 | 670 | $fields_to_update = array(); |
644 | 671 | foreach($contact as $field_name => $field_value) |
645 | 672 | { |
646 | - if($fields_exclude[$field_name] === true) continue; // dont touch specified field |
|
673 | + if($fields_exclude[$field_name] === true) |
|
674 | + { |
|
675 | + continue; |
|
676 | + } |
|
677 | + // dont touch specified field |
|
647 | 678 | |
648 | 679 | if (is_string($field_value) && $field_name != 'pubkey' && $field_name != 'jpegphoto') |
649 | 680 | { |
@@ -702,15 +733,21 @@ discard block |
||
702 | 733 | */ |
703 | 734 | function fullname($contact) |
704 | 735 | { |
705 | - if (empty($contact['n_family']) && empty($contact['n_given'])) { |
|
736 | + if (empty($contact['n_family']) && empty($contact['n_given'])) |
|
737 | + { |
|
706 | 738 | $cpart = array('org_name'); |
707 | - } else { |
|
739 | + } |
|
740 | + else |
|
741 | + { |
|
708 | 742 | $cpart = array('n_prefix','n_given','n_middle','n_family','n_suffix'); |
709 | 743 | } |
710 | 744 | $parts = array(); |
711 | 745 | foreach($cpart as $n) |
712 | 746 | { |
713 | - if ($contact[$n]) $parts[] = $contact[$n]; |
|
747 | + if ($contact[$n]) |
|
748 | + { |
|
749 | + $parts[] = $contact[$n]; |
|
750 | + } |
|
714 | 751 | } |
715 | 752 | return implode(' ',$parts); |
716 | 753 | } |
@@ -821,7 +858,10 @@ discard block |
||
821 | 858 | $ok = false; |
822 | 859 | if ($this->check_perms(Acl::DELETE,$c,$deny_account_delete)) |
823 | 860 | { |
824 | - if (!($old = $this->read($id))) return false; |
|
861 | + if (!($old = $this->read($id))) |
|
862 | + { |
|
863 | + return false; |
|
864 | + } |
|
825 | 865 | // check if we only mark contacts as deleted, or really delete them |
826 | 866 | // already marked as deleted item and accounts are always really deleted |
827 | 867 | // we cant mark accounts as deleted, as no such thing exists for accounts! |
@@ -829,8 +869,15 @@ discard block |
||
829 | 869 | { |
830 | 870 | $delete = $old; |
831 | 871 | $delete['tid'] = self::DELETED_TYPE; |
832 | - if ($check_etag) $delete['etag'] = $check_etag; |
|
833 | - if (($ok = $this->save($delete))) $ok = true; // we have to return true or false |
|
872 | + if ($check_etag) |
|
873 | + { |
|
874 | + $delete['etag'] = $check_etag; |
|
875 | + } |
|
876 | + if (($ok = $this->save($delete))) |
|
877 | + { |
|
878 | + $ok = true; |
|
879 | + } |
|
880 | + // we have to return true or false |
|
834 | 881 | Link::unlink(0,'addressbook',$id,'','','',true); |
835 | 882 | } |
836 | 883 | elseif (($ok = parent::delete($id,$check_etag))) |
@@ -841,7 +888,10 @@ discard block |
||
841 | 888 | // Don't notify of final purge |
842 | 889 | if ($ok && $old['tid'] != self::DELETED_TYPE) |
843 | 890 | { |
844 | - if (!isset($this->tracking)) $this->tracking = new Contacts\Tracking($this); |
|
891 | + if (!isset($this->tracking)) |
|
892 | + { |
|
893 | + $this->tracking = new Contacts\Tracking($this); |
|
894 | + } |
|
845 | 895 | $this->tracking->track(array('id' => $id), array('id' => $id), null, true); |
846 | 896 | } |
847 | 897 | } |
@@ -866,18 +916,24 @@ discard block |
||
866 | 916 | { |
867 | 917 | // Make sure photo remains unchanged unless its purposely set to be false |
868 | 918 | // which means photo has changed. |
869 | - if (!array_key_exists('photo_unchanged',$contact)) $contact['photo_unchanged'] = true; |
|
919 | + if (!array_key_exists('photo_unchanged',$contact)) |
|
920 | + { |
|
921 | + $contact['photo_unchanged'] = true; |
|
922 | + } |
|
870 | 923 | |
871 | 924 | // remember if we add or update a entry |
872 | 925 | if (($isUpdate = $contact['id'])) |
873 | 926 | { |
874 | - if (!isset($contact['owner']) || !isset($contact['private'])) // owner/private not set on update, eg. SyncML |
|
927 | + if (!isset($contact['owner']) || !isset($contact['private'])) |
|
928 | + { |
|
929 | + // owner/private not set on update, eg. SyncML |
|
875 | 930 | { |
876 | 931 | if (($old = $this->read($contact['id']))) // --> try reading the old entry and set it from there |
877 | 932 | { |
878 | 933 | if(!isset($contact['owner'])) |
879 | 934 | { |
880 | 935 | $contact['owner'] = $old['owner']; |
936 | + } |
|
881 | 937 | } |
882 | 938 | if(!isset($contact['private'])) |
883 | 939 | { |
@@ -893,18 +949,33 @@ discard block |
||
893 | 949 | else |
894 | 950 | { |
895 | 951 | // if no owner/addressbook set use the setting of the add_default prefs (if set, otherwise the users personal addressbook) |
896 | - if (!isset($contact['owner'])) $contact['owner'] = $this->default_addressbook; |
|
897 | - if (!isset($contact['private'])) $contact['private'] = (int)$this->default_private; |
|
952 | + if (!isset($contact['owner'])) |
|
953 | + { |
|
954 | + $contact['owner'] = $this->default_addressbook; |
|
955 | + } |
|
956 | + if (!isset($contact['private'])) |
|
957 | + { |
|
958 | + $contact['private'] = (int)$this->default_private; |
|
959 | + } |
|
898 | 960 | // do NOT allow to create new accounts via addressbook, they are broken without an account_id |
899 | 961 | if (!$contact['owner'] && empty($contact['account_id'])) |
900 | 962 | { |
901 | 963 | $contact['owner'] = $this->default_addressbook ? $this->default_addressbook : $this->user; |
902 | 964 | } |
903 | 965 | // allow admins to import contacts with creator / created date set |
904 | - if (!$contact['creator'] || !$ignore_acl && !$this->is_admin($contact)) $contact['creator'] = $this->user; |
|
905 | - if (!$contact['created'] || !$ignore_acl && !$this->is_admin($contact)) $contact['created'] = $this->now_su; |
|
966 | + if (!$contact['creator'] || !$ignore_acl && !$this->is_admin($contact)) |
|
967 | + { |
|
968 | + $contact['creator'] = $this->user; |
|
969 | + } |
|
970 | + if (!$contact['created'] || !$ignore_acl && !$this->is_admin($contact)) |
|
971 | + { |
|
972 | + $contact['created'] = $this->now_su; |
|
973 | + } |
|
906 | 974 | |
907 | - if (!$contact['tid']) $contact['tid'] = 'n'; |
|
975 | + if (!$contact['tid']) |
|
976 | + { |
|
977 | + $contact['tid'] = 'n'; |
|
978 | + } |
|
908 | 979 | } |
909 | 980 | // ensure accounts and group addressbooks are never private! |
910 | 981 | if ($contact['owner'] <= 0) |
@@ -928,7 +999,8 @@ discard block |
||
928 | 999 | } |
929 | 1000 | |
930 | 1001 | // Update country codes |
931 | - foreach(array('adr_one_', 'adr_two_') as $c_prefix) { |
|
1002 | + foreach(array('adr_one_', 'adr_two_') as $c_prefix) |
|
1003 | + { |
|
932 | 1004 | if($contact[$c_prefix.'countryname'] && !$contact[$c_prefix.'countrycode'] && |
933 | 1005 | $code = Country::country_code($contact[$c_prefix.'countryname'])) |
934 | 1006 | { |
@@ -958,7 +1030,10 @@ discard block |
||
958 | 1030 | { |
959 | 1031 | $contact['n_fn'] = $this->fullname($contact); |
960 | 1032 | } |
961 | - if (isset($contact['org_name'])) $contact['n_fileas'] = $this->fileas($contact, null, false); |
|
1033 | + if (isset($contact['org_name'])) |
|
1034 | + { |
|
1035 | + $contact['n_fileas'] = $this->fileas($contact, null, false); |
|
1036 | + } |
|
962 | 1037 | |
963 | 1038 | // Get old record for tracking changes |
964 | 1039 | if (!isset($old) && $isUpdate) |
@@ -1045,7 +1120,10 @@ discard block |
||
1045 | 1120 | if(!$contact['account_id'] || $contact['account_id'] && $this->account_repository == 'sql') |
1046 | 1121 | { |
1047 | 1122 | $deleted = ($old['tid'] == self::DELETED_TYPE || $contact['tid'] == self::DELETED_TYPE); |
1048 | - if (!isset($this->tracking)) $this->tracking = new Contacts\Tracking($this); |
|
1123 | + if (!isset($this->tracking)) |
|
1124 | + { |
|
1125 | + $this->tracking = new Contacts\Tracking($this); |
|
1126 | + } |
|
1049 | 1127 | $this->tracking->track($to_write, $old ? $old : null, null, $deleted); |
1050 | 1128 | } |
1051 | 1129 | |
@@ -1153,10 +1231,12 @@ discard block |
||
1153 | 1231 | $data['fileas_type'] = $this->fileas_type($data); |
1154 | 1232 | |
1155 | 1233 | // Update country name from code |
1156 | - if($data['adr_one_countrycode'] != null) { |
|
1234 | + if($data['adr_one_countrycode'] != null) |
|
1235 | + { |
|
1157 | 1236 | $data['adr_one_countryname'] = Country::get_full_name($data['adr_one_countrycode'], true); |
1158 | 1237 | } |
1159 | - if($data['adr_two_countrycode'] != null) { |
|
1238 | + if($data['adr_two_countrycode'] != null) |
|
1239 | + { |
|
1160 | 1240 | $data['adr_two_countryname'] = Country::get_full_name($data['adr_two_countrycode'], true); |
1161 | 1241 | } |
1162 | 1242 | } |
@@ -1182,7 +1262,10 @@ discard block |
||
1182 | 1262 | */ |
1183 | 1263 | function check_perms($needed,$contact,$deny_account_delete=false,$user=null) |
1184 | 1264 | { |
1185 | - if (!$user) $user = $this->user; |
|
1265 | + if (!$user) |
|
1266 | + { |
|
1267 | + $user = $this->user; |
|
1268 | + } |
|
1186 | 1269 | if ($user == $this->user) |
1187 | 1270 | { |
1188 | 1271 | $grants = $this->grants; |
@@ -1256,8 +1339,14 @@ discard block |
||
1256 | 1339 | */ |
1257 | 1340 | function read_org($org_id) |
1258 | 1341 | { |
1259 | - if (!$org_id) return false; |
|
1260 | - if (strpos($org_id,'*AND*')!== false) $org_id = str_replace('*AND*','&',$org_id); |
|
1342 | + if (!$org_id) |
|
1343 | + { |
|
1344 | + return false; |
|
1345 | + } |
|
1346 | + if (strpos($org_id,'*AND*')!== false) |
|
1347 | + { |
|
1348 | + $org_id = str_replace('*AND*','&',$org_id); |
|
1349 | + } |
|
1261 | 1350 | $org = array(); |
1262 | 1351 | foreach(explode('|||',$org_id) as $part) |
1263 | 1352 | { |
@@ -1287,7 +1376,10 @@ discard block |
||
1287 | 1376 | } |
1288 | 1377 | // read the regular fields |
1289 | 1378 | $contacts = parent::search('',$regular_fields,'','','',false,'AND',false,$org); |
1290 | - if (!$contacts) return false; |
|
1379 | + if (!$contacts) |
|
1380 | + { |
|
1381 | + return false; |
|
1382 | + } |
|
1291 | 1383 | |
1292 | 1384 | // if we have custom fields, read and merge them in |
1293 | 1385 | if ($custom_fields) |
@@ -1335,7 +1427,10 @@ discard block |
||
1335 | 1427 | } |
1336 | 1428 | foreach($fields as $name => $values) |
1337 | 1429 | { |
1338 | - if (!in_array($name,$this->org_fields)) continue; |
|
1430 | + if (!in_array($name,$this->org_fields)) |
|
1431 | + { |
|
1432 | + continue; |
|
1433 | + } |
|
1339 | 1434 | |
1340 | 1435 | arsort($values,SORT_NUMERIC); |
1341 | 1436 | list($value,$num) = each($values); |
@@ -1405,16 +1500,25 @@ discard block |
||
1405 | 1500 | 'adr_two_countryname' => 'adr_one_countrycode', |
1406 | 1501 | ) as $name => $code) |
1407 | 1502 | { |
1408 | - if (!empty($from[$code])) $from[$name] = ''; |
|
1409 | - if (!empty($to[$code])) $to[$name] = ''; |
|
1503 | + if (!empty($from[$code])) |
|
1504 | + { |
|
1505 | + $from[$name] = ''; |
|
1506 | + } |
|
1507 | + if (!empty($to[$code])) |
|
1508 | + { |
|
1509 | + $to[$name] = ''; |
|
1510 | + } |
|
1410 | 1511 | } |
1411 | 1512 | $changed = array(); |
1412 | 1513 | foreach($only_org_fields ? $this->org_fields : array_keys($this->contact_fields) as $name) |
1413 | 1514 | { |
1414 | - if (in_array($name,array('modified','modifier'))) // never count these |
|
1515 | + if (in_array($name,array('modified','modifier'))) |
|
1516 | + { |
|
1517 | + // never count these |
|
1415 | 1518 | { |
1416 | 1519 | continue; |
1417 | 1520 | } |
1521 | + } |
|
1418 | 1522 | if ((string) $from[$name] != (string) $to[$name]) |
1419 | 1523 | { |
1420 | 1524 | $changed[$name] = $from[$name]; |
@@ -1434,13 +1538,19 @@ discard block |
||
1434 | 1538 | */ |
1435 | 1539 | function change_org($org_name,$from,$to,$members=null) |
1436 | 1540 | { |
1437 | - if (!($changed = $this->changed_fields($from,$to,true))) return false; |
|
1541 | + if (!($changed = $this->changed_fields($from,$to,true))) |
|
1542 | + { |
|
1543 | + return false; |
|
1544 | + } |
|
1438 | 1545 | |
1439 | 1546 | if (is_null($members) || !is_array($members)) |
1440 | 1547 | { |
1441 | 1548 | $members = $this->org_similar($org_name,$changed); |
1442 | 1549 | } |
1443 | - if (!$members) return false; |
|
1550 | + if (!$members) |
|
1551 | + { |
|
1552 | + return false; |
|
1553 | + } |
|
1444 | 1554 | |
1445 | 1555 | $ids = array(); |
1446 | 1556 | foreach($members as $member) |
@@ -1505,7 +1615,10 @@ discard block |
||
1505 | 1615 | $type = $this->prefs['link_title']; |
1506 | 1616 | if (!$type || $type === 'n_fileas') |
1507 | 1617 | { |
1508 | - if ($contact['n_fileas']) return $contact['n_fileas']; |
|
1618 | + if ($contact['n_fileas']) |
|
1619 | + { |
|
1620 | + return $contact['n_fileas']; |
|
1621 | + } |
|
1509 | 1622 | $type = null; |
1510 | 1623 | } |
1511 | 1624 | $title = $this->fileas($contact,$type); |
@@ -1581,7 +1694,10 @@ discard block |
||
1581 | 1694 | $limit = array($options['start'], $options['num_rows']); |
1582 | 1695 | } |
1583 | 1696 | $filter = (array)$options['filter']; |
1584 | - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') $filter['account_id'] = null; |
|
1697 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') |
|
1698 | + { |
|
1699 | + $filter['account_id'] = null; |
|
1700 | + } |
|
1585 | 1701 | if (($contacts =& parent::search($criteria,false,'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR', $limit, $filter))) |
1586 | 1702 | { |
1587 | 1703 | $ids = array(); |
@@ -1644,12 +1760,18 @@ discard block |
||
1644 | 1760 | */ |
1645 | 1761 | function calendar_info($ids) |
1646 | 1762 | { |
1647 | - if (!$ids) return null; |
|
1763 | + if (!$ids) |
|
1764 | + { |
|
1765 | + return null; |
|
1766 | + } |
|
1648 | 1767 | |
1649 | 1768 | $data = array(); |
1650 | 1769 | foreach(!is_array($ids) ? array($ids) : $ids as $id) |
1651 | 1770 | { |
1652 | - if (!($contact = $this->read($id))) continue; |
|
1771 | + if (!($contact = $this->read($id))) |
|
1772 | + { |
|
1773 | + continue; |
|
1774 | + } |
|
1653 | 1775 | |
1654 | 1776 | $data[] = array( |
1655 | 1777 | 'res_id' => $id, |
@@ -1671,7 +1793,10 @@ discard block |
||
1671 | 1793 | */ |
1672 | 1794 | function read_calendar($uids,$extra_title=true) |
1673 | 1795 | { |
1674 | - if (!$GLOBALS['egw_info']['user']['apps']['calendar']) return array(); |
|
1796 | + if (!$GLOBALS['egw_info']['user']['apps']['calendar']) |
|
1797 | + { |
|
1798 | + return array(); |
|
1799 | + } |
|
1675 | 1800 | |
1676 | 1801 | $split_uids = array(); |
1677 | 1802 | $events = array(); |
@@ -1727,7 +1852,10 @@ discard block |
||
1727 | 1852 | |
1728 | 1853 | $contacts =& $this->db->query($sql, __LINE__, __FILE__); |
1729 | 1854 | |
1730 | - if (!$contacts) return array(); |
|
1855 | + if (!$contacts) |
|
1856 | + { |
|
1857 | + return array(); |
|
1858 | + } |
|
1731 | 1859 | |
1732 | 1860 | // Extract the event info and generate what is needed for next/last event |
1733 | 1861 | $do_event = function($key, $contact) use (&$bocal, &$calendars, $type, $extra_title) |
@@ -1887,27 +2015,36 @@ discard block |
||
1887 | 2015 | $account = null; |
1888 | 2016 | $custom_fields = Storage\Customfields::get('addressbook', true); |
1889 | 2017 | $custom_field_list = $this->read_customfields($ids); |
1890 | - foreach(parent::search(array('id'=>$ids),false) as $contact) // $this->search calls the extended search from ui! |
|
2018 | + foreach(parent::search(array('id'=>$ids),false) as $contact) |
|
2019 | + { |
|
2020 | + // $this->search calls the extended search from ui! |
|
1891 | 2021 | { |
1892 | 2022 | if ($contact['account_id']) |
1893 | 2023 | { |
1894 | 2024 | if (!is_null($account)) |
1895 | 2025 | { |
1896 | 2026 | echo $this->error = 'Can not merge more then one account!'; |
2027 | + } |
|
1897 | 2028 | return false; // we dont deal with two accounts! |
1898 | 2029 | } |
1899 | 2030 | $account = $contact; |
1900 | 2031 | continue; |
1901 | 2032 | } |
1902 | 2033 | // Add in custom fields |
1903 | - if (is_array($custom_field_list[$contact['id']])) $contact = array_merge($contact, $custom_field_list[$contact['id']]); |
|
2034 | + if (is_array($custom_field_list[$contact['id']])) |
|
2035 | + { |
|
2036 | + $contact = array_merge($contact, $custom_field_list[$contact['id']]); |
|
2037 | + } |
|
1904 | 2038 | |
1905 | 2039 | $pos = array_search($contact['id'],$ids); |
1906 | 2040 | $contacts[$pos] = $contact; |
1907 | 2041 | } |
1908 | - if (!is_null($account)) // we found an account, so we merge the contacts into it |
|
2042 | + if (!is_null($account)) |
|
2043 | + { |
|
2044 | + // we found an account, so we merge the contacts into it |
|
1909 | 2045 | { |
1910 | 2046 | $target = $account; |
2047 | + } |
|
1911 | 2048 | unset($account); |
1912 | 2049 | } |
1913 | 2050 | else // we found no account, so we merge all but the first into the first |
@@ -1924,7 +2061,10 @@ discard block |
||
1924 | 2061 | { |
1925 | 2062 | foreach($contact as $name => $value) |
1926 | 2063 | { |
1927 | - if (!$value) continue; |
|
2064 | + if (!$value) |
|
2065 | + { |
|
2066 | + continue; |
|
2067 | + } |
|
1928 | 2068 | |
1929 | 2069 | switch($name) |
1930 | 2070 | { |
@@ -1936,20 +2076,31 @@ discard block |
||
1936 | 2076 | break; // ignored |
1937 | 2077 | |
1938 | 2078 | case 'cat_id': // cats are all merged together |
1939 | - if (!is_array($target['cat_id'])) $target['cat_id'] = $target['cat_id'] ? explode(',',$target['cat_id']) : array(); |
|
2079 | + if (!is_array($target['cat_id'])) |
|
2080 | + { |
|
2081 | + $target['cat_id'] = $target['cat_id'] ? explode(',',$target['cat_id']) : array(); |
|
2082 | + } |
|
1940 | 2083 | $target['cat_id'] = array_unique(array_merge($target['cat_id'],is_array($value)?$value:explode(',',$value))); |
1941 | 2084 | break; |
1942 | 2085 | |
1943 | 2086 | default: |
1944 | 2087 | // Multi-select custom fields can also be merged |
1945 | - if($name[0] == '#') { |
|
2088 | + if($name[0] == '#') |
|
2089 | + { |
|
1946 | 2090 | $c_name = substr($name, 1); |
1947 | - if($custom_fields[$c_name]['type'] == 'select' && $custom_fields[$c_name]['rows'] > 1) { |
|
1948 | - if (!is_array($target[$name])) $target[$name] = $target[$name] ? explode(',',$target[$name]) : array(); |
|
2091 | + if($custom_fields[$c_name]['type'] == 'select' && $custom_fields[$c_name]['rows'] > 1) |
|
2092 | + { |
|
2093 | + if (!is_array($target[$name])) |
|
2094 | + { |
|
2095 | + $target[$name] = $target[$name] ? explode(',',$target[$name]) : array(); |
|
2096 | + } |
|
1949 | 2097 | $target[$name] = implode(',',array_unique(array_merge($target[$name],is_array($value)?$value:explode(',',$value)))); |
1950 | 2098 | } |
1951 | 2099 | } |
1952 | - if (!$target[$name]) $target[$name] = $value; |
|
2100 | + if (!$target[$name]) |
|
2101 | + { |
|
2102 | + $target[$name] = $value; |
|
2103 | + } |
|
1953 | 2104 | break; |
1954 | 2105 | } |
1955 | 2106 | } |
@@ -1961,7 +2112,10 @@ discard block |
||
1961 | 2112 | parent::add2list($target['id'], $list_id); |
1962 | 2113 | } |
1963 | 2114 | } |
1964 | - if (!$this->save($target)) return 0; |
|
2115 | + if (!$this->save($target)) |
|
2116 | + { |
|
2117 | + return 0; |
|
2118 | + } |
|
1965 | 2119 | |
1966 | 2120 | $success = 1; |
1967 | 2121 | foreach($contacts as $contact) |
@@ -1994,7 +2148,10 @@ discard block |
||
1994 | 2148 | // Update calendar |
1995 | 2149 | $this->merge_calendar('c'.$contact['id'], $target['account_id'] ? 'u'.$target['account_id'] : 'c'.$target['id']); |
1996 | 2150 | |
1997 | - if ($this->delete($contact['id'])) $success++; |
|
2151 | + if ($this->delete($contact['id'])) |
|
2152 | + { |
|
2153 | + $success++; |
|
2154 | + } |
|
1998 | 2155 | } |
1999 | 2156 | return $success; |
2000 | 2157 | } |
@@ -2063,11 +2220,17 @@ discard block |
||
2063 | 2220 | */ |
2064 | 2221 | function add_list($keys,$owner,$contacts=array(),array &$data=array()) |
2065 | 2222 | { |
2066 | - if (!$this->check_list(null,Acl::ADD|Acl::EDIT,$owner)) return false; |
|
2223 | + if (!$this->check_list(null,Acl::ADD|Acl::EDIT,$owner)) |
|
2224 | + { |
|
2225 | + return false; |
|
2226 | + } |
|
2067 | 2227 | |
2068 | 2228 | try { |
2069 | 2229 | $ret = parent::add_list($keys,$owner,$contacts,$data); |
2070 | - if ($ret) unset(self::$list_cache[$ret]); |
|
2230 | + if ($ret) |
|
2231 | + { |
|
2232 | + unset(self::$list_cache[$ret]); |
|
2233 | + } |
|
2071 | 2234 | } |
2072 | 2235 | // catch sql error, as creating same name&owner list gives a sql error doublicate key |
2073 | 2236 | catch(Db\Exception\InvalidSql $e) { |
@@ -2087,7 +2250,10 @@ discard block |
||
2087 | 2250 | */ |
2088 | 2251 | function add2list($contact,$list,array $existing=null) |
2089 | 2252 | { |
2090 | - if (!$this->check_list($list,Acl::EDIT)) return false; |
|
2253 | + if (!$this->check_list($list,Acl::EDIT)) |
|
2254 | + { |
|
2255 | + return false; |
|
2256 | + } |
|
2091 | 2257 | |
2092 | 2258 | unset(self::$list_cache[$list]); |
2093 | 2259 | |
@@ -2103,7 +2269,10 @@ discard block |
||
2103 | 2269 | */ |
2104 | 2270 | function remove_from_list($contact,$list=null) |
2105 | 2271 | { |
2106 | - if ($list && !$this->check_list($list,Acl::EDIT)) return false; |
|
2272 | + if ($list && !$this->check_list($list,Acl::EDIT)) |
|
2273 | + { |
|
2274 | + return false; |
|
2275 | + } |
|
2107 | 2276 | |
2108 | 2277 | if ($list) |
2109 | 2278 | { |
@@ -2127,7 +2296,10 @@ discard block |
||
2127 | 2296 | { |
2128 | 2297 | foreach((array)$list as $l) |
2129 | 2298 | { |
2130 | - if (!$this->check_list($l, Acl::DELETE)) return false; |
|
2299 | + if (!$this->check_list($l, Acl::DELETE)) |
|
2300 | + { |
|
2301 | + return false; |
|
2302 | + } |
|
2131 | 2303 | |
2132 | 2304 | unset(self::$list_cache[$l]); |
2133 | 2305 | } |
@@ -2143,7 +2315,10 @@ discard block |
||
2143 | 2315 | */ |
2144 | 2316 | function read_list($list) |
2145 | 2317 | { |
2146 | - if (isset(self::$list_cache[$list])) return self::$list_cache[$list]; |
|
2318 | + if (isset(self::$list_cache[$list])) |
|
2319 | + { |
|
2320 | + return self::$list_cache[$list]; |
|
2321 | + } |
|
2147 | 2322 | |
2148 | 2323 | return self::$list_cache[$list] = parent::read_list($list); |
2149 | 2324 | } |
@@ -2398,7 +2573,10 @@ discard block |
||
2398 | 2573 | |
2399 | 2574 | foreach ($columns_to_search as $field) |
2400 | 2575 | { |
2401 | - if ($relax && in_array($field, $tolerance_fields)) continue; |
|
2576 | + if ($relax && in_array($field, $tolerance_fields)) |
|
2577 | + { |
|
2578 | + continue; |
|
2579 | + } |
|
2402 | 2580 | |
2403 | 2581 | if (empty($contact[$field])) |
2404 | 2582 | { |
@@ -2463,7 +2641,10 @@ discard block |
||
2463 | 2641 | } |
2464 | 2642 | |
2465 | 2643 | // No need for more searches for relaxed matching |
2466 | - if ($relax || count($matchingContacts)) return $matchingContacts; |
|
2644 | + if ($relax || count($matchingContacts)) |
|
2645 | + { |
|
2646 | + return $matchingContacts; |
|
2647 | + } |
|
2467 | 2648 | |
2468 | 2649 | |
2469 | 2650 | if (!$empty_addr_one && $empty_addr_two) |
@@ -2516,7 +2697,8 @@ discard block |
||
2516 | 2697 | } |
2517 | 2698 | } |
2518 | 2699 | elseif (!$empty_addr_one && !$empty_addr_two) |
2519 | - { // try again after address swap |
|
2700 | + { |
|
2701 | +// try again after address swap |
|
2520 | 2702 | |
2521 | 2703 | foreach ($addr_one_fields as $key => $field) |
2522 | 2704 | { |
@@ -2563,7 +2745,10 @@ discard block |
||
2563 | 2745 | { |
2564 | 2746 | $filter = array('tid' => null); // tid=null --> use all entries incl. deleted (tid='D') |
2565 | 2747 | // show addressbook of a single user? |
2566 | - if (!is_null($owner)) $filter['owner'] = $owner; |
|
2748 | + if (!is_null($owner)) |
|
2749 | + { |
|
2750 | + $filter['owner'] = $owner; |
|
2751 | + } |
|
2567 | 2752 | |
2568 | 2753 | // should we hide the accounts addressbook |
2569 | 2754 | if (!$owner && $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | namespace EGroupware\Api; |
18 | 18 | |
19 | -use calendar_bo; // to_do: do NOT require it, just use if there |
|
19 | +use calendar_bo; // to_do: do NOT require it, just use if there |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Business object for contacts |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * @var array $timestamps timestamps |
40 | 40 | */ |
41 | - var $timestamps = array('modified','created'); |
|
41 | + var $timestamps = array('modified', 'created'); |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @var array $fileas_types |
@@ -173,32 +173,32 @@ discard block |
||
173 | 173 | * @param string $contact_app ='addressbook' used for acl->get_grants() |
174 | 174 | * @param Db $db =null |
175 | 175 | */ |
176 | - function __construct($contact_app='addressbook',Db $db=null) |
|
176 | + function __construct($contact_app = 'addressbook', Db $db = null) |
|
177 | 177 | { |
178 | - parent::__construct($contact_app,$db); |
|
178 | + parent::__construct($contact_app, $db); |
|
179 | 179 | if ($this->log) |
180 | 180 | { |
181 | 181 | $this->logfile = $GLOBALS['egw_info']['server']['temp_dir'].'/log-addressbook_bo'; |
182 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($contact_app)\n", 3 ,$this->logfile); |
|
182 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($contact_app)\n", 3, $this->logfile); |
|
183 | 183 | } |
184 | 184 | |
185 | - $this->now_su = DateTime::to('now','ts'); |
|
185 | + $this->now_su = DateTime::to('now', 'ts'); |
|
186 | 186 | |
187 | - $this->prefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook']; |
|
188 | - if(!isset($this->prefs['hide_accounts'])) |
|
187 | + $this->prefs = & $GLOBALS['egw_info']['user']['preferences']['addressbook']; |
|
188 | + if (!isset($this->prefs['hide_accounts'])) |
|
189 | 189 | { |
190 | 190 | $this->prefs['hide_accounts'] = '0'; |
191 | 191 | } |
192 | 192 | // get the default addressbook from the users prefs |
193 | 193 | $this->default_addressbook = $GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] ? |
194 | 194 | (int)$GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] : $this->user; |
195 | - $this->default_private = substr($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'],-1) == 'p'; |
|
195 | + $this->default_private = substr($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'], -1) == 'p'; |
|
196 | 196 | if ($this->default_addressbook > 0 && $this->default_addressbook != $this->user && |
197 | 197 | ($this->default_private || |
198 | 198 | $this->default_addressbook == (int)$GLOBALS['egw']->preferences->forced['addressbook']['add_default'] || |
199 | 199 | $this->default_addressbook == (int)$GLOBALS['egw']->preferences->default['addressbook']['add_default'])) |
200 | 200 | { |
201 | - $this->default_addressbook = $this->user; // admin set a default or forced pref for personal addressbook |
|
201 | + $this->default_addressbook = $this->user; // admin set a default or forced pref for personal addressbook |
|
202 | 202 | } |
203 | 203 | $this->private_addressbook = self::private_addressbook($this->contact_repository == 'sql', $this->prefs); |
204 | 204 | |
@@ -303,27 +303,27 @@ discard block |
||
303 | 303 | $this->own_account_acl = $GLOBALS['egw_info']['server']['own_account_acl']; |
304 | 304 | if (!is_array($this->own_account_acl)) $this->own_account_acl = json_php_unserialize($this->own_account_acl, true); |
305 | 305 | // we have only one acl (n_fn) for the whole name, as not all backends store every part in an own field |
306 | - if ($this->own_account_acl && in_array('n_fn',$this->own_account_acl)) |
|
306 | + if ($this->own_account_acl && in_array('n_fn', $this->own_account_acl)) |
|
307 | 307 | { |
308 | - $this->own_account_acl = array_merge($this->own_account_acl,array('n_prefix','n_given','n_middle','n_family','n_suffix')); |
|
308 | + $this->own_account_acl = array_merge($this->own_account_acl, array('n_prefix', 'n_given', 'n_middle', 'n_family', 'n_suffix')); |
|
309 | 309 | } |
310 | 310 | if ($GLOBALS['egw_info']['server']['org_fileds_to_update']) |
311 | 311 | { |
312 | - $this->org_fields = $GLOBALS['egw_info']['server']['org_fileds_to_update']; |
|
312 | + $this->org_fields = $GLOBALS['egw_info']['server']['org_fileds_to_update']; |
|
313 | 313 | if (!is_array($this->org_fields)) $this->org_fields = unserialize($this->org_fields); |
314 | 314 | |
315 | 315 | // Set country code if country name is selected |
316 | - $supported_fields = $this->get_fields('supported',null,0); |
|
317 | - if(in_array('adr_one_countrycode', $supported_fields) && in_array('adr_one_countryname',$this->org_fields)) |
|
316 | + $supported_fields = $this->get_fields('supported', null, 0); |
|
317 | + if (in_array('adr_one_countrycode', $supported_fields) && in_array('adr_one_countryname', $this->org_fields)) |
|
318 | 318 | { |
319 | 319 | $this->org_fields[] = 'adr_one_countrycode'; |
320 | 320 | } |
321 | - if(in_array('adr_two_countrycode', $supported_fields) && in_array('adr_two_countryname',$this->org_fields)) |
|
321 | + if (in_array('adr_two_countrycode', $supported_fields) && in_array('adr_two_countryname', $this->org_fields)) |
|
322 | 322 | { |
323 | 323 | $this->org_fields[] = 'adr_two_countrycode'; |
324 | 324 | } |
325 | 325 | } |
326 | - $this->categories = new Categories($this->user,'addressbook'); |
|
326 | + $this->categories = new Categories($this->user, 'addressbook'); |
|
327 | 327 | |
328 | 328 | $this->delete_history = $GLOBALS['egw_info']['server']['history']; |
329 | 329 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @param array $prefs addressbook preferences |
338 | 338 | * @return boolean |
339 | 339 | */ |
340 | - public static function private_addressbook($contact_repository, array $prefs=null) |
|
340 | + public static function private_addressbook($contact_repository, array $prefs = null) |
|
341 | 341 | { |
342 | 342 | return $contact_repository == 'sql' && $prefs['private_addressbook']; |
343 | 343 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * @param int $user =null account_id or null for current user |
352 | 352 | * @return array with owner => label pairs |
353 | 353 | */ |
354 | - function get_addressbooks($required=Acl::READ,$extra_label=null,$user=null) |
|
354 | + function get_addressbooks($required = Acl::READ, $extra_label = null, $user = null) |
|
355 | 355 | { |
356 | 356 | if (is_null($user)) |
357 | 357 | { |
@@ -370,11 +370,11 @@ discard block |
||
370 | 370 | if ($extra_label) $addressbooks[''] = $extra_label; |
371 | 371 | $addressbooks[$user] = lang('Personal'); |
372 | 372 | // add all group addressbooks the user has the necessary rights too |
373 | - foreach($grants as $uid => $rights) |
|
373 | + foreach ($grants as $uid => $rights) |
|
374 | 374 | { |
375 | - if (($rights & $required) == $required && $GLOBALS['egw']->accounts->get_type($uid) == 'g') |
|
375 | + if (($rights&$required) == $required && $GLOBALS['egw']->accounts->get_type($uid) == 'g') |
|
376 | 376 | { |
377 | - $to_sort[$uid] = lang('Group %1',$GLOBALS['egw']->accounts->id2name($uid)); |
|
377 | + $to_sort[$uid] = lang('Group %1', $GLOBALS['egw']->accounts->id2name($uid)); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | if ($to_sort) |
@@ -382,19 +382,19 @@ discard block |
||
382 | 382 | asort($to_sort); |
383 | 383 | $addressbooks += $to_sort; |
384 | 384 | } |
385 | - if ($required != Acl::ADD && // do NOT allow to set accounts as default addressbook (AB can add accounts) |
|
385 | + if ($required != Acl::ADD && // do NOT allow to set accounts as default addressbook (AB can add accounts) |
|
386 | 386 | $preferences['addressbook']['hide_accounts'] !== '1' && ( |
387 | - ($grants[0] & $required) == $required || |
|
387 | + ($grants[0]&$required) == $required || |
|
388 | 388 | $preferences['common']['account_selection'] == 'groupmembers' && |
389 | - $this->account_repository != 'ldap' && ($required & Acl::READ))) |
|
389 | + $this->account_repository != 'ldap' && ($required&Acl::READ))) |
|
390 | 390 | { |
391 | 391 | $addressbooks[0] = lang('Accounts'); |
392 | 392 | } |
393 | 393 | // add all other user addressbooks the user has the necessary rights too |
394 | 394 | $to_sort = array(); |
395 | - foreach($grants as $uid => $rights) |
|
395 | + foreach ($grants as $uid => $rights) |
|
396 | 396 | { |
397 | - if ($uid != $user && ($rights & $required) == $required && $GLOBALS['egw']->accounts->get_type($uid) == 'u') |
|
397 | + if ($uid != $user && ($rights&$required) == $required && $GLOBALS['egw']->accounts->get_type($uid) == 'u') |
|
398 | 398 | { |
399 | 399 | $to_sort[$uid] = Accounts::username($uid); |
400 | 400 | } |
@@ -419,22 +419,22 @@ discard block |
||
419 | 419 | * @param boolean $isUpdate =false If true, reads the old record for any not set fields |
420 | 420 | * @return string |
421 | 421 | */ |
422 | - function fileas($contact,$type=null, $isUpdate=false) |
|
422 | + function fileas($contact, $type = null, $isUpdate = false) |
|
423 | 423 | { |
424 | 424 | if (is_null($type)) $type = $contact['fileas_type']; |
425 | 425 | if (!$type) $type = $this->prefs['fileas_default'] ? $this->prefs['fileas_default'] : $this->fileas_types[0]; |
426 | 426 | |
427 | - if (strpos($type,'n_fn') !== false) $contact['n_fn'] = $this->fullname($contact); |
|
427 | + if (strpos($type, 'n_fn') !== false) $contact['n_fn'] = $this->fullname($contact); |
|
428 | 428 | |
429 | - if($isUpdate) |
|
429 | + if ($isUpdate) |
|
430 | 430 | { |
431 | - $fileas_fields = array('n_prefix','n_given','n_middle','n_family','n_suffix','n_fn','org_name','org_unit','adr_one_locality','bday'); |
|
431 | + $fileas_fields = array('n_prefix', 'n_given', 'n_middle', 'n_family', 'n_suffix', 'n_fn', 'org_name', 'org_unit', 'adr_one_locality', 'bday'); |
|
432 | 432 | $old = null; |
433 | - foreach($fileas_fields as $field) |
|
433 | + foreach ($fileas_fields as $field) |
|
434 | 434 | { |
435 | - if(!isset($contact[$field])) |
|
435 | + if (!isset($contact[$field])) |
|
436 | 436 | { |
437 | - if(is_null($old)) $old = $this->read($contact['id']); |
|
437 | + if (is_null($old)) $old = $this->read($contact['id']); |
|
438 | 438 | $contact[$field] = $old[$field]; |
439 | 439 | } |
440 | 440 | } |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | // removing empty delimiters, caused by empty contact fields |
445 | - $fileas = str_replace(array(', , : ',', : ',': , ',', , ',': : ',' ()'), |
|
446 | - array(': ',': ',': ',', ',': ',''), |
|
445 | + $fileas = str_replace(array(', , : ', ', : ', ': , ', ', , ', ': : ', ' ()'), |
|
446 | + array(': ', ': ', ': ', ', ', ': ', ''), |
|
447 | 447 | strtr($type, array( |
448 | 448 | 'n_prefix' => $contact['n_prefix'], |
449 | 449 | 'n_given' => $contact['n_given'], |
@@ -457,13 +457,13 @@ discard block |
||
457 | 457 | 'bday' => (int)$contact['bday'] ? DateTime::to($contact['bday'], true) : $contact['bday'], |
458 | 458 | ))); |
459 | 459 | |
460 | - while ($fileas[0] == ':' || $fileas[0] == ',') |
|
460 | + while ($fileas[0] == ':' || $fileas[0] == ',') |
|
461 | 461 | { |
462 | - $fileas = substr($fileas,2); |
|
462 | + $fileas = substr($fileas, 2); |
|
463 | 463 | } |
464 | - while (substr($fileas,-2) == ': ' || substr($fileas,-2) == ', ') |
|
464 | + while (substr($fileas, -2) == ': ' || substr($fileas, -2) == ', ') |
|
465 | 465 | { |
466 | - $fileas = substr($fileas,0,-2); |
|
466 | + $fileas = substr($fileas, 0, -2); |
|
467 | 467 | } |
468 | 468 | return $fileas; |
469 | 469 | } |
@@ -475,15 +475,15 @@ discard block |
||
475 | 475 | * @param string $file_as =null file_as type, default null to read it from the contact, unknown/not set type default to the first one |
476 | 476 | * @return string |
477 | 477 | */ |
478 | - function fileas_type($contact,$file_as=null) |
|
478 | + function fileas_type($contact, $file_as = null) |
|
479 | 479 | { |
480 | 480 | if (is_null($file_as)) $file_as = $contact['n_fileas']; |
481 | 481 | |
482 | 482 | if ($file_as) |
483 | 483 | { |
484 | - foreach($this->fileas_types as $type) |
|
484 | + foreach ($this->fileas_types as $type) |
|
485 | 485 | { |
486 | - if ($this->fileas($contact,$type) == $file_as) |
|
486 | + if ($this->fileas($contact, $type) == $file_as) |
|
487 | 487 | { |
488 | 488 | return $type; |
489 | 489 | } |
@@ -500,10 +500,10 @@ discard block |
||
500 | 500 | */ |
501 | 501 | public static function cf_options() |
502 | 502 | { |
503 | - $cf_fields = Storage\Customfields::get('addressbook',TRUE); |
|
504 | - foreach ($cf_fields as $key => $value ) |
|
503 | + $cf_fields = Storage\Customfields::get('addressbook', TRUE); |
|
504 | + foreach ($cf_fields as $key => $value) |
|
505 | 505 | { |
506 | - $options[$key]= $value['label']; |
|
506 | + $options[$key] = $value['label']; |
|
507 | 507 | } |
508 | 508 | return $options; |
509 | 509 | } |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | * @param array $contact =null real content to use, default none |
515 | 515 | * @return array with options: fileas type => label pairs |
516 | 516 | */ |
517 | - function fileas_options($contact=null) |
|
517 | + function fileas_options($contact = null) |
|
518 | 518 | { |
519 | 519 | $labels = array( |
520 | 520 | 'n_prefix' => lang('prefix'), |
@@ -528,13 +528,13 @@ discard block |
||
528 | 528 | 'adr_one_locality' => lang('city'), |
529 | 529 | 'bday' => lang('Birthday'), |
530 | 530 | ); |
531 | - foreach(array_keys($labels) as $name) |
|
531 | + foreach (array_keys($labels) as $name) |
|
532 | 532 | { |
533 | 533 | if ($contact[$name]) $labels[$name] = $contact[$name]; |
534 | 534 | } |
535 | - foreach($this->fileas_types as $fileas_type) |
|
535 | + foreach ($this->fileas_types as $fileas_type) |
|
536 | 536 | { |
537 | - $options[$fileas_type] = $this->fileas($labels,$fileas_type); |
|
537 | + $options[$fileas_type] = $this->fileas($labels, $fileas_type); |
|
538 | 538 | } |
539 | 539 | return $options; |
540 | 540 | } |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * @param int &$errors=null on return number of errors |
550 | 550 | * @return int|boolean number of contacts updated, false for wrong fileas type |
551 | 551 | */ |
552 | - function set_all_fileas($fileas_type,$all=false,&$errors=null,$ignore_acl=false) |
|
552 | + function set_all_fileas($fileas_type, $all = false, &$errors = null, $ignore_acl = false) |
|
553 | 553 | { |
554 | 554 | if ($fileas_type != '' && !in_array($fileas_type, $this->fileas_types)) |
555 | 555 | { |
@@ -557,17 +557,17 @@ discard block |
||
557 | 557 | } |
558 | 558 | if ($ignore_acl) |
559 | 559 | { |
560 | - unset($this->somain->grants); // to NOT limit search to contacts readable by current user |
|
560 | + unset($this->somain->grants); // to NOT limit search to contacts readable by current user |
|
561 | 561 | } |
562 | 562 | // to be able to work on huge contact repositories we read the contacts in chunks of 100 |
563 | - for($n = $updated = $errors = 0; ($contacts = parent::search($all ? array() : array( |
|
563 | + for ($n = $updated = $errors = 0; ($contacts = parent::search($all ? array() : array( |
|
564 | 564 | 'n_fileas IS NULL', |
565 | 565 | "n_fileas=''", |
566 | 566 | 'n_fn IS NULL', |
567 | 567 | "n_fn=''", |
568 | - ),false,'','','',false,'OR',array($n*100,100))); ++$n) |
|
568 | + ), false, '', '', '', false, 'OR', array($n * 100, 100))); ++$n) |
|
569 | 569 | { |
570 | - foreach($contacts as $contact) |
|
570 | + foreach ($contacts as $contact) |
|
571 | 571 | { |
572 | 572 | $old_fn = $contact['n_fn']; |
573 | 573 | $old_fileas = $contact['n_fileas']; |
@@ -575,19 +575,19 @@ discard block |
||
575 | 575 | // only update fileas if type is given AND (all should be updated or n_fileas is empty) |
576 | 576 | if ($fileas_type && ($all || empty($contact['n_fileas']))) |
577 | 577 | { |
578 | - $contact['n_fileas'] = $this->fileas($contact,$fileas_type); |
|
578 | + $contact['n_fileas'] = $this->fileas($contact, $fileas_type); |
|
579 | 579 | } |
580 | 580 | if ($old_fileas != $contact['n_fileas'] || $old_fn != $contact['n_fn']) |
581 | 581 | { |
582 | 582 | // only specify/write updated fields plus "keys" |
583 | - $contact = array_intersect_key($contact,array( |
|
583 | + $contact = array_intersect_key($contact, array( |
|
584 | 584 | 'id' => true, |
585 | 585 | 'owner' => true, |
586 | 586 | 'private' => true, |
587 | 587 | 'account_id' => true, |
588 | 588 | 'uid' => true, |
589 | - )+($old_fileas != $contact['n_fileas'] ? array('n_fileas' => true) : array())+($old_fn != $contact['n_fn'] ? array('n_fn' => true) : array())); |
|
590 | - if ($this->save($contact,$ignore_acl)) |
|
589 | + ) + ($old_fileas != $contact['n_fileas'] ? array('n_fileas' => true) : array()) + ($old_fn != $contact['n_fn'] ? array('n_fn' => true) : array())); |
|
590 | + if ($this->save($contact, $ignore_acl)) |
|
591 | 591 | { |
592 | 592 | $updated++; |
593 | 593 | } |
@@ -610,11 +610,11 @@ discard block |
||
610 | 610 | * @param int &$errors=null on return number of errors |
611 | 611 | * @return int|boolean number of contacts updated |
612 | 612 | */ |
613 | - function set_all_cleanup(&$errors=null,$ignore_acl=false) |
|
613 | + function set_all_cleanup(&$errors = null, $ignore_acl = false) |
|
614 | 614 | { |
615 | 615 | if ($ignore_acl) |
616 | 616 | { |
617 | - unset($this->somain->grants); // to NOT limit search to contacts readable by current user |
|
617 | + unset($this->somain->grants); // to NOT limit search to contacts readable by current user |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | // fields that must not be touched |
@@ -636,14 +636,14 @@ discard block |
||
636 | 636 | ); |
637 | 637 | |
638 | 638 | // to be able to work on huge contact repositories we read the contacts in chunks of 100 |
639 | - for($n = $updated = $errors = 0; ($contacts = parent::search(array(),false,'','','',false,'OR',array($n*100,100))); ++$n) |
|
639 | + for ($n = $updated = $errors = 0; ($contacts = parent::search(array(), false, '', '', '', false, 'OR', array($n * 100, 100))); ++$n) |
|
640 | 640 | { |
641 | - foreach($contacts as $contact) |
|
641 | + foreach ($contacts as $contact) |
|
642 | 642 | { |
643 | 643 | $fields_to_update = array(); |
644 | - foreach($contact as $field_name => $field_value) |
|
644 | + foreach ($contact as $field_name => $field_value) |
|
645 | 645 | { |
646 | - if($fields_exclude[$field_name] === true) continue; // dont touch specified field |
|
646 | + if ($fields_exclude[$field_name] === true) continue; // dont touch specified field |
|
647 | 647 | |
648 | 648 | if (is_string($field_value) && $field_name != 'pubkey' && $field_name != 'jpegphoto') |
649 | 649 | { |
@@ -653,9 +653,9 @@ discard block |
||
653 | 653 | $fields_to_update[$field_name] = $field_value = trim($field_value); |
654 | 654 | } |
655 | 655 | // check if field contains a carriage return - exclude notes |
656 | - if ($field_name != 'note' && strpos($field_value,"\x0D\x0A") !== false) |
|
656 | + if ($field_name != 'note' && strpos($field_value, "\x0D\x0A") !== false) |
|
657 | 657 | { |
658 | - $fields_to_update[$field_name] = $field_value = str_replace("\x0D\x0A"," ",$field_value); |
|
658 | + $fields_to_update[$field_name] = $field_value = str_replace("\x0D\x0A", " ", $field_value); |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 | // check if a field contains an empty string |
@@ -665,13 +665,13 @@ discard block |
||
665 | 665 | } |
666 | 666 | // check for valid birthday date |
667 | 667 | if ($field_name == 'bday' && $field_value != null && |
668 | - !preg_match('/^(18|19|20|21|22)\d{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/',$field_value)) |
|
668 | + !preg_match('/^(18|19|20|21|22)\d{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/', $field_value)) |
|
669 | 669 | { |
670 | 670 | $fields_to_update[$field_name] = $field_value = null; |
671 | 671 | } |
672 | 672 | } |
673 | 673 | |
674 | - if(count($fields_to_update) > 0) |
|
674 | + if (count($fields_to_update) > 0) |
|
675 | 675 | { |
676 | 676 | $contact_to_save = array( |
677 | 677 | 'id' => $contact['id'], |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | 'account_id' => $contact['account_id'], |
681 | 681 | 'uid' => $contact['uid']) + $fields_to_update; |
682 | 682 | |
683 | - if ($this->save($contact_to_save,$ignore_acl)) |
|
683 | + if ($this->save($contact_to_save, $ignore_acl)) |
|
684 | 684 | { |
685 | 685 | $updated++; |
686 | 686 | } |
@@ -705,14 +705,14 @@ discard block |
||
705 | 705 | if (empty($contact['n_family']) && empty($contact['n_given'])) { |
706 | 706 | $cpart = array('org_name'); |
707 | 707 | } else { |
708 | - $cpart = array('n_prefix','n_given','n_middle','n_family','n_suffix'); |
|
708 | + $cpart = array('n_prefix', 'n_given', 'n_middle', 'n_family', 'n_suffix'); |
|
709 | 709 | } |
710 | 710 | $parts = array(); |
711 | - foreach($cpart as $n) |
|
711 | + foreach ($cpart as $n) |
|
712 | 712 | { |
713 | 713 | if ($contact[$n]) $parts[] = $contact[$n]; |
714 | 714 | } |
715 | - return implode(' ',$parts); |
|
715 | + return implode(' ', $parts); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | /** |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | * |
727 | 727 | * @return array updated data |
728 | 728 | */ |
729 | - function db2data($data, $date_format='ts') |
|
729 | + function db2data($data, $date_format = 'ts') |
|
730 | 730 | { |
731 | 731 | static $fb_url = false; |
732 | 732 | |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | $data[$name] = DateTime::server2user($data[$name], $date_format); |
739 | 739 | } |
740 | 740 | } |
741 | - $data['photo'] = $this->photo_src($data['id'],$data['jpegphoto'] || ($data['files'] & self::FILES_BIT_PHOTO), '', $data['etag']); |
|
741 | + $data['photo'] = $this->photo_src($data['id'], $data['jpegphoto'] || ($data['files']&self::FILES_BIT_PHOTO), '', $data['etag']); |
|
742 | 742 | |
743 | 743 | // set freebusy_uri for accounts |
744 | 744 | if (!$data['freebusy_uri'] && !$data['owner'] && $data['account_id'] && !is_object($GLOBALS['egw_setup'])) |
@@ -761,13 +761,13 @@ discard block |
||
761 | 761 | * @param string $etag =null etag to set in url to allow caching with Expires header |
762 | 762 | * @return string/array |
763 | 763 | */ |
764 | - function photo_src($id,$jpeg,$default='',$etag=null) |
|
764 | + function photo_src($id, $jpeg, $default = '', $etag = null) |
|
765 | 765 | { |
766 | 766 | //error_log(__METHOD__."($id, ..., etag=$etag) ". function_backtrace()); |
767 | 767 | return $jpeg ? array( |
768 | 768 | 'menuaction' => 'addressbook.addressbook_ui.photo', |
769 | 769 | 'contact_id' => $id, |
770 | - )+(isset($etag) ? array( |
|
770 | + ) + (isset($etag) ? array( |
|
771 | 771 | 'etag' => $etag, |
772 | 772 | ) : array()) : $default; |
773 | 773 | } |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | * |
784 | 784 | * @return array upated data |
785 | 785 | */ |
786 | - function data2db($data, $date_format='ts') |
|
786 | + function data2db($data, $date_format = 'ts') |
|
787 | 787 | { |
788 | 788 | // convert timestamps from user-time to server-time in the db |
789 | 789 | foreach ($this->timestamps as $name) |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | * @param int $check_etag =null |
805 | 805 | * @return boolean|int true on success or false on failiure, 0 if etag does not match |
806 | 806 | */ |
807 | - function delete($contact,$deny_account_delete=true,$check_etag=null) |
|
807 | + function delete($contact, $deny_account_delete = true, $check_etag = null) |
|
808 | 808 | { |
809 | 809 | if (is_array($contact) && isset($contact['id'])) |
810 | 810 | { |
@@ -814,12 +814,12 @@ discard block |
||
814 | 814 | { |
815 | 815 | $contact = array($contact); |
816 | 816 | } |
817 | - foreach($contact as $c) |
|
817 | + foreach ($contact as $c) |
|
818 | 818 | { |
819 | 819 | $id = is_array($c) ? $c['id'] : $c; |
820 | 820 | |
821 | 821 | $ok = false; |
822 | - if ($this->check_perms(Acl::DELETE,$c,$deny_account_delete)) |
|
822 | + if ($this->check_perms(Acl::DELETE, $c, $deny_account_delete)) |
|
823 | 823 | { |
824 | 824 | if (!($old = $this->read($id))) return false; |
825 | 825 | // check if we only mark contacts as deleted, or really delete them |
@@ -830,12 +830,12 @@ discard block |
||
830 | 830 | $delete = $old; |
831 | 831 | $delete['tid'] = self::DELETED_TYPE; |
832 | 832 | if ($check_etag) $delete['etag'] = $check_etag; |
833 | - if (($ok = $this->save($delete))) $ok = true; // we have to return true or false |
|
834 | - Link::unlink(0,'addressbook',$id,'','','',true); |
|
833 | + if (($ok = $this->save($delete))) $ok = true; // we have to return true or false |
|
834 | + Link::unlink(0, 'addressbook', $id, '', '', '', true); |
|
835 | 835 | } |
836 | - elseif (($ok = parent::delete($id,$check_etag))) |
|
836 | + elseif (($ok = parent::delete($id, $check_etag))) |
|
837 | 837 | { |
838 | - Link::unlink(0,'addressbook',$id); |
|
838 | + Link::unlink(0, 'addressbook', $id); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | // Don't notify of final purge |
@@ -862,11 +862,11 @@ discard block |
||
862 | 862 | * @param boolean $touch_modified =true should modified/r be updated |
863 | 863 | * @return int/string/boolean id on success, false on failure, the error-message is in $this->error |
864 | 864 | */ |
865 | - function save(&$contact, $ignore_acl=false, $touch_modified=true) |
|
865 | + function save(&$contact, $ignore_acl = false, $touch_modified = true) |
|
866 | 866 | { |
867 | 867 | // Make sure photo remains unchanged unless its purposely set to be false |
868 | 868 | // which means photo has changed. |
869 | - if (!array_key_exists('photo_unchanged',$contact)) $contact['photo_unchanged'] = true; |
|
869 | + if (!array_key_exists('photo_unchanged', $contact)) $contact['photo_unchanged'] = true; |
|
870 | 870 | |
871 | 871 | // remember if we add or update a entry |
872 | 872 | if (($isUpdate = $contact['id'])) |
@@ -875,11 +875,11 @@ discard block |
||
875 | 875 | { |
876 | 876 | if (($old = $this->read($contact['id']))) // --> try reading the old entry and set it from there |
877 | 877 | { |
878 | - if(!isset($contact['owner'])) |
|
878 | + if (!isset($contact['owner'])) |
|
879 | 879 | { |
880 | 880 | $contact['owner'] = $old['owner']; |
881 | 881 | } |
882 | - if(!isset($contact['private'])) |
|
882 | + if (!isset($contact['private'])) |
|
883 | 883 | { |
884 | 884 | $contact['private'] = $old['private']; |
885 | 885 | } |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | { |
912 | 912 | $contact['private'] = 0; |
913 | 913 | } |
914 | - if(!$ignore_acl && !$this->check_perms($isUpdate ? Acl::EDIT : Acl::ADD,$contact)) |
|
914 | + if (!$ignore_acl && !$this->check_perms($isUpdate ? Acl::EDIT : Acl::ADD, $contact)) |
|
915 | 915 | { |
916 | 916 | $this->error = 'access denied'; |
917 | 917 | return false; |
@@ -924,15 +924,15 @@ discard block |
||
924 | 924 | // convert categories |
925 | 925 | if (is_array($contact['cat_id'])) |
926 | 926 | { |
927 | - $contact['cat_id'] = implode(',',$contact['cat_id']); |
|
927 | + $contact['cat_id'] = implode(',', $contact['cat_id']); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | // Update country codes |
931 | - foreach(array('adr_one_', 'adr_two_') as $c_prefix) { |
|
932 | - if($contact[$c_prefix.'countryname'] && !$contact[$c_prefix.'countrycode'] && |
|
931 | + foreach (array('adr_one_', 'adr_two_') as $c_prefix) { |
|
932 | + if ($contact[$c_prefix.'countryname'] && !$contact[$c_prefix.'countrycode'] && |
|
933 | 933 | $code = Country::country_code($contact[$c_prefix.'countryname'])) |
934 | 934 | { |
935 | - if(strlen($code) == 2) |
|
935 | + if (strlen($code) == 2) |
|
936 | 936 | { |
937 | 937 | $contact[$c_prefix.'countrycode'] = $code; |
938 | 938 | } |
@@ -941,7 +941,7 @@ discard block |
||
941 | 941 | $contact[$c_prefix.'countrycode'] = null; |
942 | 942 | } |
943 | 943 | } |
944 | - if($contact[$c_prefix.'countrycode'] != null) |
|
944 | + if ($contact[$c_prefix.'countrycode'] != null) |
|
945 | 945 | { |
946 | 946 | $contact[$c_prefix.'countryname'] = null; |
947 | 947 | } |
@@ -969,9 +969,9 @@ discard block |
||
969 | 969 | // (non-admin) user editing his own account, make sure he does not change fields he is not allowed to (eg. via SyncML or xmlrpc) |
970 | 970 | if (!$ignore_acl && !$contact['owner'] && !($this->is_admin($contact) || $this->allow_account_edit())) |
971 | 971 | { |
972 | - foreach(array_keys($contact) as $field) |
|
972 | + foreach (array_keys($contact) as $field) |
|
973 | 973 | { |
974 | - if (!in_array($field,$this->own_account_acl) && !in_array($field,array('id','owner','account_id','modified','modifier'))) |
|
974 | + if (!in_array($field, $this->own_account_acl) && !in_array($field, array('id', 'owner', 'account_id', 'modified', 'modifier'))) |
|
975 | 975 | { |
976 | 976 | // user is not allowed to change that |
977 | 977 | if ($old) |
@@ -992,12 +992,12 @@ discard block |
||
992 | 992 | { |
993 | 993 | if (isset($to_write['owner']) && !empty($to_write['owner'])) |
994 | 994 | { |
995 | - error_log(__METHOD__.__LINE__." Trying to change account to owner:". $to_write['owner'].' Account affected:'.array2string($old).' Data send:'.array2string($to_write)); |
|
995 | + error_log(__METHOD__.__LINE__." Trying to change account to owner:".$to_write['owner'].' Account affected:'.array2string($old).' Data send:'.array2string($to_write)); |
|
996 | 996 | unset($to_write['owner']); |
997 | 997 | } |
998 | 998 | } |
999 | 999 | |
1000 | - if(!($this->error = parent::save($to_write))) |
|
1000 | + if (!($this->error = parent::save($to_write))) |
|
1001 | 1001 | { |
1002 | 1002 | $contact['id'] = $to_write['id']; |
1003 | 1003 | $contact['uid'] = $to_write['uid']; |
@@ -1006,9 +1006,9 @@ discard block |
||
1006 | 1006 | |
1007 | 1007 | // Clear any files saved with new entries |
1008 | 1008 | // They've been dealt with already and they cause errors with linking |
1009 | - foreach(array_keys($this->customfields) as $field) |
|
1009 | + foreach (array_keys($this->customfields) as $field) |
|
1010 | 1010 | { |
1011 | - if(is_array($to_write[Storage::CF_PREFIX.$field])) |
|
1011 | + if (is_array($to_write[Storage::CF_PREFIX.$field])) |
|
1012 | 1012 | { |
1013 | 1013 | unset($to_write[Storage::CF_PREFIX.$field]); |
1014 | 1014 | } |
@@ -1022,27 +1022,27 @@ discard block |
||
1022 | 1022 | $GLOBALS['egw']->accounts->cache_invalidate($contact['account_id']); |
1023 | 1023 | // call edit-accout hook, to let other apps know about changed account (names or email) |
1024 | 1024 | $GLOBALS['hook_values'] = (array)$GLOBALS['egw']->accounts->read($contact['account_id']); |
1025 | - Hooks::process($GLOBALS['hook_values']+array( |
|
1025 | + Hooks::process($GLOBALS['hook_values'] + array( |
|
1026 | 1026 | 'location' => 'editaccount', |
1027 | - ),False,True); // called for every app now, not only enabled ones) |
|
1027 | + ), False, True); // called for every app now, not only enabled ones) |
|
1028 | 1028 | } |
1029 | 1029 | // notify interested apps about changes in the account-contact data |
1030 | 1030 | if (!$to_write['owner'] && $to_write['account_id'] && $isUpdate) |
1031 | 1031 | { |
1032 | 1032 | $to_write['location'] = 'editaccountcontact'; |
1033 | - Hooks::process($to_write,False,True); // called for every app now, not only enabled ones)); |
|
1033 | + Hooks::process($to_write, False, True); // called for every app now, not only enabled ones)); |
|
1034 | 1034 | } |
1035 | 1035 | // Notify linked apps about changes in the contact data |
1036 | - Link::notify_update('addressbook', $contact['id'], $contact); |
|
1036 | + Link::notify_update('addressbook', $contact['id'], $contact); |
|
1037 | 1037 | |
1038 | 1038 | // Check for restore of deleted contact, restore held links |
1039 | - if($old && $old['tid'] == self::DELETED_TYPE && $contact['tid'] != self::DELETED_TYPE) |
|
1039 | + if ($old && $old['tid'] == self::DELETED_TYPE && $contact['tid'] != self::DELETED_TYPE) |
|
1040 | 1040 | { |
1041 | 1041 | Link::restore('addressbook', $contact['id']); |
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | // Record change history for sql - doesn't work for LDAP accounts |
1045 | - if(!$contact['account_id'] || $contact['account_id'] && $this->account_repository == 'sql') |
|
1045 | + if (!$contact['account_id'] || $contact['account_id'] && $this->account_repository == 'sql') |
|
1046 | 1046 | { |
1047 | 1047 | $deleted = ($old['tid'] == self::DELETED_TYPE || $contact['tid'] == self::DELETED_TYPE); |
1048 | 1048 | if (!isset($this->tracking)) $this->tracking = new Contacts\Tracking($this); |
@@ -1050,9 +1050,9 @@ discard block |
||
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | // Expire birthday cache for this year and next if birthday changed |
1053 | - if($isUpdate && $old['bday'] !== $to_write['bday'] || !$isUpdate && $to_write['bday']) |
|
1053 | + if ($isUpdate && $old['bday'] !== $to_write['bday'] || !$isUpdate && $to_write['bday']) |
|
1054 | 1054 | { |
1055 | - $year = (int) date('Y',time()); |
|
1055 | + $year = (int)date('Y', time()); |
|
1056 | 1056 | $this->clear_birthday_cache($year, $to_write['owner']); |
1057 | 1057 | $year++; |
1058 | 1058 | $this->clear_birthday_cache($year, $to_write['owner']); |
@@ -1071,9 +1071,9 @@ discard block |
||
1071 | 1071 | protected function clear_birthday_cache($year, $owner) |
1072 | 1072 | { |
1073 | 1073 | // Cache is kept per-language, so clear them all |
1074 | - foreach(array_keys(Translation::get_installed_langs()) as $lang) |
|
1074 | + foreach (array_keys(Translation::get_installed_langs()) as $lang) |
|
1075 | 1075 | { |
1076 | - Cache::unsetInstance(__CLASS__,"birthday-$year-{$owner}-$lang"); |
|
1076 | + Cache::unsetInstance(__CLASS__, "birthday-$year-{$owner}-$lang"); |
|
1077 | 1077 | } |
1078 | 1078 | } |
1079 | 1079 | |
@@ -1086,7 +1086,7 @@ discard block |
||
1086 | 1086 | * @param int $dst_w =240 max width to resize to |
1087 | 1087 | * @return string with resized jpeg photo, null on error |
1088 | 1088 | */ |
1089 | - public static function resize_photo($photo, $dst_w=240) |
|
1089 | + public static function resize_photo($photo, $dst_w = 240) |
|
1090 | 1090 | { |
1091 | 1091 | if (is_resource($photo)) |
1092 | 1092 | { |
@@ -1102,15 +1102,15 @@ discard block |
||
1102 | 1102 | //error_log(__METHOD__."() got image $src_w * $src_h, is_jpeg=".array2string(substr($photo,0,2) === "\377\330")); |
1103 | 1103 | |
1104 | 1104 | // if $photo is to width or not a jpeg image --> resize it |
1105 | - if ($src_w > $dst_w || cut_bytes($photo,0,2) !== "\377\330") |
|
1105 | + if ($src_w > $dst_w || cut_bytes($photo, 0, 2) !== "\377\330") |
|
1106 | 1106 | { |
1107 | 1107 | //error_log(__METHOD__."(,dst_w=$dst_w) src_w=$src_w, cut_bytes(photo,0,2)=".array2string(cut_bytes($photo,0,2)).' --> resizing'); |
1108 | 1108 | // scale the image to a width of 60 and a height according to the proportion of the source image |
1109 | - $resized = imagecreatetruecolor($dst_w,$dst_h = round($src_h * $dst_w / $src_w)); |
|
1110 | - imagecopyresized($resized,$image,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h); |
|
1109 | + $resized = imagecreatetruecolor($dst_w, $dst_h = round($src_h * $dst_w / $src_w)); |
|
1110 | + imagecopyresized($resized, $image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h); |
|
1111 | 1111 | |
1112 | 1112 | ob_start(); |
1113 | - imagejpeg($resized,null,90); |
|
1113 | + imagejpeg($resized, null, 90); |
|
1114 | 1114 | $photo = ob_get_contents(); |
1115 | 1115 | ob_end_clean(); |
1116 | 1116 | |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | * @param boolean $ignore_acl =false true: no acl check |
1132 | 1132 | * @return array|boolean array with contact data, null if not found or false on no view perms |
1133 | 1133 | */ |
1134 | - function read($contact_id, $ignore_acl=false) |
|
1134 | + function read($contact_id, $ignore_acl = false) |
|
1135 | 1135 | { |
1136 | 1136 | // get so_sql_cf to read private customfields too, if we ignore acl |
1137 | 1137 | if ($ignore_acl && is_a($this->somain, __CLASS__.'\\Sql')) |
@@ -1141,11 +1141,11 @@ discard block |
||
1141 | 1141 | } |
1142 | 1142 | if (!($data = parent::read($contact_id))) |
1143 | 1143 | { |
1144 | - $data = null; // not found |
|
1144 | + $data = null; // not found |
|
1145 | 1145 | } |
1146 | - elseif (!$ignore_acl && !$this->check_perms(Acl::READ,$data)) |
|
1146 | + elseif (!$ignore_acl && !$this->check_perms(Acl::READ, $data)) |
|
1147 | 1147 | { |
1148 | - $data = false; // no view perms |
|
1148 | + $data = false; // no view perms |
|
1149 | 1149 | } |
1150 | 1150 | else |
1151 | 1151 | { |
@@ -1153,10 +1153,10 @@ discard block |
||
1153 | 1153 | $data['fileas_type'] = $this->fileas_type($data); |
1154 | 1154 | |
1155 | 1155 | // Update country name from code |
1156 | - if($data['adr_one_countrycode'] != null) { |
|
1156 | + if ($data['adr_one_countrycode'] != null) { |
|
1157 | 1157 | $data['adr_one_countryname'] = Country::get_full_name($data['adr_one_countrycode'], true); |
1158 | 1158 | } |
1159 | - if($data['adr_two_countrycode'] != null) { |
|
1159 | + if ($data['adr_two_countrycode'] != null) { |
|
1160 | 1160 | $data['adr_two_countryname'] = Country::get_full_name($data['adr_two_countrycode'], true); |
1161 | 1161 | } |
1162 | 1162 | } |
@@ -1180,7 +1180,7 @@ discard block |
||
1180 | 1180 | * @param int $user =null for which user to check, default current user |
1181 | 1181 | * @return boolean true permission granted, false for permission denied, null for contact does not exist |
1182 | 1182 | */ |
1183 | - function check_perms($needed,$contact,$deny_account_delete=false,$user=null) |
|
1183 | + function check_perms($needed, $contact, $deny_account_delete = false, $user = null) |
|
1184 | 1184 | { |
1185 | 1185 | if (!$user) $user = $this->user; |
1186 | 1186 | if ($user == $this->user) |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | else |
1192 | 1192 | { |
1193 | 1193 | $grants = $this->get_grants($user); |
1194 | - $memberships = $GLOBALS['egw']->accounts->memberships($user,true); |
|
1194 | + $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | if ((!is_array($contact) || !isset($contact['owner'])) && |
@@ -1217,12 +1217,12 @@ discard block |
||
1217 | 1217 | $GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'groupmembers' && |
1218 | 1218 | !isset($GLOBALS['egw_info']['user']['apps']['admin'])) |
1219 | 1219 | { |
1220 | - $access = !!array_intersect($memberships,$GLOBALS['egw']->accounts->memberships($contact['account_id'],true)); |
|
1220 | + $access = !!array_intersect($memberships, $GLOBALS['egw']->accounts->memberships($contact['account_id'], true)); |
|
1221 | 1221 | } |
1222 | 1222 | else |
1223 | 1223 | { |
1224 | - $access = ($grants[$owner] & $needed) && |
|
1225 | - (!$contact['private'] || ($grants[$owner] & Acl::PRIVAT) || in_array($owner,$memberships)); |
|
1224 | + $access = ($grants[$owner]&$needed) && |
|
1225 | + (!$contact['private'] || ($grants[$owner]&Acl::PRIVAT) || in_array($owner, $memberships)); |
|
1226 | 1226 | } |
1227 | 1227 | //error_log(__METHOD__."($needed,$contact[id],$deny_account_delete,$user) returning ".array2string($access)); |
1228 | 1228 | return $access; |
@@ -1237,11 +1237,11 @@ discard block |
||
1237 | 1237 | * @param int $user =null for which user to check, default current user |
1238 | 1238 | * @return boolean true if access is granted or false otherwise |
1239 | 1239 | */ |
1240 | - function file_access($id,$check,$rel_path=null,$user=null) |
|
1240 | + function file_access($id, $check, $rel_path = null, $user = null) |
|
1241 | 1241 | { |
1242 | - unset($rel_path); // not used, but required by function signature |
|
1242 | + unset($rel_path); // not used, but required by function signature |
|
1243 | 1243 | |
1244 | - return $this->check_perms($check,$id,false,$user); |
|
1244 | + return $this->check_perms($check, $id, false, $user); |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | /** |
@@ -1253,18 +1253,18 @@ discard block |
||
1253 | 1253 | function read_org($org_id) |
1254 | 1254 | { |
1255 | 1255 | if (!$org_id) return false; |
1256 | - if (strpos($org_id,'*AND*')!== false) $org_id = str_replace('*AND*','&',$org_id); |
|
1256 | + if (strpos($org_id, '*AND*') !== false) $org_id = str_replace('*AND*', '&', $org_id); |
|
1257 | 1257 | $org = array(); |
1258 | - foreach(explode('|||',$org_id) as $part) |
|
1258 | + foreach (explode('|||', $org_id) as $part) |
|
1259 | 1259 | { |
1260 | - list($name,$value) = explode(':',$part,2); |
|
1260 | + list($name, $value) = explode(':', $part, 2); |
|
1261 | 1261 | $org[$name] = $value; |
1262 | 1262 | } |
1263 | - $csvs = array('cat_id'); // fields with comma-separated-values |
|
1263 | + $csvs = array('cat_id'); // fields with comma-separated-values |
|
1264 | 1264 | |
1265 | 1265 | // split regular fields and custom fields |
1266 | 1266 | $custom_fields = $regular_fields = array(); |
1267 | - foreach($this->org_fields as $name) |
|
1267 | + foreach ($this->org_fields as $name) |
|
1268 | 1268 | { |
1269 | 1269 | if ($name[0] != '#') |
1270 | 1270 | { |
@@ -1272,9 +1272,9 @@ discard block |
||
1272 | 1272 | } |
1273 | 1273 | else |
1274 | 1274 | { |
1275 | - $custom_fields[] = $name = substr($name,1); |
|
1275 | + $custom_fields[] = $name = substr($name, 1); |
|
1276 | 1276 | $regular_fields['id'] = 'id'; |
1277 | - if (substr($this->customfields[$name]['type'],0,6)=='select' && $this->customfields[$name]['rows'] || // multiselection |
|
1277 | + if (substr($this->customfields[$name]['type'], 0, 6) == 'select' && $this->customfields[$name]['rows'] || // multiselection |
|
1278 | 1278 | $this->customfields[$name]['type'] == 'radio') |
1279 | 1279 | { |
1280 | 1280 | $csvs[] = '#'.$name; |
@@ -1282,24 +1282,24 @@ discard block |
||
1282 | 1282 | } |
1283 | 1283 | } |
1284 | 1284 | // read the regular fields |
1285 | - $contacts = parent::search('',$regular_fields,'','','',false,'AND',false,$org); |
|
1285 | + $contacts = parent::search('', $regular_fields, '', '', '', false, 'AND', false, $org); |
|
1286 | 1286 | if (!$contacts) return false; |
1287 | 1287 | |
1288 | 1288 | // if we have custom fields, read and merge them in |
1289 | 1289 | if ($custom_fields) |
1290 | 1290 | { |
1291 | - foreach($contacts as $contact) |
|
1291 | + foreach ($contacts as $contact) |
|
1292 | 1292 | { |
1293 | 1293 | $ids[] = $contact['id']; |
1294 | 1294 | } |
1295 | - if (($cfs = $this->read_customfields($ids,$custom_fields))) |
|
1295 | + if (($cfs = $this->read_customfields($ids, $custom_fields))) |
|
1296 | 1296 | { |
1297 | 1297 | foreach ($contacts as &$contact) |
1298 | 1298 | { |
1299 | 1299 | $id = $contact['id']; |
1300 | 1300 | if (isset($cfs[$id])) |
1301 | 1301 | { |
1302 | - foreach($cfs[$id] as $name => $value) |
|
1302 | + foreach ($cfs[$id] as $name => $value) |
|
1303 | 1303 | { |
1304 | 1304 | $contact['#'.$name] = $value; |
1305 | 1305 | } |
@@ -1311,33 +1311,33 @@ discard block |
||
1311 | 1311 | |
1312 | 1312 | // create a statistic about the commonness of each fields values |
1313 | 1313 | $fields = array(); |
1314 | - foreach($contacts as $contact) |
|
1314 | + foreach ($contacts as $contact) |
|
1315 | 1315 | { |
1316 | - foreach($contact as $name => $value) |
|
1316 | + foreach ($contact as $name => $value) |
|
1317 | 1317 | { |
1318 | - if (!in_array($name,$csvs)) |
|
1318 | + if (!in_array($name, $csvs)) |
|
1319 | 1319 | { |
1320 | 1320 | $fields[$name][$value]++; |
1321 | 1321 | } |
1322 | 1322 | else |
1323 | 1323 | { |
1324 | 1324 | // for comma separated fields, we have to use each single value |
1325 | - foreach(explode(',',$value) as $val) |
|
1325 | + foreach (explode(',', $value) as $val) |
|
1326 | 1326 | { |
1327 | 1327 | $fields[$name][$val]++; |
1328 | 1328 | } |
1329 | 1329 | } |
1330 | 1330 | } |
1331 | 1331 | } |
1332 | - foreach($fields as $name => $values) |
|
1332 | + foreach ($fields as $name => $values) |
|
1333 | 1333 | { |
1334 | - if (!in_array($name,$this->org_fields)) continue; |
|
1334 | + if (!in_array($name, $this->org_fields)) continue; |
|
1335 | 1335 | |
1336 | - arsort($values,SORT_NUMERIC); |
|
1337 | - list($value,$num) = each($values); |
|
1338 | - if ($value && $num / (double) count($contacts) >= $this->org_common_factor) |
|
1336 | + arsort($values, SORT_NUMERIC); |
|
1337 | + list($value, $num) = each($values); |
|
1338 | + if ($value && $num / (double)count($contacts) >= $this->org_common_factor) |
|
1339 | 1339 | { |
1340 | - if (!in_array($name,$csvs)) |
|
1340 | + if (!in_array($name, $csvs)) |
|
1341 | 1341 | { |
1342 | 1342 | $org[$name] = $value; |
1343 | 1343 | } |
@@ -1346,12 +1346,12 @@ discard block |
||
1346 | 1346 | $org[$name] = array(); |
1347 | 1347 | foreach ($values as $value => $num) |
1348 | 1348 | { |
1349 | - if ($value && $num / (double) count($contacts) >= $this->org_common_factor) |
|
1349 | + if ($value && $num / (double)count($contacts) >= $this->org_common_factor) |
|
1350 | 1350 | { |
1351 | 1351 | $org[$name][] = $value; |
1352 | 1352 | } |
1353 | 1353 | } |
1354 | - $org[$name] = implode(',',$org[$name]); |
|
1354 | + $org[$name] = implode(',', $org[$name]); |
|
1355 | 1355 | } |
1356 | 1356 | } |
1357 | 1357 | } |
@@ -1365,10 +1365,10 @@ discard block |
||
1365 | 1365 | * @param array $fields field-name => value pairs |
1366 | 1366 | * @return array with contacts |
1367 | 1367 | */ |
1368 | - function org_similar($org_name,$fields) |
|
1368 | + function org_similar($org_name, $fields) |
|
1369 | 1369 | { |
1370 | 1370 | $criteria = array(); |
1371 | - foreach($this->org_fields as $name) |
|
1371 | + foreach ($this->org_fields as $name) |
|
1372 | 1372 | { |
1373 | 1373 | if (isset($fields[$name])) |
1374 | 1374 | { |
@@ -1382,7 +1382,7 @@ discard block |
||
1382 | 1382 | } |
1383 | 1383 | } |
1384 | 1384 | } |
1385 | - return parent::search($criteria,false,'n_family,n_given','','',false,'OR',false,array('org_name'=>$org_name)); |
|
1385 | + return parent::search($criteria, false, 'n_family,n_given', '', '', false, 'OR', false, array('org_name'=>$org_name)); |
|
1386 | 1386 | } |
1387 | 1387 | |
1388 | 1388 | /** |
@@ -1393,10 +1393,10 @@ discard block |
||
1393 | 1393 | * @param boolean $only_org_fields =true check and return only org_fields, default true |
1394 | 1394 | * @return array with field-name => value from $from |
1395 | 1395 | */ |
1396 | - function changed_fields($from,$to,$only_org_fields=true) |
|
1396 | + function changed_fields($from, $to, $only_org_fields = true) |
|
1397 | 1397 | { |
1398 | 1398 | // we only care about countryname, if contrycode is empty |
1399 | - foreach(array( |
|
1399 | + foreach (array( |
|
1400 | 1400 | 'adr_one_countryname' => 'adr_one_countrycode', |
1401 | 1401 | 'adr_two_countryname' => 'adr_one_countrycode', |
1402 | 1402 | ) as $name => $code) |
@@ -1405,13 +1405,13 @@ discard block |
||
1405 | 1405 | if (!empty($to[$code])) $to[$name] = ''; |
1406 | 1406 | } |
1407 | 1407 | $changed = array(); |
1408 | - foreach($only_org_fields ? $this->org_fields : array_keys($this->contact_fields) as $name) |
|
1408 | + foreach ($only_org_fields ? $this->org_fields : array_keys($this->contact_fields) as $name) |
|
1409 | 1409 | { |
1410 | - if (in_array($name,array('modified','modifier'))) // never count these |
|
1410 | + if (in_array($name, array('modified', 'modifier'))) // never count these |
|
1411 | 1411 | { |
1412 | 1412 | continue; |
1413 | 1413 | } |
1414 | - if ((string) $from[$name] != (string) $to[$name]) |
|
1414 | + if ((string)$from[$name] != (string)$to[$name]) |
|
1415 | 1415 | { |
1416 | 1416 | $changed[$name] = $from[$name]; |
1417 | 1417 | } |
@@ -1428,35 +1428,35 @@ discard block |
||
1428 | 1428 | * @param array $members =null org-members to change, default null --> function queries them itself |
1429 | 1429 | * @return array/boolean (changed-members,changed-fields,failed-members) or false if no org_fields changed or no (other) members matching that fields |
1430 | 1430 | */ |
1431 | - function change_org($org_name,$from,$to,$members=null) |
|
1431 | + function change_org($org_name, $from, $to, $members = null) |
|
1432 | 1432 | { |
1433 | - if (!($changed = $this->changed_fields($from,$to,true))) return false; |
|
1433 | + if (!($changed = $this->changed_fields($from, $to, true))) return false; |
|
1434 | 1434 | |
1435 | 1435 | if (is_null($members) || !is_array($members)) |
1436 | 1436 | { |
1437 | - $members = $this->org_similar($org_name,$changed); |
|
1437 | + $members = $this->org_similar($org_name, $changed); |
|
1438 | 1438 | } |
1439 | 1439 | if (!$members) return false; |
1440 | 1440 | |
1441 | 1441 | $ids = array(); |
1442 | - foreach($members as $member) |
|
1442 | + foreach ($members as $member) |
|
1443 | 1443 | { |
1444 | 1444 | $ids[] = $member['id']; |
1445 | 1445 | } |
1446 | 1446 | $customfields = $this->read_customfields($ids); |
1447 | 1447 | |
1448 | 1448 | $changed_members = $changed_fields = $failed_members = 0; |
1449 | - foreach($members as $member) |
|
1449 | + foreach ($members as $member) |
|
1450 | 1450 | { |
1451 | 1451 | if (isset($customfields[$member['id']])) |
1452 | 1452 | { |
1453 | - foreach(array_keys($this->customfields) as $name) |
|
1453 | + foreach (array_keys($this->customfields) as $name) |
|
1454 | 1454 | { |
1455 | 1455 | $member['#'.$name] = $customfields[$member['id']][$name]; |
1456 | 1456 | } |
1457 | 1457 | } |
1458 | 1458 | $fields = 0; |
1459 | - foreach($changed as $name => $value) |
|
1459 | + foreach ($changed as $name => $value) |
|
1460 | 1460 | { |
1461 | 1461 | if ((string)$value == (string)$member[$name]) |
1462 | 1462 | { |
@@ -1466,7 +1466,7 @@ discard block |
||
1466 | 1466 | } |
1467 | 1467 | if ($fields) |
1468 | 1468 | { |
1469 | - if (!$this->check_perms(Acl::EDIT,$member) || !$this->save($member)) |
|
1469 | + if (!$this->check_perms(Acl::EDIT, $member) || !$this->save($member)) |
|
1470 | 1470 | { |
1471 | 1471 | ++$failed_members; |
1472 | 1472 | } |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | } |
1478 | 1478 | } |
1479 | 1479 | } |
1480 | - return array($changed_members,$changed_fields,$failed_members); |
|
1480 | + return array($changed_members, $changed_fields, $failed_members); |
|
1481 | 1481 | } |
1482 | 1482 | |
1483 | 1483 | /** |
@@ -1504,20 +1504,20 @@ discard block |
||
1504 | 1504 | if ($contact['n_fileas']) return $contact['n_fileas']; |
1505 | 1505 | $type = null; |
1506 | 1506 | } |
1507 | - $title = $this->fileas($contact,$type); |
|
1507 | + $title = $this->fileas($contact, $type); |
|
1508 | 1508 | |
1509 | 1509 | if (!empty($this->prefs['link_title_cf'])) |
1510 | 1510 | { |
1511 | 1511 | $field_list = is_string($this->prefs['link_title_cf']) ? explode(',', $this->prefs['link_title_cf']) : $this->prefs['link_title_cf']; |
1512 | 1512 | foreach ($field_list as $field) |
1513 | 1513 | { |
1514 | - if($contact['#'.$field]) |
|
1514 | + if ($contact['#'.$field]) |
|
1515 | 1515 | { |
1516 | - $title .= ', ' . $contact['#'.$field]; |
|
1516 | + $title .= ', '.$contact['#'.$field]; |
|
1517 | 1517 | } |
1518 | 1518 | } |
1519 | 1519 | } |
1520 | - return $title ; |
|
1520 | + return $title; |
|
1521 | 1521 | } |
1522 | 1522 | |
1523 | 1523 | /** |
@@ -1531,21 +1531,21 @@ discard block |
||
1531 | 1531 | function link_titles(array $ids) |
1532 | 1532 | { |
1533 | 1533 | $titles = array(); |
1534 | - if (($contacts =& $this->search(array('contact_id' => $ids),false))) |
|
1534 | + if (($contacts = & $this->search(array('contact_id' => $ids), false))) |
|
1535 | 1535 | { |
1536 | 1536 | $ids = array(); |
1537 | - foreach($contacts as $contact) |
|
1537 | + foreach ($contacts as $contact) |
|
1538 | 1538 | { |
1539 | 1539 | $ids[] = $contact['id']; |
1540 | 1540 | } |
1541 | 1541 | $cfs = $this->read_customfields($ids); |
1542 | - foreach($contacts as $contact) |
|
1542 | + foreach ($contacts as $contact) |
|
1543 | 1543 | { |
1544 | - $titles[$contact['id']] = $this->link_title($contact+(array)$cfs[$contact['id']]); |
|
1544 | + $titles[$contact['id']] = $this->link_title($contact + (array)$cfs[$contact['id']]); |
|
1545 | 1545 | } |
1546 | 1546 | } |
1547 | 1547 | // we assume all not returned contacts are not readable for the user (as we report all deleted contacts to egw_link) |
1548 | - foreach($ids as $id) |
|
1548 | + foreach ($ids as $id) |
|
1549 | 1549 | { |
1550 | 1550 | if (!isset($titles[$id])) |
1551 | 1551 | { |
@@ -1572,23 +1572,23 @@ discard block |
||
1572 | 1572 | { |
1573 | 1573 | $criteria = is_array($pattern) ? $pattern['search'] : $pattern; |
1574 | 1574 | } |
1575 | - if($options['start'] || $options['num_rows']) |
|
1575 | + if ($options['start'] || $options['num_rows']) |
|
1576 | 1576 | { |
1577 | 1577 | $limit = array($options['start'], $options['num_rows']); |
1578 | 1578 | } |
1579 | 1579 | $filter = (array)$options['filter']; |
1580 | 1580 | if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') $filter['account_id'] = null; |
1581 | - if (($contacts =& parent::search($criteria,false,'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR', $limit, $filter))) |
|
1581 | + if (($contacts = & parent::search($criteria, false, 'org_name,n_family,n_given,cat_id,contact_email', '', '%', false, 'OR', $limit, $filter))) |
|
1582 | 1582 | { |
1583 | 1583 | $ids = array(); |
1584 | - foreach($contacts as $contact) |
|
1584 | + foreach ($contacts as $contact) |
|
1585 | 1585 | { |
1586 | 1586 | $ids[] = $contact['id']; |
1587 | 1587 | } |
1588 | 1588 | $cfs = $this->read_customfields($ids); |
1589 | - foreach($contacts as $contact) |
|
1589 | + foreach ($contacts as $contact) |
|
1590 | 1590 | { |
1591 | - $result[$contact['id']] = $this->link_title($contact+(array)$cfs[$contact['id']]); |
|
1591 | + $result[$contact['id']] = $this->link_title($contact + (array)$cfs[$contact['id']]); |
|
1592 | 1592 | // make sure to return a correctly quoted rfc822 address, if requested |
1593 | 1593 | if ($options['type'] === 'email') |
1594 | 1594 | { |
@@ -1629,7 +1629,7 @@ discard block |
||
1629 | 1629 | // let link query know, to append email to list |
1630 | 1630 | $options['type'] = 'email'; |
1631 | 1631 | |
1632 | - return $this->link_query($pattern,$options); |
|
1632 | + return $this->link_query($pattern, $options); |
|
1633 | 1633 | } |
1634 | 1634 | |
1635 | 1635 | /** |
@@ -1643,14 +1643,14 @@ discard block |
||
1643 | 1643 | if (!$ids) return null; |
1644 | 1644 | |
1645 | 1645 | $data = array(); |
1646 | - foreach(!is_array($ids) ? array($ids) : $ids as $id) |
|
1646 | + foreach (!is_array($ids) ? array($ids) : $ids as $id) |
|
1647 | 1647 | { |
1648 | 1648 | if (!($contact = $this->read($id))) continue; |
1649 | 1649 | |
1650 | 1650 | $data[] = array( |
1651 | 1651 | 'res_id' => $id, |
1652 | 1652 | 'email' => $contact['email'] ? $contact['email'] : $contact['email_home'], |
1653 | - 'rights' => Acl::CUSTOM1|Acl::CUSTOM3, // calendar_bo::ACL_READ_FOR_PARTICIPANTS|ACL_INVITE |
|
1653 | + 'rights' => Acl::CUSTOM1|Acl::CUSTOM3, // calendar_bo::ACL_READ_FOR_PARTICIPANTS|ACL_INVITE |
|
1654 | 1654 | 'name' => $this->link_title($contact), |
1655 | 1655 | 'cn' => trim($contact['n_given'].' '.$contact['n_family']), |
1656 | 1656 | ); |
@@ -1665,37 +1665,37 @@ discard block |
||
1665 | 1665 | * @param boolean $extra_title =true if true, use a short date only title and put the full title as extra_title (tooltip) |
1666 | 1666 | * @return array |
1667 | 1667 | */ |
1668 | - function read_calendar($uids,$extra_title=true) |
|
1668 | + function read_calendar($uids, $extra_title = true) |
|
1669 | 1669 | { |
1670 | 1670 | if (!$GLOBALS['egw_info']['user']['apps']['calendar']) return array(); |
1671 | 1671 | |
1672 | 1672 | $split_uids = array(); |
1673 | 1673 | $events = array(); |
1674 | 1674 | |
1675 | - foreach($uids as $id => $uid) |
|
1675 | + foreach ($uids as $id => $uid) |
|
1676 | 1676 | { |
1677 | 1677 | $type = is_numeric($uid[0]) ? 'u' : $uid[0]; |
1678 | - if($GLOBALS['egw_info']['server']['disable_event_column'] == 'contacts' && $type == 'u') |
|
1678 | + if ($GLOBALS['egw_info']['server']['disable_event_column'] == 'contacts' && $type == 'u') |
|
1679 | 1679 | { |
1680 | 1680 | continue; |
1681 | 1681 | } |
1682 | 1682 | $split_uids[$type][$id] = str_replace($type, '', $uid); |
1683 | 1683 | } |
1684 | 1684 | |
1685 | - foreach($split_uids as $type => $s_uids) |
|
1685 | + foreach ($split_uids as $type => $s_uids) |
|
1686 | 1686 | { |
1687 | 1687 | $events += $this->read_calendar_type($s_uids, $type, $extra_title); |
1688 | 1688 | } |
1689 | 1689 | return $events; |
1690 | 1690 | } |
1691 | 1691 | |
1692 | - private function read_calendar_type($uids, $type='c', $extra_title = true) |
|
1692 | + private function read_calendar_type($uids, $type = 'c', $extra_title = true) |
|
1693 | 1693 | { |
1694 | 1694 | $calendars = array(); |
1695 | 1695 | $bocal = new calendar_bo(); |
1696 | - $type_field = $type=='u' ? 'account_id' : 'contact_id'; |
|
1696 | + $type_field = $type == 'u' ? 'account_id' : 'contact_id'; |
|
1697 | 1697 | $type_field_varchar = $this->db->to_varchar($type_field); |
1698 | - $concat_start_id_recurrance = $this->db->concat('cal_start',"':'",'egw_cal_user.cal_id',"':'",'cal_recur_date'); |
|
1698 | + $concat_start_id_recurrance = $this->db->concat('cal_start', "':'", 'egw_cal_user.cal_id', "':'", 'cal_recur_date'); |
|
1699 | 1699 | $now = $this->db->unix_timestamp('NOW()'); |
1700 | 1700 | $sql = "SELECT n_fn,org_name,$type_field AS user_id, |
1701 | 1701 | ( |
@@ -1704,7 +1704,7 @@ discard block |
||
1704 | 1704 | JOIN egw_cal_dates on egw_cal_dates.cal_id=egw_cal_user.cal_id and (cal_recur_date=0 or cal_recur_date=cal_start) |
1705 | 1705 | JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id AND egw_cal.cal_deleted IS NULL |
1706 | 1706 | WHERE cal_user_type='$type' and cal_user_id=$type_field_varchar and cal_start < $now"; |
1707 | - if ( !$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected']) |
|
1707 | + if (!$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected']) |
|
1708 | 1708 | { |
1709 | 1709 | $sql .= " AND egw_cal_user.cal_status != 'R'"; |
1710 | 1710 | } |
@@ -1717,7 +1717,7 @@ discard block |
||
1717 | 1717 | JOIN egw_cal_dates on egw_cal_dates.cal_id=egw_cal_user.cal_id and (cal_recur_date=0 or cal_recur_date=cal_start) |
1718 | 1718 | JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id AND egw_cal.cal_deleted IS NULL |
1719 | 1719 | WHERE cal_user_type='$type' and cal_user_id=$type_field_varchar and cal_start > $now"; |
1720 | - if ( !$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected']) |
|
1720 | + if (!$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected']) |
|
1721 | 1721 | { |
1722 | 1722 | $sql .= " AND egw_cal_user.cal_status != 'R'"; |
1723 | 1723 | } |
@@ -1728,7 +1728,7 @@ discard block |
||
1728 | 1728 | WHERE '.$this->db->expression('egw_addressbook', array($type_field => $uids)); |
1729 | 1729 | |
1730 | 1730 | |
1731 | - $contacts =& $this->db->query($sql, __LINE__, __FILE__); |
|
1731 | + $contacts = & $this->db->query($sql, __LINE__, __FILE__); |
|
1732 | 1732 | |
1733 | 1733 | if (!$contacts) return array(); |
1734 | 1734 | |
@@ -1738,11 +1738,11 @@ discard block |
||
1738 | 1738 | list($start, $cal_id, $recur_date) = explode(':', $contact[$key.'_event']); |
1739 | 1739 | |
1740 | 1740 | $link = array( |
1741 | - 'id' => $cal_id,//.':'.$start, |
|
1741 | + 'id' => $cal_id, //.':'.$start, |
|
1742 | 1742 | 'app' => 'calendar', |
1743 | - 'title' => $bocal->link_title($cal_id . ($start ? '-'.$start : '')), |
|
1743 | + 'title' => $bocal->link_title($cal_id.($start ? '-'.$start : '')), |
|
1744 | 1744 | 'extra_args' => array( |
1745 | - 'date' => \EGroupware\Api\DateTime::server2user($start,\EGroupware\Api\DateTime::ET2), |
|
1745 | + 'date' => \EGroupware\Api\DateTime::server2user($start, \EGroupware\Api\DateTime::ET2), |
|
1746 | 1746 | 'exception'=> 1 |
1747 | 1747 | ), |
1748 | 1748 | ); |
@@ -1751,18 +1751,18 @@ discard block |
||
1751 | 1751 | $link['extra_title'] = $link['title']; |
1752 | 1752 | $link['title'] = \EGroupware\Api\DateTime::server2user($start, true); |
1753 | 1753 | } |
1754 | - $user_id = ($type == 'u' ? '' : $type) . $contact['user_id']; |
|
1754 | + $user_id = ($type == 'u' ? '' : $type).$contact['user_id']; |
|
1755 | 1755 | $calendars[$user_id][$key.'_event'] = $start; |
1756 | 1756 | $calendars[$user_id][$key.'_link'] = $link; |
1757 | 1757 | }; |
1758 | 1758 | |
1759 | - foreach($contacts as $contact) |
|
1759 | + foreach ($contacts as $contact) |
|
1760 | 1760 | { |
1761 | - if($contact['last_event']) |
|
1761 | + if ($contact['last_event']) |
|
1762 | 1762 | { |
1763 | 1763 | $do_event('last', $contact); |
1764 | 1764 | } |
1765 | - if($contact['next_event']) |
|
1765 | + if ($contact['next_event']) |
|
1766 | 1766 | { |
1767 | 1767 | $do_event('next', $contact); |
1768 | 1768 | } |
@@ -1779,7 +1779,7 @@ discard block |
||
1779 | 1779 | */ |
1780 | 1780 | public function read_birthdays($addressbook, $year) |
1781 | 1781 | { |
1782 | - if (($birthdays = Cache::getInstance(__CLASS__,"birthday-$year-$addressbook-".$GLOBALS['egw_info']['user']['preferences']['common']['lang'])) !== null) |
|
1782 | + if (($birthdays = Cache::getInstance(__CLASS__, "birthday-$year-$addressbook-".$GLOBALS['egw_info']['user']['preferences']['common']['lang'])) !== null) |
|
1783 | 1783 | { |
1784 | 1784 | return $birthdays; |
1785 | 1785 | } |
@@ -1790,7 +1790,7 @@ discard block |
||
1790 | 1790 | 'n_family' => "!''", |
1791 | 1791 | 'bday' => "!''", |
1792 | 1792 | ); |
1793 | - $bdays =& $this->search('',array('id','n_family','n_given','n_prefix','n_middle','bday'), |
|
1793 | + $bdays = & $this->search('', array('id', 'n_family', 'n_given', 'n_prefix', 'n_middle', 'bday'), |
|
1794 | 1794 | 'contact_bday ASC', '', '', false, 'AND', false, $filter); |
1795 | 1795 | |
1796 | 1796 | if ($bdays) |
@@ -1798,35 +1798,34 @@ discard block |
||
1798 | 1798 | // sort by month and day only |
1799 | 1799 | usort($bdays, function($a, $b) |
1800 | 1800 | { |
1801 | - return (int) $a['bday'] == (int) $b['bday'] ? |
|
1802 | - strcmp($a['bday'], $b['bday']) : |
|
1803 | - (int) $a['bday'] - (int) $b['bday']; |
|
1801 | + return (int)$a['bday'] == (int)$b['bday'] ? |
|
1802 | + strcmp($a['bday'], $b['bday']) : (int)$a['bday'] - (int)$b['bday']; |
|
1804 | 1803 | }); |
1805 | - foreach($bdays as $pers) |
|
1804 | + foreach ($bdays as $pers) |
|
1806 | 1805 | { |
1807 | - if (empty($pers['bday']) || $pers['bday']=='0000-00-00 0' || $pers['bday']=='0000-00-00' || $pers['bday']=='0.0.00') |
|
1806 | + if (empty($pers['bday']) || $pers['bday'] == '0000-00-00 0' || $pers['bday'] == '0000-00-00' || $pers['bday'] == '0.0.00') |
|
1808 | 1807 | { |
1809 | 1808 | //error_log(__METHOD__.__LINE__.' Skipping entry for invalid birthday:'.array2string($pers)); |
1810 | 1809 | continue; |
1811 | 1810 | } |
1812 | - list($y,$m,$d) = explode('-',$pers['bday']); |
|
1811 | + list($y, $m, $d) = explode('-', $pers['bday']); |
|
1813 | 1812 | if ($y > $year) |
1814 | 1813 | { |
1815 | 1814 | // not yet born |
1816 | 1815 | continue; |
1817 | 1816 | } |
1818 | - $birthdays[sprintf('%04d%02d%02d',$year,$m,$d)][] = array( |
|
1817 | + $birthdays[sprintf('%04d%02d%02d', $year, $m, $d)][] = array( |
|
1819 | 1818 | 'day' => $d, |
1820 | 1819 | 'month' => $m, |
1821 | 1820 | 'occurence' => 0, |
1822 | - 'name' => implode(' ', array_filter(array(lang('Birthday'),($pers['n_given'] ? $pers['n_given'] : $pers['n_prefix']), $pers['n_middle'], |
|
1823 | - $pers['n_family'], ($GLOBALS['egw_info']['server']['hide_birthdays'] == 'age' ? ($year - $y): '')))). |
|
1824 | - ($y && in_array($GLOBALS['egw_info']['server']['hide_birthdays'], array('','age')) ? ' ('.$y.')' : ''), |
|
1825 | - 'birthyear' => $y, // this can be used to identify birthdays from holidays |
|
1821 | + 'name' => implode(' ', array_filter(array(lang('Birthday'), ($pers['n_given'] ? $pers['n_given'] : $pers['n_prefix']), $pers['n_middle'], |
|
1822 | + $pers['n_family'], ($GLOBALS['egw_info']['server']['hide_birthdays'] == 'age' ? ($year - $y) : '')))). |
|
1823 | + ($y && in_array($GLOBALS['egw_info']['server']['hide_birthdays'], array('', 'age')) ? ' ('.$y.')' : ''), |
|
1824 | + 'birthyear' => $y, // this can be used to identify birthdays from holidays |
|
1826 | 1825 | ); |
1827 | 1826 | } |
1828 | 1827 | } |
1829 | - Cache::setInstance(__CLASS__,"birthday-$year-$addressbook-".$GLOBALS['egw_info']['user']['preferences']['common']['lang'], $birthdays, self::BIRTHDAY_CACHE_TIME); |
|
1828 | + Cache::setInstance(__CLASS__, "birthday-$year-$addressbook-".$GLOBALS['egw_info']['user']['preferences']['common']['lang'], $birthdays, self::BIRTHDAY_CACHE_TIME); |
|
1830 | 1829 | return $birthdays; |
1831 | 1830 | } |
1832 | 1831 | |
@@ -1849,7 +1848,7 @@ discard block |
||
1849 | 1848 | { |
1850 | 1849 | // get all cats if you want to drop sub cats |
1851 | 1850 | $drop_subs = ($data['drop_subs'] && !$data['modify_subs']); |
1852 | - if($drop_subs) |
|
1851 | + if ($drop_subs) |
|
1853 | 1852 | { |
1854 | 1853 | $cats = new Categories('', 'addressbook'); |
1855 | 1854 | $cat_ids = $cats->return_all_children($data['cat_id']); |
@@ -1860,14 +1859,14 @@ discard block |
||
1860 | 1859 | } |
1861 | 1860 | |
1862 | 1861 | // Get addresses that use the category |
1863 | - @set_time_limit( 0 ); |
|
1864 | - foreach($cat_ids as $cat_id) |
|
1862 | + @set_time_limit(0); |
|
1863 | + foreach ($cat_ids as $cat_id) |
|
1865 | 1864 | { |
1866 | 1865 | if (($ids = $this->search(array('cat_id' => $cat_id), false))) |
1867 | 1866 | { |
1868 | - foreach($ids as &$info) |
|
1867 | + foreach ($ids as &$info) |
|
1869 | 1868 | { |
1870 | - $info['cat_id'] = implode(',',array_diff(explode(',',$info['cat_id']), $cat_ids)); |
|
1869 | + $info['cat_id'] = implode(',', array_diff(explode(',', $info['cat_id']), $cat_ids)); |
|
1871 | 1870 | $this->save($info); |
1872 | 1871 | } |
1873 | 1872 | } |
@@ -1889,14 +1888,14 @@ discard block |
||
1889 | 1888 | $account = null; |
1890 | 1889 | $custom_fields = Storage\Customfields::get('addressbook', true); |
1891 | 1890 | $custom_field_list = $this->read_customfields($ids); |
1892 | - foreach(parent::search(array('id'=>$ids),false) as $contact) // $this->search calls the extended search from ui! |
|
1891 | + foreach (parent::search(array('id'=>$ids), false) as $contact) // $this->search calls the extended search from ui! |
|
1893 | 1892 | { |
1894 | 1893 | if ($contact['account_id']) |
1895 | 1894 | { |
1896 | 1895 | if (!is_null($account)) |
1897 | 1896 | { |
1898 | 1897 | echo $this->error = 'Can not merge more then one account!'; |
1899 | - return false; // we dont deal with two accounts! |
|
1898 | + return false; // we dont deal with two accounts! |
|
1900 | 1899 | } |
1901 | 1900 | $account = $contact; |
1902 | 1901 | continue; |
@@ -1904,7 +1903,7 @@ discard block |
||
1904 | 1903 | // Add in custom fields |
1905 | 1904 | if (is_array($custom_field_list[$contact['id']])) $contact = array_merge($contact, $custom_field_list[$contact['id']]); |
1906 | 1905 | |
1907 | - $pos = array_search($contact['id'],$ids); |
|
1906 | + $pos = array_search($contact['id'], $ids); |
|
1908 | 1907 | $contacts[$pos] = $contact; |
1909 | 1908 | } |
1910 | 1909 | if (!is_null($account)) // we found an account, so we merge the contacts into it |
@@ -1917,38 +1916,38 @@ discard block |
||
1917 | 1916 | $target = $contacts[0]; |
1918 | 1917 | unset($contacts[0]); |
1919 | 1918 | } |
1920 | - if (!$this->check_perms(Acl::EDIT,$target)) |
|
1919 | + if (!$this->check_perms(Acl::EDIT, $target)) |
|
1921 | 1920 | { |
1922 | 1921 | echo $this->error = 'No edit permission for the target contact!'; |
1923 | 1922 | return 0; |
1924 | 1923 | } |
1925 | - foreach($contacts as $contact) |
|
1924 | + foreach ($contacts as $contact) |
|
1926 | 1925 | { |
1927 | - foreach($contact as $name => $value) |
|
1926 | + foreach ($contact as $name => $value) |
|
1928 | 1927 | { |
1929 | 1928 | if (!$value) continue; |
1930 | 1929 | |
1931 | - switch($name) |
|
1930 | + switch ($name) |
|
1932 | 1931 | { |
1933 | 1932 | case 'id': |
1934 | 1933 | case 'tid': |
1935 | 1934 | case 'owner': |
1936 | 1935 | case 'private': |
1937 | 1936 | case 'etag'; |
1938 | - break; // ignored |
|
1937 | + break; // ignored |
|
1939 | 1938 | |
1940 | 1939 | case 'cat_id': // cats are all merged together |
1941 | - if (!is_array($target['cat_id'])) $target['cat_id'] = $target['cat_id'] ? explode(',',$target['cat_id']) : array(); |
|
1942 | - $target['cat_id'] = array_unique(array_merge($target['cat_id'],is_array($value)?$value:explode(',',$value))); |
|
1940 | + if (!is_array($target['cat_id'])) $target['cat_id'] = $target['cat_id'] ? explode(',', $target['cat_id']) : array(); |
|
1941 | + $target['cat_id'] = array_unique(array_merge($target['cat_id'], is_array($value) ? $value : explode(',', $value))); |
|
1943 | 1942 | break; |
1944 | 1943 | |
1945 | 1944 | default: |
1946 | 1945 | // Multi-select custom fields can also be merged |
1947 | - if($name[0] == '#') { |
|
1946 | + if ($name[0] == '#') { |
|
1948 | 1947 | $c_name = substr($name, 1); |
1949 | - if($custom_fields[$c_name]['type'] == 'select' && $custom_fields[$c_name]['rows'] > 1) { |
|
1950 | - if (!is_array($target[$name])) $target[$name] = $target[$name] ? explode(',',$target[$name]) : array(); |
|
1951 | - $target[$name] = implode(',',array_unique(array_merge($target[$name],is_array($value)?$value:explode(',',$value)))); |
|
1948 | + if ($custom_fields[$c_name]['type'] == 'select' && $custom_fields[$c_name]['rows'] > 1) { |
|
1949 | + if (!is_array($target[$name])) $target[$name] = $target[$name] ? explode(',', $target[$name]) : array(); |
|
1950 | + $target[$name] = implode(',', array_unique(array_merge($target[$name], is_array($value) ? $value : explode(',', $value)))); |
|
1952 | 1951 | } |
1953 | 1952 | } |
1954 | 1953 | if (!$target[$name]) $target[$name] = $value; |
@@ -1958,7 +1957,7 @@ discard block |
||
1958 | 1957 | |
1959 | 1958 | // Merge distribution lists |
1960 | 1959 | $lists = $this->read_distributionlist(array($contact['id'])); |
1961 | - foreach($lists[$contact['id']] as $list_id => $list_name) |
|
1960 | + foreach ($lists[$contact['id']] as $list_id => $list_name) |
|
1962 | 1961 | { |
1963 | 1962 | parent::add2list($target['id'], $list_id); |
1964 | 1963 | } |
@@ -1966,29 +1965,29 @@ discard block |
||
1966 | 1965 | if (!$this->save($target)) return 0; |
1967 | 1966 | |
1968 | 1967 | $success = 1; |
1969 | - foreach($contacts as $contact) |
|
1968 | + foreach ($contacts as $contact) |
|
1970 | 1969 | { |
1971 | - if (!$this->check_perms(Acl::DELETE,$contact)) |
|
1970 | + if (!$this->check_perms(Acl::DELETE, $contact)) |
|
1972 | 1971 | { |
1973 | 1972 | continue; |
1974 | 1973 | } |
1975 | - foreach(Link::get_links('addressbook',$contact['id']) as $data) |
|
1974 | + foreach (Link::get_links('addressbook', $contact['id']) as $data) |
|
1976 | 1975 | { |
1977 | 1976 | //_debug_array(array('function'=>__METHOD__,'line'=>__LINE__,'app'=>'addressbook','id'=>$contact['id'],'data:'=>$data,'target'=>$target['id'])); |
1978 | 1977 | // info_from and info_link_id (main link) |
1979 | - $newlinkID = Link::link('addressbook',$target['id'],$data['app'],$data['id'],$data['remark'],$target['owner']); |
|
1978 | + $newlinkID = Link::link('addressbook', $target['id'], $data['app'], $data['id'], $data['remark'], $target['owner']); |
|
1980 | 1979 | //_debug_array(array('newLinkID'=>$newlinkID)); |
1981 | 1980 | if ($newlinkID) |
1982 | 1981 | { |
1983 | 1982 | // update egw_infolog set info_link_id=$newlinkID where info_id=$data['id'] and info_link_id=$data['link_id'] |
1984 | - if ($data['app']=='infolog') |
|
1983 | + if ($data['app'] == 'infolog') |
|
1985 | 1984 | { |
1986 | - $this->db->update('egw_infolog',array( |
|
1985 | + $this->db->update('egw_infolog', array( |
|
1987 | 1986 | 'info_link_id' => $newlinkID |
1988 | - ),array( |
|
1987 | + ), array( |
|
1989 | 1988 | 'info_id' => $data['id'], |
1990 | 1989 | 'info_link_id' => $data['link_id'] |
1991 | - ),__LINE__,__FILE__,'infolog'); |
|
1990 | + ), __LINE__, __FILE__, 'infolog'); |
|
1992 | 1991 | } |
1993 | 1992 | unset($newlinkID); |
1994 | 1993 | } |
@@ -2011,7 +2010,7 @@ discard block |
||
2011 | 2010 | protected function merge_calendar($old_id, $new_id) |
2012 | 2011 | { |
2013 | 2012 | static $bo; |
2014 | - if(!is_object($bo)) |
|
2013 | + if (!is_object($bo)) |
|
2015 | 2014 | { |
2016 | 2015 | $bo = new \calendar_boupdate(); |
2017 | 2016 | } |
@@ -2019,7 +2018,7 @@ discard block |
||
2019 | 2018 | // Find all events with this contact |
2020 | 2019 | $events = $bo->search(array('users' => $old_id, 'ignore_acl' => true)); |
2021 | 2020 | |
2022 | - foreach($events as $event) |
|
2021 | + foreach ($events as $event) |
|
2023 | 2022 | { |
2024 | 2023 | $event['participants'][$new_id] = $event['participants'][$old_id]; |
2025 | 2024 | unset($event['participants'][$old_id]); |
@@ -2044,14 +2043,14 @@ discard block |
||
2044 | 2043 | * @param int $owner =null |
2045 | 2044 | * @return boolean |
2046 | 2045 | */ |
2047 | - function check_list($list,$required,$owner=null) |
|
2046 | + function check_list($list, $required, $owner = null) |
|
2048 | 2047 | { |
2049 | 2048 | if ($list && ($list_data = $this->read_list($list))) |
2050 | 2049 | { |
2051 | 2050 | $owner = $list_data['list_owner']; |
2052 | 2051 | } |
2053 | 2052 | //error_log(__METHOD__."($list, $required, $owner) grants[$owner]=".$this->grants[$owner]." returning ".array2string(!!($this->grants[$owner] & $required))); |
2054 | - return !!($this->grants[$owner] & $required); |
|
2053 | + return !!($this->grants[$owner]&$required); |
|
2055 | 2054 | } |
2056 | 2055 | |
2057 | 2056 | /** |
@@ -2063,17 +2062,17 @@ discard block |
||
2063 | 2062 | * @param array &$data=array() values for keys 'list_uid', 'list_carddav_name', 'list_name' |
2064 | 2063 | * @return int|boolean integer list_id or false on error |
2065 | 2064 | */ |
2066 | - function add_list($keys,$owner,$contacts=array(),array &$data=array()) |
|
2065 | + function add_list($keys, $owner, $contacts = array(), array &$data = array()) |
|
2067 | 2066 | { |
2068 | - if (!$this->check_list(null,Acl::ADD|Acl::EDIT,$owner)) return false; |
|
2067 | + if (!$this->check_list(null, Acl::ADD|Acl::EDIT, $owner)) return false; |
|
2069 | 2068 | |
2070 | 2069 | try { |
2071 | - $ret = parent::add_list($keys,$owner,$contacts,$data); |
|
2070 | + $ret = parent::add_list($keys, $owner, $contacts, $data); |
|
2072 | 2071 | if ($ret) unset(self::$list_cache[$ret]); |
2073 | 2072 | } |
2074 | 2073 | // catch sql error, as creating same name&owner list gives a sql error doublicate key |
2075 | - catch(Db\Exception\InvalidSql $e) { |
|
2076 | - unset($e); // not used |
|
2074 | + catch (Db\Exception\InvalidSql $e) { |
|
2075 | + unset($e); // not used |
|
2077 | 2076 | return false; |
2078 | 2077 | } |
2079 | 2078 | return $ret; |
@@ -2087,13 +2086,13 @@ discard block |
||
2087 | 2086 | * @param array $existing =null array of existing contact-id(s) of list, to not reread it, eg. array() |
2088 | 2087 | * @return false on error |
2089 | 2088 | */ |
2090 | - function add2list($contact,$list,array $existing=null) |
|
2089 | + function add2list($contact, $list, array $existing = null) |
|
2091 | 2090 | { |
2092 | - if (!$this->check_list($list,Acl::EDIT)) return false; |
|
2091 | + if (!$this->check_list($list, Acl::EDIT)) return false; |
|
2093 | 2092 | |
2094 | 2093 | unset(self::$list_cache[$list]); |
2095 | 2094 | |
2096 | - return parent::add2list($contact,$list,$existing); |
|
2095 | + return parent::add2list($contact, $list, $existing); |
|
2097 | 2096 | } |
2098 | 2097 | |
2099 | 2098 | /** |
@@ -2103,9 +2102,9 @@ discard block |
||
2103 | 2102 | * @param int $list list-id |
2104 | 2103 | * @return false on error |
2105 | 2104 | */ |
2106 | - function remove_from_list($contact,$list=null) |
|
2105 | + function remove_from_list($contact, $list = null) |
|
2107 | 2106 | { |
2108 | - if ($list && !$this->check_list($list,Acl::EDIT)) return false; |
|
2107 | + if ($list && !$this->check_list($list, Acl::EDIT)) return false; |
|
2109 | 2108 | |
2110 | 2109 | if ($list) |
2111 | 2110 | { |
@@ -2116,7 +2115,7 @@ discard block |
||
2116 | 2115 | self::$list_cache = array(); |
2117 | 2116 | } |
2118 | 2117 | |
2119 | - return parent::remove_from_list($contact,$list); |
|
2118 | + return parent::remove_from_list($contact, $list); |
|
2120 | 2119 | } |
2121 | 2120 | |
2122 | 2121 | /** |
@@ -2127,7 +2126,7 @@ discard block |
||
2127 | 2126 | */ |
2128 | 2127 | function delete_list($list) |
2129 | 2128 | { |
2130 | - foreach((array)$list as $l) |
|
2129 | + foreach ((array)$list as $l) |
|
2131 | 2130 | { |
2132 | 2131 | if (!$this->check_list($l, Acl::DELETE)) return false; |
2133 | 2132 | |
@@ -2165,7 +2164,7 @@ discard block |
||
2165 | 2164 | { |
2166 | 2165 | $code = Country::country_code($country); |
2167 | 2166 | |
2168 | - switch($code) |
|
2167 | + switch ($code) |
|
2169 | 2168 | { |
2170 | 2169 | case 'AU': |
2171 | 2170 | case 'CA': |
@@ -2229,12 +2228,12 @@ discard block |
||
2229 | 2228 | * by the ones the user normally does not see due to category permissions - used to preserve categories |
2230 | 2229 | * @return array category ids (found, added and preserved categories) |
2231 | 2230 | */ |
2232 | - function find_or_add_categories($catname_list, $contact_id=null) |
|
2231 | + function find_or_add_categories($catname_list, $contact_id = null) |
|
2233 | 2232 | { |
2234 | 2233 | if ($contact_id && $contact_id > 0 && ($old_contact = $this->read($contact_id))) |
2235 | 2234 | { |
2236 | 2235 | // preserve categories without users read access |
2237 | - $old_categories = explode(',',$old_contact['cat_id']); |
|
2236 | + $old_categories = explode(',', $old_contact['cat_id']); |
|
2238 | 2237 | $old_cats_preserve = array(); |
2239 | 2238 | if (is_array($old_categories) && count($old_categories) > 0) |
2240 | 2239 | { |
@@ -2288,15 +2287,15 @@ discard block |
||
2288 | 2287 | { |
2289 | 2288 | if (!is_object($this->categories)) |
2290 | 2289 | { |
2291 | - $this->categories = new Categories($this->user,'addressbook'); |
|
2290 | + $this->categories = new Categories($this->user, 'addressbook'); |
|
2292 | 2291 | } |
2293 | 2292 | |
2294 | 2293 | if (!is_array($cat_id_list)) |
2295 | 2294 | { |
2296 | - $cat_id_list = explode(',',$cat_id_list); |
|
2295 | + $cat_id_list = explode(',', $cat_id_list); |
|
2297 | 2296 | } |
2298 | 2297 | $cat_list = array(); |
2299 | - foreach($cat_id_list as $cat_id) |
|
2298 | + foreach ($cat_id_list as $cat_id) |
|
2300 | 2299 | { |
2301 | 2300 | if ($cat_id && $this->categories->check_perms(Acl::READ, $cat_id) && |
2302 | 2301 | ($cat_name = $this->categories->id2name($cat_id)) && $cat_name != '--') |
@@ -2328,14 +2327,14 @@ discard block |
||
2328 | 2327 | * @param boolean $relax =false if asked to relax, we only match against some key fields |
2329 | 2328 | * @return array od matching contact_ids |
2330 | 2329 | */ |
2331 | - function find_contact($contact, $relax=false) |
|
2330 | + function find_contact($contact, $relax = false) |
|
2332 | 2331 | { |
2333 | 2332 | $empty_addr_one = $empty_addr_two = true; |
2334 | 2333 | |
2335 | 2334 | if ($this->log) |
2336 | 2335 | { |
2337 | 2336 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2338 | - . '('. ($relax ? 'RELAX': 'EXACT') . ')[ContactData]:' |
|
2337 | + . '('.($relax ? 'RELAX' : 'EXACT').')[ContactData]:' |
|
2339 | 2338 | . array2string($contact) |
2340 | 2339 | . "\n", 3, $this->logfile); |
2341 | 2340 | } |
@@ -2346,7 +2345,7 @@ discard block |
||
2346 | 2345 | if ($this->log) |
2347 | 2346 | { |
2348 | 2347 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2349 | - . '()[ContactID]: ' . $contact['id'] |
|
2348 | + . '()[ContactID]: '.$contact['id'] |
|
2350 | 2349 | . "\n", 3, $this->logfile); |
2351 | 2350 | } |
2352 | 2351 | // We only do a simple consistency check |
@@ -2364,11 +2363,11 @@ discard block |
||
2364 | 2363 | if ($this->log) |
2365 | 2364 | { |
2366 | 2365 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2367 | - . '()[ContactUID]: ' . $contact['uid'] |
|
2366 | + . '()[ContactUID]: '.$contact['uid'] |
|
2368 | 2367 | . "\n", 3, $this->logfile); |
2369 | 2368 | } |
2370 | 2369 | // Try the given UID first |
2371 | - $criteria = array ('contact_uid' => $contact['uid']); |
|
2370 | + $criteria = array('contact_uid' => $contact['uid']); |
|
2372 | 2371 | if (($foundContacts = parent::search($criteria))) |
2373 | 2372 | { |
2374 | 2373 | foreach ($foundContacts as $egwContact) |
@@ -2451,7 +2450,7 @@ discard block |
||
2451 | 2450 | { |
2452 | 2451 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2453 | 2452 | . '()[Addressbook FIND Step 1]: ' |
2454 | - . 'CRITERIA = ' . array2string($criteria) |
|
2453 | + . 'CRITERIA = '.array2string($criteria) |
|
2455 | 2454 | . "\n", 3, $this->logfile); |
2456 | 2455 | } |
2457 | 2456 | |
@@ -2480,7 +2479,7 @@ discard block |
||
2480 | 2479 | { |
2481 | 2480 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2482 | 2481 | . '()[Addressbook FIND Step 2]: ' |
2483 | - . 'CRITERIA = ' . array2string($criteria) |
|
2482 | + . 'CRITERIA = '.array2string($criteria) |
|
2484 | 2483 | . "\n", 3, $this->logfile); |
2485 | 2484 | } |
2486 | 2485 | |
@@ -2504,7 +2503,7 @@ discard block |
||
2504 | 2503 | { |
2505 | 2504 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2506 | 2505 | . '()[Addressbook FIND Step 3]: ' |
2507 | - . 'CRITERIA = ' . array2string($criteria) |
|
2506 | + . 'CRITERIA = '.array2string($criteria) |
|
2508 | 2507 | . "\n", 3, $this->logfile); |
2509 | 2508 | } |
2510 | 2509 | |
@@ -2530,7 +2529,7 @@ discard block |
||
2530 | 2529 | { |
2531 | 2530 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2532 | 2531 | . '()[Addressbook FIND Step 4]: ' |
2533 | - . 'CRITERIA = ' . array2string($criteria) |
|
2532 | + . 'CRITERIA = '.array2string($criteria) |
|
2534 | 2533 | . "\n", 3, $this->logfile); |
2535 | 2534 | } |
2536 | 2535 | if (($foundContacts = parent::search($criteria, true, '', '', '', true))) |
@@ -2544,7 +2543,7 @@ discard block |
||
2544 | 2543 | if ($this->log) |
2545 | 2544 | { |
2546 | 2545 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2547 | - . '()[FOUND]: ' . array2string($matchingContacts) |
|
2546 | + . '()[FOUND]: '.array2string($matchingContacts) |
|
2548 | 2547 | . "\n", 3, $this->logfile); |
2549 | 2548 | } |
2550 | 2549 | return $matchingContacts; |
@@ -2561,9 +2560,9 @@ discard block |
||
2561 | 2560 | * @param int|array $owner =null 0=accounts, null=all addressbooks or integer account_id of user or group |
2562 | 2561 | * @return string |
2563 | 2562 | */ |
2564 | - public function get_ctag($owner=null) |
|
2563 | + public function get_ctag($owner = null) |
|
2565 | 2564 | { |
2566 | - $filter = array('tid' => null); // tid=null --> use all entries incl. deleted (tid='D') |
|
2565 | + $filter = array('tid' => null); // tid=null --> use all entries incl. deleted (tid='D') |
|
2567 | 2566 | // show addressbook of a single user? |
2568 | 2567 | if (!is_null($owner)) $filter['owner'] = $owner; |
2569 | 2568 | |
@@ -2572,11 +2571,11 @@ discard block |
||
2572 | 2571 | { |
2573 | 2572 | $filter['account_id'] = null; |
2574 | 2573 | } |
2575 | - $result = $this->search(array(),'contact_modified','contact_modified DESC','','',false,'AND',array(0,1),$filter); |
|
2574 | + $result = $this->search(array(), 'contact_modified', 'contact_modified DESC', '', '', false, 'AND', array(0, 1), $filter); |
|
2576 | 2575 | |
2577 | 2576 | if (!$result || !isset($result[0]['modified'])) |
2578 | 2577 | { |
2579 | - $ctag = 'empty'; // ctag for empty addressbook |
|
2578 | + $ctag = 'empty'; // ctag for empty addressbook |
|
2580 | 2579 | } |
2581 | 2580 | else |
2582 | 2581 | { |
@@ -114,7 +114,10 @@ |
||
114 | 114 | break; |
115 | 115 | } |
116 | 116 | } |
117 | - if (true) $valid = $value; |
|
117 | + if (true) |
|
118 | + { |
|
119 | + $valid = $value; |
|
120 | + } |
|
118 | 121 | //error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value)); |
119 | 122 | } |
120 | 123 | } |
@@ -61,7 +61,6 @@ discard block |
||
61 | 61 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
62 | 62 | * @param array $content |
63 | 63 | * @param array &$validated=array() validated content |
64 | - * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
|
65 | 64 | */ |
66 | 65 | public function validate($cname, array $expand, array $content, &$validated=array()) |
67 | 66 | { |
@@ -132,7 +131,7 @@ discard block |
||
132 | 131 | /** |
133 | 132 | * Handle ajax searches for existing contact based on email |
134 | 133 | * |
135 | - * @return boolean $_email exists or not |
|
134 | + * @return boolean|null $_email exists or not |
|
136 | 135 | */ |
137 | 136 | public static function ajax_contact($_email) |
138 | 137 | { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param array &$validated=array() validated content |
64 | 64 | * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
65 | 65 | */ |
66 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
66 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
67 | 67 | { |
68 | 68 | $form_name = self::form_name($cname, $this->id, $expand); |
69 | 69 | |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | |
74 | 74 | if ((string)$value === '' && $this->attrs['needed']) |
75 | 75 | { |
76 | - self::set_validation_error($form_name,lang('Field must not be empty !!!'),''); |
|
76 | + self::set_validation_error($form_name, lang('Field must not be empty !!!'), ''); |
|
77 | 77 | return; |
78 | 78 | } |
79 | 79 | elseif ((string)$value != '' && !isset($this->attrs['preg'])) |
80 | 80 | { |
81 | - switch($this->type) |
|
81 | + switch ($this->type) |
|
82 | 82 | { |
83 | 83 | case 'url': |
84 | 84 | // if no protocol given eg. "www.egroupware.org" prepend "http://" for validation |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | } |
89 | 89 | $url_valid = filter_var($value, FILTER_VALIDATE_URL) || |
90 | 90 | // Remove intl chars & check again, but if it passes we'll keep the original |
91 | - filter_var(preg_replace('/[^[:print:]]/','',$value), FILTER_VALIDATE_URL); |
|
91 | + filter_var(preg_replace('/[^[:print:]]/', '', $value), FILTER_VALIDATE_URL); |
|
92 | 92 | //error_log(__METHOD__."() filter_var(value=".array2string($value).", FILTER_VALIDATE_URL)=".array2string(filter_var($value, FILTER_VALIDATE_URL))." --> url_valid=".array2string($url_valid)); |
93 | 93 | // remove http:// validation prefix again |
94 | 94 | if ($missing_protocol) |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | if (!$url_valid) |
99 | 99 | { |
100 | - self::set_validation_error($form_name,lang("'%1' has an invalid format !!!",$value),''); |
|
100 | + self::set_validation_error($form_name, lang("'%1' has an invalid format !!!", $value), ''); |
|
101 | 101 | return; |
102 | 102 | } |
103 | 103 | $this->attrs['preg'] = self::URL_PREG; |
@@ -108,19 +108,19 @@ discard block |
||
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | - $valid =& self::get_array($validated, $form_name, true); |
|
111 | + $valid = & self::get_array($validated, $form_name, true); |
|
112 | 112 | |
113 | - if ((int) $this->attrs['maxlength'] > 0 && strlen($value) > (int) $this->attrs['maxlength']) |
|
113 | + if ((int)$this->attrs['maxlength'] > 0 && strlen($value) > (int)$this->attrs['maxlength']) |
|
114 | 114 | { |
115 | - $value = substr($value,0,(int) $this->attrs['maxlength']); |
|
115 | + $value = substr($value, 0, (int)$this->attrs['maxlength']); |
|
116 | 116 | } |
117 | - if ($this->attrs['preg'] && !preg_match($this->attrs['preg'],$value)) |
|
117 | + if ($this->attrs['preg'] && !preg_match($this->attrs['preg'], $value)) |
|
118 | 118 | { |
119 | - switch($this->type) |
|
119 | + switch ($this->type) |
|
120 | 120 | { |
121 | 121 | default: |
122 | 122 | //error_log("preg_match('{$this->attrs['preg']}', '$value')=".array2string(preg_match($this->attrs['preg'], $value))); |
123 | - self::set_validation_error($form_name,lang("'%1' has an invalid format !!!",$value)/*." !preg_match('$this->attrs[preg]', '$value')"*/,''); |
|
123 | + self::set_validation_error($form_name, lang("'%1' has an invalid format !!!", $value)/*." !preg_match('$this->attrs[preg]', '$value')"*/, ''); |
|
124 | 124 | break; |
125 | 125 | } |
126 | 126 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | public static function ajax_contact($_email) |
138 | 138 | { |
139 | 139 | $email = \EGroupware\Api\Mail::stripRFC822Addresses(array($_email)); |
140 | - $result = $GLOBALS['egw']->contacts->search(array('contact_email'=>$email[0], 'contact_email_home' => $email[0]), array('email','email_home'), |
|
140 | + $result = $GLOBALS['egw']->contacts->search(array('contact_email'=>$email[0], 'contact_email_home' => $email[0]), array('email', 'email_home'), |
|
141 | 141 | '', '', '', false, 'OR', false); |
142 | 142 | \EGroupware\Api\Json\Response::data($result ? true : false); |
143 | 143 | } |