Advertisement:

Author Topic: osc_run_hook('user_menu') change needed  (Read 3603 times)

keny

  • Full Member
  • ***
  • Posts: 137
osc_run_hook('user_menu') change needed
« on: June 27, 2011, 10:46:48 pm »
In the hUtils.php helper file we can find the osc_run_hook('user_menu').

I beleive that i will be more logic to had the hook before added the logout link so if we add menu the dashborad the logout link will be always the last one in the list.

Here is my proposition that you could provide in v2.2 (code tested and working)

Code: [Select]
function osc_private_user_menu($options = null)
    {
        if($options == null) {
            $options = array();
            $options[] = array('name' => __('Dashboard'), 'url' => osc_user_dashboard_url(), 'class' => 'opt_dashboard') ;
            $options[] = array('name' => __('Manage your items'), 'url' => osc_user_list_items_url(), 'class' => 'opt_items') ;
            $options[] = array('name' => __('Manage your alerts'), 'url' => osc_user_alerts_url(), 'class' => 'opt_alerts') ;
            $options[] = array('name' => __('My account'), 'url' => osc_user_profile_url(), 'class' => 'opt_account') ;
            $options[] = array('name' => __('Logout'), 'url' => osc_user_logout_url(), 'class' => 'opt_logout') ;
        }

        echo '<script type="text/javascript">' ;
            echo '$(".user_menu > :first-child").addClass("first") ;' ;
            echo '$(".user_menu > :last-child").addClass("last") ;' ;
        echo '</script>' ;
        echo '<ul class="user_menu">' ;

            $var_l = count($options) ;
            for($var_o = 0 ; $var_o < $var_l-1 ; $var_o++) {
                echo '<li class="' . $options[$var_o]['class'] . '" ><a href="' . $options[$var_o]['url'] . '" >' . $options[$var_o]['name'] . '</a></li>' ;
            }

            osc_run_hook('user_menu') ;
                 echo '<li class="' . $options[$var_l-1]['class'] . '" ><a href="' . $options[$var_l-1]['url'] . '" >' . $options[$var_l-1]['name'] . '</a></li>' ;
   

        echo '</ul>' ;
    }

_CONEJO

  • Administrator
  • Hero Member
  • *****
  • Posts: 4689
Re: osc_run_hook('user_menu') change needed
« Reply #1 on: June 28, 2011, 10:40:32 am »
Hi keny

You're ..... right but .... well, I can't remember why you could pass some options to osc_private_user_menu(), I'm sure that back in that day, it makes much more sense than now the way it's done. But the truth is that no options are passed as a parameter to the function, no need to worry about if there's a logout or not, because it always is.

I will change the function for 2.2.

Thanks