Commit 1547164e authored by Adrian Schlegel's avatar Adrian Schlegel
Browse files

The importer now checks if the version of the uploaded LEAP2A file


is supported by Mahara.
Signed-off-by: default avatarAdrian Schlegel <adrian@liip.ch>
parent 945b78a9
......@@ -53,6 +53,9 @@ class PluginImportLeap extends PluginImport {
protected $leap2anamespace = null;
protected $leap2atypenamespace = null;
protected $leap2acategories = null;
// the version is stored with the full url since the url might change in
// future versions (as it has between 2009-03 and 2010-07)
protected $supportedleap2aversions = array('http://www.leapspecs.org/2010-07/2A/');
private $snapshots = array();
......@@ -143,12 +146,22 @@ class PluginImportLeap extends PluginImport {
*
*/
private function detect_leap2a_namespace () {
// check for the leap2a version used
$leap2 = false;
if(in_array('leap2', $this->namespaces)) {
$leap2 = true;
// disable xml warnings. The initial LEAP2A spec hasn't got the leap2
// namespace so the following xpath expression triggers a warning
// which we want to suppress.
$oldvalue = libxml_use_internal_errors(true);
$version = $this->xml->xpath('//leap2:version');
libxml_use_internal_errors($oldvalue);
// if there is no version string we assume the first version of the
// LEAP2A spec which doesn't contain the version element
if(!empty($version) && !in_array($version[0][0], $this->supportedleap2aversions)) {
throw new ImportException($this, "FATAL: The version of the uploaded LEAP2A file is not supported by this Mahara version");
}
if($leap2) {
if($version) {
$this->leap2anamespace = self::NS_LEAP;
$this->leap2atypenamespace = self::NS_LEAP;
$this->leap2acategories = self::NS_CATEGORIES;
......
......@@ -518,7 +518,7 @@ $string['failedtoobtainuploadedleapfile'] = 'Failed to obtain the uploaded Leap2
$string['failedtounzipleap2afile'] = 'Failed to unzip the Leap2A file. Check the error log for more information';
$string['fileisnotaziporxmlfile'] = 'This file has not been detected to be a zipfile or XML file';
$string['howdoyouwanttocreatethisuser'] = 'How do you want to create this user?';
$string['leap2aimportfailed'] = '<p><strong>Sorry - Importing the Leap2A file failed.</strong></p><p>This could be because you did not select a valid Leap2A file to upload. Alternatively, there may be a bug in Mahara causing your file to fail, even though it is valid.</p><p>Please <a href="add.php">go back and try again</a>, and if the problem persists, you may want to post to the <a href="http://mahara.org/forums/">Mahara Forums</a> to ask for help. Be prepared to be asked for a copy of your file!</p>';
$string['leap2aimportfailed'] = '<p><strong>Sorry - Importing the Leap2A file failed.</strong></p><p>This could be because you did not select a valid Leap2A file to upload or because the version of your LEAP2A file is not supported by this Mahara version. Alternatively, there may be a bug in Mahara causing your file to fail, even though it is valid.</p><p>Please <a href="add.php">go back and try again</a>, and if the problem persists, you may want to post to the <a href="http://mahara.org/forums/">Mahara Forums</a> to ask for help. Be prepared to be asked for a copy of your file!</p>';
$string['newuseremailnotsent'] = 'Failed to send welcome email to new user.';
$string['newusercreated'] = 'New user account created successfully';
$string['noleap2axmlfiledetected'] = 'No leap2a.xml file detected - please check your export file again';
......
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