Mod for editing the first post?

Started by Biology Forums, December 28, 2010, 12:16:01 AM

Previous topic - Next topic

Biology Forums

Is there a mod that prevents the topic starter from editing the first post of the topic (his/her's first post)?

SoLoGHoST

#1
This is a simple edit within Display.php.  No need for a MOD to do this, here ya go:

OPEN ./Sources/Display.php

FIND:
// Is this user the message author?
$output['is_message_author'] = $message['id_member'] == $user_info['id'];


AFTER, ADD:


// If it's the first post and the user is the message author...
if ($output['is_message_author'] && $output['id'] == $context['first_message'] && !$user_info['is_admin'])
$output['can_modify'] = false;


If you don't want administrator's editing their own first post within a topic, just remove the !$user_info['is_admin'] part within the if statement.  Ofcourse, if may be a good idea also to check if $output['can_modify'] == true within the if statement, but not really necessary.

Cheers :)


SoLoGHoST

Ok, a few more fixes in security for this:

Open up Post.php

FIND:

else
$context['becomes_approved'] = true;


REPLACE WITH:
else
{
$is_first_message = isset($_REQUEST['msg']) && $_REQUEST['msg'] == $id_first_msg;
$context['becomes_approved'] = true;
}


FIND:
// Editing a message...
elseif (isset($_REQUEST['msg']) && !empty($topic))


SCROLL DOWN a little and FIND this:
// The message they were trying to edit was most likely deleted.
// !!! Change this error message?


Scroll down a tad more, and you'll see this line:
if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))

BEFORE THAT LINE, ADD:
if ($row['id_member_poster'] == $user_info['id'] && $is_first_message)
redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);



This basically adds in the security if the user browses to that URL for modifying the first post within that topic and is the message author than it will just redirect that user to that topic and message instead.  Ofcourse, you can change this to a fatal_lang_error or fatal_error as well.

Well, hopefully this helps you.  Remember, if you want to allow the Administrator to modify their own first posts within topics, than you can do this to the above edit:

if ($row['id_member_poster'] == $user_info['id'] && $is_first_message && !$user_info['is_admin'])
redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);



Cheers :)

OK, I stand corrected, 3 Edits!  Go ahead and make a mod from it anyone, I don't care to.

Biology Forums

Thanks so much, I will try this and see if it works :laugh:

Biology Forums

SoLoGHoST,

the trouble I'm having is finding

// Is this user the message author?
$output['is_message_author'] = $message['id_member'] == $user_info['id'];


Are you using 1.1.12? by any chance?



SoLoGHoST

Opps, sorry bro, I'm doing my edits based on SMF 2.0.x.  I didn't notice that this is the 1.x support board.  But it shouldn't be that much different anyways, you'll just need to use the variables for 1.x instead of the variables for 2.0.  I don't have a copy of SMF 1.1.12 installed to play with.

Sorry about that.

Biology Forums

:-\ It's okay, but do you know this equivalent codes? Does anyone?

kat

Why not give your members a cursory edit time, then prevent them from editing ANY posts, thereafter?

Easily done in "Permissions".

Illori

it is under posts and topics not permissions.

kat

Both, as "Modify posts" is in "Permissions". ;)

Illori

well that is if they dont want anyone to modify their posts after they have been made, i am not sure that is what the wish is here.

Biology Forums

I don't mind them editing their work (i.e. posts other than the first). The thing is, I have students coming in, asking their questions, and then they come and erase what they wrote because they don't want it being searched by their teachers. I suppose I could give them a 5 minute grace period.

Biology Forums

Thanks Illori and K@... I gave them a 10 minute grace period to edit their work :) Questions are typically answered with an hour so that prevents them from editting anything thereafter :D Good advice!

Advertisement: