@@ -789,22 +789,28 @@ public function updatePatronInfo(User $patron, $canUpdateContactInfo, $fromMasqu
789
789
$ userMessages ['messages ' ][] = 'Your contact information cannot be updated. ' ;
790
790
return $ userMessages ;
791
791
}
792
- $ propertyName = '' ;
793
792
794
793
if (!isset ($ _REQUEST ['email ' ])) {
795
794
return $ userMessages ;
796
795
}
796
+
797
797
$ propertyName = 'email ' ;
798
798
$ propertyValue = $ _REQUEST ['email ' ];
799
- $ response = $ this ->updatePatronProperty ($ propertyName , $ propertyValue , $ patron ->ils_password , $ authToken );
799
+ $ response = $ this ->updatePatronPropertyInEvergreen ($ propertyName , $ propertyValue , $ patron ->ils_password , $ authToken );
800
+
801
+ if ($ response ['success ' ]) {
802
+ $ patron ->email = $ propertyValue ;
803
+ $ patron ->update ();
804
+ }
805
+
800
806
$ userMessages ['messages ' ][] = $ response ['success ' ] ? 'Your email has been updated. ' : 'Your email could not be updated. Please contact your library ' ;
801
807
$ userMessages ['success ' ] = $ response ['success ' ];
802
808
803
809
return $ userMessages ;
804
810
}
805
811
806
- private function updatePatronProperty ( $ propertyName , $ propertyValue , $ patronIlsPassword , $ authToken ): array {
807
- $ evergreenUrl = $ this ->accountProfile ->patronApiUrl . "/osrf-gateway-v1/ $ propertyName " ;
812
+ private function updatePatronPropertyInEvergreen ( string $ propertyEvergreenName , string $ propertyValue , string $ patronIlsPassword , string $ authToken ): array {
813
+ $ evergreenUrl = $ this ->accountProfile ->patronApiUrl . "/osrf-gateway-v1/ $ propertyEvergreenName " ;
808
814
$ headers = [
809
815
'Content-Type: application/x-www-form-urlencoded ' ,
810
816
];
@@ -815,13 +821,13 @@ private function updatePatronProperty($propertyName, $propertyValue, $patronIlsP
815
821
* determines which is which
816
822
*/
817
823
$ request = 'service=open-ils.actor ' ;
818
- $ request .= "&method=open-ils.actor.user. $ propertyName .update " ;
824
+ $ request .= "&method=open-ils.actor.user. $ propertyEvergreenName .update " ;
819
825
$ requestParams = '¶m= ' . json_encode ($ authToken );
820
826
$ requestParams .= '¶m= ' . json_encode ($ propertyValue );
821
827
$ requestParams .= '¶m= ' . json_encode ($ patronIlsPassword );
822
828
823
829
$ apiResponse = $ this ->apiCurlWrapper ->curlPostPage ($ evergreenUrl , $ request . $ requestParams );
824
- ExternalRequestLogEntry::logRequest ('evergreen.updatePatronProperty ' , 'POST ' , $ evergreenUrl , $ this ->apiCurlWrapper ->getHeaders (), $ request , $ this ->apiCurlWrapper ->getResponseCode (), $ apiResponse , []);
830
+ ExternalRequestLogEntry::logRequest ('evergreen.updatePatronPropertyInEvergreen ' , 'POST ' , $ evergreenUrl , $ this ->apiCurlWrapper ->getHeaders (), $ request , $ this ->apiCurlWrapper ->getResponseCode (), $ apiResponse , []);
825
831
826
832
$ responseData = json_decode ($ apiResponse , true );
827
833
$ response = ['success ' => false , 'message ' => ['code ' => '' , 'text ' => 'Evergreen sent an unexpected response ' ]];
@@ -838,7 +844,7 @@ private function updatePatronProperty($propertyName, $propertyValue, $patronIlsP
838
844
839
845
if (!$ response ['success ' ]) {
840
846
global $ logger ;
841
- $ logger ->log ('Error updating patron property ' . $ propertyName . ': ' . $ responseData ['payload ' ][0 ]['desc ' ], Logger::LOG_ERROR );
847
+ $ logger ->log ('Error updating patron property ' . $ propertyEvergreenName . ': ' . $ responseData ['payload ' ][0 ]['desc ' ], Logger::LOG_ERROR );
842
848
$ response ['message ' ]['code ' ] = $ responseData ['payload ' ][0 ]['textcode ' ];
843
849
$ response ['message ' ]['text ' ] = $ responseData ['payload ' ][0 ]['desc ' ];
844
850
return $ response ;
@@ -2593,9 +2599,6 @@ public function loadContactInformation(User $user) {
2593
2599
if (!empty ($ mappedPatronData ['suffix ' ])) {
2594
2600
$ user ->_fullname .= ' ' . $ mappedPatronData ['suffix ' ];
2595
2601
}
2596
- if (!empty ($ mappedPatronData ['email ' ])) {
2597
- $ user ->email = $ mappedPatronData ['email ' ];
2598
- }
2599
2602
$ user ->_fullname = trim ($ user ->_fullname );
2600
2603
2601
2604
if (!empty ($ mappedPatronData ['expire_date ' ])) {
0 commit comments