News:

Wondering if this will always be free?  See why free is better.

Main Menu

What is moderator link?

Started by Angelotus, July 09, 2008, 05:41:36 AM

Previous topic - Next topic

Angelotus

Hi, i'm rebuilding my website and want to add the moderator link, if the logged in person is a moderator (or admin)

For admin I use this code

// Is the user allowed to administrate at all? ([admin])
   if ($context['allow_admin'])
      echo '<li><a href="', $scripturl, '?action=admin">administratie</a></li>';


What code to use for the moderator link?

Angelotus

Bumping this thread. Anyone familiar with this?

TiReDsOuL

Quote from: Angelotus on July 09, 2008, 05:41:36 AM
Hi, i'm rebuilding my website and want to add the moderator link, if the logged in person is a moderator (or admin)

For admin I use this code

// Is the user allowed to administrate at all? ([admin])
   if ($context['allow_admin'])
      echo '<li><a href="', $scripturl, '?action=admin">administratie</a></li>';


What code to use for the moderator link?

are u sure your website 2.x ?? that's admin code for 1.1.x :S

smfthemes.org --language moderator
Özel mesajla yardım istemeyin artık okumuyorum bile..
Do NOT PM me for support unless I invite you, I will ignore you.
--------------------------------------
Uzun bir süre yok....

karlbenson

#3
$context['user']['is_admin']
$context['user']['is_mod'] OR allowedTo('moderate_forum')
I forget which one is per-board mods, and which is for global forum mods.

$context['user']['is_logged']
$context['user']['is_guest']

Angelotus

I have tried to create such a link with:

 
// Is the user allowed to moderate at all? ([mod])
   if ($context['user']['is_mod'])
      echo '<li><a href="', $scripturl, '?action=moderate">moderatie</a></li>';


What is wrong?

But moderators can not see the link when logged in.

Angelotus

Quote from: TiReDsOuL on July 09, 2008, 04:27:15 PM
Quote from: Angelotus on July 09, 2008, 05:41:36 AM
Hi, i'm rebuilding my website and want to add the moderator link, if the logged in person is a moderator (or admin)

For admin I use this code

// Is the user allowed to administrate at all? ([admin])
   if ($context['allow_admin'])
      echo '<li><a href="', $scripturl, '?action=admin">administratie</a></li>';


What code to use for the moderator link?

are u sure your website 2.x ?? that's admin code for 1.1.x :S

Yes it is 2.0
And I copied the code indeed from 1.1.5
What should be the code for 2.0?

karlbenson

If this use is for on your website have you included ssi.php?

is context declared within your function as a global variable?


Angelotus

Quote from: karlbenson on July 09, 2008, 04:42:48 PM
is context declared within your function as a global variable?

Yes, this is the full coding for the function:


// Show the menu up top.  Something like [home] [help] [profile] [logout]...
function template_menu()
{
   global $context, $settings, $options, $scripturl, $txt;

   if ($context['user']['is_logged'])
     
     {

   echo '<div class="tborder3"><div class="catbg">Mijn Menu</div><ul class="glossymenu">';

   // Is the user allowed to administrate at all? ([admin])
   if ($context['allow_admin'])
      echo '<li><a href="', $scripturl, '?action=admin">administratie</a></li>';

   // Is the user allowed to moderate at all? ([admin])
   if ($context['user']['is_admin'])
      echo '<li><a href="', $scripturl, '?action=moderate">moderatie</a></li>';

   // Is the user allowed to moderate at all? ([admin])
   if ($context['user']['is_mod'])
      echo '<li><a href="', $scripturl, '?action=moderate">moderatie</a></li>';


      // Go to PM center... [pm]
   if ($context['user']['is_logged'] && $context['allow_pm'])
      echo '<li><a href="', $scripturl, '?action=pm">Mijn Inbox ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a></li>';

     // Edit Profile... [profile]
   if ($context['allow_edit_profile'])
      echo '<li><a href="', $scripturl, '?action=profile">Mijn Profiel</a></li>';

     // The [bookmarks] button
   if ($context['user']['is_logged'])
      echo '<li><a href="', $scripturl, '?action=bookmarks">Mijn Favorieten</a></li>';

     // Edit profile pictures... [profile]
   if ($context['allow_edit_profile'])
      echo '<li><a href="', $scripturl, '?action=profile;u=',$ID_MEMBER,';sa=pictures">Mijn Fotoalbum</a></li>';

     // Edit profile buddies... [profile]
   if ($context['allow_edit_profile'])
      echo '<li><a href="', $scripturl, '?action=buddies">Mijn Vrienden</a></li>';


     // Edit stats... [profile]
   if ($context['allow_edit_profile'])
      echo '<li><a href="', $scripturl, '?action=profile;u=',$ID_MEMBER,';sa=statPanel">Mijn Statistieken</a></li>';

    // Edit topics... [profile]
   if ($context['allow_edit_profile'])
      echo '<li><a href="', $scripturl, '?action=profile;u=',$ID_MEMBER,';sa=showPosts">Mijn Topics</a></li>';

    // Edit topics... [profile]
   if ($context['allow_edit_profile'])
      echo '<li><a href="', $scripturl, '?action=profile;u=',$ID_MEMBER,';sa=notification">Mijn Notificaties</a></li>';

echo '</ul></div>';

  }

else

{
echo ' ';
}


}

karlbenson

which type of moderators does it not work for?

global moderators or board moderators?

Angelotus

I tested it with a global moderator

karlbenson

Then try

   if ($context['user']['is_mod'] || allowedTo('moderate_forum'))

If that still doesn't work, are you getting any error messages in your error logs.

Angelotus

Doesn't work for the global moderator. It does work for the admin though. I don't get any errors in my errorlog.

ccbtimewiz

#12
Couldn't you just use..


$mods = array(2, 3);
global $user_info;

if( in_array( $mods, $user_info['groups'] ) ) {
echo '<li><a href="', $scripturl, '?action=moderate">moderatie</a></li>'; }


If that doesn't work, then I have no clue.

Angelotus

Thanks for reply! Unfortunately it doesn't work either... I don't know why because it should work...

Rumbaar

Well I doubt you'll be able to get a trigger for general moderator out of the MessageIndex or board they are moderator in.  As they aren't a moderator out of that area and I'm sure the method of checking is in a way that it's not from user to board, but board to user.

Where are you calling this code from?
$show_page = array(1,2);
         if (!in_array($context['member']['group_id'], $show_page))


or
   $show_page = array("id1", "id2", etc);
   if($context['user']['is_admin'] || $context['can_moderate_forum'] || (in_array($context['member']['group'],$show_page)))
"An important reward for a job well done is a personal sense of worthwhile achievement."


[ Themes ]

Angelotus

in the template_menu in index.template.php

Rumbaar

Okay try:

Loads.php
Find:
// Set up the contextual user array.
$context['user'] = array(
'id' => &$ID_MEMBER,
'is_logged' => !$user_info['is_guest'],
'is_guest' => &$user_info['is_guest'],
'is_admin' => &$user_info['is_admin'],
'is_mod' => false,
'username' => &$user_info['username'],
'language' => &$user_info['language'],
'email' => &$user_info['email']
);
and replace with:
// Set up the contextual user array.
$context['user'] = array(
'id' => &$ID_MEMBER,
'is_logged' => !$user_info['is_guest'],
'is_guest' => &$user_info['is_guest'],
'is_admin' => &$user_info['is_admin'],
'groups_ids' => &$user_info['groups'],
'is_mod' => false,
'username' => &$user_info['username'],
'language' => &$user_info['language'],
'email' => &$user_info['email']
);


In in your index.template.php file use $context['user']['groups_ids'] to return a users group ID array (list of all membergroup ID's, primary/secondary).  Now you can use array_intersect() to check for a person membership to a membergroup.
example
$show_page = array(id1,id2,etc);
         if (array_intersect($context['user']['groups_ids'], $show_page))
echo 'Yes you are in the selected membergroup ID's';
else
echo ' You are not a member of the selected groups.';
"An important reward for a job well done is a personal sense of worthwhile achievement."


[ Themes ]

Angelotus

Thanks Rumbaar!
One question. In my load.php I have

'is_mod' => &$user_info['is_mod'], instead of 'is_mod' => false,

Is that ok?

Rumbaar

#18
Ah, oops. I gave you the code from 1.1.x Load.php file.  The additional code should be 'groups_ids' => &$user_info['groups'], and should insert there just fine, even with 2.x.  Though I did test with only 1.1.x.
"An important reward for a job well done is a personal sense of worthwhile achievement."


[ Themes ]

Angelotus

BTW: that code worked perfect! Very kind of you te help me out with this!!!

Advertisement: