Skip to main content
Topic: Edit post permission (Read 4740 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Edit post permission

I would like to know if it's possible to set permission for editing posts like this:
- 120 minutes for all posts
- one board with no limits to edit posts

I made a permission set for a board so my users can modify their posts inside that board always (is our garage board) and it's working. The problem is if I set a max time for edits of 120 minutes it will be applied to all posts from all boards. Is that normal? Is there any way to set them as I want?
sorry for my bad english

Re: Edit post permission

Reply #1

Yep, at the moment the way it behaves is the one you described: once set it is for the whole forum.
Make it board-based shouldn't be too difficult. Most of the places can be fixed with just hooks, the only potentially problematic one are the unread replies/messages and the profile that would need a couple of edits.
Bugs creator.
Features destroyer.
Template killer.

Re: Edit post permission

Reply #2

For me it has no sense that "Maximum time after posting to allow edit" is set globally, I think it should be under Permissions. It also has no sense if I set the permission to edit own posts in a board to be overwrited by "Maximum time after posting to allow edit".

I thought on smf it was different but same behaviour. :(

Sorry but I have no knowledge to do that
sorry for my bad english

Re: Edit post permission

Reply #3

The few times I have seen it, it has always been "all or nothing" (i.e. applied to all the boards at the same time).

Nothing to be sorry about, I just added it as a sort of memo, at the moment I'm digging something else, I may check it in the next days, or maybe someone else could have some time to try it out. ;D
Bugs creator.
Features destroyer.
Template killer.

Re: Edit post permission

Reply #4

Will be nice to see it as an addon.  Maybe I should explain well why I need this :

For garage board is good because a member can always edit his first post adding all information about his car.
For Sell / Buy board is useful when a member adds more than one item to sell in one topic  he can always update the first topic removing the sold items.

Why I don't want a member to edit his own posts everywhere? As a community we cannot satisfy all members and there are always members who abandon a forum. That's not so bad, the bad part is that when they are leaving a community they try to make some  damages. I saw that on a forum when an old member with more than 2000 posts leaved,  he edited a good part of his posts and there were diX and Cox images everywhere. As a normal user there I did a big laugh, but for the Admin was not so funny  :D
sorry for my bad english

Re: Edit post permission

Reply #5

This is possible I'd say but as I can see you wish to combine it with current available settings, am I correct on this?

Re: Edit post permission

Reply #6

Yes, I would like to have 120 minutes for all posts and a couple of boards with no limits for editing posts.
sorry for my bad english

Re: Edit post permission

Reply #7

So, this permission is to bypass settings of time set in Post Settings page, if the board(s) are allowed to do so. I think in order to do that, if done manually, we need to edit two files.

Firstly, Message.subs.php where the code is:
Code: [Select]
if ($message['approved'] && !empty($modSettings['edit_disable_time']) && $message['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
and change that to:
Code: [Select]
if (!allowedTo('modify_anytime') && $message['approved'] && !empty($modSettings['edit_disable_time']) && $message['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())

Secondly, ManagePermissions.subs.php where the code is:
Code: [Select]
$groupLevels['board']['restrict'] = array(
Code: [Select]
$groupLevels['board']['restrict'] = array(
'modify_anytime',

Note: I haven't tested this code.

Re: Edit post permission

Reply #8

Thank you ahrasis, I will test that
sorry for my bad english

 

Re: Edit post permission

Reply #9

This is one way to approach it, the one I had in mind was slightly different.
My idea was to "replace" $modSettings['edit_disable_time'] "on-the-fly" based on the board.
You could have that as a permission or as board setting, for example:
Code: [Select]
if (allowedTo('modify_anytime'))
    $modSettings['edit_disable_time'] = 0;
added for example via the hooks  integrate_action_post, integrate_action_display and integrate_action_messageindex (actually I'm not entirely sure of the name of that last one, and it may be necessary to attach the code to some others), you could trick the system and make it think the member can or cannot edit the posts.
Alternatively, you can do it with a per-board setting, that would allow you to specify different edit times for different boards, like this:
Code: [Select]
global $board, $modSettings;

if (empty($board))
    return;

$perboard = @unserialize($modSettings['per_board_disable_times']);
if (isset($perboard[$board]))
    $modSettings['edit_disable_time'] = $perboard[$board];
plus of course the page to set the times (or the edit to the admin page).
And this one as well can be used with the hooks I suggested above.

Then, of course, you could combine the two for a bit of fun! lol
But indeed the one that works is the best! ;D
Bugs creator.
Features destroyer.
Template killer.

Re: Edit post permission

Reply #10

I tried but nothing changed, the edit button is not visible on posts older than two hours
sorry for my bad english

Re: Edit post permission

Reply #11

Sorry @radu81 , the code is right but you need to do more than just that. Please undo all the earlier suggested modifications.

Part #1 - Adding Board Permission
Now, find in two occurences of this in ManagePermissions.subs.php
Code: [Select]
		'modify_own',
Add after both:
Code: [Select]
		'modify_anytime',

Then find:
Code: [Select]
			'modify' => array(true, 'post'),
Add after:
Code: [Select]
			'modify_anytime' => array(false, 'post'),

Now, open ManagePermissions.english.php and find:
Code: [Select]
$txt['permissionname_modify_any'] = 'Any post';
Add after:
Code: [Select]
$txt['permissionname_modify_anytime'] = 'Modify posts at anytime';
$txt['permissionhelp_modify_anytime'] = 'Modify posts at anytime';

That all will cover permission addon manually.


Part #2 - Add it to message permission (from earlier code)
Same as before, open Messages.subs.php and find:
Code: [Select]
$message['approved'] && !empty($modSettings['edit_disable_time']) && $message['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
Add before
Code: [Select]
!allowedTo('modify_anytime') && 


Part #3 - Add it to post permission
There is two occurences of this code, one for modify and the other for quick edit:
Code: [Select]
!empty($modSettings['edit_disable_time'])
Add before:
Code: [Select]
!allowedTo('modify_anytime') && 

Part #4 - Displaying Modify Button
Find in Display.controller.php (to display modify / quick edit button):
Code: [Select]
'can_modify' => (!$context['is_locked'] || allowedTo('moderate_board')) && (allowedTo('modify_any') || (allowedTo('modify_replies') && $context['user']['started']) || (allowedTo('modify_own') && $message['id_member'] == $user_info['id'] && (empty($modSettings['edit_disable_time']) ||
Add after:
Code: [Select]
 allowedTo('modify_anytime') ||

I have tested the code and it is working. You can do it manually, or package this up or you can create a hook based it.

If there is any error or it is not working as expected, do report.

Re: Edit post permission

Reply #12

Thanks for your help @ahrasis

I edited all files as you recommended, I set the permission for that board, and I see both "Edit" and "Quick Edit" buttons on post view. The problem is in Quick edit whan I save the message the message is not saved (the quick editor stays opened) . In full edit I get a message error that I cannot modify the post because the time to modify a topic is expired.
sorry for my bad english

Re: Edit post permission

Reply #13

Please double check.

1. There are two occurences of code that needed to be changed in two files. Make sure they are both changed.
2. Make sure you don't mixed up add after and before. It means exactly what it says here, unlike in a package mod.
3. Do report if the situation is fixed or remain the same after you did the checking as I will pack this up for easy installation.

Re: Edit post permission

Reply #14

This addon is now packaged here: http://www.elkarte.net/community/index.php?topic=2407.0.

I do not know how change the code in Post.controller.php and Messages.subs.php as suggested above so they are still manually change via the said package. Any suggestion to change that via hook is highly appreciated.

Permission and display is however, "safely" changed via hook.