Advertisement:

Author Topic: Don't Show Last Edit If Updater Is Admin  (Read 111630 times)

Offline 127.0.0.1

  • Jr. Member
  • **
  • Posts: 265
  • Gender: Male
Don't Show Last Edit If Updater Is Admin
« on: September 05, 2004, 05:12:17 PM »
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...

Code: [Select]
// 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?

Offline Radianation

  • Sophist Member
  • *****
  • Posts: 1,269
  • Gender: Male
  • Why not believe in me?
Re: Don't Show Last Edit If Updater Is Admin
« Reply #1 on: September 05, 2004, 05:20:01 PM »
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.

Offline 127.0.0.1

  • Jr. Member
  • **
  • Posts: 265
  • Gender: Male
Re: Don't Show Last Edit If Updater Is Admin
« Reply #2 on: September 05, 2004, 05:38:01 PM »
Would it look like this?

Code: [Select]
// 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.
« Last Edit: September 05, 2004, 05:40:28 PM by 127.0.0.1 »

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Don't Show Last Edit If Updater Is Admin
« Reply #3 on: September 05, 2004, 05:49:35 PM »
Find, Sources/Post.php:

Code: [Select]
// 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:

Code: [Select]
// 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]

Offline Elijah Bliss

  • Sophist Member
  • *****
  • Posts: 1,340
Re: Don't Show Last Edit If Updater Is Admin
« Reply #4 on: September 08, 2004, 01:30:52 PM »
Find, Sources/Post.php:

Code: [Select]
// 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:

Code: [Select]
// 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.

Offline Skoen

  • Language Moderator
  • SMF Friend
  • Sr. Member
  • *
  • Posts: 872
  • Gender: Male
  • I'm a shoe, so don't step on me ;)
    • Radio 3 Norge
Re: Don't Show Last Edit If Updater Is Admin
« Reply #5 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?
Alf Otto 'Skoen' Fagermo
Retired Norwegian translator


bloc

  • Guest
Re: Don't Show Last Edit If Updater Is Admin
« Reply #6 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:
Code: [Select]
                // Show "« Last Edit: Time by Person »" if this post was edited.
                if ($settings['show_modify'] && !empty($message['modified']['name']))

and replace with

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

Offline Elijah Bliss

  • Sophist Member
  • *****
  • Posts: 1,340
Re: Don't Show Last Edit If Updater Is Admin
« Reply #7 on: September 08, 2004, 03:13:44 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.

Offline Elijah Bliss

  • Sophist Member
  • *****
  • Posts: 1,340
Re: Don't Show Last Edit If Updater Is Admin
« Reply #8 on: September 08, 2004, 03:18:14 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:
Code: [Select]
                // Show "« Last Edit: Time by Person »" if this post was edited.
                if ($settings['show_modify'] && !empty($message['modified']['name']))

and replace with

Code: [Select]
                // 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.
« Last Edit: September 08, 2004, 03:42:35 PM by Elijah Bliss »

Offline 127.0.0.1

  • Jr. Member
  • **
  • Posts: 265
  • Gender: Male
Re: Don't Show Last Edit If Updater Is Admin
« Reply #9 on: September 08, 2004, 03:34:40 PM »
it worked fine for me

bloc

  • Guest
Re: Don't Show Last Edit If Updater Is Admin
« Reply #10 on: September 08, 2004, 06:05:31 PM »
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?

Offline 127.0.0.1

  • Jr. Member
  • **
  • Posts: 265
  • Gender: Male
Re: Don't Show Last Edit If Updater Is Admin
« Reply #11 on: September 08, 2004, 06:38:28 PM »
 ??? The mod keeps all edits visible, except for an admin edit.

Offline Elijah Bliss

  • Sophist Member
  • *****
  • Posts: 1,340
Re: Don't Show Last Edit If Updater Is Admin
« Reply #12 on: September 09, 2004, 12:24:55 AM »
??? 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

  • Guest
Re: Don't Show Last Edit If Updater Is Admin
« Reply #13 on: September 09, 2004, 04:19:55 AM »
??? 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. :)


Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Don't Show Last Edit If Updater Is Admin
« Reply #14 on: September 10, 2004, 03:54:08 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

  • Guest
Re: Don't Show Last Edit If Updater Is Admin
« Reply #15 on: September 10, 2004, 04:32:30 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 ;)

Offline Elijah Bliss

  • Sophist Member
  • *****
  • Posts: 1,340
Re: Don't Show Last Edit If Updater Is Admin
« Reply #16 on: September 10, 2004, 09:01:50 PM »
$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.

Offline tenera

  • Newbie
  • *
  • Posts: 3
  • Gender: Female
Re: Don't Show Last Edit If Updater Is Admin
« Reply #17 on: September 19, 2004, 02:37:53 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.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Don't Show Last Edit If Updater Is Admin
« Reply #18 on: September 19, 2004, 03:45:10 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.

Quote
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.

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

Where 'admin' is your username.

-[Unknown]

Offline HRM

  • Jr. Member
  • **
  • Posts: 333
  • Gender: Male
  • Dutch & Belgium musicforum
    • Muziekforum.com
Re: Don't Show Last Edit If Updater Is Admin
« Reply #19 on: September 26, 2004, 10:32:19 AM »
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