add feature to see appointment by clicking on its time
[openemr.git] / library / acl.inc
blob85f62ec33b3081c8b7479dbf2f0d3f3e8e334c61
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   //   super       Superuser - can delete patients, encounters, issues
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,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)
34   //
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)
45   //
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();
52   }
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
58   // be specified):
59   //
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
63   //
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);
70     }
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 ($section == 'admin' && $value == 'super') return 0;
79     if ($_SESSION['userauthorized']) return 'write';
81     if ($section == 'patients') {
82       if ($value != 'med') return 'write';
83     }
84     else if ($section == 'encounters') {
85       if (strpos($value, 'coding' ) === 0) return 'write';
86       if (strpos($value, 'notes'  ) === 0) return 'write';
87       if ($value == 'relaxed') return 'write';
88     }
89     else if ($section != 'admin') {
90       return 'write';
91     }
93     return 0;
94   }
96   // Return an array keyed on squad ACO names.  Each value is an
97   // array (section_value, value, order_value, name, hidden).
98   // This is only applicable for sports team use.
99   //
100   function acl_get_squads() {
101     global $phpgacl_location;
102     if ($phpgacl_location) {
103       include_once("$phpgacl_location/gacl_api.class.php");
104       $section = 'squads';
105       $gacl = new gacl_api();
106       $arr1 = $gacl->get_objects($section, 1, 'ACO');
107       $arr = array();
108       foreach ($arr1[$section] as $value) {
109         $odata = $gacl->get_object_data($gacl->get_object_id($section, $value, 'ACO'), 'ACO');
110         // $arr[$value] = $odata[0][3];
111         $arr[$value] = $odata[0];
112       }
113       return $arr;
114     }
115     return 0;
116   }