Completed
Push — master ( df263c...059178 )
by Ralf
91:04 queued 68:58
created
importexport/inc/class.importexport_iface_egw_record.inc.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @param string $_identifier
38 38
 	 */
39
-	public function __construct( $_identifier='' );
39
+	public function __construct($_identifier = '');
40 40
 	
41 41
 	/**
42 42
 	 * magic method to set attributes of record
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return string identifier
99 99
 	 */
100
-	public function save ( $_dst_identifier );
100
+	public function save($_dst_identifier);
101 101
 	
102 102
 	/**
103 103
 	 * copys current record to record identified by $_dst_identifier
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @param string $_dst_identifier
106 106
 	 * @return string dst_identifier
107 107
 	 */
108
-	public function copy ( $_dst_identifier );
108
+	public function copy($_dst_identifier);
109 109
 	
110 110
 	/**
111 111
 	 * moves current record to record identified by $_dst_identifier
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 	 * @param string $_dst_identifier
115 115
 	 * @return string dst_identifier
116 116
 	 */
117
-	public function move ( $_dst_identifier );
117
+	public function move($_dst_identifier);
118 118
 	
119 119
 	/**
120 120
 	 * delets current record from backend
121 121
 	 * @return void
122 122
 	 *
123 123
 	 */
124
-	public function delete ();
124
+	public function delete();
125 125
 	
126 126
 	/**
127 127
 	 * destructor
Please login to merge, or discard this patch.
importexport/inc/class.importexport_helper_functions.inc.php 4 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -32,25 +32,25 @@  discard block
 block discarded – undo
32 32
 	 * Relative date ranges for filtering
33 33
 	 */
34 34
 	public static $relative_dates = array(      // Start: year,month,day,week, End: year,month,day,week
35
-                'Today'       => array(0,0,0,0,  0,0,1,0),
36
-                'Yesterday'   => array(0,0,-1,0, 0,0,0,0),
37
-                'This week'   => array(0,0,0,0,  0,0,0,1),
38
-                'Last week'   => array(0,0,0,-1, 0,0,0,0),
39
-                'This month'  => array(0,0,0,0,  0,1,0,0),
40
-                'Last month'  => array(0,-1,0,0, 0,0,0,0),
41
-                'Last 3 months' => array(0,-3,0,0, 0,0,0,0),
42
-                'This quarter'=> array(0,0,0,0,  0,0,0,0),      // Just a marker, needs special handling
43
-                'Last quarter'=> array(0,-4,0,0, 0,-4,0,0),     // Just a marker
44
-                'This year'   => array(0,0,0,0,  1,0,0,0),
45
-                'Last year'   => array(-1,0,0,0, 0,0,0,0),
46
-                '2 years ago' => array(-2,0,0,0, -1,0,0,0),
47
-                '3 years ago' => array(-3,0,0,0, -2,0,0,0),
48
-        );
35
+				'Today'       => array(0,0,0,0,  0,0,1,0),
36
+				'Yesterday'   => array(0,0,-1,0, 0,0,0,0),
37
+				'This week'   => array(0,0,0,0,  0,0,0,1),
38
+				'Last week'   => array(0,0,0,-1, 0,0,0,0),
39
+				'This month'  => array(0,0,0,0,  0,1,0,0),
40
+				'Last month'  => array(0,-1,0,0, 0,0,0,0),
41
+				'Last 3 months' => array(0,-3,0,0, 0,0,0,0),
42
+				'This quarter'=> array(0,0,0,0,  0,0,0,0),      // Just a marker, needs special handling
43
+				'Last quarter'=> array(0,-4,0,0, 0,-4,0,0),     // Just a marker
44
+				'This year'   => array(0,0,0,0,  1,0,0,0),
45
+				'Last year'   => array(-1,0,0,0, 0,0,0,0),
46
+				'2 years ago' => array(-2,0,0,0, -1,0,0,0),
47
+				'3 years ago' => array(-3,0,0,0, -2,0,0,0),
48
+		);
49 49
 
50 50
 	/**
51
-	* Files known to cause problems, and will be skipped in a plugin scan
52
-	* If you put appname => true, the whole app will be skipped.
53
-	*/
51
+	 * Files known to cause problems, and will be skipped in a plugin scan
52
+	 * If you put appname => true, the whole app will be skipped.
53
+	 */
54 54
 	protected static $blacklist_files = array(
55 55
 		'api' => true,
56 56
 		'etemplate' => true,
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 	);
65 65
 
66 66
 	/**
67
-	* Class used to provide extra conversion functions
68
-	*
69
-	* Passed in as a param to conversion()
70
-	*/
67
+	 * Class used to provide extra conversion functions
68
+	 *
69
+	 * Passed in as a param to conversion()
70
+	 */
71 71
 	protected static $cclass = null;
72 72
 
73 73
 	/**
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		return $plugins;
446 446
 	}
447 447
 
448
-	public static function _get_plugins(Array $appnames, Array $types) {
448
+	public static function _get_plugins(array $appnames, array $types) {
449 449
 		$plugins = array();
450 450
 		foreach ($appnames as $appname) {
451 451
 			if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue;
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 	}
563 563
 
564 564
 	// Api\Cache needs this public
565
-	public static function _has_definitions(Array $appnames, Array $types) {
565
+	public static function _has_definitions(array $appnames, array $types) {
566 566
 		$def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types));
567 567
 		$list = array();
568 568
 		foreach((array)$def->get_definitions() as $id) {
Please login to merge, or discard this patch.
Spacing   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
 	 * Relative date ranges for filtering
33 33
 	 */
34 34
 	public static $relative_dates = array(      // Start: year,month,day,week, End: year,month,day,week
35
-                'Today'       => array(0,0,0,0,  0,0,1,0),
36
-                'Yesterday'   => array(0,0,-1,0, 0,0,0,0),
37
-                'This week'   => array(0,0,0,0,  0,0,0,1),
38
-                'Last week'   => array(0,0,0,-1, 0,0,0,0),
39
-                'This month'  => array(0,0,0,0,  0,1,0,0),
40
-                'Last month'  => array(0,-1,0,0, 0,0,0,0),
41
-                'Last 3 months' => array(0,-3,0,0, 0,0,0,0),
42
-                'This quarter'=> array(0,0,0,0,  0,0,0,0),      // Just a marker, needs special handling
43
-                'Last quarter'=> array(0,-4,0,0, 0,-4,0,0),     // Just a marker
44
-                'This year'   => array(0,0,0,0,  1,0,0,0),
45
-                'Last year'   => array(-1,0,0,0, 0,0,0,0),
46
-                '2 years ago' => array(-2,0,0,0, -1,0,0,0),
47
-                '3 years ago' => array(-3,0,0,0, -2,0,0,0),
35
+                'Today'       => array(0, 0, 0, 0, 0, 0, 1, 0),
36
+                'Yesterday'   => array(0, 0, -1, 0, 0, 0, 0, 0),
37
+                'This week'   => array(0, 0, 0, 0, 0, 0, 0, 1),
38
+                'Last week'   => array(0, 0, 0, -1, 0, 0, 0, 0),
39
+                'This month'  => array(0, 0, 0, 0, 0, 1, 0, 0),
40
+                'Last month'  => array(0, -1, 0, 0, 0, 0, 0, 0),
41
+                'Last 3 months' => array(0, -3, 0, 0, 0, 0, 0, 0),
42
+                'This quarter'=> array(0, 0, 0, 0, 0, 0, 0, 0), // Just a marker, needs special handling
43
+                'Last quarter'=> array(0, -4, 0, 0, 0, -4, 0, 0), // Just a marker
44
+                'This year'   => array(0, 0, 0, 0, 1, 0, 0, 0),
45
+                'Last year'   => array(-1, 0, 0, 0, 0, 0, 0, 0),
46
+                '2 years ago' => array(-2, 0, 0, 0, -1, 0, 0, 0),
47
+                '3 years ago' => array(-3, 0, 0, 0, -2, 0, 0, 0),
48 48
         );
49 49
 
50 50
 	/**
@@ -85,22 +85,22 @@  discard block
 block discarded – undo
85 85
 	 * @param string $_format format of time string e.g.: d.m.Y H:i
86 86
 	 * @param int $_is_dst is day light saving time? 0 = no, 1 = yes, -1 = system default
87 87
 	 */
88
-	public static function custom_strtotime( $_string, $_format='', $_is_dst = -1) {
89
-		if ( empty( $_format ) ) return strtotime( $_string );
90
-		$fparams = explode( ',', chunk_split( $_format, 1, ',' ) );
88
+	public static function custom_strtotime($_string, $_format = '', $_is_dst = -1) {
89
+		if (empty($_format)) return strtotime($_string);
90
+		$fparams = explode(',', chunk_split($_format, 1, ','));
91 91
 		$spos = 0;
92
-		foreach ( $fparams as $fparam ) {
93
-
94
-			switch ( $fparam ) {
95
-				case 'd': (int)$day = substr( $_string, $spos, 2 ); $spos += 2; break;
96
-				case 'm': (int)$mon = substr( $_string, $spos, 2 ); $spos += 2; break;
97
-				case 'y': (int)$year = substr( $_string, $spos, 2 ); $spos += 2; break;
98
-				case 'Y': (int)$year = substr( $_string, $spos, 4 ); $spos += 4; break;
99
-				case 'H': (int)$hour = substr( $_string, $spos, 2 ); $spos += 2; break;
100
-				case 'h': (int)$hour = substr( $_string, $spos, 2 ); $spos += 2; break;
101
-				case 'i': (int)$min =  substr( $_string, $spos, 2 ); $spos += 2; break;
102
-				case 's': (int)$sec =  substr( $_string, $spos, 2 ); $spos += 2; break;
103
-				case 'O': (int)$offset = $year = substr( $_string, $spos, 5 ); $spos += 5; break;
92
+		foreach ($fparams as $fparam) {
93
+
94
+			switch ($fparam) {
95
+				case 'd': (int)$day = substr($_string, $spos, 2); $spos += 2; break;
96
+				case 'm': (int)$mon = substr($_string, $spos, 2); $spos += 2; break;
97
+				case 'y': (int)$year = substr($_string, $spos, 2); $spos += 2; break;
98
+				case 'Y': (int)$year = substr($_string, $spos, 4); $spos += 4; break;
99
+				case 'H': (int)$hour = substr($_string, $spos, 2); $spos += 2; break;
100
+				case 'h': (int)$hour = substr($_string, $spos, 2); $spos += 2; break;
101
+				case 'i': (int)$min = substr($_string, $spos, 2); $spos += 2; break;
102
+				case 's': (int)$sec = substr($_string, $spos, 2); $spos += 2; break;
103
+				case 'O': (int)$offset = $year = substr($_string, $spos, 5); $spos += 5; break;
104 104
 				case 'a': (int)$hour = $fparam == 'am' ? $hour : $hour + 12; break;
105 105
 				case 'A': (int)$hour = $fparam == 'AM' ? $hour : $hour + 12; break;
106 106
 				default: $spos++; // seperator
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 		$timestamp = mktime($hour, $min, $sec, $mon, $day, $year, $_is_dst);
112 112
 
113 113
 		// offset given?
114
-		if ( isset( $offset ) && strlen( $offset == 5 ) ) {
114
+		if (isset($offset) && strlen($offset == 5)) {
115 115
 			$operator = $offset{0};
116
-			$ohour = 60 * 60 * (int)substr( $offset, 1, 2 );
117
-			$omin = 60 * (int)substr( $offset, 3, 2 );
118
-			if ( $operator == '+' ) $timestamp += $ohour + $omin;
116
+			$ohour = 60 * 60 * (int)substr($offset, 1, 2);
117
+			$omin = 60 * (int)substr($offset, 3, 2);
118
+			if ($operator == '+') $timestamp += $ohour + $omin;
119 119
 			else $timestamp -= $ohour + $omin;
120 120
 		}
121 121
 		return $timestamp;
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 	 * @param mixed $_account_lid comma seperated list or array with lids
127 127
 	 * @return mixed comma seperated list or array with ids
128 128
 	 */
129
-	public static function account_name2id( &$_account_lids ) {
130
-		$account_lids = is_array( $_account_lids ) ? $_account_lids : explode( ',', $_account_lids );
129
+	public static function account_name2id(&$_account_lids) {
130
+		$account_lids = is_array($_account_lids) ? $_account_lids : explode(',', $_account_lids);
131 131
 		$skip = false;
132
-		foreach ( $account_lids as $key => $account_lid ) {
133
-			if($skip) {
132
+		foreach ($account_lids as $key => $account_lid) {
133
+			if ($skip) {
134 134
 				unset($account_lids[$key]);
135 135
 				$skip = false;
136 136
 				continue;
@@ -138,15 +138,15 @@  discard block
 block discarded – undo
138 138
 			$account_lid = trim($account_lid);
139 139
 
140 140
 			// Handle any IDs that slip in
141
-			if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) {
141
+			if (is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) {
142 142
 				unset($account_lids[$key]);
143 143
 				$account_ids[] = (int)$account_lid;
144 144
 				continue;
145 145
 			}
146 146
 			// Check for [username]
147
-			if(strpos($account_lid,'[') !== false)
147
+			if (strpos($account_lid, '[') !== false)
148 148
 			{
149
-				if(preg_match('/\[(.+)\]/',$account_lid,$matches))
149
+				if (preg_match('/\[(.+)\]/', $account_lid, $matches))
150 150
 				{
151 151
 					$account_id = $GLOBALS['egw']->accounts->name2id($matches[1]);
152 152
 					unset($account_lids[$key]);
@@ -157,59 +157,59 @@  discard block
 block discarded – undo
157 157
 
158 158
 			// Handle users listed as Lastname, Firstname instead of login ID
159 159
 			// Do this first, in case their first name matches a username
160
-			if ( $account_lids[$key+1][0] == ' ')
160
+			if ($account_lids[$key + 1][0] == ' ')
161 161
 			{
162 162
 				$query = array('type' => 'accounts', 'query_type' => 'exact');
163
-				$given = $GLOBALS['egw']->accounts->search($query + array('query' => trim($account_lids[$key+1])));
163
+				$given = $GLOBALS['egw']->accounts->search($query + array('query' => trim($account_lids[$key + 1])));
164 164
 				$family = $GLOBALS['egw']->accounts->search($query + array('query' => trim($account_lid)));
165 165
 				$ids = array_intersect_key($family, $given);
166
-				if($ids)
166
+				if ($ids)
167 167
 				{
168 168
 					$account_ids[] = key($ids);
169 169
 					unset($account_lids[$key]);
170 170
 					$skip = true; // Skip the next one, it's the first name
171
-					continue ;
171
+					continue;
172 172
 				}
173 173
 			}
174 174
 
175 175
 			// Deal with groups listed as <name> Group, remove the Group
176
-			if(substr(trim($account_lid),-strlen(lang('Group'))) == lang('Group'))
176
+			if (substr(trim($account_lid), -strlen(lang('Group'))) == lang('Group'))
177 177
 			{
178 178
 				$account_lid = trim(substr(trim($account_lid), 0, -strlen(lang('Group'))));
179 179
 			}
180 180
 			// Group <name> (no comma)
181
-			else if(strpos($account_lid, lang('Group')) === 0)
181
+			else if (strpos($account_lid, lang('Group')) === 0)
182 182
 			{
183 183
 				$account_lid = trim(substr(trim($account_lid), strlen(lang('Group'))));
184 184
 			}
185 185
 
186
-			if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) {
186
+			if ($account_id = $GLOBALS['egw']->accounts->name2id($account_lid)) {
187 187
 				$account_ids[] = $account_id;
188 188
 				unset($account_lids[$key]);
189 189
 				continue;
190 190
 			}
191
-			if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) {
191
+			if ($account_id = $GLOBALS['egw']->accounts->name2id(trim($account_lid), 'account_fullname')) {
192 192
 				$account_ids[] = $account_id;
193 193
 				unset($account_lids[$key]);
194 194
 				continue;
195 195
 			}
196 196
 
197 197
 			// Handle groups listed as Group, <name>
198
-			if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) {
198
+			if ($account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id($account_lid)) {
199 199
 				$account_ids[] = $account_id;
200
-				unset($account_lids[$key-1]);
200
+				unset($account_lids[$key - 1]);
201 201
 				unset($account_lids[$key]);
202 202
 				continue;
203 203
 			}
204 204
 			// Group, <name> - remove the Group part
205
-			if($account_lid == lang('Group'))
205
+			if ($account_lid == lang('Group'))
206 206
 			{
207 207
 				unset($account_lids[$key]);
208 208
 				continue;
209 209
 			}
210 210
 		}
211
-		$_account_lids = (is_array($_account_lids) ? $account_lids : implode(',',array_unique($account_lids)));
212
-		return is_array( $_account_lids ) ? array_unique($account_ids) : implode( ',', array_unique((array)$account_ids ));
211
+		$_account_lids = (is_array($_account_lids) ? $account_lids : implode(',', array_unique($account_lids)));
212
+		return is_array($_account_lids) ? array_unique($account_ids) : implode(',', array_unique((array)$account_ids));
213 213
 
214 214
 	} // end of member function account_lid2id
215 215
 
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
 	 * @param mixed $_account_ids comma seperated list or array with ids
220 220
 	 * @return mixed comma seperated list or array with lids
221 221
 	 */
222
-	public static function account_id2name( $_account_id ) {
223
-		$account_ids = is_array( $_account_id ) ? $_account_id : explode( ',', $_account_id );
224
-		foreach ( $account_ids as $account_id ) {
225
-			if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) {
222
+	public static function account_id2name($_account_id) {
223
+		$account_ids = is_array($_account_id) ? $_account_id : explode(',', $_account_id);
224
+		foreach ($account_ids as $account_id) {
225
+			if ($account_lid = $GLOBALS['egw']->accounts->id2name($account_id)) {
226 226
 				$account_lids[] = $account_lid;
227 227
 			}
228 228
 		}
229
-		return is_array( $_account_id ) ? $account_lids : implode( ',', (array)$account_lids );
229
+		return is_array($_account_id) ? $account_lids : implode(',', (array)$account_lids);
230 230
 	} // end of member function account_id2lid
231 231
 
232 232
 	/**
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
 	 * @param mixed _cat_ids comma seperated list or array
236 236
 	 * @return mixed comma seperated list or array with cat_names
237 237
 	 */
238
-	public static function cat_id2name( $_cat_ids ) {
239
-		$cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids );
240
-		foreach ( $cat_ids as $cat_id ) {
241
-			$cat_names[] = Api\Categories::id2name( (int)$cat_id );
238
+	public static function cat_id2name($_cat_ids) {
239
+		$cat_ids = is_array($_cat_ids) ? $_cat_ids : explode(',', $_cat_ids);
240
+		foreach ($cat_ids as $cat_id) {
241
+			$cat_names[] = Api\Categories::id2name((int)$cat_id);
242 242
 		}
243
-		return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names);
243
+		return is_array($_cat_ids) ? $cat_names : implode(',', (array)$cat_names);
244 244
 	} // end of member function category_id2name
245 245
 
246 246
 	/**
@@ -251,24 +251,24 @@  discard block
 block discarded – undo
251 251
 	 * @param int $parent Optional parent ID to use for new categories
252 252
 	 * @return mixed comma seperated list or array with cat_ids
253 253
 	 */
254
-	public static function cat_name2id( $_cat_names, $parent = 0 ) {
255
-		$cats = new Api\Categories();	// uses current user and app (egw_info[flags][currentapp])
254
+	public static function cat_name2id($_cat_names, $parent = 0) {
255
+		$cats = new Api\Categories(); // uses current user and app (egw_info[flags][currentapp])
256 256
 
257
-		$cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names );
258
-		foreach ( $cat_names as $cat_name ) {
257
+		$cat_names = is_array($_cat_names) ? $_cat_names : explode(',', $_cat_names);
258
+		foreach ($cat_names as $cat_name) {
259 259
 			$cat_name = trim($cat_name);
260
-			if ( $cat_name == '' ) continue;
261
-			if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) {
262
-				$cat_id = $cats->add( array(
260
+			if ($cat_name == '') continue;
261
+			if (($cat_id = $cats->name2id($cat_name)) == 0 && !self::$dry_run) {
262
+				$cat_id = $cats->add(array(
263 263
 					'name' => $cat_name,
264 264
 					'parent' => $parent,
265 265
 					'access' => 'public',
266
-					'descr' => $cat_name. ' ('. lang('Automatically created by importexport'). ')'
266
+					'descr' => $cat_name.' ('.lang('Automatically created by importexport').')'
267 267
 				));
268 268
 			}
269 269
 			$cat_ids[] = $cat_id;
270 270
 		}
271
-		return is_array( $_cat_names ) ? $cat_ids : implode( ',', (array)$cat_ids );
271
+		return is_array($_cat_names) ? $cat_ids : implode(',', (array)$cat_ids);
272 272
 
273 273
 	} // end of member function category_name2id
274 274
 
@@ -307,76 +307,76 @@  discard block
 block discarded – undo
307 307
 	 * @param object &$cclass calling class to process the '@ evals'
308 308
 	 * @return bool
309 309
 	 */
310
-	public static function conversion( &$_record,  $_conversion, &$_cclass = null ) {
311
-		if (empty( $_conversion ) ) return $_record;
310
+	public static function conversion(&$_record, $_conversion, &$_cclass = null) {
311
+		if (empty($_conversion)) return $_record;
312 312
 
313
-		self::$cclass =& $_cclass;
313
+		self::$cclass = & $_cclass;
314 314
 
315 315
 		$PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in conversion
316 316
 		$ASep = '|>'; // Assignment-Separator, separats pattern and replacesment
317
-		$CPre = '|['; $CPos = ']';  // |[_record-idx] is expanded to the corespondig value
317
+		$CPre = '|['; $CPos = ']'; // |[_record-idx] is expanded to the corespondig value
318 318
 		$TPre = '|T{'; $TPos = '}'; // |{_record-idx} is trimmed
319
-		$CntlPre = '|TC{';		    // Filter all cntl-chars \x01-\x1f and trim
320
-		$CntlnCLPre  = '|TCnCL{';   // Like |C{ but allowes CR and LF
321
-		$INE = '|INE{';             // Only insert if stuff in ^^ is not empty
319
+		$CntlPre = '|TC{'; // Filter all cntl-chars \x01-\x1f and trim
320
+		$CntlnCLPre = '|TCnCL{'; // Like |C{ but allowes CR and LF
321
+		$INE = '|INE{'; // Only insert if stuff in ^^ is not empty
322 322
 
323
-		foreach ( $_conversion as $idx => $conversion_string ) {
324
-			if ( empty( $conversion_string ) ) continue;
323
+		foreach ($_conversion as $idx => $conversion_string) {
324
+			if (empty($conversion_string)) continue;
325 325
 
326 326
 			// fetch patterns ($rvalues)
327 327
 			$rvalues = array();
328
-			$pat_reps = explode( $PSep, stripslashes( $conversion_string ) );
329
-			foreach( $pat_reps as $k => $pat_rep ) {
330
-				list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 );
331
-				if( $replace == '' ) {
328
+			$pat_reps = explode($PSep, stripslashes($conversion_string));
329
+			foreach ($pat_reps as $k => $pat_rep) {
330
+				list($pattern, $replace) = explode($ASep, $pat_rep, 2);
331
+				if ($replace == '') {
332 332
 					$replace = $pattern; $pattern = '^.*$';
333 333
 				}
334
-				$rvalues[$pattern] = $replace;	// replace two with only one, added by the form
334
+				$rvalues[$pattern] = $replace; // replace two with only one, added by the form
335 335
 			}
336 336
 
337 337
 			// conversion list may be longer than $_record aka (no_csv)
338
-			$val = array_key_exists( $idx, $_record ) ? $_record[$idx] : '';
338
+			$val = array_key_exists($idx, $_record) ? $_record[$idx] : '';
339 339
 
340 340
 			$c_functions = array('cat', 'account', 'strtotime', 'list');
341
-			if($_cclass) {
341
+			if ($_cclass) {
342 342
 				// Add in additional methods
343 343
 				$reflection = new ReflectionClass(get_class($_cclass));
344 344
 				$methods = $reflection->getMethods(ReflectionMethod::IS_STATIC);
345
-				foreach($methods as $method) {
345
+				foreach ($methods as $method) {
346 346
 					$c_functions[] = $method->name;
347 347
 				}
348 348
 			}
349 349
 			$c_functions = implode('|', $c_functions);
350
-			foreach ( $rvalues as $pattern => $replace ) {
350
+			foreach ($rvalues as $pattern => $replace) {
351 351
 				// Allow to include record indexes in pattern
352 352
 				$reg = '/\|\[([0-9]+)\]/';
353
-				while( preg_match( $reg, $pattern, $vars ) ) {
353
+				while (preg_match($reg, $pattern, $vars)) {
354 354
 					// expand all _record fields
355 355
 					$pattern = str_replace(
356
-						$CPre . $vars[1] . $CPos,
356
+						$CPre.$vars[1].$CPos,
357 357
 						$_record[array_search($vars[1], array_keys($_record))],
358 358
 						$pattern
359 359
 					);
360 360
 				}
361
-				if( preg_match('/'. (string)$pattern.'/', $val) ) {
361
+				if (preg_match('/'.(string)$pattern.'/', $val)) {
362 362
 
363
-					$val = preg_replace( '/'.(string)$pattern.'/', $replace, (string)$val );
363
+					$val = preg_replace('/'.(string)$pattern.'/', $replace, (string)$val);
364 364
 
365 365
 					$reg = '/\|\[([a-zA-Z_0-9]+)\]/';
366
-					while( preg_match( $reg, $val, $vars ) ) {
366
+					while (preg_match($reg, $val, $vars)) {
367 367
 						// expand all _record fields
368 368
 						$val = str_replace(
369
-							$CPre . $vars[1] . $CPos,
369
+							$CPre.$vars[1].$CPos,
370 370
 							$_record[array_search($vars[1], array_keys($_record))],
371 371
 							$val
372 372
 						);
373 373
 					}
374
-					$val = preg_replace_callback( "/($c_functions)\(([^)]*)\)/i", array( self, 'c2_dispatcher') , $val );
374
+					$val = preg_replace_callback("/($c_functions)\(([^)]*)\)/i", array(self, 'c2_dispatcher'), $val);
375 375
 					break;
376 376
 				}
377 377
 			}
378 378
 			// clean each field
379
-			$val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{|\|INE\{)(.*)\}/", array( self, 'strclean'), $val );
379
+			$val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{|\|INE\{)(.*)\}/", array(self, 'strclean'), $val);
380 380
 
381 381
 			$_record[$idx] = $val;
382 382
 		}
@@ -390,42 +390,42 @@  discard block
 block discarded – undo
390 390
 	 *
391 391
 	 * @param array $_matches
392 392
 	 */
393
-	private static function c2_dispatcher( $_matches ) {
393
+	private static function c2_dispatcher($_matches) {
394 394
 		$action = &$_matches[1]; // cat or account ...
395
-		$data = &$_matches[2];   // datas for action
395
+		$data = &$_matches[2]; // datas for action
396 396
 
397
-		switch ( $action ) {
397
+		switch ($action) {
398 398
 			case 'strtotime' :
399
-				list( $string, $format ) = explode( ',', $data );
400
-				return self::custom_strtotime( trim( $string ), trim( $format ) );
399
+				list($string, $format) = explode(',', $data);
400
+				return self::custom_strtotime(trim($string), trim($format));
401 401
 			case 'list':
402
-				list( $split, $data, $index) = explode(',',$data);
402
+				list($split, $data, $index) = explode(',', $data);
403 403
 				$exploded = explode($split, $data);
404 404
 				// 1 based indexing for user ease
405 405
 				return $exploded[$index - 1];
406 406
 			default :
407
-				if(self::$cclass && method_exists(self::$cclass, $action)) {
407
+				if (self::$cclass && method_exists(self::$cclass, $action)) {
408 408
 					$class = get_class(self::$cclass);
409 409
 					return call_user_func("$class::$action", $data);
410 410
 				}
411
-				$method = (string)$action. ( is_int( $data ) ? '_id2name' : '_name2id' );
412
-				if(self::$cclass && method_exists(self::$cclass, $method)) {
411
+				$method = (string)$action.(is_int($data) ? '_id2name' : '_name2id');
412
+				if (self::$cclass && method_exists(self::$cclass, $method)) {
413 413
 					$class = get_class(self::$cclass);
414 414
 					return call_user_func("$class::$action", $data);
415 415
 				} else {
416
-					return self::$method( $data );
416
+					return self::$method($data);
417 417
 				}
418 418
 		}
419 419
 	}
420 420
 
421
-	private static function strclean( $_matches ) {
422
-		switch( $_matches[1] ) {
423
-			case '|T{' : return trim( $_matches[2] );
424
-			case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_matches[2] ) );
425
-			case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) );
426
-			case '|INE{' : return preg_match( '/\^.+\^/', $_matches[2] ) ? $_matches[2] : '';
421
+	private static function strclean($_matches) {
422
+		switch ($_matches[1]) {
423
+			case '|T{' : return trim($_matches[2]);
424
+			case '|TC{' : return trim(preg_replace('/[\x01-\x1F]+/', '', $_matches[2]));
425
+			case '|TCnCL{' : return trim(preg_replace('/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2]));
426
+			case '|INE{' : return preg_match('/\^.+\^/', $_matches[2]) ? $_matches[2] : '';
427 427
 			default:
428
-				throw new Exception('Error in conversion string! "'. substr( $_matches[1], 0, -1 ). '" is not valid!');
428
+				throw new Exception('Error in conversion string! "'.substr($_matches[1], 0, -1).'" is not valid!');
429 429
 		}
430 430
 	}
431 431
 
@@ -436,23 +436,23 @@  discard block
 block discarded – undo
436 436
 	 * @param string $_appname {<appname> | all}
437 437
 	 * @return array(<appname> => array( <type> => array(<plugin> => <title>)))
438 438
 	 */
439
-	public static function get_plugins( $_appname = 'all', $_type = 'all' ) {
439
+	public static function get_plugins($_appname = 'all', $_type = 'all') {
440 440
 		$plugins = Api\Cache::getTree(
441 441
 			__CLASS__,
442 442
 			'plugins',
443
-			array('importexport_helper_functions','_get_plugins'),
443
+			array('importexport_helper_functions', '_get_plugins'),
444 444
 			array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')),
445 445
 			self::CACHE_EXPIRATION
446 446
 		);
447 447
 		$appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname;
448
-		$types = $_type == 'all' ? array('import','export') : (array)$_type;
448
+		$types = $_type == 'all' ? array('import', 'export') : (array)$_type;
449 449
 
450 450
 		// Testing: comment out Api\Cache call, use this
451 451
 		//$plugins = self::_get_plugins($appnames, $types);
452
-		foreach($plugins as $appname => $_types) {
453
-			if(!in_array($appname, $appnames)) unset($plugins[$appname]);
452
+		foreach ($plugins as $appname => $_types) {
453
+			if (!in_array($appname, $appnames)) unset($plugins[$appname]);
454 454
 		}
455
-		foreach($plugins as $appname => $types) {
455
+		foreach ($plugins as $appname => $types) {
456 456
 			$plugins[$appname] = array_intersect_key($plugins[$appname], $types);
457 457
 		}
458 458
 		return $plugins;
@@ -461,25 +461,25 @@  discard block
 block discarded – undo
461 461
 	public static function _get_plugins(Array $appnames, Array $types) {
462 462
 		$plugins = array();
463 463
 		foreach ($appnames as $appname) {
464
-			if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue;
464
+			if (array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue;
465 465
 
466
-			$appdir = EGW_INCLUDE_ROOT. "/$appname/inc";
467
-			if(!is_dir($appdir)) continue;
466
+			$appdir = EGW_INCLUDE_ROOT."/$appname/inc";
467
+			if (!is_dir($appdir)) continue;
468 468
 			$d = dir($appdir);
469 469
 
470 470
 			// step through each file in appdir
471 471
 			while (false !== ($entry = $d->read())) {
472 472
 				// Blacklisted?
473
-				if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname]))  continue;
473
+				if (is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname]))  continue;
474 474
 				if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) continue;
475 475
 				$classname = $matches[1];
476
-				$file = $appdir. '/'. $entry;
476
+				$file = $appdir.'/'.$entry;
477 477
 
478 478
 				foreach ($types as $type) {
479
-					if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) continue;
479
+					if (!is_file($file) || strpos($entry, $type) === false || strpos($entry, 'wizard') !== false) continue;
480 480
 					require_once($file);
481 481
 					$reflectionClass = new ReflectionClass($classname);
482
-					if($reflectionClass->IsInstantiable() &&
482
+					if ($reflectionClass->IsInstantiable() &&
483 483
 							$reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) {
484 484
 						try {
485 485
 							$plugin_object = new $classname;
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 			$d->close();
496 496
 
497 497
 			$config = Api\Config::read('importexport');
498
-			if($config['update'] == 'auto') {
498
+			if ($config['update'] == 'auto') {
499 499
 				self::load_defaults($appname);
500 500
 			}
501 501
 		}
@@ -510,37 +510,37 @@  discard block
 block discarded – undo
510 510
 	 * @return array $num => $appname
511 511
 	 */
512 512
 	public static function get_apps($_type, $ignore_acl = false) {
513
-		$apps = array_keys(self::get_plugins('all',$_type));
514
-		if($ignore_acl) return $apps;
513
+		$apps = array_keys(self::get_plugins('all', $_type));
514
+		if ($ignore_acl) return $apps;
515 515
 
516
-		foreach($apps as $key => $app) {
517
-			if(!self::has_definitions($app, $_type)) unset($apps[$key]);
516
+		foreach ($apps as $key => $app) {
517
+			if (!self::has_definitions($app, $_type)) unset($apps[$key]);
518 518
 		}
519 519
 		return $apps;
520 520
 	}
521 521
 
522 522
 	public static function load_defaults($appname) {
523 523
 		// Check for new definitions to import from $appname/setup/*.xml
524
-		$appdir = EGW_INCLUDE_ROOT. "/$appname/setup";
525
-		if(!is_dir($appdir)) return;
524
+		$appdir = EGW_INCLUDE_ROOT."/$appname/setup";
525
+		if (!is_dir($appdir)) return;
526 526
 		$d = dir($appdir);
527 527
 
528 528
 		// step through each file in app's setup
529 529
 		while (false !== ($entry = $d->read())) {
530
-			$file = $appdir. '/'. $entry;
531
-			list( $filename, $extension) = explode('.',$entry);
532
-			if ( $extension != 'xml' ) continue;
530
+			$file = $appdir.'/'.$entry;
531
+			list($filename, $extension) = explode('.', $entry);
532
+			if ($extension != 'xml') continue;
533 533
 			try {
534 534
 				// import will skip invalid files
535
-				importexport_definitions_bo::import( $file );
535
+				importexport_definitions_bo::import($file);
536 536
 			} catch (Exception $e) {
537
-				error_log(__CLASS__.__FUNCTION__. " import $appname definitions: " . $e->getMessage());
537
+				error_log(__CLASS__.__FUNCTION__." import $appname definitions: ".$e->getMessage());
538 538
 			}
539 539
 		}
540 540
 		$d->close();
541 541
 	}
542 542
 
543
-	public static function guess_filetype( $_file ) {
543
+	public static function guess_filetype($_file) {
544 544
 
545 545
 	}
546 546
 
@@ -551,24 +551,24 @@  discard block
 block discarded – undo
551 551
 	 * @param string $_type {import | export | all}
552 552
 	 * @return boolean
553 553
 	 */
554
-	public static function has_definitions( $_appname = 'all', $_type = 'all' ) {
554
+	public static function has_definitions($_appname = 'all', $_type = 'all') {
555 555
 		$definitions = Api\Cache::getSession(
556 556
 			__CLASS__,
557 557
 			'has_definitions',
558
-			array('importexport_helper_functions','_has_definitions'),
558
+			array('importexport_helper_functions', '_has_definitions'),
559 559
 			array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')),
560 560
 			self::CACHE_EXPIRATION
561 561
 		);
562 562
 		$appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname;
563
-		$types = $_type == 'all' ? array('import','export') : (array)$_type;
563
+		$types = $_type == 'all' ? array('import', 'export') : (array)$_type;
564 564
 
565 565
 		// Testing: Comment out cache call above, use this
566 566
 		//$definitions = self::_has_definitions($appnames, $types);
567 567
 
568
-		foreach($definitions as $appname => $_types) {
569
-			if(!in_array($appname, $appnames)) unset($definitions[$appname]);
568
+		foreach ($definitions as $appname => $_types) {
569
+			if (!in_array($appname, $appnames)) unset($definitions[$appname]);
570 570
 		}
571
-		foreach($definitions as $appname => $_types) {
571
+		foreach ($definitions as $appname => $_types) {
572 572
 			$definitions[$appname] = array_intersect_key($definitions[$appname], array_flip($types));
573 573
 		}
574 574
 		return !empty($definitions[$appname]);
@@ -578,11 +578,11 @@  discard block
 block discarded – undo
578 578
 	public static function _has_definitions(Array $appnames, Array $types) {
579 579
 		$def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types));
580 580
 		$list = array();
581
-		foreach((array)$def->get_definitions() as $id) {
581
+		foreach ((array)$def->get_definitions() as $id) {
582 582
 			// Need to instanciate it to check, but if the user doesn't have permission, it throws an exception
583 583
 			try {
584 584
 				$definition = new importexport_definition($id);
585
-				if($def->is_permitted($definition->get_record_array())) {
585
+				if ($def->is_permitted($definition->get_record_array())) {
586 586
 					$list[$definition->application][$definition->type][] = $id;
587 587
 				}
588 588
 			} catch (Exception $e) {
@@ -614,13 +614,13 @@  discard block
 block discarded – undo
614 614
 			$plugin = is_object($plugin_name) ? $plugin_name : new $plugin_name();
615 615
 			$plugin_name = get_class($plugin);
616 616
 
617
-			if($record_classname == null) $record_classname = $plugin::get_egw_record_class();
618
-			if(!class_exists($record_classname)) throw new Exception('Bad class name ' . $record_classname);
617
+			if ($record_classname == null) $record_classname = $plugin::get_egw_record_class();
618
+			if (!class_exists($record_classname)) throw new Exception('Bad class name '.$record_classname);
619 619
 
620
-			if(!$wizard_plugin)
620
+			if (!$wizard_plugin)
621 621
 			{
622
-				$wizard_name = $app_name . '_wizard_' . str_replace($app_name . '_', '', $plugin_name);
623
-				if(!class_exists($wizard_name)) throw new Exception('Bad wizard name ' . $wizard_name);
622
+				$wizard_name = $app_name.'_wizard_'.str_replace($app_name.'_', '', $plugin_name);
623
+				if (!class_exists($wizard_name)) throw new Exception('Bad wizard name '.$wizard_name);
624 624
 				$wizard_plugin = new $wizard_name;
625 625
 			}
626 626
 		}
@@ -632,16 +632,16 @@  discard block
 block discarded – undo
632 632
 
633 633
 		// Get field -> label map and initialize fields using wizard field order
634 634
 		$fields = $export_fields = array();
635
-		if(method_exists($wizard_plugin, 'get_export_fields'))
635
+		if (method_exists($wizard_plugin, 'get_export_fields'))
636 636
 		{
637 637
 			$fields = $export_fields = $wizard_plugin->get_export_fields();
638 638
 		}
639 639
 
640
-		foreach($record_classname::$types as $type => $type_fields)
640
+		foreach ($record_classname::$types as $type => $type_fields)
641 641
 		{
642 642
 			// Only these for now, until filter methods for others are figured out
643
-			if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) continue;
644
-			foreach($type_fields as $field_name)
643
+			if (!in_array($type, array('select', 'select-cat', 'select-account', 'date', 'date-time'))) continue;
644
+			foreach ($type_fields as $field_name)
645 645
 			{
646 646
 				$fields[$field_name] = array(
647 647
 					'name' => $field_name,
@@ -652,21 +652,21 @@  discard block
 block discarded – undo
652 652
 		}
653 653
 		// Add custom fields
654 654
 		$custom = Api\Storage\Customfields::get($app_name);
655
-		foreach($custom as $field_name => $settings)
655
+		foreach ($custom as $field_name => $settings)
656 656
 		{
657 657
 			$settings['name'] = '#'.$field_name;
658 658
 			$fields['#'.$field_name] = $settings;
659 659
 		}
660 660
 
661
-		foreach($fields as $field_name => &$settings) {
661
+		foreach ($fields as $field_name => &$settings) {
662 662
 			// Can't really filter on these (or at least no generic, sane way figured out yet)
663
-			if(!is_array($settings) || in_array($settings['type'], array('text','button', 'label','url','url-email','url-phone','htmlarea')))
663
+			if (!is_array($settings) || in_array($settings['type'], array('text', 'button', 'label', 'url', 'url-email', 'url-phone', 'htmlarea')))
664 664
 			{
665 665
 				unset($fields[$field_name]);
666 666
 				continue;
667 667
 			}
668
-			if($settings['type'] == 'radio') $settings['type'] = 'select';
669
-			switch($settings['type'])
668
+			if ($settings['type'] == 'radio') $settings['type'] = 'select';
669
+			switch ($settings['type'])
670 670
 			{
671 671
 				case 'checkbox':
672 672
 					// This isn't quite right - there's only 2 options and you can select both
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 			}
690 690
 		}
691 691
 
692
-		if(method_exists($plugin, 'get_filter_fields'))
692
+		if (method_exists($plugin, 'get_filter_fields'))
693 693
 		{
694 694
 			$plugin->get_filter_fields($fields);
695 695
 		}
@@ -705,65 +705,65 @@  discard block
 block discarded – undo
705 705
 	 */
706 706
 	public static function date_rel2abs($value)
707 707
 	{
708
-		if(is_array($value))
708
+		if (is_array($value))
709 709
 		{
710 710
 			$abs = array();
711
-			foreach($value as $key => $val)
711
+			foreach ($value as $key => $val)
712 712
 			{
713 713
 				$abs[$key] = self::date_rel2abs($val);
714 714
 			}
715 715
 			return $abs;
716 716
 		}
717
-		if($date = self::$relative_dates[$value])
717
+		if ($date = self::$relative_dates[$value])
718 718
 		{
719
-			$year  = (int) date('Y');
720
-			$month = (int) date('m');
721
-			$day   = (int) date('d');
722
-			$today = mktime(0,0,0,date('m'),date('d'),date('Y'));
719
+			$year  = (int)date('Y');
720
+			$month = (int)date('m');
721
+			$day   = (int)date('d');
722
+			$today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
723 723
 
724
-			list($syear,$smonth,$sday,$sweek,$eyear,$emonth,$eday,$eweek) = $date;
724
+			list($syear, $smonth, $sday, $sweek, $eyear, $emonth, $eday, $eweek) = $date;
725 725
 
726
-			if(stripos($value, 'quarter') !== false)
726
+			if (stripos($value, 'quarter') !== false)
727 727
 			{
728 728
 				// Handle quarters
729
-				$start = mktime(0,0,0,((int)floor(($smonth+$month) / 3.1)) * 3 + 1, 1, $year);
730
-				$end = mktime(0,0,0,((int)floor(($emonth+$month) / 3.1)+1) * 3 + 1, 1, $year);
729
+				$start = mktime(0, 0, 0, ((int)floor(($smonth + $month) / 3.1)) * 3 + 1, 1, $year);
730
+				$end = mktime(0, 0, 0, ((int)floor(($emonth + $month) / 3.1) + 1) * 3 + 1, 1, $year);
731 731
 			}
732 732
 			elseif ($syear || $eyear)
733 733
 			{
734
-				$start = mktime(0,0,0,1,1,$syear+$year);
735
-				$end   = mktime(0,0,0,1,1,$eyear+$year);
734
+				$start = mktime(0, 0, 0, 1, 1, $syear + $year);
735
+				$end   = mktime(0, 0, 0, 1, 1, $eyear + $year);
736 736
 			}
737 737
 			elseif ($smonth || $emonth)
738 738
 			{
739
-				$start = mktime(0,0,0,$smonth+$month,1,$year);
740
-				$end   = mktime(0,0,0,$emonth+$month,1,$year);
739
+				$start = mktime(0, 0, 0, $smonth + $month, 1, $year);
740
+				$end   = mktime(0, 0, 0, $emonth + $month, 1, $year);
741 741
 			}
742 742
 			elseif ($sday || $eday)
743 743
 			{
744
-				$start = mktime(0,0,0,$month,$sday+$day,$year);
745
-				$end   = mktime(0,0,0,$month,$eday+$day,$year);
744
+				$start = mktime(0, 0, 0, $month, $sday + $day, $year);
745
+				$end   = mktime(0, 0, 0, $month, $eday + $day, $year);
746 746
 			}
747 747
 			elseif ($sweek || $eweek)
748 748
 			{
749
-				$wday = (int) date('w'); // 0=sun, ..., 6=sat
750
-				switch($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'])
749
+				$wday = (int)date('w'); // 0=sun, ..., 6=sat
750
+				switch ($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'])
751 751
 				{
752 752
 					case 'Sunday':
753
-						$weekstart = $today - $wday * 24*60*60;
753
+						$weekstart = $today - $wday * 24 * 60 * 60;
754 754
 						break;
755 755
 					case 'Saturday':
756
-						$weekstart = $today - (6-$wday) * 24*60*60;
756
+						$weekstart = $today - (6 - $wday) * 24 * 60 * 60;
757 757
 						break;
758 758
 					case 'Moday':
759 759
 					default:
760
-						$weekstart = $today - ($wday ? $wday-1 : 6) * 24*60*60;
760
+						$weekstart = $today - ($wday ? $wday - 1 : 6) * 24 * 60 * 60;
761 761
 						break;
762 762
 				}
763
-				$start = $weekstart + $sweek*7*24*60*60;
764
-				$end   = $weekstart + $eweek*7*24*60*60;
763
+				$start = $weekstart + $sweek * 7 * 24 * 60 * 60;
764
+				$end   = $weekstart + $eweek * 7 * 24 * 60 * 60;
765 765
 			}
766
-			$end_param = $end - 24*60*60;
766
+			$end_param = $end - 24 * 60 * 60;
767 767
 
768 768
 			// Take 1 second off end to provide an inclusive range.for filtering
769 769
 			$end -= 1;
Please login to merge, or discard this patch.
Braces   +208 added lines, -82 removed lines patch added patch discarded remove patch
@@ -16,7 +16,8 @@  discard block
 block discarded – undo
16 16
  * class importexport_helper_functions (only static methods)
17 17
  * use importexport_helper_functions::method
18 18
  */
19
-class importexport_helper_functions {
19
+class importexport_helper_functions
20
+{
20 21
 
21 22
 	/**
22 23
 	 * Plugins are scanned and cached for all instances using this source path for given time (in seconds)
@@ -85,13 +86,19 @@  discard block
 block discarded – undo
85 86
 	 * @param string $_format format of time string e.g.: d.m.Y H:i
86 87
 	 * @param int $_is_dst is day light saving time? 0 = no, 1 = yes, -1 = system default
87 88
 	 */
88
-	public static function custom_strtotime( $_string, $_format='', $_is_dst = -1) {
89
-		if ( empty( $_format ) ) return strtotime( $_string );
89
+	public static function custom_strtotime( $_string, $_format='', $_is_dst = -1)
90
+	{
91
+		if ( empty( $_format ) )
92
+		{
93
+			return strtotime( $_string );
94
+		}
90 95
 		$fparams = explode( ',', chunk_split( $_format, 1, ',' ) );
91 96
 		$spos = 0;
92
-		foreach ( $fparams as $fparam ) {
97
+		foreach ( $fparams as $fparam )
98
+		{
93 99
 
94
-			switch ( $fparam ) {
100
+			switch ( $fparam )
101
+			{
95 102
 				case 'd': (int)$day = substr( $_string, $spos, 2 ); $spos += 2; break;
96 103
 				case 'm': (int)$mon = substr( $_string, $spos, 2 ); $spos += 2; break;
97 104
 				case 'y': (int)$year = substr( $_string, $spos, 2 ); $spos += 2; break;
@@ -111,12 +118,18 @@  discard block
 block discarded – undo
111 118
 		$timestamp = mktime($hour, $min, $sec, $mon, $day, $year, $_is_dst);
112 119
 
113 120
 		// offset given?
114
-		if ( isset( $offset ) && strlen( $offset == 5 ) ) {
121
+		if ( isset( $offset ) && strlen( $offset == 5 ) )
122
+		{
115 123
 			$operator = $offset{0};
116 124
 			$ohour = 60 * 60 * (int)substr( $offset, 1, 2 );
117 125
 			$omin = 60 * (int)substr( $offset, 3, 2 );
118
-			if ( $operator == '+' ) $timestamp += $ohour + $omin;
119
-			else $timestamp -= $ohour + $omin;
126
+			if ( $operator == '+' )
127
+			{
128
+				$timestamp += $ohour + $omin;
129
+			}
130
+			else {
131
+				$timestamp -= $ohour + $omin;
132
+			}
120 133
 		}
121 134
 		return $timestamp;
122 135
 	}
@@ -126,11 +139,14 @@  discard block
 block discarded – undo
126 139
 	 * @param mixed $_account_lid comma seperated list or array with lids
127 140
 	 * @return mixed comma seperated list or array with ids
128 141
 	 */
129
-	public static function account_name2id( &$_account_lids ) {
142
+	public static function account_name2id( &$_account_lids )
143
+	{
130 144
 		$account_lids = is_array( $_account_lids ) ? $_account_lids : explode( ',', $_account_lids );
131 145
 		$skip = false;
132
-		foreach ( $account_lids as $key => $account_lid ) {
133
-			if($skip) {
146
+		foreach ( $account_lids as $key => $account_lid )
147
+		{
148
+			if($skip)
149
+			{
134 150
 				unset($account_lids[$key]);
135 151
 				$skip = false;
136 152
 				continue;
@@ -138,7 +154,8 @@  discard block
 block discarded – undo
138 154
 			$account_lid = trim($account_lid);
139 155
 
140 156
 			// Handle any IDs that slip in
141
-			if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) {
157
+			if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid))
158
+			{
142 159
 				unset($account_lids[$key]);
143 160
 				$account_ids[] = (int)$account_lid;
144 161
 				continue;
@@ -183,19 +200,22 @@  discard block
 block discarded – undo
183 200
 				$account_lid = trim(substr(trim($account_lid), strlen(lang('Group'))));
184 201
 			}
185 202
 
186
-			if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) {
203
+			if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid ))
204
+			{
187 205
 				$account_ids[] = $account_id;
188 206
 				unset($account_lids[$key]);
189 207
 				continue;
190 208
 			}
191
-			if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) {
209
+			if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' ))
210
+			{
192 211
 				$account_ids[] = $account_id;
193 212
 				unset($account_lids[$key]);
194 213
 				continue;
195 214
 			}
196 215
 
197 216
 			// Handle groups listed as Group, <name>
198
-			if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) {
217
+			if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid))
218
+			{
199 219
 				$account_ids[] = $account_id;
200 220
 				unset($account_lids[$key-1]);
201 221
 				unset($account_lids[$key]);
@@ -219,10 +239,13 @@  discard block
 block discarded – undo
219 239
 	 * @param mixed $_account_ids comma seperated list or array with ids
220 240
 	 * @return mixed comma seperated list or array with lids
221 241
 	 */
222
-	public static function account_id2name( $_account_id ) {
242
+	public static function account_id2name( $_account_id )
243
+	{
223 244
 		$account_ids = is_array( $_account_id ) ? $_account_id : explode( ',', $_account_id );
224
-		foreach ( $account_ids as $account_id ) {
225
-			if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) {
245
+		foreach ( $account_ids as $account_id )
246
+		{
247
+			if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id ))
248
+			{
226 249
 				$account_lids[] = $account_lid;
227 250
 			}
228 251
 		}
@@ -235,9 +258,11 @@  discard block
 block discarded – undo
235 258
 	 * @param mixed _cat_ids comma seperated list or array
236 259
 	 * @return mixed comma seperated list or array with cat_names
237 260
 	 */
238
-	public static function cat_id2name( $_cat_ids ) {
261
+	public static function cat_id2name( $_cat_ids )
262
+	{
239 263
 		$cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids );
240
-		foreach ( $cat_ids as $cat_id ) {
264
+		foreach ( $cat_ids as $cat_id )
265
+		{
241 266
 			$cat_names[] = Api\Categories::id2name( (int)$cat_id );
242 267
 		}
243 268
 		return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names);
@@ -251,14 +276,20 @@  discard block
 block discarded – undo
251 276
 	 * @param int $parent Optional parent ID to use for new categories
252 277
 	 * @return mixed comma seperated list or array with cat_ids
253 278
 	 */
254
-	public static function cat_name2id( $_cat_names, $parent = 0 ) {
279
+	public static function cat_name2id( $_cat_names, $parent = 0 )
280
+	{
255 281
 		$cats = new Api\Categories();	// uses current user and app (egw_info[flags][currentapp])
256 282
 
257 283
 		$cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names );
258
-		foreach ( $cat_names as $cat_name ) {
284
+		foreach ( $cat_names as $cat_name )
285
+		{
259 286
 			$cat_name = trim($cat_name);
260
-			if ( $cat_name == '' ) continue;
261
-			if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) {
287
+			if ( $cat_name == '' )
288
+			{
289
+				continue;
290
+			}
291
+			if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run)
292
+			{
262 293
 				$cat_id = $cats->add( array(
263 294
 					'name' => $cat_name,
264 295
 					'parent' => $parent,
@@ -307,8 +338,12 @@  discard block
 block discarded – undo
307 338
 	 * @param object &$cclass calling class to process the '@ evals'
308 339
 	 * @return bool
309 340
 	 */
310
-	public static function conversion( &$_record,  $_conversion, &$_cclass = null ) {
311
-		if (empty( $_conversion ) ) return $_record;
341
+	public static function conversion( &$_record,  $_conversion, &$_cclass = null )
342
+	{
343
+		if (empty( $_conversion ) )
344
+		{
345
+			return $_record;
346
+		}
312 347
 
313 348
 		self::$cclass =& $_cclass;
314 349
 
@@ -320,15 +355,21 @@  discard block
 block discarded – undo
320 355
 		$CntlnCLPre  = '|TCnCL{';   // Like |C{ but allowes CR and LF
321 356
 		$INE = '|INE{';             // Only insert if stuff in ^^ is not empty
322 357
 
323
-		foreach ( $_conversion as $idx => $conversion_string ) {
324
-			if ( empty( $conversion_string ) ) continue;
358
+		foreach ( $_conversion as $idx => $conversion_string )
359
+		{
360
+			if ( empty( $conversion_string ) )
361
+			{
362
+				continue;
363
+			}
325 364
 
326 365
 			// fetch patterns ($rvalues)
327 366
 			$rvalues = array();
328 367
 			$pat_reps = explode( $PSep, stripslashes( $conversion_string ) );
329
-			foreach( $pat_reps as $k => $pat_rep ) {
368
+			foreach( $pat_reps as $k => $pat_rep )
369
+			{
330 370
 				list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 );
331
-				if( $replace == '' ) {
371
+				if( $replace == '' )
372
+				{
332 373
 					$replace = $pattern; $pattern = '^.*$';
333 374
 				}
334 375
 				$rvalues[$pattern] = $replace;	// replace two with only one, added by the form
@@ -338,19 +379,23 @@  discard block
 block discarded – undo
338 379
 			$val = array_key_exists( $idx, $_record ) ? $_record[$idx] : '';
339 380
 
340 381
 			$c_functions = array('cat', 'account', 'strtotime', 'list');
341
-			if($_cclass) {
382
+			if($_cclass)
383
+			{
342 384
 				// Add in additional methods
343 385
 				$reflection = new ReflectionClass(get_class($_cclass));
344 386
 				$methods = $reflection->getMethods(ReflectionMethod::IS_STATIC);
345
-				foreach($methods as $method) {
387
+				foreach($methods as $method)
388
+				{
346 389
 					$c_functions[] = $method->name;
347 390
 				}
348 391
 			}
349 392
 			$c_functions = implode('|', $c_functions);
350
-			foreach ( $rvalues as $pattern => $replace ) {
393
+			foreach ( $rvalues as $pattern => $replace )
394
+			{
351 395
 				// Allow to include record indexes in pattern
352 396
 				$reg = '/\|\[([0-9]+)\]/';
353
-				while( preg_match( $reg, $pattern, $vars ) ) {
397
+				while( preg_match( $reg, $pattern, $vars ) )
398
+				{
354 399
 					// expand all _record fields
355 400
 					$pattern = str_replace(
356 401
 						$CPre . $vars[1] . $CPos,
@@ -358,12 +403,14 @@  discard block
 block discarded – undo
358 403
 						$pattern
359 404
 					);
360 405
 				}
361
-				if( preg_match('/'. (string)$pattern.'/', $val) ) {
406
+				if( preg_match('/'. (string)$pattern.'/', $val) )
407
+				{
362 408
 
363 409
 					$val = preg_replace( '/'.(string)$pattern.'/', $replace, (string)$val );
364 410
 
365 411
 					$reg = '/\|\[([a-zA-Z_0-9]+)\]/';
366
-					while( preg_match( $reg, $val, $vars ) ) {
412
+					while( preg_match( $reg, $val, $vars ) )
413
+					{
367 414
 						// expand all _record fields
368 415
 						$val = str_replace(
369 416
 							$CPre . $vars[1] . $CPos,
@@ -390,11 +437,13 @@  discard block
 block discarded – undo
390 437
 	 *
391 438
 	 * @param array $_matches
392 439
 	 */
393
-	private static function c2_dispatcher( $_matches ) {
440
+	private static function c2_dispatcher( $_matches )
441
+	{
394 442
 		$action = &$_matches[1]; // cat or account ...
395 443
 		$data = &$_matches[2];   // datas for action
396 444
 
397
-		switch ( $action ) {
445
+		switch ( $action )
446
+		{
398 447
 			case 'strtotime' :
399 448
 				list( $string, $format ) = explode( ',', $data );
400 449
 				return self::custom_strtotime( trim( $string ), trim( $format ) );
@@ -404,22 +453,28 @@  discard block
 block discarded – undo
404 453
 				// 1 based indexing for user ease
405 454
 				return $exploded[$index - 1];
406 455
 			default :
407
-				if(self::$cclass && method_exists(self::$cclass, $action)) {
456
+				if(self::$cclass && method_exists(self::$cclass, $action))
457
+				{
408 458
 					$class = get_class(self::$cclass);
409 459
 					return call_user_func("$class::$action", $data);
410 460
 				}
411 461
 				$method = (string)$action. ( is_int( $data ) ? '_id2name' : '_name2id' );
412
-				if(self::$cclass && method_exists(self::$cclass, $method)) {
462
+				if(self::$cclass && method_exists(self::$cclass, $method))
463
+				{
413 464
 					$class = get_class(self::$cclass);
414 465
 					return call_user_func("$class::$action", $data);
415
-				} else {
466
+				}
467
+				else
468
+				{
416 469
 					return self::$method( $data );
417 470
 				}
418 471
 		}
419 472
 	}
420 473
 
421
-	private static function strclean( $_matches ) {
422
-		switch( $_matches[1] ) {
474
+	private static function strclean( $_matches )
475
+	{
476
+		switch( $_matches[1] )
477
+		{
423 478
 			case '|T{' : return trim( $_matches[2] );
424 479
 			case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_matches[2] ) );
425 480
 			case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) );
@@ -436,7 +491,8 @@  discard block
 block discarded – undo
436 491
 	 * @param string $_appname {<appname> | all}
437 492
 	 * @return array(<appname> => array( <type> => array(<plugin> => <title>)))
438 493
 	 */
439
-	public static function get_plugins( $_appname = 'all', $_type = 'all' ) {
494
+	public static function get_plugins( $_appname = 'all', $_type = 'all' )
495
+	{
440 496
 		$plugins = Api\Cache::getTree(
441 497
 			__CLASS__,
442 498
 			'plugins',
@@ -449,38 +505,63 @@  discard block
 block discarded – undo
449 505
 
450 506
 		// Testing: comment out Api\Cache call, use this
451 507
 		//$plugins = self::_get_plugins($appnames, $types);
452
-		foreach($plugins as $appname => $_types) {
453
-			if(!in_array($appname, $appnames)) unset($plugins[$appname]);
508
+		foreach($plugins as $appname => $_types)
509
+		{
510
+			if(!in_array($appname, $appnames))
511
+			{
512
+				unset($plugins[$appname]);
513
+			}
454 514
 		}
455
-		foreach($plugins as $appname => $types) {
515
+		foreach($plugins as $appname => $types)
516
+		{
456 517
 			$plugins[$appname] = array_intersect_key($plugins[$appname], $types);
457 518
 		}
458 519
 		return $plugins;
459 520
 	}
460 521
 
461
-	public static function _get_plugins(Array $appnames, Array $types) {
522
+	public static function _get_plugins(Array $appnames, Array $types)
523
+	{
462 524
 		$plugins = array();
463
-		foreach ($appnames as $appname) {
464
-			if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue;
525
+		foreach ($appnames as $appname)
526
+		{
527
+			if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true)
528
+			{
529
+				continue;
530
+			}
465 531
 
466 532
 			$appdir = EGW_INCLUDE_ROOT. "/$appname/inc";
467
-			if(!is_dir($appdir)) continue;
533
+			if(!is_dir($appdir))
534
+			{
535
+				continue;
536
+			}
468 537
 			$d = dir($appdir);
469 538
 
470 539
 			// step through each file in appdir
471
-			while (false !== ($entry = $d->read())) {
540
+			while (false !== ($entry = $d->read()))
541
+			{
472 542
 				// Blacklisted?
473
-				if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname]))  continue;
474
-				if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) continue;
543
+				if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname]))
544
+				{
545
+					continue;
546
+				}
547
+				if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches))
548
+				{
549
+					continue;
550
+				}
475 551
 				$classname = $matches[1];
476 552
 				$file = $appdir. '/'. $entry;
477 553
 
478
-				foreach ($types as $type) {
479
-					if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) continue;
554
+				foreach ($types as $type)
555
+				{
556
+					if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false)
557
+					{
558
+						continue;
559
+					}
480 560
 					require_once($file);
481 561
 					$reflectionClass = new ReflectionClass($classname);
482 562
 					if($reflectionClass->IsInstantiable() &&
483
-							$reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) {
563
+							$reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin'))
564
+					{
484 565
 						try {
485 566
 							$plugin_object = new $classname;
486 567
 						}
@@ -495,7 +576,8 @@  discard block
 block discarded – undo
495 576
 			$d->close();
496 577
 
497 578
 			$config = Api\Config::read('importexport');
498
-			if($config['update'] == 'auto') {
579
+			if($config['update'] == 'auto')
580
+			{
499 581
 				self::load_defaults($appname);
500 582
 			}
501 583
 		}
@@ -509,38 +591,56 @@  discard block
 block discarded – undo
509 591
 	 * @param string $_type
510 592
 	 * @return array $num => $appname
511 593
 	 */
512
-	public static function get_apps($_type, $ignore_acl = false) {
594
+	public static function get_apps($_type, $ignore_acl = false)
595
+	{
513 596
 		$apps = array_keys(self::get_plugins('all',$_type));
514
-		if($ignore_acl) return $apps;
597
+		if($ignore_acl)
598
+		{
599
+			return $apps;
600
+		}
515 601
 
516
-		foreach($apps as $key => $app) {
517
-			if(!self::has_definitions($app, $_type)) unset($apps[$key]);
602
+		foreach($apps as $key => $app)
603
+		{
604
+			if(!self::has_definitions($app, $_type))
605
+			{
606
+				unset($apps[$key]);
607
+			}
518 608
 		}
519 609
 		return $apps;
520 610
 	}
521 611
 
522
-	public static function load_defaults($appname) {
612
+	public static function load_defaults($appname)
613
+	{
523 614
 		// Check for new definitions to import from $appname/setup/*.xml
524 615
 		$appdir = EGW_INCLUDE_ROOT. "/$appname/setup";
525
-		if(!is_dir($appdir)) return;
616
+		if(!is_dir($appdir))
617
+		{
618
+			return;
619
+		}
526 620
 		$d = dir($appdir);
527 621
 
528 622
 		// step through each file in app's setup
529
-		while (false !== ($entry = $d->read())) {
623
+		while (false !== ($entry = $d->read()))
624
+		{
530 625
 			$file = $appdir. '/'. $entry;
531 626
 			list( $filename, $extension) = explode('.',$entry);
532
-			if ( $extension != 'xml' ) continue;
627
+			if ( $extension != 'xml' )
628
+			{
629
+				continue;
630
+			}
533 631
 			try {
534 632
 				// import will skip invalid files
535 633
 				importexport_definitions_bo::import( $file );
536
-			} catch (Exception $e) {
634
+			}
635
+			catch (Exception $e) {
537 636
 				error_log(__CLASS__.__FUNCTION__. " import $appname definitions: " . $e->getMessage());
538 637
 			}
539 638
 		}
540 639
 		$d->close();
541 640
 	}
542 641
 
543
-	public static function guess_filetype( $_file ) {
642
+	public static function guess_filetype( $_file )
643
+	{
544 644
 
545 645
 	}
546 646
 
@@ -551,7 +651,8 @@  discard block
 block discarded – undo
551 651
 	 * @param string $_type {import | export | all}
552 652
 	 * @return boolean
553 653
 	 */
554
-	public static function has_definitions( $_appname = 'all', $_type = 'all' ) {
654
+	public static function has_definitions( $_appname = 'all', $_type = 'all' )
655
+	{
555 656
 		$definitions = Api\Cache::getSession(
556 657
 			__CLASS__,
557 658
 			'has_definitions',
@@ -565,27 +666,36 @@  discard block
 block discarded – undo
565 666
 		// Testing: Comment out cache call above, use this
566 667
 		//$definitions = self::_has_definitions($appnames, $types);
567 668
 
568
-		foreach($definitions as $appname => $_types) {
569
-			if(!in_array($appname, $appnames)) unset($definitions[$appname]);
669
+		foreach($definitions as $appname => $_types)
670
+		{
671
+			if(!in_array($appname, $appnames))
672
+			{
673
+				unset($definitions[$appname]);
674
+			}
570 675
 		}
571
-		foreach($definitions as $appname => $_types) {
676
+		foreach($definitions as $appname => $_types)
677
+		{
572 678
 			$definitions[$appname] = array_intersect_key($definitions[$appname], array_flip($types));
573 679
 		}
574 680
 		return !empty($definitions[$appname]);
575 681
 	}
576 682
 
577 683
 	// Api\Cache needs this public
578
-	public static function _has_definitions(Array $appnames, Array $types) {
684
+	public static function _has_definitions(Array $appnames, Array $types)
685
+	{
579 686
 		$def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types));
580 687
 		$list = array();
581
-		foreach((array)$def->get_definitions() as $id) {
688
+		foreach((array)$def->get_definitions() as $id)
689
+		{
582 690
 			// Need to instanciate it to check, but if the user doesn't have permission, it throws an exception
583 691
 			try {
584 692
 				$definition = new importexport_definition($id);
585
-				if($def->is_permitted($definition->get_record_array())) {
693
+				if($def->is_permitted($definition->get_record_array()))
694
+				{
586 695
 					$list[$definition->application][$definition->type][] = $id;
587 696
 				}
588
-			} catch (Exception $e) {
697
+			}
698
+			catch (Exception $e) {
589 699
 				// That one doesn't work, keep going
590 700
 			}
591 701
 			$definition = null;
@@ -614,13 +724,22 @@  discard block
 block discarded – undo
614 724
 			$plugin = is_object($plugin_name) ? $plugin_name : new $plugin_name();
615 725
 			$plugin_name = get_class($plugin);
616 726
 
617
-			if($record_classname == null) $record_classname = $plugin::get_egw_record_class();
618
-			if(!class_exists($record_classname)) throw new Exception('Bad class name ' . $record_classname);
727
+			if($record_classname == null)
728
+			{
729
+				$record_classname = $plugin::get_egw_record_class();
730
+			}
731
+			if(!class_exists($record_classname))
732
+			{
733
+				throw new Exception('Bad class name ' . $record_classname);
734
+			}
619 735
 
620 736
 			if(!$wizard_plugin)
621 737
 			{
622 738
 				$wizard_name = $app_name . '_wizard_' . str_replace($app_name . '_', '', $plugin_name);
623
-				if(!class_exists($wizard_name)) throw new Exception('Bad wizard name ' . $wizard_name);
739
+				if(!class_exists($wizard_name))
740
+				{
741
+					throw new Exception('Bad wizard name ' . $wizard_name);
742
+				}
624 743
 				$wizard_plugin = new $wizard_name;
625 744
 			}
626 745
 		}
@@ -640,7 +759,10 @@  discard block
 block discarded – undo
640 759
 		foreach($record_classname::$types as $type => $type_fields)
641 760
 		{
642 761
 			// Only these for now, until filter methods for others are figured out
643
-			if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) continue;
762
+			if(!in_array($type, array('select','select-cat','select-account','date','date-time')))
763
+			{
764
+				continue;
765
+			}
644 766
 			foreach($type_fields as $field_name)
645 767
 			{
646 768
 				$fields[$field_name] = array(
@@ -658,14 +780,18 @@  discard block
 block discarded – undo
658 780
 			$fields['#'.$field_name] = $settings;
659 781
 		}
660 782
 
661
-		foreach($fields as $field_name => &$settings) {
783
+		foreach($fields as $field_name => &$settings)
784
+		{
662 785
 			// Can't really filter on these (or at least no generic, sane way figured out yet)
663 786
 			if(!is_array($settings) || in_array($settings['type'], array('text','button', 'label','url','url-email','url-phone','htmlarea')))
664 787
 			{
665 788
 				unset($fields[$field_name]);
666 789
 				continue;
667 790
 			}
668
-			if($settings['type'] == 'radio') $settings['type'] = 'select';
791
+			if($settings['type'] == 'radio')
792
+			{
793
+				$settings['type'] = 'select';
794
+			}
669 795
 			switch($settings['type'])
670 796
 			{
671 797
 				case 'checkbox':
Please login to merge, or discard this patch.
importexport/inc/class.importexport_schedule_ui.inc.php 4 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
 	}
197 197
 
198 198
 	/**
199
-	* Get options for select boxes
200
-	*/
199
+	 * Get options for select boxes
200
+	 */
201 201
 	public static function get_select_options(Array $data)
202 202
 	{
203 203
 		$options = array(
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
 	}
262 262
 
263 263
 	/**
264
-	* Generate a async key
265
-	*/
264
+	 * Generate a async key
265
+	 */
266 266
 	public static function generate_id($data)
267 267
 	{
268 268
 
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
 	}
279 279
 
280 280
 	/**
281
-	* Check that the target is valid for the type (readable or writable)
282
-	* and that they're not trying to write directly to the filesystem
283
-	*
284
-	* $data should contain target & type
285
-	*/
281
+	 * Check that the target is valid for the type (readable or writable)
282
+	 * and that they're not trying to write directly to the filesystem
283
+	 *
284
+	 * $data should contain target & type
285
+	 */
286 286
 	public static function check_target(Array $data) {
287 287
 		$scheme = parse_url($data['target'], PHP_URL_SCHEME);
288 288
 		if($scheme == '' || $scheme == 'file')
@@ -329,11 +329,11 @@  discard block
 block discarded – undo
329 329
 	}
330 330
 
331 331
 	/**
332
-	* Writable that checks the folder too, in case the file does not exist yet
333
-	* http://ca3.php.net/manual/en/function.is-writable.php#73596
334
-	*
335
-	* @param path Path to check
336
-	*/
332
+	 * Writable that checks the folder too, in case the file does not exist yet
333
+	 * http://ca3.php.net/manual/en/function.is-writable.php#73596
334
+	 *
335
+	 * @param path Path to check
336
+	 */
337 337
 	private static function is__writable($path)
338 338
 	{
339 339
 		if ($path{strlen($path)-1}=='/')
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	}
366 366
 
367 367
 	/**
368
-	* Execute a scheduled import or export
369
-	*/
368
+	 * Execute a scheduled import or export
369
+	 */
370 370
 	public static function exec($data)
371 371
 	{
372 372
 		ob_start();
Please login to merge, or discard this patch.
Braces   +16 added lines, -5 removed lines patch added patch discarded remove patch
@@ -113,7 +113,10 @@  discard block
 block discarded – undo
113 113
 			// Remove any left blank
114 114
 			foreach($schedule as $key => &$value)
115 115
 			{
116
-				if($value == '') unset($schedule[$key]);
116
+				if($value == '')
117
+				{
118
+					unset($schedule[$key]);
119
+				}
117 120
 			}
118 121
 			$result = $async->set_timer(
119 122
 				$schedule,
@@ -283,14 +286,16 @@  discard block
 block discarded – undo
283 286
 	*
284 287
 	* $data should contain target & type
285 288
 	*/
286
-	public static function check_target(Array $data) {
289
+	public static function check_target(Array $data)
290
+	{
287 291
 		$scheme = parse_url($data['target'], PHP_URL_SCHEME);
288 292
 		if($scheme == '' || $scheme == 'file')
289 293
 		{
290 294
 			return 'Direct file access not allowed';
291 295
 		}
292 296
 
293
-		if($scheme == Vfs::SCHEME  && !in_array(Vfs::SCHEME, stream_get_wrappers())) {
297
+		if($scheme == Vfs::SCHEME  && !in_array(Vfs::SCHEME, stream_get_wrappers()))
298
+		{
294 299
 			stream_wrapper_register(Vfs::SCHEME, 'vfs_stream_wrapper', STREAM_IS_URL);
295 300
 		}
296 301
 
@@ -315,8 +320,14 @@  discard block
 block discarded – undo
315 320
 			// Response code has an integer key, but redirects may add more responses
316 321
 			for($i = 0; $i < count($headers); $i++)
317 322
 			{
318
-				if(!$headers[$i]) break;
319
-				if(strpos($headers[$i],'200') !== false) return true;
323
+				if(!$headers[$i])
324
+				{
325
+					break;
326
+				}
327
+				if(strpos($headers[$i],'200') !== false)
328
+				{
329
+					return true;
330
+				}
320 331
 			}
321 332
 			return lang('%1 is not readable',$data['target']);
322 333
 		}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	/**
199 199
 	* Get options for select boxes
200 200
 	*/
201
-	public static function get_select_options(Array $data)
201
+	public static function get_select_options(array $data)
202 202
 	{
203 203
 		$options = array(
204 204
 			'type'	=>	array(
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	*
284 284
 	* $data should contain target & type
285 285
 	*/
286
-	public static function check_target(Array $data) {
286
+	public static function check_target(array $data) {
287 287
 		$scheme = parse_url($data['target'], PHP_URL_SCHEME);
288 288
 		if($scheme == '' || $scheme == 'file')
289 289
 		{
Please login to merge, or discard this patch.
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	public function index($content = array())
38 38
 	{
39 39
 		$async = new Api\Asyncservice();
40
-		if(is_array($content['scheduled']))
40
+		if (is_array($content['scheduled']))
41 41
 		{
42
-			foreach($content['scheduled'] as $row)
42
+			foreach ($content['scheduled'] as $row)
43 43
 			{
44
-				if($row['delete'])
44
+				if ($row['delete'])
45 45
 				{
46 46
 					$key = urldecode(key($row['delete']));
47 47
 					$async->cancel_timer($key);
@@ -50,16 +50,16 @@  discard block
 block discarded – undo
50 50
 		}
51 51
 		$async_list = $async->read('importexport%');
52 52
 		$data = array();
53
-		if(is_array($async_list))
53
+		if (is_array($async_list))
54 54
 		{
55
-			foreach($async_list as $id => $async)
55
+			foreach ($async_list as $id => $async)
56 56
 			{
57
-				foreach(array('errors', 'warnings', 'result') as $messages)
57
+				foreach (array('errors', 'warnings', 'result') as $messages)
58 58
 				{
59
-					if(is_array($async['data'][$messages]))
59
+					if (is_array($async['data'][$messages]))
60 60
 					{
61 61
 						$list = array();
62
-						foreach($async['data'][$messages] as $target => $message)
62
+						foreach ($async['data'][$messages] as $target => $message)
63 63
 						{
64 64
 							$list[] = array(
65 65
 								'target' => (is_numeric($target) ? '' : $target),
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 						$async['data'][$messages] = $list;
70 70
 					}
71 71
 				}
72
-				if(is_numeric($async['data']['record_count']))
72
+				if (is_numeric($async['data']['record_count']))
73 73
 				{
74 74
 					$async['data']['record_count'] = lang('%1 records processed', $async['data']['record_count']);
75 75
 				}
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 		$data = $content;
101 101
 
102 102
 		// Deal with incoming
103
-		if($content['save'] && self::check_target($content) === true)
103
+		if ($content['save'] && self::check_target($content) === true)
104 104
 		{
105 105
 			unset($content['save']);
106 106
 			$async->cancel_timer($id);
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 			unset($content['schedule']);
112 112
 
113 113
 			// Remove any left blank
114
-			foreach($schedule as $key => &$value)
114
+			foreach ($schedule as $key => &$value)
115 115
 			{
116
-				if($value == '') unset($schedule[$key]);
116
+				if ($value == '') unset($schedule[$key]);
117 117
 			}
118 118
 			$result = $async->set_timer(
119 119
 				$schedule,
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 				'importexport.importexport_schedule_ui.exec',
122 122
 				$content
123 123
 			);
124
-			if($result)
124
+			if ($result)
125 125
 			{
126
-				Framework::refresh_opener('', 'admin',$id,'update','admin');
126
+				Framework::refresh_opener('', 'admin', $id, 'update', 'admin');
127 127
 				Framework::window_close();
128 128
 			}
129 129
 			else
@@ -133,19 +133,19 @@  discard block
 block discarded – undo
133 133
 			}
134 134
 		}
135 135
 
136
-		if($id)
136
+		if ($id)
137 137
 		{
138 138
 
139 139
 			$preserve['id'] = $id;
140 140
 			$async = $async->read($id);
141
-			if(is_array($async[$id]['data']))
141
+			if (is_array($async[$id]['data']))
142 142
 			{
143 143
 				$data += $async[$id]['data'];
144 144
 				$data['schedule'] = $async[$id]['times'];
145 145
 				unset($data['times']);
146 146
 
147 147
 				// Async sometimes changes minutes to an array - show user what they typed
148
-				if(is_array($data['schedule']['min']))
148
+				if (is_array($data['schedule']['min']))
149 149
 				{
150 150
 					$data['schedule']['min'] = $data['min'];
151 151
 				}
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 		{
160 160
 			$data['type'] = $content['type'] ? $content['type'] : 'import';
161 161
 
162
-			if((int)$definition_id)
162
+			if ((int)$definition_id)
163 163
 			{
164 164
 				$bo = new importexport_definitions_bo();
165 165
 				$definition = $bo->read($definition_id);
166
-				if($definition['definition_id'])
166
+				if ($definition['definition_id'])
167 167
 				{
168 168
 					$data['type'] = $definition['type'];
169 169
 					$data['appname'] = $definition['application'];
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 			}
174 174
 		}
175 175
 
176
-		if($data['target'] && $data['type'])
176
+		if ($data['target'] && $data['type'])
177 177
 		{
178 178
 			$file_check = self::check_target($data);
179
-			if($file_check !== true)
179
+			if ($file_check !== true)
180 180
 			{
181
-				$data['message'] .= ($data['message'] ? "\n" . $file_check : $file_check);
181
+				$data['message'] .= ($data['message'] ? "\n".$file_check : $file_check);
182 182
 			}
183 183
 		}
184 184
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		$data['current_time'] = time();
189 189
 
190 190
 		$sel_options = self::get_select_options($data);
191
-		Framework::includeJS('.','importexport','importexport');
191
+		Framework::includeJS('.', 'importexport', 'importexport');
192 192
 
193 193
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Schedule import / export');
194 194
 		$this->template->read('importexport.schedule_edit');
@@ -208,21 +208,21 @@  discard block
 block discarded – undo
208 208
 		);
209 209
 
210 210
 		(array)$apps = importexport_helper_functions::get_apps($data['type'] ? $data['type'] : 'all');
211
-		if(count($apps))
211
+		if (count($apps))
212 212
 		{
213
-			$options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps);
213
+			$options['appname'] = array('' => lang('Select one')) + array_combine($apps, $apps);
214 214
 		}
215 215
 
216 216
 		$plugins = importexport_helper_functions::get_plugins($data['appname'] ? $data['appname'] : 'all', $data['type']);
217
-		if(is_array($plugins))
217
+		if (is_array($plugins))
218 218
 		{
219
-			foreach($plugins as $types)
219
+			foreach ($plugins as $types)
220 220
 			{
221
-				if(!is_array($types[$data['type']]))
221
+				if (!is_array($types[$data['type']]))
222 222
 				{
223 223
 					continue;
224 224
 				}
225
-				foreach($types[$data['type']] as $key => $title)
225
+				foreach ($types[$data['type']] as $key => $title)
226 226
 				{
227 227
 					$options['plugin'][$key] = $title;
228 228
 				}
@@ -288,27 +288,27 @@  discard block
 block discarded – undo
288 288
 	*/
289 289
 	public static function check_target(Array $data) {
290 290
 		$scheme = parse_url($data['target'], PHP_URL_SCHEME);
291
-		if($scheme == '' || $scheme == 'file')
291
+		if ($scheme == '' || $scheme == 'file')
292 292
 		{
293 293
 			return 'Direct file access not allowed';
294 294
 		}
295 295
 
296
-		if($scheme == Vfs::SCHEME  && !in_array(Vfs::SCHEME, stream_get_wrappers())) {
296
+		if ($scheme == Vfs::SCHEME && !in_array(Vfs::SCHEME, stream_get_wrappers())) {
297 297
 			stream_wrapper_register(Vfs::SCHEME, 'vfs_stream_wrapper', STREAM_IS_URL);
298 298
 		}
299 299
 
300 300
 		if ($data['type'] == 'import' && ($scheme == Vfs::SCHEME && !Vfs::is_readable($data['target'])))
301 301
 		{
302
-			return lang('%1 is not readable',$data['target']);
302
+			return lang('%1 is not readable', $data['target']);
303 303
 		}
304
-		elseif ($data['type'] == 'import' && in_array($scheme, array('http','https')))
304
+		elseif ($data['type'] == 'import' && in_array($scheme, array('http', 'https')))
305 305
 		{
306 306
 			// Not supported by is_readable, try headers...
307 307
 			stream_context_set_default(array('http'=>array(
308 308
 				'method'	=> 'HEAD',
309 309
 				'ignore_errors'	=> 1
310 310
 			)));
311
-			$headers = get_headers($data['target'],1);
311
+			$headers = get_headers($data['target'], 1);
312 312
 
313 313
 			// Reset...
314 314
 			stream_context_set_default(array('http'=>array(
@@ -316,16 +316,16 @@  discard block
 block discarded – undo
316 316
 				'ignore_errors'	=> 0
317 317
 			)));
318 318
 			// Response code has an integer key, but redirects may add more responses
319
-			for($i = 0; $i < count($headers); $i++)
319
+			for ($i = 0; $i < count($headers); $i++)
320 320
 			{
321
-				if(!$headers[$i]) break;
322
-				if(strpos($headers[$i],'200') !== false) return true;
321
+				if (!$headers[$i]) break;
322
+				if (strpos($headers[$i], '200') !== false) return true;
323 323
 			}
324
-			return lang('%1 is not readable',$data['target']);
324
+			return lang('%1 is not readable', $data['target']);
325 325
 		}
326 326
 		elseif ($data['type'] == 'export' && !self::is__writable($data['target']))
327 327
 		{
328
-			return lang('%1 is not writable',$data['target']);
328
+			return lang('%1 is not writable', $data['target']);
329 329
 		}
330 330
 
331 331
 		return true;
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	*/
340 340
 	private static function is__writable($path)
341 341
 	{
342
-		if ($path{strlen($path)-1}=='/')
342
+		if ($path{strlen($path) - 1} == '/')
343 343
 		{
344 344
 			// recursively return a temporary file path
345 345
 			return self::is__writable($path.uniqid(mt_rand()).'.tmp');
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		$rm = file_exists($path);
354 354
 		$f = @fopen($path, 'a');
355 355
 
356
-		if ($f===false)
356
+		if ($f === false)
357 357
 		{
358 358
 			return false;
359 359
 		}
@@ -379,10 +379,10 @@  discard block
 block discarded – undo
379 379
 		unset($data['warnings']);
380 380
 		unset($data['result']);
381 381
 
382
-		if($data['lock'])
382
+		if ($data['lock'])
383 383
 		{
384 384
 			// Lock expires
385
-			if($data['lock'] < time())
385
+			if ($data['lock'] < time())
386 386
 			{
387 387
 				unset($data['lock']);
388 388
 				$data['warnings'][][] = lang('Lock expired on previous run');
@@ -403,25 +403,25 @@  discard block
 block discarded – undo
403 403
 
404 404
 		// check file
405 405
 		$file_check = self::check_target($data);
406
-		if($file_check !== true)
406
+		if ($file_check !== true)
407 407
 		{
408 408
 			$data['errors'] = array($file_check=>'');
409 409
 			// Update job with results
410 410
 			self::update_job($data);
411 411
 
412
-			error_log('importexport_schedule: ' . date('c') . ": $file_check \n");
412
+			error_log('importexport_schedule: '.date('c').": $file_check \n");
413 413
 			error_log(ob_get_flush());
414 414
 			return;
415 415
 		}
416 416
 
417 417
 		$definition = new importexport_definition($data['definition']);
418
-		if( $definition->get_identifier() < 1 )
418
+		if ($definition->get_identifier() < 1)
419 419
 		{
420 420
 			$data['errors'] = array('Definition not found!');
421 421
 			// Update job with results
422 422
 			self::update_job($data);
423 423
 
424
-			error_log('importexport_schedule: ' . date('c') . ": Definition not found! \n");
424
+			error_log('importexport_schedule: '.date('c').": Definition not found! \n");
425 425
 			return;
426 426
 		}
427 427
 		$GLOBALS['egw_info']['flags']['currentapp'] = $definition->application;
@@ -430,30 +430,30 @@  discard block
 block discarded – undo
430 430
 
431 431
 		$type = $data['type'];
432 432
 
433
-		if(is_dir($data['target']))
433
+		if (is_dir($data['target']))
434 434
 		{
435
-			if($data['type'] == 'import')
435
+			if ($data['type'] == 'import')
436 436
 			{
437 437
 				$targets = array();
438
-				foreach(scandir($data['target']) as $target)
438
+				foreach (scandir($data['target']) as $target)
439 439
 				{
440 440
 					if ($target == '.' || $target == '..')
441 441
 					{
442 442
 						continue;
443 443
 					}
444
-					$target = $data['target'].(substr($data['target'],-1) == '/' ? '' : '/').$target;
444
+					$target = $data['target'].(substr($data['target'], -1) == '/' ? '' : '/').$target;
445 445
 
446 446
 					// Check modification time, make sure it's not currently being written
447 447
 					// Skip files modified in the last 10 seconds
448 448
 					$mod_time = filemtime($target);
449
-					if($mod_time >= time() - 10)
449
+					if ($mod_time >= time() - 10)
450 450
 					{
451 451
 						$data['result'][$target] = lang('Skipped');
452 452
 						continue;
453 453
 					}
454 454
 					$targets[$mod_time.$target] = $target;
455 455
 				}
456
-				if($targets)
456
+				if ($targets)
457 457
 				{
458 458
 					ksort($targets);
459 459
 				}
@@ -469,27 +469,27 @@  discard block
 block discarded – undo
469 469
 			$targets = array($data['target']);
470 470
 		}
471 471
 
472
-		if($type == 'export')
472
+		if ($type == 'export')
473 473
 		{
474 474
 			// Set to export all or filter, if set
475 475
 			$selection = array('selection' => 'all');
476
-			if($definition->filter)
476
+			if ($definition->filter)
477 477
 			{
478 478
 				$fields = importexport_helper_functions::get_filter_fields($definition->application, $po);
479 479
 				$selection = array('selection' => 'filter');
480 480
 				$filters = array();
481
-				foreach($definition->filter as $field => $value)
481
+				foreach ($definition->filter as $field => $value)
482 482
 				{
483 483
 					 // Handle multiple values
484
-					if(!is_array($value) && strpos($value,',') !== false)
484
+					if (!is_array($value) && strpos($value, ',') !== false)
485 485
 					{
486
-						$value = explode(',',$value);
486
+						$value = explode(',', $value);
487 487
 					}
488 488
 
489 489
 					$filters[$field] = $value;
490 490
 
491 491
 					// Process relative dates into the current absolute date
492
-					if($filters[$field] && strpos($fields[$field]['type'],'date') === 0)
492
+					if ($filters[$field] && strpos($fields[$field]['type'], 'date') === 0)
493 493
 					{
494 494
 						$filters[$field] = importexport_helper_functions::date_rel2abs($value);
495 495
 					}
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 				// Update filter to use current absolute dates
498 498
 				$definition->filter = $filters;
499 499
 			}
500
-			if(!is_array($definition->plugin_options))
500
+			if (!is_array($definition->plugin_options))
501 501
 			{
502 502
 				$definition->plugin_options = array();
503 503
 			}
@@ -505,10 +505,10 @@  discard block
 block discarded – undo
505 505
 		}
506 506
 		// Set some automatic admin history data, if the plugin wants it
507 507
 		$definition->plugin_options = array_merge($definition->plugin_options, array('admin_cmd' => array(
508
-			'comment' => lang('schedule import / export') . "\n" . $definition->get_title() . "\n" . $target
508
+			'comment' => lang('schedule import / export')."\n".$definition->get_title()."\n".$target
509 509
 		)));
510 510
 
511
-		foreach($targets as $target)
511
+		foreach ($targets as $target)
512 512
 		{
513 513
 			// Update lock timeout
514 514
 			$data['lock'] = time() + 3600;
@@ -517,16 +517,16 @@  discard block
 block discarded – undo
517 517
 			$resource = null;
518 518
 			try
519 519
 			{
520
-				if (($resource = @fopen( $target, $data['type'] == 'import' ? 'rb' : 'wb' )))
520
+				if (($resource = @fopen($target, $data['type'] == 'import' ? 'rb' : 'wb')))
521 521
 				{
522
-					$result = $po->$type( $resource, $definition );
522
+					$result = $po->$type($resource, $definition);
523 523
 
524 524
 					fclose($resource);
525 525
 				}
526 526
 				else
527 527
 				{
528
-					error_log('importexport_schedule: ' . date('c') . ": File $target not readable! \n");
529
-					$data['errors'][$target][] = lang('%1 is not readable',$target);
528
+					error_log('importexport_schedule: '.date('c').": File $target not readable! \n");
529
+					$data['errors'][$target][] = lang('%1 is not readable', $target);
530 530
 				}
531 531
 			}
532 532
 			catch (Exception $i_ex)
@@ -536,20 +536,20 @@  discard block
 block discarded – undo
536 536
 			}
537 537
 
538 538
 
539
-			if(method_exists($po, 'get_warnings') && $po->get_warnings())
539
+			if (method_exists($po, 'get_warnings') && $po->get_warnings())
540 540
 			{
541
-				$buffer = 'importexport_schedule: ' . date('c') . ": Import warnings:\n#\tWarning\n";
542
-				foreach($po->get_warnings() as $record => $msg)
541
+				$buffer = 'importexport_schedule: '.date('c').": Import warnings:\n#\tWarning\n";
542
+				foreach ($po->get_warnings() as $record => $msg)
543 543
 				{
544 544
 					$data['warnings'][$target][] = "#$record: $msg";
545 545
 					$buffer += "$record\t$msg\n";
546 546
 				}
547 547
 				error_log($buffer);
548 548
 			}
549
-			if(method_exists($po, 'get_errors') && $po->get_errors())
549
+			if (method_exists($po, 'get_errors') && $po->get_errors())
550 550
 			{
551
-				$buffer = 'importexport_schedule: ' . date('c') . ": Import errors:\n#\tError\n";
552
-				foreach($po->get_errors() as $record => $error)
551
+				$buffer = 'importexport_schedule: '.date('c').": Import errors:\n#\tError\n";
552
+				foreach ($po->get_errors() as $record => $error)
553 553
 				{
554 554
 					$data['errors'][$target][] = "#$record: $error";
555 555
 					$buffer += "$record\t$error\n";
@@ -557,22 +557,22 @@  discard block
 block discarded – undo
557 557
 				error_log($buffer);
558 558
 			}
559 559
 
560
-			if($po instanceof importexport_iface_import_plugin)
560
+			if ($po instanceof importexport_iface_import_plugin)
561 561
 			{
562
-				if(is_numeric($result))
562
+				if (is_numeric($result))
563 563
 				{
564 564
 					$data['record_count'] += $result;
565 565
 					$data['result'][$target][] = lang('%1 records processed', $result);
566 566
 				}
567 567
 				$data['result'][$target] = array();
568
-				foreach($po->get_results() as $action => $count)
568
+				foreach ($po->get_results() as $action => $count)
569 569
 				{
570
-					$data['result'][$target][] = lang($action) . ": $count";
570
+					$data['result'][$target][] = lang($action).": $count";
571 571
 				}
572 572
 			}
573 573
 			else
574 574
 			{
575
-				if($result instanceof importexport_iface_export_record)
575
+				if ($result instanceof importexport_iface_export_record)
576 576
 				{
577 577
 					$data['record_count'] += $result->get_num_of_records();
578 578
 					$data['result'][$target][] = lang('%1 records processed', $result->get_num_of_records());
@@ -581,23 +581,23 @@  discard block
 block discarded – undo
581 581
 		}
582 582
 
583 583
 		// Delete file?
584
-		if($data['delete_files'] && $type == 'import' && !$data['errors'])
584
+		if ($data['delete_files'] && $type == 'import' && !$data['errors'])
585 585
 		{
586
-			foreach($targets as $target)
586
+			foreach ($targets as $target)
587 587
 			{
588
-				if(unlink($target))
588
+				if (unlink($target))
589 589
 				{
590
-					$data['result'][$target][] .= "\n..." . lang('deleted');
590
+					$data['result'][$target][] .= "\n...".lang('deleted');
591 591
 				}
592 592
 				else
593 593
 				{
594
-					$data['errors'][$target][] .= "\n..." . lang('Unable to delete');
594
+					$data['errors'][$target][] .= "\n...".lang('Unable to delete');
595 595
 				}
596 596
 			}
597 597
 		}
598 598
 
599 599
 		// Run time in minutes
600
-		$data['run_time'] = round((time() - $data['last_run']) / 60,1);
600
+		$data['run_time'] = round((time() - $data['last_run']) / 60, 1);
601 601
 
602 602
 		// Clear lock
603 603
 		$data['lock'] = 0;
@@ -608,9 +608,9 @@  discard block
 block discarded – undo
608 608
 		$contents = ob_get_contents();
609 609
 
610 610
 		// Log to error log
611
-		if($contents)
611
+		if ($contents)
612 612
 		{
613
-			error_log('importexport_schedule: ' . date('c') . ": \n".$contents);
613
+			error_log('importexport_schedule: '.date('c').": \n".$contents);
614 614
 		}
615 615
 
616 616
 		ob_end_clean();
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 		$jobs = $async->read($id);
628 628
 		$job = $jobs[$id];
629 629
 
630
-		if(is_array($job))
630
+		if (is_array($job))
631 631
 		{
632 632
 			$async->cancel_timer($id);
633 633
 			$result = $async->set_timer(
@@ -637,37 +637,37 @@  discard block
 block discarded – undo
637 637
 				$data
638 638
 			);
639 639
 		}
640
-		if($no_notification)
640
+		if ($no_notification)
641 641
 		{
642 642
 			return $result;
643 643
 		}
644 644
 
645 645
 		// Send notification to user
646
-		if($data['warnings'] || $data['errors'])
646
+		if ($data['warnings'] || $data['errors'])
647 647
 		{
648 648
 			$notify = new notifications();
649 649
 			$notify->set_sender($data['account_id']);
650 650
 			$notify->add_receiver($data['account_id']);
651
-			$notify->set_subject(lang('Schedule import | export'). ' ' . lang('errors'));
651
+			$notify->set_subject(lang('Schedule import | export').' '.lang('errors'));
652 652
 			$contents = '';
653 653
 
654
-			if($data['warnings'])
654
+			if ($data['warnings'])
655 655
 			{
656
-				$contents .= lang($data['type']) . ' ' . lang('Warnings') . ' ' . Api\DateTime::to() . ':';
657
-				foreach($data['warnings'] as $target => $message)
656
+				$contents .= lang($data['type']).' '.lang('Warnings').' '.Api\DateTime::to().':';
657
+				foreach ($data['warnings'] as $target => $message)
658 658
 				{
659
-					$contents .= "\n". (is_numeric($target) ? '' : $target."\n");
660
-					$contents .= is_array($message) ? implode("\n",$message) : $message;
659
+					$contents .= "\n".(is_numeric($target) ? '' : $target."\n");
660
+					$contents .= is_array($message) ? implode("\n", $message) : $message;
661 661
 				}
662 662
 				$contents .= "\n";
663 663
 			}
664
-			if($data['errors'])
664
+			if ($data['errors'])
665 665
 			{
666
-				$contents .= lang($data['type']) . ' ' . lang('Errors') . ' ' . Api\DateTime::to() . ':';
667
-				foreach($data['errors'] as $target => $errors)
666
+				$contents .= lang($data['type']).' '.lang('Errors').' '.Api\DateTime::to().':';
667
+				foreach ($data['errors'] as $target => $errors)
668 668
 				{
669
-					$contents .= "\n". (is_numeric($target) ? '' : $target."\n");
670
-					$contents .= is_array($errors) ? implode("\n",$errors) : $errors;
669
+					$contents .= "\n".(is_numeric($target) ? '' : $target."\n");
670
+					$contents .= is_array($errors) ? implode("\n", $errors) : $errors;
671 671
 				}
672 672
 				$contents .= "\n";
673 673
 			}
Please login to merge, or discard this patch.
importexport/inc/class.importexport_definitions_bo.inc.php 4 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -137,10 +137,10 @@
 block discarded – undo
137 137
 	}
138 138
 
139 139
 	/**
140
-	* Save a definition
141
-	*
142
-	* @param definition $definition
143
-	*/
140
+	 * Save a definition
141
+	 *
142
+	 * @param definition $definition
143
+	 */
144 144
 	public function save(Array $data) {
145 145
 		$definition = new importexport_definition();
146 146
 		$definition->set_record($data);
Please login to merge, or discard this patch.
Braces   +77 added lines, -29 removed lines patch added patch discarded remove patch
@@ -16,7 +16,8 @@  discard block
 block discarded – undo
16 16
  *
17 17
  * @todo make this class an egw_record_pool!
18 18
  */
19
-class importexport_definitions_bo {
19
+class importexport_definitions_bo
20
+{
20 21
 
21 22
 	const _appname = 'importexport';
22 23
 	const _defintion_table = 'egw_importexport_definitions';
@@ -34,10 +35,15 @@  discard block
 block discarded – undo
34 35
 	public function __construct($_query=false, $ignore_acl = false)
35 36
 	{
36 37
 		$this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_table );
37
-		if ($_query) {
38
+		if ($_query)
39
+		{
38 40
 			$definitions = $this->so_sql->search($_query, false);
39
-			foreach ((array)$definitions as $definition) {
40
-				if(self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id'];
41
+			foreach ((array)$definitions as $definition)
42
+			{
43
+				if(self::is_permitted($definition) || $ignore_acl)
44
+				{
45
+					$this->definitions[] = $definition['definition_id'];
46
+				}
41 47
 			}
42 48
 		}
43 49
 	}
@@ -45,7 +51,8 @@  discard block
 block discarded – undo
45 51
 	public function get_rows(&$query, &$rows, &$readonlys)
46 52
 	{
47 53
 		// Filter only definitions user is allowed to use
48
-		if(!$GLOBALS['egw_info']['user']['apps']['admin']) {
54
+		if(!$GLOBALS['egw_info']['user']['apps']['admin'])
55
+		{
49 56
 			$this_membership = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
50 57
 			$this_membership[] = $GLOBALS['egw_info']['user']['account_id'];
51 58
 			$sql .= ' (';
@@ -80,7 +87,8 @@  discard block
 block discarded – undo
80 87
 		
81 88
 		$total = $this->so_sql->get_rows($query, $rows, $readonlys);
82 89
 		$ro_count = 0;
83
-		foreach($rows as &$row) {
90
+		foreach($rows as &$row)
91
+		{
84 92
 			// Strip off leading + trailing ,
85 93
 			$row['allowed_users'] = substr($row['allowed_users'],1,-1);
86 94
 
@@ -103,14 +111,19 @@  discard block
 block discarded – undo
103 111
 	 *
104 112
 	 * @return array
105 113
 	 */
106
-	public function get_definitions() {
114
+	public function get_definitions()
115
+	{
107 116
 		return $this->definitions;
108 117
 	}
109
-	public function read($definition_id) {
110
-		if(is_numeric($definition_id)) {
118
+	public function read($definition_id)
119
+	{
120
+		if(is_numeric($definition_id))
121
+		{
111 122
 			$this->so_sql->read($definition_id);
112 123
 			$definition = new importexport_definition($this->so_sql->data['name']);
113
-		} else {
124
+		}
125
+		else
126
+		{
114 127
 			$definition = new importexport_definition( $definition_id['name'] );
115 128
 		}
116 129
 		return $definition->get_record_array();
@@ -120,18 +133,24 @@  discard block
 block discarded – undo
120 133
 	 *
121 134
 	 * @param array $keys
122 135
 	 */
123
-	public function delete($keys) {
124
-		foreach ($keys as $index => $key) {
136
+	public function delete($keys)
137
+	{
138
+		foreach ($keys as $index => $key)
139
+		{
125 140
 			// Check for ownership
126 141
 			$definition = $this->read($key);
127
-			if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) {
142
+			if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin'])
143
+			{
128 144
 				// clear private cache
129 145
 				unset($this->definitions[array_search($key,$this->definitions)]);
130
-			} else {
146
+			}
147
+			else
148
+			{
131 149
 				unset($keys[$index]);
132 150
 			}
133 151
 		}
134
-		if(count($keys) > 0) {
152
+		if(count($keys) > 0)
153
+		{
135 154
 			$this->so_sql->delete(array('definition_id' => $keys));
136 155
 		}
137 156
 	}
@@ -141,7 +160,8 @@  discard block
 block discarded – undo
141 160
 	*
142 161
 	* @param definition $definition
143 162
 	*/
144
-	public function save(Array $data) {
163
+	public function save(Array $data)
164
+	{
145 165
 		$definition = new importexport_definition();
146 166
 		$definition->set_record($data);
147 167
 		$definition->save($data['definition_id']);
@@ -153,7 +173,8 @@  discard block
 block discarded – undo
153 173
 	 * @param array $_definition
154 174
 	 * @return bool
155 175
 	 */
156
-	static public function is_permitted($_definition) {
176
+	static public function is_permitted($_definition)
177
+	{
157 178
 		$allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',',$_definition['allowed_users']);
158 179
 		$this_user_id = $GLOBALS['egw_info']['user']['account_id'];
159 180
 		$this_membership = $GLOBALS['egw']->accounts->memberships($this_user_id, true);
@@ -177,25 +198,30 @@  discard block
 block discarded – undo
177 198
 		));
178 199
 
179 200
 		$export_data['definitions'] = array();
180
-		foreach ($keys as $definition_id) {
201
+		foreach ($keys as $definition_id)
202
+		{
181 203
 			$definition = new importexport_definition( $definition_id );
182 204
 			$export_data['definitions'][$definition->name] = $definition->get_record_array();
183 205
 			$export_data['definitions'][$definition->name]['allowed_users'] =
184 206
 				importexport_helper_functions::account_id2name(
185 207
 					$export_data['definitions'][$definition->name]['allowed_users']
186 208
 				);
187
-			if($export_date['definitions'][$definition->name]['owner']) {
209
+			if($export_date['definitions'][$definition->name]['owner'])
210
+			{
188 211
 				$export_data['definitions'][$definition->name]['owner'] =
189 212
 					importexport_helper_functions::account_id2name(
190 213
 						$export_data['definitions'][$definition->name]['owner']
191 214
 					);
192
-			} else {
215
+			}
216
+			else
217
+			{
193 218
 				unset($export_data['definitions'][$definition->name]['owner']);
194 219
 			}
195 220
 			unset($export_data['definitions'][$definition->name]['definition_id']);
196 221
 			unset($export_data['definitions'][$definition->name]['description']);
197 222
 			unset($export_data['definitions'][$definition->name]['user_timezone_read']);
198
-			if(is_array($export_data['definitions'][$definition->name]['plugin_options'])) {
223
+			if(is_array($export_data['definitions'][$definition->name]['plugin_options']))
224
+			{
199 225
 				unset($export_data['definitions'][$definition->name]['plugin_options']['user_timezone_read']);
200 226
 			}
201 227
 			unset($definition);
@@ -215,7 +241,8 @@  discard block
 block discarded – undo
215 241
 	 */
216 242
 	public static function import( $_import_file )
217 243
 	{
218
-		if ( !is_file( $_import_file ) ) {
244
+		if ( !is_file( $_import_file ) )
245
+		{
219 246
 			throw new Exception("'$_import_file' does not exist or is not readable" );
220 247
 		}
221 248
 
@@ -233,14 +260,20 @@  discard block
 block discarded – undo
233 260
 		);
234 261
 
235 262
 		// Avoid warning if no definitions found
236
-		if(!is_array($definitions)) return lang('None found');
263
+		if(!is_array($definitions))
264
+		{
265
+			return lang('None found');
266
+		}
237 267
 
238 268
 		// save definition(s) into internal table
239 269
 		foreach ( $definitions as $name => $definition_data )
240 270
 		{
241 271
 			// convert allowed_user
242 272
 			$definition_data['allowed_users'] = importexport_helper_functions::account_name2id( $definition_data['allowed_users'] );
243
-			if($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all';
273
+			if($definition_data['all_users'] && !$definition_data['allowed_users'])
274
+			{
275
+				$definition_data['allowed_users'] = 'all';
276
+			}
244 277
 
245 278
 			$definition_data['owner'] = importexport_helper_functions::account_name2id( $definition_data['owner'] );
246 279
 
@@ -275,7 +308,10 @@  discard block
 block discarded – undo
275 308
 	public static function export_from_import(importexport_definition $import)
276 309
 	{
277 310
 		// Only operates on import definitions
278
-		if($import->type != 'import') throw new Api\Exception\WrongParameter('Only import definitions');
311
+		if($import->type != 'import')
312
+		{
313
+			throw new Api\Exception\WrongParameter('Only import definitions');
314
+		}
279 315
 
280 316
 		// Find export plugin
281 317
 		$plugin = str_replace('import', 'export',$import->plugin);
@@ -285,18 +321,30 @@  discard block
 block discarded – undo
285 321
 			$plugins = $type['export'];
286 322
 			foreach($plugins as $name => $label)
287 323
 			{
288
-				if($plugin == $name) break;
324
+				if($plugin == $name)
325
+				{
326
+					break;
327
+				}
328
+			}
329
+			if($plugin !== $name)
330
+			{
331
+				$plugin = $name;
289 332
 			}
290
-			if($plugin !== $name) $plugin = $name;
291 333
 		}
292 334
 
293 335
 		$export = new importexport_definition();
294 336
 
295 337
 		// Common settings
296 338
 		$export->name = str_replace('import', 'export',$import->name);
297
-		if($export->name == $import->name) $export->name = $export->name . '-export';
339
+		if($export->name == $import->name)
340
+		{
341
+			$export->name = $export->name . '-export';
342
+		}
298 343
 		$test = new importexport_definition($export->name);
299
-		if($test->name) $export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid'];
344
+		if($test->name)
345
+		{
346
+			$export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid'];
347
+		}
300 348
 
301 349
 		$export->application = $import->application;
302 350
 		$export->plugin = $plugin;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@
 block discarded – undo
141 141
 	*
142 142
 	* @param definition $definition
143 143
 	*/
144
-	public function save(Array $data) {
144
+	public function save(array $data) {
145 145
 		$definition = new importexport_definition();
146 146
 		$definition->set_record($data);
147 147
 		$definition->save($data['definition_id']);
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	private $definitions;
33 33
 
34
-	public function __construct($_query=false, $ignore_acl = false)
34
+	public function __construct($_query = false, $ignore_acl = false)
35 35
 	{
36
-		$this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_table );
36
+		$this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_table);
37 37
 		if ($_query) {
38 38
 			$definitions = $this->so_sql->search($_query, false);
39 39
 			foreach ((array)$definitions as $definition) {
40
-				if(self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id'];
40
+				if (self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id'];
41 41
 			}
42 42
 		}
43 43
 	}
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
 	public function get_rows(&$query, &$rows, &$readonlys)
46 46
 	{
47 47
 		// Filter only definitions user is allowed to use
48
-		if(!$GLOBALS['egw_info']['user']['apps']['admin']) {
48
+		if (!$GLOBALS['egw_info']['user']['apps']['admin']) {
49 49
 			$this_membership = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
50 50
 			$this_membership[] = $GLOBALS['egw_info']['user']['account_id'];
51 51
 			$sql .= ' (';
52 52
 			$read = array();
53
-			foreach($this_membership as $id)
53
+			foreach ($this_membership as $id)
54 54
 			{
55 55
 				$read[] = 'allowed_users '.
56 56
 					$GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.
57
-					$GLOBALS['egw']->db->quote('%,'.str_replace('_','\\_',$id) .',%');
57
+					$GLOBALS['egw']->db->quote('%,'.str_replace('_', '\\_', $id).',%');
58 58
 			}
59 59
 			$sql .= implode(' OR ', $read);
60 60
 			$sql .= ') OR owner = '.$GLOBALS['egw_info']['user']['account_id'];
@@ -62,37 +62,37 @@  discard block
 block discarded – undo
62 62
 		}
63 63
 
64 64
 		// Handle allowed filter
65
-		if($query['col_filter']['allowed_users'])
65
+		if ($query['col_filter']['allowed_users'])
66 66
 		{
67 67
 			$allowed = array();
68
-			foreach((array)$query['col_filter']['allowed_users'] as $id)
68
+			foreach ((array)$query['col_filter']['allowed_users'] as $id)
69 69
 			{
70 70
 				$allowed[] = 'allowed_users '.
71 71
 					$GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.
72
-					$GLOBALS['egw']->db->quote('%,'.str_replace('_','\\_',$id) .',%');
72
+					$GLOBALS['egw']->db->quote('%,'.str_replace('_', '\\_', $id).',%');
73 73
 			}
74
-			if($allowed)
74
+			if ($allowed)
75 75
 			{
76 76
 				unset($query['col_filter']['allowed_users']);
77
-				$query['col_filter'][] = '('.implode(' OR ', $allowed) . ')';
77
+				$query['col_filter'][] = '('.implode(' OR ', $allowed).')';
78 78
 			}
79 79
 		}
80 80
 
81 81
 		$total = $this->so_sql->get_rows($query, $rows, $readonlys);
82 82
 		$ro_count = 0;
83
-		foreach($rows as &$row) {
83
+		foreach ($rows as &$row) {
84 84
 			// Strip off leading + trailing ,
85
-			$row['allowed_users'] = substr($row['allowed_users'],1,-1);
85
+			$row['allowed_users'] = substr($row['allowed_users'], 1, -1);
86 86
 
87 87
 			$readonlys["edit[{$row['definition_id']}]"] = $readonlys["delete[{$row['definition_id']}]"] =
88 88
 				($row['owner'] != $GLOBALS['egw_info']['user']['account_id']) &&
89 89
 				!$GLOBALS['egw_info']['user']['apps']['admin'];
90
-			if($readonlys["edit[{$row['definition_id']}]"])
90
+			if ($readonlys["edit[{$row['definition_id']}]"])
91 91
 			{
92 92
 				$row['class'] .= 'rowNoEdit rowNoDelete';
93 93
 				$ro_count++;
94 94
 			}
95
-			$row['class'] .= ' ' . $row['type'];
95
+			$row['class'] .= ' '.$row['type'];
96 96
 		}
97 97
 		$readonlys['delete_selected'] = $ro_count == count($rows);
98 98
 		return $total;
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 		return $this->definitions;
108 108
 	}
109 109
 	public function read($definition_id) {
110
-		if(is_numeric($definition_id)) {
110
+		if (is_numeric($definition_id)) {
111 111
 			$this->so_sql->read($definition_id);
112 112
 			$definition = new importexport_definition($this->so_sql->data['name']);
113 113
 		} else {
114
-			$definition = new importexport_definition( $definition_id['name'] );
114
+			$definition = new importexport_definition($definition_id['name']);
115 115
 		}
116 116
 		return $definition->get_record_array();
117 117
 	}
@@ -124,14 +124,14 @@  discard block
 block discarded – undo
124 124
 		foreach ($keys as $index => $key) {
125 125
 			// Check for ownership
126 126
 			$definition = $this->read($key);
127
-			if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) {
127
+			if ($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) {
128 128
 				// clear private cache
129
-				unset($this->definitions[array_search($key,$this->definitions)]);
129
+				unset($this->definitions[array_search($key, $this->definitions)]);
130 130
 			} else {
131 131
 				unset($keys[$index]);
132 132
 			}
133 133
 		}
134
-		if(count($keys) > 0) {
134
+		if (count($keys) > 0) {
135 135
 			$this->so_sql->delete(array('definition_id' => $keys));
136 136
 		}
137 137
 	}
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
 	 * @return bool
155 155
 	 */
156 156
 	static public function is_permitted($_definition) {
157
-		$allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',',$_definition['allowed_users']);
157
+		$allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',', $_definition['allowed_users']);
158 158
 		$this_user_id = $GLOBALS['egw_info']['user']['account_id'];
159 159
 		$this_membership = $GLOBALS['egw']->accounts->memberships($this_user_id, true);
160 160
 		$this_membership[] = $this_user_id;
161 161
 		$this_membership[] = 'all';
162
-		$alluser = array_intersect($allowed_user,$this_membership);
162
+		$alluser = array_intersect($allowed_user, $this_membership);
163 163
 		return ($this_user_id == $_definition['owner'] || count($alluser) > 0);
164 164
 	}
165 165
 
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
 
179 179
 		$export_data['definitions'] = array();
180 180
 		foreach ($keys as $definition_id) {
181
-			$definition = new importexport_definition( $definition_id );
181
+			$definition = new importexport_definition($definition_id);
182 182
 			$export_data['definitions'][$definition->name] = $definition->get_record_array();
183 183
 			$export_data['definitions'][$definition->name]['allowed_users'] =
184 184
 				importexport_helper_functions::account_id2name(
185 185
 					$export_data['definitions'][$definition->name]['allowed_users']
186 186
 				);
187
-			if($export_date['definitions'][$definition->name]['owner']) {
187
+			if ($export_date['definitions'][$definition->name]['owner']) {
188 188
 				$export_data['definitions'][$definition->name]['owner'] =
189 189
 					importexport_helper_functions::account_id2name(
190 190
 						$export_data['definitions'][$definition->name]['owner']
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 			unset($export_data['definitions'][$definition->name]['definition_id']);
196 196
 			unset($export_data['definitions'][$definition->name]['description']);
197 197
 			unset($export_data['definitions'][$definition->name]['user_timezone_read']);
198
-			if(is_array($export_data['definitions'][$definition->name]['plugin_options'])) {
198
+			if (is_array($export_data['definitions'][$definition->name]['plugin_options'])) {
199 199
 				unset($export_data['definitions'][$definition->name]['plugin_options']['user_timezone_read']);
200 200
 			}
201 201
 			unset($definition);
@@ -213,17 +213,17 @@  discard block
 block discarded – undo
213 213
 	 * @throws Exeption
214 214
 	 * @return void
215 215
 	 */
216
-	public static function import( $_import_file )
216
+	public static function import($_import_file)
217 217
 	{
218
-		if ( !is_file( $_import_file ) ) {
219
-			throw new Exception("'$_import_file' does not exist or is not readable" );
218
+		if (!is_file($_import_file)) {
219
+			throw new Exception("'$_import_file' does not exist or is not readable");
220 220
 		}
221 221
 
222
-		$data = importexport_arrayxml::xml2array( file_get_contents( $_import_file ) );
222
+		$data = importexport_arrayxml::xml2array(file_get_contents($_import_file));
223 223
 
224 224
 		$metainfo = $data['importExportDefinitions']['metainfo'];
225 225
 		$definitions = $data['importExportDefinitions']['definitions'];
226
-		unset ( $data );
226
+		unset ($data);
227 227
 
228 228
 		// convert charset into internal used charset
229 229
 		$definitions = Api\Translation::convert(
@@ -233,26 +233,26 @@  discard block
 block discarded – undo
233 233
 		);
234 234
 
235 235
 		// Avoid warning if no definitions found
236
-		if(!is_array($definitions)) return lang('None found');
236
+		if (!is_array($definitions)) return lang('None found');
237 237
 
238 238
 		// save definition(s) into internal table
239
-		foreach ( $definitions as $name => $definition_data )
239
+		foreach ($definitions as $name => $definition_data)
240 240
 		{
241 241
 			// convert allowed_user
242
-			$definition_data['allowed_users'] = importexport_helper_functions::account_name2id( $definition_data['allowed_users'] );
243
-			if($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all';
242
+			$definition_data['allowed_users'] = importexport_helper_functions::account_name2id($definition_data['allowed_users']);
243
+			if ($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all';
244 244
 
245
-			$definition_data['owner'] = importexport_helper_functions::account_name2id( $definition_data['owner'] );
245
+			$definition_data['owner'] = importexport_helper_functions::account_name2id($definition_data['owner']);
246 246
 
247
-			$definition = new importexport_definition( $definition_data['name'] );
247
+			$definition = new importexport_definition($definition_data['name']);
248 248
 
249 249
 			// Only update if the imported is newer
250
-			if(strtotime($definition->modified) < strtotime($definition_data['modified']) || $definition->modified == 0)
250
+			if (strtotime($definition->modified) < strtotime($definition_data['modified']) || $definition->modified == 0)
251 251
 			{
252 252
 				$definition_id = $definition->get_identifier() ? $definition->get_identifier() : NULL;
253 253
 
254
-				$definition->set_record( $definition_data );
255
-				$definition->save( $definition_id );
254
+				$definition->set_record($definition_data);
255
+				$definition->save($definition_id);
256 256
 			}
257 257
 		}
258 258
 		return $definitions;
@@ -275,28 +275,28 @@  discard block
 block discarded – undo
275 275
 	public static function export_from_import(importexport_definition $import)
276 276
 	{
277 277
 		// Only operates on import definitions
278
-		if($import->type != 'import') throw new Api\Exception\WrongParameter('Only import definitions');
278
+		if ($import->type != 'import') throw new Api\Exception\WrongParameter('Only import definitions');
279 279
 
280 280
 		// Find export plugin
281
-		$plugin = str_replace('import', 'export',$import->plugin);
281
+		$plugin = str_replace('import', 'export', $import->plugin);
282 282
 		$plugin_list = importexport_helper_functions::get_plugins($import->application, 'export');
283
-		foreach($plugin_list as $appname => $type)
283
+		foreach ($plugin_list as $appname => $type)
284 284
 		{
285 285
 			$plugins = $type['export'];
286
-			foreach($plugins as $name => $label)
286
+			foreach ($plugins as $name => $label)
287 287
 			{
288
-				if($plugin == $name) break;
288
+				if ($plugin == $name) break;
289 289
 			}
290
-			if($plugin !== $name) $plugin = $name;
290
+			if ($plugin !== $name) $plugin = $name;
291 291
 		}
292 292
 
293 293
 		$export = new importexport_definition();
294 294
 
295 295
 		// Common settings
296
-		$export->name = str_replace('import', 'export',$import->name);
297
-		if($export->name == $import->name) $export->name = $export->name . '-export';
296
+		$export->name = str_replace('import', 'export', $import->name);
297
+		if ($export->name == $import->name) $export->name = $export->name.'-export';
298 298
 		$test = new importexport_definition($export->name);
299
-		if($test->name) $export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid'];
299
+		if ($test->name) $export->name = $export->name.'-'.$GLOBALS['egw_info']['user']['account_lid'];
300 300
 
301 301
 		$export->application = $import->application;
302 302
 		$export->plugin = $plugin;
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 		);
313 313
 
314 314
 		// Mapping
315
-		foreach($i_options['field_mapping'] as $col_num => $field)
315
+		foreach ($i_options['field_mapping'] as $col_num => $field)
316 316
 		{
317 317
 			// Try to use heading from import file, if possible
318 318
 			$e_options['mapping'][$field] = $i_options['csv_fields'][$col_num] ? $i_options['csv_fields'][$col_num] : $field;
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	 */
340 340
 	function change_delete_owner(array $args)  // new_owner=0 means delete
341 341
 	{
342
-		if (!(int) $args['new_owner'])
342
+		if (!(int)$args['new_owner'])
343 343
 		{
344 344
 			$this->so_sql->delete(array('owner'=>$args['account_id']));
345 345
 		}
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 				self::_defintion_table,
350 350
 				array('owner'=>$args['new_owner']),
351 351
 				array('owner'=>$args['account_id']),
352
-				__LINE__,__FILE__,'importexport'
352
+				__LINE__, __FILE__, 'importexport'
353 353
 			);
354 354
 		}
355 355
 	}
Please login to merge, or discard this patch.
importexport/inc/class.importexport_wizard_basic_export_csv.inc.php 3 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 	const TEMPLATE_MARKER = '-eTemplate-';
24 24
 
25 25
 	/**
26
-	* List of steps.  Key is the function, value is the translated title.
27
-	*/
26
+	 * List of steps.  Key is the function, value is the translated title.
27
+	 */
28 28
 	public $steps;
29 29
 
30 30
 	/**
31
-	* List of eTemplates to use for each step.  You can override this with your own etemplates steps.
32
-	*/
31
+	 * List of eTemplates to use for each step.  You can override this with your own etemplates steps.
32
+	 */
33 33
 	protected $step_templates = array(
34 34
 		'wizard_step30' => 'importexport.wizard_basic_export_csv.choose_fields',
35 35
 		'wizard_step40' => 'importexport.wizard_basic_export_csv.choosesepncharset',
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
 		
39 39
 
40 40
 	/**
41
-	* Destination fields for the export
42
-	* Key is the field name, value is the human version
43
-	*/
41
+	 * Destination fields for the export
42
+	 * Key is the field name, value is the human version
43
+	 */
44 44
 	protected $export_fields = array();
45 45
 	
46 46
 	/**
47
-	* List of conditions your plugin supports
48
-	*/
47
+	 * List of conditions your plugin supports
48
+	 */
49 49
 	protected $conditions = array();
50 50
 
51 51
 	/**
52
-	* List of actions your plugin supports
53
-	*/
52
+	 * List of actions your plugin supports
53
+	 */
54 54
 	protected $actions = array();
55 55
 
56 56
 	/**
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	}
70 70
 
71 71
 	/**
72
-	* Choose fields to export
73
-	*/
72
+	 * Choose fields to export
73
+	 */
74 74
 	function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv)
75 75
 	{
76 76
 		if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true));
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
 			);
207 207
 			$sel_options['charset'] = Api\Translation::get_installed_charsets()+
208 208
 			array(
209
-                                'user'  => lang('User preference'),
210
-                        );
209
+								'user'  => lang('User preference'),
210
+						);
211 211
 
212
-                        // Add in extra allowed charsets
213
-                        $config = Api\Config::read('importexport');
214
-                        $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings());
215
-                        if($extra_charsets)
216
-                        {
217
-                                $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets));
218
-                        }
212
+						// Add in extra allowed charsets
213
+						$config = Api\Config::read('importexport');
214
+						$extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings());
215
+						if($extra_charsets)
216
+						{
217
+								$sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets));
218
+						}
219 219
 			$sel_options['convert'] = array(
220 220
 				0	=> lang('Database values'),
221 221
 				1	=> lang('Human friendly values')
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 			'wizard_step80' => lang('Filters'),
65 65
 		);
66 66
 		list($appname, $part2) = explode('_', get_class($this));
67
-		if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= '_'.$part2; // Handle apps with _ in the name
67
+		if (!$GLOBALS['egw_info']['apps'][$appname]) $appname .= '_'.$part2; // Handle apps with _ in the name
68 68
 		Api\Translation::add_app($appname);
69 69
 	}
70 70
 
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
 	*/
74 74
 	function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv)
75 75
 	{
76
-		if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true));
76
+		if ($this->debug) error_log(get_class($this).'::wizard_step30->$content '.print_r($content, true));
77 77
 		// return from step30
78 78
 		if ($content['step'] == 'wizard_step30')
79 79
 		{
80
-			foreach($content['fields']['export'] as $field_name)
80
+			foreach ($content['fields']['export'] as $field_name)
81 81
 			{
82 82
 				// Preserve original field names, where available
83
-				if($content['plugin_options']['no_header_translation'] && $content['plugin_options']['mapping'][$field_name])
83
+				if ($content['plugin_options']['no_header_translation'] && $content['plugin_options']['mapping'][$field_name])
84 84
 				{
85 85
 					$content['mapping'][$field_name] = $content['plugin_options']['mapping'][$field_name];
86 86
 				}
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
 					$content['mapping'][$field_name] = $field_name;
90 90
 				}
91 91
 			}
92
-			if($content['mapping']['all_custom_fields']) {
92
+			if ($content['mapping']['all_custom_fields']) {
93 93
 				// Need the appname during actual export, to fetch the fields
94 94
 				$parts = explode('_', get_class($this));
95 95
 				$appname = $parts[0];
96
-				foreach($parts as $name_part) {
97
-					if($GLOBALS['egw_info']['apps'][$appname]) break;
96
+				foreach ($parts as $name_part) {
97
+					if ($GLOBALS['egw_info']['apps'][$appname]) break;
98 98
 					$appname .= '_'.$name_part; // Handle apps with _ in the name
99 99
 				}
100 100
 				$content['mapping']['all_custom_fields'] = $appname;
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
 			switch (array_search('pressed', $content['button']))
106 106
 			{
107 107
 				case 'next':
108
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
108
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
109 109
 				case 'previous' :
110
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
110
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
111 111
 				case 'finish':
112 112
 					return 'wizard_finish';
113 113
 				default :
114
-					return $this->wizard_step30($content,$sel_options,$readonlys,$preserv);
114
+					return $this->wizard_step30($content, $sel_options, $readonlys, $preserv);
115 115
 			}
116 116
 		}
117 117
 		// init step30
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
 			unset ($preserv['button']);
126 126
 			unset ($preserv['fields']);
127 127
 			$content['fields'] = array('');
128
-			if(!$content['mapping']) $content['mapping'] = $content['plugin_options']['mapping'];
128
+			if (!$content['mapping']) $content['mapping'] = $content['plugin_options']['mapping'];
129 129
 		
130 130
 			$row = 1;
131
-			foreach($this->export_fields as $field => $name) {
131
+			foreach ($this->export_fields as $field => $name) {
132 132
 				$content['fields'][] = array(
133 133
 					'field'	=>	$field,
134 134
 					'name'	=>	lang($name),
135 135
 				);
136
-				if($content['mapping'][$field]) {
136
+				if ($content['mapping'][$field]) {
137 137
 					$content['fields']['export'][$row] = $field;
138 138
 				}
139 139
 				$row++;
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv)
157 157
 	{
158
-		if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true));
158
+		if ($this->debug) error_log(get_class($this).'::wizard_step40->$content '.print_r($content, true));
159 159
 		// return from step40
160 160
 		if ($content['step'] == 'wizard_step40') {
161
-			if($content['begin_with_fieldnames'] == 'label') {
162
-				foreach($content['mapping'] as $field => &$label) {
161
+			if ($content['begin_with_fieldnames'] == 'label') {
162
+				foreach ($content['mapping'] as $field => &$label) {
163 163
 					// Check first, to avoid clearing any pseudo-columns (ex: All custom fields)
164 164
 					$label = $this->export_fields[$field] ? $this->export_fields[$field] : $label;
165 165
 				}
@@ -167,13 +167,13 @@  discard block
 block discarded – undo
167 167
 			switch (array_search('pressed', $content['button']))
168 168
 			{
169 169
 				case 'next':
170
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
170
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
171 171
 				case 'previous' :
172
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
172
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
173 173
 				case 'finish':
174 174
 					return 'wizard_finish';
175 175
 				default :
176
-					return $this->wizard_step40($content,$sel_options,$readonlys,$preserv);
176
+					return $this->wizard_step40($content, $sel_options, $readonlys, $preserv);
177 177
 			}
178 178
 		}
179 179
 		// init step40
@@ -183,18 +183,18 @@  discard block
 block discarded – undo
183 183
 			$content['step'] = 'wizard_step40';
184 184
 
185 185
 			// If editing an existing definition, these will be in plugin_options
186
-			if(!$content['delimiter'] && $content['plugin_options']['delimiter']) {
186
+			if (!$content['delimiter'] && $content['plugin_options']['delimiter']) {
187 187
 				$content['delimiter'] = $content['plugin_options']['delimiter'];
188 188
 			} elseif (!$content['delimiter']) {
189 189
 				$content['delimiter'] = ';';
190 190
 			}
191
-			if(!$content['charset'] && $content['plugin_options']['charset']) {
191
+			if (!$content['charset'] && $content['plugin_options']['charset']) {
192 192
 				$content['charset'] = $content['plugin_options']['charset'] ? $content['plugin_options']['charset'] : 'user';
193 193
 			}
194
-			if(!array_key_exists('begin_with_fieldnames', $content) && array_key_exists('begin_with_fieldnames', $content['plugin_options'])) {
194
+			if (!array_key_exists('begin_with_fieldnames', $content) && array_key_exists('begin_with_fieldnames', $content['plugin_options'])) {
195 195
 				$content['begin_with_fieldnames'] = $content['plugin_options']['begin_with_fieldnames'];
196 196
 			}
197
-			if(!array_key_exists('convert', $content) && array_key_exists('convert', $content['plugin_options'])) {
197
+			if (!array_key_exists('convert', $content) && array_key_exists('convert', $content['plugin_options'])) {
198 198
 				$content['convert'] = $content['plugin_options']['convert'];
199 199
 			}
200 200
 
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
 				1	=> lang('Field names'),
205 205
 				'label'	=> lang('Field labels')
206 206
 			);
207
-			$sel_options['charset'] = Api\Translation::get_installed_charsets()+
207
+			$sel_options['charset'] = Api\Translation::get_installed_charsets() +
208 208
 			array(
209 209
                                 'user'  => lang('User preference'),
210 210
                         );
211 211
 
212 212
                         // Add in extra allowed charsets
213 213
                         $config = Api\Config::read('importexport');
214
-                        $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings());
215
-                        if($extra_charsets)
214
+                        $extra_charsets = array_intersect(explode(',', $config['import_charsets']), mb_list_encodings());
215
+                        if ($extra_charsets)
216 216
                         {
217
-                                $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets));
217
+                                $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets, $extra_charsets));
218 218
                         }
219 219
 			$sel_options['convert'] = array(
220 220
 				0	=> lang('Database values'),
@@ -238,15 +238,15 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	function wizard_step80(&$content, &$sel_options, &$readonlys, &$preserv)
240 240
 	{
241
-		if($this->debug) error_log(get_class($this) . '::' . __METHOD__ .'->$content '.print_r($content,true));
241
+		if ($this->debug) error_log(get_class($this).'::'.__METHOD__.'->$content '.print_r($content, true));
242 242
 		// return from submit
243 243
 		if ($content['step'] == 'wizard_step80') {
244 244
 			// Process submitted
245 245
 			unset($content['filter']);
246 246
 			unset($content['set_filter']['fields']);
247
-			foreach($content['set_filter'] as $key => $value)
247
+			foreach ($content['set_filter'] as $key => $value)
248 248
 			{
249
-				if($value) {
249
+				if ($value) {
250 250
 					$content['filter'][$key] = $value;
251 251
 				}
252 252
 			}
@@ -256,13 +256,13 @@  discard block
 block discarded – undo
256 256
 			switch (array_search('pressed', $content['button']))
257 257
 			{
258 258
 				case 'next':
259
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
259
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
260 260
 				case 'previous' :
261
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
261
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
262 262
 				case 'finish':
263 263
 					return 'wizard_finish';
264 264
 				default :
265
-					return $this->wizard_step80($content,$sel_options,$readonlys,$preserv);
265
+					return $this->wizard_step80($content, $sel_options, $readonlys, $preserv);
266 266
 			}
267 267
 		} else {
268 268
 
@@ -273,15 +273,15 @@  discard block
 block discarded – undo
273 273
 			unset ($preserv['button']);
274 274
 
275 275
 			$content['set_filter']['fields'] = importexport_helper_functions::get_filter_fields(
276
-				$content['application'],$content['plugin'],$this
276
+				$content['application'], $content['plugin'], $this
277 277
 			);
278 278
 			// Load existing filter from either content or definition
279
-			foreach($content['set_filter']['fields'] as $field => $settings)
279
+			foreach ($content['set_filter']['fields'] as $field => $settings)
280 280
 			{
281 281
 				$content['set_filter'][$field] = $content['filter'][$field];
282 282
 			}
283 283
 
284
-			if(!$content['set_filter']['fields'])
284
+			if (!$content['set_filter']['fields'])
285 285
 			{
286 286
 				// No fields
287 287
 				return importexport_definitions_ui::SKIP;
Please login to merge, or discard this patch.
Braces   +57 added lines, -21 removed lines patch added patch discarded remove patch
@@ -64,7 +64,11 @@  discard block
 block discarded – undo
64 64
 			'wizard_step80' => lang('Filters'),
65 65
 		);
66 66
 		list($appname, $part2) = explode('_', get_class($this));
67
-		if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= '_'.$part2; // Handle apps with _ in the name
67
+		if(!$GLOBALS['egw_info']['apps'][$appname])
68
+		{
69
+			$appname .= '_'.$part2;
70
+		}
71
+		// Handle apps with _ in the name
68 72
 		Api\Translation::add_app($appname);
69 73
 	}
70 74
 
@@ -73,7 +77,10 @@  discard block
 block discarded – undo
73 77
 	*/
74 78
 	function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv)
75 79
 	{
76
-		if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true));
80
+		if($this->debug)
81
+		{
82
+			error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true));
83
+		}
77 84
 		// return from step30
78 85
 		if ($content['step'] == 'wizard_step30')
79 86
 		{
@@ -89,12 +96,17 @@  discard block
 block discarded – undo
89 96
 					$content['mapping'][$field_name] = $field_name;
90 97
 				}
91 98
 			}
92
-			if($content['mapping']['all_custom_fields']) {
99
+			if($content['mapping']['all_custom_fields'])
100
+			{
93 101
 				// Need the appname during actual export, to fetch the fields
94 102
 				$parts = explode('_', get_class($this));
95 103
 				$appname = $parts[0];
96
-				foreach($parts as $name_part) {
97
-					if($GLOBALS['egw_info']['apps'][$appname]) break;
104
+				foreach($parts as $name_part)
105
+				{
106
+					if($GLOBALS['egw_info']['apps'][$appname])
107
+					{
108
+						break;
109
+					}
98 110
 					$appname .= '_'.$name_part; // Handle apps with _ in the name
99 111
 				}
100 112
 				$content['mapping']['all_custom_fields'] = $appname;
@@ -125,15 +137,20 @@  discard block
 block discarded – undo
125 137
 			unset ($preserv['button']);
126 138
 			unset ($preserv['fields']);
127 139
 			$content['fields'] = array('');
128
-			if(!$content['mapping']) $content['mapping'] = $content['plugin_options']['mapping'];
140
+			if(!$content['mapping'])
141
+			{
142
+				$content['mapping'] = $content['plugin_options']['mapping'];
143
+			}
129 144
 		
130 145
 			$row = 1;
131
-			foreach($this->export_fields as $field => $name) {
146
+			foreach($this->export_fields as $field => $name)
147
+			{
132 148
 				$content['fields'][] = array(
133 149
 					'field'	=>	$field,
134 150
 					'name'	=>	lang($name),
135 151
 				);
136
-				if($content['mapping'][$field]) {
152
+				if($content['mapping'][$field])
153
+				{
137 154
 					$content['fields']['export'][$row] = $field;
138 155
 				}
139 156
 				$row++;
@@ -155,11 +172,17 @@  discard block
 block discarded – undo
155 172
 	 */
156 173
 	function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv)
157 174
 	{
158
-		if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true));
175
+		if($this->debug)
176
+		{
177
+			error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true));
178
+		}
159 179
 		// return from step40
160
-		if ($content['step'] == 'wizard_step40') {
161
-			if($content['begin_with_fieldnames'] == 'label') {
162
-				foreach($content['mapping'] as $field => &$label) {
180
+		if ($content['step'] == 'wizard_step40')
181
+		{
182
+			if($content['begin_with_fieldnames'] == 'label')
183
+			{
184
+				foreach($content['mapping'] as $field => &$label)
185
+				{
163 186
 					// Check first, to avoid clearing any pseudo-columns (ex: All custom fields)
164 187
 					$label = $this->export_fields[$field] ? $this->export_fields[$field] : $label;
165 188
 				}
@@ -183,18 +206,24 @@  discard block
 block discarded – undo
183 206
 			$content['step'] = 'wizard_step40';
184 207
 
185 208
 			// If editing an existing definition, these will be in plugin_options
186
-			if(!$content['delimiter'] && $content['plugin_options']['delimiter']) {
209
+			if(!$content['delimiter'] && $content['plugin_options']['delimiter'])
210
+			{
187 211
 				$content['delimiter'] = $content['plugin_options']['delimiter'];
188
-			} elseif (!$content['delimiter']) {
212
+			}
213
+			elseif (!$content['delimiter'])
214
+			{
189 215
 				$content['delimiter'] = ';';
190 216
 			}
191
-			if(!$content['charset'] && $content['plugin_options']['charset']) {
217
+			if(!$content['charset'] && $content['plugin_options']['charset'])
218
+			{
192 219
 				$content['charset'] = $content['plugin_options']['charset'] ? $content['plugin_options']['charset'] : 'user';
193 220
 			}
194
-			if(!array_key_exists('begin_with_fieldnames', $content) && array_key_exists('begin_with_fieldnames', $content['plugin_options'])) {
221
+			if(!array_key_exists('begin_with_fieldnames', $content) && array_key_exists('begin_with_fieldnames', $content['plugin_options']))
222
+			{
195 223
 				$content['begin_with_fieldnames'] = $content['plugin_options']['begin_with_fieldnames'];
196 224
 			}
197
-			if(!array_key_exists('convert', $content) && array_key_exists('convert', $content['plugin_options'])) {
225
+			if(!array_key_exists('convert', $content) && array_key_exists('convert', $content['plugin_options']))
226
+			{
198 227
 				$content['convert'] = $content['plugin_options']['convert'];
199 228
 			}
200 229
 
@@ -238,15 +267,20 @@  discard block
 block discarded – undo
238 267
 	 */
239 268
 	function wizard_step80(&$content, &$sel_options, &$readonlys, &$preserv)
240 269
 	{
241
-		if($this->debug) error_log(get_class($this) . '::' . __METHOD__ .'->$content '.print_r($content,true));
270
+		if($this->debug)
271
+		{
272
+			error_log(get_class($this) . '::' . __METHOD__ .'->$content '.print_r($content,true));
273
+		}
242 274
 		// return from submit
243
-		if ($content['step'] == 'wizard_step80') {
275
+		if ($content['step'] == 'wizard_step80')
276
+		{
244 277
 			// Process submitted
245 278
 			unset($content['filter']);
246 279
 			unset($content['set_filter']['fields']);
247 280
 			foreach($content['set_filter'] as $key => $value)
248 281
 			{
249
-				if($value) {
282
+				if($value)
283
+				{
250 284
 					$content['filter'][$key] = $value;
251 285
 				}
252 286
 			}
@@ -264,7 +298,9 @@  discard block
 block discarded – undo
264 298
 				default :
265 299
 					return $this->wizard_step80($content,$sel_options,$readonlys,$preserv);
266 300
 			}
267
-		} else {
301
+		}
302
+		else
303
+		{
268 304
 
269 305
 			// Step 50 - filters
270 306
 			$content['text'] = $this->steps['wizard_step80'];
Please login to merge, or discard this patch.
importexport/inc/class.importexport_wizard_basic_import_csv.inc.php 3 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 	const TEMPLATE_MARKER = '-eTemplate-';
24 24
 
25 25
 	/**
26
-	* List of steps.  Key is the function, value is the translated title.
27
-	*/
26
+	 * List of steps.  Key is the function, value is the translated title.
27
+	 */
28 28
 	public $steps;
29 29
 
30 30
 	/**
31
-	* List of eTemplates to use for each step.  You can override this with your own etemplates steps.
32
-	*/
31
+	 * List of eTemplates to use for each step.  You can override this with your own etemplates steps.
32
+	 */
33 33
 	protected $step_templates = array(
34 34
 		'wizard_step30' => 'importexport.wizard_basic_import_csv.sample_file',
35 35
 		'wizard_step40' => 'importexport.wizard_basic_import_csv.choosesepncharset',
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
 		
40 40
 
41 41
 	/**
42
-	* Destination fields for the mapping
43
-	* Key is the field name, value is the human version
44
-	*/
42
+	 * Destination fields for the mapping
43
+	 * Key is the field name, value is the human version
44
+	 */
45 45
 	protected $mapping_fields = array();
46 46
 	
47 47
 	/**
48
-	* List of conditions your plugin supports
49
-	*/
48
+	 * List of conditions your plugin supports
49
+	 */
50 50
 	protected $conditions = array();
51 51
 
52 52
 	/**
53
-	* List of actions your plugin supports
54
-	*/
53
+	 * List of actions your plugin supports
54
+	 */
55 55
 	protected $actions = array();
56 56
 
57 57
 	/**
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	}
69 69
 
70 70
 	/**
71
-	* Take a sample CSV file.  It will be processed in later steps
72
-	*/
71
+	 * Take a sample CSV file.  It will be processed in later steps
72
+	 */
73 73
 	function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv)
74 74
 	{
75 75
 		if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true));
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
 	}
264 264
 	
265 265
 	/**
266
-	* Process the sample file, get the fields out of it, then allow them to be mapped onto
267
-	* the fields the destination understands.  Also, set any translations to be done to the field.
268
-	*
269
-	* You can use the eTemplate
270
-	*/
266
+	 * Process the sample file, get the fields out of it, then allow them to be mapped onto
267
+	 * the fields the destination understands.  Also, set any translations to be done to the field.
268
+	 *
269
+	 * You can use the eTemplate
270
+	 */
271 271
 	function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
272 272
 	{
273 273
 		if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true));
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
 	}
349 349
 	
350 350
 	/**
351
-	* Edit conditions
352
-	*/
351
+	 * Edit conditions
352
+	 */
353 353
 	function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv)
354 354
 	{
355 355
 		if($this->debug) error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true));
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	*/
76 76
 	function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv)
77 77
 	{
78
-		if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true));
78
+		if ($this->debug) error_log(get_class($this).'::wizard_step30->$content '.print_r($content, true));
79 79
 		// return from step30
80 80
 		if ($content['step'] == 'wizard_step30')
81 81
 		{
@@ -83,17 +83,17 @@  discard block
 block discarded – undo
83 83
 			{
84 84
 				case 'next':
85 85
 					// Move sample file to temp
86
-					if($content['file']['tmp_name']) {
86
+					if ($content['file']['tmp_name']) {
87 87
 						Api\Cache::setSession($content['application'], 'csvfile', $content['file']['tmp_name']);
88 88
 					}
89 89
 					unset($content['file']);
90
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
90
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
91 91
 				case 'previous' :
92
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
92
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
93 93
 				case 'finish':
94 94
 					return 'wizard_finish';
95 95
 				default :
96
-					return $this->wizard_step30($content,$sel_options,$readonlys,$preserv);
96
+					return $this->wizard_step30($content, $sel_options, $readonlys, $preserv);
97 97
 			}
98 98
 		}
99 99
 		// init step30
@@ -120,57 +120,57 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv)
122 122
 	{
123
-		if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true));
123
+		if ($this->debug) error_log(get_class($this).'::wizard_step40->$content '.print_r($content, true));
124 124
 		// return from step40
125 125
 		if ($content['step'] == 'wizard_step40') {
126 126
 			switch (array_search('pressed', $content['button']))
127 127
 			{
128 128
 				case 'next':
129 129
 					// Process sample file for fields
130
-					if (Api\Cache::getSession($content['application'],'csvfile') &&
131
-						($handle = fopen(Api\Cache::getSession($content['application'],'csvfile'), "rb")) !== FALSE
130
+					if (Api\Cache::getSession($content['application'], 'csvfile') &&
131
+						($handle = fopen(Api\Cache::getSession($content['application'], 'csvfile'), "rb")) !== FALSE
132 132
 					) {
133 133
 						$data = fgetcsv($handle, 8000, $content['fieldsep']);
134 134
 						//error_log(array2string($data));
135 135
 						fclose($handle);
136 136
 
137 137
 						// Remove & forget file
138
-						unlink(Api\Cache::getSession($content['application'],'csvfile'));
138
+						unlink(Api\Cache::getSession($content['application'], 'csvfile'));
139 139
 						Api\Cache::setSession($content['application'], 'csvfile', '');
140
-						$content['csv_fields'] = Api\Translation::convert($data,$content['charset']);
140
+						$content['csv_fields'] = Api\Translation::convert($data, $content['charset']);
141 141
 
142 142
 						// Reset field mapping for new file
143 143
 						$content['field_mapping'] = array();
144 144
 
145 145
 						// Try to match automatically
146 146
 						$english = array();
147
-						foreach($content['csv_fields'] as $index => $field) {
148
-							if($content['field_mapping'][$index]) continue;
147
+						foreach ($content['csv_fields'] as $index => $field) {
148
+							if ($content['field_mapping'][$index]) continue;
149 149
 							$best_match = '';
150 150
 							$best_match_value = 0;
151
-							foreach($this->mapping_fields as $key => $field_name) {
152
-								if(is_array($field_name)) continue;
153
-								if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0) {
151
+							foreach ($this->mapping_fields as $key => $field_name) {
152
+								if (is_array($field_name)) continue;
153
+								if (strcasecmp($field, $field_name) == 0 || strcasecmp($field, $key) == 0) {
154 154
 									$content['field_mapping'][$index] = $key;
155 155
 									continue 2;
156 156
 								}
157 157
 								// Check english also
158
-								if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) {
158
+								if ($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) {
159 159
 									$msg_id = Api\Translation::get_message_id($field_name, $content['application']);
160 160
 								}
161
-								if($msg_id) {
161
+								if ($msg_id) {
162 162
 									$english[$field_name] = Api\Translation::read('en', $content['application'], $msg_id);
163 163
 								} else {
164 164
 									$english[$field_name] = false;
165 165
 								}
166
-								if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) {
166
+								if ($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) {
167 167
 									$content['field_mapping'][$index] = $key;
168 168
 									continue 2;
169 169
 								}
170 170
 
171 171
 								// Check for similar but slightly different
172 172
 								$match = 0;
173
-								if(similar_text(strtolower($field), strtolower($field_name), $match) &&
173
+								if (similar_text(strtolower($field), strtolower($field_name), $match) &&
174 174
 										$match > 85 &&
175 175
 										$match > $best_match_value
176 176
 								) {
@@ -179,20 +179,20 @@  discard block
 block discarded – undo
179 179
 								}
180 180
 
181 181
 							}
182
-							if($best_match) {
182
+							if ($best_match) {
183 183
 								$content['field_mapping'][$index] = $best_match;
184 184
 							}
185 185
 						}
186
-					} elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields']) {
186
+					} elseif (!$content['csv_fields'] && $content['plugin_options']['csv_fields']) {
187 187
 						$content['csv_fields'] = $content['plugin_options']['csv_fields'];
188 188
 					}
189
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
189
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
190 190
 				case 'previous' :
191
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
191
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
192 192
 				case 'finish':
193 193
 					return 'wizard_finish';
194 194
 				default :
195
-					return $this->wizard_step40($content,$sel_options,$readonlys,$preserv);
195
+					return $this->wizard_step40($content, $sel_options, $readonlys, $preserv);
196 196
 			}
197 197
 		}
198 198
 		// init step40
@@ -202,17 +202,17 @@  discard block
 block discarded – undo
202 202
 			$content['step'] = 'wizard_step40';
203 203
 
204 204
 			// If editing an existing definition, these will be in plugin_options
205
-			if(!$content['fieldsep'] && $content['plugin_options']['fieldsep']) {
205
+			if (!$content['fieldsep'] && $content['plugin_options']['fieldsep']) {
206 206
 				$content['fieldsep'] = $content['plugin_options']['fieldsep'];
207 207
 			} elseif (!$content['fieldsep']) {
208 208
 				$content['fieldsep'] = ';';
209 209
 			}
210
-			if(!$content['charset'] && $content['plugin_options']['charset']) {
210
+			if (!$content['charset'] && $content['plugin_options']['charset']) {
211 211
 				$content['charset'] = $content['plugin_options']['charset'];
212 212
 			}
213
-			if(!array_key_exists('num_header_lines', $content))
213
+			if (!array_key_exists('num_header_lines', $content))
214 214
 			{
215
-				if(is_array($content['plugin_options']) && array_key_exists('num_header_lines', $content['plugin_options']))
215
+				if (is_array($content['plugin_options']) && array_key_exists('num_header_lines', $content['plugin_options']))
216 216
 				{
217 217
 					$content['num_header_lines'] = $content['plugin_options']['num_header_lines'];
218 218
 				}
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
 					$content['num_header_lines'] = 1;
223 223
 				}
224 224
 			}
225
-			if(!$content['update_cats'] && $content['plugin_options']['update_cats']) {
225
+			if (!$content['update_cats'] && $content['plugin_options']['update_cats']) {
226 226
 				$content['update_cats'] = $content['plugin_options']['update_cats'];
227 227
 			}
228
-			if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) {
228
+			if (!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) {
229 229
 				$content['convert'] = $content['plugin_options']['convert'];
230 230
 			}
231 231
 			else
@@ -234,24 +234,24 @@  discard block
 block discarded – undo
234 234
 				$content['convert'] = 1;
235 235
 			}
236 236
 
237
-			$sel_options['charset'] = Api\Translation::get_installed_charsets()+
237
+			$sel_options['charset'] = Api\Translation::get_installed_charsets() +
238 238
 			array(
239 239
 				'user'	=> lang('User preference'),
240 240
 			);
241 241
 
242 242
 			// Add in extra allowed charsets
243 243
 			$config = Api\Config::read('importexport');
244
-			$extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings());
245
-			if($extra_charsets)
244
+			$extra_charsets = array_intersect(explode(',', $config['import_charsets']), mb_list_encodings());
245
+			if ($extra_charsets)
246 246
 			{
247
-				$sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets));
247
+				$sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets, $extra_charsets));
248 248
 			}
249 249
 			$sel_options['convert'] = array(
250 250
 				0       => lang('Database values'),
251 251
 				1       => lang('Human friendly values')
252 252
 			);
253 253
 			$preserv = $content;
254
-			if($this->mapping_fields['cat_id']) {
254
+			if ($this->mapping_fields['cat_id']) {
255 255
 				$sel_options['update_cats'] = array(
256 256
 					'add'	=> lang('Add'),
257 257
 					'replace'=> lang('Replace')
@@ -273,18 +273,18 @@  discard block
 block discarded – undo
273 273
 	*/
274 274
 	function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
275 275
 	{
276
-		if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true));
276
+		if ($this->debug) error_log(get_class($this).'::wizard_step50->$content '.print_r($content, true));
277 277
 		// return from step50
278 278
 		if ($content['step'] == 'wizard_step50')
279 279
 		{
280 280
 			unset($content['field_mapping']);
281 281
 			unset($content['field_conversion']);
282
-			foreach($content['mapping'] as $field)
282
+			foreach ($content['mapping'] as $field)
283 283
 			{
284 284
 				$index = $field['index'];
285
-				foreach(array('conversion'=>'field_conversion', 'field' => 'field_mapping') as $id => $dest)
285
+				foreach (array('conversion'=>'field_conversion', 'field' => 'field_mapping') as $id => $dest)
286 286
 				{
287
-					if(trim($field[$id]) != '' && $field[$id] !== '--NONE--')
287
+					if (trim($field[$id]) != '' && $field[$id] !== '--NONE--')
288 288
 					{
289 289
 						$content[$dest][$index] = trim($field[$id]);
290 290
 					}
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
 			switch (array_search('pressed', $content['button']))
295 295
 			{
296 296
 				case 'next':
297
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
297
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
298 298
 				case 'previous' :
299
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
299
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
300 300
 				case 'finish':
301 301
 					return 'wizard_finish';
302 302
 				default :
303
-					return $this->wizard_step50($content,$sel_options,$readonlys,$preserv);
303
+					return $this->wizard_step50($content, $sel_options, $readonlys, $preserv);
304 304
 			}
305 305
 		}
306 306
 		// init step50
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			$content['step'] = 'wizard_step50';
311 311
 
312 312
 			$content['mapping'] = array(false);
313
-			if(array_key_exists('field_mapping', $content))
313
+			if (array_key_exists('field_mapping', $content))
314 314
 			{
315 315
 				$field = $content['field_mapping'];
316 316
 				$conversion = $content['field_conversion'];
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 				$conversion = $content['plugin_options']['field_conversion'];
322 322
 			}
323 323
 			$empties = 1;
324
-			foreach($content['csv_fields'] as $index => $title)
324
+			foreach ($content['csv_fields'] as $index => $title)
325 325
 			{
326 326
 				$content['mapping'][] = array(
327 327
 					'index'	=>	$index,
@@ -329,15 +329,15 @@  discard block
 block discarded – undo
329 329
 					'field'	=>	$field[$index],
330 330
 					'conversion'	=>	$conversion[$index]
331 331
 				);
332
-				if(strstr($title,lang('Extra %1'))) $empties++;
332
+				if (strstr($title, lang('Extra %1'))) $empties++;
333 333
 			}
334
-			while($empties <= 3)
334
+			while ($empties <= 3)
335 335
 			{
336 336
 				$content['mapping'][] = array(
337 337
 					'index' => $index + $empties,
338 338
 					'title' => lang('Extra %1', $empties),
339
-					'field' => $field[$index+$empties],
340
-					'conversion'	=>	$conversion[$index+$empties]
339
+					'field' => $field[$index + $empties],
340
+					'conversion'	=>	$conversion[$index + $empties]
341 341
 				);
342 342
 				$empties++;
343 343
 			}
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	*/
356 356
 	function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv)
357 357
 	{
358
-		if($this->debug) error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true));
358
+		if ($this->debug) error_log(get_class($this).'::wizard_step55->$content '.print_r($content, true));
359 359
 
360 360
 		// return from step55
361 361
 		if ($content['step'] == 'wizard_step55')
@@ -363,8 +363,8 @@  discard block
 block discarded – undo
363 363
 
364 364
 			// Clear conditions that don't do anything
365 365
 			array_shift($content['conditions']);
366
-			foreach($content['conditions'] as $key => &$condition) {
367
-				if(($condition['true']['action'] == 'none' || !$condition['true']['action'])
366
+			foreach ($content['conditions'] as $key => &$condition) {
367
+				if (($condition['true']['action'] == 'none' || !$condition['true']['action'])
368 368
 					&& ($condition['false']['action'] == 'none' || !$condition['false']['action']) &&
369 369
 					!$condition['string']
370 370
 				) {
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 				}
374 374
 
375 375
 				// Check for true without false, or false without true - set to 'none'
376
-				elseif($condition['true']['action'] == '' && $condition['false']['action'] != '' ||
376
+				elseif ($condition['true']['action'] == '' && $condition['false']['action'] != '' ||
377 377
 					$condition['true']['action'] != '' && $condition['false']['action'] == '' ||
378 378
 					!$condition['true'] || !$condition['false']
379 379
 				)
@@ -385,9 +385,9 @@  discard block
 block discarded – undo
385 385
 			switch (array_search('pressed', $content['button']))
386 386
 			{
387 387
 				case 'next':
388
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
388
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
389 389
 				case 'previous' :
390
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
390
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
391 391
 				case 'finish':
392 392
 					return 'wizard_finish';
393 393
 				case 'add':
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 					$content['conditions'][] = array('string' => '');
397 397
 					return 'wizard_step55';
398 398
 				default :
399
-					return $this->wizard_step55($content,$sel_options,$readonlys,$preserv);
399
+					return $this->wizard_step55($content, $sel_options, $readonlys, $preserv);
400 400
 					break;
401 401
 			}
402 402
 		}
@@ -404,18 +404,18 @@  discard block
 block discarded – undo
404 404
 		$content['text'] = $this->steps['wizard_step55'];
405 405
 		$content['step'] = 'wizard_step55';
406 406
 
407
-		if(!$content['conditions'] && $content['plugin_options']['conditions']) {
407
+		if (!$content['conditions'] && $content['plugin_options']['conditions']) {
408 408
 			$content['conditions'] = $content['plugin_options']['conditions'];
409 409
 		}
410 410
 		$preserv = $content;
411 411
 
412
-		foreach($content['field_mapping'] as $field) {
412
+		foreach ($content['field_mapping'] as $field) {
413 413
 			$sel_options['string'][$field] = $this->mapping_fields[$field];
414
-			if(!$sel_options['string'][$field])
414
+			if (!$sel_options['string'][$field])
415 415
 			{
416
-				foreach($this->mapping_fields as $fields)
416
+				foreach ($this->mapping_fields as $fields)
417 417
 				{
418
-					if(is_array($fields) && $fields[$field])
418
+					if (is_array($fields) && $fields[$field])
419 419
 					{
420 420
 						$sel_options['string'][$field] = $fields[$field];
421 421
 					}
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 	 */
451 451
 	public function wizard_step65(&$content, &$sel_options, &$readonlys, &$preserv)
452 452
 	{
453
-		if($this->debug) error_log(__METHOD__ . '->$content '.print_r($content,true));
453
+		if ($this->debug) error_log(__METHOD__.'->$content '.print_r($content, true));
454 454
 
455 455
 		// return from step65
456 456
 		if ($content['step'] == 'wizard_step65')
@@ -458,13 +458,13 @@  discard block
 block discarded – undo
458 458
 			switch (array_search('pressed', $content['button']))
459 459
 			{
460 460
 				case 'next':
461
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
461
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
462 462
 				case 'previous' :
463
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
463
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
464 464
 				case 'finish':
465 465
 					return 'wizard_finish';
466 466
 				default :
467
-					return $this->wizard_step65($content,$sel_options,$readonlys,$preserv);
467
+					return $this->wizard_step65($content, $sel_options, $readonlys, $preserv);
468 468
 					break;
469 469
 			}
470 470
 		}
@@ -472,18 +472,18 @@  discard block
 block discarded – undo
472 472
 		$content['text'] = $this->steps['wizard_step65'];
473 473
 		$content['step'] = 'wizard_step65';
474 474
 
475
-		if(!$content['override_values'] && $content['plugin_options']['override_values']) {
475
+		if (!$content['override_values'] && $content['plugin_options']['override_values']) {
476 476
 			$content['override_values'] = $content['plugin_options']['override_values'];
477 477
 		}
478 478
 		$preserv = $content;
479 479
 
480
-		foreach($content['field_mapping'] as $field) {
480
+		foreach ($content['field_mapping'] as $field) {
481 481
 			$sel_options['string'][$field] = $this->mapping_fields[$field];
482
-			if(!$sel_options['string'][$field])
482
+			if (!$sel_options['string'][$field])
483 483
 			{
484
-				foreach($this->mapping_fields as $fields)
484
+				foreach ($this->mapping_fields as $fields)
485 485
 				{
486
-					if(is_array($fields) && $fields[$field])
486
+					if (is_array($fields) && $fields[$field])
487 487
 					{
488 488
 						$sel_options['string'][$field] = $fields[$field];
489 489
 					}
Please login to merge, or discard this patch.
Braces   +83 added lines, -33 removed lines patch added patch discarded remove patch
@@ -75,7 +75,10 @@  discard block
 block discarded – undo
75 75
 	*/
76 76
 	function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv)
77 77
 	{
78
-		if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true));
78
+		if($this->debug)
79
+		{
80
+			error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true));
81
+		}
79 82
 		// return from step30
80 83
 		if ($content['step'] == 'wizard_step30')
81 84
 		{
@@ -83,7 +86,8 @@  discard block
 block discarded – undo
83 86
 			{
84 87
 				case 'next':
85 88
 					// Move sample file to temp
86
-					if($content['file']['tmp_name']) {
89
+					if($content['file']['tmp_name'])
90
+					{
87 91
 						Api\Cache::setSession($content['application'], 'csvfile', $content['file']['tmp_name']);
88 92
 					}
89 93
 					unset($content['file']);
@@ -120,9 +124,13 @@  discard block
 block discarded – undo
120 124
 	 */
121 125
 	function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv)
122 126
 	{
123
-		if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true));
127
+		if($this->debug)
128
+		{
129
+			error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true));
130
+		}
124 131
 		// return from step40
125
-		if ($content['step'] == 'wizard_step40') {
132
+		if ($content['step'] == 'wizard_step40')
133
+		{
126 134
 			switch (array_search('pressed', $content['button']))
127 135
 			{
128 136
 				case 'next':
@@ -144,26 +152,40 @@  discard block
 block discarded – undo
144 152
 
145 153
 						// Try to match automatically
146 154
 						$english = array();
147
-						foreach($content['csv_fields'] as $index => $field) {
148
-							if($content['field_mapping'][$index]) continue;
155
+						foreach($content['csv_fields'] as $index => $field)
156
+						{
157
+							if($content['field_mapping'][$index])
158
+							{
159
+								continue;
160
+							}
149 161
 							$best_match = '';
150 162
 							$best_match_value = 0;
151
-							foreach($this->mapping_fields as $key => $field_name) {
152
-								if(is_array($field_name)) continue;
153
-								if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0) {
163
+							foreach($this->mapping_fields as $key => $field_name)
164
+							{
165
+								if(is_array($field_name))
166
+								{
167
+									continue;
168
+								}
169
+								if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0)
170
+								{
154 171
 									$content['field_mapping'][$index] = $key;
155 172
 									continue 2;
156 173
 								}
157 174
 								// Check english also
158
-								if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) {
175
+								if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name]))
176
+								{
159 177
 									$msg_id = Api\Translation::get_message_id($field_name, $content['application']);
160 178
 								}
161
-								if($msg_id) {
179
+								if($msg_id)
180
+								{
162 181
 									$english[$field_name] = Api\Translation::read('en', $content['application'], $msg_id);
163
-								} else {
182
+								}
183
+								else
184
+								{
164 185
 									$english[$field_name] = false;
165 186
 								}
166
-								if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) {
187
+								if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0)
188
+								{
167 189
 									$content['field_mapping'][$index] = $key;
168 190
 									continue 2;
169 191
 								}
@@ -179,11 +201,14 @@  discard block
 block discarded – undo
179 201
 								}
180 202
 
181 203
 							}
182
-							if($best_match) {
204
+							if($best_match)
205
+							{
183 206
 								$content['field_mapping'][$index] = $best_match;
184 207
 							}
185 208
 						}
186
-					} elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields']) {
209
+					}
210
+					elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields'])
211
+					{
187 212
 						$content['csv_fields'] = $content['plugin_options']['csv_fields'];
188 213
 					}
189 214
 					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
@@ -202,12 +227,16 @@  discard block
 block discarded – undo
202 227
 			$content['step'] = 'wizard_step40';
203 228
 
204 229
 			// If editing an existing definition, these will be in plugin_options
205
-			if(!$content['fieldsep'] && $content['plugin_options']['fieldsep']) {
230
+			if(!$content['fieldsep'] && $content['plugin_options']['fieldsep'])
231
+			{
206 232
 				$content['fieldsep'] = $content['plugin_options']['fieldsep'];
207
-			} elseif (!$content['fieldsep']) {
233
+			}
234
+			elseif (!$content['fieldsep'])
235
+			{
208 236
 				$content['fieldsep'] = ';';
209 237
 			}
210
-			if(!$content['charset'] && $content['plugin_options']['charset']) {
238
+			if(!$content['charset'] && $content['plugin_options']['charset'])
239
+			{
211 240
 				$content['charset'] = $content['plugin_options']['charset'];
212 241
 			}
213 242
 			if(!array_key_exists('num_header_lines', $content))
@@ -222,10 +251,12 @@  discard block
 block discarded – undo
222 251
 					$content['num_header_lines'] = 1;
223 252
 				}
224 253
 			}
225
-			if(!$content['update_cats'] && $content['plugin_options']['update_cats']) {
254
+			if(!$content['update_cats'] && $content['plugin_options']['update_cats'])
255
+			{
226 256
 				$content['update_cats'] = $content['plugin_options']['update_cats'];
227 257
 			}
228
-			if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) {
258
+			if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options']))
259
+			{
229 260
 				$content['convert'] = $content['plugin_options']['convert'];
230 261
 			}
231 262
 			else
@@ -251,12 +282,15 @@  discard block
 block discarded – undo
251 282
 				1       => lang('Human friendly values')
252 283
 			);
253 284
 			$preserv = $content;
254
-			if($this->mapping_fields['cat_id']) {
285
+			if($this->mapping_fields['cat_id'])
286
+			{
255 287
 				$sel_options['update_cats'] = array(
256 288
 					'add'	=> lang('Add'),
257 289
 					'replace'=> lang('Replace')
258 290
 				);
259
-			} else {
291
+			}
292
+			else
293
+			{
260 294
 				$content['no_cats'] = true;
261 295
 			}
262 296
 			unset ($preserv['button']);
@@ -273,7 +307,10 @@  discard block
 block discarded – undo
273 307
 	*/
274 308
 	function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
275 309
 	{
276
-		if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true));
310
+		if($this->debug)
311
+		{
312
+			error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true));
313
+		}
277 314
 		// return from step50
278 315
 		if ($content['step'] == 'wizard_step50')
279 316
 		{
@@ -329,7 +366,10 @@  discard block
 block discarded – undo
329 366
 					'field'	=>	$field[$index],
330 367
 					'conversion'	=>	$conversion[$index]
331 368
 				);
332
-				if(strstr($title,lang('Extra %1'))) $empties++;
369
+				if(strstr($title,lang('Extra %1')))
370
+				{
371
+					$empties++;
372
+				}
333 373
 			}
334 374
 			while($empties <= 3)
335 375
 			{
@@ -355,7 +395,10 @@  discard block
 block discarded – undo
355 395
 	*/
356 396
 	function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv)
357 397
 	{
358
-		if($this->debug) error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true));
398
+		if($this->debug)
399
+		{
400
+			error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true));
401
+		}
359 402
 
360 403
 		// return from step55
361 404
 		if ($content['step'] == 'wizard_step55')
@@ -363,7 +406,8 @@  discard block
 block discarded – undo
363 406
 
364 407
 			// Clear conditions that don't do anything
365 408
 			array_shift($content['conditions']);
366
-			foreach($content['conditions'] as $key => &$condition) {
409
+			foreach($content['conditions'] as $key => &$condition)
410
+			{
367 411
 				if(($condition['true']['action'] == 'none' || !$condition['true']['action'])
368 412
 					&& ($condition['false']['action'] == 'none' || !$condition['false']['action']) &&
369 413
 					!$condition['string']
@@ -376,8 +420,7 @@  discard block
 block discarded – undo
376 420
 				elseif($condition['true']['action'] == '' && $condition['false']['action'] != '' ||
377 421
 					$condition['true']['action'] != '' && $condition['false']['action'] == '' ||
378 422
 					!$condition['true'] || !$condition['false']
379
-				)
380
-				{
423
+				) {
381 424
 					$condition[$condition['true']['action'] == '' ? 'true' : 'false']['action'] = "none";
382 425
 				}
383 426
 			}
@@ -404,12 +447,14 @@  discard block
 block discarded – undo
404 447
 		$content['text'] = $this->steps['wizard_step55'];
405 448
 		$content['step'] = 'wizard_step55';
406 449
 
407
-		if(!$content['conditions'] && $content['plugin_options']['conditions']) {
450
+		if(!$content['conditions'] && $content['plugin_options']['conditions'])
451
+		{
408 452
 			$content['conditions'] = $content['plugin_options']['conditions'];
409 453
 		}
410 454
 		$preserv = $content;
411 455
 
412
-		foreach($content['field_mapping'] as $field) {
456
+		foreach($content['field_mapping'] as $field)
457
+		{
413 458
 			$sel_options['string'][$field] = $this->mapping_fields[$field];
414 459
 			if(!$sel_options['string'][$field])
415 460
 			{
@@ -450,7 +495,10 @@  discard block
 block discarded – undo
450 495
 	 */
451 496
 	public function wizard_step65(&$content, &$sel_options, &$readonlys, &$preserv)
452 497
 	{
453
-		if($this->debug) error_log(__METHOD__ . '->$content '.print_r($content,true));
498
+		if($this->debug)
499
+		{
500
+			error_log(__METHOD__ . '->$content '.print_r($content,true));
501
+		}
454 502
 
455 503
 		// return from step65
456 504
 		if ($content['step'] == 'wizard_step65')
@@ -472,12 +520,14 @@  discard block
 block discarded – undo
472 520
 		$content['text'] = $this->steps['wizard_step65'];
473 521
 		$content['step'] = 'wizard_step65';
474 522
 
475
-		if(!$content['override_values'] && $content['plugin_options']['override_values']) {
523
+		if(!$content['override_values'] && $content['plugin_options']['override_values'])
524
+		{
476 525
 			$content['override_values'] = $content['plugin_options']['override_values'];
477 526
 		}
478 527
 		$preserv = $content;
479 528
 
480
-		foreach($content['field_mapping'] as $field) {
529
+		foreach($content['field_mapping'] as $field)
530
+		{
481 531
 			$sel_options['string'][$field] = $this->mapping_fields[$field];
482 532
 			if(!$sel_options['string'][$field])
483 533
 			{
Please login to merge, or discard this patch.
admin/inc/class.uiconfig.inc.php 2 patches
Spacing   +52 added lines, -53 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 {
21 21
 	var $public_functions = array('index' => True);
22 22
 
23
-	function index($params=null)
23
+	function index($params = null)
24 24
 	{
25 25
 		// if we have a xet file, run new et2 config
26 26
 		if (file_exists(EGW_SERVER_ROOT.'/'.$_GET['appname'].'/templates/default/config.xet'))
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 			//_debug_array($params);
47 47
 			$_appname = $_GET['appname'];
48 48
 		}
49
-		if ($GLOBALS['egw']->acl->check('site_config_acce',1,'admin'))
49
+		if ($GLOBALS['egw']->acl->check('site_config_acce', 1, 'admin'))
50 50
 		{
51 51
 			Egw::redirect_link('/index.php');
52 52
 		}
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 			Api\Translation::add_app($_appname);
58 58
 		}
59 59
 
60
-		if(get_magic_quotes_gpc() && is_array($_POST['newsettings']))
60
+		if (get_magic_quotes_gpc() && is_array($_POST['newsettings']))
61 61
 		{
62 62
 			$_POST['newsettings'] = array_stripslashes($_POST['newsettings']);
63 63
 		}
64 64
 
65
-		switch($_appname)
65
+		switch ($_appname)
66 66
 		{
67 67
 			case 'admin':
68 68
 			case 'addressbook':
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		$t = new Framework\Template(Framework\Template::get_dir($appname));
90 90
 		$t->set_unknowns('keep');
91 91
 		$t->set_file(array('config' => 'config.tpl'));
92
-		$t->set_block('config','header','header');
92
+		$t->set_block('config', 'header', 'header');
93 93
 
94 94
 		// fix header templates missing essential parts like display of validation errors
95 95
 		$header = $t->get_var('header');
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
 		}
108 108
 		$t->set_var('header', $header);
109 109
 
110
-		$t->set_block('config','body','body');
111
-		$t->set_block('config','footer','footer');
110
+		$t->set_block('config', 'body', 'body');
111
+		$t->set_block('config', 'footer', 'footer');
112 112
 
113 113
 		// fix footer submit buttons to just {submit} {cancel}
114 114
 		$t->set_var('footer', preg_replace('/<input[^>]+value="{lang_(submit|cancel)}"[^>]*>/', '{$1}', $t->get_var('footer')));
115 115
 
116 116
 		$c = new Api\Config($config_appname);
117 117
 		$c->read_repository();
118
-		if ($_POST['cancel'] || ($_POST['submit'] || $_POST['save'] || $_POST['apply']) && $GLOBALS['egw']->acl->check('site_config_acce',2,'admin'))
118
+		if ($_POST['cancel'] || ($_POST['submit'] || $_POST['save'] || $_POST['apply']) && $GLOBALS['egw']->acl->check('site_config_acce', 2, 'admin'))
119 119
 		{
120 120
 			Egw::redirect_link('/admin/index.php?ajax=true');
121 121
 		}
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 		if ($_POST['submit'] || $_POST['save'] || $_POST['apply'])
124 124
 		{
125 125
 			/* Load hook file with functions to validate each Api\Config (one/none/all) */
126
-			Api\Hooks::single('config_validate',$appname);
126
+			Api\Hooks::single('config_validate', $appname);
127 127
 
128
-			foreach($_POST['newsettings'] as $key => $config)
128
+			foreach ($_POST['newsettings'] as $key => $config)
129 129
 			{
130 130
 				if ($config)
131 131
 				{
@@ -133,26 +133,26 @@  discard block
 block discarded – undo
133 133
 					if (in_array($key, (array)$GLOBALS['egw_info']['server']['found_validation_hook'], true) && function_exists($key))
134 134
 					{
135 135
 						call_user_func($key, $config, $c);
136
-						if($GLOBALS['config_error'])
136
+						if ($GLOBALS['config_error'])
137 137
 						{
138
-							$errors .= lang($GLOBALS['config_error']) . "\n";
138
+							$errors .= lang($GLOBALS['config_error'])."\n";
139 139
 							$GLOBALS['config_error'] = False;
140 140
 						}
141 141
 					}
142 142
 				}
143 143
 				/* don't erase passwords, since we also don't print them */
144
-				elseif(strpos($key,'passwd') === false && strpos($key,'password') === false && strpos($key,'root_pw') === false)
144
+				elseif (strpos($key, 'passwd') === false && strpos($key, 'password') === false && strpos($key, 'root_pw') === false)
145 145
 				{
146 146
 					unset($c->config_data[$key]);
147 147
 				}
148 148
 			}
149
-			if(in_array('final_validation', (array)$GLOBALS['egw_info']['server']['found_validation_hook']) &&
149
+			if (in_array('final_validation', (array)$GLOBALS['egw_info']['server']['found_validation_hook']) &&
150 150
 				function_exists('final_validation'))
151 151
 			{
152 152
 				final_validation($_POST['newsettings']);
153
-				if($GLOBALS['config_error'])
153
+				if ($GLOBALS['config_error'])
154 154
 				{
155
-					$errors .= lang($GLOBALS['config_error']) . "\n";
155
+					$errors .= lang($GLOBALS['config_error'])."\n";
156 156
 					$GLOBALS['config_error'] = False;
157 157
 				}
158 158
 				unset($GLOBALS['egw_info']['server']['found_validation_hook']);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
 			$c->save_repository();
162 162
 
163
-			if(!$errors && !$_POST['apply'])
163
+			if (!$errors && !$_POST['apply'])
164 164
 			{
165 165
 				Framework::message(lang('Configuration saved.'), 'success');
166 166
 				Egw::redirect_link('/index.php', array(
@@ -170,10 +170,10 @@  discard block
 block discarded – undo
170 170
 			}
171 171
 		}
172 172
 
173
-		$t->set_var('error','');
174
-		if($errors)
173
+		$t->set_var('error', '');
174
+		if ($errors)
175 175
 		{
176
-			Framework::message(lang('Error') . ': ' . $errors, 'error');
176
+			Framework::message(lang('Error').': '.$errors, 'error');
177 177
 			unset($errors);
178 178
 			unset($GLOBALS['config_error']);
179 179
 		}
@@ -181,41 +181,41 @@  discard block
 block discarded – undo
181 181
 		{
182 182
 			Framework::message(lang('Configuration saved.'), 'success');
183 183
 		}
184
-		$t->set_var('title',lang('Site Configuration'));
185
-		$t->set_var('action_url',$GLOBALS['egw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname));
186
-		$t->set_var('th_bg',     $GLOBALS['egw_info']['theme']['th_bg']);
187
-		$t->set_var('th_text',   $GLOBALS['egw_info']['theme']['th_text']);
188
-		$t->set_var('row_on',    $GLOBALS['egw_info']['theme']['row_on']);
189
-		$t->set_var('row_off',   $GLOBALS['egw_info']['theme']['row_off']);
184
+		$t->set_var('title', lang('Site Configuration'));
185
+		$t->set_var('action_url', $GLOBALS['egw']->link('/index.php', 'menuaction=admin.uiconfig.index&appname='.$appname));
186
+		$t->set_var('th_bg', $GLOBALS['egw_info']['theme']['th_bg']);
187
+		$t->set_var('th_text', $GLOBALS['egw_info']['theme']['th_text']);
188
+		$t->set_var('row_on', $GLOBALS['egw_info']['theme']['row_on']);
189
+		$t->set_var('row_off', $GLOBALS['egw_info']['theme']['row_off']);
190 190
 		$t->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__CLASS__)));
191 191
 
192 192
 		$vars = $t->get_undefined('body');
193 193
 
194
-		if (Api\Hooks::single('config',$appname))	// reload the config-values, they might have changed
194
+		if (Api\Hooks::single('config', $appname))	// reload the config-values, they might have changed
195 195
 		{
196 196
 			$c->read_repository();
197 197
 		}
198
-		foreach($vars as $value)
198
+		foreach ($vars as $value)
199 199
 		{
200
-			$valarray = explode('_',$value);
200
+			$valarray = explode('_', $value);
201 201
 			$type = array_shift($valarray);
202
-			$newval = implode(' ',$valarray);
202
+			$newval = implode(' ', $valarray);
203 203
 
204 204
 			switch ($type)
205 205
 			{
206 206
 				case 'lang':
207
-					$t->set_var($value,lang($newval));
207
+					$t->set_var($value, lang($newval));
208 208
 					break;
209 209
 				case 'value':
210
-					$newval = str_replace(' ','_',$newval);
210
+					$newval = str_replace(' ', '_', $newval);
211 211
 					/* Don't show passwords in the form */
212
-					if(strpos($value,'passwd') !== false || strpos($value,'password') !== false || strpos($value,'root_pw') !== false)
212
+					if (strpos($value, 'passwd') !== false || strpos($value, 'password') !== false || strpos($value, 'root_pw') !== false)
213 213
 					{
214
-						$t->set_var($value,'');
214
+						$t->set_var($value, '');
215 215
 					}
216 216
 					else
217 217
 					{
218
-						$t->set_var($value,$c->config_data[$newval]);
218
+						$t->set_var($value, $c->config_data[$newval]);
219 219
 					}
220 220
 					break;
221 221
 				/*
@@ -233,46 +233,45 @@  discard block
 block discarded – undo
233 233
 				*/
234 234
 				case 'selected':
235 235
 					$configs = array();
236
-					$newvals = explode(' ',$newval);
236
+					$newvals = explode(' ', $newval);
237 237
 					$setting = end($newvals);
238
-					for ($i=0;$i<(count($newvals) - 1); $i++)
238
+					for ($i = 0; $i < (count($newvals) - 1); $i++)
239 239
 					{
240 240
 						$configs[] = $newvals[$i];
241 241
 					}
242
-					$config = implode('_',$configs);
242
+					$config = implode('_', $configs);
243 243
 					/* echo $config . '=' . $c->config_data[$config]; */
244 244
 					if ($c->config_data[$config] == $setting)
245 245
 					{
246
-						$t->set_var($value,' selected');
246
+						$t->set_var($value, ' selected');
247 247
 					}
248 248
 					else
249 249
 					{
250
-						$t->set_var($value,'');
250
+						$t->set_var($value, '');
251 251
 					}
252 252
 					break;
253 253
 				case 'hook':
254
-					$newval = str_replace(' ','_',$newval);
255
-					if(function_exists($newval))
254
+					$newval = str_replace(' ', '_', $newval);
255
+					if (function_exists($newval))
256 256
 					{
257
-						$t->set_var($value,$newval($c->config_data));
257
+						$t->set_var($value, $newval($c->config_data));
258 258
 					}
259 259
 					else
260 260
 					{
261
-						$t->set_var($value,'');
261
+						$t->set_var($value, '');
262 262
 					}
263 263
 					break;
264 264
 				case 'call':	// eg. call_class::method or call_app.class.method
265
-					$newval = str_replace(' ','_',$newval);
266
-					$t->set_var($value,ExecMethod($newval,$c->config_data));
265
+					$newval = str_replace(' ', '_', $newval);
266
+					$t->set_var($value, ExecMethod($newval, $c->config_data));
267 267
 					break;
268 268
 				default:
269
-					$t->set_var($value,'');
269
+					$t->set_var($value, '');
270 270
 					break;
271 271
 			}
272 272
 		}
273 273
 		$t->set_var('submit', '<div class="dialogFooterToolbar" style="text-align: left">'.
274
-			($GLOBALS['egw']->acl->check('site_config_acce',2,'admin') ? '' :
275
-				Api\Html::submit_button('save', 'Save')."\n".
274
+			($GLOBALS['egw']->acl->check('site_config_acce', 2, 'admin') ? '' : Api\Html::submit_button('save', 'Save')."\n".
276 275
 				Api\Html::submit_button('apply', 'Apply')));
277 276
 		$t->set_var('cancel', Api\Html::submit_button('cancel', 'Cancel').'</div>');
278 277
 
@@ -282,10 +281,10 @@  discard block
 block discarded – undo
282 281
 		// render the page
283 282
 		$GLOBALS['egw']->framework->render(
284 283
 			'<div id="admin-config-'.$appname.'" class="admin-config">'.
285
-			$t->parse('out','header').
286
-			$t->fp('out','body').
287
-			$t->fp('out','footer').'</div>',
288
-			null,true
284
+			$t->parse('out', 'header').
285
+			$t->fp('out', 'body').
286
+			$t->fp('out', 'footer').'</div>',
287
+			null, true
289 288
 		);
290 289
 	}
291 290
 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,7 +85,11 @@  discard block
 block discarded – undo
85 85
 				$config_appname = $appname;
86 86
 				break;
87 87
 		}
88
-		if (ob_get_contents()) ob_end_flush(); // if there is output in buffer, flush it now.
88
+		if (ob_get_contents())
89
+		{
90
+			ob_end_flush();
91
+		}
92
+		// if there is output in buffer, flush it now.
89 93
 		$t = new Framework\Template(Framework\Template::get_dir($appname));
90 94
 		$t->set_unknowns('keep');
91 95
 		$t->set_file(array('config' => 'config.tpl'));
@@ -191,10 +195,13 @@  discard block
 block discarded – undo
191 195
 
192 196
 		$vars = $t->get_undefined('body');
193 197
 
194
-		if (Api\Hooks::single('config',$appname))	// reload the config-values, they might have changed
198
+		if (Api\Hooks::single('config',$appname))
199
+		{
200
+			// reload the config-values, they might have changed
195 201
 		{
196 202
 			$c->read_repository();
197 203
 		}
204
+		}
198 205
 		foreach($vars as $value)
199 206
 		{
200 207
 			$valarray = explode('_',$value);
Please login to merge, or discard this patch.
admin/inc/class.admin_import_users_csv.inc.php 3 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   +69 added lines, -28 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
 		}
@@ -131,17 +136,27 @@  discard block
 block discarded – undo
131 136
 			'account_status'	=> array('A' => lang('Active'), '' => lang('Disabled'), 'D' => lang('Disabled')),
132 137
 		);
133 138
 
134
-		while ( $record = $import_csv->get_record() ) {
139
+		while ( $record = $import_csv->get_record() )
140
+		{
135 141
 			$success = false;
136 142
 			// don't import empty records
137
-			if( count( array_unique( $record ) ) < 2 ) continue;
143
+			if( count( array_unique( $record ) ) < 2 )
144
+			{
145
+				continue;
146
+			}
138 147
 
139
-			if(strtolower($record['account_expires']) == 'never') $record['account_expires'] = -1;
148
+			if(strtolower($record['account_expires']) == 'never')
149
+			{
150
+				$record['account_expires'] = -1;
151
+			}
140 152
 			importexport_import_csv::convert($record, admin_egw_user_record::$types, 'admin', $lookups);
141 153
 
142
-			if ( $_definition->plugin_options['conditions'] ) {
143
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
144
-					switch ( $condition['type'] ) {
154
+			if ( $_definition->plugin_options['conditions'] )
155
+			{
156
+				foreach ( $_definition->plugin_options['conditions'] as $condition )
157
+				{
158
+					switch ( $condition['type'] )
159
+					{
145 160
 						// exists
146 161
 						case 'exists' :
147 162
 							$accounts = array();
@@ -157,16 +172,23 @@  discard block
 block discarded – undo
157 172
 							// Search looks in the given field, but doesn't do an exact match
158 173
 							foreach ( (array)$accounts as $key => $account )
159 174
 							{
160
-								if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]);
175
+								if($account[$condition['string']] != $record[$condition['string']])
176
+								{
177
+									unset($accounts[$key]);
178
+								}
161 179
 							}
162
-							if ( is_array( $accounts ) && count( $accounts ) >= 1 ) {
180
+							if ( is_array( $accounts ) && count( $accounts ) >= 1 )
181
+							{
163 182
 								// apply action to all contacts matching this exists condition
164 183
 								$action = $condition['true'];
165
-								foreach ( (array)$accounts as $account ) {
184
+								foreach ( (array)$accounts as $account )
185
+								{
166 186
 									$record['account_id'] = $account['account_id'];
167 187
 									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position(), $admin_cmd );
168 188
 								}
169
-							} else {
189
+							}
190
+							else
191
+							{
170 192
 								$action = $condition['false'];
171 193
 								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position(), $admin_cmd ));
172 194
 							}
@@ -176,13 +198,21 @@  discard block
 block discarded – undo
176 198
 						default :
177 199
 							die('condition / action not supported!!!');
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( 'create', $record, $import_csv->get_current_position(), $admin_cmd );
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, $admin_cmd ) {
198
-		switch ($_action) {
227
+	private function action ( $_action, $_data, $record_num = 0, $admin_cmd )
228
+	{
229
+		switch ($_action)
230
+		{
199 231
 			case 'none' :
200 232
 				return true;
201 233
 			case 'disable':
@@ -209,13 +241,15 @@  discard block
 block discarded – undo
209 241
 				)+(array)$admin_cmd);
210 242
 
211 243
 
212
-				if($this->dry_run) {
244
+				if($this->dry_run)
245
+				{
213 246
 					$this->results[$_action]++;
214 247
 					return true;
215 248
 				}
216 249
 				try {
217 250
 					$command->run();
218
-				} catch (Exception $e) {
251
+				}
252
+				catch (Exception $e) {
219 253
 					$this->errors[$record_num] = $e->getMessage();
220 254
 					return false;
221 255
 				}
@@ -232,7 +266,8 @@  discard block
 block discarded – undo
232 266
 	 *
233 267
 	 * @return string name
234 268
 	 */
235
-	public static function get_name() {
269
+	public static function get_name()
270
+	{
236 271
 		return lang('User CSV import');
237 272
 	}
238 273
 
@@ -241,7 +276,8 @@  discard block
 block discarded – undo
241 276
 	 *
242 277
 	 * @return string descriprion
243 278
 	 */
244
-	public static function get_description() {
279
+	public static function get_description()
280
+	{
245 281
 		return lang("Creates / updates user accounts from CSV file");
246 282
 	}
247 283
 
@@ -250,7 +286,8 @@  discard block
 block discarded – undo
250 286
 	 *
251 287
 	 * @return string suffix (comma seperated)
252 288
 	 */
253
-	public static function get_filesuffix() {
289
+	public static function get_filesuffix()
290
+	{
254 291
 		return 'csv';
255 292
 	}
256 293
 
@@ -276,7 +313,8 @@  discard block
 block discarded – undo
276 313
 	 *
277 314
 	 * @return string etemplate name
278 315
 	 */
279
-	public function get_selectors_etpl() {
316
+	public function get_selectors_etpl()
317
+	{
280 318
 		// lets do it!
281 319
 	}
282 320
 
@@ -288,7 +326,8 @@  discard block
 block discarded – undo
288 326
 	*       record_# => warning message
289 327
 	*       )
290 328
 	*/
291
-	public function get_warnings() {
329
+	public function get_warnings()
330
+	{
292 331
 		return $this->warnings;
293 332
 	}
294 333
 
@@ -300,7 +339,8 @@  discard block
 block discarded – undo
300 339
 	*       record_# => error message
301 340
 	*       )
302 341
 	*/
303
-	public function get_errors() {
342
+	public function get_errors()
343
+	{
304 344
 		return $this->errors;
305 345
 	}
306 346
 
@@ -312,7 +352,8 @@  discard block
 block discarded – undo
312 352
 	*       action => record count
313 353
 	* )
314 354
 	*/
315
-	public function get_results() {
355
+	public function get_results()
356
+	{
316 357
 		return $this->results;
317 358
 	}
318 359
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 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
 		}
@@ -131,22 +131,22 @@  discard block
 block discarded – undo
131 131
 			'account_status'	=> array('A' => lang('Active'), '' => lang('Disabled'), 'D' => lang('Disabled')),
132 132
 		);
133 133
 
134
-		while ( $record = $import_csv->get_record() ) {
134
+		while ($record = $import_csv->get_record()) {
135 135
 			$success = false;
136 136
 			// don't import empty records
137
-			if( count( array_unique( $record ) ) < 2 ) continue;
137
+			if (count(array_unique($record)) < 2) continue;
138 138
 
139
-			if(strtolower($record['account_expires']) == 'never') $record['account_expires'] = -1;
139
+			if (strtolower($record['account_expires']) == 'never') $record['account_expires'] = -1;
140 140
 			importexport_import_csv::convert($record, admin_egw_user_record::$types, 'admin', $lookups);
141 141
 
142
-			if ( $_definition->plugin_options['conditions'] ) {
143
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
144
-					switch ( $condition['type'] ) {
142
+			if ($_definition->plugin_options['conditions']) {
143
+				foreach ($_definition->plugin_options['conditions'] as $condition) {
144
+					switch ($condition['type']) {
145 145
 						// exists
146 146
 						case 'exists' :
147 147
 							$accounts = array();
148 148
 							// Skip the search if the field is empty
149
-							if($record[$condition['string']] !== '')
149
+							if ($record[$condition['string']] !== '')
150 150
 							{
151 151
 								$accounts = $GLOBALS['egw']->accounts->search(array(
152 152
 									'type' => 'accounts',
@@ -155,20 +155,20 @@  discard block
 block discarded – undo
155 155
 								));
156 156
 							}
157 157
 							// Search looks in the given field, but doesn't do an exact match
158
-							foreach ( (array)$accounts as $key => $account )
158
+							foreach ((array)$accounts as $key => $account)
159 159
 							{
160
-								if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]);
160
+								if ($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]);
161 161
 							}
162
-							if ( is_array( $accounts ) && count( $accounts ) >= 1 ) {
162
+							if (is_array($accounts) && count($accounts) >= 1) {
163 163
 								// apply action to all contacts matching this exists condition
164 164
 								$action = $condition['true'];
165
-								foreach ( (array)$accounts as $account ) {
165
+								foreach ((array)$accounts as $account) {
166 166
 									$record['account_id'] = $account['account_id'];
167
-									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position(), $admin_cmd );
167
+									$success = $this->action($action['action'], $record, $import_csv->get_current_position(), $admin_cmd);
168 168
 								}
169 169
 							} else {
170 170
 								$action = $condition['false'];
171
-								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position(), $admin_cmd ));
171
+								$success = ($this->action($action['action'], $record, $import_csv->get_current_position(), $admin_cmd));
172 172
 							}
173 173
 							break;
174 174
 
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 				}
181 181
 			} else {
182 182
 				// unconditional insert
183
-				$success = $this->action( 'create', $record, $import_csv->get_current_position(), $admin_cmd );
183
+				$success = $this->action('create', $record, $import_csv->get_current_position(), $admin_cmd);
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, $admin_cmd ) {
197
+	private function action($_action, $_data, $record_num = 0, $admin_cmd) {
198 198
 		switch ($_action) {
199 199
 			case 'none' :
200 200
 				return true;
@@ -203,22 +203,22 @@  discard block
 block discarded – undo
203 203
 				$_data['account_expires'] = $_action == 'disable' ? 'already' : '';
204 204
 			case 'update' :
205 205
 				$old = $GLOBALS['egw']->accounts->read($_data['account_id']);
206
-				if($old)
206
+				if ($old)
207 207
 				{
208 208
 					$old['account_passwd'] = $old['account_pwd']; unset($old['account_pwd']);
209
-					$old['account_groups'] = implode(',',$GLOBALS['egw']->accounts->memberships($_data['account_id'], true));
209
+					$old['account_groups'] = implode(',', $GLOBALS['egw']->accounts->memberships($_data['account_id'], true));
210 210
 					// Limit history to what actually changed
211 211
 					$old = array_intersect_key($old, $_data);
212 212
 				}
213 213
 			case 'create' :
214 214
 				$command = new admin_cmd_edit_user(array(
215
-					'account' => $_action=='create'?null:(int)$_data['account_id'],
215
+					'account' => $_action == 'create' ?null:(int)$_data['account_id'],
216 216
 					'set' => $_data,
217
-					'old' => $_action=='create'?null:$old
218
-				)+(array)$admin_cmd);
217
+					'old' => $_action == 'create' ?null:$old
218
+				) + (array)$admin_cmd);
219 219
 
220 220
 
221
-				if($this->dry_run) {
221
+				if ($this->dry_run) {
222 222
 					$this->results[$_action]++;
223 223
 					return true;
224 224
 				}
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	 * 		preserv		=> array,
276 276
 	 * )
277 277
 	 */
278
-	public function get_options_etpl(importexport_definition &$definition=null)
278
+	public function get_options_etpl(importexport_definition &$definition = null)
279 279
 	{
280 280
 		// lets do it!
281 281
 	}
Please login to merge, or discard this patch.
admin/inc/class.admin_export_groups_csv.inc.php 3 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param egw_record $_definition
23 23
 	 */
24
-	public function export( $_stream, importexport_definition $_definition) {
24
+	public function export($_stream, importexport_definition $_definition) {
25 25
 		$options = $_definition->plugin_options;
26 26
 
27 27
 		$query = array(
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 		// $_record is an array, that's what search() returns
41 41
 		foreach ($selection as $_record) {
42 42
 			$record = new admin_egw_group_record($_record);
43
-			if($options['convert']) {
43
+			if ($options['convert']) {
44 44
 				importexport_export_csv::convert($record, admin_egw_group_record::$types, 'admin', $lookups);
45 45
 			} else {
46 46
 				// Implode arrays, so they don't say 'Array'
47
-				foreach($record->get_record_array() as $key => $value) {
48
-					if(is_array($value)) $record->$key = implode(',', $value);
47
+				foreach ($record->get_record_array() as $key => $value) {
48
+					if (is_array($value)) $record->$key = implode(',', $value);
49 49
 				}
50 50
  			}
51 51
 			$export_object->export_record($record);
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -81,8 +81,8 @@
 block discarded – undo
81 81
 	}
82 82
 
83 83
 	public static function get_mimetype() {
84
-                return 'text/csv';
85
-        }
84
+				return 'text/csv';
85
+		}
86 86
 
87 87
 	/**
88 88
 	 * Return array of settings for export dialog
Please login to merge, or discard this patch.
Braces   +25 added lines, -11 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param egw_record $_definition
23 23
 	 */
24
-	public function export( $_stream, importexport_definition $_definition) {
24
+	public function export( $_stream, importexport_definition $_definition)
25
+	{
25 26
 		$options = $_definition->plugin_options;
26 27
 
27 28
 		$query = array(
@@ -38,14 +39,22 @@  discard block
 block discarded – undo
38 39
 		);
39 40
 
40 41
 		// $_record is an array, that's what search() returns
41
-		foreach ($selection as $_record) {
42
+		foreach ($selection as $_record)
43
+		{
42 44
 			$record = new admin_egw_group_record($_record);
43
-			if($options['convert']) {
45
+			if($options['convert'])
46
+			{
44 47
 				importexport_export_csv::convert($record, admin_egw_group_record::$types, 'admin', $lookups);
45
-			} else {
48
+			}
49
+			else
50
+			{
46 51
 				// Implode arrays, so they don't say 'Array'
47
-				foreach($record->get_record_array() as $key => $value) {
48
-					if(is_array($value)) $record->$key = implode(',', $value);
52
+				foreach($record->get_record_array() as $key => $value)
53
+				{
54
+					if(is_array($value))
55
+					{
56
+						$record->$key = implode(',', $value);
57
+					}
49 58
 				}
50 59
  			}
51 60
 			$export_object->export_record($record);
@@ -58,7 +67,8 @@  discard block
 block discarded – undo
58 67
 	 *
59 68
 	 * @return string name
60 69
 	 */
61
-	public static function get_name() {
70
+	public static function get_name()
71
+	{
62 72
 		return lang('Group CSV export');
63 73
 	}
64 74
 
@@ -67,7 +77,8 @@  discard block
 block discarded – undo
67 77
 	 *
68 78
 	 * @return string descriprion
69 79
 	 */
70
-	public static function get_description() {
80
+	public static function get_description()
81
+	{
71 82
 		return lang("Exports groups into a CSV File. ");
72 83
 	}
73 84
 
@@ -76,11 +87,13 @@  discard block
 block discarded – undo
76 87
 	 *
77 88
 	 * @return string suffix
78 89
 	 */
79
-	public static function get_filesuffix() {
90
+	public static function get_filesuffix()
91
+	{
80 92
 		return 'csv';
81 93
 	}
82 94
 
83
-	public static function get_mimetype() {
95
+	public static function get_mimetype()
96
+	{
84 97
                 return 'text/csv';
85 98
         }
86 99
 
@@ -106,7 +119,8 @@  discard block
 block discarded – undo
106 119
 	 * returns slectors of this plugin via xajax
107 120
 	 *
108 121
 	 */
109
-	public function get_selectors_etpl() {
122
+	public function get_selectors_etpl()
123
+	{
110 124
 		return array(
111 125
 			'preserv' => array('no_error_for_no_selection'),
112 126
 		);
Please login to merge, or discard this patch.