@@ -163,37 +163,8 @@ function dosomething_northstar_update_user($form_state) {
163163}
164164
165165/**
166- * If the log is enabled, log this request to the database.
167166 * Get user profile data from Northstar for the given Drupal ID.
168167 *
169- * @param string $op - label for the operation being performed
170- * @param object $user - the Drupal user
171- * @param array $request_body - the body of the request
172- * @param string $response - response JSON
173- */
174- function dosomething_northstar_log_request($op, $user, $request_body, $response) {
175- if (!variable_get('dosomething_northstar_log')) return;
176-
177- // Don't log plaintext passwords.
178- if (isset($request_body['password'])) {
179- $request_body['password'] = '*****';
180- }
181-
182- db_insert('dosomething_northstar_request_log')
183- ->fields([
184- 'op' => $op,
185- 'uid' => $user->uid,
186- 'user_lang' => $user->language,
187- 'user_country' => $user->field_address[LANGUAGE_NONE][0]['country'],
188- 'fastly_country' => dosomething_settings_get_geo_country_code(),
189- 'request_values' => json_encode($request_body),
190- 'response_code' => $response->code,
191- 'response_values' => $response->data,
192- ])
193- ->execute();
194- }
195-
196- /**
197168 * @param int $drupal_id Drupal user id.
198169 * @return object
199170 */
@@ -280,6 +251,33 @@ function dosomething_northstar_build_ns_user($user, $form_state) {
280251 return $ns_user;
281252}
282253
254+ /**
255+ * If the log is enabled, log this request to the database.
256+ *
257+ * @param string $op - label for the operation being performed
258+ * @param object $user - the Drupal user
259+ * @param array $request_body - the body of the request
260+ * @param string $response - response JSON
261+ */
262+ function dosomething_northstar_log_request($op, $user, $request_body, $response) {
263+ if (!variable_get('dosomething_northstar_log')) return;
283264
265+ // Don't log plaintext passwords.
266+ if (isset($request_body['password'])) {
267+ $request_body['password'] = '*****';
268+ }
284269
270+ db_insert('dosomething_northstar_request_log')
271+ ->fields([
272+ 'op' => $op,
273+ 'uid' => $user->uid,
274+ 'user_lang' => $user->language,
275+ 'user_country' => $user->field_address[LANGUAGE_NONE][0]['country'],
276+ 'fastly_country' => dosomething_settings_get_geo_country_code(),
277+ 'request_values' => json_encode($request_body),
278+ 'response_code' => $response->code,
279+ 'response_values' => $response->data,
280+ ])
281+ ->execute();
285282}
283+
0 commit comments