option for using DOS as billing date added
[openemr.git] / library / acl.inc
blob36f92a6e8a09bd5d262eaa01ae0561e40ce01752
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/gacl";
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   //   batchcom    Batch Communication Tool
21   //   language    Language Interface Tool      
22   //
23   // Section "acct" (Accounting):
24   //   bill        Billing (write optional)
25   //   eob         EOB Data Entry
26   //   rep         Financial Reporting - my encounters
27   //   rep_a       Financial Reporting - anything
28   //
29   // Section "patients" (Patient Information):
30   //   appt        Appointments (write optional)
31   //   demo        Demographics (write,addonly optional)
32   //   med         Medical Records and History (write,addonly optional)
33   //   trans       Transactions, e.g. referrals (write optional)
34   //   docs        Documents (write,addonly optional)
35   //   notes       Patient Notes (write,addonly optional)
36   //
37   // Section "encounters" (Encounter Information):
38   //   auth        Authorize - my encounters
39   //   auth_a      Authorize - any encounters
40   //   coding      Coding - my encounters (write,wsome optional)
41   //   coding_a    Coding - any encounters (write,wsome optional)
42   //   notes       Notes - my encounters (write,addonly optional)
43   //   notes_a     Notes - any encounters (write,addonly optional)
44   //   date_a      Fix encounter dates - any encounters
45   //   relaxed     Less-private information (write,addonly optional)
46   //               (e.g. the Sports Fitness encounter form)
47   //
48   // Section "squads" applies to sports team use only:
49   //   acos in this section define the user-specified list of squads
51   if ($phpgacl_location) {
52     include_once("$phpgacl_location/gacl.class.php");
53     $gacl_object = new gacl();
54   }
56   // acl_check should return 0 if access is denied.  Otherwise it may
57   // return anything that evaluates to true.  In addition if any of the
58   // following types of access are applicable, then the corresponding value
59   // must be returned if and only if such access is granted (ony one may
60   // be specified):
61   //
62   // * write   - the user may add or modify the ACO
63   // * wsome   - the user has limited add/modify access to the ACO
64   // * addonly - the user may view and add but not modify entries
65   //
66   function acl_check($section, $value, $user = '') {
67     global $gacl_object, $phpgacl_location;
68     if (! $user) $user = $_SESSION['authUser'];
70     if ($phpgacl_location) {
71       return $gacl_object->acl_check($section, $value, 'users', $user);
72     }
74     // If no phpgacl, then apply the old static rules whereby "authorized"
75     // users (providers) can do anything, and other users can do most things.
76     // If you want custom access control but don't want to mess with phpGACL,
77     // then you could customize the code below instead.
79     if ($section == 'admin' && $value == 'super') return 0;
81     if ($_SESSION['userauthorized']) return 'write';
83     if ($section == 'patients') {
84       if ($value != 'med') return 'write';
85     }
86     else if ($section == 'encounters') {
87       if (strpos($value, 'coding' ) === 0) return 'write';
88       if (strpos($value, 'notes'  ) === 0) return 'write';
89       if ($value == 'relaxed') return 'write';
90     }
91     else if ($section != 'admin') {
92       return 'write';
93     }
95     return 0;
96   }
98   // Return an array keyed on squad ACO names.  Each value is an
99   // array (section_value, value, order_value, name, hidden).
100   // This is only applicable for sports team use.
101   //
102   function acl_get_squads() {
103     global $phpgacl_location;
104     if ($phpgacl_location) {
105       include_once("$phpgacl_location/gacl_api.class.php");
106       $section = 'squads';
107       $gacl = new gacl_api();
108       $arr1 = $gacl->get_objects($section, 1, 'ACO');
109       $arr = array();
110       foreach ($arr1[$section] as $value) {
111         $odata = $gacl->get_object_data($gacl->get_object_id($section, $value, 'ACO'), 'ACO');
112         // $arr[$value] = $odata[0][3];
113         $arr[$value] = $odata[0];
114       }
115       return $arr;
116     }
117     return 0;
118   }