Completed
Push — 16.1 ( 2b6741...abc73d )
by Nathan
50:22 queued 36:36
created
api/src/Json/Request.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param boolean $set =null
40 40
 	 * @return boolean
41 41
 	 */
42
-	public static function isJSONRequest($set=null)
42
+	public static function isJSONRequest($set = null)
43 43
 	{
44 44
 		$ret = self::$_hadJSONRequest;
45 45
 		if (isset($set)) self::$_hadJSONRequest = $set;
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
 
63 63
 		if (get_magic_quotes_gpc()) $input_data = stripslashes($input_data);
64 64
 
65
-		$json_data = json_decode($input_data,true);
65
+		$json_data = json_decode($input_data, true);
66 66
 		if (is_array($json_data) && isset($json_data['request']) && isset($json_data['request']['parameters']) && is_array($json_data['request']['parameters']))
67 67
 		{
68 68
 			//error_log(__METHOD__.__LINE__.array2string($json_data['request']).function_backtrace());
69
-			$parameters =& $json_data['request']['parameters'];
69
+			$parameters = & $json_data['request']['parameters'];
70 70
 		}
71 71
 		else
72 72
 		{
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 		{
78 78
 			$responses = array();
79 79
 			$response = Response::get();
80
-			foreach($parameters[0] as $uid => $data)
80
+			foreach ($parameters[0] as $uid => $data)
81 81
 			{
82 82
 				//error_log("$uid: menuaction=$data[menuaction], parameters=".array2string($data['parameters']));
83 83
 				$this->handleRequest($data['menuaction'], (array)$data['parameters']);
84 84
 				$responses[$uid] = $response->initResponseArray();
85 85
 				//error_log("responses[$uid]=".array2string($responses[$uid]));
86 86
 			}
87
-			$response->data($responses);	// send all responses as data
87
+			$response->data($responses); // send all responses as data
88 88
 		}
89 89
 		else
90 90
 		{
@@ -100,32 +100,32 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public function handleRequest($menuaction, array $parameters)
102 102
 	{
103
-		if (strpos($menuaction,'::') !== false && strpos($menuaction,'.') === false)	// static method name app_something::method
103
+		if (strpos($menuaction, '::') !== false && strpos($menuaction, '.') === false)	// static method name app_something::method
104 104
 		{
105
-			@list($className,$functionName,$handler) = explode('::',$menuaction);
105
+			@list($className, $functionName, $handler) = explode('::', $menuaction);
106 106
 			if (substr($className, 0, 11) == 'EGroupware\\')
107 107
 			{
108 108
 				list(,$appName) = explode('\\', strtolower($className));
109 109
 			}
110 110
 			else
111 111
 			{
112
-				list($appName) = explode('_',$className);
112
+				list($appName) = explode('_', $className);
113 113
 			}
114 114
 
115 115
 			// Check for a real static method, avoid instanciation if it is
116 116
 			$m = new ReflectionMethod($menuaction);
117
-			if($m->isStatic())
117
+			if ($m->isStatic())
118 118
 			{
119 119
 				$ajaxClass = $className;
120 120
 			}
121 121
 		}
122 122
 		else
123 123
 		{
124
-			@list($appName, $className, $functionName, $handler) = explode('.',$menuaction);
124
+			@list($appName, $className, $functionName, $handler) = explode('.', $menuaction);
125 125
 		}
126 126
 		//error_log("json.php: appName=$appName, className=$className, functionName=$functionName, handler=$handler");
127 127
 
128
-		switch($handler)
128
+		switch ($handler)
129 129
 		{
130 130
 			case '/etemplate/process_exec':
131 131
 				$_GET['menuaction'] = $appName.'.'.$className.'.'.$functionName;
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
 				break;
152 152
 		}
153 153
 
154
-		if(substr($className,0,4) != 'ajax' && substr($className,-4) != 'ajax' &&
155
-			$menuaction != 'etemplate.etemplate.process_exec' && substr($functionName,0,4) != 'ajax' ||
156
-			!preg_match('/^[A-Za-z0-9_\\\\-]+(\.[A-Za-z0-9_\\\\]+\.|::)[A-Za-z0-9_]+$/',$menuaction))
154
+		if (substr($className, 0, 4) != 'ajax' && substr($className, -4) != 'ajax' &&
155
+			$menuaction != 'etemplate.etemplate.process_exec' && substr($functionName, 0, 4) != 'ajax' ||
156
+			!preg_match('/^[A-Za-z0-9_\\\\-]+(\.[A-Za-z0-9_\\\\]+\.|::)[A-Za-z0-9_]+$/', $menuaction))
157 157
 		{
158 158
 			// stopped for security reasons
159 159
 			error_log("className='$className', functionName='$functionName', menuaction='$menuaction'");
160
-			error_log($_SERVER['PHP_SELF']. ' stopped for security reason. '.$menuaction.' is not valid. class- or function-name must start with ajax!!!');
160
+			error_log($_SERVER['PHP_SELF'].' stopped for security reason. '.$menuaction.' is not valid. class- or function-name must start with ajax!!!');
161 161
 			// send message also to the user
162
-			throw new Exception\InvalidName($_SERVER['PHP_SELF']. ' stopped for security reason. '.$menuaction.' is not valid. class- or function-name must start with ajax!!!');
162
+			throw new Exception\InvalidName($_SERVER['PHP_SELF'].' stopped for security reason. '.$menuaction.' is not valid. class- or function-name must start with ajax!!!');
163 163
 		}
164 164
 
165 165
 		if (isset($template))
Please login to merge, or discard this patch.
api/src/Json/Tail.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @param string $filename =null if not starting with as slash relative to EGw files dir (this is strongly prefered for security reasons)
70 70
 	 */
71
-	public function __construct($filename=null)
71
+	public function __construct($filename = null)
72 72
 	{
73
-		$this->filenames =& Api\Cache::getSession('phpgwapi', __CLASS__);
73
+		$this->filenames = & Api\Cache::getSession('phpgwapi', __CLASS__);
74 74
 
75 75
 		if ($filename)
76 76
 		{
77 77
 			$this->filename = $filename;
78 78
 
79
-			if (!$this->filenames || !in_array($filename,$this->filenames)) $this->filenames[] = $filename;
79
+			if (!$this->filenames || !in_array($filename, $this->filenames)) $this->filenames[] = $filename;
80 80
 		}
81 81
 	}
82 82
 
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 	 * @param int $start =0 last position in log-file
88 88
 	 * @throws Api\Exception\WrongParameter
89 89
 	 */
90
-	public function ajax_chunk($filename,$start=0)
90
+	public function ajax_chunk($filename, $start = 0)
91 91
 	{
92
-		if (!in_array($filename,$this->filenames))
92
+		if (!in_array($filename, $this->filenames))
93 93
 		{
94 94
 			throw new Api\Exception\WrongParameter("Not allowed to view '$filename'!");
95 95
 		}
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 		if (file_exists($filename))
99 99
 		{
100 100
 			$size = filesize($filename);
101
-			if (!$start || $start < 0 || $start > $size || $size-$start > 4*self::MAX_CHUNK_SIZE)
101
+			if (!$start || $start < 0 || $start > $size || $size - $start > 4 * self::MAX_CHUNK_SIZE)
102 102
 			{
103
-				$start = $size - 4*self::MAX_CHUNK_SIZE;
103
+				$start = $size - 4 * self::MAX_CHUNK_SIZE;
104 104
 				if ($start < 0) $start = 0;
105 105
 			}
106 106
 			$hsize = Api\Vfs::hsize($size);
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 	 * @param boolean $truncate =false true: truncate file, false: delete file
132 132
 	 * @throws Api\Exception\WrongParameter
133 133
 	 */
134
-	public function ajax_delete($filename,$truncate=false)
134
+	public function ajax_delete($filename, $truncate = false)
135 135
 	{
136
-		if (!in_array($filename,$this->filenames))
136
+		if (!in_array($filename, $this->filenames))
137 137
 		{
138 138
 			throw new Api\Exception\WrongParameter("Not allowed to view '$filename'!");
139 139
 		}
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @return string
156 156
 	 * @throws Api\Exception\WrongParameter
157 157
 	 */
158
-	public function show($header=null)
158
+	public function show($header = null)
159 159
 	{
160 160
 		if (!isset($this->filename))
161 161
 		{
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 <p style="float: left; margin: 5px"><b>'.htmlspecialchars($header).'</b></p>
168 168
 <div style="float: right; margin: 2px; margin-right: 5px">
169 169
 	'.Api\Html::form(
170
-		Api\Html::input('clear_log',lang('Clear window'),'button','id="clear_log"')."\n".
171
-		Api\Html::input('delete_log',lang('Delete file'),'button','id="purge_log"')."\n".
172
-		Api\Html::input('empty_log',lang('Empty file'),'button','id="empty_log"')."\n".
173
-		Api\Html::input('download_log',lang('Download'),'submit','id="download_log"'),
174
-		'','/index.php',array(
170
+		Api\Html::input('clear_log', lang('Clear window'), 'button', 'id="clear_log"')."\n".
171
+		Api\Html::input('delete_log', lang('Delete file'), 'button', 'id="purge_log"')."\n".
172
+		Api\Html::input('empty_log', lang('Empty file'), 'button', 'id="empty_log"')."\n".
173
+		Api\Html::input('download_log', lang('Download'), 'submit', 'id="download_log"'),
174
+		'', '/index.php', array(
175 175
 		'menuaction' => 'api.'.__CLASS__.'.download',
176 176
 		'filename' => $this->filename,
177 177
 	)).'
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
 	public function download()
188 188
 	{
189 189
 		$filename = $_GET['filename'];
190
-		if (!in_array($filename,$this->filenames))
190
+		if (!in_array($filename, $this->filenames))
191 191
 		{
192 192
 			throw new Api\Exception\WrongParameter("Not allowed to download '$filename'!");
193 193
 		}
194 194
 		Api\Header\Content::type(basename($filename), 'text/plain');
195 195
 		if ($filename[0] != '/') $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename;
196
-		for($n=ob_get_level(); $n > 0; --$n)
196
+		for ($n = ob_get_level(); $n > 0; --$n)
197 197
 		{
198
-			ob_end_clean();	// stop all output buffering, to NOT run into memory_limit
198
+			ob_end_clean(); // stop all output buffering, to NOT run into memory_limit
199 199
 		}
200 200
 		readfile($filename);
201 201
 		exit;
Please login to merge, or discard this patch.
api/src/CalDAV/PropfindIterator.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
api/src/CalDAV/IcalIterator.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
api/src/CalDAV/Principals.php 1 patch
Spacing   +186 added lines, -187 removed lines patch added patch discarded remove patch
@@ -89,19 +89,18 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
api/src/Translation.php 1 patch
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 *
100 100
 	 * @var array
101 101
 	 */
102
-	static $instance_specific_translations = array('loginscreen','mainscreen','custom');
102
+	static $instance_specific_translations = array('loginscreen', 'mainscreen', 'custom');
103 103
 
104 104
 	/**
105 105
 	 * returns the charset to use (!$lang) or the charset of the lang-files or $lang
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @param string|boolean $lang =False return charset of the active user-lang, or $lang if specified
108 108
 	 * @return string charset
109 109
 	 */
110
-	static function charset($lang=False)
110
+	static function charset($lang = False)
111 111
 	{
112 112
 		static $charsets = array();
113 113
 
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
 		{
116 116
 			if (!isset($charsets[$lang]))
117 117
 			{
118
-				if (!($charsets[$lang] = self::$db->select(self::LANG_TABLE,'content',array(
118
+				if (!($charsets[$lang] = self::$db->select(self::LANG_TABLE, 'content', array(
119 119
 					'lang'		=> $lang,
120 120
 					'message_id'=> 'charset',
121 121
 					'app_name'	=> 'common',
122
-				),__LINE__,__FILE__)->fetchColumn()))
122
+				), __LINE__, __FILE__)->fetchColumn()))
123 123
 				{
124 124
 					$charsets[$lang] = 'utf-8';
125 125
 				}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 *
154 154
 	 * @param boolean $load_translations =true should we also load translations for common and currentapp
155 155
 	 */
156
-	static function init($load_translations=true)
156
+	static function init($load_translations = true)
157 157
 	{
158 158
 		if (!isset(self::$db))
159 159
 		{
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 		}
166 166
 		else
167 167
 		{
168
-			self::$system_charset =& $GLOBALS['egw_setup']->system_charset;
168
+			self::$system_charset = & $GLOBALS['egw_setup']->system_charset;
169 169
 		}
170 170
 		if ((self::$mbstring = check_load_extension('mbstring')))
171 171
 		{
172
-			if(!empty(self::$system_charset))
172
+			if (!empty(self::$system_charset))
173 173
 			{
174 174
 				$ini_default_charset = version_compare(PHP_VERSION, '5.6', '<') ? 'mbstring.internal_encoding' : 'default_charset';
175 175
 				ini_set($ini_default_charset, self::$system_charset);
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 
179 179
 		// try loading load_via from tree-wide cache and check if it contains more rules
180 180
 		if (($load_via = Cache::getTree(__CLASS__, 'load_via')) &&
181
-			$load_via >= self::$load_via && 	// > for array --> contains more elements
181
+			$load_via >= self::$load_via && // > for array --> contains more elements
182 182
 			// little sanity check: cached array contains all stock keys, otherwise ignore it
183 183
 			!array_diff_key(self::$load_via, $load_via))
184 184
 		{
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 	 * @param string $not_found ='*' what to add to not found phrases, default '*'
218 218
 	 * @return string with translation
219 219
 	 */
220
-	static function translate($key, $vars=null, $not_found='' )
220
+	static function translate($key, $vars = null, $not_found = '')
221 221
 	{
222 222
 		if (!self::$lang_arr)
223 223
 		{
224 224
 			self::init();
225 225
 		}
226
-		$ret = $key;				// save key if we dont find a translation
226
+		$ret = $key; // save key if we dont find a translation
227 227
 		if ($not_found) $ret .= $not_found;
228 228
 
229 229
 		if (isset(self::$lang_arr[$key]))
@@ -243,16 +243,16 @@  discard block
 block discarded – undo
243 243
 		{
244 244
 			if (count($vars) > 1)
245 245
 			{
246
-				static $placeholders = array('%3','%2','%1','|%2|','|%3|','%4','%5','%6','%7','%8','%9','%10');
246
+				static $placeholders = array('%3', '%2', '%1', '|%2|', '|%3|', '%4', '%5', '%6', '%7', '%8', '%9', '%10');
247 247
 				// to cope with $vars[0] containing '%2' (eg. an urlencoded path like a referer),
248 248
 				// we first replace '%2' in $ret with '|%2|' and then use that as 2. placeholder
249 249
 				// we do that for %3 as well, ...
250
-				$vars = array_merge(array('|%3|','|%2|'),$vars);	// push '|%2|' (and such) as first replacement on $vars
251
-				$ret = str_replace($placeholders,$vars,$ret);
250
+				$vars = array_merge(array('|%3|', '|%2|'), $vars); // push '|%2|' (and such) as first replacement on $vars
251
+				$ret = str_replace($placeholders, $vars, $ret);
252 252
 			}
253 253
 			else
254 254
 			{
255
-				$ret = str_replace('%1',$vars[0],$ret);
255
+				$ret = str_replace('%1', $vars[0], $ret);
256 256
 			}
257 257
 		}
258 258
 		return $ret;
@@ -267,14 +267,14 @@  discard block
 block discarded – undo
267 267
 	 * 	if multiple names given, they are requested in one request from cache and loaded in given order
268 268
 	 * @param string $lang =false 2 or 5 char lang-code or false for the users language
269 269
 	 */
270
-	static function add_app($apps, $lang=null)
270
+	static function add_app($apps, $lang = null)
271 271
 	{
272 272
 		//error_log(__METHOD__."(".array2string($apps).", $lang) count(self::\$lang_arr)=".count(self::$lang_arr));
273 273
 		//$start = microtime(true);
274 274
 		if (!$lang) $lang = self::$userlang;
275 275
 		$tree_level = $instance_level = array();
276 276
 		if (!is_array($apps)) $apps = (array)$apps;
277
-		foreach($apps as $key => $app)
277
+		foreach ($apps as $key => $app)
278 278
 		{
279 279
 			if (!isset(self::$loaded_apps[$app]) || self::$loaded_apps[$app] != $lang && $app != 'common')
280 280
 			{
@@ -298,26 +298,26 @@  discard block
 block discarded – undo
298 298
 
299 299
 		// merging loaded translations together
300 300
 		$updated_load_via = false;
301
-		foreach((array)$apps as $app)
301
+		foreach ((array)$apps as $app)
302 302
 		{
303 303
 			$l = $app == 'custom' ? 'en' : $lang;
304 304
 			if (isset($tree_level[$app.':'.$l]))
305 305
 			{
306
-				$loaded =& $tree_level[$app.':'.$l];
306
+				$loaded = & $tree_level[$app.':'.$l];
307 307
 			}
308 308
 			elseif (isset($instance_level[$app.':'.$l]))
309 309
 			{
310
-				$loaded =& $instance_level[$app.':'.$l];
310
+				$loaded = & $instance_level[$app.':'.$l];
311 311
 			}
312 312
 			else
313 313
 			{
314 314
 				if (($instance_specific = in_array($app, self::$instance_specific_translations)))
315 315
 				{
316
-					$loaded =& self::load_app($app, $l);
316
+					$loaded = & self::load_app($app, $l);
317 317
 				}
318 318
 				else
319 319
 				{
320
-					$loaded =& self::load_app_files($app, $l, null, $updated_load_via);
320
+					$loaded = & self::load_app_files($app, $l, null, $updated_load_via);
321 321
 				}
322 322
 				//error_log(__METHOD__."('$app', '$lang') instance_specific=$instance_specific, load_app(_files)() returned ".(is_array($loaded)?'Array('.count($loaded).')':array2string($loaded)));
323 323
 				if ($loaded || $instance_specific)
@@ -330,14 +330,14 @@  discard block
 block discarded – undo
330 330
 			if ($loaded)
331 331
 			{
332 332
 				self::$lang_arr = array_merge(self::$lang_arr, $loaded);
333
-				self::$loaded_apps[$app] = $l;	// dont set something not existing to $loaded_apps, no need to load client-side
333
+				self::$loaded_apps[$app] = $l; // dont set something not existing to $loaded_apps, no need to load client-side
334 334
 			}
335 335
 		}
336 336
 		// Re-merge custom over instance level, they have higher precidence
337
-		if($tree_level && !$instance_level && self::$instance_specific_translations)
337
+		if ($tree_level && !$instance_level && self::$instance_specific_translations)
338 338
 		{
339 339
 			$custom = Cache::getInstance(__CLASS__, 'custom:en');
340
-			if($custom)
340
+			if ($custom)
341 341
 			{
342 342
 				self::$lang_arr = array_merge(self::$lang_arr, $custom);
343 343
 			}
@@ -358,15 +358,15 @@  discard block
 block discarded – undo
358 358
 	 * @param string $lang =false 2 or 5 char lang-code or false for the users language
359 359
 	 * @return array the loaded strings
360 360
 	 */
361
-	static function &load_app($app,$lang)
361
+	static function &load_app($app, $lang)
362 362
 	{
363 363
 		//$start = microtime(true);
364 364
 		if (is_null(self::$db)) self::init(false);
365 365
 		$loaded = array();
366
-		foreach(self::$db->select(self::LANG_TABLE,'message_id,content',array(
366
+		foreach (self::$db->select(self::LANG_TABLE, 'message_id,content', array(
367 367
 			'lang'		=> $lang,
368 368
 			'app_name'	=> $app,
369
-		),__LINE__,__FILE__) as $row)
369
+		), __LINE__, __FILE__) as $row)
370 370
 		{
371 371
 			$loaded[strtolower($row['message_id'])] = $row['content'];
372 372
 		}
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 		'sitemgr-link' => array('sitemgr'),
391 391
 		'groupdav' => array('api'),
392 392
 		'developer_tools' => array('etemplate'),
393
-		'login' => array('api','registration'),
393
+		'login' => array('api', 'registration'),
394 394
 	);
395 395
 
396 396
 	/**
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 	{
403 403
 		$lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
404 404
 		$apps = array_keys($GLOBALS['egw_info']['apps']);
405
-		foreach($apps as $app)
405
+		foreach ($apps as $app)
406 406
 		{
407 407
 			$file = self::get_lang_file($app, $lang);
408 408
 			// check if file has changed compared to what's cached
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 		Cache::unsetTree(__CLASS__, $app.':'.$lang);
433 433
 		Cache::unsetTree(__CLASS__, self::get_lang_file($app, $lang));
434 434
 
435
-		foreach(self::$load_via as $load => $via)
435
+		foreach (self::$load_via as $load => $via)
436 436
 		{
437 437
 			//error_log("load_via[load='$load'] = via = ".array2string($via));
438 438
 			if ($via === 'all-apps' || in_array($app, (array)$via))
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 	 * @param string $_lang =null
455 455
 	 * @return array $lang or $app => number pairs
456 456
 	 */
457
-	static function statistics($_lang=null)
457
+	static function statistics($_lang = null)
458 458
 	{
459 459
 		$cache = Cache::getTree(__CLASS__, 'statistics');
460 460
 
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 			{
466 466
 				$en_phrases = array_keys(self::load_app_files(null, 'en', 'all-apps'));
467 467
 				$cache['']['en'] = count($en_phrases);
468
-				foreach(array_keys(self::get_available_langs()) as $lang)
468
+				foreach (array_keys(self::get_available_langs()) as $lang)
469 469
 				{
470 470
 					if ($lang == 'en') continue;
471 471
 					$lang_phrases = array_keys(self::load_app_files(null, $lang, 'all-apps'));
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 			else
477 477
 			{
478 478
 				$cache['en'] = array();
479
-				foreach(scandir(EGW_SERVER_ROOT) as $app)
479
+				foreach (scandir(EGW_SERVER_ROOT) as $app)
480 480
 				{
481 481
 					if ($app[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$app) ||
482 482
 						!file_exists(self::get_lang_file($app, 'en')))
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 		if (!in_array($_app, self::$instance_specific_translations))
515 515
 		{
516 516
 			// check if cache is NOT invalided by checking if we have a modification time for concerned lang-file
517
-			$time = Cache::getTree(__CLASS__, $file=self::get_lang_file($_app, $_lang));
517
+			$time = Cache::getTree(__CLASS__, $file = self::get_lang_file($_app, $_lang));
518 518
 			// if we dont have one, cache has been invalidated and we need to load translations
519 519
 			if (!isset($time)) self::add_app($_app, $_lang);
520 520
 
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 	 * @param type $time
535 535
 	 * @return type
536 536
 	 */
537
-	static function max_lang_time($time=null)
537
+	static function max_lang_time($time = null)
538 538
 	{
539 539
 		static $max_lang_time = null;
540 540
 
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 		if (isset($time) && $time > $max_lang_time)
546 546
 		{
547 547
 			//error_log(__METHOD__."($time) updating previous max_lang_time=$max_lang_time to $time");
548
-			Cache::setTree(__CLASS__, 'max_lang_time', $max_lang_time=$time);
548
+			Cache::setTree(__CLASS__, 'max_lang_time', $max_lang_time = $time);
549 549
 		}
550 550
 		return $max_lang_time;
551 551
 	}
@@ -561,34 +561,34 @@  discard block
 block discarded – undo
561 561
 	 * @param boolean $updated_load_via =false on return true if self::$load_via was updated
562 562
 	 * @return array the loaded strings
563 563
 	 */
564
-	static function &load_app_files($app, $lang, $just_app_file=null, &$updated_load_via=false)
564
+	static function &load_app_files($app, $lang, $just_app_file = null, &$updated_load_via = false)
565 565
 	{
566 566
 		//$start = microtime(true);
567 567
 		$load_app = isset($just_app_file) ? $just_app_file : (isset(self::$load_via[$app]) ? self::$load_via[$app] : $app);
568 568
 		$loaded = array();
569
-		foreach($load_app == 'all-apps' ? scandir(EGW_SERVER_ROOT) : (array)$load_app as $app_dir)
569
+		foreach ($load_app == 'all-apps' ? scandir(EGW_SERVER_ROOT) : (array)$load_app as $app_dir)
570 570
 		{
571
-			if ($load_app == 'all-apps' && $app_dir=='..') continue; // do not try to break out of egw server root
571
+			if ($load_app == 'all-apps' && $app_dir == '..') continue; // do not try to break out of egw server root
572 572
 			if ($app_dir[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$app_dir) ||
573
-				!@file_exists($file=self::get_lang_file($app_dir, $lang)) ||
573
+				!@file_exists($file = self::get_lang_file($app_dir, $lang)) ||
574 574
 				!($f = fopen($file, 'r')))
575 575
 			{
576 576
 				continue;
577 577
 			}
578 578
 			// store ctime of file we parse
579
-			Cache::setTree(__CLASS__, $file, $time=filemtime($file));
579
+			Cache::setTree(__CLASS__, $file, $time = filemtime($file));
580 580
 			self::max_lang_time($time);
581 581
 
582 582
 			$line_nr = 0;
583 583
 			//use fgets and split the line, as php5.3.3 with squeeze does not support splitting lines with fgetcsv while reading properly
584 584
 			//if the first letter after the delimiter is a german umlaut (UTF8 representation thereoff)
585 585
 			//while(($line = fgetcsv($f, 1024, "\t")))
586
-			while(($read = fgets($f)))
586
+			while (($read = fgets($f)))
587 587
 			{
588 588
 				$line = explode("\t", trim($read));
589 589
 				++$line_nr;
590 590
 				if (count($line) != 4) continue;
591
-				list($l_id,$l_app,$l_lang,$l_translation) = $line;
591
+				list($l_id, $l_app, $l_lang, $l_translation) = $line;
592 592
 				if ($l_lang != $lang) continue;
593 593
 				if (!isset($just_app_file) && $l_app != $app)
594 594
 				{
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 			// little sanity check: cached array contains all stock keys, otherwise ignore it
630 630
 			!array_diff_key(self::$load_via, $load_via))
631 631
 		{
632
-			foreach($load_via as $app => $via)
632
+			foreach ($load_via as $app => $via)
633 633
 			{
634 634
 				if (self::$load_via[$app] != $via)
635 635
 				{
@@ -655,15 +655,15 @@  discard block
 block discarded – undo
655 655
 	 * @param boolean $force_read =false force a re-read of the languages
656 656
 	 * @return array with lang-code => descriptiv lang-name pairs
657 657
 	 */
658
-	static function get_available_langs($translate=true, $force_read=false)
658
+	static function get_available_langs($translate = true, $force_read = false)
659 659
 	{
660 660
 		if (!is_array(self::$langs) || $force_read)
661 661
 		{
662
-			if (!($f = fopen($file=EGW_SERVER_ROOT.'/setup/lang/languages','rb')))
662
+			if (!($f = fopen($file = EGW_SERVER_ROOT.'/setup/lang/languages', 'rb')))
663 663
 			{
664 664
 				throw new Exception("List of available languages (%1) missing!", $file);
665 665
 			}
666
-			while(($line = fgetcsv($f, null, "\t")))
666
+			while (($line = fgetcsv($f, null, "\t")))
667 667
 			{
668 668
 				self::$langs[$line[0]] = $line[1];
669 669
 			}
@@ -673,12 +673,12 @@  discard block
 block discarded – undo
673 673
 			{
674 674
 				if (is_null(self::$db)) self::init(false);
675 675
 
676
-				foreach(self::$langs as $lang => $name)
676
+				foreach (self::$langs as $lang => $name)
677 677
 				{
678
-					self::$langs[$lang] = self::translate($name,False,'');
678
+					self::$langs[$lang] = self::translate($name, False, '');
679 679
 				}
680 680
 			}
681
-			uasort(self::$langs,'strcasecmp');
681
+			uasort(self::$langs, 'strcasecmp');
682 682
 		}
683 683
 		return self::$langs;
684 684
 	}
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 	 * @param boolean $force_read =false force a re-read of the languages
692 692
 	 * @return array with lang-code => descriptiv lang-name pairs
693 693
 	 */
694
-	static function get_installed_langs($force_read=false)
694
+	static function get_installed_langs($force_read = false)
695 695
 	{
696 696
 		return self::get_available_langs($force_read);
697 697
 	}
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 		{
709 709
 			return self::$langs[$lang];
710 710
 		}
711
-		return self::$db->select(self::LANGUAGES_TABLE,'lang_name',array('lang_id' => $lang),__LINE__,__FILE__)->fetchColumn();
711
+		return self::$db->select(self::LANGUAGES_TABLE, 'lang_name', array('lang_id' => $lang), __LINE__, __FILE__)->fetchColumn();
712 712
 	}
713 713
 
714 714
 	/**
@@ -717,20 +717,20 @@  discard block
 block discarded – undo
717 717
 	 * @param boolean $force_read =false
718 718
 	 * @return array with lang_id => lang_name pairs
719 719
 	 */
720
-	static function list_langs($force_read=false)
720
+	static function list_langs($force_read = false)
721 721
 	{
722 722
 		if (!$force_read)
723 723
 		{
724
-			return Cache::getInstance(__CLASS__,'list_langs',array(__CLASS__,'list_langs'),array(true));
724
+			return Cache::getInstance(__CLASS__, 'list_langs', array(__CLASS__, 'list_langs'), array(true));
725 725
 		}
726
-		$languages = self::get_installed_langs();	// available languages
727
-		$availible = "('".implode("','",array_keys($languages))."')";
726
+		$languages = self::get_installed_langs(); // available languages
727
+		$availible = "('".implode("','", array_keys($languages))."')";
728 728
 
729 729
 		// this shows first the installed, then the available and then the rest
730
-		foreach(self::$db->select(self::LANGUAGES_TABLE,array(
731
-			'lang_id','lang_name',
730
+		foreach (self::$db->select(self::LANGUAGES_TABLE, array(
731
+			'lang_id', 'lang_name',
732 732
 			"CASE WHEN lang_id IN $availible THEN 1 ELSE 0 END AS availible",
733
-		),"lang_id NOT IN ('".implode("','",array_keys($languages))."')",__LINE__,__FILE__,false,' ORDER BY availible DESC,lang_name') as $row)
733
+		), "lang_id NOT IN ('".implode("','", array_keys($languages))."')", __LINE__, __FILE__, false, ' ORDER BY availible DESC,lang_name') as $row)
734 734
 		{
735 735
 			$languages[$row['lang_id']] = $row['lang_name'];
736 736
 		}
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 	 * @param string $lang language code
745 745
 	 * @return the full path of the filename for the requested app and language
746 746
 	 */
747
-	static function get_lang_file($app,$lang)
747
+	static function get_lang_file($app, $lang)
748 748
 	{
749 749
 		if ($app == 'common') $app = 'phpgwapi';
750 750
 		return EGW_SERVER_ROOT.'/'.$app.'/'.self::LANG_DIR.'/'.self::LANGFILE_PREFIX.$lang.self::LANGFILE_EXTENSION;
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 	 */
758 758
 	static function get_installed_charsets()
759 759
 	{
760
-		static $charsets=null;
760
+		static $charsets = null;
761 761
 
762 762
 		if (!isset($charsets))
763 763
 		{
@@ -787,13 +787,13 @@  discard block
 block discarded – undo
787 787
 		static $extra = array(
788 788
 			'&szlig;' => 'ss',
789 789
 		);
790
-		$entities = htmlentities($_str,ENT_QUOTES,self::charset());
790
+		$entities = htmlentities($_str, ENT_QUOTES, self::charset());
791 791
 
792
-		$estr = str_replace(array_keys($extra),array_values($extra), $entities);
793
-		$ustr = preg_replace('/&([aAuUoO])uml;/','\\1e', $estr);	// replace german umlauts with the letter plus one 'e'
794
-		$astr = preg_replace('/&([a-zA-Z])(grave|acute|circ|ring|cedil|tilde|slash|uml);/','\\1', $ustr);	// remove all types of accents
792
+		$estr = str_replace(array_keys($extra), array_values($extra), $entities);
793
+		$ustr = preg_replace('/&([aAuUoO])uml;/', '\\1e', $estr); // replace german umlauts with the letter plus one 'e'
794
+		$astr = preg_replace('/&([a-zA-Z])(grave|acute|circ|ring|cedil|tilde|slash|uml);/', '\\1', $ustr); // remove all types of accents
795 795
 
796
-		return preg_replace('/&([a-zA-Z]+|#[0-9]+|);/','', $astr);	// remove all other entities
796
+		return preg_replace('/&([a-zA-Z]+|#[0-9]+|);/', '', $astr); // remove all other entities
797 797
 	}
798 798
 
799 799
 	/**
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 	 * @param boolean $check_to_from =true internal to bypass all charset replacements
806 806
 	 * @return string|array converted string(s) from $data
807 807
 	 */
808
-	static function convert($data,$from=False,$to=False,$check_to_from=true)
808
+	static function convert($data, $from = False, $to = False, $check_to_from = true)
809 809
 	{
810 810
 		if ($check_to_from)
811 811
 		{
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 			if (!$from)
817 817
 			{
818 818
 				$from = self::$mbstring ? strtolower(mb_detect_encoding($data)) : 'iso-8859-1';
819
-				if($from == 'ascii')
819
+				if ($from == 'ascii')
820 820
 				{
821 821
 					$from = 'iso-8859-1';
822 822
 				}
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 				 php does not seem to support gb2312
827 827
 				 but seems to be able to decode it as EUC-CN
828 828
 			*/
829
-			switch($from)
829
+			switch ($from)
830 830
 			{
831 831
 				case 'ks_c_5601-1987':
832 832
 					$from = 'CP949';
@@ -872,9 +872,9 @@  discard block
 block discarded – undo
872 872
 		}
873 873
 		if (is_array($data))
874 874
 		{
875
-			foreach($data as $key => $str)
875
+			foreach ($data as $key => $str)
876 876
 			{
877
-				$ret[$key] = self::convert($str,$from,$to,false);	// false = bypass the above checks, as they are already done
877
+				$ret[$key] = self::convert($str, $from, $to, false); // false = bypass the above checks, as they are already done
878 878
 			}
879 879
 			return $ret;
880 880
 		}
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
 		{
887 887
 			return utf8_decode($data);
888 888
 		}
889
-		if (self::$mbstring && !$prefer_iconv && ($data = @mb_convert_encoding($data,$to,$from)) != '')
889
+		if (self::$mbstring && !$prefer_iconv && ($data = @mb_convert_encoding($data, $to, $from)) != '')
890 890
 		{
891 891
 			return $data;
892 892
 		}
@@ -914,12 +914,12 @@  discard block
 block discarded – undo
914 914
 			// in an email on the first Traditional/Japanese/Korean character,
915 915
 			// but in reality when people send mails in GB2312, UMA mostly use
916 916
 			// extended GB13000/GB18030 which allow T/Jap/Korean characters.
917
-			if($from == 'euc-cn')
917
+			if ($from == 'euc-cn')
918 918
 			{
919 919
 				$from = 'gb18030';
920 920
 			}
921 921
 
922
-			if (($convertedData = iconv($from,$to,$data)))
922
+			if (($convertedData = iconv($from, $to, $data)))
923 923
 			{
924 924
 				return $convertedData;
925 925
 			}
@@ -934,9 +934,9 @@  discard block
 block discarded – undo
934 934
 	 * @param string|boolean $from charset $data is in or False if it should be detected
935 935
 	 * @return string|array converted string(s) from $data
936 936
 	 */
937
-	static function convert_jsonsafe($_data,$from=False)
937
+	static function convert_jsonsafe($_data, $from = False)
938 938
 	{
939
-		if ($from===false) $from = self::detect_encoding($_data);
939
+		if ($from === false) $from = self::detect_encoding($_data);
940 940
 
941 941
 		$data = self::convert($_data, strtolower($from));
942 942
 
@@ -945,12 +945,12 @@  discard block
 block discarded – undo
945 945
 		{
946 946
 			$test = @json_encode($data);
947 947
 			//error_log(__METHOD__.__LINE__.' ->'.strlen($data).' Error:'.json_last_error().'<- data:#'.$test.'#');
948
-			if (($test=="null" || $test === false || is_null($test)) && strlen($data)>0)
948
+			if (($test == "null" || $test === false || is_null($test)) && strlen($data) > 0)
949 949
 			{
950 950
 				// try to fix broken utf8
951
-				$x = (function_exists('mb_convert_encoding')?mb_convert_encoding($data,'UTF-8','UTF-8'):(function_exists('iconv')?@iconv("UTF-8","UTF-8//IGNORE",$data):$data));
951
+				$x = (function_exists('mb_convert_encoding') ? mb_convert_encoding($data, 'UTF-8', 'UTF-8') : (function_exists('iconv') ? @iconv("UTF-8", "UTF-8//IGNORE", $data) : $data));
952 952
 				$test = @json_encode($x);
953
-				if (($test=="null" || $test === false || is_null($test)) && strlen($data)>0)
953
+				if (($test == "null" || $test === false || is_null($test)) && strlen($data) > 0)
954 954
 				{
955 955
 					// this should not be needed, unless something fails with charset detection/ wrong charset passed
956 956
 					error_log(__METHOD__.__LINE__.' Charset Reported:'.$from.' Charset Detected:'.self::detect_encoding($data));
@@ -973,36 +973,36 @@  discard block
 block discarded – undo
973 973
 	 * @param string $message_id
974 974
 	 * @param string $content translation or null to delete translation
975 975
 	 */
976
-	static function write($lang,$app,$message_id,$content)
976
+	static function write($lang, $app, $message_id, $content)
977 977
 	{
978 978
 		if ($content)
979 979
 		{
980
-			self::$db->insert(self::LANG_TABLE,array(
980
+			self::$db->insert(self::LANG_TABLE, array(
981 981
 				'content' => $content,
982
-			),array(
982
+			), array(
983 983
 				'lang' => $lang,
984 984
 				'app_name' => $app,
985 985
 				'message_id' => $message_id,
986
-			),__LINE__,__FILE__);
986
+			), __LINE__, __FILE__);
987 987
 		}
988 988
 		else
989 989
 		{
990
-			self::$db->delete(self::LANG_TABLE,array(
990
+			self::$db->delete(self::LANG_TABLE, array(
991 991
 				'lang' => $lang,
992 992
 				'app_name' => $app,
993 993
 				'message_id' => $message_id,
994
-			),__LINE__,__FILE__);
994
+			), __LINE__, __FILE__);
995 995
 		}
996 996
 		// invalidate the cache
997
-		if(!in_array($app,self::$instance_specific_translations))
997
+		if (!in_array($app, self::$instance_specific_translations))
998 998
 		{
999
-			Cache::unsetCache(Cache::TREE,__CLASS__,$app.':'.$lang);
999
+			Cache::unsetCache(Cache::TREE, __CLASS__, $app.':'.$lang);
1000 1000
 		}
1001 1001
 		else
1002 1002
 		{
1003
-			foreach(array_keys((array)self::get_installed_langs()) as $key)
1003
+			foreach (array_keys((array)self::get_installed_langs()) as $key)
1004 1004
 			{
1005
-				Cache::unsetCache(Cache::INSTANCE,__CLASS__,$app.':'.$key);
1005
+				Cache::unsetCache(Cache::INSTANCE, __CLASS__, $app.':'.$key);
1006 1006
 			}
1007 1007
 		}
1008 1008
  	}
@@ -1015,13 +1015,13 @@  discard block
 block discarded – undo
1015 1015
 	 * @param string $message_id
1016 1016
 	 * @return string|boolean content or false if not found
1017 1017
 	 */
1018
-	static function read($lang,$app_name,$message_id)
1018
+	static function read($lang, $app_name, $message_id)
1019 1019
 	{
1020
-		return self::$db->select(self::LANG_TABLE,'content',array(
1020
+		return self::$db->select(self::LANG_TABLE, 'content', array(
1021 1021
 			'lang' => $lang,
1022 1022
 			'app_name' => $app_name,
1023 1023
 			'message_id' => $message_id,
1024
-		),__LINE__,__FILE__)->fetchColumn();
1024
+		), __LINE__, __FILE__)->fetchColumn();
1025 1025
 	}
1026 1026
 
1027 1027
 	/**
@@ -1032,22 +1032,22 @@  discard block
 block discarded – undo
1032 1032
 	 * @param string $lang ='' default check all langs
1033 1033
 	 * @return string
1034 1034
 	 */
1035
-	static function get_message_id($translation,$app=null,$lang=null)
1035
+	static function get_message_id($translation, $app = null, $lang = null)
1036 1036
 	{
1037 1037
 		$where = array('content '.self::$db->capabilities[Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.self::$db->quote($translation));
1038 1038
 		if ($app) $where['app_name'] = $app;
1039 1039
 		if ($lang) $where['lang'] = $lang;
1040 1040
 
1041
-		$id = self::$db->select(self::LANG_TABLE,'message_id',$where,__LINE__,__FILE__)->fetchColumn();
1041
+		$id = self::$db->select(self::LANG_TABLE, 'message_id', $where, __LINE__, __FILE__)->fetchColumn();
1042 1042
 
1043 1043
 		// Check cache, since most things aren't in the DB anymore
1044
-		if(!$id)
1044
+		if (!$id)
1045 1045
 		{
1046 1046
 			$ids = array_filter(array_keys(self::$lang_arr), function($haystack) use($translation) {
1047
-				return stripos(self::$lang_arr[$haystack],$translation) !== false;
1047
+				return stripos(self::$lang_arr[$haystack], $translation) !== false;
1048 1048
 			});
1049 1049
 			$id = array_shift($ids);
1050
-			if(!$id && ($lang && $lang !== 'en' || self::$userlang != 'en'))
1050
+			if (!$id && ($lang && $lang !== 'en' || self::$userlang != 'en'))
1051 1051
 			{
1052 1052
 				// Try english
1053 1053
 				if (in_array($app, self::$instance_specific_translations))
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
 				if ($instance_level) $lang_arr = Cache::getInstance(__CLASS__, $instance_level);
1065 1065
 				$lang_arr = $lang_arr[$app.':en'];
1066 1066
 				$ids = array_filter(array_keys($lang_arr), function($haystack) use($translation, $lang_arr) {
1067
-					return stripos($lang_arr[$haystack],$translation) !== false;
1067
+					return stripos($lang_arr[$haystack], $translation) !== false;
1068 1068
 				});
1069 1069
 				$id = array_shift($ids);
1070 1070
 			}
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
 	 * @param string $verify =null encoding to verify, get checked first and have a match for only ascii or no detection available
1082 1082
 	 * @return string - encoding
1083 1083
 	 */
1084
-	static function detect_encoding($string, $verify=null)
1084
+	static function detect_encoding($string, $verify = null)
1085 1085
 	{
1086 1086
 		if (function_exists('iconv'))
1087 1087
 		{
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 		}
1105 1105
 		if ($verify && (!isset($detected) || $detected === 'ascii'))
1106 1106
 		{
1107
-			return $verify;	// ascii matches all charsets
1107
+			return $verify; // ascii matches all charsets
1108 1108
 		}
1109 1109
 		return isset($detected) ? $detected : 'iso-8859-1'; // we choose to return iso-8859-1 as default
1110 1110
 	}
Please login to merge, or discard this patch.
api/src/Config.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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']]));
Please login to merge, or discard this patch.
api/src/Asyncservice.php 1 patch
Spacing   +74 added lines, -76 removed lines patch added patch discarded remove patch
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
api/src/Link/Storage.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.