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