Commit 24f12a18 authored by Penny Leach's avatar Penny Leach
Browse files

leap2a - add the ability to skip importing persondata.



this is useful for importing data over mnet, but also potentially in the
future when we can import leap data into existing user accounts
Signed-off-by: default avatarPenny Leach <penny@mjollnir.org>
parent 58d16fd4
...@@ -320,7 +320,20 @@ function send_content_ready($token, $username, $format, $importdata, $fetchnow=f ...@@ -320,7 +320,20 @@ function send_content_ready($token, $username, $format, $importdata, $fetchnow=f
throw new ImportException(null, "Queue record has expired"); throw new ImportException(null, "Queue record has expired");
} }
$class = null;
try {
$class = PluginImport::class_from_format($format);
} catch (Exception $e) {
throw new ImportException(null, "Invalid format $format");
}
$queue->format = $format; $queue->format = $format;
if ($class == 'PluginImportLeap') {
// don't import persondata over mnet
// because it will just silently overwrite stuff
// which is not really desirable.
$importdata['skippersondata'] = true;
}
$queue->data = serialize($importdata); $queue->data = serialize($importdata);
update_record('import_queue', $queue); update_record('import_queue', $queue);
$tr = new MnetImporterTransport($queue); $tr = new MnetImporterTransport($queue);
...@@ -331,12 +344,6 @@ function send_content_ready($token, $username, $format, $importdata, $fetchnow=f ...@@ -331,12 +344,6 @@ function send_content_ready($token, $username, $format, $importdata, $fetchnow=f
} }
$class = null;
try {
$class = PluginImport::class_from_format($format);
} catch (Exception $e) {
throw new ImportException(null, "Invalid format $format");
}
if (!array_key_exists('totalsize', $importdata)) { if (!array_key_exists('totalsize', $importdata)) {
throw new ImportException(null, 'Invalid importdata: missing totalsize'); throw new ImportException(null, 'Invalid importdata: missing totalsize');
......
...@@ -383,10 +383,12 @@ class PluginImportLeap extends PluginImport { ...@@ -383,10 +383,12 @@ class PluginImportLeap extends PluginImport {
// persondata entry // persondata entry
// TODO: this should return an artefact mapping so things can create // TODO: this should return an artefact mapping so things can create
// links to profile fields, but nothing actually needs it yet // links to profile fields, but nothing actually needs it yet
foreach (plugins_installed('artefact') as $plugin) { if (!array_key_exists('skippersondata', $this->data) || $this->data['skippersondata'] !== true) {
$classname = 'LeapImport' . ucfirst($plugin->name); foreach (plugins_installed('artefact') as $plugin) {
if (method_exists($classname, 'import_author_data')) { $classname = 'LeapImport' . ucfirst($plugin->name);
call_static_method($classname, 'import_author_data', $this, $this->persondataid); if (method_exists($classname, 'import_author_data')) {
call_static_method($classname, 'import_author_data', $this, $this->persondataid);
}
} }
} }
......
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