/**
  * storeOauth - Save the oauth data to the datbase
  * @param type $userid
  */
 public function storeOAuth($userid)
 {
     $this->_user_profile = $_SESSION['userfrosting']['oauth_details'];
     $user_details = $this->transform($this->_user_profile);
     $user_details['user_id'] = $userid;
     $user_details['provider'] = strtolower($this->_provider_name);
     // check to see if we have a record with this UID
     $cur_oauth_user = OAuthUserLoader::fetch($user_details['uid'], 'uid');
     //logarr($user_details,"Line 82 user id is $userid and uid is ".$user_details['uid']);
     //logarr($cur_oauth_user,"Line 84");
     // if we find a record with the UID then, update the record
     if (is_object($cur_oauth_user)) {
         foreach ($user_details as $usrkey => $usrdata) {
             // do not update the UID or user_id fields
             if ($usrkey != 'user_id' && $usrkey != 'uid') {
                 $cur_oauth_user->{$usrkey} = $usrdata;
             }
         }
         $oauth_user = $cur_oauth_user;
     } else {
         $oauth_user = new OAuthUser($user_details);
     }
     //logarr($user_details,"Line 99 user id $userid");
     //logarr($oauth_user,"Line 99 user id oauth_user");
     // Save to database
     $oauth_user->save();
 }