internationalization bug fixes
[openemr.git] / acl_upgrade.php
blob0ff790fa85de19a932cdf97edbb4f253e01a1d45
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)
38 //Ensure that phpGACL has been installed
39 include_once('library/acl.inc');
40 if (isset ($phpgacl_location)) {
41 include_once("$phpgacl_location/gacl_api.class.php");
42 $gacl = new gacl_api();
44 else {
45 die("You must first set up library/acl.inc to use phpGACL!");
49 //Collect the ACL ID numbers.
50 echo "<B>Checking to ensure all the proper ACL(access control list) are present:</B></BR>";
51 //Get Administrator ACL ID number
52 $admin_write = getAclIdNumber('Administrators', 'write');
53 //Get Doctor ACL ID Number
54 $doc_write = getAclIdNumber('Physicians', 'write');
55 //Get Clinician ACL with write access ID number
56 $clin_write = getAclIdNumber('Clinicians', 'write');
57 //Get Clinician ACL with addonly access ID number
58 $clin_addonly = getAclIdNumber('Clinicians', 'addonly');
59 //Get Receptionist ACL ID number
60 $front_write = getAclIdNumber('Front Office', 'write');
61 //Get Accountant ACL ID number
62 $back_write = getAclIdNumber('Accounting', 'write');
64 //Add new object Sections
65 echo "<BR/><B>Adding new object sections</B><BR/>";
66 //Add 'Sensitivities' object section (added in 2.8.2)
67 addObjectSectionAcl('sensitivities', 'Sensitivities');
68 //Add 'Lists' object section (added in 3.0.2)
69 addObjectSectionAcl('lists', 'Lists');
70 //Add 'Placeholder' object section (added in 3.0.2)
71 addObjectSectionAcl('placeholder', 'Placeholder');
73 //Add new Objects
74 echo "<BR/><B>Adding new objects</B><BR/>";
75 //Add 'Normal' sensitivity object, order variable is default 10 (added in 2.8.2)
76 addObjectAcl('sensitivities', 'Sensitivities', 'normal', 'Normal');
77 //Add 'High' sensitivity object, order variable is set to 20 (added in 2.8.2)
78 addObjectAclWithOrder('sensitivities', 'Sensitivities', 'high', 'High', 20);
79 //Add 'Pharmacy Dispensary' object (added in 2.8.4)
80 addObjectAcl('admin', 'Administration', 'drugs', 'Pharmacy Dispensary');
81 //Add 'ACL Administration' object (added in 2.8.4)
82 addObjectAcl('admin', 'Administration', 'acl', 'ACL Administration');
83 //Add 'Price Discounting' object (added in 2.8.4)
84 addObjectAcl('acct', 'Accounting', 'disc', 'Price Discounting');
85 //Add 'Default List (write,addonly optional)' object (added in 3.0.2)
86 addObjectAcl('lists', 'Lists', 'default', 'Default List (write,addonly optional)');
87 //Add 'State List (write,addonly optional)' object (added in 3.0.2)
88 addObjectAcl('lists', 'Lists', 'state', 'State List (write,addonly optional)');
89 //Add 'Country List (write,addonly optional)' object (added in 3.0.2)
90 addObjectAcl('lists', 'Lists', 'country', 'Country List (write,addonly optional)');
91 //Add 'Language List (write,addonly optional)' object (added in 3.0.2)
92 addObjectAcl('lists', 'Lists', 'language', 'Language List (write,addonly optional)');
93 //Add 'Ethnicity-Race List (write,addonly optional)' object (added in 3.0.2)
94 addObjectAcl('lists', 'Lists', 'ethrace', 'Ethnicity-Race List (write,addonly optional)');
95 //Add 'Placeholder (Maintains empty ACLs)' object (added in 3.0.2)
96 addObjectAcl('placeholder', 'Placeholder', 'filler', 'Placeholder (Maintains empty ACLs)');
98 //Update already existing Objects
99 echo "<BR/><B>Upgrading objects</B><BR/>";
100 //Ensure that 'High' sensitivity object order variable is set to 20
101 editObjectAcl('sensitivities', 'Sensitivities', 'high', 'High', 20);
103 //Add new ACLs here (will return the ACL ID of newly created or already existant ACL)
104 // (will also place in the appropriate group and CREATE a new group if needed)
105 echo "<BR/><B>Adding ACLs(Access Control Lists) and groups</B><BR/>";
106 //Add 'Physicians' ACL with 'addonly' and collect the ID number (added in 3.0.2)
107 $doc_addonly = addNewACL('Physicians', 'doc', 'addonly', 'Things that physicians can read and enter but not modify');
108 //Add 'Front Office' ACL with 'addonly' and collect the ID number (added in 3.0.2)
109 $front_addonly = addNewACL('Front Office', 'front', 'addonly', 'Things that front office can read and enter but not modify');
110 //Add 'Accounting' ACL with 'addonly' and collect the ID number (added in 3.0.2)
111 $back_addonly = addNewACL('Accounting', 'back', 'addonly', 'Things that back office can read and enter but not modify');
112 //Add 'Emergency Login' ACL with 'write' and collect the ID number (added in 3.3.0)
113 $emergency_write = addNewACL('Emergency Login', 'breakglass', 'write', 'Things that can use for emergency login, can read and modify');
115 //Update the ACLs
116 echo "<BR/><B>Updating the ACLs(Access Control Lists)</B><BR/>";
117 //Insert the 'super' object from the 'admin' section into the Administrators group write ACL (added in 2.8.2)
118 updateAcl($admin_write, 'Administrators', 'admin', 'Administration', 'super', 'Superuser', 'write');
119 //Insert the 'high' object from the 'sensitivities' section into the Administrators group write ACL (added in 2.8.2)
120 updateAcl($admin_write, 'Administrators', 'sensitivities', 'Sensitivities', 'high', 'High', 'write');
121 //Insert the 'normal' object from the 'sensitivities' section into the Administrators group write ACL (added in 2.8.2)
122 updateAcl($admin_write, 'Administrators', 'sensitivities', 'Sensitivities', 'normal', 'Normal', 'write');
123 //Insert the 'high' object from the 'sensitivities' section into the Physicians group write ACL (added in 2.8.2)
124 updateAcl($doc_write, 'Physicians', 'sensitivities', 'Sensitivities', 'high', 'High', 'write');
125 //Insert the 'normal' object from the 'sensitivities' section into the Physicians group write ACL (added in 2.8.2)
126 updateAcl($doc_write, 'Physicians', 'sensitivities', 'Sensitivities', 'normal', 'Normal', 'write');
127 //Insert the 'normal' object from the 'sensitivities' section into the Clinicians group addonly ACL (added in 2.8.2)
128 updateAcl($clin_addonly, 'Clinicians', 'sensitivities', 'Sensitivities', 'normal', 'Normal', 'addonly');
129 //Insert the 'drugs' object from the 'admin' section into the Administrators group write ACL (added in 2.8.4)
130 updateAcl($admin_write, 'Administrators', 'admin', 'Administration', 'drugs', 'Pharmacy Dispensary', 'write');
131 //Insert the 'drugs' object from the 'admin' section into the Physicians group write ACL (added in 2.8.4)
132 updateAcl($doc_write, 'Physicians', 'admin', 'Administration', 'drugs', 'Pharmacy Dispensary', 'write');
133 //Insert the 'drugs' object from the 'admin' section into the Clinicians group write ACL (added in 2.8.4)
134 updateAcl($clin_write, 'Clinicians', 'admin', 'Administration', 'drugs', 'Pharmacy Dispensary', 'write');
135 //Insert the 'acl' object from the 'admin' section into the Administrators group write ACL (added in 2.8.4)
136 updateAcl($admin_write, 'Administrators', 'admin', 'Administration', 'acl', 'ACL Administration', 'write');
137 //Insert the 'disc' object from the 'acct' section into the Administrators group write ACL (added in 2.8.4)
138 updateAcl($admin_write, 'Administrators', 'acct', 'Accounting', 'disc', 'Price Discounting', 'write');
139 //Insert the 'disc' object from the 'acct' section into the Accounting group write ACL (added in 2.8.4)
140 updateAcl($back_write, 'Accounting', 'acct', 'Accounting', 'disc', 'Price Discounting', 'write');
141 //Insert the 'disc' object from the 'acct' section into the Physicians group write ACL (added in 2.8.4)
142 updateAcl($doc_write, 'Physicians', 'acct', 'Accounting', 'disc', 'Price Discounting', 'write');
143 //Insert the 'default' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
144 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'default', 'Default List (write,addonly optional)', 'write');
145 //Insert the 'state' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
146 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'state', 'State List (write,addonly optional)', 'write');
147 //Insert the 'country' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
148 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'country', 'Country List (write,addonly optional)', 'write');
149 //Insert the 'language' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
150 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'language', 'Language List (write,addonly optional)', 'write');
151 //Insert the 'race' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
152 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'ethrace', 'Ethnicity-Race List (write,addonly optional)', 'write');
153 //Update ACLs for Emergency Login
154 //Insert the 'disc' object from the 'acct' section into the Emergency Login group write ACL (added in 3.3.0)
155 updateAcl($emergency_write, 'Emergency Login', 'acct', 'Accounting', 'disc', 'Price Discounting', 'write');
156 //Insert the 'bill' object from the 'acct' section into the Emergency Login group write ACL (added in 3.3.0)
157 updateAcl($emergency_write, 'Emergency Login', 'acct', 'Accounting', 'bill', 'Billing (write optional)', 'write');
158 //Insert the 'eob' object from the 'acct' section into the Emergency Login group write ACL (added in 3.3.0)
159 updateAcl($emergency_write, 'Emergency Login', 'acct', 'Accounting', 'eob', 'EOB Data Entry', 'write');
160 //Insert the 'rep' object from the 'acct' section into the Emergency Login group write ACL (added in 3.3.0)
161 updateAcl($emergency_write, 'Emergency Login', 'acct', 'Accounting', 'rep', 'Financial Reporting - my encounters', 'write');
162 //Insert the 'rep_a' object from the 'acct' section into the Emergency Login group write ACL (added in 3.3.0)
163 updateAcl($emergency_write, 'Emergency Login', 'acct', 'Accounting', 'rep_a', 'Financial Reporting - anything', 'write');
164 //Insert the 'calendar' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
165 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'calendar', 'Calendar Settings', 'write');
166 //Insert the 'database' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
167 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'database', 'Database Reporting', 'write');
168 //Insert the 'forms' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
169 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'forms', 'Forms Administration', 'write');
170 //Insert the 'practice' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
171 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'practice', 'Practice Settings', 'write');
172 //Insert the 'superbill' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
173 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'superbill', 'Superbill Codes Administration', 'write');
174 //Insert the 'users' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
175 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'users', 'Users/Groups/Logs Administration', 'write');
176 //Insert the 'batchcom' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
177 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'batchcom', 'Batch Communication Tool', 'write');
178 //Insert the 'language' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
179 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'language', 'Language Interface Tool', 'write');
180 //Insert the 'super' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
181 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'super', 'Superuser', 'write');
182 //Insert the 'drugs' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
183 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'drugs', 'Pharmacy Dispensary', 'write');
184 //Insert the 'acl' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
185 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'acl', 'ACL Administration', 'write');
186 //Insert the 'auth_a' object from the 'encounters' section into the Emergency Login group write ACL (added in 3.3.0)
187 updateAcl($emergency_write, 'Emergency Login', 'encounters', 'Encounters', 'auth_a', 'Authorize - any encounters', 'write');
188 //Insert the 'coding_a' object from the 'encounters' section into the Emergency Login group write ACL (added in 3.3.0)
189 updateAcl($emergency_write, 'Emergency Login', 'encounters', 'Encounters', 'coding_a', 'Coding - any encounters (write,wsome optional)', 'write');
190 //Insert the 'notes_a' object from the 'encounters' section into the Emergency Login group write ACL (added in 3.3.0)
191 updateAcl($emergency_write, 'Emergency Login', 'encounters', 'Encounters', 'notes_a', 'Notes - any encounters (write,addonly optional)', 'write');
192 //Insert the 'date_a' object from the 'encounters' section into the Emergency Login group write ACL (added in 3.3.0)
193 updateAcl($emergency_write, 'Emergency Login', 'encounters', 'Encounters', 'date_a', 'Fix encounter dates - any encounters', 'write');
194 //Insert the 'default' object from the 'lists' section into the Emergency Login group write ACL (added in 3.3.0)
195 updateAcl($emergency_write, 'Emergency Login', 'lists', 'Lists', 'default', 'Default List (write,addonly optional)', 'write');
196 //Insert the 'state' object from the 'lists' section into the Emergency Login group write ACL (added in 3.3.0)
197 updateAcl($emergency_write, 'Emergency Login', 'lists', 'Lists', 'state', 'State List (write,addonly optional)', 'write');
198 //Insert the 'country' object from the 'lists' section into the Emergency Login group write ACL (added in 3.3.0)
199 updateAcl($emergency_write, 'Emergency Login', 'lists', 'Lists', 'country', 'Country List (write,addonly optional)', 'write');
200 //Insert the 'language' object from the 'lists' section into the Emergency Login group write ACL (added in 3.3.0)
201 updateAcl($emergency_write, 'Emergency Login', 'lists', 'Lists', 'language', 'Language List (write,addonly optional)', 'write');
202 //Insert the 'ethrace' object from the 'lists' section into the Emergency Login group write ACL (added in 3.3.0)
203 updateAcl($emergency_write, 'Emergency Login', 'lists', 'Lists', 'ethrace', 'Ethnicity-Race List (write,addonly optional)', 'write');
204 //Insert the 'appt' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
205 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'appt', 'Appointments (write optional)', 'write');
206 //Insert the 'demo' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
207 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'demo', 'Demographics (write,addonly optional)', 'write');
208 //Insert the 'med' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
209 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'med', 'Medical/History (write,addonly optional)', 'write');
210 //Insert the 'trans' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
211 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'trans', 'Transactions (write optional)', 'write');
212 //Insert the 'docs' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
213 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'docs', 'Documents (write,addonly optional)', 'write');
214 //Insert the 'notes' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
215 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'notes', 'Patient Notes (write,addonly optional)', 'write');
216 //Insert the 'high' object from the 'sensitivities' section into the Emergency Login group write ACL (added in 3.3.0)
217 updateAcl($emergency_write, 'Emergency Login', 'sensitivities', 'Sensitivities', 'high', 'High', 'write');
218 //Insert the 'normal' object from the 'sensitivities' section into the Emergency Login group write ACL (added in 3.3.0)
219 updateAcl($emergency_write, 'Emergency Login', 'sensitivities', 'Sensitivities', 'normal', 'Normal', 'write');
221 //Function will return an array that contains the ACL ID number.
222 //It will also check to ensure the ACL exist and is not duplicated.
223 // $title = Title(string) of group.
224 // $return_value = What the acl returns (string), usually 'write' or 'addonly'
225 function getAclIdNumber($title, $return_value) {
226 global $gacl;
227 $temp_acl_id_array = $gacl->search_acl(FALSE, FALSE, FALSE, FALSE, $title, FALSE, FALSE, FALSE, $return_value);
228 switch (count($temp_acl_id_array)) {
229 case 0:
230 echo "<B>ERROR</B>, '$title' group '$return_value' ACL does not exist.</BR>";
231 break;
232 case 1:
233 echo "'$title' group '$return_value' ACL is present.</BR>";
234 break;
235 default:
236 echo "<B>ERROR</B>, Multiple '$title' group '$return_value' ACLs are present.</BR>";
237 break;
239 return $temp_acl_id_array;
243 //Function will add an ACL (if doesn't already exist).
244 //It will also place the acl in the group, or will CREATE a new group.
245 //It will return the ID number of the acl (created or old)
246 // $title = Title(string) of group.
247 // $name = name of acl (string)
248 // $return_value = What the acl returns (string), usually 'write' or 'addonly'
249 // $note = description of acl (array)
250 function addNewACL($title, $name, $return_value, $note) {
251 global $gacl;
252 $temp_acl_id_array = $gacl->search_acl(FALSE, FALSE, FALSE, FALSE, $title, FALSE, FALSE, FALSE, $return_value);
253 switch (count($temp_acl_id_array)) {
254 case 0:
255 $group_id = $gacl->get_group_id($name, $title, 'ARO');
256 if ($group_id) {
257 //group already exist, so just create acl
258 $temp_acl_id = $gacl->add_acl(array("placeholder"=>array("filler")), NULL, array($group_id), NULL, NULL, 1, 1, $return_value, $note);
259 if ($temp_acl_id) {
260 echo "The '$title' group already exist.</BR>";
261 echo "The '$title' group '$return_value' ACL has been successfully added.</BR>";
262 $temp_acl_id_array = array($temp_acl_id);
264 else {
265 echo "The '$title' group already exist.</BR>";
266 echo "<B>ERROR</B>, Unable to create the '$title' group '$return_value' ACL.</BR>";
269 else {
270 //create group, then create acl
271 $parent_id = $gacl->get_root_group_id();
272 $aro_id = $gacl->add_group($name, $title, $parent_id, 'ARO');
273 $temp_acl_id = $gacl->add_acl(array("placeholder"=>array("filler")), NULL, array($aro_id), NULL, NULL, 1, 1, $return_value, $note);
274 if ($aro_id ) {
275 echo "The '$title' group has been successfully added.</BR>";
277 else {
278 echo "<B>ERROR</B>, Unable to create the '$title' group.</BR>";
280 if ($temp_acl_id) {
281 echo "The '$title' group '$return_value' ACL has been successfully added.</BR>";
282 $temp_acl_id_array = array($temp_acl_id);
284 else {
285 echo "<B>ERROR</B>, Unable to create the '$title' group '$return_value' ACL.</BR>";
288 break;
289 case 1:
290 echo "'$title' group '$return_value' ACL already exist.</BR>";
291 break;
293 default:
294 echo "<B>ERROR</B>, Multiple '$title' group '$return_value' ACLs are present.</BR>";
295 break;
297 return $temp_acl_id_array;
301 //Function to add an object section.
302 //It will check to ensure the object section doesn't already exist.
303 // $name = Identifier(string) of section
304 // $title = Title(string) of object
305 function addObjectSectionAcl($name, $title) {
306 global $gacl;
307 if ($gacl->get_object_section_section_id($title, $name, 'ACO')) {
308 echo "The '$title' object section already exist.</BR>";
310 else {
311 $tmp_boolean = $gacl->add_object_section($title , $name, 10, 0, 'ACO');
312 if ($tmp_boolean) {
313 echo "The '$title' object section has been successfully added.</BR>";
315 else {
316 echo "<B>ERROR</B>,unable to create the '$title' object section.</BR>";
319 return;
323 //Function to add an object.
324 //It will check to ensure the object doesn't already exist.
325 // $section_name = Identifier(string) of section
326 // $section_title = Title(string) of section
327 // $object_name = Identifier(string) of object
328 // $object_title = Title(string) of object
329 function addObjectAcl($section_name, $section_title, $object_name, $object_title) {
330 global $gacl;
331 if ($gacl->get_object_id($section_name, $object_name, 'ACO')) {
332 echo "The '$object_title' object in the '$section_title' section already exist.</BR>";
334 else {
335 $tmp_boolean = $gacl->add_object($section_name, $object_title, $object_name, 10, 0, 'ACO');
336 if ($tmp_boolean) {
337 echo "The '$object_title' object in the '$section_title' section has been successfully added.</BR>";
339 else {
340 echo "<B>ERROR</B>,unable to create the '$object_title' object in the '$section_title' section.</BR>";
343 return;
347 //Function to add an object and set the 'order' variable.
348 //It will check to ensure the object doesn't already exist.
349 // $section_name = Identifier(string) of section
350 // $section_title = Title(string) of section
351 // $object_name = Identifier(string) of object
352 // $object_title = Title(string) of object
353 // $order_number = number to determine order in list. used in sensitivities to order the choices
354 // in openemr
355 function addObjectAclWithOrder($section_name, $section_title, $object_name, $object_title, $order_number) {
356 global $gacl;
357 if ($gacl->get_object_id($section_name, $object_name, 'ACO')) {
358 echo "The '$object_title' object in the '$section_title' section already exist.</BR>";
360 else {
361 $tmp_boolean = $gacl->add_object($section_name, $object_title, $object_name, $order_number, 0, 'ACO');
362 if ($tmp_boolean) {
363 echo "The '$object_title' object in the '$section_title' section has been successfully added.</BR>";
365 else {
366 echo "<B>ERROR</B>,unable to create the '$object_title' object in the '$section_title' section.</BR>";
369 return;
373 //Function to edit an object and set the 'order' variable.
374 //It will check to ensure the object already exist, and hasn't been upgraded yet.
375 // $section_name = Identifier(string) of section
376 // $section_title = Title(string) of section
377 // $object_name = Identifier(string) of object
378 // $object_title = Title(string) of object
379 // $order_number = number to determine order in list. used in sensitivities to order the choices
380 // in openemr
381 function editObjectAcl($section_name, $section_title, $object_name, $object_title, $order_number) {
382 global $gacl;
383 $tmp_objectID = $gacl->get_object_id($section_name, $object_name, 'ACO');
384 if ($tmp_objectID) {
385 $tmp_object = $gacl->get_object_data($tmp_objectID, 'ACO');
386 if ($tmp_object[0][2] == $order_number &&
387 $tmp_object[0][0] == $section_name &&
388 $tmp_object[0][1] == $object_name &&
389 $tmp_object[0][3] == $object_title) {
390 echo "The '$object_title' object in the '$section_title' section has already been updated.</BR>";
392 else {
393 $tmp_boolean = $gacl->edit_object($tmp_objectID, $section_name, $object_title, $object_name, $order_number, 0, 'ACO');
394 if ($tmp_boolean) {
395 echo "The '$object_title' object in the '$section_title' section has been successfully updated.</BR>";
397 else {
398 echo "<B>ERROR</B>,unable to update the '$object_title' object in the '$section_title' section.</BR>";
402 else {
403 echo "<B>ERROR</B>, the '$object_title' object in the '$section_title' section does not exist.</BR>";
405 return;
409 //Update the ACL
410 //It will check to ensure the ACL hasn't already been updated.
411 // $array_acl_id_number = array containing hopefully one element, which is an integer, and is identifier of acl to be updated.
412 // $group_title = Title(string) of group.
413 // $object_section_name = Identifier(string) of section
414 // $object_section_title = Title(string) of section
415 // $object_name = Identifier(string) of object
416 // $object_title = Title(string) of object
417 // $acl_return_value = What the acl returns (string), usually 'write' or 'addonly'
418 function updateAcl($array_acl_id_number, $group_title, $section_name, $section_title, $object_name, $object_title, $return_value) {
419 global $gacl;
420 $tmp_array = $gacl->search_acl($section_name, $object_name, FALSE, FALSE, $group_title, FALSE, FALSE, FALSE, $return_value);
421 switch (count($tmp_array)) {
422 case 0:
423 $tmp_boolean = @$gacl->append_acl($array_acl_id_number[0], NULL, NULL, NULL, NULL, array($section_name=>array($object_name)));
424 if ($tmp_boolean){
425 echo "Successfully placed the '$object_title' object of the '$section_title' section into the '$group_title' group '$return_value' ACL.</BR>";
427 else {
428 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>";
430 break;
431 case 1:
432 echo "The '$object_title' object of the '$section_title' section is already found in the '$group_title' group '$return_value' ACL.</BR>";
433 break;
434 default:
435 echo "<B>ERROR</B>, Multiple '$group_title' group '$return_value' ACLs with the '$object_title' object of the '$section_title' section are present.</BR>";
436 break;
438 return;
441 //All done
442 echo "</BR><B>ALL DONE</B>";