Skip to content
Snippets Groups Projects
Commit 79b1cbaf authored by srosse's avatar srosse
Browse files

OO-1742: limit the upload to zip and pdf and show an error if the upload doesn't succeed

parent f59d1894
No related branches found
No related tags found
No related merge requests found
...@@ -150,8 +150,6 @@ public class CertificatesManagerImpl implements CertificatesManager, MessageList ...@@ -150,8 +150,6 @@ public class CertificatesManagerImpl implements CertificatesManager, MessageList
@Autowired @Autowired
private RepositoryManager repositoryManager; private RepositoryManager repositoryManager;
@Autowired @Autowired
private NotificationsManager notificationsManager;
@Autowired
private BusinessGroupService businessGroupService; private BusinessGroupService businessGroupService;
@Autowired @Autowired
private BusinessGroupRelationDAO businessGroupRelationDao; private BusinessGroupRelationDAO businessGroupRelationDao;
...@@ -961,6 +959,8 @@ public class CertificatesManagerImpl implements CertificatesManager, MessageList ...@@ -961,6 +959,8 @@ public class CertificatesManagerImpl implements CertificatesManager, MessageList
} else { } else {
template = null; template = null;
} }
} else {
template = null;
} }
return template; return template;
} }
......
...@@ -154,6 +154,8 @@ public class CertificateChooserController extends UploadCertificateController { ...@@ -154,6 +154,8 @@ public class CertificateChooserController extends UploadCertificateController {
if(validateTemplate()) { if(validateTemplate()) {
doUpload(ureq); doUpload(ureq);
} }
} else if(fileEl == source) {
validateTemplate();
} }
super.formInnerEvent(ureq, source, event); super.formInnerEvent(ureq, source, event);
} }
...@@ -163,6 +165,9 @@ public class CertificateChooserController extends UploadCertificateController { ...@@ -163,6 +165,9 @@ public class CertificateChooserController extends UploadCertificateController {
if(template != null) { if(template != null) {
String name = fileEl.getUploadFileName(); String name = fileEl.getUploadFileName();
selectedTemplate = certificatesManager.addTemplate(name, template, getFormat(), getOrientation(), false); selectedTemplate = certificatesManager.addTemplate(name, template, getFormat(), getOrientation(), false);
if(selectedTemplate == null) {
showError("upload.wrong.mimetype");
}
fireEvent(ureq, Event.DONE_EVENT); fireEvent(ureq, Event.DONE_EVENT);
} }
} }
......
...@@ -171,6 +171,9 @@ public class UploadCertificateController extends FormBasicController { ...@@ -171,6 +171,9 @@ public class UploadCertificateController extends FormBasicController {
allOk = validatePdf(template); allOk = validatePdf(template);
} else if(filename.endsWith(".zip")) { } else if(filename.endsWith(".zip")) {
allOk = validateHtml(filename, template); allOk = validateHtml(filename, template);
} else {
fileEl.setErrorKey("upload.wrong.mimetype", null);
allOk &= false;
} }
} }
......
...@@ -45,6 +45,7 @@ upload.unkown.error=Die Vorlage kann nicht gelesen werden. ...@@ -45,6 +45,7 @@ upload.unkown.error=Die Vorlage kann nicht gelesen werden.
upload.error.noindex=Die ZIP-Datei enth\u00E4lt keine "index.html" Datei. upload.error.noindex=Die ZIP-Datei enth\u00E4lt keine "index.html" Datei.
upload.error.simplefonts=Der in den Feldern verwendete Font konnte nicht gefunden werden. Bitte benutzen Sie Standardfonts wie z.B. Helvetica, sowie die Acrobat Pro Software, um die Formularfelder zu erstellen. upload.error.simplefonts=Der in den Feldern verwendete Font konnte nicht gefunden werden. Bitte benutzen Sie Standardfonts wie z.B. Helvetica, sowie die Acrobat Pro Software, um die Formularfelder zu erstellen.
upload.error.no.phantomjs=PhantomJS ist nicht verf\u00FCgbar in PATH. HTML template k\u00F6nnen nicht benutzt werden. upload.error.no.phantomjs=PhantomJS ist nicht verf\u00FCgbar in PATH. HTML template k\u00F6nnen nicht benutzt werden.
upload.wrong.mimetype=Vorlagen k\u00F6nnen nur als ZIP-Datei oder im PDF-Vorlagenformat hochgeladen werden
notifications.title=Neue Zertifikate in Kurs "{0}" notifications.title=Neue Zertifikate in Kurs "{0}"
notifications.desc={0} hat ein neues Zertifikat erhalten. notifications.desc={0} hat ein neues Zertifikat erhalten.
notifications.header=Neue Zertifikate in Kurs "{0}" notifications.header=Neue Zertifikate in Kurs "{0}"
......
...@@ -60,5 +60,6 @@ upload.error.encrypted=The template cannot be encrypted. ...@@ -60,5 +60,6 @@ upload.error.encrypted=The template cannot be encrypted.
upload.error.no.phantomjs=PhantomJS is not in PATH. You cannot use HTML templates. upload.error.no.phantomjs=PhantomJS is not in PATH. You cannot use HTML templates.
upload.error.noindex=The ZIP file doesn't include a "index.html" file. upload.error.noindex=The ZIP file doesn't include a "index.html" file.
upload.error.simplefonts=The font(s) used in the form fields could not be found. Please use standard fonts such as e.g. Helvetica, as well as the Acrobat Pro Software in order to create the form fields. upload.error.simplefonts=The font(s) used in the form fields could not be found. Please use standard fonts such as e.g. Helvetica, as well as the Acrobat Pro Software in order to create the form fields.
upload.wrong.mimetype=Templates may only be uploaded as either .zip file or in the correct PDF template format.
upload.title=Upload template upload.title=Upload template
upload.unkown.error=The template cannot be opened. upload.unkown.error=The template cannot be opened.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment