Completed
Push — master ( 391858...f11a6e )
by Nathan
19:31
created
api/src/Contacts/Merge.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 use EGroupware\Api;
17 17
 
18 18
 // explicit import not namespaced classes
19
-use calendar_boupdate;	// we detect if it is not available
19
+use calendar_boupdate; // we detect if it is not available
20 20
 
21 21
 /**
22 22
  * Contacts document merge
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
 	 * @param boolean $ignore_acl =false true: no acl check
56 56
 	 * @return array|boolean
57 57
 	 */
58
-	protected function get_replacements($id,&$content=null,$ignore_acl=false)
58
+	protected function get_replacements($id, &$content = null, $ignore_acl = false)
59 59
 	{
60
-		if (!($replacements = $this->contact_replacements($id,'',$ignore_acl, $content)))
60
+		if (!($replacements = $this->contact_replacements($id, '', $ignore_acl, $content)))
61 61
 		{
62 62
 			return false;
63 63
 		}
64
-		if($content && strpos($content, '$$#') !== false)
64
+		if ($content && strpos($content, '$$#') !== false)
65 65
 		{
66
-			$this->cf_link_to_expand($this->contacts->read($id, $ignore_acl), $content, $replacements,'addressbook');
66
+			$this->cf_link_to_expand($this->contacts->read($id, $ignore_acl), $content, $replacements, 'addressbook');
67 67
 		}
68 68
 
69 69
 		// Links
70 70
 		$replacements += $this->get_all_links('addressbook', $id, '', $content);
71
-		if (!(strpos($content,'$$calendar/') === false))
71
+		if (!(strpos($content, '$$calendar/') === false))
72 72
 		{
73
-			$replacements += $this->calendar_replacements($id,!(strpos($content,'$$calendar/-1/') === false));
73
+			$replacements += $this->calendar_replacements($id, !(strpos($content, '$$calendar/-1/') === false));
74 74
 		}
75 75
 		return $replacements;
76 76
 	}
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 * @param boolean $last_event_too =false also include information about the last event
83 83
 	 * @return array
84 84
 	 */
85
-	protected function calendar_replacements($id,$last_event_too=false)
85
+	protected function calendar_replacements($id, $last_event_too = false)
86 86
 	{
87 87
 		if (!class_exists('calendar_boupdate')) return array();
88 88
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		{
102 102
 			$events = array();
103 103
 		}
104
-		if ($last_event_too==true)
104
+		if ($last_event_too == true)
105 105
 		{
106 106
 			$last = $calendar->search(array(
107 107
 				'end' => $calendar->now_su,
@@ -111,41 +111,41 @@  discard block
 block discarded – undo
111 111
 				'order' => 'cal_start DESC',
112 112
 				'enum_recurring' => true
113 113
 			));
114
-			$events['-1'] = $last ? array_shift($last) : array();	// returned events are indexed by cal_id!
114
+			$events['-1'] = $last ? array_shift($last) : array(); // returned events are indexed by cal_id!
115 115
 		}
116 116
 		$replacements = array();
117
-		$n = 1;  // Returned events are indexed by cal_id, need to index sequentially
118
-		foreach($events as $key => $event)
117
+		$n = 1; // Returned events are indexed by cal_id, need to index sequentially
118
+		foreach ($events as $key => $event)
119 119
 		{
120 120
 			// Use -1 for previous key
121
-			if($key < 0) $n = $key;
121
+			if ($key < 0) $n = $key;
122 122
 
123
-			foreach($calendar->event2array($event) as $name => $data)
123
+			foreach ($calendar->event2array($event) as $name => $data)
124 124
 			{
125
-				if (substr($name,-4) == 'date') $name = substr($name,0,-4);
126
-				$replacements['$$calendar/'.$n.'/'.$name.'$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data'];
125
+				if (substr($name, -4) == 'date') $name = substr($name, 0, -4);
126
+				$replacements['$$calendar/'.$n.'/'.$name.'$$'] = is_array($data['data']) ? implode(', ', $data['data']) : $data['data'];
127 127
 			}
128
-			foreach(array('start','end') as $what)
128
+			foreach (array('start', 'end') as $what)
129 129
 			{
130
-				foreach(array(
130
+				foreach (array(
131 131
 					'date' => $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'],
132 132
 					'day'  => 'l',
133 133
 					'time' => $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i',
134 134
 				) as $name => $format)
135 135
 				{
136
-					$value = $event[$what] ? date($format,$event[$what]) : '';
136
+					$value = $event[$what] ? date($format, $event[$what]) : '';
137 137
 					if ($format == 'l') $value = lang($value);
138 138
 					$replacements['$$calendar/'.$n.'/'.$what.$name.'$$'] = $value;
139 139
 				}
140 140
 			}
141
-			$duration = ($event['end'] - $event['start'])/60;
142
-			$replacements['$$calendar/'.$n.'/duration$$'] = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
141
+			$duration = ($event['end'] - $event['start']) / 60;
142
+			$replacements['$$calendar/'.$n.'/duration$$'] = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : '');
143 143
 
144 144
 			++$n;
145 145
 		}
146 146
 
147 147
 		// Need to set some keys if there is no previous event
148
-		if($last_event_too && count($events['-1']) == 0) {
148
+		if ($last_event_too && count($events['-1']) == 0) {
149 149
 			$replacements['$$calendar/-1/start$$'] = '';
150 150
 			$replacements['$$calendar/-1/end$$'] = '';
151 151
 			$replacements['$$calendar/-1/owner$$'] = '';
@@ -168,18 +168,18 @@  discard block
 block discarded – undo
168 168
 		echo '<tr><td colspan="4"><h3>'.lang('Contact fields:')."</h3></td></tr>";
169 169
 
170 170
 		$n = 0;
171
-		foreach($this->contacts->contact_fields as $name => $label)
171
+		foreach ($this->contacts->contact_fields as $name => $label)
172 172
 		{
173
-			if (in_array($name,array('tid','label','geo'))) continue;	// dont show them, as they are not used in the UI atm.
173
+			if (in_array($name, array('tid', 'label', 'geo'))) continue; // dont show them, as they are not used in the UI atm.
174 174
 
175
-			if (in_array($name,array('email','org_name','tel_work','url')) && $n&1)		// main values, which should be in the first column
175
+			if (in_array($name, array('email', 'org_name', 'tel_work', 'url')) && $n&1)		// main values, which should be in the first column
176 176
 			{
177 177
 				echo "</tr>\n";
178 178
 				$n++;
179 179
 			}
180 180
 			if (!($n&1)) echo '<tr>';
181 181
 			echo '<td>{{'.$name.'}}</td><td>'.$label.'</td>';
182
-			if($name == 'cat_id')
182
+			if ($name == 'cat_id')
183 183
 			{
184 184
 				if ($n&1) echo "</tr>\n";
185 185
 				echo '<td>{{categories}}</td><td>'.lang('Category path').'</td>';
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
 		}
191 191
 
192 192
 		echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>";
193
-		foreach($this->contacts->customfields as $name => $field)
193
+		foreach ($this->contacts->customfields as $name => $field)
194 194
 		{
195 195
 			echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n";
196 196
 		}
197 197
 
198 198
 		echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>";
199
-		foreach(array(
199
+		foreach (array(
200 200
 			'link' => lang('HTML link to the current record'),
201 201
 			'links' => lang('Titles of any entries linked to the current record, excluding attached files'),
202 202
  			'attachments' => lang('List of files linked to the current record'),
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
 		Api\Translation::add_app('calendar');
225 225
 		echo '<tr><td colspan="4"><h3>'.lang('Calendar fields:')." # = 1, 2, ..., 20, -1</h3></td></tr>";
226
-		foreach(array(
226
+		foreach (array(
227 227
 			'title' => lang('Title'),
228 228
 			'description' => lang('Description'),
229 229
 			'participants' => lang('Participants'),
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 			'owner'    => lang('Owner'),
246 246
 		) as $name => $label)
247 247
 		{
248
-			if (in_array($name,array('start','end')) && $n&1)		// main values, which should be in the first column
248
+			if (in_array($name, array('start', 'end')) && $n&1)		// main values, which should be in the first column
249 249
 			{
250 250
 				echo "</tr>\n";
251 251
 				$n++;
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 	 * @param int|string $export_limit =null export-limit, default $GLOBALS['egw_info']['server']['export_limit']
275 275
 	 * @return array see nextmatch_widget::egw_actions
276 276
 	 */
277
-	public static function document_action($dirs, $group=0, $caption='Insert in document', $prefix='document_', $default_doc='',
278
-		$export_limit=null)
277
+	public static function document_action($dirs, $group = 0, $caption = 'Insert in document', $prefix = 'document_', $default_doc = '',
278
+		$export_limit = null)
279 279
 	{
280 280
 		$actions = parent::document_action($dirs, $group, $caption, $prefix, $default_doc, $export_limit);
281 281
 
@@ -287,14 +287,14 @@  discard block
 block discarded – undo
287 287
 
288 288
 	protected static function customise_mail_actions(&$action)
289 289
 	{
290
-		if(strpos($action['egw_open'], 'edit-mail') === 0)
290
+		if (strpos($action['egw_open'], 'edit-mail') === 0)
291 291
 		{
292 292
 			unset($action['confirm_multiple']);
293 293
 			$action['onExecute'] = 'javaScript:app.addressbook.merge_mail';
294 294
 		}
295 295
 		else if ($action['children'])
296 296
 		{
297
-			foreach($action['children'] as &$child)
297
+			foreach ($action['children'] as &$child)
298 298
 			{
299 299
 				static::customise_mail_actions($child);
300 300
 			}
Please login to merge, or discard this patch.
api/src/Link/Sharing.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 	 * @param boolean $keep_session =null null: create a new session, true: try mounting it into existing (already verified) session
37 37
 	 * @return string with sessionid
38 38
 	 */
39
-	public static function create_session($keep_session=null)
39
+	public static function create_session($keep_session = null)
40 40
 	{
41 41
 		$share = array();
42 42
 		$success = static::check_token($keep_session, $share);
43
-		if($success)
43
+		if ($success)
44 44
 		{
45 45
 			static::setup_entry($share);
46 46
 			return static::login($keep_session, $share);
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
 				// Just email already filtered out
94 94
 				$documents['children'] = $documents['children']['message/rfc822']['children'];
95 95
 			}
96
-			foreach($documents['children'] as $key => &$document)
96
+			foreach ($documents['children'] as $key => &$document)
97 97
 			{
98
-				if(strpos($document['target'],'compose_') === FALSE)
98
+				if (strpos($document['target'], 'compose_') === FALSE)
99 99
 				{
100 100
 					unset($documents['children'][$key]);
101 101
 					continue;
Please login to merge, or discard this patch.
admin/inc/class.admin_cmd.inc.php 1 patch
Spacing   +124 added lines, -125 removed lines patch added patch discarded remove patch
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 	const successful = 2;
61 61
 	const failed     = 3;
62 62
 	const pending    = 4;
63
-	const queued     = 5;	// command waits to be fetched from remote
63
+	const queued     = 5; // command waits to be fetched from remote
64 64
 
65 65
 	/**
66 66
 	 * Status which stil need passwords available
67 67
 	 *
68 68
 	 * @var array
69 69
 	 */
70
-	static $require_pw_stati = array(self::scheduled,self::pending,self::queued);
70
+	static $require_pw_stati = array(self::scheduled, self::pending, self::queued);
71 71
 
72 72
 	/**
73 73
 	 * The status of the command, one of either scheduled, successful, failed or deleted
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @return string success message
154 154
 	 * @throws Exception()
155 155
 	 */
156
-	protected abstract function exec($check_only=false);
156
+	protected abstract function exec($check_only = false);
157 157
 
158 158
 	/**
159 159
 	 * Return a title / string representation for a given command, eg. to display it
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 
191 191
 		$this->type = get_class($this);
192 192
 
193
-		foreach($data as $name => $value)
193
+		foreach ($data as $name => $value)
194 194
 		{
195 195
 			$this->$name = $name == 'data' && !is_array($value) ? json_php_unserialize($value) : $value;
196 196
 		}
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
 	 * @return mixed return value of the command
210 210
 	 * @throws Exceptions on error
211 211
 	 */
212
-	function run($time=null,$set_modifier=true,$skip_checks=false,$dry_run=false)
212
+	function run($time = null, $set_modifier = true, $skip_checks = false, $dry_run = false)
213 213
 	{
214 214
 		if (!is_null($time))
215 215
 		{
216 216
 			$this->scheduled = $time;
217 217
 			$this->status = admin_cmd::scheduled;
218
-			$ret = lang('Command scheduled to run at %1',date('Y-m-d H:i',$time));
218
+			$ret = lang('Command scheduled to run at %1', date('Y-m-d H:i', $time));
219 219
 			// running the checks of the arguments for local commands, if not explicitly requested to not run them
220 220
 			if (!$this->remote_id && !$skip_checks)
221 221
 			{
@@ -281,21 +281,21 @@  discard block
 block discarded – undo
281 281
 	{
282 282
 		if (!($remote = $this->read_remote($this->remote_id)))
283 283
 		{
284
-			throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!',$this->remote_id),997);
284
+			throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!', $this->remote_id), 997);
285 285
 		}
286 286
 		if (!$this->uid)
287 287
 		{
288
-			$this->save();	// to get the uid
288
+			$this->save(); // to get the uid
289 289
 		}
290 290
 		$secret = md5($this->uid.$remote['remote_hash']);
291 291
 
292 292
 		$postdata = $this->as_array();
293 293
 		if (is_object($GLOBALS['egw']->translation))
294 294
 		{
295
-			$postdata = Api\Translation::convert($postdata,Api\Translation::charset(),'utf-8');
295
+			$postdata = Api\Translation::convert($postdata, Api\Translation::charset(), 'utf-8');
296 296
 		}
297 297
 		// dont send the id's which have no meaning on the remote install
298
-		foreach(array('id','creator','modifier','requested','remote_id') as $name)
298
+		foreach (array('id', 'creator', 'modifier', 'requested', 'remote_id') as $name)
299 299
 		{
300 300
 			unset($postdata[$name]);
301 301
 		}
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
 		}
322 322
 		if (is_object($GLOBALS['egw']->translation))
323 323
 		{
324
-			$message = Api\Translation::convert($message,'utf-8');
324
+			$message = Api\Translation::convert($message, 'utf-8');
325 325
 		}
326 326
 		$matches = null;
327
-		if (is_string($message) && preg_match('/^([0-9]+) (.*)$/',$message,$matches))
327
+		if (is_string($message) && preg_match('/^([0-9]+) (.*)$/', $message, $matches))
328 328
 		{
329
-			throw new Api\Exception($matches[2],(int)$matches[1]);
329
+			throw new Api\Exception($matches[2], (int)$matches[1]);
330 330
 		}
331 331
 		return $message;
332 332
 	}
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 * @param boolean $set_modifier =true set the current user as modifier or 0 (= run by the system)
353 353
 	 * @return boolean true on success, false otherwise
354 354
 	 */
355
-	function save($set_modifier=true)
355
+	function save($set_modifier = true)
356 356
 	{
357 357
 		admin_cmd::_instanciate_sql();
358 358
 
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 			$this->modifier = $set_modifier ? $GLOBALS['egw_info']['user']['account_id'] : 0;
368 368
 			if ($set_modifier) $this->modifier_email = admin_cmd::user_email();
369 369
 		}
370
-		$vars = get_object_vars($this);	// does not work in php5.1.2 due a bug
370
+		$vars = get_object_vars($this); // does not work in php5.1.2 due a bug
371 371
 
372 372
 		// data is stored serialized
373 373
 		// paswords are masked / removed, if we dont need them anymore
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 			$this->set_periodic_job();
407 407
 		}
408 408
 		// existing object with no rrule, cancle evtl. running periodic job
409
-		elseif($vars['id'])
409
+		elseif ($vars['id'])
410 410
 		{
411 411
 			$this->cancel_periodic_job();
412 412
 		}
@@ -420,13 +420,13 @@  discard block
 block discarded – undo
420 420
 	 * @param boolean $return_serialized =true true: return json serialized string, false: return array
421 421
 	 * @return string|array see $return_serialized
422 422
 	 */
423
-	static function mask_passwords($data, $return_serialized=true)
423
+	static function mask_passwords($data, $return_serialized = true)
424 424
 	{
425 425
 		if (!is_array($data))
426 426
 		{
427 427
 			$data = json_php_unserialize($data);
428 428
 		}
429
-		foreach($data as $key => &$value)
429
+		foreach ($data as $key => &$value)
430 430
 		{
431 431
 			if (is_array($value))
432 432
 			{
@@ -474,10 +474,10 @@  discard block
 block discarded – undo
474 474
 		{
475 475
 			$data['data'] = json_php_unserialize($data['data']);
476 476
 		}
477
-		if (!(class_exists($class = 'EGroupware\\'.$data['type']) ||	// namespaced class
477
+		if (!(class_exists($class = 'EGroupware\\'.$data['type']) || // namespaced class
478 478
 			class_exists($class = $data['type'])) || $data['type'] == 'admin_cmd')
479 479
 		{
480
-			throw new Api\Exception\WrongParameter(lang('Unknown command %1!',$class), 10);
480
+			throw new Api\Exception\WrongParameter(lang('Unknown command %1!', $class), 10);
481 481
 		}
482 482
 		$cmd = new $class($data);
483 483
 
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 		{
486 486
 			return $cmd;
487 487
 		}
488
-		throw new Api\Exception\WrongParameter(lang('%1 is no command!',$class), 10);
488
+		throw new Api\Exception\WrongParameter(lang('%1 is no command!', $class), 10);
489 489
 	}
490 490
 
491 491
 	/**
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 	 * @param array $readonlys
498 498
 	 * @return int
499 499
 	 */
500
-	static function get_rows($query,&$rows,$readonlys)
500
+	static function get_rows($query, &$rows, $readonlys)
501 501
 	{
502 502
 		admin_cmd::_instanciate_sql();
503 503
 
@@ -514,21 +514,21 @@  discard block
 block discarded – undo
514 514
 			$query['col_filter'][] = 'cmd_rrule IS NOT NULL';
515 515
 		}
516 516
 		unset($query['col_filter']['periodic']);
517
-		if($query['col_filter']['parent'])
517
+		if ($query['col_filter']['parent'])
518 518
 		{
519 519
 			$query['col_filter']['parent'] = (int)$query['col_filter']['parent'];
520 520
 		}
521 521
 
522
-		$total = admin_cmd::$sql->get_rows($query,$rows,$readonlys);
522
+		$total = admin_cmd::$sql->get_rows($query, $rows, $readonlys);
523 523
 
524 524
 		if (!$rows) return 0;
525 525
 
526 526
 		$async = new Api\Asyncservice();
527
-		foreach($rows as &$row)
527
+		foreach ($rows as &$row)
528 528
 		{
529 529
 			try {
530 530
 				$cmd = admin_cmd::instanciate($row);
531
-				$row['title'] = $cmd->__tostring();	// we call __tostring explicit, as a cast to string requires php5.2+
531
+				$row['title'] = $cmd->__tostring(); // we call __tostring explicit, as a cast to string requires php5.2+
532 532
 			}
533 533
 			catch (Exception $e) {
534 534
 				$row['title'] = $e->getMessage();
@@ -536,25 +536,24 @@  discard block
 block discarded – undo
536 536
 
537 537
 			$row['value'] = $cmd->value;
538 538
 
539
-			if(method_exists($cmd, 'summary'))
539
+			if (method_exists($cmd, 'summary'))
540 540
 			{
541 541
 				$row['data'] = $cmd->summary();
542 542
 			}
543 543
 			else
544 544
 			{
545
-				$row['data'] = !($data = json_php_unserialize($row['data'])) ? '' :
546
-					json_encode($data+(empty($row['rrule'])?array():array('rrule' => $row['rrule'])),
545
+				$row['data'] = !($data = json_php_unserialize($row['data'])) ? '' : json_encode($data + (empty($row['rrule']) ? array() : array('rrule' => $row['rrule'])),
547 546
 						JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
548 547
 			}
549
-			if($row['rrule'])
548
+			if ($row['rrule'])
550 549
 			{
551
-				$rrule = calendar_rrule::event2rrule(calendar_rrule::parseRrule($row['rrule'],true)+array(
550
+				$rrule = calendar_rrule::event2rrule(calendar_rrule::parseRrule($row['rrule'], true) + array(
552 551
 					'start' => time(),
553 552
 					'tzid'=> Api\DateTime::$server_timezone->getName()
554 553
 				));
555 554
 				$row['rrule'] = ''.$rrule;
556 555
 			}
557
-			if(!$row['scheduled'] && $cmd && $cmd->async_job_id)
556
+			if (!$row['scheduled'] && $cmd && $cmd->async_job_id)
558 557
 			{
559 558
 				$job = $async->read($cmd->async_job_id);
560 559
 
@@ -580,11 +579,11 @@  discard block
 block discarded – undo
580 579
 			admin_cmd::_instanciate_sql();
581 580
 
582 581
 			// Need a new one to avoid column name modification
583
-			$sql = new Api\Storage\Base('admin','egw_admin_queue',null);
582
+			$sql = new Api\Storage\Base('admin', 'egw_admin_queue', null);
584 583
 			$labels = $sql->query_list('cmd_type');
585 584
 
586 585
 			// for admin app we also add all available cmd objects
587
-			foreach(scandir(__DIR__) as $file)
586
+			foreach (scandir(__DIR__) as $file)
588 587
 			{
589 588
 				$matches = null;
590 589
 				if (preg_match('/^class\.(admin_cmd_.*)\.inc\.php$/', $file, $matches))
@@ -595,15 +594,15 @@  discard block
 block discarded – undo
595 594
 					}
596 595
 				}
597 596
 			}
598
-			foreach($labels as $class => &$label)
597
+			foreach ($labels as $class => &$label)
599 598
 			{
600
-				if(class_exists($class))
599
+				if (class_exists($class))
601 600
 				{
602 601
 					$label = $class::name();
603 602
 				}
604
-				elseif (class_exists('EGroupware\\' . $class))
603
+				elseif (class_exists('EGroupware\\'.$class))
605 604
 				{
606
-					$class = 'EGroupware\\' . $class;
605
+					$class = 'EGroupware\\'.$class;
607 606
 					$label = $class::name();
608 607
 				}
609 608
 			}
@@ -634,11 +633,11 @@  discard block
 block discarded – undo
634 633
 	 * @param array $filter =null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards
635 634
 	 * @return array
636 635
 	 */
637
-	static function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null)
636
+	static function &search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter = null)
638 637
 	{
639 638
 		admin_cmd::_instanciate_sql();
640 639
 
641
-		return admin_cmd::$sql->search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter);
640
+		return admin_cmd::$sql->search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter);
642 641
 	}
643 642
 
644 643
 	/**
@@ -650,7 +649,7 @@  discard block
 block discarded – undo
650 649
 	{
651 650
 		if (is_null(admin_cmd::$sql))
652 651
 		{
653
-			admin_cmd::$sql = new Api\Storage\Base('admin','egw_admin_queue',null,'cmd_');
652
+			admin_cmd::$sql = new Api\Storage\Base('admin', 'egw_admin_queue', null, 'cmd_');
654 653
 		}
655 654
 	}
656 655
 
@@ -663,7 +662,7 @@  discard block
 block discarded – undo
663 662
 	{
664 663
 		if (is_null(admin_cmd::$remote))
665 664
 		{
666
-			admin_cmd::$remote = new Api\Storage\Base('admin','egw_admin_remote');
665
+			admin_cmd::$remote = new Api\Storage\Base('admin', 'egw_admin_remote');
667 666
 		}
668 667
 	}
669 668
 
@@ -675,11 +674,11 @@  discard block
 block discarded – undo
675 674
 	 */
676 675
 	function __get($property)
677 676
 	{
678
-		if (property_exists('admin_cmd',$property))
677
+		if (property_exists('admin_cmd', $property))
679 678
 		{
680
-			return $this->$property;	// making all (non static) class vars readonly available
679
+			return $this->$property; // making all (non static) class vars readonly available
681 680
 		}
682
-		switch($property)
681
+		switch ($property)
683 682
 		{
684 683
 			case 'accounts':
685 684
 				self::_instanciate_accounts();
@@ -698,9 +697,9 @@  discard block
 block discarded – undo
698 697
 	 */
699 698
 	function __isset($property)
700 699
 	{
701
-		if (property_exists('admin_cmd',$property))
700
+		if (property_exists('admin_cmd', $property))
702 701
 		{
703
-			return isset($this->$property);	// making all (non static) class vars readonly available
702
+			return isset($this->$property); // making all (non static) class vars readonly available
704 703
 		}
705 704
 		return isset($this->data[$property]);
706 705
 	}
@@ -712,7 +711,7 @@  discard block
 block discarded – undo
712 711
 	 * @param mixed $value
713 712
 	 * @return mixed
714 713
 	 */
715
-	function __set($property,$value)
714
+	function __set($property, $value)
716 715
 	{
717 716
 		$this->data[$property] = $value;
718 717
 	}
@@ -734,19 +733,19 @@  discard block
 block discarded – undo
734 733
 	 */
735 734
 	function as_array()
736 735
 	{
737
-		if (version_compare(PHP_VERSION,'5.1.2','>'))
736
+		if (version_compare(PHP_VERSION, '5.1.2', '>'))
738 737
 		{
739
-			$vars = get_object_vars($this);	// does not work in php5.1.2 due a bug
738
+			$vars = get_object_vars($this); // does not work in php5.1.2 due a bug
740 739
 		}
741 740
 		else
742 741
 		{
743
-			foreach(array_keys(get_class_vars(__CLASS__)) as $name)
742
+			foreach (array_keys(get_class_vars(__CLASS__)) as $name)
744 743
 			{
745 744
 				$vars[$name] = $this->$name;
746 745
 			}
747 746
 		}
748 747
 		unset($vars['data']);
749
-		if ($this->data) $vars = array_merge($this->data,$vars);
748
+		if ($this->data) $vars = array_merge($this->data, $vars);
750 749
 
751 750
 		return $vars;
752 751
 	}
@@ -758,14 +757,14 @@  discard block
 block discarded – undo
758 757
 	 * @param int $extra_deny =null further admin rights to check, eg. 16 = deny edit Api\Accounts
759 758
 	 * @throws Api\Exception\NoPermission\Admin
760 759
 	 */
761
-	protected function _check_admin($extra_acl=null,$extra_deny=null)
760
+	protected function _check_admin($extra_acl = null, $extra_deny = null)
762 761
 	{
763 762
 		if ($this->creator)
764 763
 		{
765 764
 			admin_cmd::_instanciate_acl($this->creator);
766 765
 			// todo: check only if and with $this->creator
767
-			if (!admin_cmd::$acl->check('run',1,'admin') &&		// creator is no longer admin
768
-				$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin'))	// creator is explicitly forbidden to do something
766
+			if (!admin_cmd::$acl->check('run', 1, 'admin') && // creator is no longer admin
767
+				$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl, $extra_deny, 'admin'))	// creator is explicitly forbidden to do something
769 768
 			{
770 769
 				throw new Api\Exception\NoPermission\Admin();
771 770
 			}
@@ -781,13 +780,13 @@  discard block
 block discarded – undo
781 780
 	 */
782 781
 	static function parse_apps(array $apps)
783 782
 	{
784
-		foreach($apps as $key => $name)
783
+		foreach ($apps as $key => $name)
785 784
 		{
786 785
 			if (!isset($GLOBALS['egw_info']['apps'][$name]))
787 786
 			{
788
-				foreach($GLOBALS['egw_info']['apps'] as $app => $data)	// check against title and localised name
787
+				foreach ($GLOBALS['egw_info']['apps'] as $app => $data)	// check against title and localised name
789 788
 				{
790
-					if (!strcasecmp($name,$data['title']) || !strcasecmp($name,lang($app)))
789
+					if (!strcasecmp($name, $data['title']) || !strcasecmp($name, lang($app)))
791 790
 					{
792 791
 						$apps[$key] = $name = $app;
793 792
 						break;
@@ -796,7 +795,7 @@  discard block
 block discarded – undo
796 795
 			}
797 796
 			if (!isset($GLOBALS['egw_info']['apps'][$name]))
798 797
 			{
799
-				throw new Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8);
798
+				throw new Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!", $name), 8);
800 799
 			}
801 800
 		}
802 801
 		return $apps;
@@ -811,20 +810,20 @@  discard block
 block discarded – undo
811 810
 	 * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account), 15);
812 811
 	 * @throws Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')), 16);
813 812
 	 */
814
-	static function parse_account($account,$allow_only_user=null)
813
+	static function parse_account($account, $allow_only_user = null)
815 814
 	{
816 815
 		admin_cmd::_instanciate_accounts();
817 816
 
818 817
 		if (!($type = admin_cmd::$accounts->exists($account)) ||
819
-			!is_numeric($id=$account) && !($id = admin_cmd::$accounts->name2id($account)))
818
+			!is_numeric($id = $account) && !($id = admin_cmd::$accounts->name2id($account)))
820 819
 		{
821
-			throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account), 15);
820
+			throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!", $account), 15);
822 821
 		}
823 822
 		if (!is_null($allow_only_user) && $allow_only_user !== ($type == 1))
824 823
 		{
825
-			throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')), 16);
824
+			throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!", $account, $allow_only_user ?lang('user') : lang('group')), 16);
826 825
 		}
827
-		if ($type == 2 && $id > 0) $id = -$id;	// groups use negative id's internally, fix it, if user given the wrong sign
826
+		if ($type == 2 && $id > 0) $id = -$id; // groups use negative id's internally, fix it, if user given the wrong sign
828 827
 
829 828
 		return $id;
830 829
 	}
@@ -838,14 +837,14 @@  discard block
 block discarded – undo
838 837
 	 * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account), 15);
839 838
 	 * @throws Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only?lang('user'):lang('group')), 16);
840 839
 	 */
841
-	static function parse_accounts($accounts,$allow_only_user=null)
840
+	static function parse_accounts($accounts, $allow_only_user = null)
842 841
 	{
843 842
 		if (!$accounts) return null;
844 843
 
845 844
 		$ids = array();
846
-		foreach(is_array($accounts) ? $accounts : explode(',',$accounts) as $account)
845
+		foreach (is_array($accounts) ? $accounts : explode(',', $accounts) as $account)
847 846
 		{
848
-			$ids[] = admin_cmd::parse_account($account,$allow_only_user);
847
+			$ids[] = admin_cmd::parse_account($account, $allow_only_user);
849 848
 		}
850 849
 		return $ids;
851 850
 	}
@@ -863,11 +862,11 @@  discard block
 block discarded – undo
863 862
 		{
864 863
 			$datein = $date;
865 864
 			// convert german DD.MM.YYYY format into ISO YYYY-MM-DD format
866
-			$date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/','\3-\2-\1',$date);
865
+			$date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/', '\3-\2-\1', $date);
867 866
 
868
-			if (($date = strtotime($date))  === false)
867
+			if (($date = strtotime($date)) === false)
869 868
 			{
870
-				throw new Api\Exception\WrongUserinput(lang('Invalid formated date "%1"!',$datein),6);
869
+				throw new Api\Exception\WrongUserinput(lang('Invalid formated date "%1"!', $datein), 6);
871 870
 			}
872 871
 		}
873 872
 		return (int)$date;
@@ -881,7 +880,7 @@  discard block
 block discarded – undo
881 880
 	 * @return boolean
882 881
 	 * @throws Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!',$value),998);
883 882
 	 */
884
-	static function parse_boolean($value,$default=null)
883
+	static function parse_boolean($value, $default = null)
885 884
 	{
886 885
 		if (is_bool($value) || is_int($value))
887 886
 		{
@@ -891,15 +890,15 @@  discard block
 block discarded – undo
891 890
 		{
892 891
 			return $default;
893 892
 		}
894
-		if (in_array($value,array('1','yes','true',lang('yes'),lang('true'))))
893
+		if (in_array($value, array('1', 'yes', 'true', lang('yes'), lang('true'))))
895 894
 		{
896 895
 			return true;
897 896
 		}
898
-		if (in_array($value,array('0','no','false',lang('no'),lang('false'))))
897
+		if (in_array($value, array('0', 'no', 'false', lang('no'), lang('false'))))
899 898
 		{
900 899
 			return false;
901 900
 		}
902
-		throw new Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!',$value),998);
901
+		throw new Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!', $value), 998);
903 902
 	}
904 903
 
905 904
 	/**
@@ -917,9 +916,9 @@  discard block
 block discarded – undo
917 916
 			'remote_id' => $id_or_name,
918 917
 			'remote_name' => $id_or_name,
919 918
 			'remote_domain' => $id_or_name,
920
-		),true,'','','',false,'OR')) || count($remotes) != 1)
919
+		), true, '', '', '', false, 'OR')) || count($remotes) != 1)
921 920
 		{
922
-			throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!',$id_or_name),997);
921
+			throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!', $id_or_name), 997);
923 922
 		}
924 923
 		return $remotes[0]['remote_id'];
925 924
 	}
@@ -936,7 +935,7 @@  discard block
 block discarded – undo
936 935
 		{
937 936
 			if (!is_object($GLOBALS['egw']->accounts))
938 937
 			{
939
-				throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated','accounts'),999);
938
+				throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated', 'accounts'), 999);
940 939
 			}
941 940
 			admin_cmd::$accounts = $GLOBALS['egw']->accounts;
942 941
 		}
@@ -949,13 +948,13 @@  discard block
 block discarded – undo
949 948
 	 * @param int $account =null account_id the class needs to be instanciated for, default need only account-independent methods
950 949
 	 * @throws Api\Exception\AssertionFailed(lang('%1 class not instanciated','acl'),999);
951 950
 	 */
952
-	protected function _instanciate_acl($account=null)
951
+	protected function _instanciate_acl($account = null)
953 952
 	{
954 953
 		if (!is_object(admin_cmd::$acl) || $account && admin_cmd::$acl->account_id != $account)
955 954
 		{
956 955
 			if (!is_object($GLOBALS['egw']->acl))
957 956
 			{
958
-				throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated','acl'),999);
957
+				throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated', 'acl'), 999);
959 958
 			}
960 959
 			if ($account && $GLOBALS['egw']->acl->account_id != $account)
961 960
 			{
@@ -975,20 +974,20 @@  discard block
 block discarded – undo
975 974
 	 * @param $account_id =null account_id, default current user
976 975
 	 * @return string
977 976
 	 */
978
-	static function user_email($account_id=null)
977
+	static function user_email($account_id = null)
979 978
 	{
980 979
 		if ($account_id)
981 980
 		{
982 981
 			admin_cmd::_instanciate_accounts();
983
-			$fullname = admin_cmd::$accounts->id2name($account_id,'account_fullname');
984
-			$email = admin_cmd::$accounts->id2name($account_id,'account_email');
982
+			$fullname = admin_cmd::$accounts->id2name($account_id, 'account_fullname');
983
+			$email = admin_cmd::$accounts->id2name($account_id, 'account_email');
985 984
 		}
986 985
 		else
987 986
 		{
988 987
 			$fullname = $GLOBALS['egw_info']['user']['account_fullname'];
989 988
 			$email = $GLOBALS['egw_info']['user']['account_email'];
990 989
 		}
991
-		return $fullname . ($email ? ' <'.$email.'>' : '');
990
+		return $fullname.($email ? ' <'.$email.'>' : '');
992 991
 	}
993 992
 
994 993
 	/**
@@ -1012,11 +1011,11 @@  discard block
 block discarded – undo
1012 1011
 		{
1013 1012
 			return false;
1014 1013
 		}
1015
-		if (!($jobs = admin_cmd::search(array(),false,'cmd_scheduled','','',false,'AND',array(0,1),array(
1014
+		if (!($jobs = admin_cmd::search(array(), false, 'cmd_scheduled', '', '', false, 'AND', array(0, 1), array(
1016 1015
 			'cmd_status' => admin_cmd::scheduled,
1017 1016
 		))))
1018 1017
 		{
1019
-			return false;		// no schduled command, no need to setup the job
1018
+			return false; // no schduled command, no need to setup the job
1020 1019
 		}
1021 1020
 		$next = $jobs[0];
1022 1021
 		if (($time = $next['scheduled']) < time())	// should run immediatly
@@ -1026,11 +1025,11 @@  discard block
 block discarded – undo
1026 1025
 		$async = new Api\Asyncservice();
1027 1026
 
1028 1027
 		// we cant use this class as callback, as it's abstract and ExecMethod used by the async service instanciated the class!
1029
-		list($app) = explode('_',$class=$next['type']);
1028
+		list($app) = explode('_', $class = $next['type']);
1030 1029
 		$callback = $app.'.'.$class.'.run_queued_jobs';
1031 1030
 
1032
-		$async->cancel_timer(admin_cmd::async_job_id);	// we delete it in case a job already exists
1033
-		return $async->set_timer($time,admin_cmd::async_job_id,$callback,null,$next['creator']);
1031
+		$async->cancel_timer(admin_cmd::async_job_id); // we delete it in case a job already exists
1032
+		return $async->set_timer($time, admin_cmd::async_job_id, $callback, null, $next['creator']);
1034 1033
 	}
1035 1034
 
1036 1035
 	/**
@@ -1040,20 +1039,20 @@  discard block
 block discarded – undo
1040 1039
 	 */
1041 1040
 	static function run_queued_jobs()
1042 1041
 	{
1043
-		if (!($jobs = admin_cmd::search(array(),false,'cmd_scheduled','','',false,'AND',false,array(
1042
+		if (!($jobs = admin_cmd::search(array(), false, 'cmd_scheduled', '', '', false, 'AND', false, array(
1044 1043
 			'cmd_status' => admin_cmd::scheduled,
1045 1044
 			'cmd_scheduled <= '.time(),
1046 1045
 		))))
1047 1046
 		{
1048
-			return false;		// no schduled commands, no need to setup the job
1047
+			return false; // no schduled commands, no need to setup the job
1049 1048
 		}
1050
-		admin_cmd::$running_queued_jobs = true;	// stop admin_cmd::run() which calls admin_cmd::save() to install a new job
1049
+		admin_cmd::$running_queued_jobs = true; // stop admin_cmd::run() which calls admin_cmd::save() to install a new job
1051 1050
 
1052
-		foreach($jobs as $job)
1051
+		foreach ($jobs as $job)
1053 1052
 		{
1054 1053
 			try {
1055 1054
 				$cmd = admin_cmd::instanciate($job);
1056
-				$cmd->run(null,false);	// false = dont set current user as modifier, as job is run by the queue/system itself
1055
+				$cmd->run(null, false); // false = dont set current user as modifier, as job is run by the queue/system itself
1057 1056
 			}
1058 1057
 			catch (Exception $e) {	// we need to mark that command as failed, to prevent further execution
1059 1058
 				_egw_log_exception($e);
@@ -1083,13 +1082,13 @@  discard block
 block discarded – undo
1083 1082
 		if (empty($this->rrule)) return false;
1084 1083
 
1085 1084
 		// parse rrule and calculate next execution time
1086
-		$event = calendar_rrule::parseRrule($this->rrule, true);	// true: allow HOURLY or MINUTELY
1085
+		$event = calendar_rrule::parseRrule($this->rrule, true); // true: allow HOURLY or MINUTELY
1087 1086
 		// rrule can depend on start-time, use policy creation time by default, if rrule_start is not set
1088 1087
 		$event['start'] = empty($this->rrule_start) ? $this->created : $this->rrule_start;
1089 1088
 		$event['tzid'] = Api\DateTime::$server_timezone->getName();
1090
-		$rrule = calendar_rrule::event2rrule($event, false);	// false = server timezone
1089
+		$rrule = calendar_rrule::event2rrule($event, false); // false = server timezone
1091 1090
 		$rrule->rewind();
1092
-		while((($time = $rrule->current()->format('ts'))) <= time())
1091
+		while ((($time = $rrule->current()->format('ts'))) <= time())
1093 1092
 		{
1094 1093
 			$rrule->next();
1095 1094
 		}
@@ -1097,7 +1096,7 @@  discard block
 block discarded – undo
1097 1096
 		// schedule run_periodic_job to run at that time
1098 1097
 		$async = new Api\Asyncservice();
1099 1098
 		$job_id = empty($this->async_job_id) ? self::PERIOD_ASYNC_ID_PREFIX.$this->id : $this->async_job_id;
1100
-		$async->cancel_timer($job_id);	// we delete it in case a job already exists
1099
+		$async->cancel_timer($job_id); // we delete it in case a job already exists
1101 1100
 		return $async->set_timer($time, $job_id, __CLASS__.'::run_periodic_job', $this->as_array(), $this->creator);
1102 1101
 	}
1103 1102
 
@@ -1110,7 +1109,7 @@  discard block
 block discarded – undo
1110 1109
 	{
1111 1110
 		$async = new Api\Asyncservice();
1112 1111
 		$job_id = empty($this->async_job_id) ? self::PERIOD_ASYNC_ID_PREFIX.$this->id : $this->async_job_id;
1113
-		$async->cancel_timer($job_id);	// we delete it in case a job already exists
1112
+		$async->cancel_timer($job_id); // we delete it in case a job already exists
1114 1113
 	}
1115 1114
 
1116 1115
 	/**
@@ -1127,9 +1126,9 @@  discard block
 block discarded – undo
1127 1126
 		$single = $cmd->as_array();
1128 1127
 		$single['parent'] = $single['id'];
1129 1128
 		$single = array_diff_key($single, array(
1130
-			'id','uid',
1131
-			'created','modified','modifier',
1132
-			'async_job_id','rrule','scheduled',
1129
+			'id', 'uid',
1130
+			'created', 'modified', 'modifier',
1131
+			'async_job_id', 'rrule', 'scheduled',
1133 1132
 			'status', 'set', 'old'
1134 1133
 		));
1135 1134
 
@@ -1156,9 +1155,9 @@  discard block
 block discarded – undo
1156 1155
 		admin_cmd::_instanciate_remote();
1157 1156
 
1158 1157
 		$sites = array(lang('local'));
1159
-		if (($remote = admin_cmd::$remote->query_list('remote_name','remote_id')))
1158
+		if (($remote = admin_cmd::$remote->query_list('remote_name', 'remote_id')))
1160 1159
 		{
1161
-			$sites = array_merge($sites,$remote);
1160
+			$sites = array_merge($sites, $remote);
1162 1161
 		}
1163 1162
 		return $sites;
1164 1163
 	}
@@ -1171,11 +1170,11 @@  discard block
 block discarded – undo
1171 1170
 	 * @param array &$readonlys
1172 1171
 	 * @return int
1173 1172
 	 */
1174
-	static function get_remotes($query,&$rows,&$readonlys)
1173
+	static function get_remotes($query, &$rows, &$readonlys)
1175 1174
 	{
1176 1175
 		admin_cmd::_instanciate_remote();
1177 1176
 
1178
-		return admin_cmd::$remote->get_rows($query,$rows,$readonlys);
1177
+		return admin_cmd::$remote->get_rows($query, $rows, $readonlys);
1179 1178
 	}
1180 1179
 
1181 1180
 	/**
@@ -1203,7 +1202,7 @@  discard block
 block discarded – undo
1203 1202
 
1204 1203
 		if ($data['install_id'] && $data['config_passwd'])	// calculate hash
1205 1204
 		{
1206
-			$data['remote_hash'] = self::remote_hash($data['install_id'],$data['config_passwd']);
1205
+			$data['remote_hash'] = self::remote_hash($data['install_id'], $data['config_passwd']);
1207 1206
 		}
1208 1207
 		elseif (!$data['remote_hash'] && !($data['install_id'] && $data['config_passwd']))
1209 1208
 		{
@@ -1215,12 +1214,12 @@  discard block
 block discarded – undo
1215 1214
 		// check if a unique key constrain would be violated by saving the entry
1216 1215
 		if (($num = admin_cmd::$remote->not_unique()))
1217 1216
 		{
1218
-			$col = admin_cmd::$remote->table_def['uc'][$num-1];	// $num is 1 based!
1219
-			throw new egw_exception_db_not_unique(lang('Value for column %1 is not unique!',$this->table_name.'.'.$col),$num);
1217
+			$col = admin_cmd::$remote->table_def['uc'][$num - 1]; // $num is 1 based!
1218
+			throw new egw_exception_db_not_unique(lang('Value for column %1 is not unique!', $this->table_name.'.'.$col), $num);
1220 1219
 		}
1221 1220
 		if (admin_cmd::$remote->save() != 0)
1222 1221
 		{
1223
-			throw new Api\Db\Exception(lang('Error saving to db:').' '.$this->sql->db->Error.' ('.$this->sql->db->Errno.')',$this->sql->db->Errno);
1222
+			throw new Api\Db\Exception(lang('Error saving to db:').' '.$this->sql->db->Error.' ('.$this->sql->db->Errno.')', $this->sql->db->Errno);
1224 1223
 		}
1225 1224
 		return admin_cmd::$remote->data['remote_id'];
1226 1225
 	}
@@ -1232,11 +1231,11 @@  discard block
 block discarded – undo
1232 1231
 	 * @param string $config_passwd
1233 1232
 	 * @return string 32char md5 hash
1234 1233
 	 */
1235
-	static function remote_hash($install_id,$config_passwd)
1234
+	static function remote_hash($install_id, $config_passwd)
1236 1235
 	{
1237 1236
 		if (empty($config_passwd) || !self::is_md5($install_id))
1238 1237
 		{
1239
-			throw new Api\Exception\WrongParameter(empty($config_passwd)?'Empty Api\Config password':'install_id no md5 hash');
1238
+			throw new Api\Exception\WrongParameter(empty($config_passwd) ? 'Empty Api\Config password' : 'install_id no md5 hash');
1240 1239
 		}
1241 1240
 		if (!self::is_md5($config_passwd)) $config_passwd = md5($config_passwd);
1242 1241
 
@@ -1266,7 +1265,7 @@  discard block
 block discarded – undo
1266 1265
 	 */
1267 1266
 	static function is_md5($str)
1268 1267
 	{
1269
-		return preg_match('/^[0-9a-f]{32}$/',$str);
1268
+		return preg_match('/^[0-9a-f]{32}$/', $str);
1270 1269
 	}
1271 1270
 
1272 1271
 	/**
@@ -1283,26 +1282,26 @@  discard block
 block discarded – undo
1283 1282
 	 * @param string $config_passwd of the current domain
1284 1283
 	 * @throws Api\Exception\NoPermission
1285 1284
 	 */
1286
-	function check_remote_access($secret,$config_passwd)
1285
+	function check_remote_access($secret, $config_passwd)
1287 1286
 	{
1288 1287
 		// as a security measure remote administration need to be enabled under Admin > Site configuration
1289
-		list(,$remote_admin_install_id) = explode('-',$this->uid);
1290
-		$allowed_remote_admin_ids = $GLOBALS['egw_info']['server']['allow_remote_admin'] ? explode(',',$GLOBALS['egw_info']['server']['allow_remote_admin']) : array();
1288
+		list(,$remote_admin_install_id) = explode('-', $this->uid);
1289
+		$allowed_remote_admin_ids = $GLOBALS['egw_info']['server']['allow_remote_admin'] ? explode(',', $GLOBALS['egw_info']['server']['allow_remote_admin']) : array();
1291 1290
 
1292 1291
 		// to authenticate with the installation we use a secret, which is a md5 hash build from the uid
1293 1292
 		// of the command (to not allow to send new commands with an earsdroped secret) and the md5 hash
1294 1293
 		// of the md5 hash of the Api\Config password and the install_id (egw_admin_remote.remote_hash)
1295
-		if (is_null($config_passwd) || is_numeric($this->uid) || !in_array($remote_admin_install_id,$allowed_remote_admin_ids) ||
1296
-			$secret != ($md5=md5($this->uid.$this->remote_hash($GLOBALS['egw_info']['server']['install_id'],$config_passwd))))
1294
+		if (is_null($config_passwd) || is_numeric($this->uid) || !in_array($remote_admin_install_id, $allowed_remote_admin_ids) ||
1295
+			$secret != ($md5 = md5($this->uid.$this->remote_hash($GLOBALS['egw_info']['server']['install_id'], $config_passwd))))
1297 1296
 		{
1298 1297
 			//die("secret='$secret' != '$md5', is_null($config_passwd)=".is_null($config_passwd).", uid=$this->uid, remote_install_id=$remote_admin_install_id, allowed: ".implode(', ',$allowed_remote_admin_ids));
1299 1298
 			unset($md5);
1300 1299
 			$msg = lang('Permission denied!');
1301
-			if (!in_array($remote_admin_install_id,$allowed_remote_admin_ids))
1300
+			if (!in_array($remote_admin_install_id, $allowed_remote_admin_ids))
1302 1301
 			{
1303 1302
 				$msg .= "\n".lang('Remote administration need to be enabled in the remote instance under Admin > Site configuration!');
1304 1303
 			}
1305
-			throw new Api\Exception\NoPermission($msg,0);
1304
+			throw new Api\Exception\NoPermission($msg, 0);
1306 1305
 		}
1307 1306
 	}
1308 1307
 
@@ -1312,7 +1311,7 @@  discard block
 block discarded – undo
1312 1311
 	 * @param int $len =16
1313 1312
 	 * @return string
1314 1313
 	 */
1315
-	static function randomstring($len=16)
1314
+	static function randomstring($len = 16)
1316 1315
 	{
1317 1316
 		return Api\Auth::randomstring($len);
1318 1317
 	}
@@ -1334,7 +1333,7 @@  discard block
 block discarded – undo
1334 1333
 	 */
1335 1334
 	protected function get_etemplate()
1336 1335
 	{
1337
-		static $tpl = null;	// some caching to not instanciate it twice
1336
+		static $tpl = null; // some caching to not instanciate it twice
1338 1337
 
1339 1338
 		if (!isset($tpl))
1340 1339
 		{
@@ -1364,7 +1363,7 @@  discard block
 block discarded – undo
1364 1363
 		{
1365 1364
 			$tpl->run(function($cname, $expand, $widget) use (&$labels, &$label)
1366 1365
 			{
1367
-				switch($widget->type)
1366
+				switch ($widget->type)
1368 1367
 				{
1369 1368
 					// remember label from last description widget
1370 1369
 					case 'description':
@@ -1407,7 +1406,7 @@  discard block
 block discarded – undo
1407 1406
 		{
1408 1407
 			$tpl->run(function($cname, $expand, $widget) use (&$widgets, &$last_select, $selectboxes)
1409 1408
 			{
1410
-				switch($widget->type)
1409
+				switch ($widget->type)
1411 1410
 				{
1412 1411
 					// ignore non input-widgets
1413 1412
 					case 'hbox': case 'vbox': case 'box': case 'groupbox':
@@ -1459,12 +1458,12 @@  discard block
 block discarded – undo
1459 1458
 	 */
1460 1459
 	public function get_result()
1461 1460
 	{
1462
-		if($this->result)
1461
+		if ($this->result)
1463 1462
 		{
1464 1463
 			return is_array($this->result) ? implode("\n", $this->result) : $this->result;
1465 1464
 		}
1466 1465
 		return lang("Command was run %1 on %2",
1467
-				static::$stati[ $this->status ],
1466
+				static::$stati[$this->status],
1468 1467
 				Api\DateTime::to($this->created));
1469 1468
 	}
1470 1469
 }
Please login to merge, or discard this patch.