Page 1 of 1
Disable deleting and editing posts
Posted: Fri Sep 01, 2006 3:31 pm
by soylentgreen
Hi
is there a way to forbid the editing and deleting of an user's own posts? The users should be allowed to create new ones, but it is neccessary that existing ones cannot be changed or removed.
I thought about removing the edit and delete links in the template, but there might be a more elegant solution.
any help would be appreciated
Re: Disable deleting and editing posts
Posted: Fri Sep 01, 2006 4:02 pm
by garvinhicking
Hi!
You could do that by creating a custom PHP plugin, that checks if an item is being edited, and denies access. You can hook into the corresponding backend_display and other event hooks to check the item.
Serendipity itself does not restrict that, because in a blog environment its highly unusuall that an entry owner should not be able to edit his entries.
Best regards,
Garvin
Posted: Fri Sep 01, 2006 5:05 pm
by soylentgreen
hi,
is there a howto how to create such plugins?
some example code would be extremley helpful
Posted: Fri Sep 01, 2006 5:07 pm
by garvinhicking
Hi!
There is some documentation on
www.s9y.org, and many things can be done by just looking at existing plugins.
The 'serendipity_event_entrycheck' plugin (available via spartacus) already goes into a similar direction, you can look that up for an example
Best regards,
Garvin
Posted: Fri Sep 01, 2006 5:09 pm
by soylentgreen
thank you, i'll have a look
Posted: Fri Sep 01, 2006 5:41 pm
by soylentgreen
i have yet another question: how is it possible to cancel an event?
so i just have to hook into the update / delete event and cancel it...
Posted: Fri Sep 01, 2006 9:43 pm
by judebert
I don't think it's possible to cancel a hook once it's started.
I think you'll need to change the event_data instead.
Posted: Mon Sep 04, 2006 5:29 pm
by Fencer
soylentgreen wrote:thank you, i'll have a look
Please send me a note when you finish the plugin, I would use it as well, due to the same problem.
Filip
Posted: Mon Sep 04, 2006 7:56 pm
by soylentgreen
judebert wrote:I don't think it's possible to cancel a hook once it's started.
I think you'll need to change the event_data instead.
the hook api tells the following
would be setting the entry data's id to an invalid number an appropriate way to prevent the entry from being deleted? or should the entry data set to null?
Posted: Mon Sep 04, 2006 9:26 pm
by garvinhicking
Hi!
If you search the code for 'backend_delete_entry' you'll see that the hook gets executed with $id as $eventData before the DELETE SQL statements are set.
Thus, setting $id to "-1" or "0" would make all the DELETE statements not delete matching rows.
So, the answer is: Yes.
Best regards,
Garvin
Posted: Thu Sep 07, 2006 6:02 pm
by soylentgreen
i have completed the plugin, if anyone is interested i can upload it or send it
Posted: Thu Sep 07, 2006 8:20 pm
by judebert
I'd love to see it!
Posted: Tue Sep 12, 2006 11:19 pm
by soylentgreen
here's the code
comments are welcome
please note that the plugin still allows to enter the editing / deleting screens, since i could not figure out a way to prevent that