-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport_dashboard_views_log.php
63 lines (57 loc) · 2.12 KB
/
report_dashboard_views_log.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
// Set the namespace defined in your config file
namespace USBTOV\report_dashboard_views_log;
use REDCap;
// Declare your module class, which must extend AbstractExternalModule
class report_dashboard_views_log extends \ExternalModules\AbstractExternalModule
{
public function redcap_every_page_top($project_id)
{
//isAuthenticated prevents to log the pages if user ist not logged-in (just giving the URL in the browser would promt the log even without login)
//see post: https://redcap.vanderbilt.edu/community/post.php?id=226777
if ($this->isAuthenticated()) {
//get report_id or dash_id from the URL
$report_id = htmlspecialchars($_GET["report_id"]);
$dash_id = htmlspecialchars($_GET["dash_id"]);
// Reports Page (Edit or View Report, Not the all-reports page or stats/charts)
if (($this->isPage('DataExport/index.php') && $project_id && $report_id &&
!isset($_GET['stats_charts']) &&
!isset($_GET['create']) &&
!isset($_GET['other_export_options']) &&
!isset($_GET['addedit'])) ||
//Dashboard Page
($this->isPage('index.php') && $_GET['route'] == 'ProjectDashController:view' && $project_id)
) {
$page_type = '';
$page_id = '';
$dash_html='';
if ($report_id) {
$page_type = 'Report';
$page_id = $report_id;
//warning: html code for reports not collected
} elseif ($dash_id) {
$page_type = 'Dashboard';
$page_id = $dash_id;
//query to get html code
$sql = "SELECT body FROM redcap_project_dashboards WHERE dash_id = ?";
$params = [$dash_id];
$result = $this->query($sql, $params);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$dash_html = $row['body'];
}
//log html code
}
//EM log() method:
$logId = $this->log(
"Report/Dashboard views log",
[
"Page_Type" => $page_type,
"Page_ID" => $page_id,
"Html_Code" => $dash_html,
]
);
}
}
}
}