Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: ccbtimewiz on November 26, 2007, 07:16:46 PM

Title: Message Icon Permissions...
Post by: ccbtimewiz on November 26, 2007, 07:16:46 PM
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? ^^;
Title: Re: Message Icon Permissions...
Post by: SleePy on December 12, 2007, 10:57:35 PM
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.
Title: Re: Message Icon Permissions...
Post by: ccbtimewiz on December 14, 2007, 04:35:06 PM
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.
Title: Re: Message Icon Permissions...
Post by: SleePy on December 16, 2007, 11:48:39 PM
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,
}
Title: Re: Message Icon Permissions...
Post by: ccbtimewiz on December 17, 2007, 02:49:03 PM
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,
}
Title: Re: Message Icon Permissions...
Post by: codenaught on December 17, 2007, 06:02:28 PM
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,
                );
}
Title: Re: Message Icon Permissions...
Post by: ccbtimewiz on December 17, 2007, 07:57:41 PM
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
Title: Re: Message Icon Permissions...
Post by: Kays on December 17, 2007, 08:19:13 PM
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. :)
Title: Re: Message Icon Permissions...
Post by: ccbtimewiz on December 17, 2007, 09:26:51 PM
Still doesn't work. x.x

Title: Re: Message Icon Permissions...
Post by: Kays on December 17, 2007, 09:33:35 PM
What doesn't work? It works fine for me. Did you see my edit?
Title: Re: Message Icon Permissions...
Post by: ccbtimewiz on December 17, 2007, 09:45:23 PM
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
Title: Re: Message Icon Permissions...
Post by: Kays on December 17, 2007, 09:49:04 PM
Did you go into the Admin CP and change the permissions of that icon so that it's not available on all boards.