Hello,
I have a rather uncommon situation where I have created a module that encrypts user profile data before it is saved into the database table and upon request [user_load()] the data gets decrypted so that I can deal with the information and display it. However, I have been using views for a long time, more as a user than a developer for its flexibility in retrieving, sorting and displaying data with relationships and arguments. This is really great stuff but unfortunately, because Views does direct queries within the database tables, I get the encrypted results back and am finding it difficult to deal with. I have no problems decrypting them for display because I am using the Custom Field module which allows me to use php to modify the returned data. However, my view needs to have an exposed form for people to be able to search by first name and last name. I have created the necessary filters and exposed them but when I type in the name of an existing user I get no results. This is because the query is looking in the database table for a name that is not encrypted such as "David" but in the table the data is encrypted and can therefore not match.
I am quite new to using the views api and form api and I would like to know how it might be possible to encrypt the user's input before the form is submited. How would I go about doing this?
I have a feeling I need to use HOOK_form_alter to do this but after that I'm honestly clueless. And they call me a developer .. huh .. well .. we can't be good at everything in the world of development but I really need help for this one. Can anyone give me some clues or even better, a full on explanation about how I might go about doing this?
Comments
Comment #1
dawehnerYou shouldn't mark support requests are critical. Critical is if you get a wsod.
Additional assigned to you means that you want to solve the problem.
To the question: I guess you have to write your own filter handler, which transfers the exposed input back. Look therefore to the advanced help how to creat handlers, use hook_views_api und hook_views_data_alter etc.
Comment #2
Anonymous (not verified) commentedOK! Thanks Dereine for the tips and sorry about the Issue submission mistakes. Will avoid marking "critical" on a support request. I actually do want to solve the problem myself and I am currently trying to. I'd also like the input of more experienced developers too. Will check out those hooks you mentioned. I'm guessing that using HOOK_form_submit to modify the submission data before the form is processed won't work seeing that you mentioned these hooks.
P.S. What is a WSOD?
Comment #3
dawehnerWSOD is a white screen of death: http://drupal.org/node/158043
Comment #4
Anonymous (not verified) commentedOH YES! I know those... Good Fun! AAAAHHH..
Comment #5
Anonymous (not verified) commentedAre there any examples or tutorials of how to create your own custom filter?
Comment #6
dawehnerI suggest you to read views_handler_filter.inc
After this you will be possible to change the exposed input.
In advanced help there is the description how you can create own handlers.
Summary:
- use hook_views_api
- use hook_views_data_alter to change the filter handler of the field you want to change
- use hook_views_handlers to define your new handler
- implement this handler
The rest is your coding.
Comment #7
Anonymous (not verified) commentedFor anyone who is interested.. I finally found a great tutorial explaining how to override a handler...
http://himerus.com/blog/himerus/overriding-field-handlers-views-your-own...