Change support desk contact information (#7561)
[openemr.git] / gacl / admin / acl_test2.php
blobd2515a1c288e67a8d96f8b4e8c38eb8958cca239
1 <?php
2 /*
3 if (!empty($_GET['debug'])) {
4 $debug = $_GET['debug'];
6 */
7 //First make sure user has access
8 require_once("../../interface/globals.php");
10 use OpenEMR\Common\Acl\AclMain;
11 use OpenEMR\Common\Twig\TwigContainer;
13 //ensure user has proper access
14 if (!AclMain::aclCheckCore('admin', 'acl')) {
15 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("ACL Administration")]);
16 exit;
19 @set_time_limit(600);
21 require_once('../profiler.inc.php');
22 $profiler = new Profiler(true,true);
24 require_once("gacl_admin.inc.php");
26 $query = '
27 SELECT a.value AS a_value, a.name AS a_name,
28 b.value AS b_value, b.name AS b_name,
29 c.value AS c_value, c.name AS c_name,
30 d.value AS d_value, d.name AS d_name
31 FROM '. $gacl_api->_db_table_prefix .'aco_sections a
32 LEFT JOIN '. $gacl_api->_db_table_prefix .'aco b ON a.value=b.section_value,
33 '. $gacl_api->_db_table_prefix .'aro_sections c
34 LEFT JOIN '. $gacl_api->_db_table_prefix .'aro d ON c.value=d.section_value
35 ORDER BY a.value, b.value, c.value, d.value';
37 //$rs = $db->Execute($query);
38 $rs = $db->pageexecute($query, $gacl_api->_items_per_page, ($_GET['page'] ?? null));
39 $rows = $rs->GetRows();
42 echo("<pre>");
43 print_r($rows);
44 echo("</pre>");
47 $total_rows = count($rows);
49 $total_acl_check_time = 0;
51 foreach ($rows as $row) {
52 list( $aco_section_value,
53 $aco_section_name,
54 $aco_value,
55 $aco_name,
57 $aro_section_value,
58 $aro_section_name,
59 $aro_value,
60 $aro_name
61 ) = $row;
63 $acl_check_begin_time = $profiler->getMicroTime();
64 $acl_result = $gacl->acl_query($aco_section_value, $aco_value, $aro_section_value, $aro_value);
65 $acl_check_end_time = $profiler->getMicroTime();
67 $access = &$acl_result['allow'];
68 $return_value = &$acl_result['return_value'];
70 $acl_check_time = ($acl_check_end_time - $acl_check_begin_time) * 1000;
71 $total_acl_check_time += $acl_check_time;
73 if (empty($tmp_aco_section_name) OR $aco_section_name != $tmp_aco_section_name OR $aco_name != $tmp_aco_name) {
74 $display_aco_name = "$aco_section_name > $aco_name";
75 } else {
76 $display_aco_name = "";
79 $acls[] = array(
80 'aco_section_value' => $aco_section_value,
81 'aco_section_name' => $aco_section_name,
82 'aco_value' => $aco_value,
83 'aco_name' => $aco_name,
85 'aro_section_value' => $aro_section_value,
86 'aro_section_name' => $aro_section_name,
87 'aro_value' => $aro_value,
88 'aro_name' => $aro_name,
90 'access' => $access,
91 'return_value' => $return_value,
92 'acl_check_time' => number_format($acl_check_time, 2),
94 'display_aco_name' => $display_aco_name,
97 $tmp_aco_section_name = $aco_section_name;
98 $tmp_aco_name = $aco_name;
101 //echo "<br /><br />$x ACL_CHECK()'s<br />\n";
103 $smarty->assign("acls", $acls);
105 $smarty->assign("total_acl_checks", $total_rows);
106 $smarty->assign("total_acl_check_time", $total_acl_check_time);
108 if ($total_rows > 0) {
109 $avg_acl_check_time = $total_acl_check_time / $total_rows;
111 $smarty->assign("avg_acl_check_time", number_format( ($avg_acl_check_time + 0) ,2));
113 $smarty->assign("paging_data", $gacl_api->get_paging_data($rs));
115 $smarty->assign("return_page", $_SERVER['PHP_SELF'] );
117 $smarty->assign('current','acl_test');
118 $smarty->assign('page_title', '2-dim. ACL Test');
120 $smarty->assign("phpgacl_version", $gacl_api->get_version() );
121 $smarty->assign("phpgacl_schema_version", $gacl_api->get_schema_version() );
123 $smarty->display('phpgacl/acl_test2.tpl');