Commit 00ad2e08 authored by Penny Leach's avatar Penny Leach
Browse files
parents 6a85358b a350e989
......@@ -31,15 +31,10 @@ require(dirname(dirname(__FILE__)) . '/init.php');
$itemid = param_variable('itemid');
$result = array();
try {
delete_records('site_menu','id',$itemid);
$result['success'] = 'ok';
$result['message'] = get_string('deletedsuccessfully');
}
catch (Exception $e) {
$result['success'] = 'error';
$result['message'] = $e->getMessage();
if (!delete_records('site_menu','id',$itemid)) {
json_reply('local', get_string('deletefailed','admin'));
}
echo json_encode($result);
json_reply(false,get_string('menuitemdeleted','admin'));
?>
......@@ -31,16 +31,14 @@ require(dirname(dirname(__FILE__)) . '/init.php');
$pagename = param_alpha('pagename');
$data['pagename'] = $pagename;
try {
$page = get_record('site_content','name',$pagename);
$data['content'] = $page->content;
$data['error'] = false;
$data['message'] = get_string('loadedsitecontent');
}
catch (Exception $e) {
$data['error'] = 'local';
$data['message'] = get_string('failedloadingsitecontent');
if (!$page = @get_record('site_content','name',$pagename)) {
json_reply('local',get_string('failedloadingsitecontent','admin'));
}
$data['content'] = $page->content;
$data['error'] = false;
$data['message'] = get_string('loadedsitecontent','admin');
json_headers();
echo json_encode($data);
?>
......@@ -29,6 +29,17 @@ define('ADMIN', 1);
define('MENUITEM','menueditor');
require(dirname(dirname(__FILE__)).'/init.php');
$strings = array('edit','delete','update','cancel','add','name','unknownerror');
$adminstrings = array('deletefailed','deletingmenuitem','savingmenuitem',
'noadminfiles','loggedinmenu','loggedoutmenu','linkedto','externallink','adminfile',
'loadingmenuitems','menuitemsloaded','failedloadingmenuitems');
foreach ($strings as $string) {
$getstring[$string] = "'" . get_string($string) . "'";
}
foreach ($adminstrings as $string) {
$getstring[$string] = "'" . get_string($string,'admin') . "'";
}
$thead = array(get_string('type','admin'),get_string('name','admin'),get_string('linkedto','admin'),'');
$ijs = "var thead = TR(null,map(partial(TH,null),['" . implode($thead,"','") . "']));\n";
$ijs .= "var externallink = '" . get_string('externallink','admin') . "';\n";
......@@ -37,17 +48,17 @@ $ijs .= "var adminfile = '" . get_string('adminfile','admin') . "';\n";
$ijs .= <<< EOJS
// Request a list of menu items from the server
function getitems() {
logDebug(get_string('loadingmenuitems','admin'));
logDebug({$getstring['loadingmenuitems']});
processingStart();
var d = loadJSONDoc('getmenuitems.json.php',{'public':selectedmenu == 'loggedoutmenu'});
d.addCallback(function(data) {
if (!data.error) {
logDebug(get_string('loadedmenuitems','admin'));
logDebug({$getstring['menuitemsloaded']});
displaymenuitems(data.menuitems);
processingStop();
}
else {
displayMessage(get_string('failedloadingmenuitems','admin'),'error');
displayMessage({$getstring['failedloadingmenuitems']},'error');
processingStop();
}
});
......@@ -67,9 +78,9 @@ function formatrow (item) {
// item has id, type, name, link, linkedto
var type = eval(item.type);
var linkedto = item.link == '' ? item.linkedto : A({'href':item.link},item.linkedto);
var del = INPUT({'type':'button','value':get_string('delete')});
var del = INPUT({'type':'button','value':{$getstring['delete']}});
del.onclick = function () { delitem(item.id); };
var edit = INPUT({'type':'button','value':get_string('edit')});
var edit = INPUT({'type':'button','value':{$getstring['edit']}});
edit.onclick = function () { edititem(item); };
var cells = map(partial(TD,null),[type,item.name,linkedto,[del,edit]]);
return TR({'id':'menuitem_'+item.id},cells);
......@@ -108,13 +119,13 @@ function editform(item) {
elink.onclick = function () { changeaddform('externallink'); };
afile.onclick = function () { changeaddform('adminfile'); };
// The save button says 'add', and there's no cancel button.
setNodeAttribute(save,'value',get_string('add'));
setNodeAttribute(save,'value',{$getstring['add']});
savecancel = [save];
}
else { // Editing an existing menu item.
// The save button says 'update' and there's a cancel button.
setNodeAttribute(save,'value',get_string('update'));
var cancel = INPUT({'type':'button','value':get_string('cancel')});
setNodeAttribute(save,'value',{$getstring['update']});
var cancel = INPUT({'type':'button','value':{$getstring['cancel']}});
cancel.onclick = closeopenedits;
savecancel = [save,cancel];
elink.onclick = function () { changeeditform(item,'externallink'); };
......@@ -128,7 +139,7 @@ function editform(item) {
var adminfiles = getadminfiles();
if (adminfiles == null) {
// There are no admin files, we don't need the select or save button
linkedto = get_string('noadminfiles','admin');
linkedto = {$getstring['noadminfiles']};
savecancel = [cancel];
}
else {
......@@ -141,7 +152,8 @@ function editform(item) {
linkedto = INPUT({'type':'text','name':'linkedto','value':item.linkedto});
setNodeAttribute(elink,'checked',true);
}
var radios = [DIV(null,elink,eval('externallink')),DIV(null,afile,eval('adminfile'))];
var radios = [DIV(null,elink,{$getstring['externallink']}),
DIV(null,afile,{$getstring['adminfile']})];
var row = TR(null,map(partial(TD,null),[radios,name,linkedto,savecancel]));
return TABLE({'width':'100%'},cols(),TBODY(null,row));
}
......@@ -191,21 +203,31 @@ function edititem(item) {
menuitem.parentNode.insertBefore(newrow,menuitem);
}
// Receive standard json error message
function get_json_status(data) {
var errtype = 'global';
if (!data.error) {
errtype = 'info';
}
else if (data.error == 'local') {
errtype = 'error';
}
else {
global_error_handler(data);
}
if (errtype != 'global') {
displayMessage(data.message,errtype);
getitems();
processingStop();
}
}
// Request deletion of a menu item from the db
function delitem(itemid) {
processingStart();
logDebug(get_string('deletingmenuitem','admin'));
logDebug({$getstring['deletingmenuitem']});
var d = loadJSONDoc('deletemenuitem.json.php',{'itemid':itemid});
d.addCallback(function(data) {
if (data.success) {
logDebug(get_string('menuitemdeleted','admin'));
getitems();
}
else {
displayMessage(get_string('deletefailed','admin'),'error');
}
processingStop();
});
d.addCallback(get_json_status);
}
// Send the menu item in the form to the database.
......@@ -214,15 +236,15 @@ function saveitem(formid) {
var name = f.name.value;
var linkedto = f.linkedto.value;
if (name == '') {
displayMessage(get_string('namedfieldempty',get_string('name','admin')),'error');
displayMessage(get_string('namedfieldempty',{$getstring['name']}),'error');
return false;
}
if (linkedto == '') {
displayMessage(get_string('namedfieldempty',get_string('linkedto','admin')),'error');
displayMessage(get_string('namedfieldempty',{$getstring['linkedto']}),'error');
return false;
}
processingStart();
displayMessage(get_string('savingmenuitem','admin'),'info');
logDebug({$getstring['savingmenuitem']});
var data = {'type':f.type[0].checked ? 'externallink' : 'adminfile',
'name':name,
'linkedto':linkedto,
......@@ -234,24 +256,10 @@ function saveitem(formid) {
var d = sendXMLHttpRequest(req,queryString(data));
d.addCallback(function (result) {
var data = evalJSONRequest(result);
var errtype = 'global';
if (!data.error) {
errtype = 'info';
}
else if (data.error == 'local') {
errtype = 'error';
}
else {
global_error_handler(data);
}
if (errtype != 'global') {
displayMessage(data.message,errtype);
getitems();
processingStop();
}
get_json_status(data);
});
d.addErrback(function() {
displayMessage(get_string('unknownerror'),'error');
displayMessage({$getstring['unknownerror']},'error');
processingStop();
});
return false;
......@@ -284,14 +292,11 @@ EOJS;
$menulist = array('loggedinmenu', 'loggedoutmenu');
foreach ($menulist as &$menu) {
$menu = array('value' => $menu,
'name' => get_string($menu));
'name' => get_string($menu,'admin'));
}
$style = '<style type="text/css">.invisible{display:none;}</style>';
$strings = array('deletefailed','deletingmenuitem','menuitemdeleted','savingmenuitem','noadminfiles',
'edit','delete','update','cancel','add','loggedinmenu','loggedoutmenu','name',
'linkedto');
$smarty = smarty(array(),array($style),$strings);
$smarty = smarty(array(),array($style));
$smarty->assign('INLINEJAVASCRIPT',$ijs);
$smarty->assign('EDIT',get_string('edit') . ':');
$smarty->assign('MENUS',$menulist);
......
......@@ -37,6 +37,8 @@ foreach ($sitepages as $page) {
}
asort($pageoptions);
$getstring = array('discardpageedits' => "'" . get_string('discardpageedits','admin') . "'");
$f = array(
'name' => 'editsitepage',
'method' => 'post',
......@@ -104,7 +106,7 @@ var originalcontent = '';
function requestPageText(removeMessage) {
// Allow the user to abort change if changes have been made in the editor.
if (getEditorContent() != originalcontent) {
var answer = confirm(get_string('discardpageedits'));
var answer = confirm({$getstring['discardpageedits']});
if (!answer) {
$('pagename').value = oldpagename;
return;
......@@ -159,9 +161,7 @@ function onLoad() {
addLoadEvent(onLoad);
EOJS;
$jsstrings = array('discardpageedits');
$smarty = smarty($js, array(), $jsstrings);
$smarty = smarty($js);
$smarty->assign('pageeditform', $form);
$smarty->assign('INLINEJAVASCRIPT', $ijs);
$smarty->display('admin/editsitepage.tpl');
......
......@@ -32,40 +32,35 @@ $public = (int) param_boolean('public');
$result = array();
try {
$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();
if ($menuitems) {
foreach ($menuitems as $i) {
$r = array();
$r['id'] = $i->id;
$r['name'] = $i->title;
if (empty($i->url) && !empty($i->file)) {
$r['type'] = 'adminfile';
$r['linkedto'] = $i->file; // @todo: substitute the appropriate filename.
// $r['link'] = ''; // @todo: provide a link to the file
}
else if (!empty($i->url) && empty($i->file)) {
$r['type'] = 'externallink';
$r['linkedto'] = $i->url;
// $r['link'] = $i->url;
}
else {
throw new Exception ('Exactly one of {file,url} should be set in site_menu table');
}
$rows[] = $r;
$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();
if ($menuitems) {
foreach ($menuitems as $i) {
$r = array();
$r['id'] = $i->id;
$r['name'] = $i->title;
if (empty($i->url) && !empty($i->file)) {
$r['type'] = 'adminfile';
$r['linkedto'] = $i->file; // @todo: substitute the appropriate filename.
// $r['link'] = ''; // @todo: provide a link to the file
}
else if (!empty($i->url) && empty($i->file)) {
$r['type'] = 'externallink';
$r['linkedto'] = $i->url;
// $r['link'] = $i->url;
}
else {
json_reply('local',get_string('failedloadingsitemenu','admin'));
}
$rows[] = $r;
}
$result['menuitems'] = array_values($rows);
$result['error'] = false;
$result['message'] = get_string('sitemenuloaded');
}
catch (Exception $e) {
$result['error'] = 'local';
$result['message'] = get_string('failedloadingsitemenu');
}
$result['menuitems'] = array_values($rows);
$result['error'] = false;
$result['message'] = get_string('sitemenuloaded','admin');
json_headers();
echo json_encode($result);
?>
......@@ -136,7 +136,7 @@ function siteoptions_submit($values) {
json_reply(false, get_string('siteoptionsset','admin'));
}
$smarty = smarty(array(),array(),array('siteoptionsset','setsiteoptionsfailed'));
$smarty = smarty();
$smarty->assign('SITEOPTIONFORM',$siteoptionform);
$smarty->display('admin/options/index.tpl');
......
......@@ -43,7 +43,7 @@ else if ($type == 'externallink') {
$data->url = $linkedto;
}
else { // Bad menu item type
json_reply('local',get_string('badmenuitemtype'));
json_reply('local',get_string('badmenuitemtype','admin'));
}
$data->title = $name;
......@@ -62,7 +62,7 @@ if ($itemid == 'new') {
insert_record('site_menu', $data);
}
catch (Exception $e) {
json_reply('local',get_string('savefailed'));
json_reply('local',get_string('savefailed','admin'));
}
}
else {
......@@ -71,10 +71,10 @@ else {
update_record('site_menu', $data, 'id');
}
catch (Exception $e) {
json_reply('local',get_string('savefailed'));
json_reply('local',get_string('savefailed','admin'));
}
}
json_reply(false,get_string('menuitemsaved'));
json_reply(false,get_string('menuitemsaved','admin'));
?>
......@@ -50,8 +50,8 @@ $form = array(
'filter' => false
),
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('submit'), get_string('cancel'))
'type' => 'submit',
'value' => get_string('submit')
)
)
);
......
......@@ -49,8 +49,8 @@ $form = array(
'filter' => false
),
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('submit'), get_string('cancel'))
'type' => 'submit',
'value' => get_string('submit')
)
)
);
......
......@@ -27,7 +27,7 @@
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'usermanagement');
define('SUBMENUITEM', 'uploadcsv');
define('SUBMENUITEM', 'addusersbycsv');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('form.php');
......
......@@ -19,25 +19,27 @@
-->
<TABLE NAME="artefact_internal_profile_email">
<FIELDS>
<FIELD NAME="user" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="owner" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="email" TYPE="text" NOTNULL="true" />
<FIELD NAME="verified" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="principal" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="artefact" TYPE="int" LENGTH="10" NOTNULL="false" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="user,email" />
<KEY NAME="userfk" TYPE="foreign" FIELDS="user" REFTABLE="usr" REFFIELDS="id" />
<KEY NAME="primary" TYPE="primary" FIELDS="owner,email" />
<KEY NAME="ownerfk" TYPE="foreign" FIELDS="owner" REFTABLE="usr" REFFIELDS="id" />
<KEY NAME="artefactfk" TYPE="foreign" FIELDS="artefact" REFTABLE="artefact" REFFIELDS="id" />
</KEYS>
</TABLE>
<TABLE NAME="artefact_internal_profile_icon">
<FIELDS>
<FIELD NAME="user" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="owner" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="filename" TYPE="text" NOTNULL="true" />
<FIELD NAME="primary" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="user,filename" />
<KEY NAME="userfk" TYPE="foreign" FIELDS="user" REFTABLE="usr" REFFIELDS="id" />
<KEY NAME="primary" TYPE="primary" FIELDS="owner,filename" />
<KEY NAME="ownerfk" TYPE="foreign" FIELDS="owner" REFTABLE="usr" REFFIELDS="id" />
</KEYS>
</TABLE>
</TABLES>
......
......@@ -86,6 +86,10 @@ $string['linkedto'] = 'Linked to';
$string['editmenus'] = 'Edit menus';
$string['menuitemsaved'] = 'Menu item saved';
$string['savingmenuitem'] = 'Saving menu item';
$string['menuitemsloaded'] = 'Menu items loaded';
$string['deletingmenuitem'] = 'Deleting menu item';
$string['menuitemdeleted'] = 'Menu item deleted';
$string['loadingmenuitems'] = 'Loading menu items';
$string['loggedinmenu'] = 'Logged in menu';
$string['loggedoutmenu'] = 'Logged out menu';
......@@ -105,7 +109,8 @@ $string['sitecontentnotfound'] = '%s text not available';
$string['termsandconditions'] = 'Terms and conditions';
$string['uploadcopyright'] = 'Upload copyright statement';
// Upload CSV stuff
// Upload CSV
$string['addusersbycsv'] = 'Add Users by CSV';
$string['csvfile'] = 'CSV File';
$string['csvfiledescription'] = 'The file containing users to add';
$string['uploadcsverrorinvalidemail'] = 'Error on line %s of your file: The e-mail address for this user is not in correct form';
......@@ -115,6 +120,18 @@ $string['uploadcsverrorincorrectfieldcount'] = 'Line %s of the file does not hav
$string['uploadcsvfile'] = 'Upload CSV File';
$string['uploadcsvfiledescription'] = 'You may use this facility to upload new users via a <acronym title="Comma Separated Values">CSV</acronym> file. Each record in the file must have a username, e-mail address and password.';
// Admin Users
$string['adminusers'] = 'Admin Users';
$string['adminusersdescription'] = 'Here you may choose which users are administrators. Admin users are listed in the right box, and potential administrators are on the left.';
// Staff Users
$string['staffusers'] = 'Staff Users';
$string['staffusersdescription'] = 'Here you may choose which users are staff users. Staff users are listed in the right box, and potential staff users are on the left.';
// Admin Notifications
$string['adminnotifications'] = 'Admin Notifications';
// Suspended Users
$string['suspendedusers'] = 'Suspended Users';
?>
......@@ -26,9 +26,10 @@
defined('INTERNAL') || die();
$string['cancel'] = 'Cancel';
$string['sessiontimedout'] = 'Your session has timed out, please enter your login details to continue';
$string['sessiontimedoutpublic'] = 'Your session has timed out. You may <a href="?login">log in</a> to continue browsing';
$string['cancel'] = 'Cancel';
$string['submit'] = 'Submit';
$string['nextpage'] = 'Next page';
$string['prevpage'] = 'Previous page';
......
......@@ -826,7 +826,7 @@ function admin_nav() {
'link' => $wwwroot . 'admin/usermanagement/uploadcsv.php',
'submenu' => array(
array(
'name' => 'uploadcsv',
'name' => 'addusersbycsv',
'section' => 'admin',
'link' => $wwwroot . 'admin/usermanagement/uploadcsv.php'
),
......
{include file="header.tpl"}
<h2>AdminUsers</h2>
<h2>{str tag="adminusers" section="admin"}</h2>
<p>{str tag="adminusersdescription" section="admin"}</p>
{$adminusersform}
......
{include file="header.tpl"}
<h2>StaffUsers</h2>
<h2>{str tag="staffusers" section="admin"}</h2>
<p>{str tag="staffusersdescription" section="admin"}</p>
{$staffusersform}
......
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