News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Message Icon Permissions...

Started by ccbtimewiz, November 26, 2007, 07:16:46 PM

Previous topic - Next topic

ccbtimewiz

mm, I'm trying to write a modification that allows me to designate what membergroups can post certain message icons on certain/all boards.

At the moment, SMF has the function to restrict certain message icons to ONE board, and it has no function to allow certain membergroups using them in MULTIPLE boards.

What I'm trying to do is allow staff to choose a certain message icon when they make special threads, but I can't seem to find where I would alter the code, or to where I would alter the code to allow more then one board.

Can anyone help me with this? ^^;

SleePy

You could modify the template to only allow staff to see those icons. As long as they exist in the directory they could still be used in any board.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

ccbtimewiz

Well, my original intention was to allow staff to choose an "extra" icon on each board with their message icons. Like whenever a staff member makes a post, the icon to designate that it is a "special" post would be in the drop-down, but if a normal user posts, they cannot choose to use that icon, they can only view it.

SleePy

Ok.. You will need to edit it to match for your setup.

Open Post.php
Find:
if (!empty($context['icons']))
$context['icons'][count($context['icons']) - 1]['is_last'] = true;


Add before:
global $user_info;
$staff_groups = array(1, 5, 7);
if (in_array($user_info['groups'], $staff_groups))
{
$context['icons'][] = array(
'value' => 'MyImage',
'name' => 'Staff Icon',
'url' => $settings['theme_dir'] . '/images/post/MyImage.gif',
'is_last' => false,
}
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

ccbtimewiz

So, something like this would work?

global $user_info;
$staff_groups = array(1, 2, 44);
if (in_array($user_info['groups'], $staff_groups))
{
$context['icons'][] = array(
'value' => 'exclamation',
'name' => 'Staff Icon',
'url' => $settings['theme_dir'] . '/images/post/exclamation.gif',
'is_last' => false,
}

codenaught

That looks about right. You can always try it to see what it does. If there is any severe problems like a parse error you can always revert the changes or replace that file with a backup of the file.

Edit: Note quite actually.

Make it:

global $user_info;
$staff_groups = array(1, 2, 44);
if (in_array($user_info['groups'], $staff_groups))
{
$context['icons'][] = array(
'value' => 'exclamation',
'name' => 'Staff Icon',
'url' => $settings['theme_dir'] . '/images/post/exclamation.gif',
'is_last' => false,
                );
}
Dev Consultant
Former SMF Doc Coordinator

ccbtimewiz

Hmm...

I put in the code, but when I made a post as a regular member, I still had the ability to post the staff icon. x.x

Kays

#7
Try changing the permissions of that icon so it's not available in all boards.

Thanks for posting that SleePy, It's something I've been looking for a way to do also.


Edit, another small correction:

Replace this line:

if (in_array($user_info['groups'], $staff_groups))

with this:

if (in_array($user_info['groups'][0], $staff_groups))


Work great. :)

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

ccbtimewiz


Kays

What doesn't work? It works fine for me. Did you see my edit?

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

ccbtimewiz

#10
It doesn't work. It shows TWO icons instead of one and anyone can see them.


$staff_groups = array(1, 2, 44);
if (in_array($user_info['groups'][0], $staff_groups))
{
$context['icons'][0] = array(
'value' => 'exclamation',
'name' => 'LyokoGeniuses Icon',
'url' => $settings['theme_dir'] . '/images/post/exclamation.gif',
'is_last' => false,
                );
}


EDIT: Lulz, I removed the transcript
  • and it worked. XD

Kays

Did you go into the Admin CP and change the permissions of that icon so that it's not available on all boards.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Advertisement: