News:

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

Main Menu

Only PM The Admin

Started by TMR Guy, December 22, 2014, 07:30:32 PM

Previous topic - Next topic

TMR Guy

Is there a way for me to make it so a (just one) Membergroup can only PM me?

Arantor


Sir Osis of Liver

How about this?

PersonalMessage.template.php -



/// To and bcc. Include a button to search for members.

if ($user_info['groups']['0'] == '2')
{
echo '
<dt>
<span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_to']) ? ' class="error"' : ''), '>', $txt['pm_to'], ':</span>
</dt>
<dd id="pm_to" class="clear_right">

<input type="text" name="to" id="to_control" value="Admin" readonly="yes" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />';
}
else
{
echo '
<dt>
<span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_to']) ? ' class="error"' : ''), '>', $txt['pm_to'], ':</span>
</dt>';

// Autosuggest will be added by the JavaScript later on.
echo '
<dd id="pm_to" class="clear_right">
<input type="text" name="to" id="to_control" value="', $context['to_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />';

// A link to add BCC, only visible with JavaScript enabled.
echo '
<span class="smalltext" id="bcc_link_container" style="display: none;"></span>';

// A div that'll contain the items found by the autosuggest.
echo '
<div id="to_item_list_container"></div>';

echo '
</dd>';

// This BCC row will be hidden by default if JavaScript is enabled.
echo '
<dt  class="clear_left" id="bcc_div">
<span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_bcc']) ? ' class="error"' : ''), '>', $txt['pm_bcc'], ':</span>
</dt>
<dd id="bcc_div2">
<input type="text" name="bcc" id="bcc_control" value="', $context['bcc_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />
<div id="bcc_item_list_container"></div>
</dd>';
}



Selected group sees 'Admin' in 'To:' input, and can't change it.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor

Because browsers don't have dev tools built in to change this, of course. Depending on the audience this may or may not be appropriate ;)

Sir Osis of Liver

You lost me there.  It's just an alternate input field that's shown to the restricted group, value is admin, and it's set to readonly, so it can't be changed.

BTW, just reading that Joe Cocker died.  Bummer. :(
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

margarett

Yes, but if you're using, eg, Firebug, you can easily remove the "readonly" property on the fly ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Sir Osis of Liver

Never use Firebug.  How does it allow a user to change the code?  And why would anyone bother?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor

Same way Chrome dev tools do: they let you examine the code currently in force and then to edit any attributes attached that you want to change.

Attached is an example of me changing the colour of the poster link to green on this forum just now. Firefox+Firebug, Chrome and Opera can all do this, not sure about IE off hand.

Why? To get around the sort of 'limitation' you just tried to suggest...

Sir Osis of Liver

Well then, you could do this -



if ($user_info['groups']['0'] == '2')
{
echo '
<dt>
<span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_to']) ? ' class="error"' : ''), '>', $txt['pm_to'], ':</span>
</dt>
<dd id="pm_to" class="clear_right">

<div style="width:130px; border: 1px #7F9DB9 solid; padding: 2px; font: 95%/115% verdana, Helvetica, sans-serif; color: #000; background: #fff;" >Admin</div>

<input type="hidden" name="to" value="Admin">';
}
else



Looks and works the same.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor

And just as manipulatable.

Seriously: anything in the browser can be manipulated client-side. The only way to ensure it can't be abused is to do it server-side.

Sir Osis of Liver

Ok, I understand your point.  Will have another look tomorrow.  Never ran a board where I had an adversarial relationship with my members.  I set things up to work a certain way, and nobody questioned it.  I would imagine either solution would work well enough to satisify op's needs, but his situation could be quite different from what I've experienced.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

TMR Guy

Thanks guys, I was just hoping for a box to check lol. All that stuff is waaaaayy over my head.

Arantor

This is kind of the point though... if you have to put in such rules as 'people can only PM the admin', it's inherently creating a sort of adversial attitude...

Sir Osis of Liver

Looks like it could be done in PersonalMessage.php, too tired to do it tonight.

Quote from: TMR Guy on December 22, 2014, 11:38:34 PM
Thanks guys, I was just hoping for a box to check lol. All that stuff is waaaaayy over my head.

If it's doable, I'll give you the modded files and you can try it.

But for now ...... 
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

This seems to work -

PersonalMessage.php



/// Do the actual sending of the PM.

if ($user_info['groups']['0'] == '1' && !empty($recipientList['to'])
unset($recipientList['to']);
$recipientList['to']['member'] = '69';

if (!empty($recipientList['to']) || !empty($recipientList['bcc']))



Any pm sent by group 1 (admin for test purposes) to any member is redirected to member #69.  It's server side, and would be used with either of the input field mods I posted last night.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

TMR Guy

Quote from: Krash on December 23, 2014, 04:00:25 PM
This seems to work -

PersonalMessage.php



/// Do the actual sending of the PM.

if ($user_info['groups']['0'] == '1' && !empty($recipientList['to'])
unset($recipientList['to']);
$recipientList['to']['member'] = '69';

if (!empty($recipientList['to']) || !empty($recipientList['bcc']))



Any pm sent by group 1 (admin for test purposes) to any member is redirected to member #69.  It's server side, and would be used with either of the input field mods I posted last night.
Thanks...

I'm really new at this, how do I install (am I saying it right?) this. If it's done via Cpanel I'm sure my webhost will walk me through it.

Kindred

Ummm.... No.  You don't install anything.   What krash gave you were the EDITS that need to be made to the code in existing file(s)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

TMR Guy

That's going to be a little over my head (I don't know how to do that). What would be the best/easiest way for me edit the code? I'm open for any suggestions, I really would like to learn how to do it.

Thanks,

TMR Guy


Sir Osis of Liver

Are you able to upload files to your forum, via ftp or cpanel?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

TMR Guy

Quote from: Krash on December 24, 2014, 12:50:04 PM
Are you able to upload files to your forum, via ftp or cpanel?
I don't know how to do that.  :-[


Advertisement: