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 ( isset($_GET['object_type']) AND $_GET['object_type'] != '' ) {
20 $object_type = $_GET['object_type'];
22 $object_type = $_POST['object_type'];
25 switch(strtolower(trim($object_type))) {
28 $object_sections_table = $gacl_api->_db_table_prefix
. 'aco_sections';
32 $object_sections_table = $gacl_api->_db_table_prefix
. 'aro_sections';
36 $object_sections_table = $gacl_api->_db_table_prefix
. 'axo_sections';
40 $object_sections_table = $gacl_api->_db_table_prefix
. 'acl_sections';
43 echo "ERROR: Must select an object type<br>\n";
48 switch ($_POST['action']) {
51 if (count($_POST['delete_sections']) > 0) {
52 foreach($_POST['delete_sections'] as $id) {
53 $gacl_api->del_object_section($id, $object_type, TRUE);
58 $gacl_api->return_page($_POST['return_page']);
62 $gacl_api->debug_text("Submit!!");
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 );
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']);
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();
96 while (list(,$row) = @each
($rows)) {
97 list($id, $value, $order_value, $name) = $row;
102 'order' => $order_value,
107 $new_sections = array();
109 for($i=0; $i < 5; $i++
) {
110 $new_sections[] = array(
118 $smarty->assign('sections', $sections);
119 $smarty->assign('new_sections', $new_sections);
121 $smarty->assign("paging_data", $gacl_api->get_paging_data($rs));
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');