|
Viewing Bug Advanced Details |
[ Jump to Bugnotes ]
[ Bug History ]
[ Print ]
|
|
ID |
Category |
Severity |
Reproducibility |
Date Submitted |
Last Update |
|
0000231 |
core / general |
feature |
N/A |
2004-04-18 15:23 |
2010-08-30 14:12 |
|
|
|
Reporter |
hbernard |
View Status |
public |
|
|
Assigned To |
nepto |
|
Priority |
low |
Resolution |
fixed |
Platform |
PC |
|
Status |
resolved |
Duplicate ID |
|
OS |
(Server) Linux Mandrake 9.1 |
|
Projection |
none |
|
Version |
Builtin |
|
ETA |
none |
|
Product Version |
|
|
|
Product Build |
|
|
|
Votes |
1 |
|
|
|
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 |
aot-v1.patch (6,269 bytes) 2004-12-05 12:22 aot-v2.patch (6,414 bytes) 2004-12-08 00:07 aot-doc-rush.txt (1,321 bytes) 2004-12-08 12:48 configuration.triggers.html (12,620 bytes) 2004-12-08 17:21 proposed.configuration.triggers.html (16,046 bytes) 2004-12-08 22:26 namecheck.php (1,565 bytes) 2004-12-10 19:14 displayname.txt (1,183 bytes) 2005-01-03 19:05 trigger-after-to-view.php (241 bytes) 2005-01-03 21:11 locking.txt (3,616 bytes) 2005-01-04 11:17 |
|
|
|
Bug Notes |
michal
2004-04-18 20:55
|
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. |
|
|
michal
2004-12-05 15:44
|
this patch is fine and working for me.
the only comment i have: nice work... |
|
|
nepto
2004-12-08 00:09
|
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. |
|
|
nepto
2004-12-08 17:22
|
Thanks! The patch and docs were commited. Doug, could you please review the uploaded 'Trigger' documentation section? |
|
|
doug
2004-12-08 22:29
|
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. |
|
|
michal
2004-12-10 11:54
|
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. |
|
|
doug
2004-12-10 19:19
|
Perhaps you will find that namecheck.php is a simpler trigger example. |
|
|
nepto
2004-12-13 22:11
|
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 ;-) |
|
|
nepto
2004-12-27 18:54
|
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. |
|
|
nepto
2005-01-03 18:10
|
That would be wonderful. However we should consider if it is not too long for Hints & Tips... |
|
|
doug
2005-01-03 19:08
|
I uploaded my only decent trigger as "displayname.txt" |
|
|
michal
2005-01-03 21:27
|
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 ? |
|
|
nepto
2010-08-30 14:12
|
Fixed long time ago. |
|
|