comments about includes/config.php added
[openemr.git] / library / acl.inc
blob7fd0f72e4d31fb3018c32fddf05c9a7426728b77
1 <?
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.
6   //
7   // $phpgacl_location = "/var/www/phpgacl";
9   // Tentatively, the following Access Control Objects will be supported.
10   // These are the "things to be protected":
11   //
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
20   //
21   // Section "acct" (Accounting):
22   //   bill        Billing (write optional)
23   //   eob         EOB data entry
24   //   rep         Financial Reporting - my encounters
25   //   rep_a       Financial Reporting - anything
26   //
27   // Section "patients" (Patient Information):
28   //   appt        Appointments (write optional)
29   //   demo        Demographics (write optional)
30   //   med         Medical Records and History (write optional)
31   //   trans       Transactions, e.g. referrals (write optional)
32   //   docs        Documents (write optional)
33   //
34   // Section "encounters" (Encounter Information):
35   //   auth        Authorize - my encounters
36   //   auth_a      Authorize - any encounters
37   //   coding      Coding - my encounters (write,wsome optional)
38   //   coding_a    Coding - any encounters (write,wsome optional)
39   //   notes       Notes - my encounters (write optional)
40   //   notes_a     Notes - any encounters (write optional)
42   if ($phpgacl_location) {
43     include_once("$phpgacl_location/gacl.class.php");
44     $gacl_object = new gacl();
45   }
47   // acl_check should return 0 if access is denied.  Otherwise it may
48   // return anything that evaluates to true.  In addition if any of the
49   // following types of access are applicable, then the corresponding value
50   // must be returned if and only if such access is granted:
51   //
52   // * write - the user may add or modify the ACO
53   // * wsome - the user has limited add/modify access to the ACO
54   //
55   function acl_check($section, $value, $user = '') {
56     global $gacl_object, $phpgacl_location;
57     if (! $user) $user = $_SESSION['authUser'];
59     if ($phpgacl_location) {
60       return $gacl_object->acl_check($section, $value, 'users', $user);
61     }
63     // If no phpgacl, then apply the old static rules whereby "authorized"
64     // users (providers) can do anything, and other users can do most things.
66     if ($_SESSION['userauthorized']) return 'write';
68     if ($section == 'patients') {
69       if ($value != 'med') return 'write';
70     }
71     else if ($section == 'encounters') {
72       if (strpos($value, 'coding') === 0) return 'write';
73       if (strpos($value, 'notes' ) === 0) return 'write';
74     }
75     else if ($section == 'acct') {
76       return 'write';
77     }
79     return 0;
80   }