Disable "Rebuild DB" from limited Admin accounts

Discussion in 'Troubleshooting' started by nc3man, Oct 3, 2011.

  1. nc3man

    nc3man aMember Pro Customer

    Joined:
    Sep 30, 2010
    Messages:
    42
    I have set up Admin accounts for some others to have access to our membership database. This is "read-only" with the ability to export to a csv file. I noticed that this does not restricted such a limited Admin account to CP > Browse Users > Rebuild DB (found out the hard way). Since we have aMember integrated with SMF, that means that anyone who customized their display name used in SMF posts will have their display name reset to the aMember SMF plugin default of "First name" "Last name". I would like to make sure these read-only Admin accounts cannot "Rebuild DB" or "Utilities > Delete Old Records" either. Is there a setting for this?
  2. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    There is not a built in option to disable these options, you could be conditional statements around them for specific ids.

    The Rebuild DB function, for example, can be found in the amember\admin\menu.inc.php file (around line 119):

    Code:
    $s->addItem('Rebuild DB', 'rebuild.php');
  3. nc3man

    nc3man aMember Pro Customer

    Joined:
    Sep 30, 2010
    Messages:
    42
    Good suggestion. What would be the details of the conditional to use so that "Rebuild DB" will only appear on the left-hand menu for the primary administrator? I don't know most details of the aMember detailed design, but am comfortable with php edits.
    Thank you
  4. nc3man

    nc3man aMember Pro Customer

    Joined:
    Sep 30, 2010
    Messages:
    42
    Since I didn't get a reply to how to set up the conditional, let me be more specific. If I could just have access to the name of the current administrator in the Control Panel, I could compare it to the name of the primary administrator, and only display the "Rebuild DB" option for the primary administrator. So what is the name of the variable (or field in a structure) for the current logged-in administrator?
    Thank you
  5. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    If it were me, and I were the primary admin (guessing you only have 1).. I would just comment out the line in the file and uncomment it when I need to rebuild (which is probably never).

    Simple solution.
  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    you can use this code:
    if($_SESSION['_admin_login'] == 'PRIMARY_ADMIN_LOGIN'){
    // Display link
    }
  7. nc3man

    nc3man aMember Pro Customer

    Joined:
    Sep 30, 2010
    Messages:
    42
    Thank you so much, Alexander. I used that conditional to hide a few other things I didn't want my helper admins to even see.
    Case closed.

Share This Page