ElkArte Community

Extending Elk => Addons => Topic started by: ahrasis on January 16, 2015, 10:34:59 pm

Title: MPAAP: Modify Posts At Anytime Permissions
Post by: ahrasis on January 16, 2015, 10:34:59 pm
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. ;)

(http://validator.w3.org/images/valid_icons/valid-xhtml10)  (http://jigsaw.w3.org/css-validator/images/vcss)


#Change Logs

@Version 1.0.3
- Restore addons under sources.
- Add french translation.

@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.
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: radu81 on January 17, 2015, 05:39:24 am
Thank you very much ahrasis, works perfect for me!
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: Spuds on January 17, 2015, 10:25:47 am
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.
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: meetdilip on January 17, 2015, 10:53:34 am
Good work @ahrasis
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: ahrasis on January 17, 2015, 11:38:11 am
I haven't organized and put my addons in the github. I'll make the PR once I did that.
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: emanuele on January 18, 2015, 04:07:20 am
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. :)
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: ahrasis on January 27, 2015, 02:11:31 am
Quote from: emanuele –
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?
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: emanuele on January 27, 2015, 04:38:52 am
Quote from: ahrasis – 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).

Quote from: ahrasis – 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. ;)
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: ahrasis on January 27, 2015, 09:03:36 pm
Quote from: emanuele – 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.
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: radu81 on January 28, 2015, 01:19:45 pm
QuoteSo 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 ;)
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: emanuele on January 28, 2015, 02:21:54 pm
Quote from: ahrasis – Yes, you might put the wrong hook name (lol).
Not unusual. lol

Quote from: ahrasis – 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.

Quote from: ahrasis – 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 ;)).

Quote from: ahrasis – 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
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: ahrasis on January 29, 2015, 10:36:31 pm
Quote from: emanuele – 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.

Quote from: ahrasis – 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.
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: emanuele on January 30, 2015, 02:42:48 pm
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.
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: Spuds on February 07, 2015, 01:53:17 pm
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.
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: emanuele on February 07, 2015, 02:40:38 pm
You are right! :-[

I have an idea pending for 1.1, let's see if I'll be able to cook it in time. :)
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: ahrasis on December 06, 2015, 10:11:10 am
I am thinking to upgrade this addon to allow editing time (custom) based on board membergroup as well.

Currently we have forum (post) wise editable time, so the upgrade of this addon will allow either:
1. Certain period of time to edit based on board or membergroup; or
2. To edit at any time also based on board or membergroup.

The addon currently serves #2 overriding default feature. So the upgrade should allow #1 settings to override the default settings. While #2 to override all others.

What do you think?
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: radu81 on December 06, 2015, 02:34:09 pm
for me and my needs is already perfect, but improvements are welcome
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: kode54 on January 15, 2016, 02:27:28 am
Awaiting the addition of membergroup level control.
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: ahrasis on January 17, 2016, 07:26:27 am
I think this is already implemented @kode54 . My latest intention was to extend default time based on board or membergroup.

For example, whole forum is set to 90 seconds limit but certain boards or membergroups can have a longer limit like 600 seconds.
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: kode54 on January 17, 2016, 07:32:52 pm
Yes, and I'm waiting for it to be extended to member groups. I don't want to make it per board on Hydrogenaudio, but rather per member group. Modify any time, for the Developer group.
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: ahrasis on January 18, 2016, 05:01:13 am
I think it is already based on membergroup permission. You can assign it to the Developer group or any other group other than regular member group.
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: Spuds on January 21, 2016, 01:50:54 pm
This did not seem to be on the addon site so I made the PR to add it there as well.
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: kode54 on January 21, 2016, 07:13:17 pm
It is in the addon listed here, but it doesn't seem to be documented as such. That, or it's not totally clear.
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: ahrasis on January 21, 2016, 07:57:11 pm
Sometime you just have to test it to know it better. It has been sometimes that I almost forgot how to code again. Lol.
Title: Re: [ADDON] MPAAP - Modify Posts At Anytime Permissions
Post by: ahrasis on August 11, 2016, 04:22:34 am
#Change Logs

@Version 1.0.1
- Restructure addon's directories and locations.
Title: Re: MPAAP: Modify Posts At Anytime Permissions
Post by: ahrasis on November 01, 2016, 01:23:29 pm
#Change Logs

@Version 1.0.2
- Make it work for 1.1 Beta 3.
Title: Re: MPAAP: Modify Posts At Anytime Permissions
Post by: radu81 on September 16, 2017, 08:47:36 pm
tested and working fine on 1.1 RC2 ;)
Title: Re: MPAAP: Modify Posts At Anytime Permissions
Post by: ahrasis on September 17, 2017, 12:13:45 am
Thank you for testing it on 1.1 @radu81. I appreciate it.
Title: Re: MPAAP: Modify Posts At Anytime Permissions
Post by: radu81 on September 17, 2017, 02:28:56 am
I am testing all the add-ons installed on my forum, I'd like to upgrade soon to 1.1 version. Thank you for this add-on
Title: Re: MPAAP: Modify Posts At Anytime Permissions
Post by: augras on April 16, 2018, 02:07:41 pm
Hi,
Thanks a lot for this addons very useful.
Philippe
Title: Re: MPAAP: Modify Posts At Anytime Permissions
Post by: augras on March 06, 2021, 04:25:15 am
Hi @ahrasis ,
i already use your addon but today i tried to install it on my test forum and i can't download it in the packages manager : i get an error message "Although the package has been uploaded to the server, it appears to be empty...".
I don't remember i need to install the addon by hand. I'm wrong ?
To complete your addon the very small translation file to french.
Title: Re: MPAAP: Modify Posts At Anytime Permissions
Post by: ahrasis on March 06, 2021, 05:17:54 am
I am not sure why because I just tried uploading and installing it via package manager and that went well. Anyway, thank you for the french translation, I upgraded to v103 adding it in and uploaded to the first post as usual.
Title: Re: MPAAP: Modify Posts At Anytime Permissions
Post by: augras on March 06, 2021, 05:46:54 am
You are welcome. It's a very very small tranlation file.
It's not your addon. I made some tests and i have this problem with other packages : some packages can be downloaded and some not.
I open a specific post.
Title: Re: MPAAP: Modify Posts At Anytime Permissions
Post by: augras on December 19, 2021, 05:32:36 am
Hi @ahrasis,
I made a new install today ans i got an error :

Unknown Error: Invalid characters passed for attempted conversion, these have been ignored
https://augras.eu/elkatest/index.php?action=admin;area=packages;sa=install;package=mpaap.v103.sahabat.ahrasis.com.zip
Fichier: /home/augras/public_html/augras.eu/elkatest/sources/subs/Package.subs.php
Ligne: 2932

Everything seems to work.
Philippe
Title: Re: MPAAP: Modify Posts At Anytime Permissions
Post by: ahrasis on March 19, 2022, 08:54:49 pm
That is more related to ElkArte Package.subs.php rather than this package. What is your ElkArte version? Or what that line and its 10 lines above and below says?
Title: Re: MPAAP: Modify Posts At Anytime Permissions
Post by: augras on March 20, 2022, 05:20:03 am
Hi @ahrasis ,
nice to see you back.
I'm with Elkarte 1.1.8.
It's at the end of the files :
Code: [Select]
/**
 * Simple wrapper around chmod
 *
 * - Checks proper value for mode is supplied
 * - Consolidates chmod error suppression to single function
 *
 * @param string $file
 * @param string|int|null $mode
 *
 * @return bool
 */
function elk_chmod($file, $mode = null)
{
$result = false;

$mode = trim($mode);
if (empty($mode) || !is_numeric($mode))
{
if (is_dir($file))
{
$mode = 0755;
}
else
{
$mode = 0664;
}
}

// Make sure we have a form of 0777 or '777' or '0777' so its safe for intval '8'
if (($mode % 10) >= 8)
$mode = decoct($mode);
line 2932 if ($mode == decoct(octdec($mode)))
$result = @chmod($file, intval($mode, 8));

return $result;
}


I made the test today, but on the same elkarte when i got the error the first time, and i can't reproduce.
Title: Re: MPAAP: Modify Posts At Anytime Permissions
Post by: Spuds on March 20, 2022, 09:32:18 pm
I know about reported issues on that 'line' ... but I thought those had been addressed.