Hi there,
With CF/CC I am building a website containing information on several choirs in our city. For each choir one or more contacts may be registered (users) that I allow to announce concerts and change concerts and other information, but of course only for the choir(s) they have been registered for.
All this has been implemented satisfactorily.
Tables exist (via CF) for choirs and concerts. Heart of the system is a contacts table that contains records each combining a user and a choir. Effectively this implements a many-to-many relation between users and choirs.
When a user visits a choir or concert details page (CC connections) PHP-code uses this table in order to check whether this user is allowed to change this information. If so, an {edit_record} element is presented and via Front Permissions an edit action has been implemented. Works perfectly, great facility!
Now I wish to add to the site a list of recent modifications, being of interest to the general website visitor. Therefore I created a modifications table with fields chg_id (auto-increment), chg_date, chg_author, chg_choir, and chg_action. I wish to add a record upon each user change action. The only place where a user modification becomes real is when the “SAVE” button is clicked during an {edit_record} action. The only place for adding a modification record therefore seems the “OnSaveCode” field under “Front Permissions”. I added there the following code (somewhat generalised for simplicity reasons):
The SAVE button still works perfectly, but no modification record is ever added. Debug output via echo statements cannot be made visible. How can I check that this code is really executed? Is it, anyway? Making a deliberate programming error has no noticeable influence on the result. The code itself seems correct. When I place it in “Record Edit Template” a modification record is added each time a valid user enters the {edit_record} page. Not what I want of course, but just to prove that the code is working.
Any bright ideas?
Curious greetings,
Peter
With CF/CC I am building a website containing information on several choirs in our city. For each choir one or more contacts may be registered (users) that I allow to announce concerts and change concerts and other information, but of course only for the choir(s) they have been registered for.
All this has been implemented satisfactorily.
Tables exist (via CF) for choirs and concerts. Heart of the system is a contacts table that contains records each combining a user and a choir. Effectively this implements a many-to-many relation between users and choirs.
When a user visits a choir or concert details page (CC connections) PHP-code uses this table in order to check whether this user is allowed to change this information. If so, an {edit_record} element is presented and via Front Permissions an edit action has been implemented. Works perfectly, great facility!
Now I wish to add to the site a list of recent modifications, being of interest to the general website visitor. Therefore I created a modifications table with fields chg_id (auto-increment), chg_date, chg_author, chg_choir, and chg_action. I wish to add a record upon each user change action. The only place where a user modification becomes real is when the “SAVE” button is clicked during an {edit_record} action. The only place for adding a modification record therefore seems the “OnSaveCode” field under “Front Permissions”. I added there the following code (somewhat generalised for simplicity reasons):
<?php
$choir = "Choir X";
$action = "Some modification";
$localdb =& JFactory::getDBO();
$localusr =& JFactory::getUser();
$localquery = "INSERT INTO `jos_chronoforms_modifications`
(`chg_date`,`chg_author`,`chg_choir`,`chg_action`) VALUES ('".
date("Y-m-d H:i:s")."','".$localusr->name."','".$choir."','".$action."')";
$localdb->setQuery($localquery);
$localdb->query();
?>
The SAVE button still works perfectly, but no modification record is ever added. Debug output via echo statements cannot be made visible. How can I check that this code is really executed? Is it, anyway? Making a deliberate programming error has no noticeable influence on the result. The code itself seems correct. When I place it in “Record Edit Template” a modification record is added each time a valid user enters the {edit_record} page. Not what I want of course, but just to prove that the code is working.
Any bright ideas?
Curious greetings,
Peter