@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @var int |
| 73 | 73 | */ |
| 74 | - protected $start=0; |
|
| 74 | + protected $start = 0; |
|
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * Number of entries queried from callback in one call |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param array $filter filter for propfind call |
| 96 | 96 | * @param array $files =array() extra files/responses to return too |
| 97 | 97 | */ |
| 98 | - public function __construct(Handler $handler, $path, array $filter,array &$files=array()) |
|
| 98 | + public function __construct(Handler $handler, $path, array $filter, array &$files = array()) |
|
| 99 | 99 | { |
| 100 | 100 | if ($this->debug) error_log(__METHOD__."('$path', ".array2string($filter).",)"); |
| 101 | 101 | $this->path = $path; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $current = current($this->files); |
| 127 | 127 | |
| 128 | 128 | if ($this->debug) error_log(__METHOD__."() returning ".array2string($current['path'])); |
| 129 | - return $current['path']; // we return path as key |
|
| 129 | + return $current['path']; // we return path as key |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -146,11 +146,11 @@ discard block |
||
| 146 | 146 | return false; |
| 147 | 147 | } |
| 148 | 148 | // try query further files via propfind callback of handler and store result in $this->files |
| 149 | - $this->files = $this->handler->propfind_callback($this->path,$this->filter,array($this->start,self::CHUNK_SIZE)); |
|
| 149 | + $this->files = $this->handler->propfind_callback($this->path, $this->filter, array($this->start, self::CHUNK_SIZE)); |
|
| 150 | 150 | if (!is_array($this->files) || !($entries = count($this->files))) |
| 151 | 151 | { |
| 152 | 152 | if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)"); |
| 153 | - return false; // no further entries |
|
| 153 | + return false; // no further entries |
|
| 154 | 154 | } |
| 155 | 155 | $this->start += self::CHUNK_SIZE; |
| 156 | 156 | reset($this->files); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | $this->start = 0; |
| 171 | 171 | $this->files = $this->common_files; |
| 172 | - if (!$this->files) $this->next(); // otherwise valid will return false and nothing get returned |
|
| 172 | + if (!$this->files) $this->next(); // otherwise valid will return false and nothing get returned |
|
| 173 | 173 | reset($this->files); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return boolean |
| 180 | 180 | */ |
| 181 | - public function valid () |
|
| 181 | + public function valid() |
|
| 182 | 182 | { |
| 183 | 183 | if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files) !== false)); |
| 184 | 184 | return current($this->files) !== false; |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param array $callback_params =array() further parameters for the callback, 1. parameter is component |
| 107 | 107 | * @param boolean $add_container =false true, add container / $this as last parameter to callback |
| 108 | 108 | */ |
| 109 | - public function __construct($ical_file,$base='VCALENDAR',$charset=null,$callback=null,array $callback_params=array(), $add_container=false) |
|
| 109 | + public function __construct($ical_file, $base = 'VCALENDAR', $charset = null, $callback = null, array $callback_params = array(), $add_container = false) |
|
| 110 | 110 | { |
| 111 | 111 | // call parent constructor |
| 112 | 112 | parent::__construct(); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | if (!is_resource($this->ical_file)) |
| 133 | 133 | { |
| 134 | - throw new Api\Exception\WrongParameter(__METHOD__.'($ical_file, ...) NO resource! $ical_file='.substr(array2string($ical_file),0,100)); |
|
| 134 | + throw new Api\Exception\WrongParameter(__METHOD__.'($ical_file, ...) NO resource! $ical_file='.substr(array2string($ical_file), 0, 100)); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | { |
| 156 | 156 | $line = array_shift($this->unread_lines); |
| 157 | 157 | } |
| 158 | - elseif(feof($this->ical_file)) |
|
| 158 | + elseif (feof($this->ical_file)) |
|
| 159 | 159 | { |
| 160 | 160 | $line = false; |
| 161 | 161 | } |
@@ -164,9 +164,9 @@ discard block |
||
| 164 | 164 | $line = fgets($this->ical_file); |
| 165 | 165 | } |
| 166 | 166 | // check if end of container reached |
| 167 | - if ($this->container && $line && substr($line,0,4+strlen($this->base)) === 'END:'.$this->base) |
|
| 167 | + if ($this->container && $line && substr($line, 0, 4 + strlen($this->base)) === 'END:'.$this->base) |
|
| 168 | 168 | { |
| 169 | - $this->unread_line($line); // put back end-of-container, to continue to return false |
|
| 169 | + $this->unread_line($line); // put back end-of-container, to continue to return false |
|
| 170 | 170 | $line = false; |
| 171 | 171 | } |
| 172 | 172 | //error_log(__METHOD__."() returning ".($line === false ? 'FALSE' : "'$line'")); |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | protected function unread_line($line) |
| 183 | 183 | { |
| 184 | 184 | //error_log(__METHOD__."('$line')"); |
| 185 | - array_unshift($this->unread_lines,$line); |
|
| 185 | + array_unshift($this->unread_lines, $line); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -195,14 +195,14 @@ discard block |
||
| 195 | 195 | //error_log(__METHOD__."() returning a ".gettype($this->component)); |
| 196 | 196 | if ($this->callback) |
| 197 | 197 | { |
| 198 | - $ret = is_a($this->component,'Horde_Icalendar'); |
|
| 198 | + $ret = is_a($this->component, 'Horde_Icalendar'); |
|
| 199 | 199 | do { |
| 200 | 200 | if ($ret === false) $this->next(); |
| 201 | - if (!is_a($this->component,'Horde_Icalendar')) return false; |
|
| 201 | + if (!is_a($this->component, 'Horde_Icalendar')) return false; |
|
| 202 | 202 | $params = $this->callback_params; |
| 203 | - array_unshift($params,$this->component); |
|
| 203 | + array_unshift($params, $this->component); |
|
| 204 | 204 | } |
| 205 | - while(($ret = call_user_func_array($this->callback,$params)) === false); |
|
| 205 | + while (($ret = call_user_func_array($this->callback, $params)) === false); |
|
| 206 | 206 | |
| 207 | 207 | return $ret; |
| 208 | 208 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | { |
| 228 | 228 | unset($this->component); |
| 229 | 229 | |
| 230 | - while (($line = $this->read_line()) && substr($line,0,6) !== 'BEGIN:') |
|
| 230 | + while (($line = $this->read_line()) && substr($line, 0, 6) !== 'BEGIN:') |
|
| 231 | 231 | { |
| 232 | 232 | // ignore it |
| 233 | 233 | } |
@@ -236,12 +236,12 @@ discard block |
||
| 236 | 236 | $this->component = false; |
| 237 | 237 | return; |
| 238 | 238 | } |
| 239 | - $type = substr(trim($line),6); |
|
| 239 | + $type = substr(trim($line), 6); |
|
| 240 | 240 | |
| 241 | 241 | //error_log(__METHOD__."() found $type component"); |
| 242 | 242 | |
| 243 | 243 | $data = $line; |
| 244 | - while (($line = $this->read_line()) && substr($line,0,4+strlen($type)) !== 'END:'.$type) |
|
| 244 | + while (($line = $this->read_line()) && substr($line, 0, 4 + strlen($type)) !== 'END:'.$type) |
|
| 245 | 245 | { |
| 246 | 246 | $data .= $line; |
| 247 | 247 | } |
@@ -276,23 +276,23 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | public function rewind() |
| 278 | 278 | { |
| 279 | - @fseek($this->ical_file,0,SEEK_SET); |
|
| 279 | + @fseek($this->ical_file, 0, SEEK_SET); |
|
| 280 | 280 | |
| 281 | 281 | // advance to begin of container |
| 282 | - while(($line = $this->read_line()) && substr($line,0,6+strlen($this->base)) !== 'BEGIN:'.$this->base) |
|
| 282 | + while (($line = $this->read_line()) && substr($line, 0, 6 + strlen($this->base)) !== 'BEGIN:'.$this->base) |
|
| 283 | 283 | { |
| 284 | 284 | |
| 285 | 285 | } |
| 286 | 286 | // if no container start found --> use whole file (rewind) and set container marker |
| 287 | 287 | if (!($this->container = $line !== false)) |
| 288 | 288 | { |
| 289 | - fseek($this->ical_file,0,SEEK_SET); |
|
| 289 | + fseek($this->ical_file, 0, SEEK_SET); |
|
| 290 | 290 | } |
| 291 | 291 | //error_log(__METHOD__."() $this->base container ".($this->container ? 'found' : 'NOT found')); |
| 292 | 292 | |
| 293 | 293 | $data = $line; |
| 294 | 294 | // advance to first component |
| 295 | - while (($line = $this->read_line()) && substr($line,0,6) !== 'BEGIN:') |
|
| 295 | + while (($line = $this->read_line()) && substr($line, 0, 6) !== 'BEGIN:') |
|
| 296 | 296 | { |
| 297 | 297 | $matches = null; |
| 298 | 298 | if (preg_match('/^VERSION:(\d\.\d)\s*$/ism', $line, $matches)) |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | { |
| 308 | 308 | $data .= "END:$this->base\n"; |
| 309 | 309 | //error_log(__METHOD__."() about to call this->parsevCalendar('$data','$this->base','$this->charset')"); |
| 310 | - $this->parsevCalendar($data,$this->base,$this->charset); |
|
| 310 | + $this->parsevCalendar($data, $this->base, $this->charset); |
|
| 311 | 311 | } |
| 312 | 312 | if ($line) $this->unread_line($line); |
| 313 | 313 | |
@@ -320,10 +320,10 @@ discard block |
||
| 320 | 320 | * |
| 321 | 321 | * @return boolean |
| 322 | 322 | */ |
| 323 | - public function valid () |
|
| 323 | + public function valid() |
|
| 324 | 324 | { |
| 325 | 325 | //error_log(__METHOD__."() returning ".(is_a($this->component,'Horde_Icalendar') ? 'TRUE' : 'FALSE').' get_class($this->component)='.get_class($this->component)); |
| 326 | - return is_a($this->component,'Horde_Icalendar'); |
|
| 326 | + return is_a($this->component, 'Horde_Icalendar'); |
|
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | |
@@ -441,8 +441,8 @@ discard block |
||
| 441 | 441 | if (!is_resource($ical_file)) echo "<pre>$ical_file</pre>\n"; |
| 442 | 442 | //$calendar_ical = new calendar_ical(); |
| 443 | 443 | //$calendar_ical->setSupportedFields('file'); |
| 444 | - $ical_it = new IcalIterator($ical_file);//,'VCALENDAR','iso-8859-1',array($calendar_ical,'_ical2egw_callback'),array('Europe/Berlin')); |
|
| 445 | - foreach($ical_it as $uid => $vevent) |
|
| 444 | + $ical_it = new IcalIterator($ical_file); //,'VCALENDAR','iso-8859-1',array($calendar_ical,'_ical2egw_callback'),array('Europe/Berlin')); |
|
| 445 | + foreach ($ical_it as $uid => $vevent) |
|
| 446 | 446 | { |
| 447 | 447 | echo "$uid<pre>".print_r($vevent->toHash(), true)."</pre>\n"; |
| 448 | 448 | } |
@@ -89,19 +89,18 @@ discard block |
||
| 89 | 89 | * @param array $reports =null |
| 90 | 90 | * @return array Api\CalDAV::mkprop('supported-report-set', ...) |
| 91 | 91 | */ |
| 92 | - protected function supported_report_set($path, array $reports=null) |
|
| 92 | + protected function supported_report_set($path, array $reports = null) |
|
| 93 | 93 | { |
| 94 | - unset($path); // not used, but required by function signature |
|
| 94 | + unset($path); // not used, but required by function signature |
|
| 95 | 95 | |
| 96 | 96 | if (is_null($reports)) $reports = $this->supported_reports; |
| 97 | 97 | |
| 98 | 98 | $supported = array(); |
| 99 | - foreach($reports as $name => $data) |
|
| 99 | + foreach ($reports as $name => $data) |
|
| 100 | 100 | { |
| 101 | - $supported[$name] = Api\CalDAV::mkprop('supported-report',array( |
|
| 102 | - Api\CalDAV::mkprop('report',array( |
|
| 103 | - !$data['ns'] ? Api\CalDAV::mkprop($name, '') : |
|
| 104 | - Api\CalDAV::mkprop($data['ns'], $name, ''))))); |
|
| 101 | + $supported[$name] = Api\CalDAV::mkprop('supported-report', array( |
|
| 102 | + Api\CalDAV::mkprop('report', array( |
|
| 103 | + !$data['ns'] ? Api\CalDAV::mkprop($name, '') : Api\CalDAV::mkprop($data['ns'], $name, ''))))); |
|
| 105 | 104 | } |
| 106 | 105 | return $supported; |
| 107 | 106 | } |
@@ -115,7 +114,7 @@ discard block |
||
| 115 | 114 | * @param int $user account_id |
| 116 | 115 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
| 117 | 116 | */ |
| 118 | - function propfind($path,&$options,&$files,$user) |
|
| 117 | + function propfind($path, &$options, &$files, $user) |
|
| 119 | 118 | { |
| 120 | 119 | if (($report = isset($_GET['report']) ? $_GET['report'] : $options['root']['name']) && $report != 'propfind') |
| 121 | 120 | { |
@@ -127,7 +126,7 @@ discard block |
||
| 127 | 126 | $this->caldav->log(__METHOD__."('$path', ".array2string($options).",, $user) not implemented report, returning 501 Not Implemented"); |
| 128 | 127 | return '501 Not Implemented'; |
| 129 | 128 | } |
| 130 | - list(,,$type,$name,$rest) = explode('/',$path,5); |
|
| 129 | + list(,, $type, $name, $rest) = explode('/', $path, 5); |
|
| 131 | 130 | // /principals/users/$name/ |
| 132 | 131 | // /users/$name/calendar-proxy-read/ |
| 133 | 132 | // /users/$name/calendar-proxy-write/ |
@@ -136,19 +135,19 @@ discard block |
||
| 136 | 135 | // /locations/$resource/ |
| 137 | 136 | // /__uids__/$uid/.../ |
| 138 | 137 | |
| 139 | - switch($type) |
|
| 138 | + switch ($type) |
|
| 140 | 139 | { |
| 141 | 140 | case 'users': |
| 142 | - $files['files'] = $this->propfind_users($name,$rest,$options); |
|
| 141 | + $files['files'] = $this->propfind_users($name, $rest, $options); |
|
| 143 | 142 | break; |
| 144 | 143 | case 'groups': |
| 145 | - $files['files'] = $this->propfind_groups($name,$rest,$options); |
|
| 144 | + $files['files'] = $this->propfind_groups($name, $rest, $options); |
|
| 146 | 145 | break; |
| 147 | 146 | case 'resources': |
| 148 | - $files['files'] = $this->propfind_resources($name,$rest,$options,false); |
|
| 147 | + $files['files'] = $this->propfind_resources($name, $rest, $options, false); |
|
| 149 | 148 | break; |
| 150 | 149 | case 'locations': |
| 151 | - $files['files'] = $this->propfind_resources($name,$rest,$options,true); |
|
| 150 | + $files['files'] = $this->propfind_resources($name, $rest, $options, true); |
|
| 152 | 151 | break; |
| 153 | 152 | /*case '__uids__': |
| 154 | 153 | $files['files'] = $this->propfind_uids($name,$rest,$options); |
@@ -258,11 +257,11 @@ discard block |
||
| 258 | 257 | * @param int $user account_id |
| 259 | 258 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
| 260 | 259 | */ |
| 261 | - function expand_property_report($path,&$options,&$files,$user) |
|
| 260 | + function expand_property_report($path, &$options, &$files, $user) |
|
| 262 | 261 | { |
| 263 | 262 | //error_log(__METHOD__."('$path', ".array2string($options).",, $user)"); |
| 264 | 263 | $requested_props = $options['other']; |
| 265 | - while(($requested_prop = array_shift($requested_props))) |
|
| 264 | + while (($requested_prop = array_shift($requested_props))) |
|
| 266 | 265 | { |
| 267 | 266 | if ($requested_prop['name'] != 'property' || $requested_prop['depth'] != 1) continue; |
| 268 | 267 | |
@@ -270,11 +269,11 @@ discard block |
||
| 270 | 269 | $prop_name = $requested_prop['attrs']['name']; |
| 271 | 270 | $prop_path = $path; |
| 272 | 271 | // calendarserver has some special property-names for expansion |
| 273 | - switch($prop_name) |
|
| 272 | + switch ($prop_name) |
|
| 274 | 273 | { |
| 275 | 274 | case 'calendar-proxy-read-for': |
| 276 | 275 | case 'calendar-proxy-write-for': |
| 277 | - $prop_path = $path . substr($prop_name, 0, -4).'/'; |
|
| 276 | + $prop_path = $path.substr($prop_name, 0, -4).'/'; |
|
| 278 | 277 | $prop_name = 'group-member-set'; |
| 279 | 278 | $prop_ns = Api\CalDAV::DAV; |
| 280 | 279 | break; |
@@ -294,14 +293,14 @@ discard block |
||
| 294 | 293 | 'xmlns' => $prop_ns, |
| 295 | 294 | )); |
| 296 | 295 | $prop_files = array(); |
| 297 | - $this->caldav->options = $options; // also modify global variable |
|
| 296 | + $this->caldav->options = $options; // also modify global variable |
|
| 298 | 297 | if (empty($prop_name) || $this->propfind($prop_path, $options, $prop_files, $user) !== true) |
| 299 | 298 | { |
| 300 | 299 | $this->caldav->log('### NO expand-property report for '.$requested_prop['attrs']['name']); |
| 301 | 300 | continue; |
| 302 | 301 | } |
| 303 | 302 | // find prop to expand |
| 304 | - foreach($prop_files['files'][0]['props'] as $expand_prop) |
|
| 303 | + foreach ($prop_files['files'][0]['props'] as $expand_prop) |
|
| 305 | 304 | { |
| 306 | 305 | if ($expand_prop['name'] === $prop_name) break; |
| 307 | 306 | } |
@@ -315,7 +314,7 @@ discard block |
||
| 315 | 314 | // requested properties of each href are in depth=2 properties |
| 316 | 315 | // set them as regular propfind properties to $options['props'] |
| 317 | 316 | $options2 = array('props' => 'all'); |
| 318 | - while(($prop = array_shift($requested_props)) && $prop['depth'] >= 2) |
|
| 317 | + while (($prop = array_shift($requested_props)) && $prop['depth'] >= 2) |
|
| 319 | 318 | { |
| 320 | 319 | if ($prop['name'] == 'property' && $prop['depth'] == 2) |
| 321 | 320 | { |
@@ -331,10 +330,10 @@ discard block |
||
| 331 | 330 | } |
| 332 | 331 | // put back evtl. read top-level property |
| 333 | 332 | if ($prop && $prop['depth'] == 1) array_unshift($requested_props, $prop); |
| 334 | - $this->caldav->options = $options2; // also modify global variable |
|
| 333 | + $this->caldav->options = $options2; // also modify global variable |
|
| 335 | 334 | |
| 336 | 335 | // run regular profind to get requested 2.-level properties for each href |
| 337 | - foreach($expand_prop['val'] as $key => &$prop_val) |
|
| 336 | + foreach ($expand_prop['val'] as $key => &$prop_val) |
|
| 338 | 337 | { |
| 339 | 338 | list(,$expand_path) = explode($this->caldav->base_uri, $prop_val['val']); |
| 340 | 339 | //error_log(__METHOD__."('$path', ..., $user) calling propfind('$expand_path', ".array2string($options2).', '.array2string($prop_val).", $user)"); |
@@ -429,23 +428,23 @@ discard block |
||
| 429 | 428 | * @param int $user account_id |
| 430 | 429 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
| 431 | 430 | */ |
| 432 | - function principal_property_search_report($path,&$options,&$files,$user) |
|
| 431 | + function principal_property_search_report($path, &$options, &$files, $user) |
|
| 433 | 432 | { |
| 434 | 433 | //error_log(__METHOD__."('$path', ".array2string($options).",, $user)"); |
| 435 | 434 | |
| 436 | 435 | // cant find the test attribute to root principal-property-search element in WebDAV rfc, but iPhones use it ... |
| 437 | - $anyof = !empty($options['root']['attrs']['test']) && $options['root']['attrs']['test'] == 'anyof'; // "allof" (default) or "anyof" |
|
| 436 | + $anyof = !empty($options['root']['attrs']['test']) && $options['root']['attrs']['test'] == 'anyof'; // "allof" (default) or "anyof" |
|
| 438 | 437 | |
| 439 | 438 | // parse property-search prop(s) contained in $options['other'] |
| 440 | - foreach($options['other'] as $n => $prop) |
|
| 439 | + foreach ($options['other'] as $n => $prop) |
|
| 441 | 440 | { |
| 442 | - switch($prop['name']) |
|
| 441 | + switch ($prop['name']) |
|
| 443 | 442 | { |
| 444 | 443 | case 'apply-to-principal-collection-set': // optinal prop to apply search on principal-collection-set == '/principals/' |
| 445 | 444 | $path = '/principals/'; |
| 446 | 445 | break; |
| 447 | 446 | case 'property-search': |
| 448 | - $property_search = $n; // should be 1 |
|
| 447 | + $property_search = $n; // should be 1 |
|
| 449 | 448 | break; |
| 450 | 449 | case 'prop': |
| 451 | 450 | if (isset($property_search)) |
@@ -475,7 +474,7 @@ discard block |
||
| 475 | 474 | return '400 Bad Request'; |
| 476 | 475 | } |
| 477 | 476 | // make sure search property is included in toplevel props (can be missing and defaults to property-search/prop's) |
| 478 | - foreach($search_props as $prop) |
|
| 477 | + foreach ($search_props as $prop) |
|
| 479 | 478 | { |
| 480 | 479 | if (!$this->caldav->prop_requested($prop['name'], $prop['xmlns'])) |
| 481 | 480 | { |
@@ -488,7 +487,7 @@ discard block |
||
| 488 | 487 | // but interprets returning all principals (all have a matching calendar-home-set) as NOT supporting CalDAV scheduling |
| 489 | 488 | // --> search only current user's principal |
| 490 | 489 | if ($prop['name'] == 'calendar-home-set' && stripos($_SERVER['HTTP_USER_AGENT'], 'Lightning') !== false && |
| 491 | - substr($search_props[0]['match'],-13) == '/groupdav.php') |
|
| 490 | + substr($search_props[0]['match'], -13) == '/groupdav.php') |
|
| 492 | 491 | { |
| 493 | 492 | $path = '/principals/users/'.$GLOBALS['egw_info']['user']['account_lid'].'/'; |
| 494 | 493 | $this->caldav->log('Enabling hack for Lightning prior 1.1.1 for searching calendar-home-set matching "/groupdav.php": limiting search to '.$path); |
@@ -497,7 +496,7 @@ discard block |
||
| 497 | 496 | // check type attribute to limit search on a certain tree |
| 498 | 497 | if (isset($options['root']['attrs']['type'])) |
| 499 | 498 | { |
| 500 | - switch($options['root']['attrs']['type']) |
|
| 499 | + switch ($options['root']['attrs']['type']) |
|
| 501 | 500 | { |
| 502 | 501 | case 'INDIVIDUAL': |
| 503 | 502 | $path = '/principals/users/'; |
@@ -524,7 +523,7 @@ discard block |
||
| 524 | 523 | return $ret; |
| 525 | 524 | } |
| 526 | 525 | // now filter out not matching "files" |
| 527 | - foreach($files['files'] as $n => $resource) |
|
| 526 | + foreach ($files['files'] as $n => $resource) |
|
| 528 | 527 | { |
| 529 | 528 | if (count(explode('/', $resource['path'])) < 5) // hack to only return principals, not the collections itself |
| 530 | 529 | { |
@@ -533,18 +532,18 @@ discard block |
||
| 533 | 532 | } |
| 534 | 533 | // match with $search_props |
| 535 | 534 | $matches = 0; |
| 536 | - foreach($search_props as $search_prop) |
|
| 535 | + foreach ($search_props as $search_prop) |
|
| 537 | 536 | { |
| 538 | 537 | // search resource for $search_prop |
| 539 | - foreach($resource['props'] as $prop) |
|
| 538 | + foreach ($resource['props'] as $prop) |
|
| 540 | 539 | { |
| 541 | 540 | if ($prop['name'] === $search_prop['name']) break; |
| 542 | 541 | } |
| 543 | 542 | if ($prop['name'] === $search_prop['name']) // search_prop NOT found |
| 544 | 543 | { |
| 545 | - foreach((array)$prop['val'] as $value) |
|
| 544 | + foreach ((array)$prop['val'] as $value) |
|
| 546 | 545 | { |
| 547 | - if (is_array($value)) $value = $value['val']; // eg. href prop |
|
| 546 | + if (is_array($value)) $value = $value['val']; // eg. href prop |
|
| 548 | 547 | if (self::match($value, $search_prop['match'], $search_prop['match-type']) !== false) // prop does match |
| 549 | 548 | { |
| 550 | 549 | ++$matches; |
@@ -556,7 +555,7 @@ discard block |
||
| 556 | 555 | if ($anyof && $matches || $matches == count($search_props)) |
| 557 | 556 | { |
| 558 | 557 | //error_log("$resource[path]: anyof=$anyof, $matches matches --> keep"); |
| 559 | - continue 2; // enough matches --> keep |
|
| 558 | + continue 2; // enough matches --> keep |
|
| 560 | 559 | } |
| 561 | 560 | } |
| 562 | 561 | //error_log("$resource[path]: anyof=$anyof, $matches matches --> skip"); |
@@ -574,9 +573,9 @@ discard block |
||
| 574 | 573 | * @param string $match criteria/sub-string |
| 575 | 574 | * @param string $match_type ='contains' 'starts-with', 'ends-with' or 'equals' |
| 576 | 575 | */ |
| 577 | - private static function match($value, $match, $match_type='contains') |
|
| 576 | + private static function match($value, $match, $match_type = 'contains') |
|
| 578 | 577 | { |
| 579 | - switch($match_type) |
|
| 578 | + switch ($match_type) |
|
| 580 | 579 | { |
| 581 | 580 | case 'equals': |
| 582 | 581 | return $value === $match; |
@@ -646,9 +645,9 @@ discard block |
||
| 646 | 645 | * @param int $user account_id |
| 647 | 646 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
| 648 | 647 | */ |
| 649 | - function principal_search_property_set_report($path,&$options,&$files,$user) |
|
| 648 | + function principal_search_property_set_report($path, &$options, &$files, $user) |
|
| 650 | 649 | { |
| 651 | - unset($path, $options, $files, $user); // not used, but required by function signature |
|
| 650 | + unset($path, $options, $files, $user); // not used, but required by function signature |
|
| 652 | 651 | |
| 653 | 652 | static $search_props = array( |
| 654 | 653 | // from iOS iCal |
@@ -670,7 +669,7 @@ discard block |
||
| 670 | 669 | $xml->startDocument('1.0', 'UTF-8'); |
| 671 | 670 | $xml->startElementNs(null, 'principal-search-property-set', 'DAV:'); |
| 672 | 671 | |
| 673 | - foreach($search_props as $name => $data) |
|
| 672 | + foreach ($search_props as $name => $data) |
|
| 674 | 673 | { |
| 675 | 674 | $xml->startElement('principal-search-property'); |
| 676 | 675 | $xml->startElement('prop'); |
@@ -682,16 +681,16 @@ discard block |
||
| 682 | 681 | { |
| 683 | 682 | $xml->writeElement($name); |
| 684 | 683 | } |
| 685 | - $xml->endElement(); // prop |
|
| 684 | + $xml->endElement(); // prop |
|
| 686 | 685 | |
| 687 | 686 | $xml->startElement('description'); |
| 688 | 687 | $xml->writeAttribute('xml:lang', 'en'); |
| 689 | 688 | $xml->text(is_array($data) ? $data['description'] : $data); |
| 690 | - $xml->endElement(); // description |
|
| 689 | + $xml->endElement(); // description |
|
| 691 | 690 | |
| 692 | - $xml->endElement(); // principal-search-property |
|
| 691 | + $xml->endElement(); // principal-search-property |
|
| 693 | 692 | } |
| 694 | - $xml->endElement(); // principal-search-property-set |
|
| 693 | + $xml->endElement(); // principal-search-property-set |
|
| 695 | 694 | $xml->endDocument(); |
| 696 | 695 | echo $xml->outputMemory(); |
| 697 | 696 | |
@@ -726,7 +725,7 @@ discard block |
||
| 726 | 725 | * @param int $user account_id |
| 727 | 726 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
| 728 | 727 | */ |
| 729 | - function acl_principal_prop_set_report($path,&$options,&$files,$user) |
|
| 728 | + function acl_principal_prop_set_report($path, &$options, &$files, $user) |
|
| 730 | 729 | { |
| 731 | 730 | //error_log(__METHOD__."('$path', ".array2string($options).",, $user)"); |
| 732 | 731 | |
@@ -745,13 +744,13 @@ discard block |
||
| 745 | 744 | return $ret; |
| 746 | 745 | } |
| 747 | 746 | // now filter out not matching "files" |
| 748 | - foreach($files['files'] as $n => $resource) |
|
| 747 | + foreach ($files['files'] as $n => $resource) |
|
| 749 | 748 | { |
| 750 | - foreach($resource['props']['resourcetype']['val'] as $prop) |
|
| 749 | + foreach ($resource['props']['resourcetype']['val'] as $prop) |
|
| 751 | 750 | { |
| 752 | 751 | if ($prop['name'] == 'principal') continue 2; |
| 753 | 752 | } |
| 754 | - unset($files['files'][$n]); // not a principal --> do not return |
|
| 753 | + unset($files['files'][$n]); // not a principal --> do not return |
|
| 755 | 754 | } |
| 756 | 755 | // we should not return it |
| 757 | 756 | unset($options['props']['resourcetype']); |
@@ -767,7 +766,7 @@ discard block |
||
| 767 | 766 | * @param array $options |
| 768 | 767 | * @return array|string array with files or HTTP error code |
| 769 | 768 | */ |
| 770 | - protected function propfind_users($name,$rest,array $options) |
|
| 769 | + protected function propfind_users($name, $rest, array $options) |
|
| 771 | 770 | { |
| 772 | 771 | //error_log(__METHOD__."($name,$rest,".array2string($options).')'); |
| 773 | 772 | if (empty($name)) |
@@ -786,7 +785,7 @@ discard block |
||
| 786 | 785 | else |
| 787 | 786 | { |
| 788 | 787 | // add all users (account_selection == groupmembers is handled by accounts->search()) |
| 789 | - foreach($this->accounts->search(array('type' => 'accounts','order' => 'account_lid')) as $account) |
|
| 788 | + foreach ($this->accounts->search(array('type' => 'accounts', 'order' => 'account_lid')) as $account) |
|
| 790 | 789 | { |
| 791 | 790 | $files[] = $this->add_account($account); |
| 792 | 791 | } |
@@ -795,18 +794,18 @@ discard block |
||
| 795 | 794 | } |
| 796 | 795 | else |
| 797 | 796 | { |
| 798 | - if (!($id = $this->accounts->name2id($name,'account_lid','u')) || |
|
| 797 | + if (!($id = $this->accounts->name2id($name, 'account_lid', 'u')) || |
|
| 799 | 798 | !($account = $this->accounts->read($id)) || |
| 800 | 799 | !$this->accounts->visible($name)) |
| 801 | 800 | { |
| 802 | 801 | $this->caldav->log(__METHOD__."('$name', ...) account '$name' NOT found OR not visible to you (check account-selection preference)!"); |
| 803 | 802 | return '404 Not Found'; |
| 804 | 803 | } |
| 805 | - while (substr($rest,-1) == '/') |
|
| 804 | + while (substr($rest, -1) == '/') |
|
| 806 | 805 | { |
| 807 | - $rest = substr($rest,0,-1); |
|
| 806 | + $rest = substr($rest, 0, -1); |
|
| 808 | 807 | } |
| 809 | - switch((string)$rest) |
|
| 808 | + switch ((string)$rest) |
|
| 810 | 809 | { |
| 811 | 810 | case '': |
| 812 | 811 | $files[] = $this->add_account($account); |
@@ -836,7 +835,7 @@ discard block |
||
| 836 | 835 | * @param array $options |
| 837 | 836 | * @return array|string array with files or HTTP error code |
| 838 | 837 | */ |
| 839 | - protected function propfind_groups($name,$rest,array $options) |
|
| 838 | + protected function propfind_groups($name, $rest, array $options) |
|
| 840 | 839 | { |
| 841 | 840 | //echo "<p>".__METHOD__."($name,$rest,".array2string($options).")</p>\n"; |
| 842 | 841 | if (empty($name)) |
@@ -848,11 +847,11 @@ discard block |
||
| 848 | 847 | if ($options['depth']) |
| 849 | 848 | { |
| 850 | 849 | // only show own groups, if account-selection is groupmembers or none |
| 851 | - $type = in_array($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'], array('groupmembers','none')) ? |
|
| 850 | + $type = in_array($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'], array('groupmembers', 'none')) ? |
|
| 852 | 851 | 'owngroups' : 'groups'; |
| 853 | 852 | |
| 854 | 853 | // add all groups or only membergroups |
| 855 | - foreach($this->accounts->search(array('type' => $type,'order' => 'account_lid')) as $account) |
|
| 854 | + foreach ($this->accounts->search(array('type' => $type, 'order' => 'account_lid')) as $account) |
|
| 856 | 855 | { |
| 857 | 856 | $files[] = $this->add_group($account); |
| 858 | 857 | } |
@@ -860,19 +859,19 @@ discard block |
||
| 860 | 859 | } |
| 861 | 860 | else |
| 862 | 861 | { |
| 863 | - if (!($id = $this->accounts->name2id($name,'account_lid','g')) || |
|
| 862 | + if (!($id = $this->accounts->name2id($name, 'account_lid', 'g')) || |
|
| 864 | 863 | !($account = $this->accounts->read($id)) || |
| 865 | 864 | // do NOT allow other groups, if account-selection is groupmembers or none |
| 866 | - in_array($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'], array('groupmembers','none')) && |
|
| 867 | - !in_array($account['account_id'], $this->accounts->memberships($GLOBALS['egw_info']['user']['account_id'],true))) |
|
| 865 | + in_array($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'], array('groupmembers', 'none')) && |
|
| 866 | + !in_array($account['account_id'], $this->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true))) |
|
| 868 | 867 | { |
| 869 | 868 | return '404 Not Found'; |
| 870 | 869 | } |
| 871 | - while (substr($rest,-1) == '/') |
|
| 870 | + while (substr($rest, -1) == '/') |
|
| 872 | 871 | { |
| 873 | - $rest = substr($rest,0,-1); |
|
| 872 | + $rest = substr($rest, 0, -1); |
|
| 874 | 873 | } |
| 875 | - switch((string)$rest) |
|
| 874 | + switch ((string)$rest) |
|
| 876 | 875 | { |
| 877 | 876 | case '': |
| 878 | 877 | $files[] = $this->add_group($account); |
@@ -903,10 +902,10 @@ discard block |
||
| 903 | 902 | { |
| 904 | 903 | $addressbooks = array(); |
| 905 | 904 | $ab_home_set = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set']; |
| 906 | - if (empty($ab_home_set)) $ab_home_set = 'P'; // personal addressbook |
|
| 905 | + if (empty($ab_home_set)) $ab_home_set = 'P'; // personal addressbook |
|
| 907 | 906 | $addressbook_home_set = explode(',', $ab_home_set); |
| 908 | 907 | // replace symbolic id's with real nummeric id's |
| 909 | - foreach(array( |
|
| 908 | + foreach (array( |
|
| 910 | 909 | 'P' => $GLOBALS['egw_info']['user']['account_id'], |
| 911 | 910 | 'G' => $GLOBALS['egw_info']['user']['account_primary_group'], |
| 912 | 911 | 'U' => '0', |
@@ -917,13 +916,13 @@ discard block |
||
| 917 | 916 | $addressbook_home_set[$key] = $id; |
| 918 | 917 | } |
| 919 | 918 | } |
| 920 | - if (in_array('O',$addressbook_home_set)) // "all in one" from groupdav.php/addressbook/ |
|
| 919 | + if (in_array('O', $addressbook_home_set)) // "all in one" from groupdav.php/addressbook/ |
|
| 921 | 920 | { |
| 922 | 921 | $addressbooks[] = '/'; |
| 923 | 922 | } |
| 924 | - foreach(array_keys($GLOBALS['egw']->contacts->get_addressbooks(Api\Acl::READ)) as $id) |
|
| 923 | + foreach (array_keys($GLOBALS['egw']->contacts->get_addressbooks(Api\Acl::READ)) as $id) |
|
| 925 | 924 | { |
| 926 | - if ((in_array('A',$addressbook_home_set) || in_array((string)$id,$addressbook_home_set)) && |
|
| 925 | + if ((in_array('A', $addressbook_home_set) || in_array((string)$id, $addressbook_home_set)) && |
|
| 927 | 926 | is_numeric($id) && ($owner = $this->accounts->id2name($id))) |
| 928 | 927 | { |
| 929 | 928 | $addressbooks[] = '/'.$owner.'/'; |
@@ -947,45 +946,45 @@ discard block |
||
| 947 | 946 | $calendars[] = Api\CalDAV::mkprop('href', |
| 948 | 947 | $this->base_uri.'/'.$account['account_lid'].'/'); |
| 949 | 948 | |
| 950 | - $displayname = Api\Translation::convert($account['account_fullname'], Api\Translation::charset(),'utf-8'); |
|
| 949 | + $displayname = Api\Translation::convert($account['account_fullname'], Api\Translation::charset(), 'utf-8'); |
|
| 951 | 950 | |
| 952 | 951 | return $this->add_principal('users/'.$account['account_lid'], array( |
| 953 | 952 | 'getetag' => $this->get_etag($account), |
| 954 | 953 | 'displayname' => $displayname, |
| 955 | 954 | // CalDAV |
| 956 | - 'calendar-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-home-set',$calendars), |
|
| 955 | + 'calendar-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-home-set', $calendars), |
|
| 957 | 956 | // CalDAV scheduling |
| 958 | - 'schedule-outbox-URL' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'schedule-outbox-URL',array( |
|
| 959 | - Api\CalDAV::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/outbox/'))), |
|
| 960 | - 'schedule-inbox-URL' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'schedule-inbox-URL',array( |
|
| 961 | - Api\CalDAV::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/inbox/'))), |
|
| 962 | - 'calendar-user-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-user-address-set',array( |
|
| 963 | - Api\CalDAV::mkprop('href','mailto:'.$account['account_email']), |
|
| 964 | - Api\CalDAV::mkprop('href',$this->base_uri(true).'/principals/users/'.$account['account_lid'].'/'), |
|
| 965 | - Api\CalDAV::mkprop('href',$this->base_uri(false).'/principals/users/'.$account['account_lid'].'/'), |
|
| 966 | - Api\CalDAV::mkprop('href','urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id'])), |
|
| 957 | + 'schedule-outbox-URL' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'schedule-outbox-URL', array( |
|
| 958 | + Api\CalDAV::mkprop('href', $this->base_uri.'/'.$account['account_lid'].'/outbox/'))), |
|
| 959 | + 'schedule-inbox-URL' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'schedule-inbox-URL', array( |
|
| 960 | + Api\CalDAV::mkprop('href', $this->base_uri.'/'.$account['account_lid'].'/inbox/'))), |
|
| 961 | + 'calendar-user-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-user-address-set', array( |
|
| 962 | + Api\CalDAV::mkprop('href', 'mailto:'.$account['account_email']), |
|
| 963 | + Api\CalDAV::mkprop('href', $this->base_uri(true).'/principals/users/'.$account['account_lid'].'/'), |
|
| 964 | + Api\CalDAV::mkprop('href', $this->base_uri(false).'/principals/users/'.$account['account_lid'].'/'), |
|
| 965 | + Api\CalDAV::mkprop('href', 'urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id'])), |
|
| 967 | 966 | )), |
| 968 | - 'calendar-user-type' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-user-type','INDIVIDUAL'), |
|
| 967 | + 'calendar-user-type' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-user-type', 'INDIVIDUAL'), |
|
| 969 | 968 | // Calendarserver |
| 970 | - 'email-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'email-address-set',array( |
|
| 971 | - Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'email-address',$account['account_email']))), |
|
| 972 | - 'last-name' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'last-name',$account['account_lastname']), |
|
| 973 | - 'first-name' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'first-name',$account['account_firstname']), |
|
| 974 | - 'record-type' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'record-type','users'), |
|
| 969 | + 'email-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'email-address-set', array( |
|
| 970 | + Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'email-address', $account['account_email']))), |
|
| 971 | + 'last-name' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'last-name', $account['account_lastname']), |
|
| 972 | + 'first-name' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'first-name', $account['account_firstname']), |
|
| 973 | + 'record-type' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'record-type', 'users'), |
|
| 975 | 974 | // WebDAV ACL and CalDAV proxy |
| 976 | 975 | 'group-membership' => $this->principal_set('group-membership', $this->accounts->memberships($account['account_id']), |
| 977 | - array('calendar', 'resources'), $account['account_id']), // add proxy-rights |
|
| 976 | + array('calendar', 'resources'), $account['account_id']), // add proxy-rights |
|
| 978 | 977 | 'alternate-URI-set' => array( |
| 979 | - Api\CalDAV::mkprop('href','mailto:'.$account['account_email'])), |
|
| 978 | + Api\CalDAV::mkprop('href', 'mailto:'.$account['account_email'])), |
|
| 980 | 979 | // CardDAV |
| 981 | - 'addressbook-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-home-set',$addressbooks), |
|
| 982 | - 'principal-address' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'principal-address', |
|
| 980 | + 'addressbook-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-home-set', $addressbooks), |
|
| 981 | + 'principal-address' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'principal-address', |
|
| 983 | 982 | $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] ? '' : array( |
| 984 | - Api\CalDAV::mkprop('href',$this->base_uri.'/addressbook-accounts/'.$account['person_id'].'.vcf'))), |
|
| 983 | + Api\CalDAV::mkprop('href', $this->base_uri.'/addressbook-accounts/'.$account['person_id'].'.vcf'))), |
|
| 985 | 984 | // CardDAV directory |
| 986 | - 'directory-gateway' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'directory-gateway',array( |
|
| 985 | + 'directory-gateway' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'directory-gateway', array( |
|
| 987 | 986 | Api\CalDAV::mkprop('href', $this->base_uri.'/addressbook/'))), |
| 988 | - 'resource-id' => array(Api\CalDAV::mkprop('href','urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id']))), |
|
| 987 | + 'resource-id' => array(Api\CalDAV::mkprop('href', 'urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id']))), |
|
| 989 | 988 | )); |
| 990 | 989 | } |
| 991 | 990 | |
@@ -997,7 +996,7 @@ discard block |
||
| 997 | 996 | * @param string $cn =null common name to be stored in case of an "e" uid |
| 998 | 997 | * @return int|string|boolean integer account_id, string calendar uid or false if not a supported uid |
| 999 | 998 | */ |
| 1000 | - static public function url2uid($url, $only_type=null, $cn=null) |
|
| 999 | + static public function url2uid($url, $only_type = null, $cn = null) |
|
| 1001 | 1000 | { |
| 1002 | 1001 | if (!$only_type) $only_type = array('users', 'groups', 'resources', 'locations', 'mailto'); |
| 1003 | 1002 | |
@@ -1011,17 +1010,17 @@ discard block |
||
| 1011 | 1010 | } |
| 1012 | 1011 | if (empty($rest)) return false; |
| 1013 | 1012 | |
| 1014 | - switch(strtolower($schema)) |
|
| 1013 | + switch (strtolower($schema)) |
|
| 1015 | 1014 | { |
| 1016 | 1015 | case 'http': |
| 1017 | 1016 | case 'https': |
| 1018 | 1017 | list(,$rest) = explode('/groupdav.php/principals/', $url); |
| 1019 | 1018 | list($type, $name) = explode('/', $rest); |
| 1020 | - switch($type) |
|
| 1019 | + switch ($type) |
|
| 1021 | 1020 | { |
| 1022 | 1021 | case 'users': |
| 1023 | 1022 | case 'groups': |
| 1024 | - $uid = $GLOBALS['egw']->accounts->name2id($name, 'account_lid', $type[0]); // u=users, g=groups |
|
| 1023 | + $uid = $GLOBALS['egw']->accounts->name2id($name, 'account_lid', $type[0]); // u=users, g=groups |
|
| 1025 | 1024 | break; |
| 1026 | 1025 | case 'resources': |
| 1027 | 1026 | case 'locations': |
@@ -1038,9 +1037,9 @@ discard block |
||
| 1038 | 1037 | } |
| 1039 | 1038 | // search contacts for email |
| 1040 | 1039 | if ((list($data) = $GLOBALS['egw']->contacts->search(array('email' => $rest, 'email_home' => $rest), |
| 1041 | - array('id','egw_addressbook.account_id as account_id','n_fn'), |
|
| 1040 | + array('id', 'egw_addressbook.account_id as account_id', 'n_fn'), |
|
| 1042 | 1041 | 'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC', |
| 1043 | - '','',false,'OR'))) |
|
| 1042 | + '', '', false, 'OR'))) |
|
| 1044 | 1043 | { |
| 1045 | 1044 | // found an addressbook entry |
| 1046 | 1045 | $uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id']; |
@@ -1058,7 +1057,7 @@ discard block |
||
| 1058 | 1057 | list($type, $id, $install_id) = explode('-', $uid); |
| 1059 | 1058 | if ($type == 'accounts' && empty($id)) // groups have a negative id, eg. "urn:uuid:accounts--1-..." |
| 1060 | 1059 | { |
| 1061 | - list($type, , $id_abs, $install_id) = explode('-', $uid); |
|
| 1060 | + list($type,, $id_abs, $install_id) = explode('-', $uid); |
|
| 1062 | 1061 | $id = -$id_abs; |
| 1063 | 1062 | } |
| 1064 | 1063 | // own urn |
@@ -1071,9 +1070,9 @@ discard block |
||
| 1071 | 1070 | } |
| 1072 | 1071 | else |
| 1073 | 1072 | { |
| 1074 | - static $calendar_bo=null; |
|
| 1073 | + static $calendar_bo = null; |
|
| 1075 | 1074 | if (is_null($calendar_bo)) $calendar_bo = new calendar_bo(); |
| 1076 | - foreach($calendar_bo->resources as $letter => $info) |
|
| 1075 | + foreach ($calendar_bo->resources as $letter => $info) |
|
| 1077 | 1076 | { |
| 1078 | 1077 | if ($info['app'] == $type || $info['app'] == 'resources' && $type == 'location') |
| 1079 | 1078 | { |
@@ -1086,7 +1085,7 @@ discard block |
||
| 1086 | 1085 | break; |
| 1087 | 1086 | |
| 1088 | 1087 | default: |
| 1089 | - if (isset($GLOBALS['groupdav']) && is_a($GLOBALS['groupdav'],'groupdav')) |
|
| 1088 | + if (isset($GLOBALS['groupdav']) && is_a($GLOBALS['groupdav'], 'groupdav')) |
|
| 1090 | 1089 | { |
| 1091 | 1090 | $GLOBALS['groupdav']->log(__METHOD__."('$url') unsupported principal URL '$url'!"); |
| 1092 | 1091 | } |
@@ -1104,7 +1103,7 @@ discard block |
||
| 1104 | 1103 | */ |
| 1105 | 1104 | protected function add_group(array $account) |
| 1106 | 1105 | { |
| 1107 | - $displayname = Api\Translation::convert(lang('Group').' '.$account['account_lid'], Api\Translation::charset(), 'utf-8'); |
|
| 1106 | + $displayname = Api\Translation::convert(lang('Group').' '.$account['account_lid'], Api\Translation::charset(), 'utf-8'); |
|
| 1108 | 1107 | |
| 1109 | 1108 | // only return current user, if account-selection == 'none' |
| 1110 | 1109 | if ($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'none') |
@@ -1119,19 +1118,19 @@ discard block |
||
| 1119 | 1118 | return $this->add_principal('groups/'.$account['account_lid'], array( |
| 1120 | 1119 | 'getetag' => $this->get_etag($account), |
| 1121 | 1120 | 'displayname' => $displayname, |
| 1122 | - 'calendar-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-home-set',array( |
|
| 1123 | - Api\CalDAV::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/'))), |
|
| 1124 | - 'addressbook-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-home-set',array( |
|
| 1125 | - Api\CalDAV::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/'))), |
|
| 1126 | - 'calendar-user-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-user-address-set',array( |
|
| 1127 | - Api\CalDAV::mkprop('href',$this->base_uri(true).'/principals/groups/'.$account['account_lid'].'/'), |
|
| 1128 | - Api\CalDAV::mkprop('href',$this->base_uri(false).'/principals/groups/'.$account['account_lid'].'/'), |
|
| 1129 | - Api\CalDAV::mkprop('href','urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id'])), |
|
| 1121 | + 'calendar-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-home-set', array( |
|
| 1122 | + Api\CalDAV::mkprop('href', $this->base_uri.'/'.$account['account_lid'].'/'))), |
|
| 1123 | + 'addressbook-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-home-set', array( |
|
| 1124 | + Api\CalDAV::mkprop('href', $this->base_uri.'/'.$account['account_lid'].'/'))), |
|
| 1125 | + 'calendar-user-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-user-address-set', array( |
|
| 1126 | + Api\CalDAV::mkprop('href', $this->base_uri(true).'/principals/groups/'.$account['account_lid'].'/'), |
|
| 1127 | + Api\CalDAV::mkprop('href', $this->base_uri(false).'/principals/groups/'.$account['account_lid'].'/'), |
|
| 1128 | + Api\CalDAV::mkprop('href', 'urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id'])), |
|
| 1130 | 1129 | )), |
| 1131 | - 'record-type' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'record-type','groups'), |
|
| 1132 | - 'calendar-user-type' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-user-type','GROUP'), |
|
| 1130 | + 'record-type' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'record-type', 'groups'), |
|
| 1131 | + 'calendar-user-type' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-user-type', 'GROUP'), |
|
| 1133 | 1132 | 'group-member-set' => $this->principal_set('group-member-set', $groupmembers), |
| 1134 | - 'resource-id' => array(Api\CalDAV::mkprop('href','urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id']))), |
|
| 1133 | + 'resource-id' => array(Api\CalDAV::mkprop('href', 'urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id']))), |
|
| 1135 | 1134 | )); |
| 1136 | 1135 | } |
| 1137 | 1136 | |
@@ -1142,7 +1141,7 @@ discard block |
||
| 1142 | 1141 | * @param boolean $is_location =null |
| 1143 | 1142 | * @return array with values for keys 'path' and 'props' |
| 1144 | 1143 | */ |
| 1145 | - protected function add_principal_resource(array $resource, $is_location=null) |
|
| 1144 | + protected function add_principal_resource(array $resource, $is_location = null) |
|
| 1146 | 1145 | { |
| 1147 | 1146 | $displayname = null; |
| 1148 | 1147 | $name = $this->resource2name($resource, $is_location, $displayname); |
@@ -1150,18 +1149,18 @@ discard block |
||
| 1150 | 1149 | return $this->add_principal($name, array( |
| 1151 | 1150 | 'getetag' => $this->get_resource_etag($resource), |
| 1152 | 1151 | 'displayname' => $displayname, |
| 1153 | - 'calendar-user-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-user-address-set',array( |
|
| 1154 | - Api\CalDAV::mkprop('href',$this->base_uri(true).'/principals/'.$name.'/'), |
|
| 1155 | - Api\CalDAV::mkprop('href',$this->base_uri(false).'/principals/'.$name.'/'), |
|
| 1156 | - Api\CalDAV::mkprop('href','urn:uuid:'.Api\CalDAV::generate_uid('resources', $resource['res_id'])), |
|
| 1152 | + 'calendar-user-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-user-address-set', array( |
|
| 1153 | + Api\CalDAV::mkprop('href', $this->base_uri(true).'/principals/'.$name.'/'), |
|
| 1154 | + Api\CalDAV::mkprop('href', $this->base_uri(false).'/principals/'.$name.'/'), |
|
| 1155 | + Api\CalDAV::mkprop('href', 'urn:uuid:'.Api\CalDAV::generate_uid('resources', $resource['res_id'])), |
|
| 1157 | 1156 | )), |
| 1158 | - 'record-type' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'record-type',$is_location ? 'locations' : 'resources'), |
|
| 1159 | - 'calendar-user-type' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-user-type',$is_location ? 'ROOM' : 'RESOURCE'), |
|
| 1160 | - 'resource-id' => array(Api\CalDAV::mkprop('href','urn:uuid:'.Api\CalDAV::generate_uid('resources', $resource['res_id']))), |
|
| 1157 | + 'record-type' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'record-type', $is_location ? 'locations' : 'resources'), |
|
| 1158 | + 'calendar-user-type' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-user-type', $is_location ? 'ROOM' : 'RESOURCE'), |
|
| 1159 | + 'resource-id' => array(Api\CalDAV::mkprop('href', 'urn:uuid:'.Api\CalDAV::generate_uid('resources', $resource['res_id']))), |
|
| 1161 | 1160 | // Calendarserver also reports empty email-address-set, thought iCal still does not show resources (only locations) |
| 1162 | - 'email-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'email-address-set',''), |
|
| 1163 | - 'calendar-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-home-set',array( |
|
| 1164 | - Api\CalDAV::mkprop('href',$this->base_uri.'/'.$name.'/'))), |
|
| 1161 | + 'email-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'email-address-set', ''), |
|
| 1162 | + 'calendar-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-home-set', array( |
|
| 1163 | + Api\CalDAV::mkprop('href', $this->base_uri.'/'.$name.'/'))), |
|
| 1165 | 1164 | )); |
| 1166 | 1165 | } |
| 1167 | 1166 | |
@@ -1173,7 +1172,7 @@ discard block |
||
| 1173 | 1172 | * @param string &$displayname=null on return displayname of resource |
| 1174 | 1173 | * @return string eg. "locations/123-some-room" or "resouces/345-some-device" |
| 1175 | 1174 | */ |
| 1176 | - public static function resource2name($resource, &$is_location=null, &$displayname=null) |
|
| 1175 | + public static function resource2name($resource, &$is_location = null, &$displayname = null) |
|
| 1177 | 1176 | { |
| 1178 | 1177 | if (!is_array($resource) && !($resource = self::read_resource($resource))) |
| 1179 | 1178 | { |
@@ -1181,10 +1180,10 @@ discard block |
||
| 1181 | 1180 | } |
| 1182 | 1181 | if (is_null($is_location)) $is_location = self::resource_is_location($resource); |
| 1183 | 1182 | |
| 1184 | - $displayname = Api\Translation::convert($resource['name'], Api\Translation::charset(), 'utf-8'); |
|
| 1183 | + $displayname = Api\Translation::convert($resource['name'], Api\Translation::charset(), 'utf-8'); |
|
| 1185 | 1184 | |
| 1186 | 1185 | return ($is_location ? 'locations/' : 'resources/').$resource['res_id'].'-'. |
| 1187 | - preg_replace('/[^a-z0-9]+/i','-', Api\Translation::to_ascii($resource['name'])); |
|
| 1186 | + preg_replace('/[^a-z0-9]+/i', '-', Api\Translation::to_ascii($resource['name'])); |
|
| 1188 | 1187 | } |
| 1189 | 1188 | |
| 1190 | 1189 | /** |
@@ -1195,7 +1194,7 @@ discard block |
||
| 1195 | 1194 | */ |
| 1196 | 1195 | public static function resource_is_location($resource) |
| 1197 | 1196 | { |
| 1198 | - static $location_cats=null; |
|
| 1197 | + static $location_cats = null; |
|
| 1199 | 1198 | if (is_null($location_cats)) |
| 1200 | 1199 | { |
| 1201 | 1200 | $config = Api\Config::read('resources'); |
@@ -1216,7 +1215,7 @@ discard block |
||
| 1216 | 1215 | */ |
| 1217 | 1216 | public static function read_resource($res_id) |
| 1218 | 1217 | { |
| 1219 | - static $cache=null; // some per-request caching |
|
| 1218 | + static $cache = null; // some per-request caching |
|
| 1220 | 1219 | |
| 1221 | 1220 | if (isset(self::$all_resources) && isset(self::$all_resources[$res_id])) |
| 1222 | 1221 | { |
@@ -1258,7 +1257,7 @@ discard block |
||
| 1258 | 1257 | * @param int $user =null account_if of user, or null for current user |
| 1259 | 1258 | * @return array of array with values for res_id, cat_id and name (no other values1) |
| 1260 | 1259 | */ |
| 1261 | - public static function get_resources($user=null) |
|
| 1260 | + public static function get_resources($user = null) |
|
| 1262 | 1261 | { |
| 1263 | 1262 | if (!isset(self::$all_resources)) |
| 1264 | 1263 | { |
@@ -1266,18 +1265,18 @@ discard block |
||
| 1266 | 1265 | |
| 1267 | 1266 | self::$all_resources = array(); |
| 1268 | 1267 | $query = array( |
| 1269 | - 'show_bookable' => true, // ignore non-bookable resources |
|
| 1268 | + 'show_bookable' => true, // ignore non-bookable resources |
|
| 1270 | 1269 | 'filter2' => -3, |
| 1271 | 1270 | 'start' => 0, |
| 1272 | - 'num_rows' => 10000, // return all aka first 10000 entries |
|
| 1271 | + 'num_rows' => 10000, // return all aka first 10000 entries |
|
| 1273 | 1272 | ); |
| 1274 | 1273 | $rows = $readonlys = null; |
| 1275 | 1274 | if (self::$resources->get_rows($query, $rows, $readonlys)) |
| 1276 | 1275 | { |
| 1277 | 1276 | //_debug_array($rows); |
| 1278 | - foreach($rows as $resource) |
|
| 1277 | + foreach ($rows as $resource) |
|
| 1279 | 1278 | { |
| 1280 | - self::$all_resources[$resource['res_id']] = array_intersect_key($resource, array('res_id'=>true,'cat_id'=>true,'name'=>true)); |
|
| 1279 | + self::$all_resources[$resource['res_id']] = array_intersect_key($resource, array('res_id'=>true, 'cat_id'=>true, 'name'=>true)); |
|
| 1281 | 1280 | } |
| 1282 | 1281 | } |
| 1283 | 1282 | } |
@@ -1293,7 +1292,7 @@ discard block |
||
| 1293 | 1292 | */ |
| 1294 | 1293 | protected function get_resource_rights() |
| 1295 | 1294 | { |
| 1296 | - static $grants=null; |
|
| 1295 | + static $grants = null; |
|
| 1297 | 1296 | |
| 1298 | 1297 | if (is_null($grants)) |
| 1299 | 1298 | { |
@@ -1326,19 +1325,19 @@ discard block |
||
| 1326 | 1325 | * @param string $principal_url =null include given principal url, relative to principal-collection-set, default $principal |
| 1327 | 1326 | * @return array with values for keys 'path' and 'props' |
| 1328 | 1327 | */ |
| 1329 | - protected function add_principal($principal, array $props = array(), $principal_url=null) |
|
| 1328 | + protected function add_principal($principal, array $props = array(), $principal_url = null) |
|
| 1330 | 1329 | { |
| 1331 | 1330 | $props['resourcetype'][] = Api\CalDAV::mkprop('principal', ''); |
| 1332 | 1331 | |
| 1333 | 1332 | // required props per WebDAV ACL |
| 1334 | - foreach(array('alternate-URI-set', 'group-membership') as $name) |
|
| 1333 | + foreach (array('alternate-URI-set', 'group-membership') as $name) |
|
| 1335 | 1334 | { |
| 1336 | - if (!isset($props[$name])) $props[$name] = Api\CalDAV::mkprop($name,''); |
|
| 1335 | + if (!isset($props[$name])) $props[$name] = Api\CalDAV::mkprop($name, ''); |
|
| 1337 | 1336 | } |
| 1338 | 1337 | if (!$principal_url) $principal_url = $principal; |
| 1339 | 1338 | |
| 1340 | 1339 | $props['principal-URL'] = array( |
| 1341 | - Api\CalDAV::mkprop('href',$this->base_uri.'/principals/'.$principal.'/')); |
|
| 1340 | + Api\CalDAV::mkprop('href', $this->base_uri.'/principals/'.$principal.'/')); |
|
| 1342 | 1341 | |
| 1343 | 1342 | return $this->add_collection('/principals/'.$principal.'/', $props); |
| 1344 | 1343 | } |
@@ -1354,20 +1353,20 @@ discard block |
||
| 1354 | 1353 | * @param array $resource =null resource to use (to not query it multiple times from the database) |
| 1355 | 1354 | * @return array with values for 'path' and 'props' |
| 1356 | 1355 | */ |
| 1357 | - protected function add_proxys($principal, $type, array $proxys=array(), array $resource=null) |
|
| 1356 | + protected function add_proxys($principal, $type, array $proxys = array(), array $resource = null) |
|
| 1358 | 1357 | { |
| 1359 | 1358 | list($app,,$what) = explode('-', $type); |
| 1360 | 1359 | |
| 1361 | - if (true) $proxys = array(); // ignore parameter! |
|
| 1362 | - list($account_type,$account) = explode('/', $principal); |
|
| 1360 | + if (true) $proxys = array(); // ignore parameter! |
|
| 1361 | + list($account_type, $account) = explode('/', $principal); |
|
| 1363 | 1362 | |
| 1364 | - switch($account_type) |
|
| 1363 | + switch ($account_type) |
|
| 1365 | 1364 | { |
| 1366 | 1365 | case 'users': |
| 1367 | 1366 | case 'groups': |
| 1368 | 1367 | $account = $location = $this->accounts->name2id($account, 'account_lid', $account_type[0]); |
| 1369 | 1368 | $right = $what == 'write' ? Api\Acl::EDIT : Api\Acl::READ; |
| 1370 | - $mask = $what == 'write' ? Api\Acl::EDIT : Api\Acl::EDIT|Api\Acl::READ; // do NOT report write+read in read |
|
| 1369 | + $mask = $what == 'write' ? Api\Acl::EDIT : Api\Acl::EDIT|Api\Acl::READ; // do NOT report write+read in read |
|
| 1371 | 1370 | break; |
| 1372 | 1371 | |
| 1373 | 1372 | case 'locations': |
@@ -1379,18 +1378,18 @@ discard block |
||
| 1379 | 1378 | } |
| 1380 | 1379 | $location = 'L'.$resource['cat_id']; |
| 1381 | 1380 | $right = $what == 'write' ? EGW_ACL_DIRECT_BOOKING : EGW_ACL_CALREAD; |
| 1382 | - $mask = $what == 'write' ? EGW_ACL_DIRECT_BOOKING : EGW_ACL_DIRECT_BOOKING|EGW_ACL_CALREAD; // do NOT report write+read in read |
|
| 1381 | + $mask = $what == 'write' ? EGW_ACL_DIRECT_BOOKING : EGW_ACL_DIRECT_BOOKING|EGW_ACL_CALREAD; // do NOT report write+read in read |
|
| 1383 | 1382 | break; |
| 1384 | 1383 | } |
| 1385 | 1384 | static $principal2grants = array(); |
| 1386 | - $grants =& $principal2grants[$principal]; |
|
| 1385 | + $grants = & $principal2grants[$principal]; |
|
| 1387 | 1386 | if (!isset($grants)) |
| 1388 | 1387 | { |
| 1389 | - switch($app) |
|
| 1388 | + switch ($app) |
|
| 1390 | 1389 | { |
| 1391 | 1390 | case 'resources': |
| 1392 | 1391 | $res_grants = $this->get_resource_rights(); |
| 1393 | - $grants = (array)$res_grants[$location]; // returns array($location => $grants) |
|
| 1392 | + $grants = (array)$res_grants[$location]; // returns array($location => $grants) |
|
| 1394 | 1393 | break; |
| 1395 | 1394 | |
| 1396 | 1395 | case 'calendar': |
@@ -1400,9 +1399,9 @@ discard block |
||
| 1400 | 1399 | } |
| 1401 | 1400 | //echo "<p>type=$type --> app=$app, what=$what --> right=$right, mask=$mask, account=$account, location=$location --> grants=".array2string($grants)."</p>\n"; |
| 1402 | 1401 | } |
| 1403 | - foreach($grants as $account_id => $rights) |
|
| 1402 | + foreach ($grants as $account_id => $rights) |
|
| 1404 | 1403 | { |
| 1405 | - if ($account_id !== 'run' && $account_id != $account && ($rights & $mask) == $right && |
|
| 1404 | + if ($account_id !== 'run' && $account_id != $account && ($rights&$mask) == $right && |
|
| 1406 | 1405 | ($account_lid = $this->accounts->id2name($account_id))) |
| 1407 | 1406 | { |
| 1408 | 1407 | // ignore "broken" grants (eg. negative account_id for a user), as they lead to further errors (no members) |
@@ -1433,12 +1432,12 @@ discard block |
||
| 1433 | 1432 | * @param int $account who is the proxy |
| 1434 | 1433 | * @return array with href props |
| 1435 | 1434 | */ |
| 1436 | - protected function principal_set($prop, array $accounts=array(), $app_proxys=null, $account=null) |
|
| 1435 | + protected function principal_set($prop, array $accounts = array(), $app_proxys = null, $account = null) |
|
| 1437 | 1436 | { |
| 1438 | - unset($prop); // not used, but required by function signature |
|
| 1437 | + unset($prop); // not used, but required by function signature |
|
| 1439 | 1438 | |
| 1440 | 1439 | $set = array(); |
| 1441 | - foreach($accounts as $account_id => $account_lid) |
|
| 1440 | + foreach ($accounts as $account_id => $account_lid) |
|
| 1442 | 1441 | { |
| 1443 | 1442 | if ($this->accounts->visible($account_lid)) // only add visible accounts, gives error in iCal otherwise |
| 1444 | 1443 | { |
@@ -1447,11 +1446,11 @@ discard block |
||
| 1447 | 1446 | } |
| 1448 | 1447 | if ($app_proxys) |
| 1449 | 1448 | { |
| 1450 | - foreach((array)$app_proxys as $app) |
|
| 1449 | + foreach ((array)$app_proxys as $app) |
|
| 1451 | 1450 | { |
| 1452 | 1451 | if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) continue; |
| 1453 | 1452 | |
| 1454 | - switch($app) |
|
| 1453 | + switch ($app) |
|
| 1455 | 1454 | { |
| 1456 | 1455 | case 'resources': |
| 1457 | 1456 | $proxy_groups = $this->get_resource_proxy_groups($account); |
@@ -1483,11 +1482,11 @@ discard block |
||
| 1483 | 1482 | // get location grants for $account (incl. his memberships) |
| 1484 | 1483 | $memberships = $GLOBALS['egw']->accounts->memberships($account, true); |
| 1485 | 1484 | $location_grants = array(); |
| 1486 | - foreach($all_location_grants as $location => $grants) |
|
| 1485 | + foreach ($all_location_grants as $location => $grants) |
|
| 1487 | 1486 | { |
| 1488 | - foreach($grants as $account_id => $rights) |
|
| 1487 | + foreach ($grants as $account_id => $rights) |
|
| 1489 | 1488 | { |
| 1490 | - if (($rights & (EGW_ACL_CALREAD|EGW_ACL_DIRECT_BOOKING)) && // we only care for these rights |
|
| 1489 | + if (($rights&(EGW_ACL_CALREAD|EGW_ACL_DIRECT_BOOKING)) && // we only care for these rights |
|
| 1491 | 1490 | ($account_id == $account || in_array($account_id, $memberships))) |
| 1492 | 1491 | { |
| 1493 | 1492 | if (!isset($location_grants[$location])) $location_grants[$location] = 0; |
@@ -1496,13 +1495,13 @@ discard block |
||
| 1496 | 1495 | } |
| 1497 | 1496 | } |
| 1498 | 1497 | // now add proxy-groups for all resources user has rights to |
| 1499 | - foreach($resources as $resource) |
|
| 1498 | + foreach ($resources as $resource) |
|
| 1500 | 1499 | { |
| 1501 | 1500 | $rights = $location_grants['L'.$resource['cat_id']]; |
| 1502 | 1501 | if (isset($rights)) |
| 1503 | 1502 | { |
| 1504 | 1503 | $set[] = Api\CalDAV::mkprop('href', $this->base_uri.'/principals/'.$this->resource2name($resource). |
| 1505 | - '/calendar-proxy-'.($rights & EGW_ACL_DIRECT_BOOKING ? 'write' : 'read').'/'); |
|
| 1504 | + '/calendar-proxy-'.($rights&EGW_ACL_DIRECT_BOOKING ? 'write' : 'read').'/'); |
|
| 1506 | 1505 | } |
| 1507 | 1506 | } |
| 1508 | 1507 | } |
@@ -1517,18 +1516,18 @@ discard block |
||
| 1517 | 1516 | * @param string|array $app ='calendar' applications for which proxys should be added |
| 1518 | 1517 | * @return array with href props |
| 1519 | 1518 | */ |
| 1520 | - protected function get_calendar_proxy_groups($account, $app='calendar') |
|
| 1519 | + protected function get_calendar_proxy_groups($account, $app = 'calendar') |
|
| 1521 | 1520 | { |
| 1522 | 1521 | $set = array(); |
| 1523 | - foreach($this->acl->get_grants($app, $app != 'addressbook', $account) as $account_id => $rights) |
|
| 1522 | + foreach ($this->acl->get_grants($app, $app != 'addressbook', $account) as $account_id => $rights) |
|
| 1524 | 1523 | { |
| 1525 | - if ($account_id != $account && ($rights & Api\Acl::READ) && |
|
| 1524 | + if ($account_id != $account && ($rights&Api\Acl::READ) && |
|
| 1526 | 1525 | ($account_lid = $this->accounts->id2name($account_id)) && |
| 1527 | 1526 | $this->accounts->visible($account_lid)) // only add visible accounts, gives error in iCal otherwise |
| 1528 | 1527 | { |
| 1529 | 1528 | $set[] = Api\CalDAV::mkprop('href', $this->base_uri.'/principals/'. |
| 1530 | 1529 | ($account_id < 0 ? 'groups/' : 'users/'). |
| 1531 | - $account_lid.'/'.$app.'-proxy-'.($rights & Api\Acl::EDIT ? 'write' : 'read').'/'); |
|
| 1530 | + $account_lid.'/'.$app.'-proxy-'.($rights&Api\Acl::EDIT ? 'write' : 'read').'/'); |
|
| 1532 | 1531 | } |
| 1533 | 1532 | } |
| 1534 | 1533 | return $set; |
@@ -1543,7 +1542,7 @@ discard block |
||
| 1543 | 1542 | * @param boolean $do_locations =false false: /principal/resources, true: /principals/locations |
| 1544 | 1543 | * @return array|string array with files or HTTP error code |
| 1545 | 1544 | */ |
| 1546 | - protected function propfind_resources($name,$rest,array $options,$do_locations=false) |
|
| 1545 | + protected function propfind_resources($name, $rest, array $options, $do_locations = false) |
|
| 1547 | 1546 | { |
| 1548 | 1547 | if (!isset($GLOBALS['egw_info']['user']['apps']['resources'])) |
| 1549 | 1548 | { |
@@ -1562,7 +1561,7 @@ discard block |
||
| 1562 | 1561 | if (($resources = $this->get_resources())) |
| 1563 | 1562 | { |
| 1564 | 1563 | //_debug_array($resources); |
| 1565 | - foreach($resources as $resource) |
|
| 1564 | + foreach ($resources as $resource) |
|
| 1566 | 1565 | { |
| 1567 | 1566 | if (($is_location = self::resource_is_location($resource)) == $do_locations) |
| 1568 | 1567 | { |
@@ -1579,11 +1578,11 @@ discard block |
||
| 1579 | 1578 | return '404 Not Found'; |
| 1580 | 1579 | } |
| 1581 | 1580 | $path = ($is_location ? 'locations/' : 'resources/').$name; |
| 1582 | - while (substr($rest,-1) == '/') |
|
| 1581 | + while (substr($rest, -1) == '/') |
|
| 1583 | 1582 | { |
| 1584 | - $rest = substr($rest,0,-1); |
|
| 1583 | + $rest = substr($rest, 0, -1); |
|
| 1585 | 1584 | } |
| 1586 | - switch((string)$rest) |
|
| 1585 | + switch ((string)$rest) |
|
| 1587 | 1586 | { |
| 1588 | 1587 | case '': |
| 1589 | 1588 | $files[] = $this->add_principal_resource($resource); |
@@ -1622,12 +1621,12 @@ discard block |
||
| 1622 | 1621 | if ($options['depth']) |
| 1623 | 1622 | { |
| 1624 | 1623 | if (is_numeric($options['depth'])) --$options['depth']; |
| 1625 | - $files = array_merge($files, $this->propfind_users('','',$options), |
|
| 1626 | - $this->propfind_groups('','',$options)); |
|
| 1624 | + $files = array_merge($files, $this->propfind_users('', '', $options), |
|
| 1625 | + $this->propfind_groups('', '', $options)); |
|
| 1627 | 1626 | if ($GLOBALS['egw_info']['user']['apps']['resources']) |
| 1628 | 1627 | { |
| 1629 | - $files = array_merge($files, $this->propfind_resources('','',$options,false), // resources |
|
| 1630 | - $this->propfind_resources('','',$options,true)); // locations |
|
| 1628 | + $files = array_merge($files, $this->propfind_resources('', '', $options, false), // resources |
|
| 1629 | + $this->propfind_resources('', '', $options, true)); // locations |
|
| 1631 | 1630 | } |
| 1632 | 1631 | //$files = array_merge($files,$this->propfind_uids('','',$options)); |
| 1633 | 1632 | } |
@@ -1642,9 +1641,9 @@ discard block |
||
| 1642 | 1641 | * @param int $user =null account_id |
| 1643 | 1642 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
| 1644 | 1643 | */ |
| 1645 | - function get(&$options,$id,$user=null) |
|
| 1644 | + function get(&$options, $id, $user = null) |
|
| 1646 | 1645 | { |
| 1647 | - unset($options, $id, $user); // not used, but required by function signature |
|
| 1646 | + unset($options, $id, $user); // not used, but required by function signature |
|
| 1648 | 1647 | |
| 1649 | 1648 | return false; |
| 1650 | 1649 | } |
@@ -1657,9 +1656,9 @@ discard block |
||
| 1657 | 1656 | * @param int $user =null account_id of owner, default null |
| 1658 | 1657 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
| 1659 | 1658 | */ |
| 1660 | - function put(&$options,$id,$user=null) |
|
| 1659 | + function put(&$options, $id, $user = null) |
|
| 1661 | 1660 | { |
| 1662 | - unset($options, $id, $user); // not used, but required by function signature |
|
| 1661 | + unset($options, $id, $user); // not used, but required by function signature |
|
| 1663 | 1662 | |
| 1664 | 1663 | return false; |
| 1665 | 1664 | } |
@@ -1671,9 +1670,9 @@ discard block |
||
| 1671 | 1670 | * @param int $id |
| 1672 | 1671 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
| 1673 | 1672 | */ |
| 1674 | - function delete(&$options,$id) |
|
| 1673 | + function delete(&$options, $id) |
|
| 1675 | 1674 | { |
| 1676 | - unset($options, $id); // not used, but required by function signature |
|
| 1675 | + unset($options, $id); // not used, but required by function signature |
|
| 1677 | 1676 | |
| 1678 | 1677 | return false; |
| 1679 | 1678 | } |
@@ -1686,7 +1685,7 @@ discard block |
||
| 1686 | 1685 | */ |
| 1687 | 1686 | function read($id) |
| 1688 | 1687 | { |
| 1689 | - unset($id); // not used, but required by function signature |
|
| 1688 | + unset($id); // not used, but required by function signature |
|
| 1690 | 1689 | |
| 1691 | 1690 | return false; |
| 1692 | 1691 | } |
@@ -1698,13 +1697,13 @@ discard block |
||
| 1698 | 1697 | * @param array|int $entry entry-array or id |
| 1699 | 1698 | * @return boolean null if entry does not exist, false if no access, true if access permitted |
| 1700 | 1699 | */ |
| 1701 | - function check_access($acl,$entry) |
|
| 1700 | + function check_access($acl, $entry) |
|
| 1702 | 1701 | { |
| 1703 | 1702 | if ($acl != Api\Acl::READ) |
| 1704 | 1703 | { |
| 1705 | 1704 | return false; |
| 1706 | 1705 | } |
| 1707 | - if (!is_array($entry) && !$this->accounts->name2id($entry,'account_lid','u')) |
|
| 1706 | + if (!is_array($entry) && !$this->accounts->name2id($entry, 'account_lid', 'u')) |
|
| 1708 | 1707 | { |
| 1709 | 1708 | return null; |
| 1710 | 1709 | } |
@@ -1741,9 +1740,9 @@ discard block |
||
| 1741 | 1740 | * @param int $user =null owner of the collection, default current user |
| 1742 | 1741 | * @return array with privileges |
| 1743 | 1742 | */ |
| 1744 | - public function current_user_privileges($path, $user=null) |
|
| 1743 | + public function current_user_privileges($path, $user = null) |
|
| 1745 | 1744 | { |
| 1746 | - unset($path, $user); // not used, but required by function signature |
|
| 1745 | + unset($path, $user); // not used, but required by function signature |
|
| 1747 | 1746 | |
| 1748 | 1747 | return array('read', 'read-current-user-privilege-set'); |
| 1749 | 1748 | } |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | { |
| 87 | 87 | if (is_array($this->config_data)) |
| 88 | 88 | { |
| 89 | - foreach($this->config_data as $name => $value) |
|
| 89 | + foreach ($this->config_data as $name => $value) |
|
| 90 | 90 | { |
| 91 | 91 | self::save_value($name, $value, $this->appname, false); |
| 92 | 92 | } |
| 93 | - foreach(self::$configs[$this->appname] as $name => $value) |
|
| 93 | + foreach (self::$configs[$this->appname] as $name => $value) |
|
| 94 | 94 | { |
| 95 | 95 | if (!isset($this->config_data[$name])) // has been deleted |
| 96 | 96 | { |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if ($this->appname == 'phpgwapi' && method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 102 | + if ($this->appname == 'phpgwapi' && method_exists($GLOBALS['egw'], 'invalidate_session_cache')) // egw object in setup is limited |
|
| 103 | 103 | { |
| 104 | - $GLOBALS['egw']->invalidate_session_cache(); // in case egw_info is cached in the session (phpgwapi is in egw_info[server]) |
|
| 104 | + $GLOBALS['egw']->invalidate_session_cache(); // in case egw_info is cached in the session (phpgwapi is in egw_info[server]) |
|
| 105 | 105 | } |
| 106 | 106 | self::$configs[$this->appname] = $this->config_data; |
| 107 | 107 | |
@@ -122,13 +122,13 @@ discard block |
||
| 122 | 122 | * @throws Exception\WrongParameter if no $app parameter given for static call |
| 123 | 123 | * @return boolean|int true if no change, else number of affected rows |
| 124 | 124 | */ |
| 125 | - static function save_value($name, $value, $app, $update_cache=true) |
|
| 125 | + static function save_value($name, $value, $app, $update_cache = true) |
|
| 126 | 126 | { |
| 127 | - if (!$app && (!isset($this) || !is_a($this,__CLASS__))) |
|
| 127 | + if (!$app && (!isset($this) || !is_a($this, __CLASS__))) |
|
| 128 | 128 | { |
| 129 | 129 | throw new Exception\WrongParameter('$app parameter required for static call of Config::save_value($name,$value,$app)!'); |
| 130 | 130 | } |
| 131 | - if (!$app || isset($this) && is_a($this,__CLASS__) && $app == $this->appname) |
|
| 131 | + if (!$app || isset($this) && is_a($this, __CLASS__) && $app == $this->appname) |
|
| 132 | 132 | { |
| 133 | 133 | $app = $this->appname; |
| 134 | 134 | $this->config_data[$name] = $value; |
@@ -140,25 +140,25 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | if (isset(self::$configs[$app][$name]) && self::$configs[$app][$name] === $value) |
| 142 | 142 | { |
| 143 | - return True; // no change ==> exit |
|
| 143 | + return True; // no change ==> exit |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | if (!isset($value) || $value === '') |
| 147 | 147 | { |
| 148 | 148 | if (isset(self::$configs[$app])) unset(self::$configs[$app][$name]); |
| 149 | - self::$db->delete(self::TABLE,array('config_app'=>$app,'config_name'=>$name),__LINE__,__FILE__); |
|
| 149 | + self::$db->delete(self::TABLE, array('config_app'=>$app, 'config_name'=>$name), __LINE__, __FILE__); |
|
| 150 | 150 | } |
| 151 | 151 | else |
| 152 | 152 | { |
| 153 | 153 | self::$configs[$app][$name] = $value; |
| 154 | - if(is_array($value)) $value = json_encode($value); |
|
| 155 | - self::$db->insert(self::TABLE,array('config_value'=>$value),array('config_app'=>$app,'config_name'=>$name),__LINE__,__FILE__); |
|
| 154 | + if (is_array($value)) $value = json_encode($value); |
|
| 155 | + self::$db->insert(self::TABLE, array('config_value'=>$value), array('config_app'=>$app, 'config_name'=>$name), __LINE__, __FILE__); |
|
| 156 | 156 | } |
| 157 | 157 | if ($update_cache) |
| 158 | 158 | { |
| 159 | - if ($app == 'phpgwapi' && method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 159 | + if ($app == 'phpgwapi' && method_exists($GLOBALS['egw'], 'invalidate_session_cache')) // egw object in setup is limited |
|
| 160 | 160 | { |
| 161 | - $GLOBALS['egw']->invalidate_session_cache(); // in case egw_info is cached in the session (phpgwapi is in egw_info[server]) |
|
| 161 | + $GLOBALS['egw']->invalidate_session_cache(); // in case egw_info is cached in the session (phpgwapi is in egw_info[server]) |
|
| 162 | 162 | } |
| 163 | 163 | Cache::setInstance(__CLASS__, 'configs', self::$configs); |
| 164 | 164 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | { |
| 176 | 176 | self::init_static(); |
| 177 | 177 | } |
| 178 | - self::$db->delete(self::TABLE,array('config_app' => $this->appname),__LINE__,__FILE__); |
|
| 178 | + self::$db->delete(self::TABLE, array('config_app' => $this->appname), __LINE__, __FILE__); |
|
| 179 | 179 | |
| 180 | 180 | unset(self::$configs[$this->appname]); |
| 181 | 181 | Cache::setInstance(__CLASS__, 'configs', self::$configs); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @param $variable_name string name of the config |
| 198 | 198 | * @param $variable_data mixed the content |
| 199 | 199 | */ |
| 200 | - function value($variable_name,$variable_data) |
|
| 200 | + function value($variable_name, $variable_data) |
|
| 201 | 201 | { |
| 202 | 202 | $this->config_data[$variable_name] = $variable_data; |
| 203 | 203 | } |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * @deprecated use Api\Storage\Customfields::get() |
| 229 | 229 | * @return array with customfields |
| 230 | 230 | */ |
| 231 | - static function get_customfields($app, $all_private_too=false, $only_type2=null) |
|
| 231 | + static function get_customfields($app, $all_private_too = false, $only_type2 = null) |
|
| 232 | 232 | { |
| 233 | 233 | //error_log(__METHOD__."('$app', $all_private_too, $only_type2) deprecated, use Storage\Customfields::get() in ". function_backtrace()); |
| 234 | 234 | return Storage\Customfields::get($app, $all_private_too, $only_type2); |
@@ -258,12 +258,12 @@ discard block |
||
| 258 | 258 | { |
| 259 | 259 | static $white_list = array( |
| 260 | 260 | 'all' => array('customfields', 'types'), |
| 261 | - 'phpgwapi' => array('webserver_url','server_timezone','enforce_ssl','system_charset', |
|
| 262 | - 'checkfornewversion','checkappversions','email_address_format', // admin >> site config |
|
| 263 | - 'site_title','login_logo_file','login_logo_url','login_logo_title','favicon_file', |
|
| 264 | - 'markuntranslated','link_list_thumbnail','enabled_spellcheck','debug_minify', |
|
| 265 | - 'call_link','call_popup','geolocation_url', // addressbook |
|
| 266 | - 'hide_birthdays','calview_no_consolidate', 'egw_tutorial_disable','fw_mobile_app_list'), // calendar |
|
| 261 | + 'phpgwapi' => array('webserver_url', 'server_timezone', 'enforce_ssl', 'system_charset', |
|
| 262 | + 'checkfornewversion', 'checkappversions', 'email_address_format', // admin >> site config |
|
| 263 | + 'site_title', 'login_logo_file', 'login_logo_url', 'login_logo_title', 'favicon_file', |
|
| 264 | + 'markuntranslated', 'link_list_thumbnail', 'enabled_spellcheck', 'debug_minify', |
|
| 265 | + 'call_link', 'call_popup', 'geolocation_url', // addressbook |
|
| 266 | + 'hide_birthdays', 'calview_no_consolidate', 'egw_tutorial_disable', 'fw_mobile_app_list'), // calendar |
|
| 267 | 267 | 'projectmanager' => array('hours_per_workday', 'duration_units'), |
| 268 | 268 | 'manual' => array('manual_remote_egw_url'), |
| 269 | 269 | 'infolog' => array('status'), |
@@ -274,9 +274,9 @@ discard block |
||
| 274 | 274 | self::init_static(); |
| 275 | 275 | } |
| 276 | 276 | $client_config = array(); |
| 277 | - foreach(self::$configs as $app => $config) |
|
| 277 | + foreach (self::$configs as $app => $config) |
|
| 278 | 278 | { |
| 279 | - foreach($config as $name => $value) |
|
| 279 | + foreach ($config as $name => $value) |
|
| 280 | 280 | { |
| 281 | 281 | if (strpos($name, 'pass') !== false) continue; |
| 282 | 282 | |
@@ -314,12 +314,12 @@ discard block |
||
| 314 | 314 | } |
| 315 | 315 | // handling of old PHP serialized config values |
| 316 | 316 | $data = php_safe_unserialize($str); |
| 317 | - if($data === false) |
|
| 317 | + if ($data === false) |
|
| 318 | 318 | { |
| 319 | 319 | // manually retrieve the string lengths of the serialized array if unserialize failed (iso / utf-8 conversation) |
| 320 | 320 | $data = php_safe_unserialize(preg_replace_callback('!s:(\d+):"(.*?)";!s', function($matches) |
| 321 | 321 | { |
| 322 | - return 's:'.mb_strlen($matches[2],'8bit').':"'.$matches[2].'";'; |
|
| 322 | + return 's:'.mb_strlen($matches[2], '8bit').':"'.$matches[2].'";'; |
|
| 323 | 323 | }, $str)); |
| 324 | 324 | } |
| 325 | 325 | // returning original string, if unserialize failed, eg. for "a:hello" |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | if (!(self::$configs = Cache::getInstance(__CLASS__, 'configs')) || !is_array(self::$configs['phpgwapi'])) |
| 345 | 345 | { |
| 346 | 346 | self::$configs = array(); |
| 347 | - foreach(self::$db->select(self::TABLE,'*',false,__LINE__,__FILE__) as $row) |
|
| 347 | + foreach (self::$db->select(self::TABLE, '*', false, __LINE__, __FILE__) as $row) |
|
| 348 | 348 | { |
| 349 | 349 | self::$configs[$row['config_app']][$row['config_name']] = self::unserialize($row['config_value']); |
| 350 | 350 | //error_log(__METHOD__."() configs[$row[config_app]][$row[config_name]]=".array2string(self::$configs[$row['config_app']][$row['config_name']])); |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | $this->db = $GLOBALS['egw_setup']->db; |
| 51 | 51 | } |
| 52 | - $this->cronline = EGW_SERVER_ROOT . '/api/asyncservices.php '.$GLOBALS['egw_info']['user']['domain']; |
|
| 52 | + $this->cronline = EGW_SERVER_ROOT.'/api/asyncservices.php '.$GLOBALS['egw_info']['user']['domain']; |
|
| 53 | 53 | |
| 54 | - $this->only_fallback = substr(php_uname(), 0, 7) == "Windows"; // atm cron-jobs dont work on win |
|
| 54 | + $this->only_fallback = substr(php_uname(), 0, 7) == "Windows"; // atm cron-jobs dont work on win |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | * @param boolean $debug =false |
| 72 | 72 | * @return boolean False if $id already exists, else True |
| 73 | 73 | */ |
| 74 | - function set_timer($times,$id,$method,$data=null,$account_id=False,$debug=false) |
|
| 74 | + function set_timer($times, $id, $method, $data = null, $account_id = False, $debug = false) |
|
| 75 | 75 | { |
| 76 | 76 | if (empty($id) || empty($method) || $this->read($id) || |
| 77 | - !($next = $this->next_run($times,$debug))) |
|
| 77 | + !($next = $this->next_run($times, $debug))) |
|
| 78 | 78 | { |
| 79 | 79 | return False; |
| 80 | 80 | } |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | * @param int $now Use this time to calculate then next run from. Defaults to time(). |
| 108 | 108 | * @return int a unix timestamp of the next execution time or False if no more executions |
| 109 | 109 | */ |
| 110 | - function next_run($times,$debug=False, $now = null) |
|
| 110 | + function next_run($times, $debug = False, $now = null) |
|
| 111 | 111 | { |
| 112 | 112 | if ($this->debug) |
| 113 | 113 | { |
| 114 | - echo "<p>next_run("; print_r($times); echo ",'$debug', " . date('Y-m-d H:i', $now) . ")</p>\n"; |
|
| 115 | - $debug = True; // enable syntax-error messages too |
|
| 114 | + echo "<p>next_run("; print_r($times); echo ",'$debug', ".date('Y-m-d H:i', $now).")</p>\n"; |
|
| 115 | + $debug = True; // enable syntax-error messages too |
|
| 116 | 116 | } |
| 117 | - if(is_null($now)) { |
|
| 117 | + if (is_null($now)) { |
|
| 118 | 118 | $now = time(); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | 'dow' => 6, |
| 143 | 143 | 'day' => 31, |
| 144 | 144 | 'month' => 12, |
| 145 | - 'year' => date('Y')+10 // else */[0-9] would never stop returning numbers |
|
| 145 | + 'year' => date('Y') + 10 // else */[0-9] would never stop returning numbers |
|
| 146 | 146 | ); |
| 147 | 147 | $min_unit = array( |
| 148 | 148 | 'min' => 0, |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | // get set to the minimum after |
| 159 | 159 | // |
| 160 | 160 | $i = $first_set = $last_set = 0; |
| 161 | - foreach($units as $u => $date_pattern) |
|
| 161 | + foreach ($units as $u => $date_pattern) |
|
| 162 | 162 | { |
| 163 | 163 | ++$i; |
| 164 | 164 | if (isset($times[$u])) |
@@ -176,24 +176,24 @@ discard block |
||
| 176 | 176 | // (as descript above), enumerations are arrays with unit-values as keys |
| 177 | 177 | // |
| 178 | 178 | $n = 0; |
| 179 | - foreach($units as $u => $date_pattern) |
|
| 179 | + foreach ($units as $u => $date_pattern) |
|
| 180 | 180 | { |
| 181 | 181 | ++$n; |
| 182 | - if ($this->debug) { echo "<p>n=$n, $u: isset(times[$u]="; print_r($times[$u]); echo ")=".(isset($times[$u])?'True':'False')."</p>\n"; } |
|
| 182 | + if ($this->debug) { echo "<p>n=$n, $u: isset(times[$u]="; print_r($times[$u]); echo ")=".(isset($times[$u]) ? 'True' : 'False')."</p>\n"; } |
|
| 183 | 183 | if (isset($times[$u])) |
| 184 | 184 | { |
| 185 | - if(is_array($times[$u])) { |
|
| 185 | + if (is_array($times[$u])) { |
|
| 186 | 186 | $time = array_keys($times[$u]); |
| 187 | 187 | } else { |
| 188 | - $time = explode(',',$times[$u]); |
|
| 188 | + $time = explode(',', $times[$u]); |
|
| 189 | 189 | } |
| 190 | 190 | $times[$u] = array(); |
| 191 | 191 | |
| 192 | - foreach($time as $t) |
|
| 192 | + foreach ($time as $t) |
|
| 193 | 193 | { |
| 194 | - if (strpos($t,'-') !== False && strpos($t,'/') === False) |
|
| 194 | + if (strpos($t, '-') !== False && strpos($t, '/') === False) |
|
| 195 | 195 | { |
| 196 | - list($min,$max) = $arr = explode('-',$t); |
|
| 196 | + list($min, $max) = $arr = explode('-', $t); |
|
| 197 | 197 | |
| 198 | 198 | if (count($arr) != 2 || !is_numeric($min) || !is_numeric($max) || $min > $max) |
| 199 | 199 | { |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | { |
| 211 | 211 | if ((string)$t == '*') $t = '*/1'; |
| 212 | 212 | |
| 213 | - list($one,$inc) = $arr = explode('/',$t); |
|
| 213 | + list($one, $inc) = $arr = explode('/', $t); |
|
| 214 | 214 | |
| 215 | 215 | if (!(is_numeric($one) && count($arr) == 1 || |
| 216 | 216 | count($arr) == 2 && is_numeric($inc))) |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | else |
| 227 | 227 | { |
| 228 | - list($min,$max) = $arr = explode('-',$one); |
|
| 228 | + list($min, $max) = $arr = explode('-', $one); |
|
| 229 | 229 | if (empty($one) || $one == '*') |
| 230 | 230 | { |
| 231 | 231 | $min = $min_unit[$u]; |
@@ -266,20 +266,19 @@ discard block |
||
| 266 | 266 | { |
| 267 | 267 | $future = False; |
| 268 | 268 | |
| 269 | - foreach($units as $u => $date_pattern) |
|
| 269 | + foreach ($units as $u => $date_pattern) |
|
| 270 | 270 | { |
| 271 | - $unit_now = $u != 'dow' ? (int)date($date_pattern, $now) : |
|
| 272 | - (int)date($date_pattern,mktime(12,0,0,$found['month'],$found['day'],$found['year'])); |
|
| 271 | + $unit_now = $u != 'dow' ? (int)date($date_pattern, $now) : (int)date($date_pattern, mktime(12, 0, 0, $found['month'], $found['day'], $found['year'])); |
|
| 273 | 272 | |
| 274 | 273 | if (isset($found[$u])) |
| 275 | 274 | { |
| 276 | 275 | $future = $future || $found[$u] > $unit_now; |
| 277 | 276 | if ($this->debug) echo "--> already have a $u = ".$found[$u].", future='$future'<br>\n"; |
| 278 | - continue; // already set |
|
| 277 | + continue; // already set |
|
| 279 | 278 | } |
| 280 | - foreach(array_keys($times[$u]) as $unit_value) |
|
| 279 | + foreach (array_keys($times[$u]) as $unit_value) |
|
| 281 | 280 | { |
| 282 | - switch($u) |
|
| 281 | + switch ($u) |
|
| 283 | 282 | { |
| 284 | 283 | case 'dow': |
| 285 | 284 | $valid = $unit_value == $unit_now; |
@@ -302,12 +301,12 @@ discard block |
||
| 302 | 301 | if (!isset($found[$u])) // we have to try the next one, if it exists |
| 303 | 302 | { |
| 304 | 303 | $nexts = array_keys($units); |
| 305 | - if (!isset($nexts[count($found)-1])) |
|
| 304 | + if (!isset($nexts[count($found) - 1])) |
|
| 306 | 305 | { |
| 307 | 306 | if ($this->debug) echo "<p>Nothing found, exiting !!!</p>\n"; |
| 308 | 307 | return False; |
| 309 | 308 | } |
| 310 | - $next = $nexts[count($found)-1]; |
|
| 309 | + $next = $nexts[count($found) - 1]; |
|
| 311 | 310 | $over = $found[$next]; |
| 312 | 311 | unset($found[$next]); |
| 313 | 312 | if ($this->debug) echo "<p>Have to try the next $next, $u's are over for $next=$over !!!</p>\n"; |
@@ -317,7 +316,7 @@ discard block |
||
| 317 | 316 | } |
| 318 | 317 | if ($this->debug) { echo "<p>next="; print_r($found); echo "</p>\n"; } |
| 319 | 318 | |
| 320 | - return mktime($found['hour'],$found['min'],0,$found['month'],$found['day'],$found['year']); |
|
| 319 | + return mktime($found['hour'], $found['min'], 0, $found['month'], $found['day'], $found['year']); |
|
| 321 | 320 | } |
| 322 | 321 | |
| 323 | 322 | /** |
@@ -339,7 +338,7 @@ discard block |
||
| 339 | 338 | * @return mixed if !$set array('start' => $start,'end' => $end) with timestamps of last check_run start and end, \ |
| 340 | 339 | * !$end means check_run is just running. If $set returns True if it was able to get the semaphore, else False |
| 341 | 340 | */ |
| 342 | - function last_check_run($semaphore=False,$release=False,$run_by='') |
|
| 341 | + function last_check_run($semaphore = False, $release = False, $run_by = '') |
|
| 343 | 342 | { |
| 344 | 343 | //echo "<p>last_check_run(semaphore=".($semaphore?'True':'False').",release=".($release?'True':'False').")</p>\n"; |
| 345 | 344 | if (($exists = $this->read('##last-check-run##'))) |
@@ -361,7 +360,7 @@ discard block |
||
| 361 | 360 | } |
| 362 | 361 | else |
| 363 | 362 | { |
| 364 | - @set_time_limit(0); // dont stop for an execution-time-limit |
|
| 363 | + @set_time_limit(0); // dont stop for an execution-time-limit |
|
| 365 | 364 | ignore_user_abort(True); |
| 366 | 365 | |
| 367 | 366 | $last_run = array( |
@@ -377,7 +376,7 @@ discard block |
||
| 377 | 376 | ); |
| 378 | 377 | // as the async_next column is used as a semaphore we only update it, |
| 379 | 378 | // if it is 0 (semaphore released) or older then 10min to recover from failed or crashed attempts |
| 380 | - if ($exists) $where = array('async_next=0 OR async_next<'.(time()-600)); |
|
| 379 | + if ($exists) $where = array('async_next=0 OR async_next<'.(time() - 600)); |
|
| 381 | 380 | } |
| 382 | 381 | //echo "last_run=<pre>"; print_r($last_run); echo "</pre>\n"; |
| 383 | 382 | return $this->write($last_run, !!$exists, $where) > 0; |
@@ -386,20 +385,20 @@ discard block |
||
| 386 | 385 | /** |
| 387 | 386 | * checks if there are any jobs ready to run (timer expired) and executes them |
| 388 | 387 | */ |
| 389 | - function check_run($run_by='') |
|
| 388 | + function check_run($run_by = '') |
|
| 390 | 389 | { |
| 391 | 390 | if ($run_by === 'fallback') flush(); |
| 392 | 391 | |
| 393 | - if (!$this->last_check_run(True,False,$run_by)) |
|
| 392 | + if (!$this->last_check_run(True, False, $run_by)) |
|
| 394 | 393 | { |
| 395 | - return False; // cant obtain semaphore |
|
| 394 | + return False; // cant obtain semaphore |
|
| 396 | 395 | } |
| 397 | 396 | // mark enviroment as async-service, check with isset()! |
| 398 | 397 | $GLOBALS['egw_info']['flags']['async-service'] = $run_by; |
| 399 | 398 | |
| 400 | 399 | if (($jobs = $this->read())) |
| 401 | 400 | { |
| 402 | - foreach($jobs as $job) |
|
| 401 | + foreach ($jobs as $job) |
|
| 403 | 402 | { |
| 404 | 403 | // checking / setting up egw_info/user |
| 405 | 404 | // |
@@ -408,7 +407,7 @@ discard block |
||
| 408 | 407 | // run notifications, before changing account_id of enviroment |
| 409 | 408 | Link::run_notifies(); |
| 410 | 409 | // unset all objects in $GLOBALS, which are created and used by ExecMethod, as they can contain user-data |
| 411 | - foreach($GLOBALS as $name => $value) |
|
| 410 | + foreach ($GLOBALS as $name => $value) |
|
| 412 | 411 | { |
| 413 | 412 | if ($name !== 'egw' && is_object($value)) unset($GLOBALS[$name]); |
| 414 | 413 | } |
@@ -420,7 +419,7 @@ discard block |
||
| 420 | 419 | { |
| 421 | 420 | $GLOBALS['egw']->session->account_lid = $GLOBALS['egw']->accounts->id2name($job['account_id']); |
| 422 | 421 | $GLOBALS['egw']->session->account_domain = $domain; |
| 423 | - $GLOBALS['egw_info']['user'] = $GLOBALS['egw']->session->read_repositories(); |
|
| 422 | + $GLOBALS['egw_info']['user'] = $GLOBALS['egw']->session->read_repositories(); |
|
| 424 | 423 | |
| 425 | 424 | if ($lang != $GLOBALS['egw_info']['user']['preferences']['common']['lang']) |
| 426 | 425 | { |
@@ -435,12 +434,11 @@ discard block |
||
| 435 | 434 | $GLOBALS['egw_info']['user']['domain'] = $domain; |
| 436 | 435 | } |
| 437 | 436 | } |
| 438 | - list($app) = strpos($job['method'],'::') !== false ? explode('_',$job['method']) : |
|
| 439 | - explode('.',$job['method']); |
|
| 437 | + list($app) = strpos($job['method'], '::') !== false ? explode('_', $job['method']) : explode('.', $job['method']); |
|
| 440 | 438 | Translation::add_app($app); |
| 441 | 439 | if (is_array($job['data'])) |
| 442 | 440 | { |
| 443 | - $job['data'] += array_diff_key($job,array('data' => false)); |
|
| 441 | + $job['data'] += array_diff_key($job, array('data' => false)); |
|
| 444 | 442 | } |
| 445 | 443 | // update job before running it, to cope with jobs taking longer then async-frequency |
| 446 | 444 | if (($job['next'] = $this->next_run($job['times']))) |
@@ -453,16 +451,16 @@ discard block |
||
| 453 | 451 | } |
| 454 | 452 | try |
| 455 | 453 | { |
| 456 | - ExecMethod($job['method'],$job['data']); |
|
| 454 | + ExecMethod($job['method'], $job['data']); |
|
| 457 | 455 | } |
| 458 | - catch(Exception $e) |
|
| 456 | + catch (Exception $e) |
|
| 459 | 457 | { |
| 460 | 458 | // log the exception to error_log, but continue running other async jobs |
| 461 | 459 | _egw_log_exception($e); |
| 462 | 460 | } |
| 463 | 461 | } |
| 464 | 462 | } |
| 465 | - $this->last_check_run(True,True,$run_by); // release semaphore |
|
| 463 | + $this->last_check_run(True, True, $run_by); // release semaphore |
|
| 466 | 464 | |
| 467 | 465 | return $jobs ? count($jobs) : 0; |
| 468 | 466 | } |
@@ -478,7 +476,7 @@ discard block |
||
| 478 | 476 | * @param int $num_rows =0 number of rows to return if offset set, default 0 = use default in user prefs |
| 479 | 477 | * @return array/boolean db-rows / jobs as array or False if no matches |
| 480 | 478 | */ |
| 481 | - function read($id=0,$cols='*',$offset=False,$append='ORDER BY async_next',$num_rows=0) |
|
| 479 | + function read($id = 0, $cols = '*', $offset = False, $append = 'ORDER BY async_next', $num_rows = 0) |
|
| 482 | 480 | { |
| 483 | 481 | if (!is_a($this->db, 'EGroupware\\Api\\Db')) return false; |
| 484 | 482 | |
@@ -486,7 +484,7 @@ discard block |
||
| 486 | 484 | { |
| 487 | 485 | $where = "async_id != '##last-check-run##'"; |
| 488 | 486 | } |
| 489 | - elseif (!is_array($id) && (strpos($id,'%') !== False || strpos($id,'_') !== False)) |
|
| 487 | + elseif (!is_array($id) && (strpos($id, '%') !== False || strpos($id, '_') !== False)) |
|
| 490 | 488 | { |
| 491 | 489 | $id = $this->db->quote($id); |
| 492 | 490 | $where = "async_id LIKE $id AND async_id != '##last-check-run##'"; |
@@ -500,21 +498,21 @@ discard block |
||
| 500 | 498 | $where = array('async_id' => $id); |
| 501 | 499 | } |
| 502 | 500 | $jobs = array(); |
| 503 | - foreach($this->db->select($this->db_table,$cols,$where,__LINE__,__FILE__,$offset,$append,False,$num_rows) as $row) |
|
| 501 | + foreach ($this->db->select($this->db_table, $cols, $where, __LINE__, __FILE__, $offset, $append, False, $num_rows) as $row) |
|
| 504 | 502 | { |
| 505 | 503 | $row['async_times'] = json_php_unserialize($row['async_times']); |
| 506 | 504 | // check for broken value during migration |
| 507 | 505 | if ($row['async_data'][0] == '"' && substr($row['async_data'], 0, 7) == '"\\"\\\\\\"') |
| 508 | 506 | { |
| 509 | 507 | $row['async_data'] = null; |
| 510 | - $this->write(Db::strip_array_keys($row,'async_'), true); |
|
| 508 | + $this->write(Db::strip_array_keys($row, 'async_'), true); |
|
| 511 | 509 | } |
| 512 | 510 | else |
| 513 | 511 | { |
| 514 | 512 | $row['async_data'] = !empty($row['async_data']) ? |
| 515 | - json_php_unserialize($row['async_data'], true) : null; // allow non-serialized data |
|
| 513 | + json_php_unserialize($row['async_data'], true) : null; // allow non-serialized data |
|
| 516 | 514 | } |
| 517 | - $jobs[$row['async_id']] = Db::strip_array_keys($row,'async_'); |
|
| 515 | + $jobs[$row['async_id']] = Db::strip_array_keys($row, 'async_'); |
|
| 518 | 516 | } |
| 519 | 517 | if (!count($jobs)) |
| 520 | 518 | { |
@@ -531,7 +529,7 @@ discard block |
||
| 531 | 529 | * @param array $where additional where statemetn to update only if a certain condition is met, used for the semaphore |
| 532 | 530 | * @return int affected rows, can be 0 if an additional where statement is given |
| 533 | 531 | */ |
| 534 | - function write($job, $exists = False, $where=array()) |
|
| 532 | + function write($job, $exists = False, $where = array()) |
|
| 535 | 533 | { |
| 536 | 534 | if (!is_a($this->db, 'EGroupware\\Api\\Db')) return 0; |
| 537 | 535 | |
@@ -562,7 +560,7 @@ discard block |
||
| 562 | 560 | */ |
| 563 | 561 | function delete($id) |
| 564 | 562 | { |
| 565 | - $this->db->delete($this->db_table,array('async_id' => $id),__LINE__,__FILE__); |
|
| 563 | + $this->db->delete($this->db_table, array('async_id' => $id), __LINE__, __FILE__); |
|
| 566 | 564 | |
| 567 | 565 | return $this->db->affected_rows(); |
| 568 | 566 | } |
@@ -587,38 +585,38 @@ discard block |
||
| 587 | 585 | { |
| 588 | 586 | $binarys = array( |
| 589 | 587 | 'php' => '/usr/bin/php', |
| 590 | - 'php5' => '/usr/bin/php5', // SuSE 9.3 with php5 |
|
| 588 | + 'php5' => '/usr/bin/php5', // SuSE 9.3 with php5 |
|
| 591 | 589 | 'crontab' => '/usr/bin/crontab' |
| 592 | 590 | ); |
| 593 | 591 | foreach ($binarys as $name => $path) |
| 594 | 592 | { |
| 595 | - $this->$name = $path; // a reasonable default for *nix |
|
| 593 | + $this->$name = $path; // a reasonable default for *nix |
|
| 596 | 594 | |
| 597 | 595 | if (!($Ok = @is_executable($this->$name))) |
| 598 | 596 | { |
| 599 | 597 | if (file_exists($this->$name)) |
| 600 | 598 | { |
| 601 | - echo '<p>'.lang('%1 is not executable by the webserver !!!',$this->$name)."</p>\n"; |
|
| 599 | + echo '<p>'.lang('%1 is not executable by the webserver !!!', $this->$name)."</p>\n"; |
|
| 602 | 600 | $perms = fileperms($this->$name); |
| 603 | - if (!($perms & 0x0001) && ($perms & 0x0008) && function_exists('posix_getuid')) // only executable by group |
|
| 601 | + if (!($perms&0x0001) && ($perms&0x0008) && function_exists('posix_getuid')) // only executable by group |
|
| 604 | 602 | { |
| 605 | 603 | $group = posix_getgrgid(filegroup($this->$name)); |
| 606 | - $webserver = posix_getpwuid(posix_getuid ()); |
|
| 607 | - echo '<p>'.lang("You need to add the webserver user '%1' to the group '%2'.",$webserver['name'],$group['name'])."</p>\n"; } |
|
| 604 | + $webserver = posix_getpwuid(posix_getuid()); |
|
| 605 | + echo '<p>'.lang("You need to add the webserver user '%1' to the group '%2'.", $webserver['name'], $group['name'])."</p>\n"; } |
|
| 608 | 606 | } |
| 609 | - if (($fd = popen('/bin/sh -c "type -p '.$name.'"','r'))) |
|
| 607 | + if (($fd = popen('/bin/sh -c "type -p '.$name.'"', 'r'))) |
|
| 610 | 608 | { |
| 611 | - $this->$name = fgets($fd,256); |
|
| 609 | + $this->$name = fgets($fd, 256); |
|
| 612 | 610 | @pclose($fd); |
| 613 | 611 | } |
| 614 | - if (($pos = strpos($this->$name,"\n"))) |
|
| 612 | + if (($pos = strpos($this->$name, "\n"))) |
|
| 615 | 613 | { |
| 616 | - $this->$name = substr($this->$name,0,$pos); |
|
| 614 | + $this->$name = substr($this->$name, 0, $pos); |
|
| 617 | 615 | } |
| 618 | 616 | } |
| 619 | 617 | if (!$Ok && !@is_executable($this->$name)) |
| 620 | 618 | { |
| 621 | - $this->$name = $name; // hopefully its in the path |
|
| 619 | + $this->$name = $name; // hopefully its in the path |
|
| 622 | 620 | } |
| 623 | 621 | //echo "<p>$name = '".$this->$name."'</p>\n"; |
| 624 | 622 | } |
@@ -649,15 +647,15 @@ discard block |
||
| 649 | 647 | } |
| 650 | 648 | $times = False; |
| 651 | 649 | $this->other_cronlines = array(); |
| 652 | - if (($crontab = popen('/bin/sh -c "'.$this->crontab.' -l" 2>&1','r')) !== False) |
|
| 650 | + if (($crontab = popen('/bin/sh -c "'.$this->crontab.' -l" 2>&1', 'r')) !== False) |
|
| 653 | 651 | { |
| 654 | 652 | $n = 0; |
| 655 | - while ($line = fgets($crontab,256)) |
|
| 653 | + while ($line = fgets($crontab, 256)) |
|
| 656 | 654 | { |
| 657 | 655 | if ($this->debug) echo 'line '.++$n.": $line<br>\n"; |
| 658 | - $parts = explode(' ',$line,6); |
|
| 656 | + $parts = explode(' ', $line, 6); |
|
| 659 | 657 | |
| 660 | - if ($line{0} == '#' || count($parts) < 6 || ($parts[5]{0} != '/' && substr($parts[5],0,3) != 'php')) |
|
| 658 | + if ($line{0} == '#' || count($parts) < 6 || ($parts[5]{0} != '/' && substr($parts[5], 0, 3) != 'php')) |
|
| 661 | 659 | { |
| 662 | 660 | // ignore comments |
| 663 | 661 | if ($line{0} != '#') |
@@ -665,12 +663,12 @@ discard block |
||
| 665 | 663 | $times['error'] .= $line; |
| 666 | 664 | } |
| 667 | 665 | } |
| 668 | - elseif (strpos($line,$this->cronline) !== False || |
|
| 666 | + elseif (strpos($line, $this->cronline) !== False || |
|
| 669 | 667 | // also check of old phpgwapi/cron path |
| 670 | 668 | strpos($line, str_replace('/api/', '/phpgwapi/cron/', $this->cronline)) !== False) |
| 671 | 669 | { |
| 672 | - $cron_units = array('min','hour','day','month','dow'); |
|
| 673 | - foreach($cron_units as $n => $u) |
|
| 670 | + $cron_units = array('min', 'hour', 'day', 'month', 'dow'); |
|
| 671 | + foreach ($cron_units as $n => $u) |
|
| 674 | 672 | { |
| 675 | 673 | $times[$u] = $parts[$n]; |
| 676 | 674 | } |
@@ -701,29 +699,29 @@ discard block |
||
| 701 | 699 | if ($this->only_fallback && $times !== False) { |
| 702 | 700 | return 0; |
| 703 | 701 | } |
| 704 | - $this->installed(); // find other installed cronlines |
|
| 702 | + $this->installed(); // find other installed cronlines |
|
| 705 | 703 | |
| 706 | - if (($crontab = popen('/bin/sh -c "'.$this->crontab.' -" 2>&1','w')) !== False) |
|
| 704 | + if (($crontab = popen('/bin/sh -c "'.$this->crontab.' -" 2>&1', 'w')) !== False) |
|
| 707 | 705 | { |
| 708 | 706 | if (is_array($this->other_cronlines)) |
| 709 | 707 | { |
| 710 | 708 | foreach ($this->other_cronlines as $cronline) |
| 711 | 709 | { |
| 712 | - fwrite($crontab,$cronline); // preserv the other lines on install |
|
| 710 | + fwrite($crontab, $cronline); // preserv the other lines on install |
|
| 713 | 711 | } |
| 714 | 712 | } |
| 715 | 713 | if ($times !== False) |
| 716 | 714 | { |
| 717 | - $cron_units = array('min','hour','day','month','dow'); |
|
| 715 | + $cron_units = array('min', 'hour', 'day', 'month', 'dow'); |
|
| 718 | 716 | $cronline = ''; |
| 719 | - foreach($cron_units as $cu) |
|
| 717 | + foreach ($cron_units as $cu) |
|
| 720 | 718 | { |
| 721 | - $cronline .= (isset($times[$cu]) ? $times[$cu] : '*') . ' '; |
|
| 719 | + $cronline .= (isset($times[$cu]) ? $times[$cu] : '*').' '; |
|
| 722 | 720 | } |
| 723 | 721 | // -d memory_limit=-1 --> no memory limit |
| 724 | 722 | $cronline .= $this->php.' -q -d memory_limit=-1 '.$this->cronline."\n"; |
| 725 | 723 | //echo "<p>Installing: '$cronline'</p>\n"; |
| 726 | - fwrite($crontab,$cronline); |
|
| 724 | + fwrite($crontab, $cronline); |
|
| 727 | 725 | } |
| 728 | 726 | @pclose($crontab); |
| 729 | 727 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param int $lastmod =0 timestamp of last modification (defaults to now=time()) |
| 60 | 60 | * @return int/boolean False (for db or param-error) or on success link_id (Please not the return-value of $id1) |
| 61 | 61 | */ |
| 62 | - static function link( $app1,&$id1,$app2,$id2='',$remark='',$owner=0,$lastmod=0 ) |
|
| 62 | + static function link($app1, &$id1, $app2, $id2 = '', $remark = '', $owner = 0, $lastmod = 0) |
|
| 63 | 63 | { |
| 64 | 64 | if (self::DEBUG) |
| 65 | 65 | { |
@@ -68,21 +68,21 @@ discard block |
||
| 68 | 68 | if ($app1 == $app2 && $id1 == $id2 || |
| 69 | 69 | $id1 == '' || $id2 == '' || $app1 == '' || $app2 == '') |
| 70 | 70 | { |
| 71 | - return False; // dont link to self or other nosense |
|
| 71 | + return False; // dont link to self or other nosense |
|
| 72 | 72 | } |
| 73 | - if (($link = self::get_link($app1,$id1,$app2,$id2))) |
|
| 73 | + if (($link = self::get_link($app1, $id1, $app2, $id2))) |
|
| 74 | 74 | { |
| 75 | 75 | if ($link['link_remark'] != $remark) |
| 76 | 76 | { |
| 77 | - self::update_remark($link['link_id'],$remark); |
|
| 77 | + self::update_remark($link['link_id'], $remark); |
|
| 78 | 78 | } |
| 79 | - return $link['link_id']; // link alread exist |
|
| 79 | + return $link['link_id']; // link alread exist |
|
| 80 | 80 | } |
| 81 | 81 | if (!$owner) |
| 82 | 82 | { |
| 83 | 83 | $owner = $GLOBALS['egw_info']['user']['account_id']; |
| 84 | 84 | } |
| 85 | - return self::$db->insert(self::TABLE,array( |
|
| 85 | + return self::$db->insert(self::TABLE, array( |
|
| 86 | 86 | 'link_app1' => $app1, |
| 87 | 87 | 'link_id1' => $id1, |
| 88 | 88 | 'link_app2' => $app2, |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | 'link_remark' => $remark, |
| 91 | 91 | 'link_lastmod' => $lastmod ? $lastmod : time(), |
| 92 | 92 | 'link_owner' => $owner, |
| 93 | - ),False,__LINE__,__FILE__) ? self::$db->get_last_insert_id(self::TABLE,'link_id') : false; |
|
| 93 | + ), False, __LINE__, __FILE__) ? self::$db->get_last_insert_id(self::TABLE, 'link_id') : false; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -100,14 +100,14 @@ discard block |
||
| 100 | 100 | * @param string $remark new text for the remark |
| 101 | 101 | * @return boolean true on success, else false |
| 102 | 102 | */ |
| 103 | - static function update_remark($link_id,$remark) |
|
| 103 | + static function update_remark($link_id, $remark) |
|
| 104 | 104 | { |
| 105 | - return self::$db->update(self::TABLE,array( |
|
| 105 | + return self::$db->update(self::TABLE, array( |
|
| 106 | 106 | 'link_remark' => $remark, |
| 107 | 107 | 'link_lastmod' => time(), |
| 108 | - ),array( |
|
| 108 | + ), array( |
|
| 109 | 109 | 'link_id' => $link_id, |
| 110 | - ),__LINE__,__FILE__); |
|
| 110 | + ), __LINE__, __FILE__); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -121,15 +121,15 @@ discard block |
||
| 121 | 121 | * @param int|array $limit =null number of entries to return, default null = all or array(offset, num_rows) to return num_rows starting from offset |
| 122 | 122 | * @return array id => links pairs if $id is an array or just the links (only_app: ids) or empty array if no matching links found |
| 123 | 123 | */ |
| 124 | - static function get_links($app, $id, $only_app='', $order='link_lastmod DESC', $deleted=false, $limit=null) |
|
| 124 | + static function get_links($app, $id, $only_app = '', $order = 'link_lastmod DESC', $deleted = false, $limit = null) |
|
| 125 | 125 | { |
| 126 | 126 | if (self::DEBUG) |
| 127 | 127 | { |
| 128 | - echo "<p>solink.get_links($app,".print_r($id,true).",$only_app,$order,$deleted)</p>\n"; |
|
| 128 | + echo "<p>solink.get_links($app,".print_r($id, true).",$only_app,$order,$deleted)</p>\n"; |
|
| 129 | 129 | } |
| 130 | 130 | if (($not_only = $only_app[0] == '!')) |
| 131 | 131 | { |
| 132 | - $only_app = substr($only_app,1); |
|
| 132 | + $only_app = substr($only_app, 1); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $offset = false; |
@@ -137,32 +137,32 @@ discard block |
||
| 137 | 137 | { |
| 138 | 138 | list($offset, $limit) = $limit; |
| 139 | 139 | } |
| 140 | - elseif($limit) |
|
| 140 | + elseif ($limit) |
|
| 141 | 141 | { |
| 142 | 142 | $offset = 0; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $links = array(); |
| 146 | 146 | try { |
| 147 | - foreach(self::$db->select(self::TABLE, '*', self::$db->expression(self::TABLE, '((', array( |
|
| 147 | + foreach (self::$db->select(self::TABLE, '*', self::$db->expression(self::TABLE, '((', array( |
|
| 148 | 148 | 'link_app1' => $app, |
| 149 | 149 | 'link_id1' => $id, |
| 150 | - ),') OR (',array( |
|
| 150 | + ), ') OR (', array( |
|
| 151 | 151 | 'link_app2' => $app, |
| 152 | 152 | 'link_id2' => $id, |
| 153 | - ),'))', |
|
| 153 | + ), '))', |
|
| 154 | 154 | $deleted ? '' : ' AND deleted IS NULL' |
| 155 | 155 | ), __LINE__, __FILE__, $offset, $order ? " ORDER BY $order" : '', 'phpgwapi', $limit) as $row) |
| 156 | 156 | { |
| 157 | 157 | // check if left side (1) is one of our targets --> add it |
| 158 | - if ($row['link_app1'] == $app && in_array($row['link_id1'],(array)$id)) |
|
| 158 | + if ($row['link_app1'] == $app && in_array($row['link_id1'], (array)$id)) |
|
| 159 | 159 | { |
| 160 | - self::_add2links($row,true,$only_app,$not_only,$links); |
|
| 160 | + self::_add2links($row, true, $only_app, $not_only, $links); |
|
| 161 | 161 | } |
| 162 | 162 | // check if right side (2) is one of our targets --> add it (both can be true for multiple targets!) |
| 163 | - if ($row['link_app2'] == $app && in_array($row['link_id2'],(array)$id)) |
|
| 163 | + if ($row['link_app2'] == $app && in_array($row['link_id2'], (array)$id)) |
|
| 164 | 164 | { |
| 165 | - self::_add2links($row,false,$only_app,$not_only,$links); |
|
| 165 | + self::_add2links($row, false, $only_app, $not_only, $links); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | // if query returns exactly limit rows, we assume there are more and therefore set self::$limit_exceeded |
@@ -170,18 +170,18 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | // catch Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' (1267) |
| 172 | 172 | // caused by non-ascii chars compared with ascii field uid |
| 173 | - catch(Api\Db\Exception $e) { |
|
| 173 | + catch (Api\Db\Exception $e) { |
|
| 174 | 174 | _egw_log_exception($e); |
| 175 | 175 | } |
| 176 | 176 | return is_array($id) ? $links : ($links[$id] ? $links[$id] : array()); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - private static function _add2links($row,$left,$only_app,$not_only,array &$links) |
|
| 179 | + private static function _add2links($row, $left, $only_app, $not_only, array &$links) |
|
| 180 | 180 | { |
| 181 | 181 | $linked_app = $left ? $row['link_app2'] : $row['link_app1']; |
| 182 | 182 | $linked_id = $left ? $row['link_id2'] : $row['link_id1']; |
| 183 | 183 | $app_id = $left ? $row['link_id1'] : $row['link_id2']; |
| 184 | - list($app) = explode('-',$linked_app); |
|
| 184 | + list($app) = explode('-', $linked_app); |
|
| 185 | 185 | if ($only_app && $not_only == ($linked_app == $only_app) || !$GLOBALS['egw_info']['user']['apps'][$app]) |
| 186 | 186 | { |
| 187 | 187 | #echo "$linked_app == $only_app, ";var_dump($linked_app == $only_app);echo " ->dont return a link<br>"; |
@@ -208,13 +208,13 @@ discard block |
||
| 208 | 208 | * @param string $id2 ='' id in $app2, if no integer link_id given in $app_link_id |
| 209 | 209 | * @return array with link-data or False |
| 210 | 210 | */ |
| 211 | - static function get_link($app_link_id,$id='',$app2='',$id2='') |
|
| 211 | + static function get_link($app_link_id, $id = '', $app2 = '', $id2 = '') |
|
| 212 | 212 | { |
| 213 | 213 | if (self::DEBUG) |
| 214 | 214 | { |
| 215 | 215 | echo "<p>solink.get_link('$app_link_id',$id,'$app2','$id2')</p>\n"; |
| 216 | 216 | } |
| 217 | - if ((int) $app_link_id > 0) |
|
| 217 | + if ((int)$app_link_id > 0) |
|
| 218 | 218 | { |
| 219 | 219 | $where = array('link_id' => $app_link_id); |
| 220 | 220 | } |
@@ -224,24 +224,24 @@ discard block |
||
| 224 | 224 | { |
| 225 | 225 | return False; |
| 226 | 226 | } |
| 227 | - $where = self::$db->expression(self::TABLE,'(',array( |
|
| 227 | + $where = self::$db->expression(self::TABLE, '(', array( |
|
| 228 | 228 | 'link_app1' => $app_link_id, |
| 229 | 229 | 'link_id1' => $id, |
| 230 | 230 | 'link_app2' => $app2, |
| 231 | 231 | 'link_id2' => $id2, |
| 232 | - ),') OR (',array( |
|
| 232 | + ), ') OR (', array( |
|
| 233 | 233 | 'link_app2' => $app_link_id, |
| 234 | 234 | 'link_id2' => $id, |
| 235 | 235 | 'link_app1' => $app2, |
| 236 | 236 | 'link_id1' => $id2, |
| 237 | - ),')'); |
|
| 237 | + ), ')'); |
|
| 238 | 238 | } |
| 239 | 239 | try { |
| 240 | - return self::$db->select(self::TABLE,'*',$where,__LINE__,__FILE__)->fetch(ADODB_FETCH_ASSOC); |
|
| 240 | + return self::$db->select(self::TABLE, '*', $where, __LINE__, __FILE__)->fetch(ADODB_FETCH_ASSOC); |
|
| 241 | 241 | } |
| 242 | 242 | // catch Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' (1267) |
| 243 | 243 | // caused by non-ascii chars compared with ascii field uid |
| 244 | - catch(Api\Db\Exception $e) { |
|
| 244 | + catch (Api\Db\Exception $e) { |
|
| 245 | 245 | _egw_log_exception($e); |
| 246 | 246 | } |
| 247 | 247 | return false; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @param boolean $hold_for_purge Don't really delete the link, just mark it as deleted and wait for final delete of linked entry |
| 260 | 260 | * @return array with deleted links |
| 261 | 261 | */ |
| 262 | - static function unlink($link_id,$app='',$id='',$owner=0,$app2='',$id2='',$hold_for_purge=false) |
|
| 262 | + static function unlink($link_id, $app = '', $id = '', $owner = 0, $app2 = '', $id2 = '', $hold_for_purge = false) |
|
| 263 | 263 | { |
| 264 | 264 | if (self::DEBUG) |
| 265 | 265 | { |
@@ -284,21 +284,21 @@ discard block |
||
| 284 | 284 | $check1['link_id1'] = $id; |
| 285 | 285 | $check2['link_id2'] = $id; |
| 286 | 286 | } |
| 287 | - $where = self::$db->expression(self::TABLE,'((',$check1,') OR (',$check2,'))'); |
|
| 287 | + $where = self::$db->expression(self::TABLE, '((', $check1, ') OR (', $check2, '))'); |
|
| 288 | 288 | } |
| 289 | 289 | elseif ($app != '' && $app2 != '') |
| 290 | 290 | { |
| 291 | - $where = self::$db->expression(self::TABLE,'(',array( |
|
| 291 | + $where = self::$db->expression(self::TABLE, '(', array( |
|
| 292 | 292 | 'link_app1' => $app, |
| 293 | 293 | 'link_id1' => $id, |
| 294 | 294 | 'link_app2' => $app2, |
| 295 | 295 | 'link_id2' => $id2, |
| 296 | - ),') OR (',array( |
|
| 296 | + ), ') OR (', array( |
|
| 297 | 297 | 'link_app1' => $app2, |
| 298 | 298 | 'link_id1' => $id2, |
| 299 | 299 | 'link_app2' => $app, |
| 300 | 300 | 'link_id2' => $id, |
| 301 | - ),')'); |
|
| 301 | + ), ')'); |
|
| 302 | 302 | } |
| 303 | 303 | if ($owner) |
| 304 | 304 | { |
@@ -308,25 +308,25 @@ discard block |
||
| 308 | 308 | } |
| 309 | 309 | $deleted = array(); |
| 310 | 310 | try { |
| 311 | - foreach(self::$db->select(self::TABLE,'*',$where,__LINE__,__FILE__) as $row) |
|
| 311 | + foreach (self::$db->select(self::TABLE, '*', $where, __LINE__, __FILE__) as $row) |
|
| 312 | 312 | { |
| 313 | 313 | $deleted[] = $row; |
| 314 | 314 | } |
| 315 | - if($hold_for_purge) |
|
| 315 | + if ($hold_for_purge) |
|
| 316 | 316 | { |
| 317 | - self::$db->update(self::TABLE,array( |
|
| 317 | + self::$db->update(self::TABLE, array( |
|
| 318 | 318 | 'deleted' => time(), |
| 319 | 319 | 'link_lastmod' => time(), |
| 320 | - ), $where, __LINE__,__FILE__); |
|
| 320 | + ), $where, __LINE__, __FILE__); |
|
| 321 | 321 | } |
| 322 | 322 | else |
| 323 | 323 | { |
| 324 | - self::$db->delete(self::TABLE,$where,__LINE__,__FILE__); |
|
| 324 | + self::$db->delete(self::TABLE, $where, __LINE__, __FILE__); |
|
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | // catch Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' (1267) |
| 328 | 328 | // caused by non-ascii chars compared with ascii field uid |
| 329 | - catch(Api\Db\Exception $e) { |
|
| 329 | + catch (Api\Db\Exception $e) { |
|
| 330 | 330 | _egw_log_exception($e); |
| 331 | 331 | } |
| 332 | 332 | |
@@ -357,8 +357,8 @@ discard block |
||
| 357 | 357 | $check1['link_id1'] = $id; |
| 358 | 358 | $check2['link_id2'] = $id; |
| 359 | 359 | } |
| 360 | - $where = self::$db->expression(self::TABLE,'((',$check1,') OR (',$check2,'))'); |
|
| 361 | - self::$db->update(self::TABLE,array('deleted'=> null), $where, __LINE__,__FILE__); |
|
| 360 | + $where = self::$db->expression(self::TABLE, '((', $check1, ') OR (', $check2, '))'); |
|
| 361 | + self::$db->update(self::TABLE, array('deleted'=> null), $where, __LINE__, __FILE__); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -371,13 +371,13 @@ discard block |
||
| 371 | 371 | * @param int $new_owner account_id of new owner |
| 372 | 372 | * @return int number of links changed |
| 373 | 373 | */ |
| 374 | - static function chown($owner,$new_owner) |
|
| 374 | + static function chown($owner, $new_owner) |
|
| 375 | 375 | { |
| 376 | - if ((int)$owner <= 0 || (int) $new_owner <= 0) |
|
| 376 | + if ((int)$owner <= 0 || (int)$new_owner <= 0) |
|
| 377 | 377 | { |
| 378 | 378 | return 0; |
| 379 | 379 | } |
| 380 | - self::$db->update(self::TABLE,array('owner'=>$new_owner),array('owner'=>$owner),__LINE__,__FILE__); |
|
| 380 | + self::$db->update(self::TABLE, array('owner'=>$new_owner), array('owner'=>$owner), __LINE__, __FILE__); |
|
| 381 | 381 | |
| 382 | 382 | return self::$db->affected_rows(); |
| 383 | 383 | } |
@@ -404,15 +404,15 @@ discard block |
||
| 404 | 404 | * @param int|array $limit =null number of entries to return, default null = all or array(offset, num_rows) to return num_rows starting from offset |
| 405 | 405 | * @return array with links from entries from $app to $target_app/$target_id plus the other (b) link_id/app/id in the keys 'link3'/'app3'/'id3' |
| 406 | 406 | */ |
| 407 | - static function get_3links($app, $target_app, $target_id=null, $just_app_ids=false, $order='link_lastmod DESC', $limit=null) |
|
| 407 | + static function get_3links($app, $target_app, $target_id = null, $just_app_ids = false, $order = 'link_lastmod DESC', $limit = null) |
|
| 408 | 408 | { |
| 409 | 409 | $table = self::TABLE; |
| 410 | - $arrayofselects=array( |
|
| 410 | + $arrayofselects = array( |
|
| 411 | 411 | // retrieve the type of links, where the relation is realized as timesheet->infolog/tracker via infolog->projectmanager to timesheet->projectmanager |
| 412 | 412 | array('table'=>self::TABLE, |
| 413 | 413 | 'cols'=>'c.*,b.link_app1 AS app3,b.link_id1 AS id3,b.link_id AS link3', |
| 414 | 414 | 'where'=>'a.link_app1='.self::$db->quote($app).' AND c.link_app2='.self::$db->quote($target_app). |
| 415 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND c.',array('link_id2' => $target_id))), |
|
| 415 | + (!$target_id ? '' : self::$db->expression(self::TABLE, ' AND c.', array('link_id2' => $target_id))), |
|
| 416 | 416 | 'join'=>" a |
| 417 | 417 | JOIN $table b ON a.link_id2=b.link_id1 AND a.link_app2=b.link_app1 |
| 418 | 418 | JOIN $table c ON a.link_id1=c.link_id1 AND a.link_app1=c.link_app1 AND a.link_id!=c.link_id AND c.link_app2=b.link_app2 AND c.link_id2=b.link_id2", |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | array('table'=>self::TABLE, |
| 422 | 422 | 'cols'=>'b.link_id, b.link_app2 as app1, b.link_id2 as id1, b.link_app1 as app2, b.link_id1 as id2, b.link_remark,b.link_lastmod,b.link_owner,b.deleted,c.link_app1 AS app3,c.link_id1 AS id3,c.link_id AS link3', |
| 423 | 423 | 'where'=>'a.link_app1='.self::$db->quote($app).' AND b.link_app1='.self::$db->quote($target_app). |
| 424 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND b.',array('link_id1' => $target_id))), |
|
| 424 | + (!$target_id ? '' : self::$db->expression(self::TABLE, ' AND b.', array('link_id1' => $target_id))), |
|
| 425 | 425 | 'join'=>" a |
| 426 | 426 | JOIN $table b ON a.link_id1=b.link_id2 AND a.link_app1=b.link_app2 |
| 427 | 427 | JOIN $table c ON a.link_id2=c.link_id1 AND a.link_app2=c.link_app1 AND a.link_id!=c.link_id AND c.link_app2=b.link_app1 AND c.link_id2=b.link_id1", |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | array('table'=>self::TABLE, |
| 431 | 431 | 'cols'=>'a.*,c.link_app1 AS app3,c.link_id1 AS id3,c.link_id AS link3', |
| 432 | 432 | 'where'=>'a.link_app1='.self::$db->quote($app).' AND a.link_app2='.self::$db->quote($target_app). |
| 433 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND a.',array('link_id2' => $target_id))), |
|
| 433 | + (!$target_id ? '' : self::$db->expression(self::TABLE, ' AND a.', array('link_id2' => $target_id))), |
|
| 434 | 434 | 'join'=>" a |
| 435 | 435 | JOIN $table b ON a.link_id1=b.link_id2 AND a.link_app1=b.link_app2 |
| 436 | 436 | JOIN $table c ON a.link_id2=c.link_id2 AND a.link_app2=c.link_app2 AND a.link_id!=c.link_id AND c.link_app1=b.link_app1 AND c.link_id1=b.link_id1", |
@@ -442,17 +442,17 @@ discard block |
||
| 442 | 442 | { |
| 443 | 443 | list($offset, $limit) = $limit; |
| 444 | 444 | } |
| 445 | - elseif($limit) |
|
| 445 | + elseif ($limit) |
|
| 446 | 446 | { |
| 447 | 447 | $offset = 0; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | $links = array(); |
| 451 | - foreach(self::$db->union($arrayofselects, __LINE__, __FILE__, $order, $offset, $limit) as $row) |
|
| 451 | + foreach (self::$db->union($arrayofselects, __LINE__, __FILE__, $order, $offset, $limit) as $row) |
|
| 452 | 452 | { |
| 453 | 453 | if ($just_app_ids) |
| 454 | 454 | { |
| 455 | - if ($row['link_app1'] == $target_app && (is_null($target_id) || in_array($row['link_id1'],(array)$target_id))) |
|
| 455 | + if ($row['link_app1'] == $target_app && (is_null($target_id) || in_array($row['link_id1'], (array)$target_id))) |
|
| 456 | 456 | { |
| 457 | 457 | $links[$row['link_id']] = $row['link_id2']; |
| 458 | 458 | } |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | else |
| 465 | 465 | { |
| 466 | - $links[] = Api\Db::strip_array_keys($row,'link_'); |
|
| 466 | + $links[] = Api\Db::strip_array_keys($row, 'link_'); |
|
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | // if query returns exactly limit rows, we assume there are more and therefore set self::$limit_exceeded |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | */ |
| 478 | 478 | static function init_static( ) |
| 479 | 479 | { |
| 480 | - self::$db = $GLOBALS['egw']->db; |
|
| 480 | + self::$db = $GLOBALS['egw']->db; |
|
| 481 | 481 | } |
| 482 | 482 | } |
| 483 | 483 | Storage::init_static(); |
@@ -46,13 +46,13 @@ discard block |
||
| 46 | 46 | * @param Base $storage |
| 47 | 47 | * @param \Traversable $rs |
| 48 | 48 | */ |
| 49 | - public function __construct(Base $storage, \Traversable $rs=null) |
|
| 49 | + public function __construct(Base $storage, \Traversable $rs = null) |
|
| 50 | 50 | { |
| 51 | 51 | $this->storage = $storage; |
| 52 | 52 | |
| 53 | 53 | $this->total = $storage->total; |
| 54 | 54 | |
| 55 | - if (is_a($rs,'IteratorAggregate')) |
|
| 55 | + if (is_a($rs, 'IteratorAggregate')) |
|
| 56 | 56 | { |
| 57 | 57 | $this->rs = $rs->getIterator(); |
| 58 | 58 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function current() |
| 71 | 71 | { |
| 72 | - if (is_a($this->rs,'iterator')) |
|
| 72 | + if (is_a($this->rs, 'iterator')) |
|
| 73 | 73 | { |
| 74 | 74 | $data = $this->rs->current(); |
| 75 | 75 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function key() |
| 87 | 87 | { |
| 88 | - if (is_a($this->rs,'iterator')) |
|
| 88 | + if (is_a($this->rs, 'iterator')) |
|
| 89 | 89 | { |
| 90 | 90 | return $this->rs->key(); |
| 91 | 91 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function next() |
| 99 | 99 | { |
| 100 | - if (is_a($this->rs,'iterator')) |
|
| 100 | + if (is_a($this->rs, 'iterator')) |
|
| 101 | 101 | { |
| 102 | 102 | return $this->rs->next(); |
| 103 | 103 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function rewind() |
| 110 | 110 | { |
| 111 | - if (is_a($this->rs,'iterator')) |
|
| 111 | + if (is_a($this->rs, 'iterator')) |
|
| 112 | 112 | { |
| 113 | 113 | return $this->rs->rewind(); |
| 114 | 114 | } |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @return boolean |
| 121 | 121 | */ |
| 122 | - public function valid () |
|
| 122 | + public function valid() |
|
| 123 | 123 | { |
| 124 | - if (is_a($this->rs,'iterator')) |
|
| 124 | + if (is_a($this->rs, 'iterator')) |
|
| 125 | 125 | { |
| 126 | 126 | return $this->rs->valid(); |
| 127 | 127 | } |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return so_sql2 |
| 55 | 55 | */ |
| 56 | - function __construct($app='',$table='',Api\Db $db=null,$column_prefix='',$no_clone=false) |
|
| 56 | + function __construct($app = '', $table = '', Api\Db $db = null, $column_prefix = '', $no_clone = false) |
|
| 57 | 57 | { |
| 58 | - parent::__construct($app,$table,$db,$column_prefix,$no_clone); |
|
| 58 | + parent::__construct($app, $table, $db, $column_prefix, $no_clone); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -68,13 +68,13 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | function __get($property) |
| 70 | 70 | { |
| 71 | - switch($property) |
|
| 71 | + switch ($property) |
|
| 72 | 72 | { |
| 73 | 73 | case 'id': |
| 74 | 74 | $property = $this->autoinc_id; |
| 75 | 75 | break; |
| 76 | 76 | } |
| 77 | - if (in_array($property,$this->db_cols) || in_array($property,$this->non_db_cols)) |
|
| 77 | + if (in_array($property, $this->db_cols) || in_array($property, $this->non_db_cols)) |
|
| 78 | 78 | { |
| 79 | 79 | return $this->data[$property]; |
| 80 | 80 | } |
@@ -88,15 +88,15 @@ discard block |
||
| 88 | 88 | * @param string $property |
| 89 | 89 | * @param mixed $value |
| 90 | 90 | */ |
| 91 | - function __set($property,$value) |
|
| 91 | + function __set($property, $value) |
|
| 92 | 92 | { |
| 93 | - switch($property) |
|
| 93 | + switch ($property) |
|
| 94 | 94 | { |
| 95 | 95 | case 'id': |
| 96 | 96 | $property = $this->autoinc_id; |
| 97 | 97 | break; |
| 98 | 98 | } |
| 99 | - if (in_array($property,$this->db_cols) || in_array($property,$this->non_db_cols)) |
|
| 99 | + if (in_array($property, $this->db_cols) || in_array($property, $this->non_db_cols)) |
|
| 100 | 100 | { |
| 101 | 101 | $this->data[$property] = $value; |
| 102 | 102 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class App extends Exception\NoPermission |
| 23 | 23 | { |
| 24 | - function __construct($msg=null,$code=101) |
|
| 24 | + function __construct($msg = null, $code = 101) |
|
| 25 | 25 | { |
| 26 | 26 | if (isset($GLOBALS['egw_info']['apps'][$msg])) |
| 27 | 27 | { |
@@ -39,6 +39,6 @@ discard block |
||
| 39 | 39 | '"'.$app.'"'); |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | - parent::__construct($msg,$code); |
|
| 42 | + parent::__construct($msg, $code); |
|
| 43 | 43 | } |
| 44 | 44 | } |