Forums / General / Cancel edit
Alejandro Serrano
Saturday 23 September 2006 9:06:00 am
Hi, Is there any way I could cancel an edit due to some conditions? I'm planning using a spam filter which work under PHP. My idea was implementing an operator, and, if it returns false(), just cancel the edit, I mean, continue as if the edit had been successful, but not adding/editing the node.Is it possible?
Thanks in advance.
Claudia Kosny
Saturday 23 September 2006 12:16:42 pm
Hello Alejandro
Here my thoughts on this: Editing something consists of two major parts. First you have the html page consisting out of the form elements where you enter the new information. Once this page is visible in the browser there is nothing you can do to to change the page (except with Javascript and Ajax). So the best your operator could do on this part is the adapt the edit page depending on some condition you know before the page is sent to browser. But if the condition depends on whatever the user put into the edit form a template operator will not help you much. Most of the times the form is posted to some php script which then has to call and check the return value of your operator. Depending on the outcome the script either cancels the operation or continues. As most forms have a cancel option anyway you just need to look what happens if a customer clicks on this button to cancel the edit.I am not sure how I would implement something like this. Most likely I would write my own extension to which all forms are posted. All forms would need to include the original form action in a hidden form field. My extension then would check the condition to see whether the data should be further processed or not. If yes the received data would be posted to the original form action.
Pretending the edit was successfull might be problem as sometimes the forms redirect to the view of the just edited object. To fake this might be cumbersome.
No matter how you do it, if you get your spamfilter to work please post you experiences here - it might be useful for others as well.
Greetings from Luxembourg
Claudia
Monday 25 September 2006 10:43:03 am
I've been thinking a bit more. Maybe I could do it in the same way that datatypes are checked. Is this possible? If yes, could you point me into some direction?
Thanks again
Monday 25 September 2006 11:44:15 am
Hi Alejandro
Good idea. Maybe you should have a look at the EZcaptcha extension. I have not tried it and I don't know whether it works with newer versions of EZ but it should give you some hints on how to do this.