Skip to main content
Topic: MPAAP: Modify Posts At Anytime Permissions (Read 2679 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

MPAAP: Modify Posts At Anytime Permissions


MPAAP: Modify Posts At Anytime Permission

- For ElkArte 1.0.x and 1.1 Beta x.
- Partially using hook, modifications on two files.

1. Please do your own backup though every installation is backed up automatically.
2. By default, forum members are usually not allowed to modify their post after certain time.
3. This mod will allow user from group(s) with this permission to modify their post beyond that time.
4. Permission is on board basis and is assignable by forum admin at the permission page.
5. You can test it in all lower version too as IMO it should work just fine. ;)


Thank you for using/testing it.


Yours friendly,
Abu Fahim Ismail.

BSD License. Feel free to modify accordingly but keep original and current authors' link(s) if it is in there somewhere. ;)

 


#Change Logs

@Version 1.0.2
- Make it work for 1.1 Beta 3.

@Version 1.0.1
- Restructure addon's directories and locations.

@Version 1.0.0
- Initial release.

Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions

Reply #1
Thank you very much ahrasis, works perfect for me!
sorry for my bad english

Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions

Reply #2
Very nice  :)  ... When you have time, be sure to make a PR to the addon repo so it gets added to that site as well.
Squish squish. squish, squish, squish.
Find a bug,
Make a wish.


Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions

Reply #4
I haven't organized and put my addons in the github. I'll make the PR once I did that.

Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions

Reply #5
Just to be sure it's clear: have a repository at github is not necessary in order to have the addon listed at the site. :)
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions

Reply #6
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.
Actually, I have been playing with the above to make it fully hook but unfortunately, none of the said integration is actually readily available in Elk's hook.

I even try to use this with integrate_pre_load but it is not working either.
Code: [Select]
	if (allowedTo('modify_anytime') && !empty($topic))
$modSettings['edit_disable_time'] = 0;

Any idea why simply using the above cannot override $modSettings['edit_disable_time'] in display page?

Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions

Reply #7
Actually, I have been playing with the above to make it fully hook but unfortunately, none of the said integration is actually readily available in Elk's hook.
What do you mean with "none is readily available"?
Are you sure the hook runs the code? Maybe I posted the wrong hook name (it happens frequently lol).

I have been playing with the above to make it fully hook
Even that idea of mine, cannot be completely hooks-based if you want to be 100% consistent. For example, the quick moderation of search and recent and maybe other places would require code edits in order to make it work "properly", because in those pages there are topics from different boards, so a single "catch 'em all" setting won't work. ;)
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions

Reply #8
What do you mean with "none is readily available"?
Are you sure the hook runs the code? Maybe I posted the wrong hook name (it happens frequently lol).
Yes, you might put the wrong hook name (lol). They are not found in any of the source files. Above all I cannot find any hook for Post.controller.php and any useful hook in Messages.subs.php.

General overriding only with if (allowedTo('modify_anytime')) also failed. So I will leave this mod as it is for now.

Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions

Reply #9
Quote
So I will leave this mod as it is for now.
No problem for me, this addon is working good even if it's not fully hooks ;)
sorry for my bad english

Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions

Reply #10
Yes, you might put the wrong hook name (lol).
Not unusual. lol

They are not found in any of the source files.
Because the "integrate_action_{whatever}_before" and "integrate_action_{whatever}_after" are "built" on-the-file at:
https://github.com/elkarte/Elkarte/blob/master/sources/SiteDispatcher.class.php#L300
and
https://github.com/elkarte/Elkarte/blob/master/sources/SiteDispatcher.class.php#L325
you will not find the exact name.

Above all I cannot find any hook for Post.controller.php and any useful hook in Messages.subs.php.
Not sure why you need it in Messages.subs.php, but for Post.controller.php the integrate_action_post_before will do the trick (I'm quite sure now ;)).

General overriding only with if (allowedTo('modify_anytime')) also failed. So I will leave this mod as it is for now.
That's possible, as I (think I) said it was an idea. ;D
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions

Reply #11
Because the "integrate_action_{whatever}_before" and "integrate_action_{whatever}_after" are "built" on-the-file at:
https://github.com/elkarte/Elkarte/blob/master/sources/SiteDispatcher.class.php#L300
and
https://github.com/elkarte/Elkarte/blob/master/sources/SiteDispatcher.class.php#L325
you will not find the exact name.

Above all I cannot find any hook for Post.controller.php and any useful hook in Messages.subs.php.
Not sure why you need it in Messages.subs.php, but for Post.controller.php the integrate_action_post_before will do the trick (I'm quite sure now ;)).
This is new for me. From what you are saying, it means that we can integrate with function action_post simply using integrate_action_post_before (or after). This is amazing.

Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions

Reply #12
Yep, you can integrate with any action[1]using these two hooks.
Of course are "general" hooks, so are not as "useful" as other specific ones, but in some cases better than nothing.

Something similar applies to menus, (some) sub-actions, errors, set up of profile fields and lists created via createList.
And any sub-action that uses the Action class, but this is a bit less straightforward at the moment.
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions

Reply #13
Also a very small caveat ... the _after will not fire if the action does a redirect, obexit, etc ... Thats somewhat rare but be aware of the action you are hooking in to and check for those conditions.
Squish squish. squish, squish, squish.
Find a bug,
Make a wish.

Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions

Reply #14
You are right! :-[

I have an idea pending for 1.1, let's see if I'll be able to cook it in time. :)
Bugs creator.
Features destroyer.
Template killer.