Ubuntu Package modification - Added configuration of max_input_vars setting
[openemr.git] / gacl / admin / edit_group.php
blobf57240eca9f9859927ebacb1c520442ae5cdb777
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 ($_GET['group_type'] == '') {
20 $group_type = $_POST['group_type'];
21 } else {
22 $group_type = $_GET['group_type'];
25 if ($_GET['return_page'] == '') {
26 $return_page = $_POST['return_page'];
27 } else {
28 $return_page = $_GET['return_page'];
31 switch(strtolower(trim($group_type))) {
32 case 'axo':
33 $group_type = 'axo';
34 $group_table = $gacl_api->_db_table_prefix . 'axo_groups';
35 break;
36 default:
37 $group_type = 'aro';
38 $group_table = $gacl_api->_db_table_prefix . 'aro_groups';
39 break;
43 switch ($_POST['action']) {
44 case 'Delete':
45 $gacl_api->debug_text('Delete');
47 if (count($_POST['delete_group']) > 0) {
48 //Always reparent children when deleting a group.
49 foreach ($_POST['delete_group'] as $group_id) {
50 $gacl_api->debug_text('Deleting group_id: '. $group_id);
52 $result = $gacl_api->del_group($group_id, TRUE, $group_type);
53 if ($result == FALSE) {
54 $retry[] = $group_id;
58 if (count($retry) > 0) {
59 foreach($retry as $group_id) {
60 $gacl_api->del_group($group_id, TRUE, $group_type);
66 //Return page.
67 $gacl_api->return_page($return_page);
68 break;
69 case 'Submit':
70 $gacl_api->debug_text('Submit');
72 if (empty($_POST['parent_id'])) {
73 $parent_id = 0;
74 } else {
75 $parent_id = $_POST['parent_id'];
78 //Make sure we're not reparenting to ourself.
79 if (!empty($_POST['group_id']) AND $parent_id == $_POST['group_id']) {
80 echo "Sorry, can't reparent to self!<br />\n";
81 exit;
84 //No parent, assume a "root" group, generate a new parent id.
85 if (empty($_POST['group_id'])) {
86 $gacl_api->debug_text('Insert');
88 $insert_id = $gacl_api->add_group($_POST['value'], $_POST['name'], $parent_id, $group_type);
89 } else {
90 $gacl_api->debug_text('Update');
92 $gacl_api->edit_group($_POST['group_id'], $_POST['value'], $_POST['name'], $parent_id, $group_type);
95 $gacl_api->return_page($return_page);
96 break;
97 default:
98 //Grab specific group data
99 if (!empty($_GET['group_id'])) {
100 $query = '
101 SELECT id,parent_id,value,name
102 FROM '. $group_table .'
103 WHERE id='. (int)$_GET['group_id'];
105 list($id, $parent_id, $value, $name) = $db->GetRow($query);
106 //showarray($row);
107 } else {
108 $parent_id = $_GET['parent_id'];
109 $value = '';
110 $name = '';
113 $smarty->assign('id', $id);
114 $smarty->assign('parent_id', $parent_id);
115 $smarty->assign('value', $value);
116 $smarty->assign('name', $name);
118 $smarty->assign('options_groups', $gacl_api->format_groups($gacl_api->sort_groups($group_type)));
119 break;
122 $smarty->assign('group_type', $group_type);
123 $smarty->assign('return_page', $return_page);
125 $smarty->assign('current','edit_'. $group_type .'_group');
126 $smarty->assign('page_title', 'Edit '. strtoupper($group_type) .' Group');
128 $smarty->assign('phpgacl_version', $gacl_api->get_version());
129 $smarty->assign('phpgacl_schema_version', $gacl_api->get_schema_version());
131 $smarty->display('phpgacl/edit_group.tpl');