News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Automatic Message Icon

Started by Old Lynx, June 11, 2008, 04:04:11 AM

Previous topic - Next topic

Old Lynx

Hi Guys

Can someone tell me How to disable normal memebers from using Message Icons. I want the Admin to be the only one who can use them.



Any help given would be greatly appreciated.

Thanks Guys

Old Lynx

is this hard to do ? someone please help :(


Cccddd

If you want to get rid of members' ability to use message icons, just edit the Post.template.php so if they aren't an admin then it doesnt show the option.

adding buttons... that's a lot more difficult.

Old Lynx

#4
Hi Cheschire :)

OK can you tell me what code exactly I need to look for in the post.template.php and what do I change it to ? I'm a n00b so clear instructions would be greatly appreciated. Let's do this easy bit first and then get onto the buttons !

Thanks man :)

Jade Elizabeth

In my experience when I removed that, and the users edited the post, it would look for an icon called ".gif" instead of "xx.gif" and it caused a lot of trouble. There is a mod you can use however:

http://custom.simplemachines.org/mods/index.php?mod=1168
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Jade Elizabeth

If you're in 1.1.x you can use this:

'altlinks' => array('code' => 'altlinks', 'before' => '[center][b][size=14]ALTERNATE LINKS[/size][/b][/center]', 'description' => 'altlinks'),


Put that after the button you like in the post.template.php, for the end of the list search for this:

'list' => array('code' => 'list', 'before' => '[list]\n[li]', 'after' => '[/li]\n[li][/li]\n[/list]', 'description' => $txt[261]),


Put an image in the theme folders > bbc > altlinks.gif

Karl has been teaching me to make BBC tags :D.
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Old Lynx

Thanks Alundra You are a GREAT HELP :)

Thanks :)

Bulakbol

To hide message icon from the rest except admin, in the default/Post.template.php, look for
// Now show the subject box for this post.
echo '
<tr>
<td align="right" style="font-weight: bold;', isset($context['post_error']['no_subject']) ? 'color: red;' : '', '" id="caption_subject">
', $txt[70], ':
</td>
<td>
<input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" />
</td>
</tr>
<tr>
<td align="right">
<b>', $txt[71], ':</b>
</td>
<td>
<select name="icon" id="icon" onchange="showimage()">';

// Loop through each message icon allowed, adding it to the drop down list.
foreach ($context['icons'] as $icon)
echo '
<option value="', $icon['value'], '"', $icon['value'] == $context['icon'] ? ' selected="selected"' : '', '>', $icon['name'], '</option>';

echo '
</select>
<img src="', $context['icon_url'], '" name="icons" hspace="15" alt="" />
</td>
</tr>';



and replace with
// Now show the subject box for this post.
echo '
<tr>
<td align="right" style="font-weight: bold;', isset($context['post_error']['no_subject']) ? 'color: red;' : '', '" id="caption_subject">
', $txt[70], ':
</td>
<td>
<input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" />
</td>
</tr>';
if ($context['user']['is_admin'])
{
echo '
<tr>
<td align="right">
<b>', $txt[71], ':</b>
</td>
<td>
<select name="icon" id="icon" onchange="showimage()">';

// Loop through each message icon allowed, adding it to the drop down list.
foreach ($context['icons'] as $icon)
echo '
<option value="', $icon['value'], '"', $icon['value'] == $context['icon'] ? ' selected="selected"' : '', '>', $icon['name'], '</option>';

echo '
</select>
<img src="', $context['icon_url'], '" name="icons" hspace="15" alt="" />
</td>
</tr>';
}
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Jade Elizabeth

No problem at  all :)

JB, that caused troubles for me last time when non admin users inline (mostly) edited...
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Bulakbol

oh really? I didn't test it. Thanks Alundra. I'll test it when I have a chance.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Jade Elizabeth

No problem, the topic is missing from my site, otherwise I would link you, but basically my users noticed it and I didnt (firefox doesnt display boxes for missing images) so they reported it.

They tested it out, and turns out inline and normal edit messed it up, made the post look for ".gif" instead of "xx.gif".
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Bulakbol

#12
I tested the codes I posted above and the error was undefined index "icon". If you would like to try the above codes, you have to edit Sources/Post.php too. Look for
'icon' => preg_replace('~[\./\\\\*\':"<>]~', '', $_POST['icon']),

and replace with
'icon' => !empty($_POST['icon']) ? preg_replace('~[\./\\\\*\':"<>]~', '', $_POST['icon']) : '',


edit: The snippet of code I posted will only hide the icons from regular members. Admin can change it, so there will be no missing icon error.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Old Lynx

OK let me go and backup them two files and edit them.

I'll let you guys know if it worked !

thanks :)

Old Lynx

OK I just did them code changes and it didn't work !!

All regular members can still see it ! :(

Jade Elizabeth

Are you sure you copied the entire code? JB's code looks right to me.
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Old Lynx


Jade Elizabeth

So you edited the post template inside all the themes, and then the post source file too?
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Old Lynx

lol no not inside all theme !! only inside the default theme ! cause that is what he said !!

So I should go and do it for every single theme ?

Old Lynx

OMG it WORKED !!!

I did it for the default theme and the theme I was currently using and it worked !!!!!

Thanks VERY MUCH Alundra and JohnyB  You guys are GREAT :)

Thanks :)

Old Lynx

Problem ! :(

maybe I should have said this before > I'm sorry guys !

The reason I want to disable the Message Icon for other members is was because they weren't using the Standard icon > they were going and choosing other like thumbs up > thumb down > smily face ...etc >> it all looked messy ! So I want all their posts to be the standard icon !

after doing the above mod > I just relised (not two minutes ago) that even the standard icon has now been removed !!!!

What do I do to disable their choice of message icons > but make their posts automatically appear with a standard icon !!

thanks guys

Bulakbol

You can try this then. Disregard my other codes. In the Sources/Post.php find
// Collect all parameters for the creation or modification of a post.

add this line above it.
$_POST['icon'] = !empty($_POST['icon']) ? $_POST['icon'] : 'xx';

Then in the Post.template.php find
<b>', $txt[71], ':</b>
</td>
<td>

replace with

<b>', $txt[71], ':</b>
</td>
<td>';
if (($modSettings['hide_message_icon'] == 0) || $context['user']['is_admin'])
{
echo '


find

</select>
<img src="', $context['icon_url'], '" name="icons" hspace="15" alt="" />


and replace with

</select>';
}
echo '
<img src="', $context['icon_url'], '" name="icons" hspace="15" alt="" />


Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Old Lynx

so do I undo the changes I did from your old instructions ?

Bulakbol

Yes, undo the first changes. Use the original files before the changes.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Old Lynx

Hi JohnyB :)

OK I un-did the previous changes then edit it again to the code above > but again the normal members can use whatever image icon they want to use !!

by the way I did the changes in the Default theme and in my current theme ! still doesn't work :(

Bulakbol

Woopppps sorry, I missed something. This line
if (($modSettings['hide_message_icon'] == 0) || $context['user']['is_admin'])

should be like this.
if ($context['user']['is_admin'])

sorry.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Jade Elizabeth

Or...

Admin > Smileys and Message Icons > Edit Message Icons (delete all but the one you want)
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Old Lynx

Hi Alundra

but wouldn't that stop me from using them as well !! I want the admins to have access to all the message icons > but the members and Mods to have access to the Standard Message Icon only !!

JohnyB I tried your thing and I got this huge error :(

{{ Template Parse Error!
It seems something has gone sour on the forum with the template system. This problem should only be temporary, so please come back later and try again. If you continue to see this message, please contact the administrator.

You can also try refreshing this page. }}

Please help :)

Bulakbol

Attach your Post.template.php and I'll edit it for you. You do the Sources/Post.php. :)
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Old Lynx

Hi Johnny :)

attached are the post.template.php and the post.php

thanks man :)

Old Lynx

by the way > that post.template.php is from my current theme !!

thanks

Bulakbol

Here are your edited files.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Old Lynx

OMG thanks JohnnyB that Worked perfectly !!!

you are a genius who is a GREAT HELP

Thanks again bro

Bulakbol

No worries bro. I'm glad I could help too.
Solved.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Jade Elizabeth

Just look at his picture, it SCREAMS genius :P

I'm glad you got it sorted :D
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Bulakbol

 :P Don't get deceived by illusion.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

locjan

are there no plugin to do it?
locjan.com - Free Korean Dramas OST shwoomp.com - Art of shwoomp

Jade Elizabeth

Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

meemzo

I would very much like this to work for me also.  I know it's been a long time since it was posted, but maybe it's become enough of a thing for someone to jump in and help me.  My problem would be that I don't want to download the edited post files as I may loose mods that have been installed.  Can anyone tell me what lines to edit?  As a precursor I have uploaded my files.

Advertisement: