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');
10 //ensure php is installed
11 if (!isset($phpgacl_location)) {
12 echo xl('php-GACL access controls are turned off');
16 require_once('gacl_admin.inc.php');
18 // GET takes precedence.
19 if ($_GET['group_type'] == '') {
20 $group_type = $_POST['group_type'];
22 $group_type = $_GET['group_type'];
25 if ($_GET['return_page'] == '') {
26 $return_page = $_POST['return_page'];
28 $return_page = $_GET['return_page'];
31 switch(strtolower(trim($group_type))) {
34 $group_table = $gacl_api->_db_table_prefix
. 'axo_groups';
38 $group_table = $gacl_api->_db_table_prefix
. 'aro_groups';
43 switch ($_POST['action']) {
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) {
58 if (count($retry) > 0) {
59 foreach($retry as $group_id) {
60 $gacl_api->del_group($group_id, TRUE, $group_type);
67 $gacl_api->return_page($return_page);
70 $gacl_api->debug_text('Submit');
72 if (empty($_POST['parent_id'])) {
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";
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);
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);
98 //Grab specific group data
99 if (!empty($_GET['group_id'])) {
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);
108 $parent_id = $_GET['parent_id'];
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)));
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');