2 //First make sure user has access
3 require_once("../../interface/globals.php");
5 use OpenEMR\Common\Acl\AclMain
;
6 use OpenEMR\Common\Csrf\CsrfUtils
;
7 use OpenEMR\Common\Twig\TwigContainer
;
9 //ensure user has proper access
10 if (!AclMain
::aclCheckCore('admin', 'acl')) {
11 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("ACL Administration")]);
15 require_once('gacl_admin.inc.php');
17 //GET takes precedence.
18 if ($_GET['group_type'] != '') {
19 $group_type = $_GET['group_type'];
21 $group_type = $_POST['group_type'];
24 switch(strtolower(trim($group_type))) {
27 $group_table = $gacl_api->_db_table_prefix
. 'axo_groups';
28 $group_map_table = $gacl_api->_db_table_prefix
. 'groups_axo_map';
29 $smarty->assign('current','axo_group');
33 $group_table = $gacl_api->_db_table_prefix
. 'aro_groups';
34 $group_map_table = $gacl_api->_db_table_prefix
. 'groups_aro_map';
35 $smarty->assign('current','aro_group');
39 $postAction = $_POST['action'] ??
null;
40 switch ($postAction) {
45 $formatted_groups = $gacl_api->format_groups($gacl_api->sort_groups($group_type), 'HTML');
48 SELECT a.id, a.name, a.value, count(b.'. $group_type .'_id)
49 FROM '. $group_table .' a
50 LEFT JOIN '. $group_map_table .' b ON b.group_id=a.id
51 GROUP BY a.id,a.name,a.value';
52 $rs = $db->Execute($query);
54 $group_data = array();
57 while($row = $rs->FetchRow()) {
58 $group_data[$row[0]] = array(
68 foreach($formatted_groups as $id => $name) {
71 // 'parent_id' => $parent_id,
72 // 'family_id' => $family_id,
74 'raw_name' => $group_data[$id]['name'],
75 'value' => $group_data[$id]['value'],
76 'object_count' => $group_data[$id]['count']
80 $smarty->assign('groups', $groups);
84 $smarty->assign('group_type', $group_type);
85 $smarty->assign('return_page', $_SERVER['REQUEST_URI']);
87 $smarty->assign('current', $group_type .'_group');
88 $smarty->assign('page_title', strtoupper($group_type) .' Group Admin');
90 $smarty->assign('phpgacl_version', $gacl_api->get_version());
91 $smarty->assign('phpgacl_schema_version', $gacl_api->get_schema_version());
93 $smarty->assign("CSRF_TOKEN_FORM", CsrfUtils
::collectCsrfToken());
95 $smarty->display('phpgacl/group_admin.tpl');