Bug fix for provider Insurance Numbers
[openemr.git] / acl_upgrade.php
blob4c96ab09cb5a28739d1eff0ca213b6dcd3a2a233
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
6 //
7 // This script will update the phpGACL database, which include
8 // Access Control Objects(ACO), Groups(ARO), and Access Control
9 // Lists(ACL) to the most recent version.
10 // It will display whether each update already exist
11 // or if it was updated succesfully.
13 // Updates included:
14 // 2.8.2
15 // Section "sensitivities" (Sensitivities):
16 // ADD normal Normal (Administrators, Physicians, Clinicians(addonly))
17 // ADD high High (Administrators, Physicians)
18 // Section "admin" (Administration):
19 // ADD super Superuser (Adminstrators)
20 // 2.8.4
21 // Section "admin" (Administration):
22 // ADD drugs Pharmacy Dispensary (Administrators, Physicians, Clinicians(write))
23 // ADD acl ACL Administration (Administrators)
24 // Section "sensitivities" (Sensitivities):
25 // EDIT high High (ensure the order variable is '20')
26 // Section "acct" (Accounting):
27 // ADD disc Price Discounting (Administrators, Physicians, Accounting(write))
28 // 3.0.2
29 // ADD Section "lists" (Lists):
30 // ADD default Default List (write,addonly optional) (Administrators)
31 // ADD state State List (write,addonly optional) (Administrators)
32 // ADD country Country List (write,addonly optional) (Administrators)
33 // ADD language Language List (write,addonly optional) (Administrators)
34 // ADD ethrace Ethnicity-Race List (write,addonly optional) (Administrators)
35 // ADD Section "placeholder" (Placeholder):
36 // ADD filler Placeholder (Maintains empty ACLs)
37 // 3.3.0
38 // Section "patients" (Patients):
39 // ADD sign Sign Lab Results (Physicians)
41 $ignoreAuth = true; // no login required
43 require_once('interface/globals.php');
45 //Ensure that phpGACL has been installed
46 include_once('library/acl.inc');
47 if (isset ($phpgacl_location)) {
48 include_once("$phpgacl_location/gacl_api.class.php");
49 $gacl = new gacl_api();
51 else {
52 die("You must first set up library/acl.inc to use phpGACL!");
56 //Collect the ACL ID numbers.
57 echo "<B>Checking to ensure all the proper ACL(access control list) are present:</B></BR>";
58 //Get Administrator ACL ID number
59 $admin_write = getAclIdNumber('Administrators', 'write');
60 //Get Doctor ACL ID Number
61 $doc_write = getAclIdNumber('Physicians', 'write');
62 //Get Clinician ACL with write access ID number
63 $clin_write = getAclIdNumber('Clinicians', 'write');
64 //Get Clinician ACL with addonly access ID number
65 $clin_addonly = getAclIdNumber('Clinicians', 'addonly');
66 //Get Receptionist ACL ID number
67 $front_write = getAclIdNumber('Front Office', 'write');
68 //Get Accountant ACL ID number
69 $back_write = getAclIdNumber('Accounting', 'write');
71 //Add new object Sections
72 echo "<BR/><B>Adding new object sections</B><BR/>";
73 //Add 'Sensitivities' object section (added in 2.8.2)
74 addObjectSectionAcl('sensitivities', 'Sensitivities');
75 //Add 'Lists' object section (added in 3.0.2)
76 addObjectSectionAcl('lists', 'Lists');
77 //Add 'Placeholder' object section (added in 3.0.2)
78 addObjectSectionAcl('placeholder', 'Placeholder');
79 //Add 'Nation Notes' object section (added in 4.1.0)
80 addObjectSectionAcl('nationnotes','Nation Notes');
81 //Add 'Patient Portal' object section (added in 4.1.0)
82 addObjectSectionAcl('patientportal', 'Patient Portal');
84 //Add new Objects
85 echo "<BR/><B>Adding new objects</B><BR/>";
86 //Add 'Normal' sensitivity object, order variable is default 10 (added in 2.8.2)
87 addObjectAcl('sensitivities', 'Sensitivities', 'normal', 'Normal');
88 //Add 'High' sensitivity object, order variable is set to 20 (added in 2.8.2)
89 addObjectAclWithOrder('sensitivities', 'Sensitivities', 'high', 'High', 20);
90 //Add 'Pharmacy Dispensary' object (added in 2.8.4)
91 addObjectAcl('admin', 'Administration', 'drugs', 'Pharmacy Dispensary');
92 //Add 'ACL Administration' object (added in 2.8.4)
93 addObjectAcl('admin', 'Administration', 'acl', 'ACL Administration');
94 //Add 'Price Discounting' object (added in 2.8.4)
95 addObjectAcl('acct', 'Accounting', 'disc', 'Price Discounting');
96 //Add 'Default List (write,addonly optional)' object (added in 3.0.2)
97 addObjectAcl('lists', 'Lists', 'default', 'Default List (write,addonly optional)');
98 //Add 'State List (write,addonly optional)' object (added in 3.0.2)
99 addObjectAcl('lists', 'Lists', 'state', 'State List (write,addonly optional)');
100 //Add 'Country List (write,addonly optional)' object (added in 3.0.2)
101 addObjectAcl('lists', 'Lists', 'country', 'Country List (write,addonly optional)');
102 //Add 'Language List (write,addonly optional)' object (added in 3.0.2)
103 addObjectAcl('lists', 'Lists', 'language', 'Language List (write,addonly optional)');
104 //Add 'Ethnicity-Race List (write,addonly optional)' object (added in 3.0.2)
105 addObjectAcl('lists', 'Lists', 'ethrace', 'Ethnicity-Race List (write,addonly optional)');
106 //Add 'Placeholder (Maintains empty ACLs)' object (added in 3.0.2)
107 addObjectAcl('placeholder', 'Placeholder', 'filler', 'Placeholder (Maintains empty ACLs)');
108 //Add 'Sign Lab Results (write,addonly optional)' object (added in 3.3.0)
109 addObjectAcl('patients', 'Patients', 'sign', 'Sign Lab Results (write,addonly optional)');
110 //Add 'nationnotes' object (added in 4.1.0)
111 addObjectAcl('nationnotes', 'Nation Notes', 'nn_configure', 'Nation Notes Configure');
112 //Add 'patientportal' object (added in 4.1.0)
113 addObjectAcl('patientportal', 'Patient Portal', 'portal', 'Patient Portal');
115 //Update already existing Objects
116 echo "<BR/><B>Upgrading objects</B><BR/>";
117 //Ensure that 'High' sensitivity object order variable is set to 20
118 editObjectAcl('sensitivities', 'Sensitivities', 'high', 'High', 20);
120 //Add new ACLs here (will return the ACL ID of newly created or already existant ACL)
121 // (will also place in the appropriate group and CREATE a new group if needed)
122 echo "<BR/><B>Adding ACLs(Access Control Lists) and groups</B><BR/>";
123 //Add 'Physicians' ACL with 'addonly' and collect the ID number (added in 3.0.2)
124 $doc_addonly = addNewACL('Physicians', 'doc', 'addonly', 'Things that physicians can read and enter but not modify');
125 //Add 'Front Office' ACL with 'addonly' and collect the ID number (added in 3.0.2)
126 $front_addonly = addNewACL('Front Office', 'front', 'addonly', 'Things that front office can read and enter but not modify');
127 //Add 'Accounting' ACL with 'addonly' and collect the ID number (added in 3.0.2)
128 $back_addonly = addNewACL('Accounting', 'back', 'addonly', 'Things that back office can read and enter but not modify');
129 //Add 'Emergency Login' ACL with 'write' and collect the ID number (added in 3.3.0)
130 $emergency_write = addNewACL('Emergency Login', 'breakglass', 'write', 'Things that can use for emergency login, can read and modify');
132 //Update the ACLs
133 echo "<BR/><B>Updating the ACLs(Access Control Lists)</B><BR/>";
134 //Insert the 'super' object from the 'admin' section into the Administrators group write ACL (added in 2.8.2)
135 updateAcl($admin_write, 'Administrators', 'admin', 'Administration', 'super', 'Superuser', 'write');
136 //Insert the 'high' object from the 'sensitivities' section into the Administrators group write ACL (added in 2.8.2)
137 updateAcl($admin_write, 'Administrators', 'sensitivities', 'Sensitivities', 'high', 'High', 'write');
138 //Insert the 'normal' object from the 'sensitivities' section into the Administrators group write ACL (added in 2.8.2)
139 updateAcl($admin_write, 'Administrators', 'sensitivities', 'Sensitivities', 'normal', 'Normal', 'write');
140 //Insert the 'high' object from the 'sensitivities' section into the Physicians group write ACL (added in 2.8.2)
141 updateAcl($doc_write, 'Physicians', 'sensitivities', 'Sensitivities', 'high', 'High', 'write');
142 //Insert the 'normal' object from the 'sensitivities' section into the Physicians group write ACL (added in 2.8.2)
143 updateAcl($doc_write, 'Physicians', 'sensitivities', 'Sensitivities', 'normal', 'Normal', 'write');
144 //Insert the 'normal' object from the 'sensitivities' section into the Clinicians group addonly ACL (added in 2.8.2)
145 updateAcl($clin_addonly, 'Clinicians', 'sensitivities', 'Sensitivities', 'normal', 'Normal', 'addonly');
146 //Insert the 'drugs' object from the 'admin' section into the Administrators group write ACL (added in 2.8.4)
147 updateAcl($admin_write, 'Administrators', 'admin', 'Administration', 'drugs', 'Pharmacy Dispensary', 'write');
148 //Insert the 'drugs' object from the 'admin' section into the Physicians group write ACL (added in 2.8.4)
149 updateAcl($doc_write, 'Physicians', 'admin', 'Administration', 'drugs', 'Pharmacy Dispensary', 'write');
150 //Insert the 'drugs' object from the 'admin' section into the Clinicians group write ACL (added in 2.8.4)
151 updateAcl($clin_write, 'Clinicians', 'admin', 'Administration', 'drugs', 'Pharmacy Dispensary', 'write');
152 //Insert the 'acl' object from the 'admin' section into the Administrators group write ACL (added in 2.8.4)
153 updateAcl($admin_write, 'Administrators', 'admin', 'Administration', 'acl', 'ACL Administration', 'write');
154 //Insert the 'disc' object from the 'acct' section into the Administrators group write ACL (added in 2.8.4)
155 updateAcl($admin_write, 'Administrators', 'acct', 'Accounting', 'disc', 'Price Discounting', 'write');
156 //Insert the 'disc' object from the 'acct' section into the Accounting group write ACL (added in 2.8.4)
157 updateAcl($back_write, 'Accounting', 'acct', 'Accounting', 'disc', 'Price Discounting', 'write');
158 //Insert the 'disc' object from the 'acct' section into the Physicians group write ACL (added in 2.8.4)
159 updateAcl($doc_write, 'Physicians', 'acct', 'Accounting', 'disc', 'Price Discounting', 'write');
160 //Insert the 'default' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
161 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'default', 'Default List (write,addonly optional)', 'write');
162 //Insert the 'state' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
163 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'state', 'State List (write,addonly optional)', 'write');
164 //Insert the 'country' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
165 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'country', 'Country List (write,addonly optional)', 'write');
166 //Insert the 'language' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
167 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'language', 'Language List (write,addonly optional)', 'write');
168 //Insert the 'race' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
169 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'ethrace', 'Ethnicity-Race List (write,addonly optional)', 'write');
170 //Update ACLs for Emergency Login
171 //Insert the 'disc' object from the 'acct' section into the Emergency Login group write ACL (added in 3.3.0)
172 updateAcl($emergency_write, 'Emergency Login', 'acct', 'Accounting', 'disc', 'Price Discounting', 'write');
173 //Insert the 'bill' object from the 'acct' section into the Emergency Login group write ACL (added in 3.3.0)
174 updateAcl($emergency_write, 'Emergency Login', 'acct', 'Accounting', 'bill', 'Billing (write optional)', 'write');
175 //Insert the 'eob' object from the 'acct' section into the Emergency Login group write ACL (added in 3.3.0)
176 updateAcl($emergency_write, 'Emergency Login', 'acct', 'Accounting', 'eob', 'EOB Data Entry', 'write');
177 //Insert the 'rep' object from the 'acct' section into the Emergency Login group write ACL (added in 3.3.0)
178 updateAcl($emergency_write, 'Emergency Login', 'acct', 'Accounting', 'rep', 'Financial Reporting - my encounters', 'write');
179 //Insert the 'rep_a' object from the 'acct' section into the Emergency Login group write ACL (added in 3.3.0)
180 updateAcl($emergency_write, 'Emergency Login', 'acct', 'Accounting', 'rep_a', 'Financial Reporting - anything', 'write');
181 //Insert the 'calendar' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
182 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'calendar', 'Calendar Settings', 'write');
183 //Insert the 'database' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
184 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'database', 'Database Reporting', 'write');
185 //Insert the 'forms' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
186 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'forms', 'Forms Administration', 'write');
187 //Insert the 'practice' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
188 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'practice', 'Practice Settings', 'write');
189 //Insert the 'superbill' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
190 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'superbill', 'Superbill Codes Administration', 'write');
191 //Insert the 'users' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
192 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'users', 'Users/Groups/Logs Administration', 'write');
193 //Insert the 'batchcom' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
194 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'batchcom', 'Batch Communication Tool', 'write');
195 //Insert the 'language' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
196 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'language', 'Language Interface Tool', 'write');
197 //Insert the 'super' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
198 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'super', 'Superuser', 'write');
199 //Insert the 'drugs' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
200 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'drugs', 'Pharmacy Dispensary', 'write');
201 //Insert the 'acl' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
202 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'acl', 'ACL Administration', 'write');
203 //Insert the 'auth_a' object from the 'encounters' section into the Emergency Login group write ACL (added in 3.3.0)
204 updateAcl($emergency_write, 'Emergency Login', 'encounters', 'Encounters', 'auth_a', 'Authorize - any encounters', 'write');
205 //Insert the 'coding_a' object from the 'encounters' section into the Emergency Login group write ACL (added in 3.3.0)
206 updateAcl($emergency_write, 'Emergency Login', 'encounters', 'Encounters', 'coding_a', 'Coding - any encounters (write,wsome optional)', 'write');
207 //Insert the 'notes_a' object from the 'encounters' section into the Emergency Login group write ACL (added in 3.3.0)
208 updateAcl($emergency_write, 'Emergency Login', 'encounters', 'Encounters', 'notes_a', 'Notes - any encounters (write,addonly optional)', 'write');
209 //Insert the 'date_a' object from the 'encounters' section into the Emergency Login group write ACL (added in 3.3.0)
210 updateAcl($emergency_write, 'Emergency Login', 'encounters', 'Encounters', 'date_a', 'Fix encounter dates - any encounters', 'write');
211 //Insert the 'default' object from the 'lists' section into the Emergency Login group write ACL (added in 3.3.0)
212 updateAcl($emergency_write, 'Emergency Login', 'lists', 'Lists', 'default', 'Default List (write,addonly optional)', 'write');
213 //Insert the 'state' object from the 'lists' section into the Emergency Login group write ACL (added in 3.3.0)
214 updateAcl($emergency_write, 'Emergency Login', 'lists', 'Lists', 'state', 'State List (write,addonly optional)', 'write');
215 //Insert the 'country' object from the 'lists' section into the Emergency Login group write ACL (added in 3.3.0)
216 updateAcl($emergency_write, 'Emergency Login', 'lists', 'Lists', 'country', 'Country List (write,addonly optional)', 'write');
217 //Insert the 'language' object from the 'lists' section into the Emergency Login group write ACL (added in 3.3.0)
218 updateAcl($emergency_write, 'Emergency Login', 'lists', 'Lists', 'language', 'Language List (write,addonly optional)', 'write');
219 //Insert the 'ethrace' object from the 'lists' section into the Emergency Login group write ACL (added in 3.3.0)
220 updateAcl($emergency_write, 'Emergency Login', 'lists', 'Lists', 'ethrace', 'Ethnicity-Race List (write,addonly optional)', 'write');
221 //Insert the 'appt' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
222 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'appt', 'Appointments (write,wsome optional)', 'write');
223 //Insert the 'demo' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
224 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'demo', 'Demographics (write,addonly optional)', 'write');
225 //Insert the 'med' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
226 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'med', 'Medical/History (write,addonly optional)', 'write');
227 //Insert the 'trans' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
228 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'trans', 'Transactions (write optional)', 'write');
229 //Insert the 'docs' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
230 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'docs', 'Documents (write,addonly optional)', 'write');
231 //Insert the 'notes' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
232 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'notes', 'Patient Notes (write,addonly optional)', 'write');
233 //Insert the 'high' object from the 'sensitivities' section into the Emergency Login group write ACL (added in 3.3.0)
234 updateAcl($emergency_write, 'Emergency Login', 'sensitivities', 'Sensitivities', 'high', 'High', 'write');
235 //Insert the 'normal' object from the 'sensitivities' section into the Emergency Login group write ACL (added in 3.3.0)
236 updateAcl($emergency_write, 'Emergency Login', 'sensitivities', 'Sensitivities', 'normal', 'Normal', 'write');
237 //Insert the 'sign' object from the 'patients' section into the Physicians group write ACL (added in 3.3.0)
238 updateAcl($doc_write, 'Physicians', 'patients', 'Patients', 'sign', 'Sign Lab Results (write,addonly optional)', 'write');
239 //Insert the 'sign' object from the 'nationnotes' section into the Administrators group write ACL (added in 3.3.0)
240 updateAcl($admin_write, 'Administrators','nationnotes', 'Nation Notes', 'nn_configure', 'Nation Notes Configure','write');
241 //Insert the 'sign' object from the 'nationnotes' section into the Emergency Login group write ACL (added in 3.3.0)
242 updateAcl($emergency_write, 'Emergency Login','nationnotes', 'Nation Notes', 'nn_configure', 'Nation Notes Configure','write');
243 //Insert the 'patientportal' object from the 'patientportal' section into the Administrators group write ACL (added in 4.1.0)
244 updateAcl($admin_write, 'Administrators','patientportal', 'Patient Portal', 'portal', 'Patient Portal','write');
245 //Insert the 'patientportal' object from the 'patientportal' section into the Emergency Login group write ACL (added in 4.1.0)
246 updateAcl($emergency_write, 'Emergency Login','patientportal', 'Patient Portal', 'portal', 'Patient Portal','write');
248 //Function will return an array that contains the ACL ID number.
249 //It will also check to ensure the ACL exist and is not duplicated.
250 // $title = Title(string) of group.
251 // $return_value = What the acl returns (string), usually 'write' or 'addonly'
252 function getAclIdNumber($title, $return_value) {
253 global $gacl;
254 $temp_acl_id_array = $gacl->search_acl(FALSE, FALSE, FALSE, FALSE, $title, FALSE, FALSE, FALSE, $return_value);
255 switch (count($temp_acl_id_array)) {
256 case 0:
257 echo "<B>ERROR</B>, '$title' group '$return_value' ACL does not exist.</BR>";
258 break;
259 case 1:
260 echo "'$title' group '$return_value' ACL is present.</BR>";
261 break;
262 default:
263 echo "<B>ERROR</B>, Multiple '$title' group '$return_value' ACLs are present.</BR>";
264 break;
266 return $temp_acl_id_array;
270 //Function will add an ACL (if doesn't already exist).
271 //It will also place the acl in the group, or will CREATE a new group.
272 //It will return the ID number of the acl (created or old)
273 // $title = Title(string) of group.
274 // $name = name of acl (string)
275 // $return_value = What the acl returns (string), usually 'write' or 'addonly'
276 // $note = description of acl (array)
277 function addNewACL($title, $name, $return_value, $note) {
278 global $gacl;
279 $temp_acl_id_array = $gacl->search_acl(FALSE, FALSE, FALSE, FALSE, $title, FALSE, FALSE, FALSE, $return_value);
280 switch (count($temp_acl_id_array)) {
281 case 0:
282 $group_id = $gacl->get_group_id($name, $title, 'ARO');
283 if ($group_id) {
284 //group already exist, so just create acl
285 $temp_acl_id = $gacl->add_acl(array("placeholder"=>array("filler")), NULL, array($group_id), NULL, NULL, 1, 1, $return_value, $note);
286 if ($temp_acl_id) {
287 echo "The '$title' group already exist.</BR>";
288 echo "The '$title' group '$return_value' ACL has been successfully added.</BR>";
289 $temp_acl_id_array = array($temp_acl_id);
291 else {
292 echo "The '$title' group already exist.</BR>";
293 echo "<B>ERROR</B>, Unable to create the '$title' group '$return_value' ACL.</BR>";
296 else {
297 //create group, then create acl
298 $parent_id = $gacl->get_root_group_id();
299 $aro_id = $gacl->add_group($name, $title, $parent_id, 'ARO');
300 $temp_acl_id = $gacl->add_acl(array("placeholder"=>array("filler")), NULL, array($aro_id), NULL, NULL, 1, 1, $return_value, $note);
301 if ($aro_id ) {
302 echo "The '$title' group has been successfully added.</BR>";
304 else {
305 echo "<B>ERROR</B>, Unable to create the '$title' group.</BR>";
307 if ($temp_acl_id) {
308 echo "The '$title' group '$return_value' ACL has been successfully added.</BR>";
309 $temp_acl_id_array = array($temp_acl_id);
311 else {
312 echo "<B>ERROR</B>, Unable to create the '$title' group '$return_value' ACL.</BR>";
315 break;
316 case 1:
317 echo "'$title' group '$return_value' ACL already exist.</BR>";
318 break;
320 default:
321 echo "<B>ERROR</B>, Multiple '$title' group '$return_value' ACLs are present.</BR>";
322 break;
324 return $temp_acl_id_array;
328 //Function to add an object section.
329 //It will check to ensure the object section doesn't already exist.
330 // $name = Identifier(string) of section
331 // $title = Title(string) of object
332 function addObjectSectionAcl($name, $title) {
333 global $gacl;
334 if ($gacl->get_object_section_section_id($title, $name, 'ACO')) {
335 echo "The '$title' object section already exist.</BR>";
337 else {
338 $tmp_boolean = $gacl->add_object_section($title , $name, 10, 0, 'ACO');
339 if ($tmp_boolean) {
340 echo "The '$title' object section has been successfully added.</BR>";
342 else {
343 echo "<B>ERROR</B>,unable to create the '$title' object section.</BR>";
346 return;
350 //Function to add an object.
351 //It will check to ensure the object doesn't already exist.
352 // $section_name = Identifier(string) of section
353 // $section_title = Title(string) of section
354 // $object_name = Identifier(string) of object
355 // $object_title = Title(string) of object
356 function addObjectAcl($section_name, $section_title, $object_name, $object_title) {
357 global $gacl;
358 if ($gacl->get_object_id($section_name, $object_name, 'ACO')) {
359 echo "The '$object_title' object in the '$section_title' section already exist.</BR>";
361 else {
362 $tmp_boolean = $gacl->add_object($section_name, $object_title, $object_name, 10, 0, 'ACO');
363 if ($tmp_boolean) {
364 echo "The '$object_title' object in the '$section_title' section has been successfully added.</BR>";
366 else {
367 echo "<B>ERROR</B>,unable to create the '$object_title' object in the '$section_title' section.</BR>";
370 return;
374 //Function to add an object and set the 'order' variable.
375 //It will check to ensure the object doesn't already exist.
376 // $section_name = Identifier(string) of section
377 // $section_title = Title(string) of section
378 // $object_name = Identifier(string) of object
379 // $object_title = Title(string) of object
380 // $order_number = number to determine order in list. used in sensitivities to order the choices
381 // in openemr
382 function addObjectAclWithOrder($section_name, $section_title, $object_name, $object_title, $order_number) {
383 global $gacl;
384 if ($gacl->get_object_id($section_name, $object_name, 'ACO')) {
385 echo "The '$object_title' object in the '$section_title' section already exist.</BR>";
387 else {
388 $tmp_boolean = $gacl->add_object($section_name, $object_title, $object_name, $order_number, 0, 'ACO');
389 if ($tmp_boolean) {
390 echo "The '$object_title' object in the '$section_title' section has been successfully added.</BR>";
392 else {
393 echo "<B>ERROR</B>,unable to create the '$object_title' object in the '$section_title' section.</BR>";
396 return;
400 //Function to edit an object and set the 'order' variable.
401 //It will check to ensure the object already exist, and hasn't been upgraded yet.
402 // $section_name = Identifier(string) of section
403 // $section_title = Title(string) of section
404 // $object_name = Identifier(string) of object
405 // $object_title = Title(string) of object
406 // $order_number = number to determine order in list. used in sensitivities to order the choices
407 // in openemr
408 function editObjectAcl($section_name, $section_title, $object_name, $object_title, $order_number) {
409 global $gacl;
410 $tmp_objectID = $gacl->get_object_id($section_name, $object_name, 'ACO');
411 if ($tmp_objectID) {
412 $tmp_object = $gacl->get_object_data($tmp_objectID, 'ACO');
413 if ($tmp_object[0][2] == $order_number &&
414 $tmp_object[0][0] == $section_name &&
415 $tmp_object[0][1] == $object_name &&
416 $tmp_object[0][3] == $object_title) {
417 echo "The '$object_title' object in the '$section_title' section has already been updated.</BR>";
419 else {
420 $tmp_boolean = $gacl->edit_object($tmp_objectID, $section_name, $object_title, $object_name, $order_number, 0, 'ACO');
421 if ($tmp_boolean) {
422 echo "The '$object_title' object in the '$section_title' section has been successfully updated.</BR>";
424 else {
425 echo "<B>ERROR</B>,unable to update the '$object_title' object in the '$section_title' section.</BR>";
429 else {
430 echo "<B>ERROR</B>, the '$object_title' object in the '$section_title' section does not exist.</BR>";
432 return;
436 //Update the ACL
437 //It will check to ensure the ACL hasn't already been updated.
438 // $array_acl_id_number = array containing hopefully one element, which is an integer, and is identifier of acl to be updated.
439 // $group_title = Title(string) of group.
440 // $object_section_name = Identifier(string) of section
441 // $object_section_title = Title(string) of section
442 // $object_name = Identifier(string) of object
443 // $object_title = Title(string) of object
444 // $acl_return_value = What the acl returns (string), usually 'write' or 'addonly'
445 function updateAcl($array_acl_id_number, $group_title, $section_name, $section_title, $object_name, $object_title, $return_value) {
446 global $gacl;
447 $tmp_array = $gacl->search_acl($section_name, $object_name, FALSE, FALSE, $group_title, FALSE, FALSE, FALSE, $return_value);
448 switch (count($tmp_array)) {
449 case 0:
450 $tmp_boolean = @$gacl->append_acl($array_acl_id_number[0], NULL, NULL, NULL, NULL, array($section_name=>array($object_name)));
451 if ($tmp_boolean){
452 echo "Successfully placed the '$object_title' object of the '$section_title' section into the '$group_title' group '$return_value' ACL.</BR>";
454 else {
455 echo "<B>ERROR</B>,unable to place the '$object_title' object of the '$section_title' section into the '$group_title' group '$return_value' ACL.</BR>";
457 break;
458 case 1:
459 echo "The '$object_title' object of the '$section_title' section is already found in the '$group_title' group '$return_value' ACL.</BR>";
460 break;
461 default:
462 echo "<B>ERROR</B>, Multiple '$group_title' group '$return_value' ACLs with the '$object_title' object of the '$section_title' section are present.</BR>";
463 break;
465 return;
468 //All done
469 echo "</BR><B>ALL DONE</B>";