Commit 95056fbe authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files
parents 94ff422c 04b6f4c0
......@@ -51,7 +51,7 @@ if ($oldid = ArtefactTypeFileBase::exists_in_db($data->title, $data->owner, $par
$obj->delete();
}
else {
json_reply('local', get_string('fileexists'));
json_reply('local', get_string('fileexists', 'artefact.file'));
}
}
......@@ -59,7 +59,7 @@ $f = new ArtefactTypeFolder(0, $data);
$f->set('dirty', true);
$f->commit();
json_reply(false, get_string('foldercreated'));
json_reply(false, get_string('foldercreated', 'artefact.file'));
?>
......@@ -39,6 +39,7 @@ require_once('artefact.php');
$artefact = artefact_instance_from_id($fileid);
$artefact->delete();
json_reply(false, get_string('filedeleted'));
json_reply(false, get_string('filethingdeleted', 'artefact.file',
get_string($artefact->get('artefacttype'), 'artefact.file')));
?>
......@@ -70,14 +70,14 @@ function FileBrowser(element, changedircallback) {
var name = $(formid).name.value;
if (isEmpty(name)) {
$(formid + 'message').innerHTML = get_string('namefieldisrequired');
return;
return false;
}
if (!replacefile && self.fileexists(name) && name != originalname) {
$(formid+'message').innerHTML = get_string('fileexistsoverwritecancel');
setDisplayForElement('inline', $(formid).replace);
//$(formid).name.value = newfilename(name, this.fileexists); // not a good idea yet.
$(formid).name.focus();
return;
return false;
}
$(formid+'message').innerHTML = '';
hideElement($(formid).replace);
......@@ -96,6 +96,7 @@ function FileBrowser(element, changedircallback) {
data['parentfolder'] = self.pathids[self.cwd];
}
sendjsonrequest(script, data, self.refresh);
return true;
}
this.openeditform = function(fileinfo) {
......@@ -104,7 +105,7 @@ function FileBrowser(element, changedircallback) {
var formid = editid + '_form';
var rowid = 'row_' + fileinfo.id;
var cancelform = function() {
setDisplayForElement(null, rowid);
setDisplayForElement('', rowid);
removeElement(editid);
};
var savebutton = INPUT({'type':'button','value':get_string('savechanges')});
......@@ -131,20 +132,25 @@ function FileBrowser(element, changedircallback) {
this.initcreatefolderform = function () {
var formid = 'createfolderform';
var cancelbutton = INPUT({'type':'button','value':get_string('cancel'), 'onclick':function () {
setDisplayForElement(null, self.createfolderbutton);
var cancelcreateform = function () {
setDisplayForElement('inline', self.createfolderbutton);
hideElement($(formid).replace);
$(formid).name.value = '';
$(formid).description.value = '';
$(formid+'message').innerHTML = '';
hideElement(formid);
}});
};
var cancelbutton = INPUT({'type':'button','value':get_string('cancel'), 'onclick':cancelcreateform});
var createbutton = INPUT({'type':'button','value':get_string('create'),'onclick':function () {
self.savemetadata(null, formid, false);
if (self.savemetadata(null, formid, false)) {
cancelcreateform();
}
}});
var replacebutton = INPUT({'type':'button', 'value':get_string('overwrite'),
'name':'replace', 'style':'display: none;', 'onclick':function() {
self.savemetadata(null, formid, true);
if (self.savemetadata(null, formid, true)) {
cancelcreateform();
}
}});
return FORM({'method':'post', 'id':formid, 'style':'display: none;'},
TABLE(null,
......
......@@ -47,6 +47,7 @@ function FileUploader(element, foldername, folderid, uploadcallback, fileexists)
if ($('uploadformmessage')) {
$('uploadformmessage').innerHTML = '';
}
self.form.notice.checked = '';
self.form.userfile.value = '';
self.form.title.value = '';
self.form.description.value = '';
......@@ -75,9 +76,9 @@ function FileUploader(element, foldername, folderid, uploadcallback, fileexists)
TR(null,TD({'colspan':2, 'id':'uploadformmessage'})),
TR(null,TD({'colspan':2},
INPUT({'name':'upload','type':'button','value':get_string('upload'),
'onclick':function () { self.sendform(false)}}),
'onclick':function () { if (self.sendform(false)) { cancelform(); } }}),
INPUT({'name':'replace','type':'button','value':get_string('overwrite'),
'onclick':function () { self.sendform(true); }}),
'onclick':function () { if (self.sendform(true)) { cancelform(); } }}),
INPUT({'type':'button','value':get_string('cancel'),'onclick':cancelform}))))));
hideElement(form.replace);
......@@ -96,17 +97,17 @@ function FileUploader(element, foldername, folderid, uploadcallback, fileexists)
this.sendform = function (replacefile) {
if (!self.form.notice.checked) {
$('uploadformmessage').innerHTML = get_string('youmustagreetothecopyrightnotice');
return;
return false;
}
var localname = self.form.userfile.value;
if (isEmpty(localname)) {
$('uploadformmessage').innerHTML = get_string('filenamefieldisrequired');
return;
return false;
}
var destname = self.form.title.value;
if (isEmpty(destname)) {
$('uploadformmessage').innerHTML = get_string('titlefieldisrequired');
return;
return false;
}
localname = self.filepart(localname);
if (!replacefile && self.fileexists(destname)) {
......@@ -114,7 +115,7 @@ function FileUploader(element, foldername, folderid, uploadcallback, fileexists)
// Show replace button
setDisplayForElement('inline', self.form.replace);
self.form.title.focus();
return;
return false;
}
$('uploadformmessage').innerHTML = '';
hideElement(self.form.replace);
......@@ -140,21 +141,20 @@ function FileUploader(element, foldername, folderid, uploadcallback, fileexists)
// Display upload status
insertSiblingNodesBefore(self.form,
DIV({'id':'uploadstatusline'+self.nextupload}, IMG({'src':config.themeurl+'loading.gif'}),
get_string('uploading',[localname,self.foldername,destname])));
get_string('uploadingfiletofolder',localname,self.foldername)));
self.nextupload += 1;
return true;
}
this.getresult = function(data) {
if (!data.error) {
var image = 'success.gif';
var message = get_string('uploadcomplete');
}
else {
var image = 'failure.gif';
var message = get_string('uploadfailed');
}
replaceChildNodes($('uploadstatusline'+data.uploadnumber),
IMG({'src':config.themeurl+image}), message);
IMG({'src':config.themeurl+image}), data.message);
this.uploadcallback();
}
......
......@@ -26,21 +26,25 @@
defined('INTERNAL') || die();
$string['changessaved'] = 'Changes saved';
$string['copyrightnotice'] = 'Copyright notice';
$string['create'] = 'Create';
$string['createfolder'] = 'Create folder';
$string['deletefile?'] = 'Are you sure you want to delete this file?';
$string['deletefolderandcontents?'] = 'Are you sure you want to delete this folder and all its contents?';
$string['deletefolder?'] = 'Are you sure you want to delete this folder?';
$string['description'] = 'Description';
$string['destination'] = 'Destination';
$string['editfile'] = 'Edit file';
$string['editfolder'] = 'Edit folder';
$string['file'] = 'File';
$string['fileexistsoverwritecancel'] = 'A file with that name already exists. You can rename the file you are about to upload, or overwrite the existing file.';
$string['fileexists'] = 'File exists';
$string['filethingdeleted'] = '%s deleted';
$string['fileexistsoverwritecancel'] = 'A file with that name already exists. You can try a different name, or overwrite the existing file.';
$string['filenamefieldisrequired'] = 'The file field is required';
$string['folder'] = 'folder';
$string['folder'] = 'Folder';
$string['foldercreated'] = 'Folder created';
$string['home'] = 'Home';
$string['image'] = 'image';
$string['image'] = 'Image';
$string['myfiles'] = 'My Files';
$string['name'] = 'Name';
$string['namefieldisrequired'] = 'The name field is required';
......@@ -51,11 +55,11 @@ $string['size'] = 'Size';
$string['title'] = 'Name';
$string['titlefieldisrequired'] = 'The name field is required';
$string['upload'] = 'Upload';
$string['uploadcomplete'] = 'Upload complete';
$string['uploadfailed'] = 'Upload failed';
$string['uploadoffilecomplete'] = 'Upload of %s complete';
$string['uploadoffilefailed'] = 'Upload of %s failed';
$string['uploadfile'] = 'Upload file';
$string['uploadfileexistsoverwritecancel'] = 'A file with that name already exists. You can rename the file you are about to upload, or overwrite the existing file.';
$string['uploading'] = 'Uploading';
$string['uploadingfiletofolder'] = 'Uploading %s to %s';
$string['youmustagreetothecopyrightnotice'] = 'You must agree to the copyright notice';
?>
......@@ -66,43 +66,49 @@ class PluginArtefactFile extends PluginArtefact {
public static function jsstrings($type) {
static $jsstrings = array(
'uploader' => array(
'cancel' => 'mahara',
'copyrightnotice' => 'artefact.file',
'description' => 'artefact.file',
'destination' => 'artefact.file',
'file' => 'artefact.file',
'filenamefieldisrequired' => 'artefact.file',
'home' => 'artefact.file',
'overwrite' => 'artefact.file',
'title' => 'artefact.file',
'titlefieldisrequired' => 'artefact.file',
'upload' => 'artefact.file',
'uploadcomplete' => 'artefact.file',
'uploadfailed' => 'artefact.file',
'uploadfile' => 'artefact.file',
'uploadfileexistsoverwritecancel' => 'artefact.file',
'uploading' => 'artefact.file',
'youmustagreetothecopyrightnotice' => 'artefact.file',
'mahara' => array(
'cancel' => 'mahara',
),
'artefact.file' => array(
'copyrightnotice',
'description',
'destination',
'file',
'filenamefieldisrequired',
'home',
'overwrite',
'title',
'titlefieldisrequired',
'upload',
'uploadfile',
'uploadfileexistsoverwritecancel',
'uploadingfiletofolder',
'youmustagreetothecopyrightnotice',
),
),
'filebrowser' => array(
'cancel' => 'mahara',
'create' => 'artefact.file',
'createfolder' => 'artefact.file',
'delete' => 'mahara',
'deletefile?' => 'artefact.file',
'deletefolder?' => 'artefact.file',
'description' => 'artefact.file',
'destination' => 'artefact.file',
'edit' => 'mahara',
'editfile' => 'artefact.file',
'editfolder' => 'artefact.file',
'fileexistsoverwritecancel' => 'artefact.file',
'home' => 'artefact.file',
'name' => 'artefact.file',
'namefieldisrequired' => 'artefact.file',
'nofilesfound' => 'artefact.file',
'overwrite' => 'artefact.file',
'savechanges' => 'artefact.file',
'mahara' => array(
'cancel',
'delete',
'edit',
),
'artefact.file' => array(
'create',
'createfolder',
'deletefile?',
'deletefolder?',
'description',
'destination',
'editfile',
'editfolder',
'fileexistsoverwritecancel',
'home',
'name',
'namefieldisrequired',
'nofilesfound',
'overwrite',
'savechanges',
),
)
);
return $jsstrings[$type];
......
......@@ -30,8 +30,6 @@ safe_require('artefact', 'file');
require_once('artefact.php');
global $USER;
log_debug('updatemetadata');
$parentfolder = param_variable('parentfolder', null); // id of parent artefact
$id = param_integer('id');
$name = param_variable('name');
......@@ -46,7 +44,7 @@ if ($existingid = ArtefactTypeFileBase::exists_in_db($name, $USER->get('id'), $p
$copy->delete();
}
else {
json_reply('local', get_string('fileexists'));
json_reply('local', get_string('fileexists', 'artefact.file'));
}
}
......@@ -55,6 +53,6 @@ $artefact->set('title',$name);
$artefact->set('description',$description);
$artefact->commit();
json_reply(false, get_string('changessaved'));
json_reply(false, get_string('changessaved', 'artefact.file'));
?>
......@@ -62,9 +62,13 @@ if (!isset($result->error)) {
$f = new ArtefactTypeFile(0, $data);
if ($f->save_uploaded_file('userfile')) {
$result->error = false;
$result->message = get_string('uploadoffilecomplete', 'artefact.file',
$f->get('title'));
}
else {
$result->error = 'uploadfailed';
$result->message = get_string('uploadoffilefailed', 'artefact.file',
$f->get('title'));
}
}
......
......@@ -71,6 +71,20 @@ class PluginArtefactInternal extends PluginArtefact {
);
}
public static function get_cron() {
return array(
(object)array(
'callfunction' => 'clean_email_validations',
'hour' => '4',
'minute' => '10',
),
);
}
public static function clean_email_validations() {
delete_records_select('artefact_internal_profile_email', 'verified=0 AND expiry IS NOT NULL AND expiry < ?', array(db_format_timestamp(time())));
}
public static function get_toplevel_artefact_types() {
return array('profile');
}
......
......@@ -173,7 +173,7 @@ $string['forgotpassemailmessagehtml'] = '<p>Dear %s,</p>
<p><a href="' . get_config('wwwroot') . 'forgotpass.php?key=%s">' . get_config('wwwroot') . 'forgotpass.php?key=%s</a></p>';
$string['forgotpassemailsendunsuccessful'] = 'Sorry, it appears that the e-mail could not be sent successfully. This is our fault, please try again shortly';
$string['forgotpassnosuchemailaddress'] = 'The email address you entered doesn\'t any users for this site';
$string['forgotpassnosuchemailaddress'] = 'The email address you entered doesn\'t match any users for this site';
$string['nosuchpasswordrequest'] = 'No such password request';
$string['passwordchangedok'] = 'Your password was successfully changed';
......
......@@ -713,7 +713,7 @@ class Plugin {
/**
* This function returns an array of crons it wants to have run
* Each item should be a StdtClass object containing -
* Each item should be a StdClass object containing -
* - callfunction (static function on the Plugin Class)
* - any or all of minute, hour, day, month, dayofweek
* (will default to * if not supplied)
......
......@@ -117,9 +117,9 @@ EOF;
if (strpos($jsfile, '/') === false) {
$javascript_array[] = $jsroot . $jsfile . '.js';
if (isset($jsstrings[$jsfile])) {
foreach ($jsstrings[$jsfile] as $string => $section) {
if (!isset($strings[$string])) {
$strings[$string] = get_raw_string($string, $section);
foreach ($jsstrings[$jsfile] as $section => $tags) {
foreach ($tags as $tag) {
$strings[$tag] = get_raw_string($tag, $section);
}
}
}
......@@ -136,9 +136,9 @@ EOF;
if (is_callable(array($pluginclass, 'jsstrings'))) {
$name = substr($bits[3], 0, strpos($bits[3], '.js'));
$tempstrings = call_static_method($pluginclass, 'jsstrings', $name);
foreach ($tempstrings as $string => $section) {
if (!isset($strings[$string])) {
$strings[$string] = get_raw_string($string, $section);
foreach ($tempstrings as $section => $tags) {
foreach ($tags as $tag) {
$strings[$tag] = get_raw_string($tag, $section);
}
}
}
......@@ -149,9 +149,9 @@ EOF;
$javascript_array[] = $jsroot . 'mahara.js';
$javascript_array[] = $jsroot . 'debug.js';
foreach ($jsstrings['mahara'] as $string => $section) {
if (!isset($strings[$string])) {
$strings[$string] = get_raw_string($string, $section);
foreach ($jsstrings['mahara'] as $section => $tags) {
foreach ($tags as $tag) {
$strings[$tag] = get_raw_string($tag, $section);
}
}
......@@ -198,23 +198,27 @@ EOF;
/**
* Returns the lists of strings used in the .js files
* @return array
* @return array
*/
function jsstrings() {
return array(
'mahara' => array(
'namedfieldempty' => 'mahara',
'processingform' => 'mahara',
'requiredfieldempty' => 'mahara',
'unknownerror' => 'mahara',
'loading' => 'mahara',
'mahara' => array( // js file
'mahara' => array( // section
'namedfieldempty', // string name
'processingform',
'requiredfieldempty',
'unknownerror',
'loading',
),
),
'tablerenderer' => array(
'firstpage' => 'mahara',
'nextpage' => 'mahara',
'prevpage' => 'mahara',
'lastpage' => 'mahara',
'mahara' => array(
'firstpage',
'nextpage',
'prevpage',
'lastpage',
)
)
);
}
......
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