@@ -53,7 +53,8 @@ public function &run(Router &$router, View &$view, array &$args) {
5353
5454 if ( $ model ->profile ) {
5555
56- $ model ->biography = $ model ->profile ->getBiography ();
56+ $ model ->biography = $ model ->profile ->getBiography ();
57+ $ model ->facebook_username = $ model ->profile ->getFacebookUsername ();
5758
5859 }
5960
@@ -83,6 +84,10 @@ public function &run(Router &$router, View &$view, array &$args) {
8384 isset ($ data ['biography ' ]) ? $ data ['biography ' ] : null
8485 );
8586
87+ $ model ->facebook_username = (
88+ isset ($ data ['facebook_username ' ]) ? $ data ['facebook_username ' ] : null
89+ );
90+
8691 // process input
8792
8893 if ($ model ->username !== Authentication::$ user ->getUsername ()) {
@@ -198,6 +203,24 @@ public function &run(Router &$router, View &$view, array &$args) {
198203
199204 }
200205
206+ if (
207+ $ model ->facebook_username !== $ model ->profile ->getFacebookUsername ()
208+ ) {
209+
210+ // facebook username change request
211+
212+ if (strlen ($ model ->facebook_username ) >
213+ $ model ->facebook_username_max_len
214+ ) {
215+ $ model ->facebook_username_error = ['red ' , 'TOO_LONG ' ];
216+ } else {
217+ $ model ->profile ->setFacebookUsername ($ model ->facebook_username );
218+ $ model ->facebook_username_error = ['green ' , 'CHANGE_SUCCESS ' ];
219+ $ profile_changed = true ;
220+ }
221+
222+ }
223+
201224 if ($ profile_changed ) {
202225 $ model ->profile ->save ();
203226 }
@@ -207,17 +230,19 @@ public function &run(Router &$router, View &$view, array &$args) {
207230 Authentication::$ user ->getId (),
208231 getenv ('REMOTE_ADDR ' ),
209232 json_encode ([
210- 'username_error ' => $ model ->username_error ,
211- 'email_error ' => $ model ->email_error ,
212- 'display_name_error ' => $ model ->display_name_error ,
213- 'biography_error ' => $ model ->biography_error ,
214- 'user_id ' => Authentication::$ user ->getId (),
215- 'username ' => $ model ->username ,
216- 'email_1 ' => $ model ->email_1 ,
217- 'email_2 ' => $ model ->email_2 ,
218- 'display_name ' => $ display_name ,
219- 'profile_changed ' => $ profile_changed ,
220- 'biography ' => $ model ->biography ,
233+ 'username_error ' => $ model ->username_error ,
234+ 'email_error ' => $ model ->email_error ,
235+ 'display_name_error ' => $ model ->display_name_error ,
236+ 'biography_error ' => $ model ->biography_error ,
237+ 'facebook_username_error ' => $ model ->facebook_username_error ,
238+ 'user_id ' => Authentication::$ user ->getId (),
239+ 'username ' => $ model ->username ,
240+ 'email_1 ' => $ model ->email_1 ,
241+ 'email_2 ' => $ model ->email_2 ,
242+ 'display_name ' => $ display_name ,
243+ 'profile_changed ' => $ profile_changed ,
244+ 'biography ' => $ model ->biography ,
245+ 'facebook_username ' => $ model ->facebook_username ,
221246 ])
222247 );
223248
0 commit comments