Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
463 views
in Plugins by
edited by

I am trying to develop a plugin called prevent-simultaneous-edits to solve the existing problem that content gets lost by edits at the same time.

I read I can use the event module to catch the q_edit event.

So I tried:

        function process_event($event, $userid, $handle, $cookieid, $params)
        {
            if($event == "q_edit") {
               
$this->output('### test');
            }
         }

which gives me nothing in frontend. Do I need to use another module, and let them communicate?
Or in other words: The event module will write data to the database (edit time, and user), do I need another module that reads this data and outputs the html?


Who can help me on that?

-- EDIT --

Scenario would be:

1. editor clicks on "edit"

2. event is caught by event module → writes into new table `qa_preventedits`: current-time | postid | userid

3. if 2nd editor wants to edit the same question (within say 15 min), either hide "edit" button from question or if it is still available:

4. 2nd editor clicks on "edit" → edit page is loaded with javascript alert (injected by plugin - module?): "This question is being edited by *username* right now. Please wait 15 minutes and try again." (and redirect to question).

That's it.

by
This would be great plugin. I think you can give both options you mentioned. Where admin can select as per choice. Either disable the edit button or give js alert not.

1 Answer

0 votes
by

I guess I understand now what I have to do:

1. event plugin only catches q_edit event, and writes it to database

2. then I use a layer to check the other database entries for conflicting edit times and output from there, overwriting the question output function (still need to find that one).

:)

by
Exactly! You can also communicate between the two parts using global variables, or having the layer call a function in the event module - see the bottom of http://www.question2answer.org/modules.php
by
thanks for letting me know. If I'm lucky, I might develop this plugin until by the end of this year... let's see.
by
edited by
I ran into a problem: "Event module not listening?"
http://www.question2answer.org/qa/19535/event-module-not-listening

Could you help please?

--

Is this related to: http://www.question2answer.org/qa/2469/ ?
...