Completed
Push — master ( aa44e9...fa84e5 )
by Ralf
90:14 queued 73:21
created
admin/inc/class.admin_export_users_csv.inc.php 4 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@  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(
28 28
 			'type'	=>	'accounts',
29 29
 		);
30
-		if($options['selection']['group_id']) {
30
+		if ($options['selection']['group_id']) {
31 31
 			$query['type'] = (int)$options['selection']['group_id'];
32 32
 		}
33 33
 		$selection = $GLOBALS['egw']->accounts->search($query);
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
 		// $_record is an array, that's what search() returns
44 44
 		foreach ($selection as $_record) {
45 45
 			$record = new admin_egw_user_record($_record);
46
-			if($options['convert']) {
46
+			if ($options['convert']) {
47 47
 				$never_expires = ($record->account_expires == -1);
48 48
 				importexport_export_csv::convert($record, admin_egw_user_record::$types, 'admin', $lookups);
49
-				if($never_expires) $record->account_expires = 'never';  // Has to be 'never' for admin_cmd_edit_user to parse it
49
+				if ($never_expires) $record->account_expires = 'never'; // Has to be 'never' for admin_cmd_edit_user to parse it
50 50
 			} else {
51 51
 				// Implode arrays, so they don't say 'Array'
52
-				foreach($record->get_record_array() as $key => $value) {
53
-					if(is_array($value)) $record->$key = implode(',', $value);
52
+				foreach ($record->get_record_array() as $key => $value) {
53
+					if (is_array($value)) $record->$key = implode(',', $value);
54 54
 				}
55 55
  			}
56 56
 			$export_object->export_record($record);
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * Exports records as defined in $_definition
27 27
 	 *
28
-	 * @param egw_record $_definition
28
+	 * @param importexport_definition $_definition
29 29
 	 */
30 30
 	public function export( $_stream, importexport_definition $_definition) {
31 31
 		$options = $_definition->plugin_options;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * return html for options.
133 133
 	 * this way the plugin has all opportunities for options tab
134 134
 	 *
135
-	 * @return string html
135
+	 * @return boolean html
136 136
 	 */
137 137
 	public function get_options_etpl() {
138 138
 		return false;
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -125,8 +125,8 @@
 block discarded – undo
125 125
 	}
126 126
 
127 127
 	public static function get_mimetype() {
128
-                return 'text/csv';
129
-        }
128
+				return 'text/csv';
129
+		}
130 130
 
131 131
 	/**
132 132
 	 * return html for options.
Please login to merge, or discard this patch.
Braces   +34 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,13 +21,15 @@  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(
28 29
 			'type'	=>	'accounts',
29 30
 		);
30
-		if($options['selection']['group_id']) {
31
+		if($options['selection']['group_id'])
32
+		{
31 33
 			$query['type'] = (int)$options['selection']['group_id'];
32 34
 		}
33 35
 		$selection = $GLOBALS['egw']->accounts->search($query);
@@ -41,16 +43,28 @@  discard block
 block discarded – undo
41 43
 		);
42 44
 
43 45
 		// $_record is an array, that's what search() returns
44
-		foreach ($selection as $_record) {
46
+		foreach ($selection as $_record)
47
+		{
45 48
 			$record = new admin_egw_user_record($_record);
46
-			if($options['convert']) {
49
+			if($options['convert'])
50
+			{
47 51
 				$never_expires = ($record->account_expires == -1);
48 52
 				importexport_export_csv::convert($record, admin_egw_user_record::$types, 'admin', $lookups);
49
-				if($never_expires) $record->account_expires = 'never';  // Has to be 'never' for admin_cmd_edit_user to parse it
50
-			} else {
53
+				if($never_expires)
54
+				{
55
+					$record->account_expires = 'never';
56
+				}
57
+				// Has to be 'never' for admin_cmd_edit_user to parse it
58
+			}
59
+			else
60
+			{
51 61
 				// Implode arrays, so they don't say 'Array'
52
-				foreach($record->get_record_array() as $key => $value) {
53
-					if(is_array($value)) $record->$key = implode(',', $value);
62
+				foreach($record->get_record_array() as $key => $value)
63
+				{
64
+					if(is_array($value))
65
+					{
66
+						$record->$key = implode(',', $value);
67
+					}
54 68
 				}
55 69
  			}
56 70
 			$export_object->export_record($record);
@@ -63,7 +77,8 @@  discard block
 block discarded – undo
63 77
 	 *
64 78
 	 * @return string name
65 79
 	 */
66
-	public static function get_name() {
80
+	public static function get_name()
81
+	{
67 82
 		return lang('User CSV export');
68 83
 	}
69 84
 
@@ -72,7 +87,8 @@  discard block
 block discarded – undo
72 87
 	 *
73 88
 	 * @return string descriprion
74 89
 	 */
75
-	public static function get_description() {
90
+	public static function get_description()
91
+	{
76 92
 		return lang("Exports users into a CSV File. ");
77 93
 	}
78 94
 
@@ -81,11 +97,13 @@  discard block
 block discarded – undo
81 97
 	 *
82 98
 	 * @return string suffix
83 99
 	 */
84
-	public static function get_filesuffix() {
100
+	public static function get_filesuffix()
101
+	{
85 102
 		return 'csv';
86 103
 	}
87 104
 
88
-	public static function get_mimetype() {
105
+	public static function get_mimetype()
106
+	{
89 107
                 return 'text/csv';
90 108
         }
91 109
 
@@ -95,7 +113,8 @@  discard block
 block discarded – undo
95 113
 	 *
96 114
 	 * @return string html
97 115
 	 */
98
-	public function get_options_etpl() {
116
+	public function get_options_etpl()
117
+	{
99 118
 		return false;
100 119
 	}
101 120
 
@@ -103,7 +122,8 @@  discard block
 block discarded – undo
103 122
 	 * returns slectors of this plugin via xajax
104 123
 	 *
105 124
 	 */
106
-	public function get_selectors_etpl() {
125
+	public function get_selectors_etpl()
126
+	{
107 127
 		return array(
108 128
 			'name'	=> 'admin.export_users_csv_selectors',
109 129
 			'preserv' => array('no_error_for_all'),
Please login to merge, or discard this patch.
admin/inc/class.admin_import_groups_csv.inc.php 3 patches
Spacing   +29 added lines, -29 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 (groups)
17 17
  */
18
-class admin_import_groups_csv implements importexport_iface_import_plugin  {
18
+class admin_import_groups_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');
43
+	protected static $actions = array('none', 'update', 'create', 'delete');
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
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 	 * @param string $_charset
81 81
 	 * @param definition $_definition
82 82
 	 */
83
-	public function import( $_stream, importexport_definition $_definition ) {
84
-		$import_csv = new importexport_import_csv( $_stream, array(
83
+	public function import($_stream, importexport_definition $_definition) {
84
+		$import_csv = new importexport_import_csv($_stream, array(
85 85
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
86 86
 			'charset' => $_definition->plugin_options['charset'],
87 87
 		));
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		$this->definition = $_definition;
90 90
 
91 91
 		// dry run?
92
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
92
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
93 93
 
94 94
 		// set FieldMapping.
95 95
 		$import_csv->mapping = $_definition->plugin_options['field_mapping'];
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
99 99
 
100 100
 		//check if file has a header lines
101
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
101
+		if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) {
102 102
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
103
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
103
+		} elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
104 104
 			// First method is preferred
105 105
 			$import_csv->skip_records(1);
106 106
 		}
@@ -112,22 +112,22 @@  discard block
 block discarded – undo
112 112
 		// Failures
113 113
 		$this->errors = array();
114 114
 
115
-		while ( $record = $import_csv->get_record() ) {
115
+		while ($record = $import_csv->get_record()) {
116 116
 			$success = false;
117 117
 			// don't import empty records
118
-			if( count( array_unique( $record ) ) < 2 ) continue;
118
+			if (count(array_unique($record)) < 2) continue;
119 119
 
120 120
 			importexport_import_csv::convert($record, admin_egw_group_record::$types, 'admin');
121 121
 
122
-			if ( $_definition->plugin_options['conditions'] ) {
123
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
124
-					switch ( $condition['type'] ) {
122
+			if ($_definition->plugin_options['conditions']) {
123
+				foreach ($_definition->plugin_options['conditions'] as $condition) {
124
+					switch ($condition['type']) {
125 125
 						// exists
126 126
 						case 'exists' :
127 127
 							$accounts = array();
128 128
 
129 129
 							// Skip the search if the field is empty
130
-							if($record[$condition['string']] !== '') {
130
+							if ($record[$condition['string']] !== '') {
131 131
 
132 132
 								$accounts = $GLOBALS['egw']->accounts->search(array(
133 133
 									'type' => 'groups',
@@ -136,25 +136,25 @@  discard block
 block discarded – undo
136 136
 								));
137 137
 							}
138 138
 							// Search looks in the given field, but doesn't do an exact match
139
-							foreach ( (array)$accounts as $key => $account )
139
+							foreach ((array)$accounts as $key => $account)
140 140
 							{
141
-								if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]);
141
+								if ($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]);
142 142
 							}
143
-							if ( is_array( $accounts ) && count( $accounts ) >= 1 ) {
143
+							if (is_array($accounts) && count($accounts) >= 1) {
144 144
 								$account = current($accounts);
145 145
 								// apply action to all contacts matching this exists condition
146 146
 								$action = $condition['true'];
147
-								foreach ( (array)$accounts as $account ) {
147
+								foreach ((array)$accounts as $account) {
148 148
 									// Read full account, and copy needed info for accounts->save()
149 149
 									$account = $GLOBALS['egw']->accounts->read($account['account_id']);
150 150
 									$record['account_id'] = $account['account_id'];
151 151
 									$record['account_firstname'] = $account['account_firstname'];
152 152
 									$record['account_lastname'] = $account['account_lastname'];
153
-									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
153
+									$success = $this->action($action['action'], $record, $import_csv->get_current_position());
154 154
 								}
155 155
 							} else {
156 156
 								$action = $condition['false'];
157
-								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
157
+								$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
158 158
 							}
159 159
 							break;
160 160
 
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
 				}
168 168
 			} else {
169 169
 				// unconditional insert
170
-				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
170
+				$success = $this->action('insert', $record, $import_csv->get_current_position());
171 171
 			}
172
-			if($success) $count++;
172
+			if ($success) $count++;
173 173
 		}
174 174
 		return $count;
175 175
 	}
@@ -181,18 +181,18 @@  discard block
 block discarded – undo
181 181
 	 * @param array $_data contact data for the action
182 182
 	 * @return bool success or not
183 183
 	 */
184
-	private function action ( $_action, $_data, $record_num = 0 ) {
184
+	private function action($_action, $_data, $record_num = 0) {
185 185
 		switch ($_action) {
186 186
 			case 'none' :
187 187
 				return true;
188 188
 			case 'update' :
189 189
 			case 'create' :
190
-				if(count($_data['account_members']) < 1) {
190
+				if (count($_data['account_members']) < 1) {
191 191
 					$this->errors[$record_num] = lang('You must select at least one group member.');
192 192
 					return false;
193 193
 				}
194 194
 				$command = new admin_cmd_edit_group($_action == 'create' ? false : $_data['account_lid'], $_data);
195
-				if($this->dry_run) {
195
+				if ($this->dry_run) {
196 196
 					$this->results[$_action]++;
197 197
 					return true;
198 198
 				}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -104,8 +104,7 @@
 block discarded – undo
104 104
 	/**
105 105
 	 * imports entries according to given definition object.
106 106
 	 * @param resource $_stream
107
-	 * @param string $_charset
108
-	 * @param definition $_definition
107
+	 * @param importexport_definition $_definition
109 108
 	 */
110 109
 	public function import( $_stream, importexport_definition $_definition ) {
111 110
 		$import_csv = new importexport_import_csv( $_stream, array(
Please login to merge, or discard this patch.
Braces   +71 added lines, -30 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 (groups)
17 17
  */
18
-class admin_import_groups_csv implements importexport_iface_import_plugin  {
18
+class admin_import_groups_csv implements importexport_iface_import_plugin
19
+{
19 20
 
20 21
 	private static $plugin_options = array(
21 22
 		'fieldsep', 		// char
@@ -80,7 +81,8 @@  discard block
 block discarded – undo
80 81
 	 * @param string $_charset
81 82
 	 * @param definition $_definition
82 83
 	 */
83
-	public function import( $_stream, importexport_definition $_definition ) {
84
+	public function import( $_stream, importexport_definition $_definition )
85
+	{
84 86
 		$import_csv = new importexport_import_csv( $_stream, array(
85 87
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
86 88
 			'charset' => $_definition->plugin_options['charset'],
@@ -98,9 +100,12 @@  discard block
 block discarded – undo
98 100
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
99 101
 
100 102
 		//check if file has a header lines
101
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
103
+		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0)
104
+		{
102 105
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
103
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
106
+		}
107
+		elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line'])
108
+		{
104 109
 			// First method is preferred
105 110
 			$import_csv->skip_records(1);
106 111
 		}
@@ -112,22 +117,30 @@  discard block
 block discarded – undo
112 117
 		// Failures
113 118
 		$this->errors = array();
114 119
 
115
-		while ( $record = $import_csv->get_record() ) {
120
+		while ( $record = $import_csv->get_record() )
121
+		{
116 122
 			$success = false;
117 123
 			// don't import empty records
118
-			if( count( array_unique( $record ) ) < 2 ) continue;
124
+			if( count( array_unique( $record ) ) < 2 )
125
+			{
126
+				continue;
127
+			}
119 128
 
120 129
 			importexport_import_csv::convert($record, admin_egw_group_record::$types, 'admin');
121 130
 
122
-			if ( $_definition->plugin_options['conditions'] ) {
123
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
124
-					switch ( $condition['type'] ) {
131
+			if ( $_definition->plugin_options['conditions'] )
132
+			{
133
+				foreach ( $_definition->plugin_options['conditions'] as $condition )
134
+				{
135
+					switch ( $condition['type'] )
136
+					{
125 137
 						// exists
126 138
 						case 'exists' :
127 139
 							$accounts = array();
128 140
 
129 141
 							// Skip the search if the field is empty
130
-							if($record[$condition['string']] !== '') {
142
+							if($record[$condition['string']] !== '')
143
+							{
131 144
 
132 145
 								$accounts = $GLOBALS['egw']->accounts->search(array(
133 146
 									'type' => 'groups',
@@ -138,13 +151,18 @@  discard block
 block discarded – undo
138 151
 							// Search looks in the given field, but doesn't do an exact match
139 152
 							foreach ( (array)$accounts as $key => $account )
140 153
 							{
141
-								if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]);
154
+								if($account[$condition['string']] != $record[$condition['string']])
155
+								{
156
+									unset($accounts[$key]);
157
+								}
142 158
 							}
143
-							if ( is_array( $accounts ) && count( $accounts ) >= 1 ) {
159
+							if ( is_array( $accounts ) && count( $accounts ) >= 1 )
160
+							{
144 161
 								$account = current($accounts);
145 162
 								// apply action to all contacts matching this exists condition
146 163
 								$action = $condition['true'];
147
-								foreach ( (array)$accounts as $account ) {
164
+								foreach ( (array)$accounts as $account )
165
+								{
148 166
 									// Read full account, and copy needed info for accounts->save()
149 167
 									$account = $GLOBALS['egw']->accounts->read($account['account_id']);
150 168
 									$record['account_id'] = $account['account_id'];
@@ -152,7 +170,9 @@  discard block
 block discarded – undo
152 170
 									$record['account_lastname'] = $account['account_lastname'];
153 171
 									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
154 172
 								}
155
-							} else {
173
+							}
174
+							else
175
+							{
156 176
 								$action = $condition['false'];
157 177
 								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
158 178
 							}
@@ -163,13 +183,21 @@  discard block
 block discarded – undo
163 183
 							die('condition / action not supported!!!');
164 184
 							break;
165 185
 					}
166
-					if ($action['last']) break;
186
+					if ($action['last'])
187
+					{
188
+						break;
189
+					}
167 190
 				}
168
-			} else {
191
+			}
192
+			else
193
+			{
169 194
 				// unconditional insert
170 195
 				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
171 196
 			}
172
-			if($success) $count++;
197
+			if($success)
198
+			{
199
+				$count++;
200
+			}
173 201
 		}
174 202
 		return $count;
175 203
 	}
@@ -181,24 +209,29 @@  discard block
 block discarded – undo
181 209
 	 * @param array $_data contact data for the action
182 210
 	 * @return bool success or not
183 211
 	 */
184
-	private function action ( $_action, $_data, $record_num = 0 ) {
185
-		switch ($_action) {
212
+	private function action ( $_action, $_data, $record_num = 0 )
213
+	{
214
+		switch ($_action)
215
+		{
186 216
 			case 'none' :
187 217
 				return true;
188 218
 			case 'update' :
189 219
 			case 'create' :
190
-				if(count($_data['account_members']) < 1) {
220
+				if(count($_data['account_members']) < 1)
221
+				{
191 222
 					$this->errors[$record_num] = lang('You must select at least one group member.');
192 223
 					return false;
193 224
 				}
194 225
 				$command = new admin_cmd_edit_group($_action == 'create' ? false : $_data['account_lid'], $_data);
195
-				if($this->dry_run) {
226
+				if($this->dry_run)
227
+				{
196 228
 					$this->results[$_action]++;
197 229
 					return true;
198 230
 				}
199 231
 				try {
200 232
 					$command->run();
201
-				} catch (Exception $e) {
233
+				}
234
+				catch (Exception $e) {
202 235
 					$this->errors[$record_num] = $e->getMessage();
203 236
 					return false;
204 237
 				}
@@ -215,7 +248,8 @@  discard block
 block discarded – undo
215 248
 	 *
216 249
 	 * @return string name
217 250
 	 */
218
-	public static function get_name() {
251
+	public static function get_name()
252
+	{
219 253
 		return lang('Group CSV import');
220 254
 	}
221 255
 
@@ -224,7 +258,8 @@  discard block
 block discarded – undo
224 258
 	 *
225 259
 	 * @return string descriprion
226 260
 	 */
227
-	public static function get_description() {
261
+	public static function get_description()
262
+	{
228 263
 		return lang("Creates / updates user groups from CSV file");
229 264
 	}
230 265
 
@@ -233,7 +268,8 @@  discard block
 block discarded – undo
233 268
 	 *
234 269
 	 * @return string suffix (comma seperated)
235 270
 	 */
236
-	public static function get_filesuffix() {
271
+	public static function get_filesuffix()
272
+	{
237 273
 		return 'csv';
238 274
 	}
239 275
 
@@ -249,7 +285,8 @@  discard block
 block discarded – undo
249 285
 	 * 		preserv		=> array,
250 286
 	 * )
251 287
 	 */
252
-	public function get_options_etpl() {
288
+	public function get_options_etpl()
289
+	{
253 290
 		// lets do it!
254 291
 	}
255 292
 
@@ -258,7 +295,8 @@  discard block
 block discarded – undo
258 295
 	 *
259 296
 	 * @return string etemplate name
260 297
 	 */
261
-	public function get_selectors_etpl() {
298
+	public function get_selectors_etpl()
299
+	{
262 300
 		// lets do it!
263 301
 	}
264 302
 
@@ -270,7 +308,8 @@  discard block
 block discarded – undo
270 308
 	 *       record_# => warning message
271 309
 	 * )
272 310
 	 */
273
-	public function get_warnings() {
311
+	public function get_warnings()
312
+	{
274 313
 		return $this->warnings;
275 314
 	}
276 315
 
@@ -282,7 +321,8 @@  discard block
 block discarded – undo
282 321
 	 *       record_# => error message
283 322
 	 * )
284 323
 	 */
285
-	public function get_errors() {
324
+	public function get_errors()
325
+	{
286 326
 		return $this->errors;
287 327
 	}
288 328
 
@@ -294,7 +334,8 @@  discard block
 block discarded – undo
294 334
 	 *       action => record count
295 335
 	 * )
296 336
 	 */
297
-	public function get_results() {
337
+	public function get_results()
338
+	{
298 339
 		return $this->results;
299 340
 	}
300 341
 }
Please login to merge, or discard this patch.
admin/inc/class.admin_passwordreset.inc.php 1 patch
Spacing   +31 added lines, -32 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @version $Id$
11 11
  */
12 12
 
13
-include_once(EGW_INCLUDE_ROOT.'/setup/inc/hook_config.inc.php');	// functions to return password hashes
13
+include_once(EGW_INCLUDE_ROOT.'/setup/inc/hook_config.inc.php'); // functions to return password hashes
14 14
 
15 15
 use EGroupware\Api;
16 16
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	function __construct()
49 49
 	{
50
-		if($GLOBALS['egw']->acl->check('account_access',16,'admin'))
50
+		if ($GLOBALS['egw']->acl->check('account_access', 16, 'admin'))
51 51
 		{
52 52
 			$GLOBALS['egw']->redirect_link('/index.php');
53 53
 		}
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 * @param array $content =null
60 60
 	 * @param string $msg =''
61 61
 	 */
62
-	function index(array $content=null, $msg='')
62
+	function index(array $content = null, $msg = '')
63 63
 	{
64 64
 		if (!($account_repository = $GLOBALS['egw_info']['server']['account_repository']) &&
65 65
 			!($account_repository = $GLOBALS['egw_info']['server']['auth_type']))
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			{
77 77
 				Api\Header\Content::type('changed.csv', 'text/csv');
78 78
 				//echo "account_lid;account_password;account_email;account_firstname;account_lastname\n";
79
-				foreach($content['changed'] as $account)
79
+				foreach ($content['changed'] as $account)
80 80
 				{
81 81
 					echo "$account[account_lid];$account[account_password];$account[account_email];$account[account_firstname];$account[account_lastname]\n";
82 82
 				}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 			{
94 94
 				$msg = lang('You need to select as least one action!');
95 95
 			}
96
-			elseif(!$content['random_pw'] && $content['hash'] && $content['hash'] != $current_hash && $current_hash != 'plain')
96
+			elseif (!$content['random_pw'] && $content['hash'] && $content['hash'] != $current_hash && $current_hash != 'plain')
97 97
 			{
98 98
 				$msg = lang('You can only change the hash, if you set a random password or currently use plaintext passwords!');
99 99
 			}
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 			{
102 102
 				if ($content['hash'] && $content['hash'] != $current_hash)
103 103
 				{
104
-					Api\Config::save_value($account_repository.'_encryption_type',$content['hash'],'phpgwapi');
105
-					$msg = lang('Changed password hash for %1 to %2.',strtoupper($account_repository),$content['hash'])."\n";
104
+					Api\Config::save_value($account_repository.'_encryption_type', $content['hash'], 'phpgwapi');
105
+					$msg = lang('Changed password hash for %1 to %2.', strtoupper($account_repository), $content['hash'])."\n";
106 106
 					$GLOBALS['egw_info']['server'][$account_repository.'_encryption_type'] = $content['hash'];
107 107
 				}
108 108
 				$change_pw = $content['random_pw'] || $content['hash'] && $content['hash'] != $current_hash;
109 109
 				$changed = array();
110 110
 				$emailadmin = null;
111
-				foreach($content['users'] as $account_id)
111
+				foreach ($content['users'] as $account_id)
112 112
 				{
113 113
 					if (($account = $GLOBALS['egw']->accounts->read($account_id)))
114 114
 					{
@@ -118,20 +118,20 @@  discard block
 block discarded – undo
118 118
 							$password = Api\Auth::randomstring(8);
119 119
 							$old_password = null;
120 120
 						}
121
-						elseif ($change_pw && !preg_match('/^{plain}/i',$account['account_pwd']) &&
121
+						elseif ($change_pw && !preg_match('/^{plain}/i', $account['account_pwd']) &&
122 122
 							($current_hash != 'plain' || $current_hash == 'plain' && $account['account_pwd'][0] == '{'))
123 123
 						{
124
-							$msg .= lang('Account "%1" has NO plaintext password!',$account['account_lid'])."\n";
124
+							$msg .= lang('Account "%1" has NO plaintext password!', $account['account_lid'])."\n";
125 125
 							continue;
126 126
 						}
127 127
 						else
128 128
 						{
129
-							$old_password = $password = preg_replace('/^{plain}/i','',$account['account_pwd']);
129
+							$old_password = $password = preg_replace('/^{plain}/i', '', $account['account_pwd']);
130 130
 						}
131 131
 						// change password, if requested
132
-						if ($change_pw && !$GLOBALS['egw']->auth->change_password($old_password,$password,$account_id))
132
+						if ($change_pw && !$GLOBALS['egw']->auth->change_password($old_password, $password, $account_id))
133 133
 						{
134
-							$msg .= lang('Failed to change password for account "%1"!',$account['account_lid'])."\n";
134
+							$msg .= lang('Failed to change password for account "%1"!', $account['account_lid'])."\n";
135 135
 							continue;
136 136
 						}
137 137
 						// force password change on next login
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
 						// allow or forbid to change password, if requested
144 144
 						if ((string)$content['changepassword'] !== '')
145 145
 						{
146
-							if(!$content['changepassword'])
146
+							if (!$content['changepassword'])
147 147
 							{
148
-								$GLOBALS['egw']->acl->add_repository('preferences','nopasswordchange',$account_id,1);
148
+								$GLOBALS['egw']->acl->add_repository('preferences', 'nopasswordchange', $account_id, 1);
149 149
 							}
150 150
 							else
151 151
 							{
152
-								$GLOBALS['egw']->acl->delete_repository('preferences','nopasswordchange',$account_id);
152
+								$GLOBALS['egw']->acl->delete_repository('preferences', 'nopasswordchange', $account_id);
153 153
 							}
154 154
 						}
155 155
 						$account['account_password'] = $password;
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 									break;
167 167
 								}
168 168
 							}
169
-							if (($userData = $emailadmin->getUserData ($account_id)))
169
+							if (($userData = $emailadmin->getUserData($account_id)))
170 170
 							{
171 171
 								if ((string)$content['mail']['activate'] !== '')
172 172
 								{
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 								{
181 181
 									$userData['mailLocalAddress'] = preg_replace('/@'.preg_quote($emailadmin->acc_domain).'$/', '@'.$content['mail']['domain'], $userData['mailLocalAddress']);
182 182
 
183
-									foreach($userData['mailAlternateAddress'] as &$alias)
183
+									foreach ($userData['mailAlternateAddress'] as &$alias)
184 184
 									{
185 185
 										$alias = preg_replace('/@'.preg_quote($emailadmin->acc_domain).'$/', '@'.$content['mail']['domain'], $alias);
186 186
 									}
@@ -197,20 +197,20 @@  discard block
 block discarded – undo
197 197
 
198 198
 						if ($content['notify'])
199 199
 						{
200
-							if (strpos($account['account_email'],'@') === false)
200
+							if (strpos($account['account_email'], '@') === false)
201 201
 							{
202
-								$msg .= lang('Account "%1" has no email address --> not notified!',$account['account_lid']);
202
+								$msg .= lang('Account "%1" has no email address --> not notified!', $account['account_lid']);
203 203
 								continue;
204 204
 							}
205 205
 							$send = new send();
206
-							$send->AddAddress($account['account_email'],$account['account_fullname']);
206
+							$send->AddAddress($account['account_email'], $account['account_fullname']);
207 207
 							$replacements = array();
208
-							foreach($this->replacements as $name => $label)
208
+							foreach ($this->replacements as $name => $label)
209 209
 							{
210 210
 								$replacements['$$'.$name.'$$'] = $account['account_'.$name];
211 211
 							}
212
-							$send->Subject = strtr($content['subject'],$replacements);
213
-							$send->Body = strtr($content['body'],$replacements);
212
+							$send->Subject = strtr($content['subject'], $replacements);
213
+							$send->Body = strtr($content['body'], $replacements);
214 214
 							if (!empty($GLOBALS['egw_info']['user']['account_email']))
215 215
 							{
216 216
 								$send->From = $GLOBALS['egw_info']['user']['account_email'];
@@ -223,15 +223,15 @@  discard block
 block discarded – undo
223 223
 							catch (Exception $e)
224 224
 							{
225 225
 								unset ($e);
226
-								$msg .= lang('Notifying account "%1" %2 failed!',$account['account_lid'],$account['account_email']).
227
-									': '.strip_tags(str_replace('<p>',"\n",$send->ErrorInfo))."\n";
226
+								$msg .= lang('Notifying account "%1" %2 failed!', $account['account_lid'], $account['account_email']).
227
+									': '.strip_tags(str_replace('<p>', "\n", $send->ErrorInfo))."\n";
228 228
 							}
229 229
 						}
230 230
 					}
231 231
 				}
232 232
 				if ($changed)
233 233
 				{
234
-					$msg .= lang('Passwords and/or attributes of %1 accounts changed',count($changed));
234
+					$msg .= lang('Passwords and/or attributes of %1 accounts changed', count($changed));
235 235
 				}
236 236
 			}
237 237
 		}
@@ -239,12 +239,11 @@  discard block
 block discarded – undo
239 239
 		$content['account_repository'] = $account_repository;
240 240
 		$content['current_hash'] = $content['hash'] ? $content['hash'] : $current_hash;
241 241
 		$sel_options['hash'] = $account_repository == 'sql' ?
242
-			sql_passwdhashes($GLOBALS['egw_info']['server'],true) :
243
-			passwdhashes($GLOBALS['egw_info']['server'],true);
244
-		$sel_options['activate'] = array('Deactivate','Activate');
242
+			sql_passwdhashes($GLOBALS['egw_info']['server'], true) : passwdhashes($GLOBALS['egw_info']['server'], true);
243
+		$sel_options['activate'] = array('Deactivate', 'Activate');
245 244
 
246 245
 		$content['replacements'] = array();
247
-		foreach($this->replacements as $name => $label)
246
+		foreach ($this->replacements as $name => $label)
248 247
 		{
249 248
 			$content['replacements'][] = array(
250 249
 				'name'  => '$$'.$name.'$$',
@@ -256,7 +255,7 @@  discard block
 block discarded – undo
256 255
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Bulk password reset');
257 256
 
258 257
 		$tmpl = new Api\Etemplate('admin.passwordreset');
259
-		$tmpl->exec('admin.admin_passwordreset.index',$content,$sel_options,$readonlys,array(
258
+		$tmpl->exec('admin.admin_passwordreset.index', $content, $sel_options, $readonlys, array(
260 259
 			'changed' => $changed,
261 260
 		));
262 261
 	}
Please login to merge, or discard this patch.
admin/inc/class.admin_wizard_import_users_csv.inc.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
 	function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
60 60
 	{
61 61
 		$result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv);
62
-		$content['msg'] .= "\n*" ;
62
+		$content['msg'] .= "\n*";
63 63
 		
64 64
 		return $result;
65 65
 	}
Please login to merge, or discard this patch.
admin/phpinfo.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 );
16 16
 include('../header.inc.php');
17 17
 
18
-if ($GLOBALS['egw']->acl->check('info_access',1,'admin'))
18
+if ($GLOBALS['egw']->acl->check('info_access', 1, 'admin'))
19 19
 {
20 20
 	$GLOBALS['egw']->redirect_link('/index.php');
21 21
 }
Please login to merge, or discard this patch.
logout.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,34 +28,34 @@
 block discarded – undo
28 28
 
29 29
 $verified = $GLOBALS['egw']->session->verify();
30 30
 
31
-if(!($redirectTarget = Api\Cache::getSession('login', 'referer')))
31
+if (!($redirectTarget = Api\Cache::getSession('login', 'referer')))
32 32
 {
33 33
 	$redirectTarget = $GLOBALS['egw_info']['server']['webserver_url'].'/login.php?cd=1&domain='.$GLOBALS['egw_info']['user']['domain'];
34 34
 }
35
-elseif(strpos($redirectTarget, '[?&]cd=') !== false)
35
+elseif (strpos($redirectTarget, '[?&]cd=') !== false)
36 36
 {
37 37
 	$redirectTarget = preg_replace('/([?&])cd=[^&]+/', '$1cd=1', $redirectTarget);
38 38
 }
39 39
 
40
-if($verified)
40
+if ($verified)
41 41
 {
42 42
 	Api\Hooks::process('logout');
43
-	$GLOBALS['egw']->session->destroy($GLOBALS['sessionid'],$GLOBALS['kp3']);
43
+	$GLOBALS['egw']->session->destroy($GLOBALS['sessionid'], $GLOBALS['kp3']);
44 44
 }
45 45
 
46
-Api\Session::egw_setcookie('eGW_remember','',0,'/');
46
+Api\Session::egw_setcookie('eGW_remember', '', 0, '/');
47 47
 Api\Session::egw_setcookie('sessionid');
48 48
 Api\Session::egw_setcookie('kp3');
49 49
 Api\Session::egw_setcookie('domain');
50 50
 
51
-if($GLOBALS['egw_info']['server']['auth_type'] == 'cas')
51
+if ($GLOBALS['egw_info']['server']['auth_type'] == 'cas')
52 52
 {
53 53
 	require_once('CAS/CAS.php');
54 54
 
55 55
 	phpCAS::client(CAS_VERSION_2_0,
56 56
 								$GLOBALS['egw_info']['server']['cas_server_host_name'],
57
-								(int) $GLOBALS['egw_info']['server']['cas_server_port'],
58
-								$GLOBALS['egw_info']['server']['cas_server_uri'] );
57
+								(int)$GLOBALS['egw_info']['server']['cas_server_port'],
58
+								$GLOBALS['egw_info']['server']['cas_server_uri']);
59 59
 	phpCAS::logout(array('url'=>$GLOBALS['egw_info']['server']['webserver_url'].'/login.php?cd=1&domain='.$GLOBALS['egw_info']['user']['domain']));
60 60
 }
61 61
 
Please login to merge, or discard this patch.
share.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 	'flags' => array(
19 19
 		'disable_Template_class' => true,
20 20
 		'noheader'  => true,
21
-		'nonavbar' => 'always',	// true would cause eTemplate to reset it to false for non-popups!
21
+		'nonavbar' => 'always', // true would cause eTemplate to reset it to false for non-popups!
22 22
 		'currentapp' => 'filemanager',
23 23
 		'autocreate_session_callback' => 'EGroupware\\Api\\Vfs\\Sharing::create_session',
24
-		'no_exception_handler' => 'basic_auth',	// we use a basic auth exception handler (sends exception message as basic auth realm)
24
+		'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm)
25 25
 	)
26 26
 );
27 27
 
@@ -29,6 +29,6 @@  discard block
 block discarded – undo
29 29
 
30 30
 if (!$GLOBALS['egw']->sharing)
31 31
 {
32
-	Sharing::create_session(true);	// true = mount into existing session
32
+	Sharing::create_session(true); // true = mount into existing session
33 33
 }
34 34
 $GLOBALS['egw']->sharing->ServeRequest();
Please login to merge, or discard this patch.
files/webdav.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 {
35 35
 	if (isset($_GET['auth']))
36 36
 	{
37
-		list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) = explode(':',base64_decode($_GET['auth']),2);
37
+		list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode($_GET['auth']), 2);
38 38
 	}
39 39
 	return Api\Header\Authenticate::autocreate_session_callback($account);
40 40
 }
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 		'noheader'  => True,
46 46
 		'currentapp' => preg_match('|/webdav.php/apps/([A-Za-z0-9_-]+)/|', $_SERVER['REQUEST_URI'], $matches) ? $matches[1] : 'filemanager',
47 47
 		'autocreate_session_callback' => 'check_access',
48
-		'no_exception_handler' => 'basic_auth',	// we use a basic auth exception handler (sends exception message as basic auth realm)
49
-		'auth_realm' => 'EGroupware WebDAV server',	// cant use Vfs\WebDAV::REALM as autoloading and include path not yet setup!
48
+		'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm)
49
+		'auth_realm' => 'EGroupware WebDAV server', // cant use Vfs\WebDAV::REALM as autoloading and include path not yet setup!
50 50
 	)
51 51
 );
52 52
 
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 
75 75
 // temporary mount ownCloud default /clientsync as /home/$user, if not explicitly mounted
76 76
 // so ownCloud dir contains users home-dir by default
77
-if (strpos($_SERVER['REQUEST_URI'],'/webdav.php/clientsync') !== false &&
78
-	($fstab=Vfs::mount()) && !isset($fstab['/clientsync']))
77
+if (strpos($_SERVER['REQUEST_URI'], '/webdav.php/clientsync') !== false &&
78
+	($fstab = Vfs::mount()) && !isset($fstab['/clientsync']))
79 79
 {
80 80
 	$is_root_backup = Vfs::$is_root;
81 81
 	Vfs::$is_root = true;
82
-	$ok = Vfs::mount($url='vfs://default/home/$user', $clientsync='/clientsync', null, false);
82
+	$ok = Vfs::mount($url = 'vfs://default/home/$user', $clientsync = '/clientsync', null, false);
83 83
 	Vfs::$is_root = $is_root_backup;
84 84
 	//error_log("mounting ownCloud default '$clientsync' as '$url' ".($ok ? 'successful' : 'failed!'));
85 85
 }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
  * Create a session or if the user has no account return authenticate header and 401 Unauthorized
32 32
  *
33 33
  * @param array &$account
34
- * @return int session-id
34
+ * @return string session-id
35 35
  */
36 36
 function check_access(&$account)
37 37
 {
Please login to merge, or discard this patch.
timesheet/setup/setup.inc.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
 
14 14
 if (!defined('TIMESHEET_APP'))
15 15
 {
16
-	define('TIMESHEET_APP','timesheet');
16
+	define('TIMESHEET_APP', 'timesheet');
17 17
 }
18 18
 
19 19
 $setup_info[TIMESHEET_APP]['name']      = TIMESHEET_APP;
20 20
 $setup_info[TIMESHEET_APP]['version']   = '16.1';
21 21
 $setup_info[TIMESHEET_APP]['app_order'] = 5;
22
-$setup_info[TIMESHEET_APP]['tables']    = array('egw_timesheet','egw_timesheet_extra');
22
+$setup_info[TIMESHEET_APP]['tables']    = array('egw_timesheet', 'egw_timesheet_extra');
23 23
 $setup_info[TIMESHEET_APP]['enable']    = 1;
24 24
 $setup_info[TIMESHEET_APP]['index']     = 'timesheet.timesheet_ui.index&ajax=true';
25 25
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	'name'  => 'Ralf Becker',
29 29
 	'email' => '[email protected]'
30 30
 );
31
-$setup_info[TIMESHEET_APP]['license']  = 'GPL';
31
+$setup_info[TIMESHEET_APP]['license'] = 'GPL';
32 32
 $setup_info[TIMESHEET_APP]['description'] =
33 33
 'Tracking times and other activities for the Projectmanager.';
34 34
 $setup_info[TIMESHEET_APP]['note'] =
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 
39 39
 $setup_info['resources']['depends'][]	= array(
40 40
 	 'appname' => 'api',
41
-	 'versions' => Array('16.1')
41
+	 'versions' => array('16.1')
42 42
 );
43 43
 
44 44
 
Please login to merge, or discard this patch.