Completed
Push — 16.1 ( 7ccc73...046888 )
by Nathan
64:46 queued 51:15
created
admin/inc/class.admin_import_users_csv.inc.php 4 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -275,37 +275,37 @@
 block discarded – undo
275 275
 	}
276 276
 
277 277
 	/**
278
-	* Returns warnings that were encountered during importing
279
-	* Maximum of one warning message per record, but you can concatenate them if you need to
280
-	*
281
-	* @return Array (
282
-	*       record_# => warning message
283
-	*       )
284
-	*/
278
+	 * Returns warnings that were encountered during importing
279
+	 * Maximum of one warning message per record, but you can concatenate them if you need to
280
+	 *
281
+	 * @return Array (
282
+	 *       record_# => warning message
283
+	 *       )
284
+	 */
285 285
 	public function get_warnings() {
286 286
 		return $this->warnings;
287 287
 	}
288 288
 
289 289
 	/**
290
-	* Returns errors that were encountered during importing
291
-	* Maximum of one error message per record, but you can append if you need to
292
-	*
293
-	* @return Array (
294
-	*       record_# => error message
295
-	*       )
296
-	*/
290
+	 * Returns errors that were encountered during importing
291
+	 * Maximum of one error message per record, but you can append if you need to
292
+	 *
293
+	 * @return Array (
294
+	 *       record_# => error message
295
+	 *       )
296
+	 */
297 297
 	public function get_errors() {
298 298
 		return $this->errors;
299 299
 	}
300 300
 
301 301
 	/**
302
-	* Returns a list of actions taken, and the number of records for that action.
303
-	* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
304
-	*
305
-	* @return Array (
306
-	*       action => record count
307
-	* )
308
-	*/
302
+	 * Returns a list of actions taken, and the number of records for that action.
303
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
304
+	 *
305
+	 * @return Array (
306
+	 *       action => record count
307
+	 * )
308
+	 */
309 309
 	public function get_results() {
310 310
 		return $this->results;
311 311
 	}
Please login to merge, or discard this patch.
Braces   +71 added lines, -29 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * class import_csv for admin (users)
17 17
  */
18
-class admin_import_users_csv implements importexport_iface_import_plugin  {
18
+class admin_import_users_csv implements importexport_iface_import_plugin
19
+{
19 20
 
20 21
 	private static $plugin_options = array(
21 22
 		'fieldsep', 		// char
@@ -90,7 +91,8 @@  discard block
 block discarded – undo
90 91
 	 * @param string $_charset
91 92
 	 * @param definition $_definition
92 93
 	 */
93
-	public function import( $_stream, importexport_definition $_definition ) {
94
+	public function import( $_stream, importexport_definition $_definition )
95
+	{
94 96
 		$import_csv = new importexport_import_csv( $_stream, array(
95 97
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
96 98
 			'charset' => $_definition->plugin_options['charset'],
@@ -112,9 +114,12 @@  discard block
 block discarded – undo
112 114
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
113 115
 
114 116
 		//check if file has a header lines
115
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
117
+		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0)
118
+		{
116 119
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
117
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
120
+		}
121
+		elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line'])
122
+		{
118 123
 			// First method is preferred
119 124
 			$import_csv->skip_records(1);
120 125
 		}
@@ -130,17 +135,27 @@  discard block
 block discarded – undo
130 135
 			'account_status'	=> array('A' => lang('Active'), '' => lang('Disabled'), 'D' => lang('Disabled')),
131 136
 		);
132 137
 
133
-		while ( $record = $import_csv->get_record() ) {
138
+		while ( $record = $import_csv->get_record() )
139
+		{
134 140
 			$success = false;
135 141
 			// don't import empty records
136
-			if( count( array_unique( $record ) ) < 2 ) continue;
142
+			if( count( array_unique( $record ) ) < 2 )
143
+			{
144
+				continue;
145
+			}
137 146
 
138
-			if(strtolower($record['account_expires']) == 'never') $record['account_expires'] = -1;
147
+			if(strtolower($record['account_expires']) == 'never')
148
+			{
149
+				$record['account_expires'] = -1;
150
+			}
139 151
 			importexport_import_csv::convert($record, admin_egw_user_record::$types, 'admin', $lookups);
140 152
 
141
-			if ( $_definition->plugin_options['conditions'] ) {
142
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
143
-					switch ( $condition['type'] ) {
153
+			if ( $_definition->plugin_options['conditions'] )
154
+			{
155
+				foreach ( $_definition->plugin_options['conditions'] as $condition )
156
+				{
157
+					switch ( $condition['type'] )
158
+					{
144 159
 						// exists
145 160
 						case 'exists' :
146 161
 							$accounts = array();
@@ -156,16 +171,23 @@  discard block
 block discarded – undo
156 171
 							// Search looks in the given field, but doesn't do an exact match
157 172
 							foreach ( (array)$accounts as $key => $account )
158 173
 							{
159
-								if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]);
174
+								if($account[$condition['string']] != $record[$condition['string']])
175
+								{
176
+									unset($accounts[$key]);
177
+								}
160 178
 							}
161
-							if ( is_array( $accounts ) && count( $accounts ) >= 1 ) {
179
+							if ( is_array( $accounts ) && count( $accounts ) >= 1 )
180
+							{
162 181
 								// apply action to all contacts matching this exists condition
163 182
 								$action = $condition['true'];
164
-								foreach ( (array)$accounts as $account ) {
183
+								foreach ( (array)$accounts as $account )
184
+								{
165 185
 									$record['account_id'] = $account['account_id'];
166 186
 									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
167 187
 								}
168
-							} else {
188
+							}
189
+							else
190
+							{
169 191
 								$action = $condition['false'];
170 192
 								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
171 193
 							}
@@ -176,13 +198,21 @@  discard block
 block discarded – undo
176 198
 							die('condition / action not supported!!!');
177 199
 							break;
178 200
 					}
179
-					if ($action['last']) break;
201
+					if ($action['last'])
202
+					{
203
+						break;
204
+					}
180 205
 				}
181
-			} else {
206
+			}
207
+			else
208
+			{
182 209
 				// unconditional insert
183 210
 				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
184 211
 			}
185
-			if($success) $count++;
212
+			if($success)
213
+			{
214
+				$count++;
215
+			}
186 216
 		}
187 217
 		return $count;
188 218
 	}
@@ -194,8 +224,10 @@  discard block
 block discarded – undo
194 224
 	 * @param array $_data contact data for the action
195 225
 	 * @return bool success or not
196 226
 	 */
197
-	private function action ( $_action, $_data, $record_num = 0 ) {
198
-		switch ($_action) {
227
+	private function action ( $_action, $_data, $record_num = 0 )
228
+	{
229
+		switch ($_action)
230
+		{
199 231
 			case 'none' :
200 232
 				return true;
201 233
 			case 'disable':
@@ -204,13 +236,15 @@  discard block
 block discarded – undo
204 236
 			case 'create' :
205 237
 			case 'update' :
206 238
 				$command = new admin_cmd_edit_user(($_action=='create'?null:$_data['account_lid']), $_data);
207
-				if($this->dry_run) {
239
+				if($this->dry_run)
240
+				{
208 241
 					$this->results[$_action]++;
209 242
 					return true;
210 243
 				}
211 244
 				try {
212 245
 					$command->run();
213
-				} catch (Exception $e) {
246
+				}
247
+				catch (Exception $e) {
214 248
 					$this->errors[$record_num] = $e->getMessage();
215 249
 					return false;
216 250
 				}
@@ -227,7 +261,8 @@  discard block
 block discarded – undo
227 261
 	 *
228 262
 	 * @return string name
229 263
 	 */
230
-	public static function get_name() {
264
+	public static function get_name()
265
+	{
231 266
 		return lang('User CSV import');
232 267
 	}
233 268
 
@@ -236,7 +271,8 @@  discard block
 block discarded – undo
236 271
 	 *
237 272
 	 * @return string descriprion
238 273
 	 */
239
-	public static function get_description() {
274
+	public static function get_description()
275
+	{
240 276
 		return lang("Creates / updates user accounts from CSV file");
241 277
 	}
242 278
 
@@ -245,7 +281,8 @@  discard block
 block discarded – undo
245 281
 	 *
246 282
 	 * @return string suffix (comma seperated)
247 283
 	 */
248
-	public static function get_filesuffix() {
284
+	public static function get_filesuffix()
285
+	{
249 286
 		return 'csv';
250 287
 	}
251 288
 
@@ -261,7 +298,8 @@  discard block
 block discarded – undo
261 298
 	 * 		preserv		=> array,
262 299
 	 * )
263 300
 	 */
264
-	public function get_options_etpl() {
301
+	public function get_options_etpl()
302
+	{
265 303
 		// lets do it!
266 304
 	}
267 305
 
@@ -270,7 +308,8 @@  discard block
 block discarded – undo
270 308
 	 *
271 309
 	 * @return string etemplate name
272 310
 	 */
273
-	public function get_selectors_etpl() {
311
+	public function get_selectors_etpl()
312
+	{
274 313
 		// lets do it!
275 314
 	}
276 315
 
@@ -282,7 +321,8 @@  discard block
 block discarded – undo
282 321
 	*       record_# => warning message
283 322
 	*       )
284 323
 	*/
285
-	public function get_warnings() {
324
+	public function get_warnings()
325
+	{
286 326
 		return $this->warnings;
287 327
 	}
288 328
 
@@ -294,7 +334,8 @@  discard block
 block discarded – undo
294 334
 	*       record_# => error message
295 335
 	*       )
296 336
 	*/
297
-	public function get_errors() {
337
+	public function get_errors()
338
+	{
298 339
 		return $this->errors;
299 340
 	}
300 341
 
@@ -306,7 +347,8 @@  discard block
 block discarded – undo
306 347
 	*       action => record count
307 348
 	* )
308 349
 	*/
309
-	public function get_results() {
350
+	public function get_results()
351
+	{
310 352
 		return $this->results;
311 353
 	}
312 354
 }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,8 +77,7 @@
 block discarded – undo
77 77
 	/**
78 78
 	 * imports entries according to given definition object.
79 79
 	 * @param resource $_stream
80
-	 * @param string $_charset
81
-	 * @param definition $_definition
80
+	 * @param importexport_definition $_definition
82 81
 	 */
83 82
 	public function import( $_stream, importexport_definition $_definition ) {
84 83
 		$import_csv = new importexport_import_csv( $_stream, array(
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,15 +15,15 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * class import_csv for admin (users)
17 17
  */
18
-class admin_import_users_csv implements importexport_iface_import_plugin  {
18
+class admin_import_users_csv implements importexport_iface_import_plugin {
19 19
 
20 20
 	private static $plugin_options = array(
21
-		'fieldsep', 		// char
22
-		'charset', 		// string
21
+		'fieldsep', // char
22
+		'charset', // string
23 23
 		'num_header_lines', // int number of header lines
24 24
 		'field_conversion', // array( $csv_col_num => conversion)
25
-		'field_mapping',	// array( $csv_col_num => adb_filed)
26
-		'conditions',		/* => array containing condition arrays:
25
+		'field_mapping', // array( $csv_col_num => adb_filed)
26
+		'conditions', /* => array containing condition arrays:
27 27
 				'type' => exists, // exists
28 28
 				'string' => '#kundennummer',
29 29
 				'true' => array(
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 	/**
41 41
 	 * actions which could be done to data entries
42 42
 	 */
43
-	protected static $actions = array( 'none', 'update', 'create', 'delete', 'disable', 'enable' );
43
+	protected static $actions = array('none', 'update', 'create', 'delete', 'disable', 'enable');
44 44
 
45 45
 	/**
46 46
 	 * conditions for actions
47 47
 	 *
48 48
 	 * @var array
49 49
 	 */
50
-	protected static $conditions = array( 'exists' );
50
+	protected static $conditions = array('exists');
51 51
 
52 52
 	/**
53 53
 	 * @var definition
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 	 * @param string $_charset
91 91
 	 * @param definition $_definition
92 92
 	 */
93
-	public function import( $_stream, importexport_definition $_definition ) {
94
-		$import_csv = new importexport_import_csv( $_stream, array(
93
+	public function import($_stream, importexport_definition $_definition) {
94
+		$import_csv = new importexport_import_csv($_stream, array(
95 95
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
96 96
 			'charset' => $_definition->plugin_options['charset'],
97 97
 		));
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 		$this->definition = $_definition;
100 100
 
101 101
 		// user, is admin ?
102
-		$this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin'];
102
+		$this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin'];
103 103
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
104 104
 
105 105
 		// dry run?
106
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
106
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
107 107
 
108 108
 		// set FieldMapping.
109 109
 		$import_csv->mapping = $_definition->plugin_options['field_mapping'];
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
113 113
 
114 114
 		//check if file has a header lines
115
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
115
+		if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) {
116 116
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
117
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
117
+		} elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
118 118
 			// First method is preferred
119 119
 			$import_csv->skip_records(1);
120 120
 		}
@@ -130,22 +130,22 @@  discard block
 block discarded – undo
130 130
 			'account_status'	=> array('A' => lang('Active'), '' => lang('Disabled'), 'D' => lang('Disabled')),
131 131
 		);
132 132
 
133
-		while ( $record = $import_csv->get_record() ) {
133
+		while ($record = $import_csv->get_record()) {
134 134
 			$success = false;
135 135
 			// don't import empty records
136
-			if( count( array_unique( $record ) ) < 2 ) continue;
136
+			if (count(array_unique($record)) < 2) continue;
137 137
 
138
-			if(strtolower($record['account_expires']) == 'never') $record['account_expires'] = -1;
138
+			if (strtolower($record['account_expires']) == 'never') $record['account_expires'] = -1;
139 139
 			importexport_import_csv::convert($record, admin_egw_user_record::$types, 'admin', $lookups);
140 140
 
141
-			if ( $_definition->plugin_options['conditions'] ) {
142
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
143
-					switch ( $condition['type'] ) {
141
+			if ($_definition->plugin_options['conditions']) {
142
+				foreach ($_definition->plugin_options['conditions'] as $condition) {
143
+					switch ($condition['type']) {
144 144
 						// exists
145 145
 						case 'exists' :
146 146
 							$accounts = array();
147 147
 							// Skip the search if the field is empty
148
-							if($record[$condition['string']] !== '')
148
+							if ($record[$condition['string']] !== '')
149 149
 							{
150 150
 								$accounts = $GLOBALS['egw']->accounts->search(array(
151 151
 									'type' => 'accounts',
@@ -154,20 +154,20 @@  discard block
 block discarded – undo
154 154
 								));
155 155
 							}
156 156
 							// Search looks in the given field, but doesn't do an exact match
157
-							foreach ( (array)$accounts as $key => $account )
157
+							foreach ((array)$accounts as $key => $account)
158 158
 							{
159
-								if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]);
159
+								if ($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]);
160 160
 							}
161
-							if ( is_array( $accounts ) && count( $accounts ) >= 1 ) {
161
+							if (is_array($accounts) && count($accounts) >= 1) {
162 162
 								// apply action to all contacts matching this exists condition
163 163
 								$action = $condition['true'];
164
-								foreach ( (array)$accounts as $account ) {
164
+								foreach ((array)$accounts as $account) {
165 165
 									$record['account_id'] = $account['account_id'];
166
-									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
166
+									$success = $this->action($action['action'], $record, $import_csv->get_current_position());
167 167
 								}
168 168
 							} else {
169 169
 								$action = $condition['false'];
170
-								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
170
+								$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
171 171
 							}
172 172
 							break;
173 173
 
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 				}
181 181
 			} else {
182 182
 				// unconditional insert
183
-				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
183
+				$success = $this->action('insert', $record, $import_csv->get_current_position());
184 184
 			}
185
-			if($success) $count++;
185
+			if ($success) $count++;
186 186
 		}
187 187
 		return $count;
188 188
 	}
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 * @param array $_data contact data for the action
195 195
 	 * @return bool success or not
196 196
 	 */
197
-	private function action ( $_action, $_data, $record_num = 0 ) {
197
+	private function action($_action, $_data, $record_num = 0) {
198 198
 		switch ($_action) {
199 199
 			case 'none' :
200 200
 				return true;
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
 				$_data['account_expires'] = $_action == 'disable' ? 'already' : '';
204 204
 			case 'create' :
205 205
 			case 'update' :
206
-				$command = new admin_cmd_edit_user(($_action=='create'?null:$_data['account_lid']), $_data);
207
-				if($this->dry_run) {
206
+				$command = new admin_cmd_edit_user(($_action == 'create' ?null:$_data['account_lid']), $_data);
207
+				if ($this->dry_run) {
208 208
 					$this->results[$_action]++;
209 209
 					return true;
210 210
 				}
Please login to merge, or discard this patch.
admin/inc/class.admin_customtranslation.inc.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param array $_content =null
35 35
 	 * @param string $msg =''
36 36
 	 */
37
-	function index(array $_content=null, $msg='')
37
+	function index(array $_content = null, $msg = '')
38 38
 	{
39 39
 		if (is_array($_content))
40 40
 		{
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
 				list($action) = each($_content['button']);
45 45
 				unset($_content['button']);
46 46
 			}
47
-			elseif($_content['rows']['delete'])
47
+			elseif ($_content['rows']['delete'])
48 48
 			{
49 49
 				list($action) = each($_content['rows']['delete']);
50 50
 				unset($_content['rows']['delete']);
51 51
 			}
52
-			switch($action)
52
+			switch ($action)
53 53
 			{
54 54
 				case 'save':
55 55
 				case 'apply':
56 56
 					$saved = 0;
57
-					foreach($_content['rows'] as $data)
57
+					foreach ($_content['rows'] as $data)
58 58
 					{
59 59
 						if (!empty($data['phrase']))
60 60
 						{
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 			}
80 80
 		}
81 81
 		$content = array('rows' => array());
82
-		foreach(Api\Translation::load_app('custom', 'en') as $phrase => $translation)
82
+		foreach (Api\Translation::load_app('custom', 'en') as $phrase => $translation)
83 83
 		{
84 84
 			$content['rows'][++$row] = array(
85 85
 				'phrase' => $phrase,
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			'phrase' => '',
92 92
 			'translation' => '',
93 93
 		);
94
-		$readonlys["delete[$row]"] = true;	// no delete for empty row
94
+		$readonlys["delete[$row]"] = true; // no delete for empty row
95 95
 		$content['msg'] = $msg;
96 96
 
97 97
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Custom translation');
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,8 +62,14 @@
 block discarded – undo
62 62
 							++$saved;
63 63
 						}
64 64
 					}
65
-					if ($saved) $msg = lang('%1 phrases saved.', $saved);
66
-					if ($action == 'apply') break;
65
+					if ($saved)
66
+					{
67
+						$msg = lang('%1 phrases saved.', $saved);
68
+					}
69
+					if ($action == 'apply')
70
+					{
71
+						break;
72
+					}
67 73
 					// fall through
68 74
 				case 'cancel':
69 75
 					Egw::redirect_link('/admin/index.php');
Please login to merge, or discard this patch.
admin/inc/class.admin_account.inc.php 2 patches
Spacing   +14 added lines, -16 removed lines patch added patch discarded remove patch
@@ -40,11 +40,10 @@  discard block
 block discarded – undo
40 40
 	{
41 41
 		if ((string)$content['owner'] === '0' && $GLOBALS['egw_info']['user']['apps']['admin'])
42 42
 		{
43
-			$deny_edit = $content['account_id'] ? $GLOBALS['egw']->acl->check('account_access', 16, 'admin') :
44
-				$GLOBALS['egw']->acl->check('account_access', 4, 'admin');
43
+			$deny_edit = $content['account_id'] ? $GLOBALS['egw']->acl->check('account_access', 16, 'admin') : $GLOBALS['egw']->acl->check('account_access', 4, 'admin');
45 44
 			//error_log(__METHOD__."() contact_id=$content[contact_id], account_id=$content[account_id], deny_edit=".array2string($deny_edit));
46 45
 
47
-			if (!$content['account_id'] && $deny_edit) return;	// no right to add new Api\Accounts, should not happen by AB ACL
46
+			if (!$content['account_id'] && $deny_edit) return; // no right to add new Api\Accounts, should not happen by AB ACL
48 47
 
49 48
 			// load our translations
50 49
 			Api\Translation::add_app('admin');
@@ -58,7 +57,7 @@  discard block
 block discarded – undo
58 57
 					throw new Api\Exception\NotFound('Account data NOT found!');
59 58
 				}
60 59
 				if ($account['account_expires'] == -1) $account['account_expires'] = '';
61
-				unset($account['account_pwd']);	// do NOT send to client
60
+				unset($account['account_pwd']); // do NOT send to client
62 61
 				$account['memberships'] = array_keys($account['memberships']);
63 62
 				$acl = new Acl($content['account_id']);
64 63
 				$acl->read_repository();
@@ -78,7 +77,7 @@  discard block
 block discarded – undo
78 77
 					'account_status' => 'A',
79 78
 					'memberships' => array(),
80 79
 					'anonymous' => false,
81
-					'changepassword' => true,	//old default: (bool)$GLOBALS['egw_info']['server']['change_pwd_every_x_days'],
80
+					'changepassword' => true, //old default: (bool)$GLOBALS['egw_info']['server']['change_pwd_every_x_days'],
82 81
 					'mustchangepassword' => false,
83 82
 					'account_primary_group' => $GLOBALS['egw']->accounts->name2id('Default'),
84 83
 					'homedirectory' => $GLOBALS['egw_info']['server']['ldap_account_home'],
@@ -99,7 +98,7 @@  discard block
 block discarded – undo
99 98
 
100 99
 			if ($deny_edit)
101 100
 			{
102
-				foreach(array_keys($account) as $key)
101
+				foreach (array_keys($account) as $key)
103 102
 				{
104 103
 					$readonlys[$key] = true;
105 104
 				}
@@ -131,11 +130,11 @@  discard block
 block discarded – undo
131 130
 	{
132 131
 		if ($content['old_account'] && $content['old_account'] == array_diff_key($content, $content['old_account']))
133 132
 		{
134
-			return '';	// no need to save account data, if nothing changed
133
+			return ''; // no need to save account data, if nothing changed
135 134
 		}
136 135
 		//error_log(__METHOD__."(".array2string($content).")");
137 136
 		$account = array();
138
-		foreach(array(
137
+		foreach (array(
139 138
 			// need to copy/rename some fields named different in account and contact
140 139
 			'n_given' => 'account_firstname',
141 140
 			'n_family' => 'account_lastname',
@@ -152,11 +151,10 @@  discard block
 block discarded – undo
152 151
 		{
153 152
 			if (is_int($c_name)) $c_name = $a_name;
154 153
 
155
-			switch($a_name)
154
+			switch ($a_name)
156 155
 			{
157 156
 				case 'account_expires':
158
-					$account[$a_name] = $content[$c_name] ? $content[$c_name] :
159
-						($content['account_status'] ? 'never' : 'already');
157
+					$account[$a_name] = $content[$c_name] ? $content[$c_name] : ($content['account_status'] ? 'never' : 'already');
160 158
 					break;
161 159
 
162 160
 				case 'changepassword':	// boolean values: admin_cmd_edit_user understands '' as NOT set
@@ -171,7 +169,7 @@  discard block
 block discarded – undo
171 169
 			}
172 170
 		}
173 171
 		// Make sure primary group is in account groups
174
-		if($account['account_primary_group'] && !array_search($account['account_primary_group'], (array)$account['account_groups']))
172
+		if ($account['account_primary_group'] && !array_search($account['account_primary_group'], (array)$account['account_groups']))
175 173
 		{
176 174
 			$account['account_groups'][] = $account['account_primary_group'];
177 175
 		}
@@ -204,7 +202,7 @@  discard block
 block discarded – undo
204 202
 	 *
205 203
 	 * @param array $content =null
206 204
 	 */
207
-	public static function delete(array $content=null)
205
+	public static function delete(array $content = null)
208 206
 	{
209 207
 		if (!is_array($content))
210 208
 		{
@@ -221,7 +219,7 @@  discard block
 block discarded – undo
221 219
 			}
222 220
 			//error_log(__METHOD__."() \$_GET[account_id]=$_GET[account_id], \$_GET[contact_id]=$_GET[contact_id] content=".array2string($content));
223 221
 		}
224
-		if ($GLOBALS['egw']->acl->check('account_access',32,'admin') || !($content['account_id'] > 0) ||
222
+		if ($GLOBALS['egw']->acl->check('account_access', 32, 'admin') || !($content['account_id'] > 0) ||
225 223
 			$GLOBALS['egw_info']['user']['account_id'] == $content['account_id'])
226 224
 		{
227 225
 			Framework::window_close(lang('Permission denied!!!'));
@@ -275,7 +273,7 @@  discard block
 block discarded – undo
275 273
 			}
276 274
 		}
277 275
 
278
-		if (!$data['account_lid'] && !$data['account_id']) return;	// makes no sense to check before
276
+		if (!$data['account_lid'] && !$data['account_id']) return; // makes no sense to check before
279 277
 
280 278
 		// set home-directory when account_lid is entered, but only for new Api\Accounts
281 279
 		if ($changed == 'account_lid' && !$data['account_id'] &&
@@ -294,7 +292,7 @@  discard block
 block discarded – undo
294 292
 			$cmd = new admin_cmd_edit_user($data['account_id'], $data);
295 293
 			$cmd->run(null, false, false, true);
296 294
 		}
297
-		catch(Exception $e)
295
+		catch (Exception $e)
298 296
 		{
299 297
 			Api\Json\Response::get()->data($e->getMessage());
300 298
 		}
Please login to merge, or discard this patch.
Braces   +26 added lines, -6 removed lines patch added patch discarded remove patch
@@ -44,20 +44,30 @@  discard block
 block discarded – undo
44 44
 				$GLOBALS['egw']->acl->check('account_access', 4, 'admin');
45 45
 			//error_log(__METHOD__."() contact_id=$content[contact_id], account_id=$content[account_id], deny_edit=".array2string($deny_edit));
46 46
 
47
-			if (!$content['account_id'] && $deny_edit) return;	// no right to add new Api\Accounts, should not happen by AB ACL
47
+			if (!$content['account_id'] && $deny_edit)
48
+			{
49
+				return;
50
+			}
51
+			// no right to add new Api\Accounts, should not happen by AB ACL
48 52
 
49 53
 			// load our translations
50 54
 			Api\Translation::add_app('admin');
51 55
 
52
-			if ($content['id'])	// existing account
56
+			if ($content['id'])
57
+			{
58
+				// existing account
53 59
 			{
54 60
 				// invalidate account, before reading it, to code with changed to DB or LDAP outside EGw
55 61
 				Api\Accounts::cache_invalidate((int)$content['account_id']);
62
+			}
56 63
 				if (!($account = $GLOBALS['egw']->accounts->read($content['account_id'])))
57 64
 				{
58 65
 					throw new Api\Exception\NotFound('Account data NOT found!');
59 66
 				}
60
-				if ($account['account_expires'] == -1) $account['account_expires'] = '';
67
+				if ($account['account_expires'] == -1)
68
+				{
69
+					$account['account_expires'] = '';
70
+				}
61 71
 				unset($account['account_pwd']);	// do NOT send to client
62 72
 				$account['memberships'] = array_keys($account['memberships']);
63 73
 				$acl = new Acl($content['account_id']);
@@ -150,7 +160,10 @@  discard block
 block discarded – undo
150 160
 			'homedirectory', 'loginshell',
151 161
 		) as $c_name => $a_name)
152 162
 		{
153
-			if (is_int($c_name)) $c_name = $a_name;
163
+			if (is_int($c_name))
164
+			{
165
+				$c_name = $a_name;
166
+			}
154 167
 
155 168
 			switch($a_name)
156 169
 			{
@@ -269,13 +282,20 @@  discard block
 block discarded – undo
269 282
 		if (!$data['account_id'] && in_array($changed, array('n_given', 'n_family', 'account_lid')))
270 283
 		{
271 284
 			$email = Api\Accounts::email($data['account_firstname'], $data['account_lastname'], $data['account_lid']);
272
-			if ($email && $email[0] != '@' && strpos($email, '@'))	// only add valid email addresses
285
+			if ($email && $email[0] != '@' && strpos($email, '@'))
286
+			{
287
+				// only add valid email addresses
273 288
 			{
274 289
 				Api\Json\Response::get()->assign('addressbook-edit_email', 'value', $email);
275 290
 			}
291
+			}
276 292
 		}
277 293
 
278
-		if (!$data['account_lid'] && !$data['account_id']) return;	// makes no sense to check before
294
+		if (!$data['account_lid'] && !$data['account_id'])
295
+		{
296
+			return;
297
+		}
298
+		// makes no sense to check before
279 299
 
280 300
 		// set home-directory when account_lid is entered, but only for new Api\Accounts
281 301
 		if ($changed == 'account_lid' && !$data['account_id'] &&
Please login to merge, or discard this patch.
admin/inc/hook_acl_manager.inc.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 		'List config settings'   => 1,
15 15
 		'Change config settings' => 2
16 16
 	)
17
-);	// added and working ralfbecker
17
+); // added and working ralfbecker
18 18
 
19 19
 $GLOBALS['acl_manager']['admin']['account_access'] = array(
20 20
 	'name' => 'Deny access to user accounts',
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		'Delete account'  => 32,
28 28
 		'change ACL Rights' => 64
29 29
 	)
30
-);	// was already there and seems to work ralfbecker
30
+); // was already there and seems to work ralfbecker
31 31
 
32 32
 $GLOBALS['acl_manager']['admin']['group_access'] = array(
33 33
 	'name' => 'Deny access to groups',
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 		'Edit group'    => 16,
40 40
 		'Delete group'  => 32
41 41
 	)
42
-);	// was already there and seems to work ralfbecker
42
+); // was already there and seems to work ralfbecker
43 43
 
44 44
 $GLOBALS['acl_manager']['admin']['applications_acc'] = array(
45 45
 	'name' => 'Deny access to applications',
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 */
53 53
 		'Register application hooks' => 16
54 54
 	)
55
-);	// added and working ralfbecker
55
+); // added and working ralfbecker
56 56
 
57 57
 $GLOBALS['acl_manager']['admin']['global_categorie'] = array(
58 58
 	'name' => 'Deny access to global categories',
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		'Delete category'   => 32,
66 66
 		'Add sub-category'  => 64
67 67
 	)
68
-);	// added and working ralfbecker
68
+); // added and working ralfbecker
69 69
 
70 70
 $GLOBALS['acl_manager']['admin']['mainscreen_messa'] = array(
71 71
 	'name' => 'Deny access to mainscreen message',
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		'Main screen message' => 1,
74 74
 		'Login message'       => 2
75 75
 	)
76
-);	// added and working ralfbecker
76
+); // added and working ralfbecker
77 77
 
78 78
 $GLOBALS['acl_manager']['admin']['current_sessions'] = array(
79 79
 	'name' => 'Deny access to current sessions',
@@ -83,40 +83,40 @@  discard block
 block discarded – undo
83 83
 		'Show session IP address' => 4,
84 84
 		'Kill session'            => 8
85 85
 	)
86
-);	// checked and working ralfbecker
86
+); // checked and working ralfbecker
87 87
 
88 88
 $GLOBALS['acl_manager']['admin']['access_log_acces'] = array(
89 89
 	'name' => 'Deny access to access log',
90 90
 	'rights' => array(
91 91
 		'Show access log' => 1
92 92
 	)
93
-);	// added and working ralfbecker
93
+); // added and working ralfbecker
94 94
 
95 95
 $GLOBALS['acl_manager']['admin']['error_log_access'] = array(
96 96
 	'name' => 'Deny access to error log',
97 97
 	'rights' => array(
98 98
 		'Show error log' => 1
99 99
 	)
100
-);	// added and working ralfbecker
100
+); // added and working ralfbecker
101 101
 
102 102
 $GLOBALS['acl_manager']['admin']['asyncservice_acc'] = array(
103 103
 	'name' => 'Deny access to asynchronous timed services',
104 104
 	'rights' => array(
105 105
 		'Asynchronous timed services' => 1
106 106
 	)
107
-);	// added and working ralfbecker
107
+); // added and working ralfbecker
108 108
 
109 109
 $GLOBALS['acl_manager']['admin']['db_backup_access'] = array(
110 110
 	'name' => 'Deny access to DB backup and restore',
111 111
 	'rights' => array(
112 112
 		'DB backup and restore' => 1
113 113
 	)
114
-);	// added and working ralfbecker
114
+); // added and working ralfbecker
115 115
 
116 116
 $GLOBALS['acl_manager']['admin']['info_access'] = array(
117 117
 	'name' => 'Deny access to phpinfo',
118 118
 	'rights' => array(
119 119
 		'Show phpinfo()' => 1
120 120
 	)
121
-);	// added and working ralfbecker
121
+); // added and working ralfbecker
122 122
 
Please login to merge, or discard this patch.
admin/inc/class.admin_wizard_export_groups_csv.inc.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@
 block discarded – undo
18 18
 		parent::__construct();
19 19
 
20 20
 		// Field mapping
21
-                $this->export_fields = array(
21
+				$this->export_fields = array(
22 22
 			'account_id'		=> lang('Account ID'),
23 23
 			'account_lid'		=> lang('Group Name'),
24 24
 			'account_members'	=> lang('Members'),
25
-                );
25
+				);
26 26
 
27 27
 		// Custom fields - not really used in admin...
28 28
 		unset($this->export_fields['customfields']);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 		// Custom fields - not really used in admin...
28 28
 		unset($this->export_fields['customfields']);
29 29
 		$custom = Api\Storage\Customfields::get('admin', true);
30
-		foreach($custom as $name => $data) {
30
+		foreach ($custom as $name => $data) {
31 31
 			$this->export_fields['#'.$name] = $data['label'];
32 32
 		}
33 33
 	}
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,8 @@  discard block
 block discarded – undo
14 14
 
15 15
 class admin_wizard_export_groups_csv extends importexport_wizard_basic_export_csv
16 16
 {
17
-	public function __construct() {
17
+	public function __construct()
18
+	{
18 19
 		parent::__construct();
19 20
 
20 21
 		// Field mapping
@@ -27,7 +28,8 @@  discard block
 block discarded – undo
27 28
 		// Custom fields - not really used in admin...
28 29
 		unset($this->export_fields['customfields']);
29 30
 		$custom = Api\Storage\Customfields::get('admin', true);
30
-		foreach($custom as $name => $data) {
31
+		foreach($custom as $name => $data)
32
+		{
31 33
 			$this->export_fields['#'.$name] = $data['label'];
32 34
 		}
33 35
 	}
Please login to merge, or discard this patch.
admin/inc/class.admin_cmd_check_cats.inc.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @param array $data =array() default parm from parent class, no real parameters
26 26
 	 */
27
-	function __construct($data=array())
27
+	function __construct($data = array())
28 28
 	{
29 29
 		admin_cmd::__construct($data);
30 30
 	}
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param boolean $check_only =false only run the checks (and throw the exceptions), but not the command itself
36 36
 	 * @return string success message
37 37
 	 */
38
-	protected function exec($check_only=false)
38
+	protected function exec($check_only = false)
39 39
 	{
40 40
 		if ($check_only) return true;
41 41
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,10 @@
 block discarded – undo
37 37
 	 */
38 38
 	protected function exec($check_only=false)
39 39
 	{
40
-		if ($check_only) return true;
40
+		if ($check_only)
41
+		{
42
+			return true;
43
+		}
41 44
 
42 45
 		admin_cmd::_instanciate_accounts();
43 46
 
Please login to merge, or discard this patch.
admin/inc/class.admin_acl.inc.php 2 patches
Spacing   +29 added lines, -32 removed lines patch added patch discarded remove patch
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 		$old_apps = array_keys($this->acl->get_user_applications($content['acl_account'], false, false));
56 56
 		// add new apps
57 57
 		$added_apps = array_diff($content['apps'], $old_apps);
58
-		foreach($added_apps as $app)
58
+		foreach ($added_apps as $app)
59 59
 		{
60 60
 			$this->acl->add_repository($app, 'run', $content['acl_account'], 1);
61 61
 		}
62 62
 		// remove no longer checked apps
63 63
 		$removed_apps = array_diff($old_apps, $content['apps']);
64 64
 		$deleted_ids = array();
65
-		foreach($removed_apps as $app)
65
+		foreach ($removed_apps as $app)
66 66
 		{
67 67
 			$this->acl->delete_repository($app, 'run', $content['acl_account']);
68 68
 			$deleted_ids[] = $app.':'.$content['acl_account'].':run';
@@ -96,12 +96,11 @@  discard block
 block discarded – undo
96 96
 	{
97 97
 		// assamble rights again
98 98
 		$rights = (int)$content['preserve_rights'];
99
-		foreach($content['acl'] as $right)
99
+		foreach ($content['acl'] as $right)
100 100
 		{
101 101
 			$rights |= $right;
102 102
 		}
103
-		$id = !empty($content['id']) ? $content['id'] :
104
-		$content['acl_appname'].':'.$content['acl_account'].':'.$content['acl_location'];
103
+		$id = !empty($content['id']) ? $content['id'] : $content['acl_appname'].':'.$content['acl_account'].':'.$content['acl_location'];
105 104
 		//error_log(__METHOD__."() id=$id, acl=".array2string($content['acl'])." --> rights=$rights");
106 105
 
107 106
 		if ($this->acl->get_specific_rights_for_account($content['acl_account'], $content['acl_location'], $content['acl_appname']) == $rights)
@@ -134,14 +133,14 @@  discard block
 block discarded – undo
134 133
 	 * @param array &$rows=null
135 134
 	 * @return int total number of rows available
136 135
 	 */
137
-	public static function get_rows(array $query, array &$rows=null)
136
+	public static function get_rows(array $query, array &$rows = null)
138 137
 	{
139 138
 		$so_sql = new Api\Storage\Base('phpgwapi', Acl::TABLE, null, '', true);
140 139
 
141 140
 		// client queries destinct rows by their row-id
142 141
 		if (isset($query['col_filter']['id']))
143 142
 		{
144
-			$query['col_filter'][] = $GLOBALS['egw']->db->concat('acl_appname',"':'",'acl_account',"':'",'acl_location').
143
+			$query['col_filter'][] = $GLOBALS['egw']->db->concat('acl_appname', "':'", 'acl_account', "':'", 'acl_location').
145 144
 				' IN ('.implode(',', array_map(array($GLOBALS['egw']->db, 'quote'), (array)$query['col_filter']['id'])).')';
146 145
 			unset($query['col_filter']['id']);
147 146
 		}
@@ -159,9 +158,9 @@  discard block
 block discarded – undo
159 158
 			if ($GLOBALS['egw_info']['user']['preferences']['admin']['acl_filter'] != $query['filter'])
160 159
 			{
161 160
 				$GLOBALS['egw']->preferences->add('admin', 'acl_filter', $query['filter']);
162
-				$GLOBALS['egw']->preferences->save_repository(false,'user',false);
161
+				$GLOBALS['egw']->preferences->save_repository(false, 'user', false);
163 162
 			}
164
-			switch($query['filter'])
163
+			switch ($query['filter'])
165 164
 			{
166 165
 				case 'run':
167 166
 					$query['col_filter']['acl_location'] = 'run';
@@ -185,7 +184,7 @@  discard block
 block discarded – undo
185 184
 					if ($not_enum_group_acls)
186 185
 					{
187 186
 						$sql = '(CASE acl_appname';
188
-						foreach($not_enum_group_acls as $app => $groups)
187
+						foreach ($not_enum_group_acls as $app => $groups)
189 188
 						{
190 189
 							if ($groups === true)
191 190
 							{
@@ -195,7 +194,7 @@  discard block
 block discarded – undo
195 194
 							{
196 195
 								$check = array_diff($memberships, $groups);
197 196
 								//error_log(__METHOD__."() app=$app, array_diff(memberships=".array2string($memberships).", groups=".array2string($groups).")=".array2string($check));
198
-								if (!$check) continue;	// would give sql error otherwise!
197
+								if (!$check) continue; // would give sql error otherwise!
199 198
 							}
200 199
 							$sql .= ' WHEN '.$GLOBALS['egw']->db->quote($app).' THEN '.$GLOBALS['egw']->db->expression(Acl::TABLE, array(
201 200
 								'acl_account' => $check,
@@ -225,7 +224,7 @@  discard block
 block discarded – undo
225 224
 		$readonlys = array();
226 225
 		$total = $so_sql->get_rows($query, $rows, $readonlys);
227 226
 
228
-		foreach($rows as &$row)
227
+		foreach ($rows as &$row)
229 228
 		{
230 229
 			// generate a row-id
231 230
 			$row['id'] = $row['acl_appname'].':'.$row['acl_account'].':'.$row['acl_location'];
@@ -237,9 +236,9 @@  discard block
 block discarded – undo
237 236
 			else
238 237
 			{
239 238
 				if ($app !== $row['acl_appname']) Api\Translation::add_app($row['app_name']);
240
-				foreach($query['acl_rights'][$row['acl_appname']] as $val => $label)
239
+				foreach ($query['acl_rights'][$row['acl_appname']] as $val => $label)
241 240
 				{
242
-					if ($row['acl_rights'] & $val)
241
+					if ($row['acl_rights']&$val)
243 242
 					{
244 243
 						$row['acl'.$val] = lang($label);
245 244
 					}
@@ -254,11 +253,11 @@  discard block
 block discarded – undo
254 253
 		//error_log(__METHOD__."(".array2string($query).") returning ".$total);
255 254
 
256 255
 		// Get supporting or all apps for filter2 depending on filter
257
-		if($query['filter'] == 'run')
256
+		if ($query['filter'] == 'run')
258 257
 		{
259 258
 			$rows['sel_options']['filter2'] = array(
260 259
 				'' => lang('All applications'),
261
-			)+Etemplate\Widget\Select::app_options('enabled');
260
+			) + Etemplate\Widget\Select::app_options('enabled');
262 261
 		}
263 262
 		else
264 263
 		{
@@ -269,14 +268,14 @@  discard block
 block discarded – undo
269 268
 				'location' => 'acl_rights',
270 269
 				'owner' => $query['account_id'],
271 270
 			), array(), true);
272
-			foreach(array_keys($apps) as $appname)
271
+			foreach (array_keys($apps) as $appname)
273 272
 			{
274 273
 				$rows['sel_options']['filter2'][] = array(
275 274
 					'value' => $appname,
276 275
 					'label' => lang($appname)
277 276
 				);
278 277
 			}
279
-			usort($rows['sel_options']['filter2'], function($a,$b) {
278
+			usort($rows['sel_options']['filter2'], function($a, $b) {
280 279
 				return strcasecmp($a['label'], $b['label']);
281 280
 			});
282 281
 		}
@@ -293,14 +292,14 @@  discard block
 block discarded – undo
293 292
 	 * @return boolean true if access is granted, false if notification_bo
294 293
 	 * @throws Api\Exception\NoPermission
295 294
 	 */
296
-	public static function check_access($account_id, $location=null, $throw=true)
295
+	public static function check_access($account_id, $location = null, $throw = true)
297 296
 	{
298
-		static $admin_access=null;
299
-		static $own_access=null;
297
+		static $admin_access = null;
298
+		static $own_access = null;
300 299
 		if (is_null($admin_access))
301 300
 		{
302 301
 			$admin_access = isset($GLOBALS['egw_info']['user']['apps']['admin']) &&
303
-				!$GLOBALS['egw']->acl->check('account_access', 64, 'admin');	// ! because this denies access!
302
+				!$GLOBALS['egw']->acl->check('account_access', 64, 'admin'); // ! because this denies access!
304 303
 			$own_access = $admin_access || isset($GLOBALS['egw_info']['user']['apps']['preferences']);
305 304
 		}
306 305
 		if (!(int)$account_id || !((int)$account_id == (int)$GLOBALS['egw_info']['user']['account_id'] && $location !== 'run' ?
@@ -322,9 +321,9 @@  discard block
 block discarded – undo
322 321
 	public static function ajax_get_app_list($account_id)
323 322
 	{
324 323
 		$list = array();
325
-		if(self::check_access((int)$account_id,'run',false))
324
+		if (self::check_access((int)$account_id, 'run', false))
326 325
 		{
327
-			$list = array_keys($GLOBALS['egw']->acl->get_user_applications((int)$account_id,false,false));
326
+			$list = array_keys($GLOBALS['egw']->acl->get_user_applications((int)$account_id, false, false));
328 327
 		}
329 328
 		Api\Json\Response::get()->data($list);
330 329
 	}
@@ -338,14 +337,14 @@  discard block
 block discarded – undo
338 337
 	 * @param int $rights =null null to delete, or new rights
339 338
 	 * @throws Api\Exception\NoPermission
340 339
 	 */
341
-	public static function ajax_change_acl($ids, $rights=null)
340
+	public static function ajax_change_acl($ids, $rights = null)
342 341
 	{
343 342
 		try {
344
-			foreach((array)$ids as $id)
343
+			foreach ((array)$ids as $id)
345 344
 			{
346 345
 				list($app, $account_id, $location) = explode(':', $id, 3);
347 346
 
348
-				self::check_access($account_id, $location);	// throws exception, if no rights
347
+				self::check_access($account_id, $location); // throws exception, if no rights
349 348
 
350 349
 				$acl = $GLOBALS['egw']->acl;
351 350
 
@@ -389,9 +388,9 @@  discard block
 block discarded – undo
389 388
 	 *
390 389
 	 * @param array $_content =null
391 390
 	 */
392
-	public function index(array $_content=null)
391
+	public function index(array $_content = null)
393 392
 	{
394
-		unset($_content);	// not used, required by function signature
393
+		unset($_content); // not used, required by function signature
395 394
 
396 395
 		$tpl = new Etemplate('admin.acl');
397 396
 
@@ -401,9 +400,7 @@  discard block
 block discarded – undo
401 400
 		$content['nm'] = array(
402 401
 			'get_rows' => 'admin_acl::get_rows',
403 402
 			'no_cat' => true,
404
-			'filter' => !empty($_GET['acl_filter']) ? $_GET['acl_filter'] :
405
-				($GLOBALS['egw_info']['flags']['currentapp'] != 'admin' ? 'other' :
406
-					$GLOBALS['egw_info']['user']['preferences']['admin']['acl_filter']),
403
+			'filter' => !empty($_GET['acl_filter']) ? $_GET['acl_filter'] : ($GLOBALS['egw_info']['flags']['currentapp'] != 'admin' ? 'other' : $GLOBALS['egw_info']['user']['preferences']['admin']['acl_filter']),
407 404
 			'filter2' => !empty($_GET['acl_app']) ? $_GET['acl_app'] : '',
408 405
 			'lettersearch' => false,
409 406
 			'order' => 'acl_appname',
Please login to merge, or discard this patch.
Braces   +31 added lines, -8 removed lines patch added patch discarded remove patch
@@ -108,9 +108,12 @@  discard block
 block discarded – undo
108 108
 		{
109 109
 			// nothing changed --> nothing to do
110 110
 		}
111
-		elseif (!$rights)	// all rights removed --> delete it
111
+		elseif (!$rights)
112
+		{
113
+			// all rights removed --> delete it
112 114
 		{
113 115
 			$this->acl->delete_repository($content['acl_appname'], $content['acl_location'], $content['acl_account']);
116
+		}
114 117
 			Framework::refresh_opener(lang('ACL deleted.'), 'admin', $id, 'delete');
115 118
 		}
116 119
 		else
@@ -195,7 +198,11 @@  discard block
 block discarded – undo
195 198
 							{
196 199
 								$check = array_diff($memberships, $groups);
197 200
 								//error_log(__METHOD__."() app=$app, array_diff(memberships=".array2string($memberships).", groups=".array2string($groups).")=".array2string($check));
198
-								if (!$check) continue;	// would give sql error otherwise!
201
+								if (!$check)
202
+								{
203
+									continue;
204
+								}
205
+								// would give sql error otherwise!
199 206
 							}
200 207
 							$sql .= ' WHEN '.$GLOBALS['egw']->db->quote($app).' THEN '.$GLOBALS['egw']->db->expression(Acl::TABLE, array(
201 208
 								'acl_account' => $check,
@@ -206,7 +213,10 @@  discard block
 block discarded – undo
206 213
 					$sql .= $GLOBALS['egw']->db->expression(Acl::TABLE, array(
207 214
 						'acl_account' => $memberships,
208 215
 					));
209
-					if ($not_enum_group_acls) $sql .= ' END)';
216
+					if ($not_enum_group_acls)
217
+					{
218
+						$sql .= ' END)';
219
+					}
210 220
 					$query['col_filter'][] = $sql;
211 221
 					break;
212 222
 
@@ -236,7 +246,10 @@  discard block
 block discarded – undo
236 246
 			}
237 247
 			else
238 248
 			{
239
-				if ($app !== $row['acl_appname']) Api\Translation::add_app($row['app_name']);
249
+				if ($app !== $row['acl_appname'])
250
+				{
251
+					Api\Translation::add_app($row['app_name']);
252
+				}
240 253
 				foreach($query['acl_rights'][$row['acl_appname']] as $val => $label)
241 254
 				{
242 255
 					if ($row['acl_rights'] & $val)
@@ -245,10 +258,13 @@  discard block
 block discarded – undo
245 258
 					}
246 259
 				}
247 260
 			}
248
-			if (!self::check_access($row['acl_account'], $row['acl_location'], false))	// false: do NOT throw an exception!
261
+			if (!self::check_access($row['acl_account'], $row['acl_location'], false))
262
+			{
263
+				// false: do NOT throw an exception!
249 264
 			{
250 265
 				$row['class'] = 'rowNoEdit';
251 266
 			}
267
+			}
252 268
 			//error_log(__METHOD__."() $n: ".array2string($row));
253 269
 		}
254 270
 		//error_log(__METHOD__."(".array2string($query).") returning ".$total);
@@ -276,7 +292,8 @@  discard block
 block discarded – undo
276 292
 					'label' => lang($appname)
277 293
 				);
278 294
 			}
279
-			usort($rows['sel_options']['filter2'], function($a,$b) {
295
+			usort($rows['sel_options']['filter2'], function($a,$b)
296
+			{
280 297
 				return strcasecmp($a['label'], $b['label']);
281 298
 			});
282 299
 		}
@@ -306,7 +323,10 @@  discard block
 block discarded – undo
306 323
 		if (!(int)$account_id || !((int)$account_id == (int)$GLOBALS['egw_info']['user']['account_id'] && $location !== 'run' ?
307 324
 				$own_access : $admin_access))
308 325
 		{
309
-			if ($throw) throw new Api\Exception\NoPermission(lang('Permission denied!!!'));
326
+			if ($throw)
327
+			{
328
+				throw new Api\Exception\NoPermission(lang('Permission denied!!!'));
329
+			}
310 330
 			return false;
311 331
 		}
312 332
 		return true;
@@ -349,10 +369,13 @@  discard block
 block discarded – undo
349 369
 
350 370
 				$acl = $GLOBALS['egw']->acl;
351 371
 
352
-				if (!(int)$rights)	// this also handles taking away all rights as delete
372
+				if (!(int)$rights)
373
+				{
374
+					// this also handles taking away all rights as delete
353 375
 				{
354 376
 					$acl->delete_repository($app, $location, $account_id);
355 377
 				}
378
+				}
356 379
 				else
357 380
 				{
358 381
 					$acl->add_repository($app, $location, $account_id, $rights);
Please login to merge, or discard this patch.
admin/inc/class.admin_cmd_edit_group.inc.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * @param string|int|array $account account name or id (!$account to add a new account), or array with all parameters
24 24
 	 * @param array $set =null array with all data to change
25 25
 	 */
26
-	function __construct($account,$set=null)
26
+	function __construct($account, $set = null)
27 27
 	{
28 28
 		if (!is_array($account))
29 29
 		{
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 * @throws Api\Exception\NoPermission\Admin
44 44
 	 * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15);
45 45
 	 */
46
-	protected function exec($check_only=false)
46
+	protected function exec($check_only = false)
47 47
 	{
48 48
 		// check creator is still admin and not explicitly forbidden to edit accounts/groups
49
-		if ($this->creator) $this->_check_admin('group_access',$this->account ? 16 : 4);
49
+		if ($this->creator) $this->_check_admin('group_access', $this->account ? 16 : 4);
50 50
 
51 51
 		admin_cmd::_instanciate_accounts();
52 52
 
@@ -54,32 +54,32 @@  discard block
 block discarded – undo
54 54
 
55 55
 		if ($this->account)	// existing account
56 56
 		{
57
-			$data['account_id'] = admin_cmd::parse_account($this->account,false);
57
+			$data['account_id'] = admin_cmd::parse_account($this->account, false);
58 58
 		}
59 59
 		else
60 60
 		{
61 61
 			$data += array(
62 62
 				'account_type' => 'g',
63
-				'account_status' => 'A',	// not used, but so we do the same thing as the web-interface
63
+				'account_status' => 'A', // not used, but so we do the same thing as the web-interface
64 64
 				'account_expires' => -1,
65 65
 			);
66 66
 		}
67 67
 		if (!$data['account_lid'] && (!$this->account || !is_null($data['account_lid'])))
68 68
 		{
69
-			throw new Api\Exception\WrongUserinput(lang('You must enter a group name.'),9);
69
+			throw new Api\Exception\WrongUserinput(lang('You must enter a group name.'), 9);
70 70
 		}
71
-		if (!is_null($data['account_lid']) && ($id = admin_cmd::$accounts->name2id($data['account_lid'],'account_lid','g')) &&
71
+		if (!is_null($data['account_lid']) && ($id = admin_cmd::$accounts->name2id($data['account_lid'], 'account_lid', 'g')) &&
72 72
 			$id !== $data['account_id'])
73 73
 		{
74
-			throw new Api\Exception\WrongUserinput(lang('That loginid has already been taken'),999);
74
+			throw new Api\Exception\WrongUserinput(lang('That loginid has already been taken'), 999);
75 75
 		}
76 76
 		if (!$data['account_members'] && !$this->account)
77 77
 		{
78
-			throw new Api\Exception\WrongUserinput(lang('You must select at least one group member.'),9);
78
+			throw new Api\Exception\WrongUserinput(lang('You must select at least one group member.'), 9);
79 79
 		}
80 80
 		if ($data['account_members'])
81 81
 		{
82
-			$data['account_members'] = admin_cmd::parse_accounts($data['account_members'],true);
82
+			$data['account_members'] = admin_cmd::parse_accounts($data['account_members'], true);
83 83
 		}
84 84
 		if ($check_only) return true;
85 85
 
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
 			Api\Accounts::cache_invalidate($data['account_id']);
90 90
 			if (!($old = admin_cmd::$accounts->read($data['account_id'])))
91 91
 			{
92
-				throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15);
92
+				throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!", $this->account), 15);
93 93
 			}
94 94
 			// as the current account class always sets all values, we have to add the not specified ones
95
-			foreach($data as $name => &$value)
95
+			foreach ($data as $name => &$value)
96 96
 			{
97 97
 				if (is_null($value)) $value = $old[$name];
98 98
 			}
@@ -100,18 +100,18 @@  discard block
 block discarded – undo
100 100
 		if (!($data['account_id'] = admin_cmd::$accounts->save($data)))
101 101
 		{
102 102
 			//_debug_array($data);
103
-			throw new Api\Db\Exception(lang("Error saving account!"),11);
103
+			throw new Api\Db\Exception(lang("Error saving account!"), 11);
104 104
 		}
105
-		$data['account_name'] = $data['account_lid'];	// also set deprecated name
106
-		if ($update) $data['old_name'] = $old['account_lid'];	// make old name available for hooks
107
-		$GLOBALS['hook_values'] =& $data;
108
-		Api\Hooks::process($GLOBALS['hook_values']+array(
105
+		$data['account_name'] = $data['account_lid']; // also set deprecated name
106
+		if ($update) $data['old_name'] = $old['account_lid']; // make old name available for hooks
107
+		$GLOBALS['hook_values'] = & $data;
108
+		Api\Hooks::process($GLOBALS['hook_values'] + array(
109 109
 			'location' => $update ? 'editgroup' : 'addgroup'
110
-		),False,True);	// called for every app now, not only enabled ones)
110
+		), False, True); // called for every app now, not only enabled ones)
111 111
 
112 112
 		if ($data['account_members'])
113 113
 		{
114
-			admin_cmd::$accounts->set_members($data['account_members'],$data['account_id']);
114
+			admin_cmd::$accounts->set_members($data['account_members'], $data['account_id']);
115 115
 		}
116 116
 		// make new account_id available to caller
117 117
 		$this->account = $data['account_id'];
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	function __tostring()
129 129
 	{
130
-		return lang('%1 group %2',$this->account ? lang('Edit') : lang('Add'),
130
+		return lang('%1 group %2', $this->account ? lang('Edit') : lang('Add'),
131 131
 			admin_cmd::display_account($this->account ? $this->account : $this->set['account_lid']));
132 132
 	}
133 133
 }
Please login to merge, or discard this patch.
Braces   +21 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,16 +46,22 @@  discard block
 block discarded – undo
46 46
 	protected function exec($check_only=false)
47 47
 	{
48 48
 		// check creator is still admin and not explicitly forbidden to edit accounts/groups
49
-		if ($this->creator) $this->_check_admin('group_access',$this->account ? 16 : 4);
49
+		if ($this->creator)
50
+		{
51
+			$this->_check_admin('group_access',$this->account ? 16 : 4);
52
+		}
50 53
 
51 54
 		admin_cmd::_instanciate_accounts();
52 55
 
53 56
 		$data = $this->set;
54 57
 
55
-		if ($this->account)	// existing account
58
+		if ($this->account)
59
+		{
60
+			// existing account
56 61
 		{
57 62
 			$data['account_id'] = admin_cmd::parse_account($this->account,false);
58 63
 		}
64
+		}
59 65
 		else
60 66
 		{
61 67
 			$data += array(
@@ -81,7 +87,10 @@  discard block
 block discarded – undo
81 87
 		{
82 88
 			$data['account_members'] = admin_cmd::parse_accounts($data['account_members'],true);
83 89
 		}
84
-		if ($check_only) return true;
90
+		if ($check_only)
91
+		{
92
+			return true;
93
+		}
85 94
 
86 95
 		if (($update = $this->account))
87 96
 		{
@@ -94,7 +103,10 @@  discard block
 block discarded – undo
94 103
 			// as the current account class always sets all values, we have to add the not specified ones
95 104
 			foreach($data as $name => &$value)
96 105
 			{
97
-				if (is_null($value)) $value = $old[$name];
106
+				if (is_null($value))
107
+				{
108
+					$value = $old[$name];
109
+				}
98 110
 			}
99 111
 		}
100 112
 		if (!($data['account_id'] = admin_cmd::$accounts->save($data)))
@@ -103,7 +115,11 @@  discard block
 block discarded – undo
103 115
 			throw new Api\Db\Exception(lang("Error saving account!"),11);
104 116
 		}
105 117
 		$data['account_name'] = $data['account_lid'];	// also set deprecated name
106
-		if ($update) $data['old_name'] = $old['account_lid'];	// make old name available for hooks
118
+		if ($update)
119
+		{
120
+			$data['old_name'] = $old['account_lid'];
121
+		}
122
+		// make old name available for hooks
107 123
 		$GLOBALS['hook_values'] =& $data;
108 124
 		Api\Hooks::process($GLOBALS['hook_values']+array(
109 125
 			'location' => $update ? 'editgroup' : 'addgroup'
Please login to merge, or discard this patch.
admin/inc/class.admin_cmd_delete_account.inc.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * @param string $new_user =null if specified, account to transfer the data to (users only)
25 25
 	 * @param string $is_user =true type of the account: true=user, false=group
26 26
 	 */
27
-	function __construct($account,$new_user=null,$is_user=true)
27
+	function __construct($account, $new_user = null, $is_user = true)
28 28
 	{
29 29
 		if (!is_array($account))
30 30
 		{
@@ -46,18 +46,18 @@  discard block
 block discarded – undo
46 46
 	 * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15);
47 47
 	 * @throws Api\Exception\WrongUserinput(lang('Error changing the password for %1 !!!',$this->account),99);
48 48
 	 */
49
-	protected function exec($check_only=false)
49
+	protected function exec($check_only = false)
50 50
 	{
51
-		$account_id = admin_cmd::parse_account($this->account,$this->is_user);
51
+		$account_id = admin_cmd::parse_account($this->account, $this->is_user);
52 52
 		admin_cmd::_instanciate_accounts();
53 53
 		$account_lid = admin_cmd::$accounts->id2name($account_id);
54 54
 
55 55
 		if ($this->is_user && $this->new_user)
56 56
 		{
57
-			$new_user = admin_cmd::parse_account($this->new_user,true);	// true = user, no group
57
+			$new_user = admin_cmd::parse_account($this->new_user, true); // true = user, no group
58 58
 		}
59 59
 		// check creator is still admin and not explicitly forbidden to edit accounts
60
-		if ($this->creator) $this->_check_admin($this->is_user ? 'account_access' : 'group_access',32);
60
+		if ($this->creator) $this->_check_admin($this->is_user ? 'account_access' : 'group_access', 32);
61 61
 
62 62
 		if ($check_only) return true;
63 63
 
@@ -65,22 +65,22 @@  discard block
 block discarded – undo
65 65
 		$GLOBALS['hook_values'] = array(
66 66
 			'account_id'  => $account_id,
67 67
 			'account_lid' => $account_lid,
68
-			'account_name'=> $account_lid,		// depericated name for deletegroup hook
69
-			'new_owner'   => (int)$new_user,	// deleteaccount only
68
+			'account_name'=> $account_lid, // depericated name for deletegroup hook
69
+			'new_owner'   => (int)$new_user, // deleteaccount only
70 70
 			'location'    => $this->is_user ? 'deleteaccount' : 'deletegroup',
71 71
 		);
72 72
 		// first all other apps, then preferences and admin
73
-		foreach(array_merge(array_diff(array_keys($GLOBALS['egw_info']['apps']),array('preferences','admin')),array('preferences','admin')) as $app)
73
+		foreach (array_merge(array_diff(array_keys($GLOBALS['egw_info']['apps']), array('preferences', 'admin')), array('preferences', 'admin')) as $app)
74 74
 		{
75
-			Api\Hooks::single($GLOBALS['hook_values'],$app);
75
+			Api\Hooks::single($GLOBALS['hook_values'], $app);
76 76
 		}
77 77
 		$GLOBALS['egw']->accounts->delete($account_id);
78 78
 
79 79
 		if ($account_id < 0)
80 80
 		{
81
-			return lang("Group '%1' deleted.",$account_lid)."\n\n";
81
+			return lang("Group '%1' deleted.", $account_lid)."\n\n";
82 82
 		}
83
-		return lang("Account '%1' deleted.",$account_lid)."\n\n";
83
+		return lang("Account '%1' deleted.", $account_lid)."\n\n";
84 84
 	}
85 85
 
86 86
 	/**
@@ -90,6 +90,6 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	function __tostring()
92 92
 	{
93
-		return lang('Delete account %1',admin_cmd::display_account($this->account));
93
+		return lang('Delete account %1', admin_cmd::display_account($this->account));
94 94
 	}
95 95
 }
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,9 +57,15 @@
 block discarded – undo
57 57
 			$new_user = admin_cmd::parse_account($this->new_user,true);	// true = user, no group
58 58
 		}
59 59
 		// check creator is still admin and not explicitly forbidden to edit accounts
60
-		if ($this->creator) $this->_check_admin($this->is_user ? 'account_access' : 'group_access',32);
60
+		if ($this->creator)
61
+		{
62
+			$this->_check_admin($this->is_user ? 'account_access' : 'group_access',32);
63
+		}
61 64
 
62
-		if ($check_only) return true;
65
+		if ($check_only)
66
+		{
67
+			return true;
68
+		}
63 69
 
64 70
 		// delete the account
65 71
 		$GLOBALS['hook_values'] = array(
Please login to merge, or discard this patch.