Appointment Report Enhancements:
[openemr.git] / acl_upgrade.php
blob4c555066a46512cd0f11c4ae8d1b94a521154337
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');
80 //Add new Objects
81 echo "<BR/><B>Adding new objects</B><BR/>";
82 //Add 'Normal' sensitivity object, order variable is default 10 (added in 2.8.2)
83 addObjectAcl('sensitivities', 'Sensitivities', 'normal', 'Normal');
84 //Add 'High' sensitivity object, order variable is set to 20 (added in 2.8.2)
85 addObjectAclWithOrder('sensitivities', 'Sensitivities', 'high', 'High', 20);
86 //Add 'Pharmacy Dispensary' object (added in 2.8.4)
87 addObjectAcl('admin', 'Administration', 'drugs', 'Pharmacy Dispensary');
88 //Add 'ACL Administration' object (added in 2.8.4)
89 addObjectAcl('admin', 'Administration', 'acl', 'ACL Administration');
90 //Add 'Price Discounting' object (added in 2.8.4)
91 addObjectAcl('acct', 'Accounting', 'disc', 'Price Discounting');
92 //Add 'Default List (write,addonly optional)' object (added in 3.0.2)
93 addObjectAcl('lists', 'Lists', 'default', 'Default List (write,addonly optional)');
94 //Add 'State List (write,addonly optional)' object (added in 3.0.2)
95 addObjectAcl('lists', 'Lists', 'state', 'State List (write,addonly optional)');
96 //Add 'Country List (write,addonly optional)' object (added in 3.0.2)
97 addObjectAcl('lists', 'Lists', 'country', 'Country List (write,addonly optional)');
98 //Add 'Language List (write,addonly optional)' object (added in 3.0.2)
99 addObjectAcl('lists', 'Lists', 'language', 'Language List (write,addonly optional)');
100 //Add 'Ethnicity-Race List (write,addonly optional)' object (added in 3.0.2)
101 addObjectAcl('lists', 'Lists', 'ethrace', 'Ethnicity-Race List (write,addonly optional)');
102 //Add 'Placeholder (Maintains empty ACLs)' object (added in 3.0.2)
103 addObjectAcl('placeholder', 'Placeholder', 'filler', 'Placeholder (Maintains empty ACLs)');
104 //Add 'Sign Lab Results (write,addonly optional)' object (added in 3.3.0)
105 addObjectAcl('patients', 'Patients', 'sign', 'Sign Lab Results (write,addonly optional)');
107 //Update already existing Objects
108 echo "<BR/><B>Upgrading objects</B><BR/>";
109 //Ensure that 'High' sensitivity object order variable is set to 20
110 editObjectAcl('sensitivities', 'Sensitivities', 'high', 'High', 20);
112 //Add new ACLs here (will return the ACL ID of newly created or already existant ACL)
113 // (will also place in the appropriate group and CREATE a new group if needed)
114 echo "<BR/><B>Adding ACLs(Access Control Lists) and groups</B><BR/>";
115 //Add 'Physicians' ACL with 'addonly' and collect the ID number (added in 3.0.2)
116 $doc_addonly = addNewACL('Physicians', 'doc', 'addonly', 'Things that physicians can read and enter but not modify');
117 //Add 'Front Office' ACL with 'addonly' and collect the ID number (added in 3.0.2)
118 $front_addonly = addNewACL('Front Office', 'front', 'addonly', 'Things that front office can read and enter but not modify');
119 //Add 'Accounting' ACL with 'addonly' and collect the ID number (added in 3.0.2)
120 $back_addonly = addNewACL('Accounting', 'back', 'addonly', 'Things that back office can read and enter but not modify');
121 //Add 'Emergency Login' ACL with 'write' and collect the ID number (added in 3.3.0)
122 $emergency_write = addNewACL('Emergency Login', 'breakglass', 'write', 'Things that can use for emergency login, can read and modify');
124 //Update the ACLs
125 echo "<BR/><B>Updating the ACLs(Access Control Lists)</B><BR/>";
126 //Insert the 'super' object from the 'admin' section into the Administrators group write ACL (added in 2.8.2)
127 updateAcl($admin_write, 'Administrators', 'admin', 'Administration', 'super', 'Superuser', 'write');
128 //Insert the 'high' object from the 'sensitivities' section into the Administrators group write ACL (added in 2.8.2)
129 updateAcl($admin_write, 'Administrators', 'sensitivities', 'Sensitivities', 'high', 'High', 'write');
130 //Insert the 'normal' object from the 'sensitivities' section into the Administrators group write ACL (added in 2.8.2)
131 updateAcl($admin_write, 'Administrators', 'sensitivities', 'Sensitivities', 'normal', 'Normal', 'write');
132 //Insert the 'high' object from the 'sensitivities' section into the Physicians group write ACL (added in 2.8.2)
133 updateAcl($doc_write, 'Physicians', 'sensitivities', 'Sensitivities', 'high', 'High', 'write');
134 //Insert the 'normal' object from the 'sensitivities' section into the Physicians group write ACL (added in 2.8.2)
135 updateAcl($doc_write, 'Physicians', 'sensitivities', 'Sensitivities', 'normal', 'Normal', 'write');
136 //Insert the 'normal' object from the 'sensitivities' section into the Clinicians group addonly ACL (added in 2.8.2)
137 updateAcl($clin_addonly, 'Clinicians', 'sensitivities', 'Sensitivities', 'normal', 'Normal', 'addonly');
138 //Insert the 'drugs' object from the 'admin' section into the Administrators group write ACL (added in 2.8.4)
139 updateAcl($admin_write, 'Administrators', 'admin', 'Administration', 'drugs', 'Pharmacy Dispensary', 'write');
140 //Insert the 'drugs' object from the 'admin' section into the Physicians group write ACL (added in 2.8.4)
141 updateAcl($doc_write, 'Physicians', 'admin', 'Administration', 'drugs', 'Pharmacy Dispensary', 'write');
142 //Insert the 'drugs' object from the 'admin' section into the Clinicians group write ACL (added in 2.8.4)
143 updateAcl($clin_write, 'Clinicians', 'admin', 'Administration', 'drugs', 'Pharmacy Dispensary', 'write');
144 //Insert the 'acl' object from the 'admin' section into the Administrators group write ACL (added in 2.8.4)
145 updateAcl($admin_write, 'Administrators', 'admin', 'Administration', 'acl', 'ACL Administration', 'write');
146 //Insert the 'disc' object from the 'acct' section into the Administrators group write ACL (added in 2.8.4)
147 updateAcl($admin_write, 'Administrators', 'acct', 'Accounting', 'disc', 'Price Discounting', 'write');
148 //Insert the 'disc' object from the 'acct' section into the Accounting group write ACL (added in 2.8.4)
149 updateAcl($back_write, 'Accounting', 'acct', 'Accounting', 'disc', 'Price Discounting', 'write');
150 //Insert the 'disc' object from the 'acct' section into the Physicians group write ACL (added in 2.8.4)
151 updateAcl($doc_write, 'Physicians', 'acct', 'Accounting', 'disc', 'Price Discounting', 'write');
152 //Insert the 'default' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
153 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'default', 'Default List (write,addonly optional)', 'write');
154 //Insert the 'state' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
155 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'state', 'State List (write,addonly optional)', 'write');
156 //Insert the 'country' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
157 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'country', 'Country List (write,addonly optional)', 'write');
158 //Insert the 'language' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
159 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'language', 'Language List (write,addonly optional)', 'write');
160 //Insert the 'race' object from the 'lists' section into the Administrators group write ACL (added in 3.0.2)
161 updateAcl($admin_write, 'Administrators', 'lists', 'Lists', 'ethrace', 'Ethnicity-Race List (write,addonly optional)', 'write');
162 //Update ACLs for Emergency Login
163 //Insert the 'disc' object from the 'acct' section into the Emergency Login group write ACL (added in 3.3.0)
164 updateAcl($emergency_write, 'Emergency Login', 'acct', 'Accounting', 'disc', 'Price Discounting', 'write');
165 //Insert the 'bill' object from the 'acct' section into the Emergency Login group write ACL (added in 3.3.0)
166 updateAcl($emergency_write, 'Emergency Login', 'acct', 'Accounting', 'bill', 'Billing (write optional)', 'write');
167 //Insert the 'eob' object from the 'acct' section into the Emergency Login group write ACL (added in 3.3.0)
168 updateAcl($emergency_write, 'Emergency Login', 'acct', 'Accounting', 'eob', 'EOB Data Entry', 'write');
169 //Insert the 'rep' object from the 'acct' section into the Emergency Login group write ACL (added in 3.3.0)
170 updateAcl($emergency_write, 'Emergency Login', 'acct', 'Accounting', 'rep', 'Financial Reporting - my encounters', 'write');
171 //Insert the 'rep_a' 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', 'rep_a', 'Financial Reporting - anything', 'write');
173 //Insert the 'calendar' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
174 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'calendar', 'Calendar Settings', 'write');
175 //Insert the 'database' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
176 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'database', 'Database Reporting', 'write');
177 //Insert the 'forms' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
178 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'forms', 'Forms Administration', 'write');
179 //Insert the 'practice' object from the 'admin' section into the Emergency Login group write ACL (added in 3.3.0)
180 updateAcl($emergency_write, 'Emergency Login', 'admin', 'Administration', 'practice', 'Practice Settings', 'write');
181 //Insert the 'superbill' 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', 'superbill', 'Superbill Codes Administration', 'write');
183 //Insert the 'users' 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', 'users', 'Users/Groups/Logs Administration', 'write');
185 //Insert the 'batchcom' 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', 'batchcom', 'Batch Communication Tool', 'write');
187 //Insert the 'language' 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', 'language', 'Language Interface Tool', 'write');
189 //Insert the 'super' 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', 'super', 'Superuser', 'write');
191 //Insert the 'drugs' 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', 'drugs', 'Pharmacy Dispensary', 'write');
193 //Insert the 'acl' 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', 'acl', 'ACL Administration', 'write');
195 //Insert the 'auth_a' object from the 'encounters' section into the Emergency Login group write ACL (added in 3.3.0)
196 updateAcl($emergency_write, 'Emergency Login', 'encounters', 'Encounters', 'auth_a', 'Authorize - any encounters', 'write');
197 //Insert the 'coding_a' object from the 'encounters' section into the Emergency Login group write ACL (added in 3.3.0)
198 updateAcl($emergency_write, 'Emergency Login', 'encounters', 'Encounters', 'coding_a', 'Coding - any encounters (write,wsome optional)', 'write');
199 //Insert the 'notes_a' object from the 'encounters' section into the Emergency Login group write ACL (added in 3.3.0)
200 updateAcl($emergency_write, 'Emergency Login', 'encounters', 'Encounters', 'notes_a', 'Notes - any encounters (write,addonly optional)', 'write');
201 //Insert the 'date_a' object from the 'encounters' section into the Emergency Login group write ACL (added in 3.3.0)
202 updateAcl($emergency_write, 'Emergency Login', 'encounters', 'Encounters', 'date_a', 'Fix encounter dates - any encounters', 'write');
203 //Insert the 'default' object from the 'lists' section into the Emergency Login group write ACL (added in 3.3.0)
204 updateAcl($emergency_write, 'Emergency Login', 'lists', 'Lists', 'default', 'Default List (write,addonly optional)', 'write');
205 //Insert the 'state' object from the 'lists' section into the Emergency Login group write ACL (added in 3.3.0)
206 updateAcl($emergency_write, 'Emergency Login', 'lists', 'Lists', 'state', 'State List (write,addonly optional)', 'write');
207 //Insert the 'country' object from the 'lists' section into the Emergency Login group write ACL (added in 3.3.0)
208 updateAcl($emergency_write, 'Emergency Login', 'lists', 'Lists', 'country', 'Country List (write,addonly optional)', 'write');
209 //Insert the 'language' object from the 'lists' section into the Emergency Login group write ACL (added in 3.3.0)
210 updateAcl($emergency_write, 'Emergency Login', 'lists', 'Lists', 'language', 'Language List (write,addonly optional)', 'write');
211 //Insert the 'ethrace' 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', 'ethrace', 'Ethnicity-Race List (write,addonly optional)', 'write');
213 //Insert the 'appt' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
214 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'appt', 'Appointments (write optional)', 'write');
215 //Insert the 'demo' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
216 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'demo', 'Demographics (write,addonly optional)', 'write');
217 //Insert the 'med' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
218 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'med', 'Medical/History (write,addonly optional)', 'write');
219 //Insert the 'trans' object from the 'patients' section into the Emergency Login group write ACL (added in 3.3.0)
220 updateAcl($emergency_write, 'Emergency Login', 'patients', 'Patients', 'trans', 'Transactions (write optional)', 'write');
221 //Insert the 'docs' 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', 'docs', 'Documents (write,addonly optional)', 'write');
223 //Insert the 'notes' 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', 'notes', 'Patient Notes (write,addonly optional)', 'write');
225 //Insert the 'high' object from the 'sensitivities' section into the Emergency Login group write ACL (added in 3.3.0)
226 updateAcl($emergency_write, 'Emergency Login', 'sensitivities', 'Sensitivities', 'high', 'High', 'write');
227 //Insert the 'normal' object from the 'sensitivities' section into the Emergency Login group write ACL (added in 3.3.0)
228 updateAcl($emergency_write, 'Emergency Login', 'sensitivities', 'Sensitivities', 'normal', 'Normal', 'write');
229 //Insert the 'sign' object from the 'patients' section into the Physicians group write ACL (added in 3.3.0)
230 updateAcl($doc_write, 'Physicians', 'patients', 'Patients', 'sign', 'Sign Lab Results (write,addonly optional)', 'write');
233 //Function will return an array that contains the ACL ID number.
234 //It will also check to ensure the ACL exist and is not duplicated.
235 // $title = Title(string) of group.
236 // $return_value = What the acl returns (string), usually 'write' or 'addonly'
237 function getAclIdNumber($title, $return_value) {
238 global $gacl;
239 $temp_acl_id_array = $gacl->search_acl(FALSE, FALSE, FALSE, FALSE, $title, FALSE, FALSE, FALSE, $return_value);
240 switch (count($temp_acl_id_array)) {
241 case 0:
242 echo "<B>ERROR</B>, '$title' group '$return_value' ACL does not exist.</BR>";
243 break;
244 case 1:
245 echo "'$title' group '$return_value' ACL is present.</BR>";
246 break;
247 default:
248 echo "<B>ERROR</B>, Multiple '$title' group '$return_value' ACLs are present.</BR>";
249 break;
251 return $temp_acl_id_array;
255 //Function will add an ACL (if doesn't already exist).
256 //It will also place the acl in the group, or will CREATE a new group.
257 //It will return the ID number of the acl (created or old)
258 // $title = Title(string) of group.
259 // $name = name of acl (string)
260 // $return_value = What the acl returns (string), usually 'write' or 'addonly'
261 // $note = description of acl (array)
262 function addNewACL($title, $name, $return_value, $note) {
263 global $gacl;
264 $temp_acl_id_array = $gacl->search_acl(FALSE, FALSE, FALSE, FALSE, $title, FALSE, FALSE, FALSE, $return_value);
265 switch (count($temp_acl_id_array)) {
266 case 0:
267 $group_id = $gacl->get_group_id($name, $title, 'ARO');
268 if ($group_id) {
269 //group already exist, so just create acl
270 $temp_acl_id = $gacl->add_acl(array("placeholder"=>array("filler")), NULL, array($group_id), NULL, NULL, 1, 1, $return_value, $note);
271 if ($temp_acl_id) {
272 echo "The '$title' group already exist.</BR>";
273 echo "The '$title' group '$return_value' ACL has been successfully added.</BR>";
274 $temp_acl_id_array = array($temp_acl_id);
276 else {
277 echo "The '$title' group already exist.</BR>";
278 echo "<B>ERROR</B>, Unable to create the '$title' group '$return_value' ACL.</BR>";
281 else {
282 //create group, then create acl
283 $parent_id = $gacl->get_root_group_id();
284 $aro_id = $gacl->add_group($name, $title, $parent_id, 'ARO');
285 $temp_acl_id = $gacl->add_acl(array("placeholder"=>array("filler")), NULL, array($aro_id), NULL, NULL, 1, 1, $return_value, $note);
286 if ($aro_id ) {
287 echo "The '$title' group has been successfully added.</BR>";
289 else {
290 echo "<B>ERROR</B>, Unable to create the '$title' group.</BR>";
292 if ($temp_acl_id) {
293 echo "The '$title' group '$return_value' ACL has been successfully added.</BR>";
294 $temp_acl_id_array = array($temp_acl_id);
296 else {
297 echo "<B>ERROR</B>, Unable to create the '$title' group '$return_value' ACL.</BR>";
300 break;
301 case 1:
302 echo "'$title' group '$return_value' ACL already exist.</BR>";
303 break;
305 default:
306 echo "<B>ERROR</B>, Multiple '$title' group '$return_value' ACLs are present.</BR>";
307 break;
309 return $temp_acl_id_array;
313 //Function to add an object section.
314 //It will check to ensure the object section doesn't already exist.
315 // $name = Identifier(string) of section
316 // $title = Title(string) of object
317 function addObjectSectionAcl($name, $title) {
318 global $gacl;
319 if ($gacl->get_object_section_section_id($title, $name, 'ACO')) {
320 echo "The '$title' object section already exist.</BR>";
322 else {
323 $tmp_boolean = $gacl->add_object_section($title , $name, 10, 0, 'ACO');
324 if ($tmp_boolean) {
325 echo "The '$title' object section has been successfully added.</BR>";
327 else {
328 echo "<B>ERROR</B>,unable to create the '$title' object section.</BR>";
331 return;
335 //Function to add an object.
336 //It will check to ensure the object doesn't already exist.
337 // $section_name = Identifier(string) of section
338 // $section_title = Title(string) of section
339 // $object_name = Identifier(string) of object
340 // $object_title = Title(string) of object
341 function addObjectAcl($section_name, $section_title, $object_name, $object_title) {
342 global $gacl;
343 if ($gacl->get_object_id($section_name, $object_name, 'ACO')) {
344 echo "The '$object_title' object in the '$section_title' section already exist.</BR>";
346 else {
347 $tmp_boolean = $gacl->add_object($section_name, $object_title, $object_name, 10, 0, 'ACO');
348 if ($tmp_boolean) {
349 echo "The '$object_title' object in the '$section_title' section has been successfully added.</BR>";
351 else {
352 echo "<B>ERROR</B>,unable to create the '$object_title' object in the '$section_title' section.</BR>";
355 return;
359 //Function to add an object and set the 'order' variable.
360 //It will check to ensure the object doesn't already exist.
361 // $section_name = Identifier(string) of section
362 // $section_title = Title(string) of section
363 // $object_name = Identifier(string) of object
364 // $object_title = Title(string) of object
365 // $order_number = number to determine order in list. used in sensitivities to order the choices
366 // in openemr
367 function addObjectAclWithOrder($section_name, $section_title, $object_name, $object_title, $order_number) {
368 global $gacl;
369 if ($gacl->get_object_id($section_name, $object_name, 'ACO')) {
370 echo "The '$object_title' object in the '$section_title' section already exist.</BR>";
372 else {
373 $tmp_boolean = $gacl->add_object($section_name, $object_title, $object_name, $order_number, 0, 'ACO');
374 if ($tmp_boolean) {
375 echo "The '$object_title' object in the '$section_title' section has been successfully added.</BR>";
377 else {
378 echo "<B>ERROR</B>,unable to create the '$object_title' object in the '$section_title' section.</BR>";
381 return;
385 //Function to edit an object and set the 'order' variable.
386 //It will check to ensure the object already exist, and hasn't been upgraded yet.
387 // $section_name = Identifier(string) of section
388 // $section_title = Title(string) of section
389 // $object_name = Identifier(string) of object
390 // $object_title = Title(string) of object
391 // $order_number = number to determine order in list. used in sensitivities to order the choices
392 // in openemr
393 function editObjectAcl($section_name, $section_title, $object_name, $object_title, $order_number) {
394 global $gacl;
395 $tmp_objectID = $gacl->get_object_id($section_name, $object_name, 'ACO');
396 if ($tmp_objectID) {
397 $tmp_object = $gacl->get_object_data($tmp_objectID, 'ACO');
398 if ($tmp_object[0][2] == $order_number &&
399 $tmp_object[0][0] == $section_name &&
400 $tmp_object[0][1] == $object_name &&
401 $tmp_object[0][3] == $object_title) {
402 echo "The '$object_title' object in the '$section_title' section has already been updated.</BR>";
404 else {
405 $tmp_boolean = $gacl->edit_object($tmp_objectID, $section_name, $object_title, $object_name, $order_number, 0, 'ACO');
406 if ($tmp_boolean) {
407 echo "The '$object_title' object in the '$section_title' section has been successfully updated.</BR>";
409 else {
410 echo "<B>ERROR</B>,unable to update the '$object_title' object in the '$section_title' section.</BR>";
414 else {
415 echo "<B>ERROR</B>, the '$object_title' object in the '$section_title' section does not exist.</BR>";
417 return;
421 //Update the ACL
422 //It will check to ensure the ACL hasn't already been updated.
423 // $array_acl_id_number = array containing hopefully one element, which is an integer, and is identifier of acl to be updated.
424 // $group_title = Title(string) of group.
425 // $object_section_name = Identifier(string) of section
426 // $object_section_title = Title(string) of section
427 // $object_name = Identifier(string) of object
428 // $object_title = Title(string) of object
429 // $acl_return_value = What the acl returns (string), usually 'write' or 'addonly'
430 function updateAcl($array_acl_id_number, $group_title, $section_name, $section_title, $object_name, $object_title, $return_value) {
431 global $gacl;
432 $tmp_array = $gacl->search_acl($section_name, $object_name, FALSE, FALSE, $group_title, FALSE, FALSE, FALSE, $return_value);
433 switch (count($tmp_array)) {
434 case 0:
435 $tmp_boolean = @$gacl->append_acl($array_acl_id_number[0], NULL, NULL, NULL, NULL, array($section_name=>array($object_name)));
436 if ($tmp_boolean){
437 echo "Successfully placed the '$object_title' object of the '$section_title' section into the '$group_title' group '$return_value' ACL.</BR>";
439 else {
440 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>";
442 break;
443 case 1:
444 echo "The '$object_title' object of the '$section_title' section is already found in the '$group_title' group '$return_value' ACL.</BR>";
445 break;
446 default:
447 echo "<B>ERROR</B>, Multiple '$group_title' group '$return_value' ACLs with the '$object_title' object of the '$section_title' section are present.</BR>";
448 break;
450 return;
453 //All done
454 echo "</BR><B>ALL DONE</B>";