• Welcome to Simple Machines Community Forum. Please login or sign up.
November 27, 2021, 11:44:17 AM

News:

Wondering if this will always be free?  See why free is better.


Don't Show Last Edit If Updater Is Admin

Started by 127.0.0.1, September 05, 2004, 05:12:17 PM

Previous topic - Next topic

127.0.0.1

I'm trying to write a little mod that does what is stated in the topic. I successfully wrote one for YaBBSE and it looked like this...

// dont update modified time or name if updater is admin
if ($settings[7] != 'Administrator')
{
$request = mysql_query("UPDATE {$db_prefix}messages SET subject='$subject',icon='$icon', body='$message', modifiedTime=" . time() . ", modifiedName='" . addslashes($realname) . "', smiliesEnabled=$smilies WHERE ID_MSG=$postid $doLimitOne;") or database_error(__FILE__, __LINE__);
}
else
{
$request = mysql_query("UPDATE {$db_prefix}messages SET subject='$subject',icon='$icon', body='$message', smiliesEnabled=$smilies WHERE ID_MSG=$postid $doLimitOne;") or database_error(__FILE__, __LINE__);
}

There is no more modifymessage.php in SMF, but I'm pretty sure the mod would be done in post.php. What would I need to change?

Or better yet, maybe I can accomplish this by modding the display.template.php?

Radianation

Check post.php lines 1110 - 1126

The table with the check for admin is in smf_members titled "ID_GROUP"
From my understanding, if ID_GROUP = 1 then the user is administrator.

There are several members lookups in post.php. You should be able to find one that does what you want if you can't write it yourself.

I hope this helps.

127.0.0.1

September 05, 2004, 05:38:01 PM #2 Last Edit: September 05, 2004, 05:40:28 PM by 127.0.0.1
Would it look like this?


// Do not update modified time if poster is admin.
if ($_POST['ID_GROUP'] == 1)
$modifiedTime = '';


I know this is wrong because it doesn't work. $_POST['ID_GROUP'] is probably a non-existant variable.  I'm trying to figure out what the proper variable is that identifies if the poster is an admin.

[Unknown]

Find, Sources/Post.php:

// Have admins allowed people to hide their screwups?
if (time() - $row['posterTime'] > $modSettings['edit_wait_time'] || $ID_MEMBER != $row['ID_MEMBER'])
$modifiedTime = time();


See that?  Fix it ;) like so:

// Administrator edits should not be logged!
if ($user_info['is_admin'])
$modifiedTime = 0;
// Have admins allowed people to hide their screwups?
elseif (time() - $row['posterTime'] > $modSettings['edit_wait_time'] || $ID_MEMBER != $row['ID_MEMBER'])
$modifiedTime = time();


-[Unknown]

Elijah Bliss

Quote from: [Unknown] on September 05, 2004, 05:49:35 PM
Find, Sources/Post.php:

// Have admins allowed people to hide their screwups?
if (time() - $row['posterTime'] > $modSettings['edit_wait_time'] || $ID_MEMBER != $row['ID_MEMBER'])
$modifiedTime = time();


See that?  Fix it ;) like so:

// Administrator edits should not be logged!
if ($user_info['is_admin'])
$modifiedTime = 0;
// Have admins allowed people to hide their screwups?
elseif (time() - $row['posterTime'] > $modSettings['edit_wait_time'] || $ID_MEMBER != $row['ID_MEMBER'])
$modifiedTime = time();


-[Unknown]


This doesn't work for me, I still get the "last edit" below posts I modify.

Skoen

I think you will see it, as you are the administrator.
But have you checked with a test account to see if the normal user still can see it?
Alf Otto 'Skoen' Fagermo
Retired Norwegian translator


bloc

You could just change the Display.template.php file, but then you will not see your own edits. And you have to do it on every theme.

Just find this in Display.template.php:
                // Show "« Last Edit: Time by Person »" if this post was edited.
                if ($settings['show_modify'] && !empty($message['modified']['name']))


and replace with

                // Show "« Last Edit: Time by Person »" if this post was edited.
                if ($settings['show_modify'] && !empty($message['modified']['name']) && $context['user']['is_admin']!=1)

Elijah Bliss

Quote from: Skoen on September 08, 2004, 01:38:06 PM
I think you will see it, as you are the administrator.
But have you checked with a test account to see if the normal user still can see it?

Yeah, normal users can still see edits as well.

Elijah Bliss

September 08, 2004, 03:18:14 PM #8 Last Edit: September 08, 2004, 03:42:35 PM by Elijah Bliss
Quote from: Bloc on September 08, 2004, 01:50:18 PM
You could just change the Display.template.php file, but then you will not see your own edits. And you have to do it on every theme.

Just find this in Display.template.php:
                // Show "« Last Edit: Time by Person »" if this post was edited.
                if ($settings['show_modify'] && !empty($message['modified']['name']))


and replace with

                // Show "« Last Edit: Time by Person »" if this post was edited.
                if ($settings['show_modify'] && !empty($message['modified']['name']) && $context['user']['is_admin']!=1)


Now this mod worked but in reverse, the admin can't see his/hers "Last Edits" but everyone else can.




I just changed this from:
if ($settings['show_modify'] && !empty($message['modified']['name']) && $context['user']['is_admin']!=1)

to

if ($settings['show_modify'] && !empty($message['modified']['name']) && $context['user']['is_admin']!=0)

and it worked.

127.0.0.1


bloc

Of course....now I see that it actually makes all edits invisible - but not for admin. Oh,well. ;) Not exactly what was asked for but could be of use anyway?

127.0.0.1

 ??? The mod keeps all edits visible, except for an admin edit.

Elijah Bliss

Quote from: 127.0.0.1 on September 08, 2004, 06:38:28 PM
??? The mod keeps all edits visible, except for an admin edit.

I logged on as a regular user and I could still see the admin edit.

bloc

Quote from: Elijah Bliss on September 09, 2004, 12:24:55 AM
Quote from: 127.0.0.1 on September 08, 2004, 06:38:28 PM
??? The mod keeps all edits visible, except for an admin edit.

I logged on as a regular user and I could still see the admin edit.

Ok, I got a bit confused here, but this is more correct:

1.$settings['show_modify']...............................show if settings for showing edits are ON
2.&& !empty($message['modified']['name']).....AND if the name of the person editing is NOT empty
3.&& $context['user']['is_admin']==1)..............AND if person watching IS admin.

What $context['user']['is_admin']!=1) would do is show for all BUT the admin, and $context['user']['is_admin']!=0 - show for all that has 1 or nothing...which us unsafe.

So to be sure only the admin see edits ( all edits btw not just admin's edits) use $context['user']['is_admin']==1.

One must make sure all themes has it too...or else the persons with different themes from you will see it anyway.

Sorry for the confusion. :)


[Unknown]

Quote from: Bloc on September 09, 2004, 04:19:55 AM$context['user']['is_admin']!=1

Quote$context['user']['is_admin']!=0

Actually, it's not a number at all.  It's better to just say:

$context['user']['is_admin'] means they are an admin.
!$context['user']['is_admin'] means they aren't an admin.

In other words, I would suggest using:

$context['user']['is_admin'] instead of $context['user']['is_admin']!=0
!$context['user']['is_admin'] instead of $context['user']['is_admin']!=1

Regardless of that, this is not really a good way to do what at least the topic is about, and I don't see why they way I posted shouldn't work. (as long as you replace all the code I mentioned, event the elseif.)

-[Unknown]

bloc

Quote from: [Unknown] on September 10, 2004, 03:54:08 AM
Regardless of that, this is not really a good way to do what at least the topic is about, and I don't see why they way I posted shouldn't work. (as long as you replace all the code I mentioned, event the elseif.)

-[Unknown]

Agreed on that. It was a merely a alternative suggestion that got a bit out of hand ;)

Elijah Bliss

Quote from: [Unknown] on September 10, 2004, 03:54:08 AM
Quote from: Bloc on September 09, 2004, 04:19:55 AM$context['user']['is_admin']!=1

Quote$context['user']['is_admin']!=0

Actually, it's not a number at all.  It's better to just say:

$context['user']['is_admin'] means they are an admin.
!$context['user']['is_admin'] means they aren't an admin.

In other words, I would suggest using:

$context['user']['is_admin'] instead of $context['user']['is_admin']!=0
!$context['user']['is_admin'] instead of $context['user']['is_admin']!=1

Regardless of that, this is not really a good way to do what at least the topic is about, and I don't see why they way I posted shouldn't work. (as long as you replace all the code I mentioned, event the elseif.)

-[Unknown]

I dunno. I copied and pasted the code exactly the way you had it and as a regular user I can still see the last edit of the admin.

tenera

Quote from: Elijah Bliss on September 08, 2004, 01:30:52 PM
This doesn't work for me, I still get the "last edit" below posts I modify.

What happens is, any message you edit after you add the code, will not have an 'edit line', but a message that has already been edited will still have its 'edit line'. Also, on a previously edited post, the edit date will no longer change.

If you want the edit line to be gone from all of your posts, you will have to go into your database and set modifiedTime to 0, and modifiedName to NULL. Then the edit line will no longer appear on any of your posts. There is probably a relativily quick to do this, but I couldn't outline one for you. If you're relatively knowleagable of mySQL, you could probably write a script to go through all posts with posterName = yourname, and reset the values for modifiedName and modifiedTime.

[Unknown]

Quote from: tenera on September 19, 2004, 02:37:53 PM
What happens is, any message you edit after you add the code, will not have an 'edit line', but a message that has already been edited will still have its 'edit line'. Also, on a previously edited post, the edit date will no longer change.

Ah.  I thought that was implied.  I didn't realize it might be expected to be retroactive.  Thanks for clearing it up.

QuoteIf you want the edit line to be gone from all of your posts, you will have to go into your database and set modifiedTime to 0, and modifiedName to NULL. Then the edit line will no longer appear on any of your posts. There is probably a relativily quick to do this, but I couldn't outline one for you. If you're relatively knowleagable of mySQL, you could probably write a script to go through all posts with posterName = yourname, and reset the values for modifiedName and modifiedTime.

UPDATE smf_messages
SET modifiedTime = 0, modifiedName = NULL
WHERE modifiedName = 'admin';

Where 'admin' is your username.

-[Unknown]

HRM

Hm...The very first code [Unknown] gave works straigh away excellent for me.

Indeed I can see the Edits from before adding the code but for the new one it works perfect, i don't even see my own (new) edits.

Very helpful topic this one.
To install something for the cat's 'cut' is never nice..... (old dutch saying) :D

Advertisement: