Advertisement:

Author Topic: User name doesn't update in header when changed in profile  (Read 2283 times)

code monkey

  • Full Member
  • ***
  • Posts: 204
User name doesn't update in header when changed in profile
« on: March 19, 2011, 08:37:43 am »
The user name that appears in head.php, says Hello _____!, doesn't update when you change your name in User Profiles.

Here is the fix, together with: pre-fill Contact Publisher form with logged-in user's Name/Email/Phone.


oc-includes/osclass/frm/Contact.form.class.php

Current:
Code: [Select]
    static public function your_name() {
        parent::generic_input_text("yourName", "", null, false);
        return true ;
    }
    
    static public function your_email($value = null) {
        parent::generic_input_text("yourEmail", , null, false);
        return true ;
    }
    
    static public function your_phone_number() {
        parent::generic_input_text("phoneNumber", "", null, false);
        return true ;
    }

Replace with:
Code: [Select]
   static public function your_name() {
        parent::generic_input_text("yourName", osc_logged_user_name(), null, false);
        return true ;
    }
    
    static public function your_email($value = null) {
        parent::generic_input_text("yourEmail", osc_logged_user_email(), null, false);
        return true ;
    }
    
    static public function your_phone_number() {
        parent::generic_input_text("phoneNumber", osc_logged_user_phone(), null, false);
        return true ;
    }


oc-includes/osclass/helpers/hUsers.php

Find ~line 31:
Code: [Select]
           Session::newInstance()->_set('userId', $user['pk_i_id']) ;
            Session::newInstance()->_set('userName', $user['s_name']) ;
            Session::newInstance()->_set('userEmail', $user['s_email']) ;

            return true ;

Replace with:
Code: [Select]
           Session::newInstance()->_set('userId', $user['pk_i_id']) ;
            Session::newInstance()->_set('userName', $user['s_name']) ;
            Session::newInstance()->_set('userEmail', $user['s_email']) ;
            Session::newInstance()->_set('userPhone',
($user['s_phone_mobile'])? $user['s_phone_mobile'] : $user['s_phone_land']) ;
            return true ;

Find ~line 48:
Code: [Select]
   function osc_logged_user_name() {
        return Session::newInstance()->_get('userName') ;
    }

After, add:
Code: [Select]
   function osc_logged_user_phone() {
        return Session::newInstance()->_get('userPhone') ;
    }


login.php

Find ~line 55:
Code: [Select]
Session::newInstance()->_set('userId', $user['pk_i_id']) ;
Session::newInstance()->_set('userName', $user['s_name']) ;
Session::newInstance()->_set('userEmail', $user['s_email']) ;

Replace with:
Code: [Select]
Session::newInstance()->_set('userId', $user['pk_i_id']) ;
Session::newInstance()->_set('userName', $user['s_name']) ;
Session::newInstance()->_set('userEmail', $user['s_email']) ;
Session::newInstance()->_set('userPhone',
($user['s_phone_mobile'])? $user['s_phone_mobile'] : $user['s_phone_land']) ;


oc-includes/osclass/user.php (or UserActions.php)

Find ~line 103:
Code: [Select]
       function edit($userId)
        {
            $input = $this->prepareData(false) ;
            $this->manager->update($input, array('pk_i_id' => $userId)) ;

After, add:
Code: [Select]
// Update user vars in $_SESSION
Session::newInstance()->_set('userName', $input['s_name']) ;
Session::newInstance()->_set('userPhone',
($input['s_phone_mobile'])? $input['s_phone_mobile'] : $input['s_phone_land']) ;

user-non-secure.php

Find ~line 39:
Code: [Select]
$userManager->update(
array('s_email' => $userEmailTmp['s_new_email'])//, 's_pass_code' => $code)
,array('pk_i_id' => $userEmailTmp['fk_i_user_id'])
);

After, add:
Code: [Select]
// Update user vars in $_SESSION
Session::newInstance()->_set('userEmail', $userEmailTmp['s_new_email']) ;

Now when user changes their name, changes to header.php will appear immediately,
instead of at next login.

Now when user is viewing item page, the "contact publisher" fields Name/Email/Phone will be pre-filled with logged-in user's data.

_CONEJO

  • Administrator
  • Hero Member
  • *****
  • Posts: 4689
Re: User name doesn't update in header when changed in profile
« Reply #1 on: March 23, 2011, 11:56:04 am »
Hi,

I've just created an issue. Follor the development : http://issues.osclass.org/browse/OSCLASS-411



Thanks

Juan Ramón

  • Osclass Developer
  • Hero Member
  • *****
  • Posts: 2382
Re: User name doesn't update in header when changed in profile
« Reply #2 on: March 23, 2011, 02:19:24 pm »
fixed! thanks code monkey