@@ -104,26 +104,46 @@ function _dosomething_northstar_build_http_client() {
104104/**
105105 * Send user profile updates to northstar.
106106 */
107+ // function dosomething_northstar_update_user($form_state) {
108+ // $user = $form_state['user'];
109+ // $id = $user->uid;
110+
111+ // $ns_user = dosomething_northstar_build_ns_user($user, $form_state);
112+
113+ // $northstar = new Northstar();
114+ // $client = _dosomething_northstar_build_http_client();
115+
116+ // $northstar_user_info = dosomething_northstar_get_northstar_user($id);
117+ // $northstar_user_info = json_decode($northstar_user_info->data, TRUE);
118+ // $northstar_user_info = (object) $northstar_user_info['data'][0];
119+ // $ns_id = $northstar_user_info->_id;
120+
121+ // $response = drupal_http_request($client['base_url'] . '/users/' . $ns_id, array(
122+ // 'headers' => $client['headers'],
123+ // 'method' => 'PUT',
124+ // 'data' => json_encode($ns_user),
125+ // ));
126+
127+ // if ($response->code === '200' && module_exists('stathat')) {
128+ // stathat_send_ez_count('drupal - Northstar - user updated - count', 1);
129+ // }
130+ // elseif ($response->code !== '200') {
131+ // watchdog('dosomething_northstar', 'User not updated : ' . $response->code, NULL, WATCHDOG_ERROR);
132+ // }
133+
134+ // }
135+
107136function dosomething_northstar_update_user($form_state) {
108137 $user = $form_state['user'];
109- $id = $user->uid;
110-
111138 $ns_user = dosomething_northstar_build_ns_user($user, $form_state);
112139
113140 $northstar = new Northstar();
114141 $client = _dosomething_northstar_build_http_client();
115-
116- $northstar_user_info = dosomething_northstar_get_northstar_user($id);
117- $northstar_user_info = json_decode($northstar_user_info->data, true);
118- $northstar_user_info = (object) $northstar_user_info['data'][0];
119- $ns_id = $northstar_user_info->_id;
120-
121- $response = drupal_http_request($client['base_url'] . '/users/' . $ns_id, array(
142+ $response = drupal_http_request($client['base_url'] . '/users', array(
122143 'headers' => $client['headers'],
123- 'method' => 'PUT ',
144+ 'method' => 'POST ',
124145 'data' => json_encode($ns_user),
125146 ));
126-
127147 if ($response->code === '200' && module_exists('stathat')) {
128148 stathat_send_ez_count('drupal - Northstar - user updated - count', 1);
129149 }
0 commit comments