/** * The profile importer has two strategies it can use for certain entries. * * The profile importer attempts to "reserve" the persondata entry * representing the user being imported (if one exists). * * The persondata entry is not actually imported using a strategy, because * we need to be able to import basic data from the <author> element if * it's not present too. So all the importing is handled in one custom hook * - import_author_data() * * The importer also tries to reserve raw entries with mahara:plugin="internal" * - these can be used to populate some of our profile fields that aren't * explicitly mapped in LEAP2A. */ public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImport $importer) { $strategies = array(); if (is_null(self::$persondataid)) { $author = $importer->get('xml')->xpath('//a:feed/a:author[1]'); $author = $author[0]; if (isset($author->uri) && $importer->get_entry_by_id((string) $author->uri)) { self::$persondataid = (string) $author->uri; } else { self::$persondataid = false; } } // TODO: also check other element has the right leaptype (person) //$correctrdftype = count($entry->xpath('rdf:type[' // . $importer->curie_xpath('@rdf:resource', PluginImportLeap::NS_LEAPTYPE, 'selection') . ']')) == 1; if ((string) $entry->id == self::$persondataid) { $strategies[] = array('strategy' => self::STRATEGY_DUMMY, 'score' => 100, 'other_required_entries' => array()); } else { // If it's a raw entry with the right mahara:plugin and mahara:type // we should be able to import it $correctrdftype = count($entry->xpath('rdf:type[' . $importer->curie_xpath('@rdf:resource', PluginImportLeap::NS_LEAPTYPE, 'entry') . ']')) == 1; $correctplugintype = count($entry->xpath('mahara:artefactplugin[@mahara:plugin="internal"]')) == 1; if ($correctrdftype && $correctplugintype) { $strategies[] = array('strategy' => self::STRATEGY_IMPORT_AS_PROFILE_FIELD, 'score' => 100, 'other_required_entries' => array()); } } return $strategies; }