table view - data decryption

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
G Scott
Posts: 18
Joined: 2018-02-25 00:02

table view - data decryption

Post by G Scott » 2018-07-15 13:22

I have a table with 8 columns, 3 of these columns contain encrypted data.
I wish to display the data in a decrypted format in the Table View.

I've been trying to do this using the table_init hook to no avail.

Basically, I need to run the data in the 3 encrypted columns through a php function before it is displayed in the table view.

Can anyone help me?
My php decrypt function looks like:

Code: Select all

decrypt($data_to_decrypt, $key);
Column names to decrypt are ColumnB, ColumnC, ColumnD.

I just can't figure out how this can be done.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: table view - data decryption

Post by pbottcher » 2018-07-16 10:23

Hi,

I cannot provide a solution via a hook, but if you want, you can try the following. (Remeber that the changes will be overwritten when you recreate your project.)

Edit the template/<tablename>_templateTV.html

replace
<td id="<tablename>-ColumnB-<%%VALUE(ID)%%>" class="<tablename>-ColumnB"><%%SELECT%%><%%VALUE(ColumnB)%%><%%ENDSELECT%%></td>
<td id="<tablename>-ColumnC-<%%VALUE(ID)%%>" class="<tablename>-ColumnC"><%%SELECT%%><%%VALUE(ColumnC)%%><%%ENDSELECT%%></td>
<td id="<tablename>-ColumnD-<%%VALUE(ID)%%>" class="<tablename>-ColumnD"><%%SELECT%%><%%VALUE(ColumnD)%%><%%ENDSELECT%%></td>

by
<td id="<tablename>-ColumnB-<%%VALUE(ID)%%>" class="<tablename>-ColumnB"><%%SELECT%%><%%DECRYPT(ColumnB)%%><%%ENDSELECT%%></td>
<td id="<tablename>-ColumnC-<%%VALUE(ID)%%>" class="<tablename>-ColumnC"><%%SELECT%%><%%DECRYPT(ColumnC)%%><%%ENDSELECT%%></td>
<td id="<tablename>-ColumnD-<%%VALUE(ID)%%>" class="<tablename>-ColumnD"><%%SELECT%%><%%DECRYPT(ColumnD)%%><%%ENDSELECT%%></td>

Then edit the datalist.php, search for %%VALUE(Field caption)%% and add an additional like

$rowTemp = str_replace("<%%DECRYPT($fieldTVCaption)%%>", <YOURFUNCTION>($fd), $rowTemp);

recplace <tablename> with your tablename and <YOURFUNCTION> with your function. Make sure your function is available at the time you call it.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

G Scott
Posts: 18
Joined: 2018-02-25 00:02

Re: table view - data decryption

Post by G Scott » 2018-07-16 20:55

Hi pböttcher,

Thanks for your help, I'm having trouble including the files for the function to work.

I.e. I placed the following code on line 16 of datalist.php

Code: Select all

require_once($curr_dir . '/encryption.class.php');
I also tried placing the code on line 21 of common.js.php and changing require_once to include_once.

I've placed the file encryption.class.php in the root folder of my project.
Whenever I try to access that table in the web browser, I get a 500 server error however no event is logged in the server error log.

At this point I have not tried to call the function within datalist.php, just merely tried to include the function files.

Do you have any suggestions on how I can make the code for the function available?

Many thanks for your help,

Grant

G Scott
Posts: 18
Joined: 2018-02-25 00:02

Re: table view - data decryption

Post by G Scott » 2018-07-16 22:10

Hi pböttcher,

Please ignore the last post, I was getting the error because I had already included the function elsewhere in the project so the class was already declared...

I do have one more question though, when I select a record and the detail view is displayed, how could I decrypt those fields when on the detail view form?

Many thanks,
Grant

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: table view - data decryption

Post by pbottcher » 2018-07-17 06:07

Hi,

you can use the hooks/<tablename>.php -> <tablename>_dv function to replace the text with the decryptet text.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Post Reply