Not signed in (Sign In)

Categories

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

Help keep Vanilla free:
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    •  
      CommentAuthormonstr
    • CommentTimeJan 3rd 2008
     # 1
    hejhej.
    is it possible to have the panel on the comments page only displayed when you are logged in as a admin?
    • CommentAuthorGrahack
    • CommentTimeJan 4th 2008 edited
     # 2
    Hi, I see two ways to do it, I'll give you the cleanest:
    create a new theme and put a conditional statement around the code of panel.php (some code is stolen from appg/init_vanilla.php)
    // this code is not tested
    $DisplayPanel = false;
    if ( $Context->SelfUrl == "comments.php" )
    {
    if ($Context->Session->UserID > 0) {
    $RequiredPermissions = array('PERMISSION_CHECK_FOR_UPDATES',
    'PERMISSION_APPROVE_APPLICANTS',
    'PERMISSION_MANAGE_REGISTRATION',
    'PERMISSION_ADD_ROLES',
    'PERMISSION_EDIT_ROLES',
    'PERMISSION_REMOVE_ROLES',
    'PERMISSION_ADD_CATEGORIES',
    'PERMISSION_EDIT_CATEGORIES',
    'PERMISSION_REMOVE_CATEGORIES',
    'PERMISSION_SORT_CATEGORIES',
    'PERMISSION_CHANGE_APPLICATION_SETTINGS',
    'PERMISSION_MANAGE_EXTENSIONS',
    'PERMISSION_MANAGE_LANGUAGE',
    'PERMISSION_MANAGE_STYLES',
    'PERMISSION_MANAGE_THEMES');

    $RequiredPermissionsCount = count($RequiredPermissions);
    $i = 0;
    for ($i = 0; $i < $RequiredPermissionsCount; $i++) {
    if ($Context->Session->User->Permission($RequiredPermissions[$i])) {
    $DisplayPanel = true;
    break;
    }
    }
    }
    }
    if ( ! $Context->SelfUrl == "comments.php" OR $DisplayPanel )
    {
    // old code in panel.php
    }

    This should always display the panel on other pages than somments.php, and if we're in comments.php, display the panel only if we are authenticated and have a permission among those listed.
    •  
      CommentAuthormonstr
    • CommentTimeJan 4th 2008
     # 3
    woh, thanks so far, looks quite good but doesn't work ._.
    i get a php error because of the following lines

    if ( $Context->SelfUrl == "comments.php" )

    if ( ! $Context->SelfUrl == "comments.php" OR $DisplayPanel )

    i tried

    if (in_array($Context->SelfUrl, array("comments.php"))

    but it didn't work. any idea?
  1.  # 4
    What's the error?
    •  
      CommentAuthormonstr
    • CommentTimeJan 4th 2008
     # 5
    invalid argument
  2.  # 6
    Paste us the whole thing.
    •  
      CommentAuthormonstr
    • CommentTimeJan 4th 2008
     # 7
    sorry (i wasn't even right, shame on me) here it is:

    Notice: Undefined variable: Context in /kunden/121606_86830/monstrs/forum/themes/monstrs/panel.php on line 4

    Notice: Undefined variable: Context in /kunden/121606_86830/monstrs/forum/themes/monstrs/panel.php on line 33
    • CommentAuthortimfire
    • CommentTimeJan 4th 2008 edited
     # 8
    I think "$Context" needs to be changed to "$this->Context" (the theme patch is being called from within the Panel object).

    Also, wouldn't this be easier?

    // this code is not tested

    if ( ! $this->Context->SelfUrl == "comments.php" OR $this->Context->Session->User->RoleID > {whatever} )
    {
    // old code in panel.php
    }
  3.  # 9
    Sounds like timfire is on the money with the $this-> thing. I'm too tired to think about the other bit.
    • CommentAuthorGrahack
    • CommentTimeJan 5th 2008
     # 10
    Must work now, Tim is right. Now for the precise condition, I first started to think like the last bit of code, but I'm not good at permissions and role ids and so on. I just copy-pasted the code in appg/init_vanilla.php to be sure to have something like an 'admin condition'. It depends on what Monstr wants.
Add your comments
    Username Password
  • Format comments as