Created
October 14, 2011 21:13
-
-
Save mrryanjohnston/1288368 to your computer and use it in GitHub Desktop.
Optional fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/includes/services_sso_client.admin.inc b/includes/services_sso_client.admin.inc | |
index 1b8453b..9a4ef4e 100644 | |
--- a/includes/services_sso_client.admin.inc | |
+++ b/includes/services_sso_client.admin.inc | |
@@ -43,6 +43,21 @@ function services_sso_client_user_admin_form($form_state) { | |
'#description' => t('The url of the external account editing interface. Example: http://example.com/user/[uid]/edit. The [uid] portion will be replaced with the actual uid of the remote Drupal user account.'), | |
); | |
+ // Extra settings | |
+ $form['extra'] = array( | |
+ '#type' => 'fieldset', | |
+ '#title' => t('Extra options'), | |
+ '#collapsible' => TRUE, | |
+ '#collapsed' => FALSE, | |
+ ); | |
+ $form['extra']['services_sso_client_optional_profile_fields'] = array( | |
+ '#type' => 'textarea', | |
+ '#title' => 'Profile Fields', | |
+ '#description' => t('Other fields to be carried over from the sso server (non-standard profile fields). Separate remote field machine names from local field machine names with a |.'), | |
+ '#default_value' => variable_get('services_sso_client_optional_profile_fields', ''), | |
+ '#required' => FALSE, | |
+ ); | |
+ | |
// Debugging settings | |
$form['debug'] = array( | |
'#type' => 'fieldset', | |
diff --git a/services_sso_client.module b/services_sso_client.module | |
index 802b8a1..6b4e9b4 100644 | |
--- a/services_sso_client.module | |
+++ b/services_sso_client.module | |
@@ -354,12 +354,21 @@ function services_sso_client_update_remote_process($user, $skip_login = TRUE, &$ | |
'status' => $user->status, | |
'timezone' => $user->timezone, | |
'language' => $user->language, | |
- | |
+ | |
// Parse the picture member variable from a public://xxxx.jpg format to a http://myssoserver/path/to/file/xxxx.jpg. | |
'picture' => ((variable_get('services_sso_client_server_address', '') && !empty($user->picture->uri)) ? variable_get('services_sso_client_server_address', '') . '/' . str_ireplace('public://', 'sites/default/files/', $user->picture->uri) : str_ireplace('public://', 'sites/default/files/', $user->picture->uri)), | |
'init' => $user->init, | |
'roles' => (array) $user->roles | |
); | |
+ //If extra settings are specified | |
+ if ($extras = variable_get('services_sso_client_optional_profile_fields', '')) { | |
+ $extras = explode("\n", $extras); | |
+ $extras = array_filter(array_map('trim', $extras)); | |
+ foreach ($extras as $extra) { | |
+ $extra = explode("|", $extra); | |
+ $account[$extra[1]] = $user->$extra[0]->und[0]->value; | |
+ } | |
+ } | |
// Attempt to load the local user account with the processed account info array. | |
$account = services_sso_client_load_local_user($account, $skip_login, $form_state); | |
@@ -444,7 +453,6 @@ function services_sso_client_authenticate_remote(&$form_state) { | |
// Parse return data. | |
$data = json_decode($response->data); | |
- | |
// Fail if no data. | |
if (empty($data)) { | |
return FALSE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment