Advertisement:

Author Topic: -SOLVED-old  (Read 2495 times)

Pigeon

  • Sr. Member
  • ****
  • Posts: 498
-SOLVED-old
« on: July 28, 2015, 02:19:21 am »
Hello
i have a question:
in my osclass (osclass.3.5.2) there is a bug: the bug is, in user profile page, when you hit on (public profile), it does NOT work, we have to first hit on my-profile and then hit public-profile to open public-profile page
now i'm using old version, does this bug available in new version of osclass?
if not, how can i fix it in my version of osclass?
Thank You
« Last Edit: August 01, 2015, 02:09:44 am by alive_gene »

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: old
« Reply #1 on: July 29, 2015, 02:37:10 pm »
What theme are you using?
I think you mean clicking the user name in Bender theme when watching an item?

I run version 3.5.6 and just checked with latest Bender theme. When I click username when watching an item I get redirected to user's public profile with no issue. Also when on user's private profile clicking the button public profile redirects me to user's public profile so I think no more bug in this version.

The code behind the item's name which redirects to public profile should look like this in file item-sidebar.php:
Code: [Select]
<p class="name"><?php _e('Name''bender'?>: <a href="<?php echo osc_user_public_profile_urlosc_item_user_id() ); ?>" ><?php echo osc_item_contact_name(); ?></a></p>
Regards,
Eric

Pigeon

  • Sr. Member
  • ****
  • Posts: 498
Re: old
« Reply #2 on: July 29, 2015, 02:57:57 pm »
Thanks, but you didn't answer my question
Please read my post again
Im using modern theme.
If you sign in your profile and then click on public profile menue, it doesn't work, try it

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: old
« Reply #3 on: July 29, 2015, 05:18:56 pm »
Hi, thanks, I can see what's happening in modern theme but I have not been able to track down the root cause.
Unless someone beats me to it I'll get back on this, need more time to figure it out.


Regards,
Eric

Pigeon

  • Sr. Member
  • ****
  • Posts: 498
Re: old
« Reply #4 on: July 29, 2015, 10:27:55 pm »
Hi, thanks, I can see what's happening in modern theme but I have not been able to track down the root cause.
Unless someone beats me to it I'll get back on this, need more time to figure it out.


Regards,
Eric
Thank you, im waiting for you.

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: old
« Reply #5 on: July 30, 2015, 01:28:05 am »
I have found the root cause as well as a way to fix it but now I am trying to figure out if it is core bug or theme bug.
Anyway, I will post the fix soon.

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: old
« Reply #6 on: July 30, 2015, 02:16:15 am »
Here it is, I am quite certain it is a theme bug.

For those interested, the cause of public profile not working is because the href is "" so no link to follow. Reason for this happening is because there's no user 'known' to the View class most likely because it was not yet added at the time the public profile request is made.
The solution is to make sure all user data is available and for this I took a big part of a function used in Bender theme's functions.php and changed it a bit.  :)

Place the following code in your theme's functions.php at the end of the file and your Public Profile in modern theme should be working again:
Code: [Select]
    if( !function_exists('modern_user_info') ) {
        function modern_user_info() {
            $location = Rewrite::newInstance()->get_location();
            $section  = Rewrite::newInstance()->get_section();
            if( $location === 'user' && in_array($section, array('dashboard', 'profile', 'alerts', 'change_email', 'change_username',  'change_password', 'items')) ) {
                $user = User::newInstance()->findByPrimaryKey( Session::newInstance()->_get('userId') );
                View::newInstance()->_exportVariableToView('user', $user);
}
}
        osc_add_hook('header', 'modern_user_info');
    }


Regards,
Eric

Pigeon

  • Sr. Member
  • ****
  • Posts: 498
Re: old
« Reply #7 on: July 30, 2015, 06:02:09 am »
Here it is, I am quite certain it is a theme bug.

For those interested, the cause of public profile not working is because the href is "" so no link to follow. Reason for this happening is because there's no user 'known' to the View class most likely because it was not yet added at the time the public profile request is made.
The solution is to make sure all user data is available and for this I took a big part of a function used in Bender theme's functions.php and changed it a bit.  :)

Place the following code in your theme's functions.php at the end of the file and your Public Profile in modern theme should be working again:
Code: [Select]
    if( !function_exists('modern_user_info') ) {
        function modern_user_info() {
            $location = Rewrite::newInstance()->get_location();
            $section  = Rewrite::newInstance()->get_section();
            if( $location === 'user' && in_array($section, array('dashboard', 'profile', 'alerts', 'change_email', 'change_username',  'change_password', 'items')) ) {
                $user = User::newInstance()->findByPrimaryKey( Session::newInstance()->_get('userId') );
                View::newInstance()->_exportVariableToView('user', $user);
}
}
        osc_add_hook('header', 'modern_user_info');
    }


Regards,
Eric

it worked eric
awesome man, your great
this was a big bug in osclass
please report it to osclass and tell them that you solve it,
thank you again.

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: old
« Reply #8 on: July 30, 2015, 09:17:27 pm »
Thanks for the kind words. :)
It is nice I was able to figure it out and come up with a fix but there should be a review for a final fix by Osclass devs.
This fix is not tailored on the specific issue and I still wonder if the fix should be in core or theme like I did now.
Bender uses similar code but also has some extra code to fill some java vars used by Bender theme.

At this moment I think the core function 'osc_private_user_menu()' should be changed with this "View" fix code so that theme devs do not have to think about this specific issue and they can simply use this function to display a correct private user menu in their theme at all times.

P.s. can you put SOLVED in the subject?


Regards,
Eric
« Last Edit: July 30, 2015, 09:19:58 pm by SmaRTeY »

Pigeon

  • Sr. Member
  • ****
  • Posts: 498
Re: old
« Reply #9 on: July 31, 2015, 05:43:29 am »
thank you, how can i put solve on the topic?

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: old
« Reply #10 on: July 31, 2015, 04:20:16 pm »
Quote
how can i put solve on the topic?

You edit your 1st message in this thread and then change the subject by adding -SOLVED- in front of it and save the change, that's all  :)

Regards,
Eric

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: -SOLVED-old
« Reply #11 on: August 04, 2015, 03:57:06 pm »
Quote
At this moment I think the core function 'osc_private_user_menu()' should be changed with this "View" fix code so that theme devs do not have to think about this specific issue and they can simply use this function to display a correct private user menu in their theme at all times.

I still think for the 'default' Osclass private user menu this should be fixed in a similar way I have here but there is one thing I did not thought off until a couple of days ago worth mentioning for others; certain plugins add private menu options, these added menu options will either have to follow specific 'routing' for this code to keep working or these plugins need this code fix to keep the issue from re-occuring.
For example I have several plugins that add a menu option for users and they cause the public profile issue again.  :-\

Be aware!

Pigeon

  • Sr. Member
  • ****
  • Posts: 498
Re: -SOLVED-old
« Reply #12 on: August 07, 2015, 06:34:53 am »
Quote
At this moment I think the core function 'osc_private_user_menu()' should be changed with this "View" fix code so that theme devs do not have to think about this specific issue and they can simply use this function to display a correct private user menu in their theme at all times.

I still think for the 'default' Osclass private user menu this should be fixed in a similar way I have here but there is one thing I did not thought off until a couple of days ago worth mentioning for others; certain plugins add private menu options, these added menu options will either have to follow specific 'routing' for this code to keep working or these plugins need this code fix to keep the issue from re-occuring.
For example I have several plugins that add a menu option for users and they cause the public profile issue again.  :-\

Be aware!
SmaRTeY i did not get you
what do you mean by private prifile
there was just was bug on user profle that you solved it
please explain clearly

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: -SOLVED-old
« Reply #13 on: August 08, 2015, 03:35:25 am »
Yes user profile is solved for now BUT as mentioned there are plugins that add a user menu item and in these cases if you click this menu item as a user you will also most likely if not certain have the same issue again of public profile link not working.

Pigeon

  • Sr. Member
  • ****
  • Posts: 498
Re: -SOLVED-old
« Reply #14 on: August 08, 2015, 04:41:28 am »
Yes user profile is solved for now BUT as mentioned there are plugins that add a user menu item and in these cases if you click this menu item as a user you will also most likely if not certain have the same issue again of public profile link not working.

im not using a plugin, because if i need something i try to edit my theme or core,
and now my user profile works good