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['object_type'] != '') {
20 $object_type = $_GET['object_type'];
22 $object_type = $_POST['object_type'];
25 switch(strtolower(trim($object_type))) {
28 $object_table = $gacl_api->_db_table_prefix
. 'aco';
29 $object_sections_table = $gacl_api->_db_table_prefix
. 'aco_sections';
33 $object_table = $gacl_api->_db_table_prefix
. 'aro';
34 $object_sections_table = $gacl_api->_db_table_prefix
. 'aro_sections';
38 $object_table = $gacl_api->_db_table_prefix
. 'axo';
39 $object_sections_table = $gacl_api->_db_table_prefix
. 'axo_sections';
42 echo "ERROR: Must select an object type<br>\n";
47 switch ($_POST['action']) {
50 if (count($_POST['delete_object']) > 0) {
51 foreach($_POST['delete_object'] as $id) {
52 $gacl_api->del_object($id, $object_type, TRUE);
57 $gacl_api->return_page($_POST['return_page']);
61 $gacl_api->debug_text("Submit!!");
64 while (list(,$row) = @each
($_POST['objects'])) {
65 list($id, $value, $order, $name) = $row;
66 $gacl_api->edit_object($id, $_POST['section_value'], $name, $value, $order, 0, $object_type);
69 unset($section_value);
75 while (list(,$row) = @each
($_POST['new_objects'])) {
76 list($value, $order, $name) = $row;
78 if (!empty($value) AND !empty($name)) {
79 $object_id= $gacl_api->add_object($_POST['section_value'], $name, $value, $order, 0, $object_type);
82 $gacl_api->debug_text("return_page: ". $_POST['return_page']);
83 $gacl_api->return_page($_POST['return_page']);
88 $query = "select name from $object_sections_table where value = '". $_GET['section_value'] ."'";
89 $section_name = $db->GetOne($query);
98 where section_value='". $_GET['section_value'] ."'
99 order by order_value";
100 $rs = $db->pageexecute($query, $gacl_api->_items_per_page
, $_GET['page']);
101 $rows = $rs->GetRows();
103 while (list(,$row) = @each
($rows)) {
104 list($id, $section_value, $value, $order_value, $name) = $row;
108 'section_value' => $section_value,
110 'order' => $order_value,
115 for($i=0; $i < 5; $i++
) {
116 $new_objects[] = array(
118 'section_value' => NULL,
125 $smarty->assign('objects', $objects);
126 $smarty->assign('new_objects', $new_objects);
128 $smarty->assign("paging_data", $gacl_api->get_paging_data($rs));
133 $smarty->assign('section_value', stripslashes($_GET['section_value']));
134 $smarty->assign('section_name', $section_name);
135 $smarty->assign('object_type', $object_type);
136 $smarty->assign('return_page', $_SERVER['REQUEST_URI']);
138 $smarty->assign('current','edit_'. $object_type .'s');
139 $smarty->assign('page_title', 'Edit '. strtoupper($object_type) .' Objects');
141 $smarty->assign("phpgacl_version", $gacl_api->get_version() );
142 $smarty->assign("phpgacl_schema_version", $gacl_api->get_schema_version() );
144 $smarty->display('phpgacl/edit_objects.tpl');