Track user's action

喜欢而已 提交于 2019-12-25 03:22:44

问题


In our company I have to extend the functionality of existing Drupal 7 website. Here are the requirements:

  • The business needs to inform all staff members, on different topics using uploaded to the Drupal site documents. (I already implemented this requirement.)
  • The business needs to know, which staff members have read a document and which still have not. They need a report like this:

    Document 1 25/50 (25 from 50 staff members still didn't read the file)

    Document 2 50/50 (all staff members did read the file), etc.

In order to fulfill the second business requirement, I need a module which can track specific user's activity (in my case click on a link to download a file, which means the file is read). The module(s) have to be able to create a report like the one above. (All staff members have a drupal account with a specific role.)

Is there any drupal module I can use or maybe a part of it. Or the requirements are too 'custom' and I have to create my own module.


回答1:


I created almost exactly the feature you need. I would be glad to help you in the process.

I developed indeed a full custom module. And I could tell you that you will need different things:

  • A custom table in your DB to store the data
  • A custom entity called "track" or "action" that will be stored in the DB
  • Implementing the right hooks to create a track when you want to keep a track of a user's action
  • A custom page or block to display the tracks you stored in your DB with a custom query and appropriated permissions

To achieve all that, I suggest you to take a look at these pieces of documentation:

  • https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_schema/7
  • https://www.drupal.org/node/878784
  • https://api.drupal.org/api/drupal/includes!module.inc/group/hooks/7
  • https://www.drupal.org/node/1343708
  • http://befused.com/drupal/page-programatically
  • https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_permission/7

Hope it will help.



来源:https://stackoverflow.com/questions/25127777/track-users-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!