Commit eb02ccef authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Pass public/private menu as a boolean

parent 037bd034
......@@ -28,7 +28,6 @@ define('INTERNAL',1);
define('ADMIN', 1);
define('MENUITEM','menueditor');
require(dirname(dirname(__FILE__)).'/init.php');
//require_once('form.php');
$thead = array(get_string('type'),get_string('name'),get_string('linkedto'),'');
$ijs = "var thead = TR(null,map(partial(TH,null),['" . implode($thead,"','") . "']));\n";
......@@ -40,7 +39,7 @@ $ijs .= <<< EOJS
function getitems() {
logDebug(get_string('loadingmenuitems'));
processingStart();
var d = loadJSONDoc('getmenuitems.json.php',{'menu':selectedmenu});
var d = loadJSONDoc('getmenuitems.json.php',{'public':selectedmenu == 'public'});
d.addCallback(function(data) {
if (!data.error) {
logDebug(get_string('loadedmenuitems'));
......@@ -218,7 +217,7 @@ function saveitem(formid) {
'name':f.name.value,
'linkedto':f.linkedto.value,
'itemid':f.itemid.value,
'menu':selectedmenu};
'public':selectedmenu == 'public'};
var req = getXMLHttpRequest();
req.open('POST','updatemenu.json.php');
req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
......
......@@ -28,8 +28,7 @@ define('INTERNAL', 1);
define('ADMIN', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
$menu = param_variable('menu');
$public = (int)($menu == 'public');
$public = (int) param_boolean('public');
$result = array();
......
......@@ -36,11 +36,11 @@ function send_fail_message() {
exit;
}
$type = param_variable('type'); // external list or admin file
$type = param_alpha('type'); // external list or admin file
$name = param_variable('name');
$linkedto = param_variable('linkedto');
$itemid = param_variable('itemid');
$menu = param_variable('menu');
$public = (int) param_boolean('public');
$data = new StdClass;
if ($type == 'adminfile') {
......@@ -56,7 +56,7 @@ else { // Bad menu item type
$data->title = $name;
if ($itemid == 'new') {
$data->public = (int) ($menu == 'public');
$data->public = $public;
// set displayorder to be after all the existing menu items
try {
$displayorders = get_rows('site_menu', 'public', $data->public, '', 'displayorder');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment