{"action":"created","comment":{"url":"https://api.github.com/repos/DoSomething/phoenix/pulls/comments/40569133","id":40569133,"diff_hunk":"@@ -524,6 +517,51 @@ function dosomething_user_new_user($form, &$form_state) {\n }\n \n /**\n+ * Sets the user global attributes and sends them to Northstar.\n+ *\n+ * @param object $account\n+ *   The account to return value for. If NULL, uses global $user.\n+ * @param string $country_code\n+ *   The country code where the user currently resides. If NULL, uses\n+ *   the headers in current request.\n+ * @param string $language\n+ *   The new language to set on the user. If NULL, gets the matching\n+ *   language or defaults.\n+ */\n+function dosomething_user_set_global_attributes($user = NULL, $country_code = NULL, $language = NULL) {\n+  if ($user == NULL) {\n+    global $user;\n+  }\n+  if ($country_code == NULL) {\n+    $country_code = dosomething_settings_get_geo_country_code();\n+    // If no Fastly headers set, use US EN\n+    if ($country_code == NULL) {\n+      $language = 'en';\n+    }\n+  }\n+  if ($language == NULL) {","path":"lib/modules/dosomething/dosomething_user/dosomething_user.module","position":42,"original_position":42,"commit_id":"bf9f2c445dfe6876240ee64fef30b9062e0efe6f","original_commit_id":"bf9f2c445dfe6876240ee64fef30b9062e0efe6f","user":{"login":"angaither","id":645205,"avatar_url":"https://avatars.githubusercontent.com/u/645205?v=3","gravatar_id":"","url":"https://api.github.com/users/angaither","html_url":"https://github.com/angaither","followers_url":"https://api.github.com/users/angaither/followers","following_url":"https://api.github.com/users/angaither/following{/other_user}","gists_url":"https://api.github.com/users/angaither/gists{/gist_id}","starred_url":"https://api.github.com/users/angaither/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angaither/subscriptions","organizations_url":"https://api.github.com/users/angaither/orgs","repos_url":"https://api.github.com/users/angaither/repos","events_url":"https://api.github.com/users/angaither/events{/privacy}","received_events_url":"https://api.github.com/users/angaither/received_events","type":"User","site_admin":false},"body":"can you add a comment block above explaining the logic that happens below?","created_at":"2015-09-28T15:56:32Z","updated_at":"2015-09-28T15:56:32Z","html_url":"https://github.com/DoSomething/phoenix/pull/5266#discussion_r40569133","pull_request_url":"https://api.github.com/repos/DoSomething/phoenix/pulls/5266","_links":{"self":{"href":"https://api.github.com/repos/DoSomething/phoenix/pulls/comments/40569133"},"html":{"href":"https://github.com/DoSomething/phoenix/pull/5266#discussion_r40569133"},"pull_request":{"href":"https://api.github.com/repos/DoSomething/phoenix/pulls/5266"}}},"pull_request":{"url":"https://api.github.com/repos/DoSomething/phoenix/pulls/5266","id":46172900,"html_url":"https://github.com/DoSomething/phoenix/pull/5266","diff_url":"https://github.com/DoSomething/phoenix/pull/5266.diff","patch_url":"https://github.com/DoSomething/phoenix/pull/5266.patch","issue_url":"https://api.github.com/repos/DoSomething/phoenix/issues/5266","number":5266,"state":"open","locked":false,"title":"Updates global ","user":{"login":"deadlybutter","id":897368,"avatar_url":"https://avatars.githubusercontent.com/u/897368?v=3","gravatar_id":"","url":"https://api.github.com/users/deadlybutter","html_url":"https://github.com/deadlybutter","followers_url":"https://api.github.com/users/deadlybutter/followers","following_url":"https://api.github.com/users/deadlybutter/following{/other_user}","gists_url":"https://api.github.com/users/deadlybutter/gists{/gist_id}","starred_url":"https://api.github.com/users/deadlybutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deadlybutter/subscriptions","organizations_url":"https://api.github.com/users/deadlybutter/orgs","repos_url":"https://api.github.com/users/deadlybutter/repos","events_url":"https://api.github.com/users/deadlybutter/events{/privacy}","received_events_url":"https://api.github.com/users/deadlybutter/received_events","type":"User","site_admin":false},"body":"#### What's this PR do?\r\nUpdates the logic used to seta users language upon registering. See here for summary of what was discussed in #global https://github.com/DoSomething/phoenix/issues/5168#issuecomment-143766220\r\n\r\nAll of this was also moved into a new function per @angaither 's suggestion here https://github.com/DoSomething/phoenix/issues/5263#issuecomment-143743816\r\n\r\nAlso updates dosomething_global_convert_country_to_language to return null rather than 'en'\r\n\r\n#### Where should the reviewer start?\r\ndosomething_user_set_global_attributes();\r\n\r\n#### How should this be manually tested?\r\nCreate new users and spoof there country codes, check there languages to make sure they match. Also try making a user without a country code header and make sure it goes to English. \r\n\r\n#### Any background context you want to provide?\r\nSlack discussion from here and down https://dosomething.slack.com/archives/global/p1443451428000871\r\n\r\n#### What are the relevant tickets?\r\nFixes #5168 \r\nUnblocks #5263\r\n \r\nAlso @DeeZone this is going to break your logic here for users coming from countries outside US/MX/BR https://github.com/DoSomething/phoenix/blob/cf11f1b791a9668ae73f403b8121dc055156b447/lib/modules/dosomething/dosomething_mbp/dosomething_mbp.module#L235\r\n","created_at":"2015-09-28T15:44:34Z","updated_at":"2015-09-28T15:56:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"17da5503e8f62c54af63eea26a93e788caaa5258","assignee":{"login":"angaither","id":645205,"avatar_url":"https://avatars.githubusercontent.com/u/645205?v=3","gravatar_id":"","url":"https://api.github.com/users/angaither","html_url":"https://github.com/angaither","followers_url":"https://api.github.com/users/angaither/followers","following_url":"https://api.github.com/users/angaither/following{/other_user}","gists_url":"https://api.github.com/users/angaither/gists{/gist_id}","starred_url":"https://api.github.com/users/angaither/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angaither/subscriptions","organizations_url":"https://api.github.com/users/angaither/orgs","repos_url":"https://api.github.com/users/angaither/repos","events_url":"https://api.github.com/users/angaither/events{/privacy}","received_events_url":"https://api.github.com/users/angaither/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/DoSomething/phoenix/pulls/5266/commits","review_comments_url":"https://api.github.com/repos/DoSomething/phoenix/pulls/5266/comments","review_comment_url":"https://api.github.com/repos/DoSomething/phoenix/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DoSomething/phoenix/issues/5266/comments","statuses_url":"https://api.github.com/repos/DoSomething/phoenix/statuses/bf9f2c445dfe6876240ee64fef30b9062e0efe6f","head":{"label":"deadlybutter:5168","ref":"5168","sha":"bf9f2c445dfe6876240ee64fef30b9062e0efe6f","user":{"login":"deadlybutter","id":897368,"avatar_url":"https://avatars.githubusercontent.com/u/897368?v=3","gravatar_id":"","url":"https://api.github.com/users/deadlybutter","html_url":"https://github.com/deadlybutter","followers_url":"https://api.github.com/users/deadlybutter/followers","following_url":"https://api.github.com/users/deadlybutter/following{/other_user}","gists_url":"https://api.github.com/users/deadlybutter/gists{/gist_id}","starred_url":"https://api.github.com/users/deadlybutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deadlybutter/subscriptions","organizations_url":"https://api.github.com/users/deadlybutter/orgs","repos_url":"https://api.github.com/users/deadlybutter/repos","events_url":"https://api.github.com/users/deadlybutter/events{/privacy}","received_events_url":"https://api.github.com/users/deadlybutter/received_events","type":"User","site_admin":false},"repo":{"id":26186134,"name":"dosomething","full_name":"deadlybutter/dosomething","owner":{"login":"deadlybutter","id":897368,"avatar_url":"https://avatars.githubusercontent.com/u/897368?v=3","gravatar_id":"","url":"https://api.github.com/users/deadlybutter","html_url":"https://github.com/deadlybutter","followers_url":"https://api.github.com/users/deadlybutter/followers","following_url":"https://api.github.com/users/deadlybutter/following{/other_user}","gists_url":"https://api.github.com/users/deadlybutter/gists{/gist_id}","starred_url":"https://api.github.com/users/deadlybutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deadlybutter/subscriptions","organizations_url":"https://api.github.com/users/deadlybutter/orgs","repos_url":"https://api.github.com/users/deadlybutter/repos","events_url":"https://api.github.com/users/deadlybutter/events{/privacy}","received_events_url":"https://api.github.com/users/deadlybutter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/deadlybutter/dosomething","description":"A Drupal 7 distribution that powers the DoSomething.org web platform.","fork":true,"url":"https://api.github.com/repos/deadlybutter/dosomething","forks_url":"https://api.github.com/repos/deadlybutter/dosomething/forks","keys_url":"https://api.github.com/repos/deadlybutter/dosomething/keys{/key_id}","collaborators_url":"https://api.github.com/repos/deadlybutter/dosomething/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/deadlybutter/dosomething/teams","hooks_url":"https://api.github.com/repos/deadlybutter/dosomething/hooks","issue_events_url":"https://api.github.com/repos/deadlybutter/dosomething/issues/events{/number}","events_url":"https://api.github.com/repos/deadlybutter/dosomething/events","assignees_url":"https://api.github.com/repos/deadlybutter/dosomething/assignees{/user}","branches_url":"https://api.github.com/repos/deadlybutter/dosomething/branches{/branch}","tags_url":"https://api.github.com/repos/deadlybutter/dosomething/tags","blobs_url":"https://api.github.com/repos/deadlybutter/dosomething/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/deadlybutter/dosomething/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/deadlybutter/dosomething/git/refs{/sha}","trees_url":"https://api.github.com/repos/deadlybutter/dosomething/git/trees{/sha}","statuses_url":"https://api.github.com/repos/deadlybutter/dosomething/statuses/{sha}","languages_url":"https://api.github.com/repos/deadlybutter/dosomething/languages","stargazers_url":"https://api.github.com/repos/deadlybutter/dosomething/stargazers","contributors_url":"https://api.github.com/repos/deadlybutter/dosomething/contributors","subscribers_url":"https://api.github.com/repos/deadlybutter/dosomething/subscribers","subscription_url":"https://api.github.com/repos/deadlybutter/dosomething/subscription","commits_url":"https://api.github.com/repos/deadlybutter/dosomething/commits{/sha}","git_commits_url":"https://api.github.com/repos/deadlybutter/dosomething/git/commits{/sha}","comments_url":"https://api.github.com/repos/deadlybutter/dosomething/comments{/number}","issue_comment_url":"https://api.github.com/repos/deadlybutter/dosomething/issues/comments{/number}","contents_url":"https://api.github.com/repos/deadlybutter/dosomething/contents/{+path}","compare_url":"https://api.github.com/repos/deadlybutter/dosomething/compare/{base}...{head}","merges_url":"https://api.github.com/repos/deadlybutter/dosomething/merges","archive_url":"https://api.github.com/repos/deadlybutter/dosomething/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/deadlybutter/dosomething/downloads","issues_url":"https://api.github.com/repos/deadlybutter/dosomething/issues{/number}","pulls_url":"https://api.github.com/repos/deadlybutter/dosomething/pulls{/number}","milestones_url":"https://api.github.com/repos/deadlybutter/dosomething/milestones{/number}","notifications_url":"https://api.github.com/repos/deadlybutter/dosomething/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/deadlybutter/dosomething/labels{/name}","releases_url":"https://api.github.com/repos/deadlybutter/dosomething/releases{/id}","created_at":"2014-11-04T19:57:31Z","updated_at":"2015-02-24T20:06:33Z","pushed_at":"2015-09-28T15:37:33Z","git_url":"git://github.com/deadlybutter/dosomething.git","ssh_url":"git@github.com:deadlybutter/dosomething.git","clone_url":"https://github.com/deadlybutter/dosomething.git","svn_url":"https://github.com/deadlybutter/dosomething","homepage":"http://www.dosomething.org/","size":15109,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"DoSomething:dev","ref":"dev","sha":"9b47bd6c3ae040823e84c948775dff0246efb5cf","user":{"login":"DoSomething","id":731685,"avatar_url":"https://avatars.githubusercontent.com/u/731685?v=3","gravatar_id":"","url":"https://api.github.com/users/DoSomething","html_url":"https://github.com/DoSomething","followers_url":"https://api.github.com/users/DoSomething/followers","following_url":"https://api.github.com/users/DoSomething/following{/other_user}","gists_url":"https://api.github.com/users/DoSomething/gists{/gist_id}","starred_url":"https://api.github.com/users/DoSomething/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DoSomething/subscriptions","organizations_url":"https://api.github.com/users/DoSomething/orgs","repos_url":"https://api.github.com/users/DoSomething/repos","events_url":"https://api.github.com/users/DoSomething/events{/privacy}","received_events_url":"https://api.github.com/users/DoSomething/received_events","type":"Organization","site_admin":false},"repo":{"id":13592927,"name":"phoenix","full_name":"DoSomething/phoenix","owner":{"login":"DoSomething","id":731685,"avatar_url":"https://avatars.githubusercontent.com/u/731685?v=3","gravatar_id":"","url":"https://api.github.com/users/DoSomething","html_url":"https://github.com/DoSomething","followers_url":"https://api.github.com/users/DoSomething/followers","following_url":"https://api.github.com/users/DoSomething/following{/other_user}","gists_url":"https://api.github.com/users/DoSomething/gists{/gist_id}","starred_url":"https://api.github.com/users/DoSomething/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DoSomething/subscriptions","organizations_url":"https://api.github.com/users/DoSomething/orgs","repos_url":"https://api.github.com/users/DoSomething/repos","events_url":"https://api.github.com/users/DoSomething/events{/privacy}","received_events_url":"https://api.github.com/users/DoSomething/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DoSomething/phoenix","description":"A Drupal 7 distribution that powers the DoSomething.org web platform.","fork":false,"url":"https://api.github.com/repos/DoSomething/phoenix","forks_url":"https://api.github.com/repos/DoSomething/phoenix/forks","keys_url":"https://api.github.com/repos/DoSomething/phoenix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DoSomething/phoenix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DoSomething/phoenix/teams","hooks_url":"https://api.github.com/repos/DoSomething/phoenix/hooks","issue_events_url":"https://api.github.com/repos/DoSomething/phoenix/issues/events{/number}","events_url":"https://api.github.com/repos/DoSomething/phoenix/events","assignees_url":"https://api.github.com/repos/DoSomething/phoenix/assignees{/user}","branches_url":"https://api.github.com/repos/DoSomething/phoenix/branches{/branch}","tags_url":"https://api.github.com/repos/DoSomething/phoenix/tags","blobs_url":"https://api.github.com/repos/DoSomething/phoenix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DoSomething/phoenix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DoSomething/phoenix/git/refs{/sha}","trees_url":"https://api.github.com/repos/DoSomething/phoenix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DoSomething/phoenix/statuses/{sha}","languages_url":"https://api.github.com/repos/DoSomething/phoenix/languages","stargazers_url":"https://api.github.com/repos/DoSomething/phoenix/stargazers","contributors_url":"https://api.github.com/repos/DoSomething/phoenix/contributors","subscribers_url":"https://api.github.com/repos/DoSomething/phoenix/subscribers","subscription_url":"https://api.github.com/repos/DoSomething/phoenix/subscription","commits_url":"https://api.github.com/repos/DoSomething/phoenix/commits{/sha}","git_commits_url":"https://api.github.com/repos/DoSomething/phoenix/git/commits{/sha}","comments_url":"https://api.github.com/repos/DoSomething/phoenix/comments{/number}","issue_comment_url":"https://api.github.com/repos/DoSomething/phoenix/issues/comments{/number}","contents_url":"https://api.github.com/repos/DoSomething/phoenix/contents/{+path}","compare_url":"https://api.github.com/repos/DoSomething/phoenix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DoSomething/phoenix/merges","archive_url":"https://api.github.com/repos/DoSomething/phoenix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DoSomething/phoenix/downloads","issues_url":"https://api.github.com/repos/DoSomething/phoenix/issues{/number}","pulls_url":"https://api.github.com/repos/DoSomething/phoenix/pulls{/number}","milestones_url":"https://api.github.com/repos/DoSomething/phoenix/milestones{/number}","notifications_url":"https://api.github.com/repos/DoSomething/phoenix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DoSomething/phoenix/labels{/name}","releases_url":"https://api.github.com/repos/DoSomething/phoenix/releases{/id}","created_at":"2013-10-15T14:50:48Z","updated_at":"2015-07-23T19:32:25Z","pushed_at":"2015-09-28T15:44:35Z","git_url":"git://github.com/DoSomething/phoenix.git","ssh_url":"git@github.com:DoSomething/phoenix.git","clone_url":"https://github.com/DoSomething/phoenix.git","svn_url":"https://github.com/DoSomething/phoenix","homepage":"http://www.dosomething.org/","size":27522,"stargazers_count":25,"watchers_count":25,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":285,"forks":18,"open_issues":285,"watchers":25,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/DoSomething/phoenix/pulls/5266"},"html":{"href":"https://github.com/DoSomething/phoenix/pull/5266"},"issue":{"href":"https://api.github.com/repos/DoSomething/phoenix/issues/5266"},"comments":{"href":"https://api.github.com/repos/DoSomething/phoenix/issues/5266/comments"},"review_comments":{"href":"https://api.github.com/repos/DoSomething/phoenix/pulls/5266/comments"},"review_comment":{"href":"https://api.github.com/repos/DoSomething/phoenix/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DoSomething/phoenix/pulls/5266/commits"},"statuses":{"href":"https://api.github.com/repos/DoSomething/phoenix/statuses/bf9f2c445dfe6876240ee64fef30b9062e0efe6f"}}}}