How about nuPreProcess();kev1n wrote:I'm testing a way to change data before saving (it already works but it's experimental)
To do so, I introduced a new PHP event that is triggered before "BS". Now I'm looking for a good name for it... How about "On Submit" (OS) or is the a more appropriate name?
I've been playing with this all night and this morning too with different vars to see what I can change. Anyways I don't understand the array model enough in PHP to do anything with it.
But Im curious why would this need to be done before the BS? Logically I would think that's the place you'd want it to be. (again I don't quite understand a few things in the nudatabase.php and nudata.php and how passing arrays around works). The name doesn't matter. But I wouldn't necessarily want to change whats appearing on the form. For example: an SSN field. I want to encrypt that field when it saves it to the database table, but I don't want it to change on the form screen. I know this is going to introduce a whole new set of issues when trying to retrieve it from the DB, But theoretically, since there is a BeforeSearch function, I should be able to run through the same encryption routine Before the SQL search occurs to encrypt the search field. So the SQL tha gets executed to do the search would use something like this.
$encryptedSSN = doencryptroutine($_POST['cust_SSN']

SQL = 'Select * from customers where cust_SSN = $encryptedSSN"
I found that if I did something like below as a test in the BS code. It actually does change the value of that field name but just in the nuhash array. It doesn't save it. It appears to maybe repost the data from the form when it actually saves it. I also get what looks like all the table definitions echoed back on the screen. Not sure why. Since BS was intended to do field eval and stop the processing, Maybe I need to do a return(0); or something like that at the end in the BS code. I found that if I change another field on the form screen it actually does save that field though, so the code below isn't stopping the actual save. Its just not using the data from $_POST['nuHash']['cust_lastname'] to save to the database.
Code: Select all
echo $_POST['nuHash']['cust_lastname']." Last1\n";
$_POST['nuHash']['cust_lastname']=$_POST['nuHash']['cust_lastname']."123";
echo $_POST['nuHash']['cust_lastname']." Last2\n";