/** * Recursively get MAPs */ function get_recursive_maps(&$request, &$all_maps, $parents, &$maps, $start_level) { while ($maps->next()) { $map = $maps->current(); if ($map['row_level'] - $start_level > 0) { $map['level'] = str_repeat('<img src="Images/' . $request['template']->getVar('IMG_DIR') . '/Icons/threaded_bit.gif" alt="" border="0" />', $map['row_level'] - $start_level); } $all_maps[] = $map; $is_expanded = !$parents && !is_array($parents) ? TRUE : in_array($map['id'], $parents); if ($is_expanded && $map['num_children'] > 0) { // reset it if needed $map['expanded'] = 1; $all_maps[count($all_maps) - 1] = $map; $n_maps = $request['dba']->executeQuery("SELECT * FROM " . K4MAPS . " WHERE parent_id = " . intval($map['id']) . " ORDER BY name ASC"); get_recursive_maps($request, $all_maps, $parents, $n_maps, $start_level); } } }
function execute(&$request) { if ($request['user']->isMember() && $request['user']->get('perms') >= SUPERADMIN) { /* Get the parent id's */ $parents = array(); foreach ($_COOKIE as $key => $val) { if (strpos($key, 'mapsgui') !== FALSE) { $parents[] = intval($_COOKIE[$key]); } } $all_maps = array(); $maps = $request['dba']->executeQuery("SELECT * FROM " . K4MAPS . " WHERE row_level = 1 AND (varname <> 'forums' AND varname <> 'categories' AND varname <> 'forum0') ORDER BY name ASC"); get_recursive_maps($request, $all_maps, $parents, $maps, 1); $all_maps =& new FAArrayIterator($all_maps); k4_bread_crumbs($request['template'], $request['dba'], 'L_PERMISSIONS'); $request['template']->setVar('options_on', '_on'); $request['template']->setFile('sidebar_menu', 'menus/options.html'); $request['template']->setList('maps_list', $all_maps); $request['template']->setFile('content', 'maps_tree.html'); } else { no_perms_error($request); } return TRUE; }
function execute(&$request) { if ($request['user']->isMember() && $request['user']->get('perms') >= SUPERADMIN) { global $_QUERYPARAMS; if (!isset($_REQUEST['id']) || intval($_REQUEST['id']) == 0) { $action = new K4InformationAction(new K4LanguageElement('L_INVALIDCATEGORY'), 'content', FALSE); return $action->execute($request); } $category = $request['dba']->getRow("SELECT * FROM " . K4CATEGORIES . " WHERE category_id = " . intval($_REQUEST['id'])); if (!is_array($category) || empty($category)) { $action = new K4InformationAction(new K4LanguageElement('L_INVALIDCATEGORY'), 'content', FALSE); return $action->execute($request); } foreach ($category as $key => $val) { $request['template']->setVar('category_' . $key, $val); } /* Get the parent id's */ $parents = array(); foreach ($_COOKIE as $key => $val) { if (strpos($key, 'mapsgui') !== FALSE) { $parents[] = intval($_COOKIE[$key]); } } $all_maps = array(); $maps = $request['dba']->executeQuery("SELECT * FROM " . K4MAPS . " WHERE category_id = " . intval($category['category_id']) . " AND forum_id = 0"); get_recursive_maps($request, $all_maps, $parents, $maps, 2); $all_maps =& new FAArrayIterator($all_maps); $request['template']->setList('category_maps', $all_maps); $request['template']->setFile('content', 'categories_permissions.html'); k4_bread_crumbs($request['template'], $request['dba'], 'L_CATEGORIES'); $request['template']->setVar('forums_on', '_on'); $request['template']->setFile('sidebar_menu', 'menus/forums.html'); } else { no_perms_error($request); } return TRUE; }
function execute(&$request) { if ($request['user']->isMember() && $request['user']->get('perms') >= SUPERADMIN) { global $_QUERYPARAMS; if (!isset($_REQUEST['id']) || intval($_REQUEST['id']) == 0) { $offset = 0; $get_mask_maps = FALSE; } else { $forum = $request['dba']->getRow("SELECT * FROM " . K4FORUMS . " WHERE forum_id = " . intval($_REQUEST['id'])); if (!is_array($forum) || empty($forum)) { $action = new K4InformationAction(new K4LanguageElement('L_INVALIDFORUM'), 'content', FALSE); return $action->execute($request); } $get_mask_maps = TRUE; $offset = 2; } // $forum_map = $request['dba']->getRow("SELECT * FROM ". K4MAPS ." WHERE varname = 'forum". $forum['forum_id'] ."' AND forum_id = ". intval($forum['forum_id'])); // $forum_maps = $request['dba']->executeQuery("SELECT * FROM ". K4MAPS ." WHERE forum_id = ". intval($forum['forum_id'])); // // /* Loop through the forum map items */ // while($forum_maps->next()) { // $f = $forum_maps->current(); // // if(isset($_REQUEST[$f['varname'] .'_can_view']) && isset($_REQUEST[$f['varname'] .'_can_add']) && isset($_REQUEST[$f['varname'] .'_can_edit']) && isset($_REQUEST[$f['varname'] .'_can_del'])) { // // if(($_REQUEST[$f['varname'] .'_can_view'] != $f['can_view']) || ($_REQUEST[$f['varname'] .'_can_add'] != $f['can_add']) || ($_REQUEST[$f['varname'] .'_can_edit'] != $f['can_edit']) || ($_REQUEST[$f['varname'] .'_can_del'] != $f['can_del'])) { // // $update = $request['dba']->prepareStatement("UPDATE ". K4MAPS ." SET can_view=?,can_add=?,can_edit=?,can_del=? WHERE varname=? AND forum_id=?"); // $update->setInt(1, $_REQUEST[$f['varname'] .'_can_view']); // $update->setInt(2, $_REQUEST[$f['varname'] .'_can_add']); // $update->setInt(3, $_REQUEST[$f['varname'] .'_can_edit']); // $update->setInt(4, $_REQUEST[$f['varname'] .'_can_del']); // $update->setString(5, $f['varname']); // $update->setInt(6, $forum['forum_id']); // // $update->executeUpdate(); // // unset($update); // } // } // } $all_maps = array(); $maps = $request['dba']->executeQuery("SELECT * FROM " . K4MAPS . " WHERE group_id = 0 AND forum_id = 0 AND varname = 'forum0'"); get_recursive_maps($request, $all_maps, FALSE, $maps, 1); // delete all of the perms because we are going to readd them // by doing this, we are guranteed to store the minimum number // of changed permissions $forum_map_id = 0; if ($get_mask_maps) { $request['dba']->executeUpdate("DELETE FROM " . K4MAPS . " WHERE group_id = 0 AND forum_id = " . intval($forum['forum_id'])); $insert = $request['dba']->prepareStatement("INSERT INTO " . K4MAPS . " (row_level,name,varname,category_id,forum_id,user_id,can_view,can_add,can_edit,can_del,value,parent_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"); } else { $insert = $request['dba']->prepareStatement("UPDATE " . K4MAPS . " SET row_level=?,name=?,varname=?,category_id=?,forum_id=?,user_id=?,can_view=?,can_add=?,can_edit=?,can_del=?,value=?,parent_id=? WHERE id=?"); } foreach ($all_maps as $temp) { // make an adjustment for the master forum perm varname if ($get_mask_maps) { if ($temp['varname'] == 'forum0') { $add = TRUE; $temp['varname'] = 'forum' . intval($forum['forum_id']); $temp['name'] = $forum['name']; } else { $add = FALSE; } } else { $add = TRUE; } if (!$get_mask_maps) { $forum = $temp; } if (isset($_REQUEST[$temp['varname'] . '_can_view']) && $_REQUEST[$temp['varname'] . '_can_view'] != $temp['can_view']) { $add = TRUE; } if (isset($_REQUEST[$temp['varname'] . '_can_add']) && $_REQUEST[$temp['varname'] . '_can_add'] != $temp['can_add']) { $add = TRUE; } if (isset($_REQUEST[$temp['varname'] . '_can_edit']) && $_REQUEST[$temp['varname'] . '_can_edit'] != $temp['can_edit']) { $add = TRUE; } if (isset($_REQUEST[$temp['varname'] . '_can_del']) && $_REQUEST[$temp['varname'] . '_can_del'] != $temp['can_del']) { $add = TRUE; } if ($add) { $insert->setInt(1, $temp['row_level'] + $offset); $insert->setString(2, $temp['name']); $insert->setString(3, $temp['varname']); $insert->setInt(4, $forum['category_id']); $insert->setInt(5, $forum['forum_id']); $insert->setInt(6, $temp['user_id']); $insert->setInt(7, $_REQUEST[$temp['varname'] . '_can_view']); $insert->setInt(8, $_REQUEST[$temp['varname'] . '_can_add']); $insert->setInt(9, $_REQUEST[$temp['varname'] . '_can_edit']); $insert->setInt(10, $_REQUEST[$temp['varname'] . '_can_del']); $insert->setString(11, $temp['value']); $insert->setInt(12, $forum_map_id); if (!$get_mask_maps) { $insert->setInt(13, $temp['id']); } $insert->executeUpdate(); if ($temp['varname'] == 'forum' . intval($forum['forum_id'])) { $forum_map_id = $request['dba']->getValue("SELECT * FROM " . K4MAPS . " WHERE varname = 'forum" . intval($forum['forum_id']) . "'"); } } } reset_cache('all_forums'); reset_cache('maps'); k4_bread_crumbs($request['template'], $request['dba'], 'L_FORUMS'); $request['template']->setVar('forums_on', '_on'); $request['template']->setFile('sidebar_menu', 'menus/forums.html'); $action = new K4InformationAction(new K4LanguageElement('L_UPDATEDFORUMPERMS', $forum['name']), 'content', FALSE, 'admin.php?act=forums', 3); return $action->execute($request); } else { no_perms_error($request); } return TRUE; }