Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Can edit own posts "forever" vs "until there has been a reply"
Avatar
Peter
Member
Free Members
sp_UserOfflineSmall Offline
Nov 15, 2014 - 9:54 pm

On one of my forums, I used to have the permission "Can edit own posts forever" configured for normal members.  That was until a forum user decided to remove all of his posts and really mess up some of the conversation histories for some threads.

I then changed the permission to "Can edit own posts until there has been a reply" but some members complained that they wanted to make legitimate edits (corrections, mostly) after someone had replied.

So... I decided to hack the "Can edit own posts forever" to become "Can edit own posts for 24 hours".

It would be nice to add this as a proper option, although presumably you would have to allow administrators to edit the number of minutes / hours / days for which editing is allowed.

For anyone who is interested in similar functionality, here are the edits (hack style) made to 5.1.  (I need to upgrade to 5.5...):

--- forum/content/ahah/sp-ahah-admintoollinks.orig.php 2014-11-15 18:20:46.431004577 -0800
+++ forum/content/ahah/sp-ahah-admintoollinks.php 2014-11-15 18:20:09.066004390 -0800
@@ -113,7 +113,7 @@
}
if (sp_get_auth('edit_any_post', $forum['forum_id']) ||
- ($post['user_id'] == $spThisUser->ID && (sp_get_auth('edit_own_posts_forever', $forum['forum_id']) || (sp_get_auth('edit_own_posts_reply', $forum['forum_id']) && $last)))) {
+ ($post['user_id'] == $spThisUser->ID && ( ( sp_get_auth('edit_own_posts_forever', $forum['forum_id'] ) && ( strtotime( $post['post_date'] ) > ( time() - 86400 ) ) ) || (sp_get_auth('edit_own_posts_reply', $forum['forum_id']) && $last)))) {
$out.= '<div class="spForumToolsEdit">';
$out.= '<img class="spIcon" src="'.SPTHEMEICONSURL.'sp_ToolsEdit.png" alt="" title="" />';
$out.= '<a href="javascript:document.admineditpost'.$post['post_id'].'.submit();">'.sp_text('Edit this post').'</a>';
@@ -266,4 +266,4 @@
}

--- forum/content/sp-topic-view-functions.orig.php 2014-11-15 18:18:51.315004473 -0800
+++ forum/content/sp-topic-view-functions.php 2014-11-15 18:17:44.113004427 -0800
@@ -1192,7 +1192,7 @@
$canEdit = true;
} else {
if ($spThisPostUser->ID == $spThisUser->ID &&
- (sp_get_auth('edit_own_posts_forever', $spThisTopic->forum_id) ||
(sp_get_auth('edit_own_posts_reply', $spThisTopic->forum_id) && $spThisPost->last_post))) {
+ ( ( sp_get_auth('edit_own_posts_forever', $spThisTopic->forum_id ) && ( strtotime( $spThisPost->post_date ) > ( time() - 86400 ) ) ) ||
$canEdit = true;
}
@@ -1968,8 +1968,8 @@
if (sp_get_auth('view_email', $spThisTopic->forum_id) ||
sp_get_auth('pin_posts', $spThisTopic->forum_id) ||
sp_get_auth('edit_any_post', $spThisTopic->forum_id) ||
- (sp_get_auth('edit_own_posts_forever', $spThisTopic->forum_id) && $spThisUser->member && $spThisPostUser->ID == $spThisUser->ID) ||
- (sp_get_auth('edit_own_posts_forever', $spThisTopic->forum_id) && $spThisUser->guest && $spThisPostUser->guest_email == $spThisUser->guest_email) ||
+ (sp_get_auth('edit_own_posts_forever', $spThisTopic->forum_id) && ( strtotime( $spThisPost->post_date ) > ( time() - 86400 ) ) && $spThisUser->member && $spThisPostUser->ID == $spThisUser->ID) ||
+ (sp_get_auth('edit_own_posts_forever', $spThisTopic->forum_id) && ( strtotime( $spThisPost->post_date ) > ( time() - 86400 ) ) && $spThisUser->guest && $spThisPostUser->guest_email == $spThisUser->guest_email) ||
(sp_get_auth('edit_own_posts_reply', $spThisTopic->forum_id) && $spThisUser->member && $spThisPostUser->ID == $spThisUser->ID && $spThisPost->last_post) ||

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Nov 16, 2014 - 1:17 am

well now... we have an open ticket to consider a time based option for allowing edits to posts...

would it be possible for you to post the above using the code syntax highlighter?  makes it easier to read and ensure proper character encoding...  we could take a look at it an consider incorporation into the next release...

to use the syntax highlighter, paste your code into the editor window... then highlight (ie select) your code... go up to the code syntax highlighter button (looks like a piece of paper with letter O on it)... and select php...

a bit worried about the currency though if really against 5.1 (latest version is 5.5.2)...

Avatar
Peter
Member
Free Members
sp_UserOfflineSmall Offline
Nov 16, 2014 - 1:44 am

Ah, sorry about that.  I thought I'd selected the PHP syntax highlighter, but something went awry...

--- simple-press/forum/content/ahah/sp-ahah-admintoollinks.orig.php 2014-11-15 18:20:09.066004390 -0800
+++ simple-press/forum/content/ahah/sp-ahah-admintoollinks.php 2014-11-15 18:35:25.118004258 -0800
@@ -113,7 +113,7 @@
 }
 
 if (sp_get_auth('edit_any_post', $forum['forum_id']) ||
- ($post['user_id'] == $spThisUser->ID && (sp_get_auth('edit_own_posts_forever', $forum['forum_id']) || (sp_get_auth('edit_own_posts_reply', $forum['forum_id']) && $last)))) {
+ ($post['user_id'] == $spThisUser->ID && ( ( sp_get_auth('edit_own_posts_forever', $forum['forum_id'] ) && ( strtotime( $post['post_date'] ) > ( time() - 86400 ) ) ) || (sp_get_auth('edit_own_posts_reply', $forum['forum_id']) && $last)))) {
 $out.= '<div class="spForumToolsEdit">';
--- simple-press/forum/content/sp-topic-view-functions.orig.php 2014-11-15 18:17:44.113004427 -0800
+++ simple-press/forum/content/sp-topic-view-functions.php 2014-11-15 18:36:42.940005212 -0800
@@ -1192,7 +1192,7 @@
 $canEdit = true;
 } else {
 if ($spThisPostUser->ID == $spThisUser->ID &&
- (sp_get_auth('edit_own_posts_forever', $spThisTopic->forum_id) ||
+ ( ( sp_get_auth('edit_own_posts_forever', $spThisTopic->forum_id ) && ( strtotime( $spThisPost->post_date ) > ( time() - 86400 ) ) ) ||
 (sp_get_auth('edit_own_posts_reply', $spThisTopic->forum_id) && $spThisPost->last_post))) {
 $canEdit = true;
 }
@@ -1968,8 +1968,8 @@
 if (sp_get_auth('view_email', $spThisTopic->forum_id) ||
 sp_get_auth('pin_posts', $spThisTopic->forum_id) ||
 sp_get_auth('edit_any_post', $spThisTopic->forum_id) ||
- (sp_get_auth('edit_own_posts_forever', $spThisTopic->forum_id) && $spThisUser->member && $spThisPostUser->ID == $spThisUser->ID) ||
- (sp_get_auth('edit_own_posts_forever', $spThisTopic->forum_id) && $spThisUser->guest && $spThisPostUser->guest_email == $spThisUser->guest_email) ||
+ (sp_get_auth('edit_own_posts_forever', $spThisTopic->forum_id) && ( strtotime( $spThisPost->post_date ) > ( time() - 86400 ) ) && $spThisUser->member && $spThisPostUser->ID == $spThisUser->ID) ||
+ (sp_get_auth('edit_own_posts_forever', $spThisTopic->forum_id) && ( strtotime( $spThisPost->post_date ) > ( time() - 86400 ) ) && $spThisUser->guest && $spThisPostUser->guest_email == $spThisUser->guest_email) ||
 (sp_get_auth('edit_own_posts_reply', $spThisTopic->forum_id) && $spThisUser->member && $spThisPostUser->ID == $spThisUser->ID && $spThisPost->last_post) ||

All I'm doing is checking the post date timestamp against a lookback period. The code should be quite similar in 5.5, although you would also need to add a check on the actual edit, not just on the display of the button.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Nov 16, 2014 - 1:03 pm

Thanks Peter... we will take a look and see if we can adapt it to the latest 5.5.3 released version...

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626