Commit 93b2d818 authored by Richard Mansfield's avatar Richard Mansfield

Add public flag to site_menu table

parent 36ad028a
......@@ -37,10 +37,10 @@ $ijs .= "var adminfile = '" . get_string('adminfile') . "';\n";
$ijs .= <<< EOJS
// Request a list of menu items from the server
function getitems() {
function getitems(menu) {
logDebug(get_string('loadingmenuitems'));
processingStart();
var d = loadJSONDoc('getmenuitems.json.php');
var d = loadJSONDoc('getmenuitems.json.php',{'menu':menu});
d.addCallback(function(data) {
if (!data.error) {
logDebug(get_string('loadedmenuitems'));
......@@ -200,7 +200,7 @@ function delitem(itemid) {
d.addCallback(function(data) {
if (data.success) {
logDebug(get_string('menuitemdeleted'));
getitems();
getitems(menu);
}
else {
displayMessage(get_string('deletefailed'),'error');
......@@ -217,7 +217,8 @@ function saveitem(formid) {
var data = {'type':f.type[0].checked ? 'externallink' : 'adminfile',
'name':f.name.value,
'linkedto':f.linkedto.value,
'itemid':f.itemid.value};
'itemid':f.itemid.value,
'menu':menu};
var req = getXMLHttpRequest();
req.open('POST','updatemenu.json.php');
req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
......@@ -236,7 +237,7 @@ function saveitem(formid) {
}
else {
displayMessage(data.message,errtype);
getitems();
getitems(menu);
processingStop();
}
});
......@@ -251,7 +252,8 @@ function getadminfiles() {
return null;
}
addLoadEvent(getitems);
var menu = 'public';
addLoadEvent(function () {getitems(menu);});
EOJS;
$style = '<style type="text/css">.invisible{display:none;} .menueditcell{width:200px;}</style>';
......
......@@ -28,10 +28,13 @@ define('INTERNAL', 1);
define('ADMIN', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
$menu = get_variable('menu');
$public = $menu == 'public' ? 1 : 0;
$result = array();
try {
$menuitems = get_records('site_menu','','','displayorder');
$menuitems = get_records('site_menu','public',$public,'displayorder');
// @todo: Get all the filenames of the files referred to in the $menuitems records.
// (files table doesn't exist yet)
$rows = array();
......
......@@ -42,6 +42,7 @@ $type = get_variable('type');
$name = get_variable('name');
$linkedto = get_variable('linkedto');
$itemid = get_variable('itemid');
$menu = get_variable('menu');
error_log('updatemenu.json.php '.$type .' '. $name .' '. $linkedto .' '. $itemid);
......@@ -57,6 +58,7 @@ else { // Bad menu item type
send_fail_message();
}
$data->title = $name;
$data->public = $menu == 'public' ? 1 : 0;
if ($itemid == 'new') {
// set displayorder to be after all the existing menu items
......
......@@ -602,6 +602,7 @@
<FIELD NAME="file" TYPE="int" LENGTH="10" NOTNULL="false" />
<FIELD NAME="url" TYPE="text" NOTNULL="false" />
<FIELD NAME="displayorder" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="public" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<!--- public? -->
<!-- displayorder maybe should be the primary key -->
</FIELDS>
......
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