Commit 64b7e234 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Views can be submitted from my views page

parent ca3553c6
...@@ -30,8 +30,8 @@ require(dirname(dirname(__FILE__)) . '/init.php'); ...@@ -30,8 +30,8 @@ require(dirname(dirname(__FILE__)) . '/init.php');
$wwwroot = get_config('wwwroot'); $wwwroot = get_config('wwwroot');
$strings = array('accessstartdate', 'accessenddate', 'artefacts', 'delete', 'description', $strings = array('accessstartdate', 'accessenddate', 'artefacts', 'delete', 'description',
'editaccess', 'editview', 'editviewinformation', 'editaccess', 'editview', 'editviewinformation', 'submitted', 'submittedto',
'submitted', 'submittedto', 'submitview', 'unknownerror'); 'submitview', 'submitviewquestion', 'unknownerror');
$getstring = array(); $getstring = array();
foreach ($strings as $string) { foreach ($strings as $string) {
$getstring[$string] = "'" . get_string($string) . "'"; $getstring[$string] = "'" . get_string($string) . "'";
...@@ -55,7 +55,7 @@ viewlist.rowfunction = function(r, n, data) { ...@@ -55,7 +55,7 @@ viewlist.rowfunction = function(r, n, data) {
description(r), artefacts(r)]); description(r), artefacts(r)]);
} }
function title(r, c) { function title(r, communities) {
var editinfo = INPUT({'type':'button','value':{$getstring['editviewinformation']}}); var editinfo = INPUT({'type':'button','value':{$getstring['editviewinformation']}});
editinfo.onclick = function () { submitform(r.id, 'editinfo'); }; editinfo.onclick = function () { submitform(r.id, 'editinfo'); };
var edit = INPUT({'type':'button','value':{$getstring['editview']}}); var edit = INPUT({'type':'button','value':{$getstring['editview']}});
...@@ -65,10 +65,10 @@ function title(r, c) { ...@@ -65,10 +65,10 @@ function title(r, c) {
var del = INPUT({'type':'button','value':{$getstring['delete']}}); var del = INPUT({'type':'button','value':{$getstring['delete']}});
del.onclick = function () { submitform(r.id, 'delete'); }; del.onclick = function () { submitform(r.id, 'delete'); };
if (r.submittedto) { if (r.submittedto) {
var assess = {$getstring['submittedto']} + ': ' + r.submittedto; var assess = {$getstring['submitted']} + ': ' + r.submittedto;
} }
else { else {
var assess = assessselect(r.id,c); var assess = assessselect(r.id,communities);
} }
var f = FORM({'id':('form'+r.id),'method':'post','enctype':'multipart/form-data', var f = FORM({'id':('form'+r.id),'method':'post','enctype':'multipart/form-data',
'encoding':'multipart/form-data','onsubmit':"return formsubmit('"+r.id+"');"}, 'encoding':'multipart/form-data','onsubmit':"return formsubmit('"+r.id+"');"},
...@@ -79,15 +79,17 @@ function title(r, c) { ...@@ -79,15 +79,17 @@ function title(r, c) {
} }
function communityoption(community) { function communityoption(community) {
return OPTION({'name':'community'+community.id},community.name); return OPTION({'value':community.id},community.name);
} }
function assessselect(viewid, clist) { function assessselect(viewid, communitylist) {
if (clist.length < 1) { if (communitylist.length < 1) {
return null; return null;
} }
return [SELECT({'name':'community'},map(communityoption, clist)), var submitview = INPUT({'type':'button','value':{$getstring['submitview']}});
INPUT({'type':'button','value':{$getstring['submitview']}})]; submitview.onclick = function () { submitform(viewid, 'submitview'); };
return [SELECT({'name':'community'},map(communityoption, communitylist)), submitview];
} }
function startdate(r) { function startdate(r) {
...@@ -124,6 +126,20 @@ function deleteview(viewid) { ...@@ -124,6 +126,20 @@ function deleteview(viewid) {
return false; return false;
} }
function submitview(viewid, communityid) {
var answer = confirm({$getstring['submitviewquestion']});
if (!answer) {
return;
}
processingStart();
var req = getXMLHttpRequest();
req.open('POST','submit.json.php');
req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
var d = sendXMLHttpRequest(req,queryString({'viewid':viewid,'communityid':communityid}));
d.addCallbacks(json_success, json_error);
return false;
}
function json_success(result) { function json_success(result) {
var data = evalJSONRequest(result); var data = evalJSONRequest(result);
var errtype = false; var errtype = false;
...@@ -153,6 +169,9 @@ function submitform(viewid, action) { ...@@ -153,6 +169,9 @@ function submitform(viewid, action) {
return deleteview(viewid); return deleteview(viewid);
} }
var form = $('form' + viewid); var form = $('form' + viewid);
if (action == 'submitview') {
return submitview(viewid, form.community.value);
}
var page = 'index.php'; var page = 'index.php';
if (action == 'editinfo') { if (action == 'editinfo') {
page = 'editmetadata.php'; page = 'editmetadata.php';
......
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage admin
* @author Richard Mansfield <richard.mansfield@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
$data = new StdClass;
$data->id = param_integer('viewid');
$data->submittedto = param_integer('communityid');
if (!update_record('view',$data,'id')) {
json_reply('local', get_string('submitviewfailed'));
}
json_reply(false,get_string('viewsubmitted'));
?>
Supports Markdown
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