Re: How to hide the Orders tab under My Account?

jmassheder's picture
Offline
Joined: 10/15/2008
Juice: 4
Re: How to hide the Orders tab under My Account?

I'm planning to use Ubercart on my existing Drupal site and want to play about setting things up with out existing users knowing (being confused by an orders tab that is of no use to them yet). So I've added a 'view own orders' permission that I have given only to administrators for now. Of course not giving users permission to see their own orders on a live Ubercart site makes no sense but it seems the way to accomplish what I want. Only give administrators permission to view their own orders while setting up the site and then I can give the permission to all when the Ubercart section goes live. Is their a problem with this approach that I haven't seen?

I started off with file uc_order.module:
// $Id: uc_order.module,v 1.11.2.15 2008/10/07 15:47:57 rszrama Exp $

in function uc_order_menu($may_cache) {
I changed the section:

    if ($user->uid) {
      $items[] = array(
        'path' => 'user/'. arg(1) .'/orders',
        'title' => t('Orders'),
        'description' => t('View your order history.'),

to

    // jmm: added the  && user_access('view own orders')
    if ($user->uid && user_access('view own orders')) {
      $items[] = array(
        'path' => 'user/'. arg(1) .'/orders',
        'title' => t('Orders'),
        'description' => t('View your order history.'),

and changed:

  /**
   * Implementation of hook_perm().
   */
  function uc_order_perm() {
    return array('view all orders', 'create orders', 'edit orders', 'delete   orders', 'delete any order', 'administer order workflow');
  }

to

  /**
   * Implementation of hook_perm().
   */
  // jmm added 'view own orders'
  function uc_order_perm() {
    return array('view own orders', 'view all orders', 'create orders', 'edit   orders', 'delete orders', 'delete any order', 'administer order workflow');
  }

and :

  /**
   * Implementation of hook_user().
   */
  function uc_order_user($op, &$edit, &$account, $category = NULL) {
    global $user;
    switch ($op) {
      case 'view':
     if ($user->uid && ($user->uid == $account->uid || user_access('view all orders'))) {

to

  /**
   * Implementation of hook_user().
   */
  function uc_order_user($op, &$edit, &$account, $category = NULL) {
    global $user;
    switch ($op) {
      case 'view':
    // jmm added  && user_access('view own orders')
        if ($user->uid && (($user->uid == $account->uid && user_access('view own orders')) || user_access('view all orders'))) {

Jonathan

How to hide the Orders tab under My Account? By: morekbps (6 replies) Fri, 09/19/2008 - 13:21