Created
October 3, 2012 14:51
-
-
Save jblyberg/3827335 to your computer and use it in GitHub Desktop.
rtd's mutli-account fix
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
| function sopac_subaccounts_confirm_remove_submit($form, &$form_state) { | |
| $account = $form_state['values']['account']; | |
| $subID = $form_state['values']['subID']; | |
| $sub_cards = explode(',', $account->profile_pref_additional_cardnum); | |
| $removed_card = $sub_cards[$subID]; | |
| unset($sub_cards[$subID]); | |
| $update = array( | |
| 'profile_pref_additional_cardnum' => implode(',', $sub_cards), | |
| 'profile_pref_cardnum' => $account->profile_pref_cardnum, | |
| 'profile_pref_home_branch' => $account->profile_pref_home_branch, | |
| ); | |
| profile_save_profile($update, $account, 'AHML Options'); | |
| drupal_set_message("Removed Library Card $removed_card from your account"); | |
| drupal_goto('user'); | |
| } | |
| function sopac_subaccounts_add_card($account, $lcard) { | |
| if (strlen($account->profile_pref_additional_cardnum)) { | |
| $sub_cards = explode(',', $account->profile_pref_additional_cardnum); | |
| if (!in_array($lcard, $sub_cards)) { | |
| $sub_cards[] = $lcard; | |
| } | |
| $update = array( | |
| 'profile_pref_additional_cardnum' => implode(',', $sub_cards), | |
| 'profile_pref_cardnum' => $account->profile_pref_cardnum, | |
| 'profile_pref_home_branch' => $account->profile_pref_home_branch, | |
| ); | |
| } | |
| else { | |
| $update = array( | |
| 'profile_pref_additional_cardnum' => $lcard, | |
| 'profile_pref_cardnum' => $account->profile_pref_cardnum, | |
| 'profile_pref_home_branch' => $account->profile_pref_home_branch, | |
| ); | |
| } | |
| profile_save_profile($update, $account, 'AHML Options'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment