Skip to content
This repository was archived by the owner on Oct 29, 2020. It is now read-only.

Commit ab3ec96

Browse files
committed
Update docblocks and formatting.
1 parent 696a915 commit ab3ec96

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

lib/modules/dosomething/dosomething_northstar/dosomething_northstar.module

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ function dosomething_northstar_register_user($form_state) {
108108
}
109109

110110
/**
111-
* Build the drupal_http_request object for nothstar calls.
112-
* This will be depricated once guzzle is fixed...
111+
* Build the drupal_http_request object for Northstar calls.
112+
* @returns array
113113
*/
114114
function _dosomething_northstar_build_http_client() {
115115
$base_url = NORTHSTAR_URL;
@@ -131,7 +131,10 @@ function _dosomething_northstar_build_http_client() {
131131
}
132132

133133
/**
134-
* Send user profile updates to northstar.
134+
* Update a user's existing Northstar profile based on
135+
* their Drupal ID.
136+
*
137+
* @return void
135138
*/
136139
function dosomething_northstar_update_user($form_state) {
137140
$user = $form_state['user'];
@@ -159,6 +162,7 @@ function dosomething_northstar_update_user($form_state) {
159162

160163
/**
161164
* If the log is enabled, log this request to the database.
165+
* Get user profile data from Northstar for the given Drupal ID.
162166
*
163167
* @param string $op - label for the operation being performed
164168
* @param object $user - the Drupal user
@@ -188,9 +192,7 @@ function dosomething_northstar_log_request($op, $user, $request_body, $response)
188192
}
189193

190194
/**
191-
* Get user data from northstar.
192-
*
193-
* @param int $id Drupal user id.
195+
* @param int $drupal_id Drupal user id.
194196
* @return object
195197
*/
196198
function dosomething_northstar_get_northstar_user($id) {
@@ -221,11 +223,10 @@ function dosomething_northstar_get_northstar_user($id) {
221223
}
222224

223225
/**
224-
* Build a user json object, that's accepted by Northstar.
225-
*
226-
* @param obj $user
227-
* Drupal user object
226+
* Build a user JSON object in the format that Northstar expects.
228227
*
228+
* @param $user - Drupal user object
229+
* @return array
229230
*/
230231
function dosomething_northstar_build_ns_user($user, $form_state) {
231232
// Optional fields

lib/modules/dosomething/dosomething_user/dosomething_user.module

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ function dosomething_user_form_alter(&$form, $form_state, $form_id) {
268268
_dosomething_user_add_signup_data($form);
269269
}
270270
else {
271+
// If this is not the registration form, then register submit handler
272+
// to update that existing Northstar user by their Drupal ID.
271273
$form['#submit'][] = 'dosomething_user_update_user';
272274
}
273275

@@ -424,13 +426,13 @@ function dosomething_user_validate_address_field($form, &$form_state) {
424426
}
425427
}
426428

427-
/**
429+
/**
428430
* Validates address for dosomething_user_info_form
429431
*
430432
* @param array $form
431-
* A drupal form.
433+
* A drupal form.
432434
* @param array $form_state
433-
* A drupal form_state array.
435+
* A drupal form_state array.
434436
*/
435437
function dosomething_user_validate_info_form_address ($form, &$form_state) {
436438
$first_name = $form_state['input']['first_name'];
@@ -439,7 +441,7 @@ function dosomething_user_validate_info_form_address ($form, &$form_state) {
439441
'country' => 'US',
440442
'thoroughfare' => $form_state['input']['street'],
441443
'premise' => $form_state['input']['sub_street'],
442-
'locality' => $form_state['input']['city'],
444+
'locality' => $form_state['input']['city'],
443445
'administrative_area' => $form_state['input']['state'],
444446
'postal_code' => $form_state['input']['zipcode'],
445447
];
@@ -466,7 +468,7 @@ function dosomething_user_validate_info_form_address ($form, &$form_state) {
466468
}
467469

468470
/**
469-
* Validates that password is 6 or more characters long.
471+
* Validates that password is 6 or more characters long.
470472
*
471473
* @param array $form
472474
* A drupal form.
@@ -588,9 +590,15 @@ function dosomething_user_user_login(&$form_state, $account) {
588590

589591
/**
590592
*
593+
* Custom form submission handler to update an existing user.
594+
* Triggered when making changes on the user profile form.
595+
*
596+
* @param $form
597+
* @param $form_state
591598
*/
592599
function dosomething_user_update_user($form, &$form_state) {
593600
if (!module_exists('dosomething_northstar')) { return; }
601+
594602
// Forward user updates into Northstar.
595603
dosomething_northstar_update_user($form_state);
596604
}
@@ -775,7 +783,8 @@ function dosomething_user_is_old_person($user = NULL) {
775783
}
776784

777785
/**
778-
* Custom login submission handler.
786+
* Custom login submission handler. This does _not_ trigger on log-ins
787+
* that happen post-registration.
779788
*/
780789
function dosomething_user_login_submit($form, &$form_state) {
781790
// Trigger an analytics event on login
@@ -815,7 +824,7 @@ function dosomething_user_authentication_submit($form, &$form_state) {
815824
dosomething_northstar_register_user($form_state);
816825
}
817826

818-
// After all logins, except reportback pages redirect to page user was just on.
827+
// After all log-ins, except reportback pages redirect to page user was just on.
819828
if (isset($source) && stripos($source, 'reportback') > 0) {
820829
$form_state['redirect'] = drupal_get_path_alias($_SERVER['HTTP_REFERER']);
821830
}
@@ -1402,7 +1411,7 @@ function dosomething_user_info_form($form, &$form_state, $account) {
14021411
'#type' => 'textfield',
14031412
'#default_value' => $birthday,
14041413
'#description' => t("Format: M/D/YYYY"),
1405-
'#field_suffix' => 'User age: ' . $age,
1414+
'#field_suffix' => 'User age: ' . $age,
14061415
);
14071416
$form['picture'] = array(
14081417
'#type' => 'fieldset',

0 commit comments

Comments
 (0)