Fix to using most recent development translation set on development demo.
[openemr.git] / gacl / admin / edit_object_sections.php
blob80fda1570d35e5ba4e32fb79e0873077ed77f7e8
1 <?php
2 //First make sure user has access
3 include_once("../../interface/globals.php");
4 include_once("$srcdir/acl.inc");
5 //ensure user has proper access
6 if (!acl_check('admin', 'acl')) {
7 echo xl('ACL Administration Not Authorized');
8 exit;
10 //ensure php is installed
11 if (!isset($phpgacl_location)) {
12 echo xl('php-GACL access controls are turned off');
13 exit;
16 require_once("gacl_admin.inc.php");
18 //GET takes precedence.
19 if ( isset($_GET['object_type']) AND $_GET['object_type'] != '' ) {
20 $object_type = $_GET['object_type'];
21 } else {
22 $object_type = $_POST['object_type'];
25 switch(strtolower(trim($object_type))) {
26 case 'aco':
27 $object_type = 'aco';
28 $object_sections_table = $gacl_api->_db_table_prefix . 'aco_sections';
29 break;
30 case 'aro':
31 $object_type = 'aro';
32 $object_sections_table = $gacl_api->_db_table_prefix . 'aro_sections';
33 break;
34 case 'axo':
35 $object_type = 'axo';
36 $object_sections_table = $gacl_api->_db_table_prefix . 'axo_sections';
37 break;
38 case 'acl':
39 $object_type = 'acl';
40 $object_sections_table = $gacl_api->_db_table_prefix . 'acl_sections';
41 break;
42 default:
43 echo "ERROR: Must select an object type<br>\n";
44 exit();
45 break;
48 switch ($_POST['action']) {
49 case 'Delete':
51 if (count($_POST['delete_sections']) > 0) {
52 foreach($_POST['delete_sections'] as $id) {
53 $gacl_api->del_object_section($id, $object_type, TRUE);
57 //Return page.
58 $gacl_api->return_page($_POST['return_page']);
60 break;
61 case 'Submit':
62 $gacl_api->debug_text("Submit!!");
64 //Update sections
65 while (list(,$row) = @each($_POST['sections'])) {
66 list($id, $value, $order, $name) = $row;
67 $gacl_api->edit_object_section($id, $name, $value, $order,0,$object_type );
69 unset($id);
70 unset($value);
71 unset($order);
72 unset($name);
74 //Insert new sections
75 while (list(,$row) = @each($_POST['new_sections'])) {
76 list($value, $order, $name) = $row;
78 if (!empty($value) AND !empty($order) AND !empty($name)) {
80 $object_section_id = $gacl_api->add_object_section($name, $value, $order, 0, $object_type);
81 $gacl_api->debug_text("Section ID: $object_section_id");
84 $gacl_api->debug_text("return_page: ". $_POST['return_page']);
85 $gacl_api->return_page($_POST['return_page']);
87 break;
88 default:
89 $query = "select id,value,order_value,name from $object_sections_table order by order_value";
91 $rs = $db->pageexecute($query, $gacl_api->_items_per_page, $_GET['page']);
92 $rows = $rs->GetRows();
94 $sections = array();
96 while (list(,$row) = @each($rows)) {
97 list($id, $value, $order_value, $name) = $row;
99 $sections[] = array(
100 'id' => $id,
101 'value' => $value,
102 'order' => $order_value,
103 'name' => $name
107 $new_sections = array();
109 for($i=0; $i < 5; $i++) {
110 $new_sections[] = array(
111 'id' => $i,
112 'value' => NULL,
113 'order' => NULL,
114 'name' => NULL
118 $smarty->assign('sections', $sections);
119 $smarty->assign('new_sections', $new_sections);
121 $smarty->assign("paging_data", $gacl_api->get_paging_data($rs));
123 break;
126 $smarty->assign('object_type', $object_type);
127 $smarty->assign('return_page', $_SERVER['REQUEST_URI']);
129 $smarty->assign('current','edit_'. $object_type .'_sections');
130 $smarty->assign('page_title', 'Edit '. strtoupper($object_type) .' Sections');
132 $smarty->assign("phpgacl_version", $gacl_api->get_version() );
133 $smarty->assign("phpgacl_schema_version", $gacl_api->get_schema_version() );
135 $smarty->display('phpgacl/edit_object_sections.tpl');