|
phpMyEdit - Viewing Bug Advanced Details |
[ Go Back ]
|
|
|
ID:
|
Category:
|
Severity:
|
Reproducibility:
|
Date Submitted:
|
Last Update:
|
|
231 |
core / general |
feature |
N/A |
2004-04-18 15:23 |
2010-08-30 14:12 |
|
|
Reporter:
|
hbernard |
Platform:
|
PC |
|
|
Assigned To:
|
nepto |
OS:
|
(Server) Linux Mandrake 9.1 |
|
|
Priority:
|
low |
Version:
|
Builtin |
|
|
Status:
|
resolved |
Product Version:
|
|
|
|
Product Build:
|
|
Resolution:
|
fixed |
|
|
Projection:
|
none |
Duplicate ID:
|
|
|
|
ETA:
|
none |
|
|
|
Summary:
|
array of trigger and event processing |
|
Description:
|
Please note that this is a low prority feature request, but very easy also.
As PME's user base expands, there are more and more request that can be done by using triggers.
Samples are : lock, validation, custom mail notification, advanced joining, etc...
Users share triggers file in forum, but if they already have a trigger set, they just can't use those triggers "as is".
On the road to make PME more plugable, I think this would be a good idea to allow arrays of triggers. |
|
Steps To Reproduce:
|
|
|
Additional Information / Solution:
|
API would be as current trigger API, except we could set an array of triggers in place of the current file name.
$opts['triggers']['update']['after'][] = 'postvalid.TUA.php';
$opts['triggers']['update']['after'][] = 'unlock.TUA.php';
....
Rule for processing would be :
Run each trigger
- as soon as one fail, stop processing and return false
- at the end, if nothing fail, return true.
|
|
System Description:
|
|
|
Attached Files:
|
0000231-aot-v1.patch.txt (6 KB) 1970-01-01 01:33 0000231-aot-v2.patch.txt (6 KB) 1970-01-01 01:33 0000231-aot-doc-rush.txt.txt (1 KB) 1970-01-01 01:33 0000231-configuration.triggers.html.txt (12 KB) 1970-01-01 01:33 0000231-proposed.configuration.triggers.html.txt (16 KB) 1970-01-01 01:33 0000231-namecheck.php.txt (2 KB) 1970-01-01 01:33 0000231-displayname.txt.txt (1 KB) 1970-01-01 01:33 0000231-trigger-after-to-view.php.txt (0 KB) 1970-01-01 01:33 0000231-locking.txt.txt (4 KB) 1970-01-01 01:33 |
|
Bug Notes |
|
|
|
i agree
this array of triggers would be ran through foreach.(?)
would i be able to explicitly specify first trigger ? (the one that corrects $newvals array) |
|
|
|
hbernard
|
|
2004-04-18 21:02
|
|
array of triggers would be ran through foreach, which default process elements in the order they are set.
This mean that
$opts['triggers']['insert']['before'][] = 'valid.TIB.php';
$opts['triggers']['insert']['before'][] = 'foo.TIB.php';
would cause 'valid.TIB.php' to be the first processed.
That's fine if we agree on a bug ;-) |
|
|
|
hbernard
|
|
2004-12-05 12:22
|
|
uploaded aot-v1.patch
It's the implementation of discussion above. Changes are BC.
1. API :
Additional allowed API for triggers is :
$opts['triggers']['update']['before'] = Array(
2 => 'second.TUB.php'
1 => 'first.TUB.php',
);
Previous simple API is still allowed.
2. Feature
* triggers are sorted against their key.
* they are executed in this order.
* execution is stopped as soon as a trigger return false.
-> the overall return value is then false.
* If all triggers returned true,
->return value of triggers execution is true. (success)
This is a traditionnal event processing.
This allow to easily share triggers between PME users. (mostly thinking about locking and checking triggers)
This also means that cancel triggers return value may be useful, because if the first one fail, the next one won't be executed, although this doesn't change next PME operation.
3. Implementation details :
$changed and $newvals are passed by reference, in order to prepare the resolution of #262
I think code is now more readable, but maybe that's only my point of view ;-)
I think (1) & (2) are OK.
Comments on the patch are welcome. |
|
|
|
|
this patch is fine and working for me.
the only comment i have: nice work... |
|
|
|
|
Yes, great work, indeed.
I did some minor modifications (the name exec_precancel_triggers() was really not a good one; due to searching for exec_trig... and so on). Please test and if it is OK, I will commit this yesterday ehm sorry today :) |
|
|
|
hbernard
|
|
2004-12-08 10:34
|
|
I like the rewrite that you made of the exec_triggers() func.
Looks OK to me. (Tests OK).
Ready to commit ! |
|
|
|
hbernard
|
|
2004-12-08 12:46
|
|
|
uploaded a rough rush for the documentation. |
|
|
|
|
|
Thanks! The patch and docs were commited. Doug, could you please review the uploaded 'Trigger' documentation section? |
|
|
|
|
|
View proposed.configuration.triggers.html using your web browser to find corrections and suggestions in red font. Triggers were a source of confusion for me when I first tried to use this feature. I posted the only working example that I could quickly locate (at the end of the uploaded file). Someone else probably has a better example. In any event, I think a simple User Input Validation example should be included in this page. |
|
|
|
hbernard
|
|
2004-12-09 07:41
|
|
Doug, I agree with your idea of having a simple example.
-I would suggest to add a simpler example that the one you posted.
(Just checking one value according to another, without db connection required)
optionnaly, this same example could use the incoming #262 to correct the value.
for example, a trigger that would require either the First Name or the Last Name to build the login of the user when inserting record.
If none are set, trigger fails, If one/both are set, build the username according to these values.
- nepto, can we add a "locking with trigger" section in misc. If so, I will write the two page documentation for this. |
|
|
|
|
afaik, there is no way to display users input back to the user (with note fill this) in change mode. (in add just change 'default') (well except for 'back' button, but ...)
for a simple trigger i would vote for strtotime($userinput) or inserting users ip when adding a record. |
|
|
|
hbernard
|
|
2004-12-10 12:38
|
|
right.
I agree with this simple trigger idea. |
|
|
|
|
|
Perhaps you will find that namecheck.php is a simpler trigger example. |
|
|
|
|
Doug you did a great work, as usual. Thank you for that, it was commited into CVS.
Concerning to examples:
The Trigger section is full. We can either split it into several parts or just leave it as-is, without any examples. We can add two examples, simple and more difficult one, into Hints & Tips section. Doug initial example (unique USERID) is a very nice one, however I believe such example should comform good phpMyEdit programming habits and thus used $this->myQuery() insead raw mysql_*() functions ;-) |
|
|
|
|
OK, so what examples we are going to use in the Hints & Tips?
I can contribute somes from the phpMyEzin/Metafox content management system where phpMyEdit is used, however I'm not sure if they will be good and understandable enough. |
|
|
|
hbernard
|
|
2005-01-03 06:54
|
|
|
Do you want a full locking triggers example ? I have a generic one in production for one year. |
|
|
|
|
|
That would be wonderful. However we should consider if it is not too long for Hints & Tips... |
|
|
|
|
|
I uploaded my only decent trigger as "displayname.txt" |
|
|
|
|
uploaded an after trigger that jumps to view mode after add/change (discussed a couple time in the forums). several questions arise:
- should it override 'apply' if hit (currently not)
- should the recreate_* be executed in the core class regardless of what's hit (currently no)(it would not have to be in the trigger)
looking at the source code, recreate_fdd() is not neccessary in the trigger, but backward_compatibility() is, hmmm, things change...
another trigger would be with php emulation of js functions, but we would need an API to display users input back to him... (long and painfull story, connected to #241 and merging display_add_record() and display_change_field($row, $k); will open a feature request...) |
|
|
|
hbernard
|
|
2005-01-04 11:18
|
|
Uploaded locking.txt
This is a draft of "locking triggers" section.
This is not SGML-ized, I'm first waiting for your feedback on this (too long, more details, etc...) |
|
|
|
hbernard
|
|
2010-08-30 08:33
|
|
|
This is fixed and should be marked as such, no ? |
|
|
|
|
|