Passed
Push — 16.1 ( db562c...7e0086 )
by Nathan
18:08
created
importexport/inc/class.importexport_definition.inc.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -176,7 +176,6 @@
 block discarded – undo
176 176
 	/**
177 177
 	 * sets options
178 178
 	 *
179
-	 * @param array $options
180 179
 	 */
181 180
 	private function set_options(array $_plugin_options) {
182 181
 		// Check conditions
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @param string $_identifier
67 67
 	 */
68
-	public function __construct( $_identifier='' ) {
69
-		$this->so_sql = new Api\Storage\Base(self::_appname ,self::_defintion_talbe);
68
+	public function __construct($_identifier = '') {
69
+		$this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_talbe);
70 70
 		$this->user = $GLOBALS['egw_info']['user']['user_id'];
71 71
 		$this->is_admin = $GLOBALS['egw_info']['user']['apps']['admin'] || $GLOBALS['egw_setup'] ? true : false;
72 72
 		// compability to string identifiers
@@ -74,17 +74,17 @@  discard block
 block discarded – undo
74 74
 
75 75
 		if ((int)$_identifier != 0) {
76 76
 			$this->definition = $this->so_sql->read(array('definition_id' => $_identifier));
77
-			if ( empty( $this->definition ) ) {
77
+			if (empty($this->definition)) {
78 78
 				throw new Exception('Error: No such definition with identifier :"'.$_identifier.'"!');
79 79
 			}
80
-			if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) {
80
+			if (!(importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) {
81 81
 				throw new Exception('Error: User "'.$this->user.'" is not permitted to get definition with identifier "'.$_identifier.'"!');
82 82
 			}
83 83
 			try
84 84
 			{
85
-				$options_data = importexport_arrayxml::xml2array( $this->definition['plugin_options'] );
85
+				$options_data = importexport_arrayxml::xml2array($this->definition['plugin_options']);
86 86
 				$this->definition['plugin_options'] = (array)$options_data['root'];
87
-				if($this->definition['filter']) $filter = importexport_arrayxml::xml2array( $this->definition['filter']  );
87
+				if ($this->definition['filter']) $filter = importexport_arrayxml::xml2array($this->definition['filter']);
88 88
 				$this->definition['filter'] = $filter['root'];
89 89
 			}
90 90
 			catch (Exception $e)
@@ -100,22 +100,22 @@  discard block
 block discarded – undo
100 100
 	 * @param string $_name
101 101
 	 * @return int
102 102
 	 */
103
-	private function name2identifier( $_name ) {
104
-		$identifiers = $this->so_sql->search(array('name' => $_name),true);
103
+	private function name2identifier($_name) {
104
+		$identifiers = $this->so_sql->search(array('name' => $_name), true);
105 105
 		if (isset($identifiers[1])) {
106
-			throw new Exception('Error: Definition: "'.$_name. '" is not unique! Can\'t convert to identifier');
106
+			throw new Exception('Error: Definition: "'.$_name.'" is not unique! Can\'t convert to identifier');
107 107
 		}
108
-		if ( empty( $identifiers[0] ) ) {
108
+		if (empty($identifiers[0])) {
109 109
 			// not a good idea, till we don't have different exceptions so far
110 110
 			// throw new Exception('Error: No such definition :"'.$_name.'"!');
111
-			$identifiers = array( array( 'definition_id' => 0 ) );
111
+			$identifiers = array(array('definition_id' => 0));
112 112
 		}
113 113
 		return $identifiers[0]['definition_id'];
114 114
 	}
115 115
 
116 116
 	public function __get($_attribute_name) {
117
-		if (!array_key_exists($_attribute_name,$this->attributes)) {
118
-			throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion');
117
+		if (!array_key_exists($_attribute_name, $this->attributes)) {
118
+			throw new Exception('Error: "'.$_attribute_name.'" is not an attribute defintion');
119 119
 		}
120 120
 		switch ($_attribute_name) {
121 121
 			case 'allowed_users' :
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
 		}
130 130
 	}
131 131
 
132
-	public function __set($_attribute_name,$_data) {
133
-		if (!array_key_exists($_attribute_name,$this->attributes)) {
134
-			throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion');
132
+	public function __set($_attribute_name, $_data) {
133
+		if (!array_key_exists($_attribute_name, $this->attributes)) {
134
+			throw new Exception('Error: "'.$_attribute_name.'" is not an attribute defintion');
135 135
 		}
136 136
 		switch ($_attribute_name) {
137 137
 			case 'allowed_users' :
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @return array
153 153
 	 */
154 154
 	private function get_allowed_users() {
155
-		return explode(',',substr($this->definition['allowed_users'],1,-1));
155
+		return explode(',', substr($this->definition['allowed_users'], 1, -1));
156 156
 	}
157 157
 
158 158
 	/**
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @param array $_allowed_users
162 162
 	 */
163
-	private function set_allowed_users( $_allowed_users ) {
164
-		$this->definition['allowed_users'] = ','.implode(',',(array)$_allowed_users) .',';
163
+	private function set_allowed_users($_allowed_users) {
164
+		$this->definition['allowed_users'] = ','.implode(',', (array)$_allowed_users).',';
165 165
 	}
166 166
 
167 167
 	/**
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	private function set_options(array $_plugin_options) {
182 182
 		// Check conditions
183
-		foreach ( $_plugin_options['conditions'] as $key => $condition ) {
184
-			if(!$condition['string'])
183
+		foreach ($_plugin_options['conditions'] as $key => $condition) {
184
+			if (!$condition['string'])
185 185
 			{
186 186
 				unset($_plugin_options['conditions'][$key]);
187 187
 			}
@@ -237,13 +237,13 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return void
239 239
 	 */
240
-	public function set_record( array $_record ) {
241
-		$this->definition = array_intersect_key( $_record, $this->attributes );
240
+	public function set_record(array $_record) {
241
+		$this->definition = array_intersect_key($_record, $this->attributes);
242 242
 
243 243
 		// anything which is not an attribute is perhaps a plugin_option.
244 244
 		// If not, it gets whiped out on save time.
245
-		foreach ( $_record as $attribute => $value) {
246
-			if ( !array_key_exists( $attribute, $this->attributes ) ) {
245
+		foreach ($_record as $attribute => $value) {
246
+			if (!array_key_exists($attribute, $this->attributes)) {
247 247
 				$this->definition['plugin_options'][$attribute] = $value;
248 248
 			}
249 249
 		}
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 		$this->plugin = $_record['plugin'];
252 252
 
253 253
 		// convert plugin_options into internal representation
254
-		$this->set_allowed_users( $this->definition['allowed_users'] );
255
-		$this->set_options( $this->definition['plugin_options'] ? $this->definition['plugin_options'] : array());
256
-		$this->set_filter( $this->definition['filter'] ? $this->definition['filter'] : array());
254
+		$this->set_allowed_users($this->definition['allowed_users']);
255
+		$this->set_options($this->definition['plugin_options'] ? $this->definition['plugin_options'] : array());
256
+		$this->set_filter($this->definition['filter'] ? $this->definition['filter'] : array());
257 257
 	}
258 258
 
259 259
 	/**
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 * @return string Full URL of an icon, or appname/icon_name
274 274
 	 */
275 275
 	public function get_icon() {
276
-		return self::_appname . '/navbar';
276
+		return self::_appname.'/navbar';
277 277
 	}
278 278
 
279 279
 	/**
@@ -281,16 +281,16 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return string identifier
283 283
 	 */
284
-	public function save ( $_dst_identifier ) {
285
-		if ( strlen($this->definition['name']) < 3 ) {
284
+	public function save($_dst_identifier) {
285
+		if (strlen($this->definition['name']) < 3) {
286 286
 			throw new Exception('Error: Can\'t save definition, no valid name given!');
287 287
 		}
288 288
 
289 289
 		$this->so_sql->data = $this->definition;
290
-		$this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml( $this->definition['plugin_options'] );
291
-		$this->so_sql->data['filter'] = importexport_arrayxml::array2xml( $this->definition['filter'] );
290
+		$this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml($this->definition['plugin_options']);
291
+		$this->so_sql->data['filter'] = importexport_arrayxml::array2xml($this->definition['filter']);
292 292
 		$this->so_sql->data['modified'] = time();
293
-		if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier ))) {
293
+		if ($this->so_sql->save(array('definition_id' => $_dst_identifier))) {
294 294
 			throw new Exception('Error: Api\Storage\Base was not able to save definition: '.$this->get_identifier());
295 295
 		}
296 296
 
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
 	 * @param string $_dst_identifier
304 304
 	 * @return string dst_identifier
305 305
 	 */
306
-	public function copy ( $_dst_identifier ) {
306
+	public function copy($_dst_identifier) {
307 307
 		$dst_object = clone $this;
308 308
 		try {
309 309
 			$dst_object->set_owner($this->user);
310 310
 			$dst_identifier = $dst_object->save($_dst_identifier);
311 311
 		}
312
-		catch(exception $Exception) {
312
+		catch (exception $Exception) {
313 313
 			unset($dst_object);
314 314
 			throw $Exception;
315 315
 		}
@@ -324,16 +324,16 @@  discard block
 block discarded – undo
324 324
 	 * @param string $_dst_identifier
325 325
 	 * @return string dst_identifier
326 326
 	 */
327
-	public function move ( $_dst_identifier ) {
327
+	public function move($_dst_identifier) {
328 328
 		if ($this->user != $this->get_owner() && !$this->is_admin) {
329
-			throw('Error: User '. $this->user. 'does not have permissions to move definition '.$this->get_identifier());
329
+			throw('Error: User '.$this->user.'does not have permissions to move definition '.$this->get_identifier());
330 330
 		}
331 331
 		$old_object = clone $this;
332 332
 		try {
333 333
 			$dst_identifier = $this->save($_dst_identifier);
334 334
 			$old_object->delete();
335 335
 		}
336
-		catch(exception $Exception) {
336
+		catch (exception $Exception) {
337 337
 			unset($old_object);
338 338
 			throw $Exception;
339 339
 		}
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
 	 * @return void
347 347
 	 *
348 348
 	 */
349
-	public function delete () {
350
-		if($this->user != $this->get_owner() && !$this->is_admin) {
351
-			throw('Error: User '. $this->user. 'does not have permissions to delete definition '.$this->get_identifier());
349
+	public function delete() {
350
+		if ($this->user != $this->get_owner() && !$this->is_admin) {
351
+			throw('Error: User '.$this->user.'does not have permissions to delete definition '.$this->get_identifier());
352 352
 		}
353
-		if(!$this->so_sql->delete()) {
353
+		if (!$this->so_sql->delete()) {
354 354
 			throw('Error: Api\Storage\Base was not able to delete definition: '.$this->get_identifier());
355 355
 		}
356 356
 	}
Please login to merge, or discard this patch.
Braces   +84 added lines, -40 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@  discard block
 block discarded – undo
20 20
  * are in one assiozative array which is complely managed by {Im|Ex}port plugins
21 21
  * @todo testing
22 22
  */
23
-class importexport_definition implements importexport_iface_egw_record {
23
+class importexport_definition implements importexport_iface_egw_record
24
+{
24 25
 
25 26
 	const _appname = 'importexport';
26 27
 	const _defintion_talbe = 'egw_importexport_definitions';
@@ -65,26 +66,36 @@  discard block
 block discarded – undo
65 66
 	 *
66 67
 	 * @param string $_identifier
67 68
 	 */
68
-	public function __construct( $_identifier='' ) {
69
+	public function __construct( $_identifier='' )
70
+	{
69 71
 		$this->so_sql = new Api\Storage\Base(self::_appname ,self::_defintion_talbe);
70 72
 		$this->user = $GLOBALS['egw_info']['user']['user_id'];
71 73
 		$this->is_admin = $GLOBALS['egw_info']['user']['apps']['admin'] || $GLOBALS['egw_setup'] ? true : false;
72 74
 		// compability to string identifiers
73
-		if (!is_numeric($_identifier) && strlen($_identifier) > 3) $_identifier = $this->name2identifier($_identifier);
75
+		if (!is_numeric($_identifier) && strlen($_identifier) > 3)
76
+		{
77
+			$_identifier = $this->name2identifier($_identifier);
78
+		}
74 79
 
75
-		if ((int)$_identifier != 0) {
80
+		if ((int)$_identifier != 0)
81
+		{
76 82
 			$this->definition = $this->so_sql->read(array('definition_id' => $_identifier));
77
-			if ( empty( $this->definition ) ) {
83
+			if ( empty( $this->definition ) )
84
+			{
78 85
 				throw new Exception('Error: No such definition with identifier :"'.$_identifier.'"!');
79 86
 			}
80
-			if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) {
87
+			if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin))
88
+			{
81 89
 				throw new Exception('Error: User "'.$this->user.'" is not permitted to get definition with identifier "'.$_identifier.'"!');
82 90
 			}
83 91
 			try
84 92
 			{
85 93
 				$options_data = importexport_arrayxml::xml2array( $this->definition['plugin_options'] );
86 94
 				$this->definition['plugin_options'] = (array)$options_data['root'];
87
-				if($this->definition['filter']) $filter = importexport_arrayxml::xml2array( $this->definition['filter']  );
95
+				if($this->definition['filter'])
96
+				{
97
+					$filter = importexport_arrayxml::xml2array( $this->definition['filter']  );
98
+				}
88 99
 				$this->definition['filter'] = $filter['root'];
89 100
 			}
90 101
 			catch (Exception $e)
@@ -100,12 +111,15 @@  discard block
 block discarded – undo
100 111
 	 * @param string $_name
101 112
 	 * @return int
102 113
 	 */
103
-	private function name2identifier( $_name ) {
114
+	private function name2identifier( $_name )
115
+	{
104 116
 		$identifiers = $this->so_sql->search(array('name' => $_name),true);
105
-		if (isset($identifiers[1])) {
117
+		if (isset($identifiers[1]))
118
+		{
106 119
 			throw new Exception('Error: Definition: "'.$_name. '" is not unique! Can\'t convert to identifier');
107 120
 		}
108
-		if ( empty( $identifiers[0] ) ) {
121
+		if ( empty( $identifiers[0] ) )
122
+		{
109 123
 			// not a good idea, till we don't have different exceptions so far
110 124
 			// throw new Exception('Error: No such definition :"'.$_name.'"!');
111 125
 			$identifiers = array( array( 'definition_id' => 0 ) );
@@ -113,11 +127,14 @@  discard block
 block discarded – undo
113 127
 		return $identifiers[0]['definition_id'];
114 128
 	}
115 129
 
116
-	public function __get($_attribute_name) {
117
-		if (!array_key_exists($_attribute_name,$this->attributes)) {
130
+	public function __get($_attribute_name)
131
+	{
132
+		if (!array_key_exists($_attribute_name,$this->attributes))
133
+		{
118 134
 			throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion');
119 135
 		}
120
-		switch ($_attribute_name) {
136
+		switch ($_attribute_name)
137
+		{
121 138
 			case 'allowed_users' :
122 139
 				return $this->get_allowed_users();
123 140
 			case 'plugin_options' :
@@ -129,11 +146,14 @@  discard block
 block discarded – undo
129 146
 		}
130 147
 	}
131 148
 
132
-	public function __set($_attribute_name,$_data) {
133
-		if (!array_key_exists($_attribute_name,$this->attributes)) {
149
+	public function __set($_attribute_name,$_data)
150
+	{
151
+		if (!array_key_exists($_attribute_name,$this->attributes))
152
+		{
134 153
 			throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion');
135 154
 		}
136
-		switch ($_attribute_name) {
155
+		switch ($_attribute_name)
156
+		{
137 157
 			case 'allowed_users' :
138 158
 				return $this->set_allowed_users($_data);
139 159
 			case 'plugin_options' :
@@ -151,7 +171,8 @@  discard block
 block discarded – undo
151 171
 	 *
152 172
 	 * @return array
153 173
 	 */
154
-	private function get_allowed_users() {
174
+	private function get_allowed_users()
175
+	{
155 176
 		return explode(',',substr($this->definition['allowed_users'],1,-1));
156 177
 	}
157 178
 
@@ -160,7 +181,8 @@  discard block
 block discarded – undo
160 181
 	 *
161 182
 	 * @param array $_allowed_users
162 183
 	 */
163
-	private function set_allowed_users( $_allowed_users ) {
184
+	private function set_allowed_users( $_allowed_users )
185
+	{
164 186
 		$this->definition['allowed_users'] = ','.implode(',',(array)$_allowed_users) .',';
165 187
 	}
166 188
 
@@ -169,7 +191,8 @@  discard block
 block discarded – undo
169 191
 	 *
170 192
 	 * @return array
171 193
 	 */
172
-	private function get_options() {
194
+	private function get_options()
195
+	{
173 196
 		return $this->definition['plugin_options'];
174 197
 	}
175 198
 
@@ -178,9 +201,11 @@  discard block
 block discarded – undo
178 201
 	 *
179 202
 	 * @param array $options
180 203
 	 */
181
-	private function set_options(array $_plugin_options) {
204
+	private function set_options(array $_plugin_options)
205
+	{
182 206
 		// Check conditions
183
-		foreach ( $_plugin_options['conditions'] as $key => $condition ) {
207
+		foreach ( $_plugin_options['conditions'] as $key => $condition )
208
+		{
184 209
 			if(!$condition['string'])
185 210
 			{
186 211
 				unset($_plugin_options['conditions'][$key]);
@@ -194,7 +219,8 @@  discard block
 block discarded – undo
194 219
 	 *
195 220
 	 * @return array
196 221
 	 */
197
-	private function get_filter() {
222
+	private function get_filter()
223
+	{
198 224
 		return $this->definition['filter'];
199 225
 	}
200 226
 
@@ -203,7 +229,8 @@  discard block
 block discarded – undo
203 229
 	 *
204 230
 	 * @param filter array of field => settings
205 231
 	 */
206
-	private function set_filter(Array $filter) {
232
+	private function set_filter(Array $filter)
233
+	{
207 234
 		$this->definition['filter'] = $filter;
208 235
 	}
209 236
 
@@ -215,7 +242,8 @@  discard block
 block discarded – undo
215 242
 	 *
216 243
 	 * @return array complete record as associative array
217 244
 	 */
218
-	public function get_record_array() {
245
+	public function get_record_array()
246
+	{
219 247
 		$definition = $this->definition;
220 248
 		$definition['allowed_users'] = $this->get_allowed_users();
221 249
 		$definition['plugin_options'] = $this->get_options();
@@ -228,7 +256,8 @@  discard block
 block discarded – undo
228 256
 	 *
229 257
 	 *@return string tiltle
230 258
 	 */
231
-	public function get_title() {
259
+	public function get_title()
260
+	{
232 261
 		return $this->definition['name'];
233 262
 	}
234 263
 
@@ -237,13 +266,16 @@  discard block
 block discarded – undo
237 266
 	 *
238 267
 	 * @return void
239 268
 	 */
240
-	public function set_record( array $_record ) {
269
+	public function set_record( array $_record )
270
+	{
241 271
 		$this->definition = array_intersect_key( $_record, $this->attributes );
242 272
 
243 273
 		// anything which is not an attribute is perhaps a plugin_option.
244 274
 		// If not, it gets whiped out on save time.
245
-		foreach ( $_record as $attribute => $value) {
246
-			if ( !array_key_exists( $attribute, $this->attributes ) ) {
275
+		foreach ( $_record as $attribute => $value)
276
+		{
277
+			if ( !array_key_exists( $attribute, $this->attributes ) )
278
+			{
247 279
 				$this->definition['plugin_options'][$attribute] = $value;
248 280
 			}
249 281
 		}
@@ -261,7 +293,8 @@  discard block
 block discarded – undo
261 293
 	 *
262 294
 	 * @return int identifier of this record
263 295
 	 */
264
-	public function get_identifier() {
296
+	public function get_identifier()
297
+	{
265 298
 		return $this->definition['definition_id'];
266 299
 	}
267 300
 
@@ -272,7 +305,8 @@  discard block
 block discarded – undo
272 305
 	 *
273 306
 	 * @return string Full URL of an icon, or appname/icon_name
274 307
 	 */
275
-	public function get_icon() {
308
+	public function get_icon()
309
+	{
276 310
 		return self::_appname . '/navbar';
277 311
 	}
278 312
 
@@ -281,8 +315,10 @@  discard block
 block discarded – undo
281 315
 	 *
282 316
 	 * @return string identifier
283 317
 	 */
284
-	public function save ( $_dst_identifier ) {
285
-		if ( strlen($this->definition['name']) < 3 ) {
318
+	public function save ( $_dst_identifier )
319
+	{
320
+		if ( strlen($this->definition['name']) < 3 )
321
+		{
286 322
 			throw new Exception('Error: Can\'t save definition, no valid name given!');
287 323
 		}
288 324
 
@@ -290,7 +326,8 @@  discard block
 block discarded – undo
290 326
 		$this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml( $this->definition['plugin_options'] );
291 327
 		$this->so_sql->data['filter'] = importexport_arrayxml::array2xml( $this->definition['filter'] );
292 328
 		$this->so_sql->data['modified'] = time();
293
-		if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier ))) {
329
+		if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier )))
330
+		{
294 331
 			throw new Exception('Error: Api\Storage\Base was not able to save definition: '.$this->get_identifier());
295 332
 		}
296 333
 
@@ -303,7 +340,8 @@  discard block
 block discarded – undo
303 340
 	 * @param string $_dst_identifier
304 341
 	 * @return string dst_identifier
305 342
 	 */
306
-	public function copy ( $_dst_identifier ) {
343
+	public function copy ( $_dst_identifier )
344
+	{
307 345
 		$dst_object = clone $this;
308 346
 		try {
309 347
 			$dst_object->set_owner($this->user);
@@ -324,8 +362,10 @@  discard block
 block discarded – undo
324 362
 	 * @param string $_dst_identifier
325 363
 	 * @return string dst_identifier
326 364
 	 */
327
-	public function move ( $_dst_identifier ) {
328
-		if ($this->user != $this->get_owner() && !$this->is_admin) {
365
+	public function move ( $_dst_identifier )
366
+	{
367
+		if ($this->user != $this->get_owner() && !$this->is_admin)
368
+		{
329 369
 			throw('Error: User '. $this->user. 'does not have permissions to move definition '.$this->get_identifier());
330 370
 		}
331 371
 		$old_object = clone $this;
@@ -346,11 +386,14 @@  discard block
 block discarded – undo
346 386
 	 * @return void
347 387
 	 *
348 388
 	 */
349
-	public function delete () {
350
-		if($this->user != $this->get_owner() && !$this->is_admin) {
389
+	public function delete ()
390
+	{
391
+		if($this->user != $this->get_owner() && !$this->is_admin)
392
+		{
351 393
 			throw('Error: User '. $this->user. 'does not have permissions to delete definition '.$this->get_identifier());
352 394
 		}
353
-		if(!$this->so_sql->delete()) {
395
+		if(!$this->so_sql->delete())
396
+		{
354 397
 			throw('Error: Api\Storage\Base was not able to delete definition: '.$this->get_identifier());
355 398
 		}
356 399
 	}
@@ -359,7 +402,8 @@  discard block
 block discarded – undo
359 402
 	 * destructor
360 403
 	 *
361 404
 	 */
362
-	public function __destruct() {
405
+	public function __destruct()
406
+	{
363 407
 		unset($this->so_sql);
364 408
 	}
365 409
 
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_wizard_import_contacts_csv.inc.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 		$bocontacts = new Api\Contacts();
32 32
 		$this->mapping_fields = $bocontacts->contact_fields;
33 33
 
34
-		$categories = new Api\Categories('','addressbook');
34
+		$categories = new Api\Categories('', 'addressbook');
35 35
 		$cat_list = array();
36
-		foreach((array)$categories->return_sorted_array(0,False,'','','',true,0,true) as $cat)
36
+		foreach ((array)$categories->return_sorted_array(0, False, '', '', '', true, 0, true) as $cat)
37 37
 		{
38
-			$s = str_repeat('&nbsp;',$cat['level']) . stripslashes($cat['name']);
38
+			$s = str_repeat('&nbsp;', $cat['level']).stripslashes($cat['name']);
39 39
 
40 40
 			if (Api\Categories::is_global($cat))
41 41
 			{
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 				'title' => $cat['description'],
47 47
 			);
48 48
 		}
49
-		if(count($cat_list) > 0) {
49
+		if (count($cat_list) > 0) {
50 50
 			$this->mapping_fields[lang('Categories')] = $cat_list;
51 51
 		}
52 52
 
53
-		foreach($bocontacts->customfields as $name => $data) {
53
+		foreach ($bocontacts->customfields as $name => $data) {
54 54
 			$this->mapping_fields['#'.$name] = $data['label'];
55 55
 		}
56
-		unset($this->mapping_fields['jpegphoto']);        // can't cvs import that
56
+		unset($this->mapping_fields['jpegphoto']); // can't cvs import that
57 57
 
58 58
 		// Add in special handled fields
59 59
 		$this->mapping_fields[lang('Special')] = addressbook_import_contacts_csv::$special_fields;
@@ -75,18 +75,18 @@  discard block
 block discarded – undo
75 75
 
76 76
 	function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
77 77
 	{
78
-		if($content['field_mapping'][0] == lang('Categories')) {
78
+		if ($content['field_mapping'][0] == lang('Categories')) {
79 79
 			unset($content['field_mapping'][0]);
80 80
 		}
81 81
 		$result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv);
82
-		$content['msg'] .= "\n*" . lang('Contact ID cannot be changed by import');
82
+		$content['msg'] .= "\n*".lang('Contact ID cannot be changed by import');
83 83
 
84 84
 		return $result;
85 85
 	}
86 86
 
87 87
 	function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv)
88 88
 	{
89
-		if($this->debug) error_log('addressbook.importexport.addressbook_csv_import::wizard_step60->$content '.print_r($content,true));
89
+		if ($this->debug) error_log('addressbook.importexport.addressbook_csv_import::wizard_step60->$content '.print_r($content, true));
90 90
 		unset($content['no_owner_map']);
91 91
 		// return from step60
92 92
 		if ($content['step'] == 'wizard_step60')
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 			switch (array_search('pressed', $content['button']))
95 95
 			{
96 96
 				case 'next':
97
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
97
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
98 98
 				case 'previous' :
99
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
99
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
100 100
 				case 'finish':
101 101
 					return 'wizard_finish';
102 102
 				default :
103
-					return $this->wizard_step60($content,$sel_options,$readonlys,$preserv);
103
+					return $this->wizard_step60($content, $sel_options, $readonlys, $preserv);
104 104
 			}
105 105
 		}
106 106
 		// init step60
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
 		{
109 109
 			$content['msg'] = $this->steps['wizard_step60'];
110 110
 			$content['step'] = 'wizard_step60';
111
-			if(!array_key_exists($content['contact_owner']) && $content['plugin_options']) {
111
+			if (!array_key_exists($content['contact_owner']) && $content['plugin_options']) {
112 112
 				$content['contact_owner'] = $content['plugin_options']['contact_owner'];
113 113
 			}
114
-			if(!array_key_exists($content['owner_from_csv']) && $content['plugin_options']) {
114
+			if (!array_key_exists($content['owner_from_csv']) && $content['plugin_options']) {
115 115
 				$content['owner_from_csv'] = $content['plugin_options']['owner_from_csv'];
116 116
 			}
117
-			if(!array_key_exists($content['change_owner']) && $content['plugin_options']) {
117
+			if (!array_key_exists($content['change_owner']) && $content['plugin_options']) {
118 118
 				$content['change_owner'] = $content['plugin_options']['change_owner'];
119 119
 			}
120 120
 
121 121
 			$bocontacts = new Api\Contacts();
122 122
 			$sel_options['contact_owner'] = array('personal' => lang("Importer's personal")) + $bocontacts->get_addressbooks(Acl::ADD);
123
-			if(!in_array($content['contact_owner'], $sel_options['contact_owner']))
123
+			if (!in_array($content['contact_owner'], $sel_options['contact_owner']))
124 124
 			{
125
-				$sel_options['contact_owner'][$content['contact_owner']] = lang("'%1' is not allowed ('%2')!", $content['contact_owner'], implode(',',array_keys($sel_options['contact_owner'])));
125
+				$sel_options['contact_owner'][$content['contact_owner']] = lang("'%1' is not allowed ('%2')!", $content['contact_owner'], implode(',', array_keys($sel_options['contact_owner'])));
126 126
 			}
127
-			if(!in_array('owner', $content['field_mapping'])) {
127
+			if (!in_array('owner', $content['field_mapping'])) {
128 128
 				$content['no_owner_map'] = true;
129 129
 			}
130 130
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,11 +46,13 @@  discard block
 block discarded – undo
46 46
 				'title' => $cat['description'],
47 47
 			);
48 48
 		}
49
-		if(count($cat_list) > 0) {
49
+		if(count($cat_list) > 0)
50
+		{
50 51
 			$this->mapping_fields[lang('Categories')] = $cat_list;
51 52
 		}
52 53
 
53
-		foreach($bocontacts->customfields as $name => $data) {
54
+		foreach($bocontacts->customfields as $name => $data)
55
+		{
54 56
 			$this->mapping_fields['#'.$name] = $data['label'];
55 57
 		}
56 58
 		unset($this->mapping_fields['jpegphoto']);        // can't cvs import that
@@ -75,7 +77,8 @@  discard block
 block discarded – undo
75 77
 
76 78
 	function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
77 79
 	{
78
-		if($content['field_mapping'][0] == lang('Categories')) {
80
+		if($content['field_mapping'][0] == lang('Categories'))
81
+		{
79 82
 			unset($content['field_mapping'][0]);
80 83
 		}
81 84
 		$result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv);
@@ -86,7 +89,10 @@  discard block
 block discarded – undo
86 89
 
87 90
 	function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv)
88 91
 	{
89
-		if($this->debug) error_log('addressbook.importexport.addressbook_csv_import::wizard_step60->$content '.print_r($content,true));
92
+		if($this->debug)
93
+		{
94
+			error_log('addressbook.importexport.addressbook_csv_import::wizard_step60->$content '.print_r($content,true));
95
+		}
90 96
 		unset($content['no_owner_map']);
91 97
 		// return from step60
92 98
 		if ($content['step'] == 'wizard_step60')
@@ -108,13 +114,16 @@  discard block
 block discarded – undo
108 114
 		{
109 115
 			$content['msg'] = $this->steps['wizard_step60'];
110 116
 			$content['step'] = 'wizard_step60';
111
-			if(!array_key_exists($content['contact_owner']) && $content['plugin_options']) {
117
+			if(!array_key_exists($content['contact_owner']) && $content['plugin_options'])
118
+			{
112 119
 				$content['contact_owner'] = $content['plugin_options']['contact_owner'];
113 120
 			}
114
-			if(!array_key_exists($content['owner_from_csv']) && $content['plugin_options']) {
121
+			if(!array_key_exists($content['owner_from_csv']) && $content['plugin_options'])
122
+			{
115 123
 				$content['owner_from_csv'] = $content['plugin_options']['owner_from_csv'];
116 124
 			}
117
-			if(!array_key_exists($content['change_owner']) && $content['plugin_options']) {
125
+			if(!array_key_exists($content['change_owner']) && $content['plugin_options'])
126
+			{
118 127
 				$content['change_owner'] = $content['plugin_options']['change_owner'];
119 128
 			}
120 129
 
@@ -124,7 +133,8 @@  discard block
 block discarded – undo
124 133
 			{
125 134
 				$sel_options['contact_owner'][$content['contact_owner']] = lang("'%1' is not allowed ('%2')!", $content['contact_owner'], implode(',',array_keys($sel_options['contact_owner'])));
126 135
 			}
127
-			if(!in_array('owner', $content['field_mapping'])) {
136
+			if(!in_array('owner', $content['field_mapping']))
137
+			{
128 138
 				$content['no_owner_map'] = true;
129 139
 			}
130 140
 
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_import_contacts_csv.inc.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * class import_csv for addressbook
17 17
  */
18
-class addressbook_import_contacts_csv extends importexport_basic_import_csv  {
18
+class addressbook_import_contacts_csv extends importexport_basic_import_csv {
19 19
 
20 20
 	/**
21 21
 	 * conditions for actions
22 22
 	 *
23 23
 	 * @var array
24 24
 	 */
25
-	protected static $conditions = array( 'exists', 'equal' );
25
+	protected static $conditions = array('exists', 'equal');
26 26
 
27 27
 	/**
28 28
 	 * @var bocontacts
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param string $_charset
49 49
 	 * @param definition $_definition
50 50
 	 */
51
-	public function init(importexport_definition &$_definition ) {
51
+	public function init(importexport_definition&$_definition) {
52 52
 
53 53
 		// fetch the addressbook bo
54 54
 		$this->bocontacts = new Api\Contacts();
@@ -59,27 +59,27 @@  discard block
 block discarded – undo
59 59
 		$this->lookups = array(
60 60
 			'tid' => array('n'=>'contact')
61 61
 		);
62
-		foreach($this->bocontacts->content_types as $tid => $data)
62
+		foreach ($this->bocontacts->content_types as $tid => $data)
63 63
 		{
64 64
 			$this->lookups['tid'][$tid] = $data['name'];
65 65
 		}
66 66
 
67 67
 		// set contact owner
68
-		$contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ?
68
+		$contact_owner = isset($_definition->plugin_options['contact_owner']) ?
69 69
 			$_definition->plugin_options['contact_owner'] : $this->user;
70 70
 
71 71
 		// Check to make sure target addressbook is valid
72
-		if(!in_array($contact_owner, array_keys($this->bocontacts->get_addressbooks(Api\Acl::ADD))))
72
+		if (!in_array($contact_owner, array_keys($this->bocontacts->get_addressbooks(Api\Acl::ADD))))
73 73
 		{
74 74
 			$this->warnings[0] = lang("Unable to import into %1, using %2",
75
-				$contact_owner . ' ('.Api\Accounts::username($record->owner) . ')',
75
+				$contact_owner.' ('.Api\Accounts::username($record->owner).')',
76 76
 				Api\Accounts::username($this->user)
77 77
 			);
78 78
 			$contact_owner = 'personal';
79 79
 		}
80 80
 
81 81
 		// Import into importer's personal addressbook
82
-		if($contact_owner == 'personal')
82
+		if ($contact_owner == 'personal')
83 83
 		{
84 84
 			$contact_owner = $this->user;
85 85
 		}
@@ -96,15 +96,15 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @return boolean success
98 98
 	 */
99
-	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
99
+	protected function import_record(importexport_iface_egw_record&$record, &$import_csv)
100 100
 	{
101 101
 
102 102
 		// Set owner, unless it's supposed to come from CSV file
103
-		if($this->definition->plugin_options['owner_from_csv'] && $record->owner) {
104
-			if(!is_numeric($record->owner)) {
103
+		if ($this->definition->plugin_options['owner_from_csv'] && $record->owner) {
104
+			if (!is_numeric($record->owner)) {
105 105
 				// Automatically handle text owner without explicit translation
106 106
 				$new_owner = importexport_helper_functions::account_name2id($record->owner);
107
-				if($new_owner == '') {
107
+				if ($new_owner == '') {
108 108
 					$this->errors[$import_csv->get_current_position()] = lang(
109 109
 						'Unable to convert "%1" to account ID.  Using plugin setting (%2) for owner.',
110 110
 						$record->owner,
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		}
121 121
 
122 122
 		// Check that owner (addressbook) is allowed
123
-		if(!array_key_exists($record->owner, $this->bocontacts->get_addressbooks()))
123
+		if (!array_key_exists($record->owner, $this->bocontacts->get_addressbooks()))
124 124
 		{
125 125
 			$this->errors[$import_csv->get_current_position()] = lang("Unable to import into %1, using %2",
126 126
 				Api\Accounts::username($record->owner),
@@ -131,18 +131,18 @@  discard block
 block discarded – undo
131 131
 
132 132
 		// Do not allow owner == 0 (accounts) without an account_id
133 133
 		// It causes the contact to be filed as an account, and can't delete
134
-		if(!$record->owner && !$record->account_id)
134
+		if (!$record->owner && !$record->account_id)
135 135
 		{
136 136
 			$record->owner = $GLOBALS['egw_info']['user']['account_id'];
137 137
 		}
138 138
 
139 139
 		// Do not import into non-existing type, warn and change
140
-		if(!$record->tid || !$this->lookups['tid'][$record->tid])
140
+		if (!$record->tid || !$this->lookups['tid'][$record->tid])
141 141
 		{
142 142
 			// Avoid lots of warnings about type (2 types are contact and deleted)
143
-			if(!$this->type_warned || count($this->lookups['tid']) == 2 )
143
+			if (!$this->type_warned || count($this->lookups['tid']) == 2)
144 144
 			{
145
-				$this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2',$record->tid,lang($this->lookups['tid']['n']));
145
+				$this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2', $record->tid, lang($this->lookups['tid']['n']));
146 146
 				$this->type_warned = true;
147 147
 			}
148 148
 			$record->tid = 'n';
@@ -151,45 +151,45 @@  discard block
 block discarded – undo
151 151
 		// Also handle categories in their own field
152 152
 		$record_array = $record->get_record_array();
153 153
 		$more_categories = array();
154
-		foreach($this->definition->plugin_options['field_mapping'] as $field_name) {
155
-			if(!array_key_exists($field_name, $record_array) ||
156
-				substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue;
154
+		foreach ($this->definition->plugin_options['field_mapping'] as $field_name) {
155
+			if (!array_key_exists($field_name, $record_array) ||
156
+				substr($field_name, 0, 3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue;
157 157
 			list(, $cat_id) = explode('-', $field_name);
158
-			if(is_numeric($record->$field_name) && $record->$field_name != 1) {
158
+			if (is_numeric($record->$field_name) && $record->$field_name != 1) {
159 159
 				// Column has a single category ID
160 160
 				$more_categories[] = $record->$field_name;
161
-			} elseif($record->$field_name == '1' ||
161
+			} elseif ($record->$field_name == '1' ||
162 162
 				(!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) {
163 163
 				// Each category got its own column.  '1' is the database value, lang('yes') is the human value
164 164
 				$more_categories[] = $cat_id;
165 165
 			} else {
166 166
 				// Text categories
167
-				$more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id));
167
+				$more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',', $record->$field_name), $cat_id));
168 168
 			}
169 169
 		}
170
-		if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories);
170
+		if (count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',', $record->cat_id), $more_categories);
171 171
 
172 172
 		// Private set but missing causes hidden entries
173
-		if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private);
173
+		if (array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private);
174 174
 
175 175
 		// Format birthday as backend requires - converter should give timestamp
176
-		if($record->bday && is_numeric($record->bday))
176
+		if ($record->bday && is_numeric($record->bday))
177 177
 		{
178 178
 			$time = new Api\DateTime($record->bday);
179 179
 			$record->bday = $time->format('Y-m-d');
180 180
 		}
181 181
 
182
-		if ( $this->definition->plugin_options['conditions'] ) {
183
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
182
+		if ($this->definition->plugin_options['conditions']) {
183
+			foreach ($this->definition->plugin_options['conditions'] as $condition) {
184 184
 				$contacts = array();
185
-				switch ( $condition['type'] ) {
185
+				switch ($condition['type']) {
186 186
 					// exists
187 187
 					case 'exists' :
188
-						if($record_array[$condition['string']]) {
189
-							$searchcondition = array( $condition['string'] => $record_array[$condition['string']]);
188
+						if ($record_array[$condition['string']]) {
189
+							$searchcondition = array($condition['string'] => $record_array[$condition['string']]);
190 190
 							// if we use account_id for the condition, we need to set the owner for filtering, as this
191 191
 							// enables Api\Contacts\Storage to decide what backend is to be used
192
-							if ($condition['string']=='account_id') $searchcondition['owner']=0;
192
+							if ($condition['string'] == 'account_id') $searchcondition['owner'] = 0;
193 193
 							$contacts = $this->bocontacts->search(
194 194
 								//array( $condition['string'] => $record[$condition['string']],),
195 195
 								'',
@@ -198,37 +198,37 @@  discard block
 block discarded – undo
198 198
 								$searchcondition
199 199
 							);
200 200
 						}
201
-						if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) {
201
+						if (is_array($contacts) && count(array_keys($contacts)) >= 1) {
202 202
 							// apply action to all contacts matching this exists condition
203 203
 							$action = $condition['true'];
204
-							foreach ( (array)$contacts as $contact ) {
204
+							foreach ((array)$contacts as $contact) {
205 205
 								$record->id = $contact['id'];
206
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
207
-									if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
208
-									if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id );
209
-									$record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) );
206
+								if ($this->definition->plugin_options['update_cats'] == 'add') {
207
+									if (!is_array($contact['cat_id'])) $contact['cat_id'] = explode(',', $contact['cat_id']);
208
+									if (!is_array($record_array['cat_id'])) $record->cat_id = explode(',', $record->cat_id);
209
+									$record->cat_id = implode(',', array_unique(array_merge($record->cat_id, $contact['cat_id'])));
210 210
 								}
211
-								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
211
+								$success = $this->action($action['action'], $record, $import_csv->get_current_position());
212 212
 							}
213 213
 						} else {
214 214
 							$action = $condition['false'];
215
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
215
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
216 216
 						}
217 217
 						break;
218 218
 					case 'equal':
219 219
 						// Match on field
220 220
 						$result = $this->equal($record, $condition);
221
-						if($result)
221
+						if ($result)
222 222
 						{
223 223
 							// Apply true action to any matching records found
224 224
 							$action = $condition['true'];
225
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
225
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
226 226
 						}
227 227
 						else
228 228
 						{
229 229
 							// Apply false action if no matching records found
230 230
 							$action = $condition['false'];
231
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
231
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
232 232
 						}
233 233
 						break;
234 234
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 			}
241 241
 		} else {
242 242
 			// unconditional insert
243
-			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
243
+			$success = $this->action('insert', $record, $import_csv->get_current_position());
244 244
 		}
245 245
 		return $success;
246 246
 	}
@@ -252,21 +252,21 @@  discard block
 block discarded – undo
252 252
 	 * @param importexport_iface_egw_record $record contact data for the action
253 253
 	 * @return bool success or not
254 254
 	 */
255
-	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) {
255
+	protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0) {
256 256
 		$_data = $record->get_record_array();
257 257
 		switch ($_action) {
258 258
 			case 'none' :
259 259
 				return true;
260 260
 			case 'delete':
261
-				if($_data['id'])
261
+				if ($_data['id'])
262 262
 				{
263
-					if ( $this->dry_run ) {
263
+					if ($this->dry_run) {
264 264
 						//print_r($_data);
265 265
 						$this->results[$_action]++;
266 266
 						return true;
267 267
 					}
268 268
 					$result = $this->bocontacts->delete($_data);
269
-					if($result && $result === true)
269
+					if ($result && $result === true)
270 270
 					{
271 271
 						$this->results[$_action]++;
272 272
 					}
@@ -281,14 +281,14 @@  discard block
 block discarded – undo
281 281
 				// Only update if there are changes
282 282
 				$old = $this->bocontacts->read($_data['id']);
283 283
 				// if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes.
284
-				foreach(array('adr_one_', 'adr_two_') as $c_prefix) {
285
-					if (strlen(trim($_data[$c_prefix.'countryname']))==2)
284
+				foreach (array('adr_one_', 'adr_two_') as $c_prefix) {
285
+					if (strlen(trim($_data[$c_prefix.'countryname'])) == 2)
286 286
 						$_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true);
287 287
 				}
288 288
 				// Don't change a user account into a contact
289
-				if($old['owner'] == 0) {
289
+				if ($old['owner'] == 0) {
290 290
 					unset($_data['owner']);
291
-				} elseif(!$this->definition->plugin_options['change_owner']) {
291
+				} elseif (!$this->definition->plugin_options['change_owner']) {
292 292
 					// Don't change addressbook of an existing contact
293 293
 					unset($_data['owner']);
294 294
 				}
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 				// Merge to deal with fields not in import record
297 297
 				$_data = array_merge($old, $_data);
298 298
 				$changed = $this->tracking->changed_fields($_data, $old);
299
-				if(count($changed) == 0) {
299
+				if (count($changed) == 0) {
300 300
 					return true;
301 301
 				} else {
302 302
 					//error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')');
@@ -307,22 +307,22 @@  discard block
 block discarded – undo
307 307
 
308 308
 				// Fall through
309 309
 			case 'insert' :
310
-				if($_action == 'insert') {
310
+				if ($_action == 'insert') {
311 311
 					// Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag
312 312
 					unset($_data['id']);
313 313
 				}
314
-				if(!isset($_data['org_name'])) {
314
+				if (!isset($_data['org_name'])) {
315 315
 					// org_name is a trigger to update n_fileas
316 316
 					$_data['org_name'] = '';
317 317
 				}
318 318
 
319
-				if ( $this->dry_run ) {
319
+				if ($this->dry_run) {
320 320
 					//print_r($_data);
321 321
 					$this->results[$_action]++;
322 322
 					return true;
323 323
 				} else {
324
-					$result = $this->bocontacts->save( $_data, $this->is_admin);
325
-					if(!$result) {
324
+					$result = $this->bocontacts->save($_data, $this->is_admin);
325
+					if (!$result) {
326 326
 						$this->errors[$record_num] = $this->bocontacts->error;
327 327
 					} else {
328 328
 						$this->results[$_action]++;
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 					return $result;
333 333
 				}
334 334
 			default:
335
-				throw new Api\Exception('Unsupported action: '. $_action);
335
+				throw new Api\Exception('Unsupported action: '.$_action);
336 336
 
337 337
 		}
338 338
 	}
Please login to merge, or discard this patch.