Commit 58d177a2 authored by Penny Leach's avatar Penny Leach
Browse files
parents f1df685c 996b4440
......@@ -26,6 +26,8 @@
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'configextensions');
define('SUBMENUITEM', 'pluginadmin');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('pieforms/pieform.php');
......@@ -75,7 +77,7 @@ $smarty->assign('form', pieform($form));
$smarty->assign('plugintype', $plugintype);
$smarty->assign('pluginname', $pluginname);
$smarty->assign('type', $type);
$smarty->display('admin/plugins/pluginconfig.tpl');
$smarty->display('admin/extensions/pluginconfig.tpl');
function pluginconfig_submit($values) {
......
......@@ -26,6 +26,8 @@
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'configextensions');
define('SUBMENUITEM', 'pluginadmin');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require('upgrade.php');
......@@ -132,6 +134,6 @@ $smarty = smarty();
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->assign('plugins', $plugins);
$smarty->assign('installlink', 'installplugin');
$smarty->display('admin/plugins/index.tpl');
$smarty->display('admin/extensions/plugins.tpl');
?>
......@@ -252,9 +252,9 @@ foreach ($menulist as &$menu) {
}
$style = '<style type="text/css">.invisible{display:none;}</style>';
$smarty = smarty(array(),array($style));
$smarty->assign('INLINEJAVASCRIPT',$ijs);
$smarty->assign('MENUS',$menulist);
$smarty->display('admin/editmenu.tpl');
$smarty = smarty(array(), array($style));
$smarty->assign('INLINEJAVASCRIPT', $ijs);
$smarty->assign('MENUS', $menulist);
$smarty->display('admin/site/menu.tpl');
?>
......@@ -126,7 +126,7 @@ function siteoptions_submit($values) {
}
$smarty = smarty();
$smarty->assign('SITEOPTIONFORM',$siteoptionform);
$smarty->display('admin/options/index.tpl');
$smarty->assign('SITEOPTIONFORM', $siteoptionform);
$smarty->display('admin/site/options.tpl');
?>
......@@ -27,7 +27,7 @@
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'configsite');
define('SUBMENUITEM', 'pageeditor');
define('SUBMENUITEM', 'sitepages');
require(dirname(dirname(dirname(__FILE__))).'/init.php');
require_once('pieforms/pieform.php');
......@@ -107,7 +107,7 @@ function requestPageText(removeMessage) {
if (getEditorContent() != originalcontent) {
var answer = confirm({$getstring['discardpageedits']});
if (!answer) {
$('pagename').value = oldpagename;
$('editsitepage_pagename').value = oldpagename;
return;
}
}
......@@ -118,13 +118,13 @@ function requestPageText(removeMessage) {
}
editsitepage_remove_error('pagetext');
logDebug(get_string('loadingpagecontent', 'admin'));
var d = loadJSONDoc('editchangepage.json.php',{'pagename':$('pagename').value});
var d = loadJSONDoc('editchangepage.json.php',{'pagename':$('editsitepage_pagename').value});
d.addCallback(function(data) {
if (!data.error) {
logDebug(get_string('sitepageloaded', 'admin'));
setEditorContent(data.content);
originalcontent = getEditorContent();
oldpagename = $('pagename').value;
oldpagename = $('editsitepage_pagename').value;
}
else {
displayMessage(get_string('loadsitepagefailed', 'admin'));
......@@ -149,12 +149,12 @@ function onLoad() {
getEditorContent = tinyMCE.getContent;
}
else {
setEditorContent = function (c) { $('pagetext').value = c; };
getEditorContent = function () { return $('pagetext').value; };
setEditorContent = function (c) { $('editsitepage_pagetext').value = c; };
getEditorContent = function () { return $('editsitepage_pagetext').value; };
}
originalcontent = getEditorContent();
requestPageText();
connect('pagename', 'onchange', requestPageText);
connect('editsitepage_pagename', 'onchange', requestPageText);
}
addLoadEvent(onLoad);
......@@ -163,6 +163,6 @@ EOJS;
$smarty = smarty($js);
$smarty->assign('pageeditform', $form);
$smarty->assign('INLINEJAVASCRIPT', $ijs);
$smarty->display('admin/editsitepage.tpl');
$smarty->display('admin/site/pages.tpl');
?>
......@@ -73,6 +73,6 @@ function adminusers_submit($values) {
}
$smarty->assign('adminusersform', pieform($form));
$smarty->display('admin/usermanagement/adminusers.tpl');
$smarty->display('admin/users/admin.tpl');
?>
......@@ -47,7 +47,7 @@ if ($institution || $add) {
}
function delete_cancel_submit() {
redirect(get_config('wwwroot') . 'admin/institutions.php');
redirect(get_config('wwwroot') . 'admin/users/institutions.php');
}
function delete_submit($values) {
......@@ -59,7 +59,7 @@ if ($institution || $add) {
db_commit();
$SESSION->add_ok_msg(get_string('institutiondeletedsuccessfully', 'admin'));
redirect(get_config('wwwroot') . 'admin/institutions.php');
redirect(get_config('wwwroot') . 'admin/users/institutions.php');
}
$form = array(
'name' => 'delete',
......@@ -79,7 +79,7 @@ if ($institution || $add) {
)
);
$smarty->assign('delete_form', pieform($form));
$smarty->display('admin/institutions.tpl');
$smarty->display('admin/users/institutions.tpl');
exit;
}
......@@ -234,13 +234,13 @@ function institution_submit($values) {
$message = ($add) ? 'institutionaddedsuccessfully' : 'institutionupdatedsuccessfully';
$SESSION->add_ok_msg(get_string($message, 'admin'));
redirect(get_config('wwwroot') . 'admin/institutions.php');
redirect(get_config('wwwroot') . 'admin/users/institutions.php');
}
function institution_cancel_submit() {
redirect(get_config('wwwroot') . 'admin/institutions.php');
redirect(get_config('wwwroot') . 'admin/users/institutions.php');
}
$smarty->display('admin/institutions.tpl');
$smarty->display('admin/users/institutions.tpl');
?>
......@@ -31,6 +31,6 @@ define('SUBMENUITEM', 'adminnotifications');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$smarty = smarty();
$smarty->display('admin/usermanagement/adminnotifications.tpl');
$smarty->display('admin/users/notifications.tpl');
?>
......@@ -72,6 +72,6 @@ function staffusers_submit($values) {
}
$smarty->assign('staffusersform', pieform($form));
$smarty->display('admin/usermanagement/staffusers.tpl');
$smarty->display('admin/users/staff.tpl');
?>
......@@ -31,6 +31,6 @@ define('SUBMENUITEM', 'suspendedusers');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
$smarty = smarty();
$smarty->display('admin/usermanagement/suspendedusers.tpl');
$smarty->display('admin/users/suspended.tpl');
?>
......@@ -171,7 +171,7 @@ function uploadcsv_submit($values) {
$id = insert_record('usr', $user, 'id', true);
$i = 2;
safe_require('artefact', 'internal', 'lib.php');
safe_require('artefact', 'internal');
foreach (ArtefactTypeProfile::get_mandatory_fields() as $field => $type) {
set_profile_field($id, $field, $record[$i++]);
}
......@@ -180,11 +180,11 @@ function uploadcsv_submit($values) {
$SESSION->add_ok_msg(get_string('uploadcsvusersaddedsuccessfully', 'admin'));
// @todo support relative URLs here
redirect(get_config('wwwroot') . 'admin/usermanagement/uploadcsv.php');
redirect(get_config('wwwroot') . 'admin/users/uploadcsv.php');
}
$smarty = smarty();
$smarty->assign('uploadcsvform', pieform($form));
$smarty->display('admin/usermanagement/uploadcsv.tpl');
$smarty->display('admin/users/uploadcsv.tpl');
?>
......@@ -34,30 +34,10 @@ catch (ParameterException $e) {
json_reply('missingparameter',get_string('missingparameter'));
}
$prefix = get_config('dbprefix');
require_once('artefact.php');
$filerecord = get_record_sql('SELECT a.artefacttype, a.owner, f.name
FROM ' . $prefix . 'artefact a
JOIN ' . $prefix . 'artefact_file_files f ON a.id = f.artefact
WHERE a.id = ' . $fileid);
if ($filerecord->owner != $USER->get('id')) {
json_reply('local',get_string('notowner'));
}
if (count_records('artefact', 'parent', $fileid) > 0) {
json_reply('local', get_string('artefacthaschildren'));
}
if (!delete_records('artefact_file_files', 'artefact', $fileid)) {
json_reply('local', get_string('deletefailed'));
}
if (!delete_records('artefact', 'id', $fileid)) {
json_reply('local', get_string('deletefailed'));
}
// @todo: Delete the file from the filesystem here
$artefact = artefact_instance_from_id($fileid);
$artefact->delete();
json_reply(false, get_string('filedeleted'));
......
......@@ -39,8 +39,7 @@ foreach ($strings as $string) {
$javascript = <<<JAVASCRIPT
var browser = new FileBrowser('filelist');
var uploader = new FileUploader('uploader');
uploader.uploadcallback = browser.refresh;
var uploader = new FileUploader('uploader', null, null, browser.refresh, browser.fileexists);
browser.changedircallback = uploader.updatedestination;
JAVASCRIPT;
......
......@@ -6,6 +6,7 @@ function FileBrowser(element, changedircallback) {
this.pathids = {'/':null};
this.cwd = '/';
this.changedircallback = changedircallback;
this.filenames = {};
this.init = function() {
self.filelist = new TableRenderer(
......@@ -33,7 +34,11 @@ function FileBrowser(element, changedircallback) {
var editb = INPUT({'type':'button', 'value':get_string('edit')});
editb.onclick = function () { self.openeditform(r); };
var deleteb = INPUT({'type':'button', 'value':get_string('delete')});
deleteb.onclick = function () { sendjsonrequest('delete.json.php', {'id': r.id}, self.refresh); };
deleteb.onclick = function () {
if (confirm(get_string(r.artefacttype == 'folder' ? 'deletefolderandcontents?' : 'deletefile?'))) {
sendjsonrequest('delete.json.php', {'id': r.id}, self.refresh);
}
};
return TD(null, editb, deleteb);
}
......@@ -69,30 +74,35 @@ function FileBrowser(element, changedircallback) {
this.openeditform = function(fileinfo) {
var editrows = [];
var elemid = fileinfo.artefacttype + fileinfo.id;
var editid = 'edit_' + fileinfo.id;
var formid = editid + '_form';
var rowid = 'row_' + fileinfo.id;
var cancelform = function() {
setDisplayForElement(null, rowid);
removeElement(editid);
};
var savebutton = INPUT({'type':'button','value':get_string('savechanges')});
//savebutton.onclick = function () { updatefilemetadata(elemid) };
savebutton.onclick = function () {
sendjsonrequest('updatemetadata.json.php',
{'id':fileinfo.id, 'name':$(formid).name.value,
'description':$(formid).description.value},
function() {cancelform(); self.refresh()});
};
if (fileinfo['artefacttype'] == 'folder') {
editrows = self.folderformrows(fileinfo);
}
else {
editrows = [self.editformtitle(get_string('editfile')),
self.textinputrow('title',fileinfo.title),
self.textinputrow('name',fileinfo.title),
self.textinputrow('description',fileinfo.description)];
}
var editid = 'edit_' + elemid;
var rowid = 'row_'+fileinfo.id;
var cancelbutton = INPUT({'type':'button', 'value':get_string('cancel')});
cancelbutton.onclick = function () {
$(rowid).style.visibility = '';
removeElement(editid);
}
var edittable = TABLE({'align':'center'},TBODY(null,editrows));
var buttons = [savebutton,cancelbutton];
$(rowid).style.visibility = 'hidden';
var cancelbutton = INPUT({'type':'button', 'value':get_string('cancel'), 'onclick':cancelform});
var buttons = TR(null,TD({'colspan':2},savebutton,cancelbutton));
var edittable = TABLE({'align':'center'},TBODY(null,editrows,buttons));
hideElement(rowid);
insertSiblingNodesBefore(rowid, TR({'id':editid},
TD({'colSpan':4},
FORM({'id':editid+'_form','action':''},edittable,buttons))));
FORM({'id':formid,'action':''},edittable))));
}
this.showsize = function(bytes) {
......@@ -106,6 +116,7 @@ function FileBrowser(element, changedircallback) {
}
this.formatname = function(r) {
self.filenames[r.title] = true;
if (r.artefacttype == 'file') {
return TD(null, r.title);
}
......@@ -118,10 +129,15 @@ function FileBrowser(element, changedircallback) {
}
}
this.fileexists = function (filename) {
return self.filenames[filename] == true;
}
this.changedir = function(path) {
self.cwd = path;
self.linked_path();
self.changedircallback(self.pathids[path], path);
self.filenames = {};
var args = path == '/' ? null : {'folder':self.pathids[path]};
self.filelist.doupdate(args);
return false;
......
......@@ -93,6 +93,15 @@ class ArtefactTypeFileBase extends ArtefactType {
return 'file';
}
public function delete() {
if (empty($this->id)) {
return;
}
delete_records('artefact_file_files', 'artefact', $this->id);
// @todo: Delete the file from the filesystem
parent::delete();
}
}
class ArtefactTypeFile extends ArtefactTypeFileBase {
......
......@@ -41,6 +41,8 @@ else {
$infolder = ' IS NULL';
}
// todo: do this in the artefact file class.
$prefix = get_config('dbprefix');
$filedata = get_records_sql_array('SELECT a.id, a.artefacttype, a.mtime, f.size, a.title, a.description
FROM ' . $prefix . 'artefact a
......
<?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 artefact-file
* @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(dirname(__FILE__))) . '/init.php');
log_debug('updatemetadata');
try {
$id = param_integer('id');
$name = param_variable('name');
$description = param_variable('description');
}
catch (ParameterException $e) {
json_reply('missingparameter',get_string('missingparameter'));
}
require_once('artefact.php');
$artefact = artefact_instance_from_id($id);
$artefact->set('title',$name);
$artefact->set('description',$description);
$artefact->commit();
json_reply(false, get_string('changessaved'));
?>
......@@ -325,8 +325,9 @@ class ArtefactTypeProfileField extends ArtefactTypeProfile {
*/
public static function format_child_data($data, $pluginname) {
$res = new StdClass;
$res->id = "{$data->artefacttype}_{$data->id}";
$res->title = $data->title;
$res->id = $data->id;
$res->title = $data->title;
$res->isartefact = true;
if ($data->artefacttype == 'email') {
$res->text = get_string('email') . ' - ' . $data->title;
}
......
......@@ -72,7 +72,7 @@ MochiKit.DragAndDrop.Droppables = {
remove: function (element) {
this.drops = MochiKit.Base.filter(function (d) {
return d.element != MochiKit.DOM.getElement(element)
return d.element != MochiKit.DOM.getElement(element);
}, this.drops);
},
......@@ -333,7 +333,7 @@ MochiKit.DragAndDrop.Draggables = {
return d != draggable;
}, this.drags);
if (this.drags.length === 0) {
var disc = MochiKit.Signal.disconnect
var disc = MochiKit.Signal.disconnect;
disc(this.eventMouseUp);
disc(this.eventMouseMove);
disc(this.eventKeypress);
......@@ -519,7 +519,7 @@ MochiKit.DragAndDrop.Draggable.prototype = {
var pointer = event.mouse();
var pos = MochiKit.Position.cumulativeOffset(this.element);
this.offset = [pointer.page.x - pos.x, pointer.page.y - pos.y]
this.offset = [pointer.page.x - pos.x, pointer.page.y - pos.y];
MochiKit.DragAndDrop.Draggables.activate(this);
event.stop();
......@@ -691,7 +691,7 @@ MochiKit.DragAndDrop.Draggable.prototype = {
}
var p = [point.page.x - pos.x - this.offset[0],
point.page.y - pos.y - this.offset[1]]
point.page.y - pos.y - this.offset[1]];
if (this.options.snap) {
if (typeof(this.options.snap) == 'function') {
......@@ -702,13 +702,13 @@ MochiKit.DragAndDrop.Draggable.prototype = {
p = MochiKit.Base.map(MochiKit.Base.bind(function (v) {
i += 1;
return Math.round(v/this.options.snap[i]) *
this.options.snap[i]
}, this), p)
this.options.snap[i];
}, this), p);
} else {
p = MochiKit.Base.map(MochiKit.Base.bind(function (v) {
return Math.round(v/this.options.snap) *
this.options.snap
}, this), p)
this.options.snap;
}, this), p);
}
}
}
......@@ -755,9 +755,9 @@ MochiKit.DragAndDrop.Draggable.prototype = {
if (this.options.scroll == window) {
var s = this._getWindowScroll(this.options.scroll);
if (this.scrollSpeed[0] || this.scrollSpeed[1]) {
var d = delta / 1000;
this.options.scroll.scrollTo(s.left + d * this.scrollSpeed[0],
s.top + d * this.scrollSpeed[1]);
var dm = delta / 1000;
this.options.scroll.scrollTo(s.left + dm * this.scrollSpeed[0],
s.top + dm * this.scrollSpeed[1]);
}
} else {
this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
......@@ -785,20 +785,20 @@ MochiKit.DragAndDrop.Draggable.prototype = {
this.options.onchange(this);
},
_getWindowScroll: function (w) {
_getWindowScroll: function (win) {
var vp, w, h;
MochiKit.DOM.withWindow(w, function () {
vp = MochiKit.Style.getViewportPosition(w.document);
MochiKit.DOM.withWindow(win, function () {
vp = MochiKit.Style.getViewportPosition(win.document);
});
if (w.innerWidth) {
w = w.innerWidth;
h = w.innerHeight;
} else if (w.document.documentElement && w.document.documentElement.clientWidth) {
w = w.document.documentElement.clientWidth;
h = w.document.documentElement.clientHeight;
if (win.innerWidth) {
w = win.innerWidth;
h = win.innerHeight;
} else if (win.document.documentElement && win.document.documentElement.clientWidth) {
w = win.document.documentElement.clientWidth;
h = win.document.documentElement.clientHeight;
} else {
w = w.document.body.offsetWidth;
h = w.document.body.offsetHeight
w = win.document.body.offsetWidth;
h = win.document.body.offsetHeight;
}
return {top: vp.x, left: vp.y, width: w, height: h};
},
......
......@@ -389,7 +389,7 @@ MochiKit.Visual.tagifyText = function (element, /* optional */tagifyStyle) {
'position: relative'.
***/
var tagifyStyle = tagifyStyle || 'position:relative';
tagifyStyle = tagifyStyle || 'position:relative';
if (/MSIE/.test(navigator.userAgent)) {
tagifyStyle += ';zoom:1';
}
......@@ -469,7 +469,7 @@ Transitions: define functions calculating variations depending of a position.
***/
MochiKit.Visual.Transitions = {}
MochiKit.Visual.Transitions = {};
/** @id MochiKit.Visual.Transitions.linear */
MochiKit.Visual.Transitions.linear = function (pos) {
......@@ -498,7 +498,7 @@ MochiKit.Visual.Transitions.wobble = function (pos) {
/** @id MochiKit.Visual.Transitions.pulse */
MochiKit.Visual.Transitions.pulse = function (pos) {
return (Math.floor(pos*10) % 2 == 0 ?
return (Math.floor(pos*10) % 2 === 0 ?
(pos*10 - Math.floor(pos*10)) : 1 - (pos*10 - Math.floor(pos*10)));
};
......@@ -583,7 +583,7 @@ MochiKit.Base.update(MochiKit.Visual.ScopedQueue.prototype, {
/** @id MochiKit.Visual.ScopedQueue.prototype.startLoop */
startLoop: function (func, interval) {
return setInterval(func, interval)
return setInterval(func, interval);
},
/** @id MochiKit.Visual.ScopedQueue.prototype.remove */
......@@ -591,7 +591,7 @@ MochiKit.Base.update(MochiKit.Visual.ScopedQueue.prototype, {
this.effects = MochiKit.Base.filter(function (e) {
return e != effect;
}, this.effects);
if (this.effects.length == 0) {
if (!this.effects.length) {
this.stopLoop(this.interval);
this.interval = null;
}
......@@ -599,7 +599,7 @@ MochiKit.Base.update(MochiKit.Visual.ScopedQueue.prototype, {
/** @id MochiKit.Visual.ScopedQueue.prototype.stopLoop */
stopLoop: function (interval) {
clearInterval(interval)
clearInterval(interval);
},