2 // If you have installed phpGACL (http://phpgacl.sourceforge.net/)
3 // and have configured it for your site, then uncomment the following
4 // statement and change it to point to the location where
5 // gacl.class.php is intalled.
7 // $phpgacl_location = "/var/www/phpgacl";
9 // Tentatively, the following Access Control Objects will be supported.
10 // These are the "things to be protected":
12 // Section "admin" (Administration):
13 // acl Access Control Administration
14 // calendar Calendar Settings
15 // database Database Reporting
16 // forms Forms Administration
17 // practice Practice Settings
18 // superbill Superbill Codes Administration
19 // users Users/Groups/Logs Administration
21 // Section "acct" (Accounting):
22 // bill Billing (write optional)
24 // rep Financial Reporting - my encounters
25 // rep_a Financial Reporting - anything
27 // Section "patients" (Patient Information):
28 // appt Appointments (write optional)
29 // demo Demographics (write,addonly optional)
30 // med Medical Records and History (write,addonly optional)
31 // trans Transactions, e.g. referrals (write optional)
32 // docs Documents (write,addonly optional)
33 // notes Patient Notes (write,addonly optional)
35 // Section "encounters" (Encounter Information):
36 // auth Authorize - my encounters
37 // auth_a Authorize - any encounters
38 // coding Coding - my encounters (write,wsome optional)
39 // coding_a Coding - any encounters (write,wsome optional)
40 // notes Notes - my encounters (write,addonly optional)
41 // notes_a Notes - any encounters (write,addonly optional)
42 // date_a Fix encounter dates - any encounters
43 // relaxed Less-private information (write,addonly optional)
44 // (e.g. the Sports Fitness encounter form)
46 // Section "squads" applies to sports team use only:
47 // acos in this section define the user-specified list of squads
49 if ($phpgacl_location) {
50 include_once("$phpgacl_location/gacl.class.php");
51 $gacl_object = new gacl();
54 // acl_check should return 0 if access is denied. Otherwise it may
55 // return anything that evaluates to true. In addition if any of the
56 // following types of access are applicable, then the corresponding value
57 // must be returned if and only if such access is granted (ony one may
60 // * write - the user may add or modify the ACO
61 // * wsome - the user has limited add/modify access to the ACO
62 // * addonly - the user may view and add but not modify entries
64 function acl_check($section, $value, $user = '') {
65 global $gacl_object, $phpgacl_location;
66 if (! $user) $user = $_SESSION['authUser'];
68 if ($phpgacl_location) {
69 return $gacl_object->acl_check($section, $value, 'users', $user);
72 // If no phpgacl, then apply the old static rules whereby "authorized"
73 // users (providers) can do anything, and other users can do most things.
74 // If you want custom access control but don't want to mess with phpGACL,
75 // then you could customize the code below instead.
77 if ($_SESSION['userauthorized']) return 'write';
79 if ($section == 'patients') {
80 if ($value != 'med') return 'write';
82 else if ($section == 'encounters') {
83 if (strpos($value, 'coding' ) === 0) return 'write';
84 if (strpos($value, 'notes' ) === 0) return 'write';
85 if ($value == 'relaxed') return 'write';
87 else if ($section != 'admin') {
94 // Return an array of squad ACO names and descriptive names.
95 // This is only applicable for sports team use.
97 function acl_get_squads() {
98 global $phpgacl_location;
99 if ($phpgacl_location) {
100 include_once("$phpgacl_location/gacl_api.class.php");
102 $gacl = new gacl_api();
103 $arr1 = $gacl->get_objects($section, 1, 'ACO');
105 foreach ($arr1[$section] as $value) {
106 $odata = $gacl->get_object_data($gacl->get_object_id($section, $value, 'ACO'), 'ACO');
107 $arr[$value] = $odata[0][3];