CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Logging accesses to contact files
Pages: [1]

Author Topic: Logging accesses to contact files  (Read 700 times)

capo

  • I post occasionally
  • **
  • Posts: 108
  • Karma: 5
Logging accesses to contact files
July 31, 2012, 03:56:20 pm
Hello,

I'm working for a project where we will work with sensible information. In Spain, since certain level of "sensibility" of information we've to keep a record of every single access to the file of a contact.

Logging capabilities through triggers, allow CiviCRM to record evrey creation, modification or deletion but I also need to record every access.

I've two questions regarding this topic:

  • Should I use log tables to record this information (such as log_contact with log_action = 'View') for these purposes?
  • How can I detect accesses to contact files?

Just in order to clarify, when I say "access a contact file", I mean open it in "View" mode (http://localhost/drupal/civicrm/contact/view?reset=1&cid=1).

Thanks

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Logging accesses to contact files
July 31, 2012, 03:58:39 pm
hi capo - i am just making this comment to make it easier for others to spot. this issue is about 'sensitive' information.
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Logging accesses to contact files
July 31, 2012, 07:20:26 pm

if database triggers are also fired on SELECT, then doing this via triggers is definitely a good option.

You can potentially add this via the new trigger hook functionality in 4.2

Some expertise with php and mysql would be needed for this

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Logging accesses to contact files
July 31, 2012, 07:59:10 pm
MySQL triggers probably can't be bound to SELECT events (http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html) although I've never tried.

If they don't work, then the best bet is to implement logging on a screen-by-screen basis using hooks. (It sounds like you have some technical expertise, so I'm assuming that you have a general familiarity with hooks but not with Civi's hooks.) For example, one of two hooks will be called whenever a web form or web page is displayed (F.1, F.2). If you write code that listens to the hook, then your code can examine the hook arguments (eg $formName, $page) and figure out which screen is being displayed and which contact ID is being used.

These hooks can be a little tricky for a new developer because it's hard to guess what values will be coming through $form/$page. If you're using Drupal, then the best the thing is to install the "devel" and the "civicrm_developer" modules (F.3, F.4). After activating the modules and logging in as super-admin, you will see an on-screen alert every time a CiviCRM hook runs. Pay attention to the class-names and attributes -- that information helps when writing the hook.

(F.1) http://wiki.civicrm.org/confluence/display/CRMDOC41/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmbuildForm
(F.2) http://wiki.civicrm.org/confluence/display/CRMDOC41/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmpageRun
(F.3) http://drupal.org/project/devel
(F.4) https://github.com/eileenmcnaughton/civicrm_developer

capo

  • I post occasionally
  • **
  • Posts: 108
  • Karma: 5
Re: Logging accesses to contact files
August 05, 2012, 05:45:15 am
As far as I know, the applications wanting to perform any kind of sql action whenever someone is opening a record file, use to replace SELECTs and use calls to stored procedures instead. In my case, it's not possible, so I'll probably have to use Civi's hooks. Thanks a lot for your ideas. I'm already installing these modules in my development environment!  :)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Logging accesses to contact files

This forum was archived on 2017-11-26.