Commit 026df998 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Merge commit 'origin/master' into tagsearch

parents 65b0662c cfb5de94
......@@ -655,6 +655,7 @@ function get_public_key($uri, $application=null) {
if (strpos($uri, $host) !== false) {
return $keyarray[$uri];
}
throw new XmlrpcClientException('The remote site sent us a key that is valid for ' . $host . ' instead of their hostname (' . $uri . ')', 500);
}
} else {
throw new XmlrpcClientException($res['faultString'], $res['faultCode']);
......
......@@ -24,6 +24,11 @@
*
*/
/*
* For more information about blog LEAP export, see:
* http://wiki.mahara.org/Developer_Area/Import//Export/LEAP_Export/Blog_Artefact_Plugin
*/
defined('INTERNAL') || die();
class LeapExportElementBlogpost extends LeapExportElement {
......
......@@ -30,13 +30,11 @@ defined('INTERNAL') || die();
* Implements LEAP2A import of blog related entries into Mahara
*
* For more information about LEAP blog importing, see:
* http://wiki.mahara.org/Developer_Area/Import%2f%2fExport/LEAP_Import/Blog_Artefact_Plugin
* http://wiki.mahara.org/Developer_Area/Import//Export/LEAP_Import/Blog_Artefact_Plugin
*
* TODO:
* - Get entries that feel they're part of the blog, not just entries the blog feels are part of it
* - Import raw ATOM feed entries as blog posts
* - Provide a default strategy for importing anything into a 'miscellaneous' blog
* - Handle importing things that don't have inline entry content into a blogpost
*/
class LeapImportBlog extends LeapImportArtefactPlugin {
......@@ -50,16 +48,11 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
*/
const STRATEGY_IMPORT_AS_ENTRY = 2;
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImport $importer) {
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImportLeap $importer) {
$strategies = array();
// TODO: when the xpath has an error in it, count(error) == 1 also.. so should check return type
$correctrdftype = count($entry->xpath('rdf:type['
. $importer->curie_xpath('@rdf:resource', PluginImportLeap::NS_LEAPTYPE, 'selection') . ']')) == 1;
$correctcategoryscheme = count($entry->xpath('a:category[('
. $importer->curie_xpath('@scheme', PluginImportLeap::NS_CATEGORIES, 'selection_type#') . ') and @term="Blog"]')) == 1;
if ($correctrdftype && $correctcategoryscheme) {
if (PluginImportLeap::is_rdf_type($entry, $importer, 'selection')
&& PluginImportLeap::is_correct_category_scheme($entry, $importer, 'selection_type', 'Blog')) {
$otherrequiredentries = array();
// Get entries that this blog feels are a part of it
......@@ -92,7 +85,7 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
return $strategies;
}
public static function import_using_strategy(SimpleXMLElement $entry, PluginImport $importer, $strategy, array $otherentries) {
public static function import_using_strategy(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries) {
$artefactmapping = array();
switch ($strategy) {
case self::STRATEGY_IMPORT_AS_BLOG:
......@@ -142,7 +135,7 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
* If importing an entry resulted in importing a new file (caused by the
* entry having out-of-line content), we attach that file to the entry.
*/
public static function setup_relationships(SimpleXMLElement $entry, PluginImport $importer, $strategy, array $otherentries) {
public static function setup_relationships(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries) {
switch ($strategy) {
case self::STRATEGY_IMPORT_AS_BLOG:
foreach ($otherentries as $entryid) {
......@@ -249,9 +242,7 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
$blogpost->set('mtime', $updated);
}
$draftpost = count($entry->xpath('a:category[('
. $importer->curie_xpath('@scheme', PluginImportLeap::NS_CATEGORIES, 'readiness#')
. ') and @term="Unready"]')) == 1;
$draftpost = PluginImportLeap::is_correct_category_scheme($entry, $importer, 'readiness', 'Unready');
$blogpost->set('published', $draftpost ? 0 : 1);
$blogpost->set('owner', $importer->get('usr'));
......
......@@ -24,6 +24,11 @@
*
*/
/*
* For more information about file LEAP export, see:
* http://wiki.mahara.org/Developer_Area/Import//Export/LEAP_Export/File_Artefact_Plugin
*/
defined('INTERNAL') || die();
class LeapExportElementFile extends LeapExportElement {
......@@ -32,7 +37,7 @@ class LeapExportElementFile extends LeapExportElement {
public function add_links() {
parent::add_links();
// check for blog posts this file may be attached to
// Check for artefacts this file may be attached to
if (!$posts = get_records_array('artefact_attachment',
'attachment', $this->artefact->get('id'))) {
return;
......@@ -93,6 +98,13 @@ class LeapExportElementFolder extends LeapExportElement {
}
class LeapExportElementImage extends LeapExportElementFile { }
class LeapExportElementProfileIcon extends LeapExportElementFile { }
class LeapExportElementProfileIcon extends LeapExportElementFile {
public function add_links() {
parent::add_links();
$this->add_generic_link('artefactinternal', 'related');
}
}
?>
......@@ -30,7 +30,7 @@ defined('INTERNAL') || die();
* Implements LEAP2A import of file/folder related entries into Mahara
*
* For more information about LEAP file importing, see:
* http://wiki.mahara.org/Developer_Area/Import%2f%2fExport/LEAP_Import/File_Artefact_Plugin
* http://wiki.mahara.org/Developer_Area/Import//Export/LEAP_Import/File_Artefact_Plugin
*
* TODO:
* - Protect get_children_of_folder against circular references
......@@ -47,7 +47,7 @@ class LeapImportFile extends LeapImportArtefactPlugin {
*/
const STRATEGY_IMPORT_AS_FOLDER = 2;
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImport $importer) {
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImportLeap $importer) {
$strategies = array();
if (!self::has_parent_folder($entry, $importer)) {
......@@ -77,7 +77,7 @@ class LeapImportFile extends LeapImportArtefactPlugin {
// TODO: we're assuming an empty files area to work with, but that might
// not be the case, in which case we have conflicting file/folder names to
// deal with!
public static function import_using_strategy(SimpleXMLElement $entry, PluginImport $importer, $strategy, array $otherentries) {
public static function import_using_strategy(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries) {
$artefactmapping = array();
switch ($strategy) {
case self::STRATEGY_IMPORT_AS_FILE:
......@@ -99,35 +99,30 @@ class LeapImportFile extends LeapImportArtefactPlugin {
* if it's of rdf:type rdf:resource. This may be more strict than necessary
* - possibly just having the content ouf of line should be enough.
*
* @param SimpleXMLElement $entry The entry to check
* @param PluginImport $importer The importer
* @param SimpleXMLElement $entry The entry to check
* @param PluginImportLeap $importer The importer
* @return boolean Whether the entry is a file
*/
private static function is_file(SimpleXMLElement $entry, PluginImport $importer) {
$correctrdftype = count($entry->xpath('rdf:type['
. $importer->curie_xpath('@rdf:resource', PluginImportLeap::NS_LEAPTYPE, 'resource') . ']')) == 1;
$outoflinecontent = isset($entry->content['src']);
return $correctrdftype && $outoflinecontent;
private static function is_file(SimpleXMLElement $entry, PluginImportLeap $importer) {
return PluginImportLeap::is_rdf_type($entry, $importer, 'resource')
&& isset($entry->content['src']);
}
/**
* Returns whether the given entry is a folder
*
* @param SimpleXMLElement $entry The entry to check
* @param PluginImport $importer The importer
* @param SimpleXMLElement $entry The entry to check
* @param PluginImportLeap $importer The importer
* @return boolean Whether the entry is a folder
*/
private static function is_folder(SimpleXMLElement $entry, PluginImport $importer) {
private static function is_folder(SimpleXMLElement $entry, PluginImportLeap $importer) {
static $cache = array();
$id = (string)$entry->id;
if (isset($cache[$id])) {
return $cache[$id];
}
$correctrdftype = count($entry->xpath('rdf:type['
. $importer->curie_xpath('@rdf:resource', PluginImportLeap::NS_LEAPTYPE, 'selection') . ']')) == 1;
$correctcategoryscheme = count($entry->xpath('a:category[('
. $importer->curie_xpath('@scheme', PluginImportLeap::NS_CATEGORIES, 'selection_type#') . ') and @term="Folder"]')) == 1;
return ($cache[$id] = $correctrdftype && $correctcategoryscheme);
return ($cache[$id] = PluginImportLeap::is_rdf_type($entry, $importer, 'selection')
&& PluginImportLeap::is_correct_category_scheme($entry, $importer, 'selection_type', 'Folder'));
}
/**
......@@ -137,11 +132,11 @@ class LeapImportFile extends LeapImportArtefactPlugin {
* The entry itself can be any entry, although in the context of this
* plugin, it is a file or folder.
*
* @param SimpleXMLElement $entry The entry to check
* @param PluginImport $importer The importer
* @param SimpleXMLElement $entry The entry to check
* @param PluginImportLeap $importer The importer
* @return boolean Whether this entry is in a folder
*/
private static function has_parent_folder(SimpleXMLElement $entry, PluginImport $importer) {
private static function has_parent_folder(SimpleXMLElement $entry, PluginImportLeap $importer) {
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'is_part_of') && isset($link['href'])) {
$potentialfolder = $importer->get_entry_by_id((string)$link['href']);
......@@ -161,12 +156,12 @@ class LeapImportFile extends LeapImportArtefactPlugin {
*
* TODO: protection against circular references
*
* @param SimpleXMLElement $entry The folder to get children for
* @param PluginImport $importer The importer
* @param boolean $recurse Whether to return children at all levels below this folder
* @param SimpleXMLElement $entry The folder to get children for
* @param PluginImportLeap $importer The importer
* @param boolean $recurse Whether to return children at all levels below this folder
* @return array A list of the entry IDs of children in this folder
*/
private static function get_children_of_folder(SimpleXMLElement $entry, PluginImport $importer, $recurse=false) {
private static function get_children_of_folder(SimpleXMLElement $entry, PluginImportLeap $importer, $recurse=false) {
$children = array();
// Get entries that this folder feels are a part of it
......@@ -202,13 +197,13 @@ class LeapImportFile extends LeapImportArtefactPlugin {
/**
* Creates a file artefact based on the given entry.
*
* @param SimpleXMLElement $entry The entry to base the file's data on
* @param PluginImport $importer The importer
* @param int $parent The ID of the parent artefact for this file
* @param SimpleXMLElement $entry The entry to base the file's data on
* @param PluginImportLeap $importer The importer
* @param int $parent The ID of the parent artefact for this file
* @throws ImportException If the given entry is not detected as being a file
* @return ArtefactTypeFile The file artefact created
*/
public static function create_file(SimpleXMLElement $entry, PluginImport $importer, $parent=null) {
public static function create_file(SimpleXMLElement $entry, PluginImportLeap $importer, $parent=null) {
if (!self::is_file($entry, $importer)) {
throw new ImportException($importer, "create_file(): Cannot create a file artefact from an entry we don't recognise as a file");
}
......@@ -251,14 +246,23 @@ class LeapImportFile extends LeapImportArtefactPlugin {
throw new ImportException($importer, 'TODO: get_string: was unable to import file');
}
$artefact = artefact_instance_from_id($id);
// Work out if the file was really a profile icon
$isprofileicon = false;
$match = $entry->xpath('mahara:artefactplugin[@mahara:plugin="file" and @mahara:type="profileicon"]');
if (count($match) == 1) {
$isprofileicon = true;
if ($artefact->get('artefacttype') == 'image') {
$match = $entry->xpath('mahara:artefactplugin[@mahara:plugin="file" and @mahara:type="profileicon"]');
if (count($match) == 1) {
$isprofileicon = true;
}
else if ($importer->get('persondataid')) {
$persondata = $importer->get_entry_by_id($importer->get('persondataid'));
if (count($persondata->xpath('a:link[@rel="related" and @href="' . (string)$entry->id . '"]')) == 1) {
$isprofileicon = true;
}
}
}
$artefact = artefact_instance_from_id($id);
// Work around that save_file doesn't let us set the mtime
$artefact->set('mtime', strtotime((string)$entry->updated));
if ($isprofileicon) {
......@@ -274,10 +278,6 @@ class LeapImportFile extends LeapImportArtefactPlugin {
if (!rename($basedir . $olddir . $id, $basedir . $newdir . $id)) {
throw new ImportException($importer, 'TODO: get_string: was unable to move profile icon');
}
// Unconditionally set as default, even if there is more than one
$importer->get('usrobj')->profileicon = $id;
$importer->get('usrobj')->commit();
}
$artefact->commit();
......@@ -288,13 +288,13 @@ class LeapImportFile extends LeapImportArtefactPlugin {
/**
* Creates a folder artefact based on the given entry.
*
* @param SimpleXMLElement $entry The entry to base the folder's data on
* @param PluginImport $importer The importer
* @param int $parent The ID of the parent artefact for this folder
* @param SimpleXMLElement $entry The entry to base the folder's data on
* @param PluginImportLeap $importer The importer
* @param int $parent The ID of the parent artefact for this folder
* @throws ImportException If the given entry is not detected as being a folder
* @return int The ID of the folder artefact created
*/
private static function create_folder(SimpleXMLElement $entry, PluginImport $importer, $parent=null) {
private static function create_folder(SimpleXMLElement $entry, PluginImportLeap $importer, $parent=null) {
if (!self::is_folder($entry, $importer)) {
throw new ImportException($importer, "create_folder(): Cannot create a folder artefact from an entry we don't recognise as a folder");
}
......@@ -320,15 +320,15 @@ class LeapImportFile extends LeapImportArtefactPlugin {
/**
* Creates a folder, and recursively, all folders and files under it.
*
* @param SimpleXMLElement $entry The entry to base the folder's data on
* @param PluginImport $importer The importer
* @param int $parent The ID of the parent artefact for this folder
* @param SimpleXMLElement $entry The entry to base the folder's data on
* @param PluginImportLeap $importer The importer
* @param int $parent The ID of the parent artefact for this folder
* @throws ImportException If the given entry is not detected as being a folder
* @return array The artefact mapping for the folder and all children - a
* list of entry ID => artefact IDs for each entry processed. See
* PluginImport::import_from_load_mapping() for more information
*/
private static function create_folder_and_children(SimpleXMLElement $entry, PluginImport $importer, $parent=null) {
private static function create_folder_and_children(SimpleXMLElement $entry, PluginImportLeap $importer, $parent=null) {
if (!self::is_folder($entry, $importer)) {
throw new ImportException($importer, "create_folder(): Cannot create a folder artefact from an entry we don't recognise as a folder");
}
......
......@@ -1186,16 +1186,13 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
// name of the directory uses the site language rather than
// the language of the admin who first creates it.
$name = get_string_from_language(get_config('lang'), 'adminpublicdirname', 'admin');
$folderid = get_field_sql("
SELECT
a.id
FROM {artefact} a
INNER JOIN {artefact_file_files} f ON a.id = f.artefact
WHERE a.title = ?
AND a.artefacttype = ?
AND a.institution = 'mahara'
AND a.parent IS NULL", array($name, 'folder'));
if (!$folderid) {
$folders = get_records_select_array(
'artefact',
'title = ? AND artefacttype = ? AND institution = ? AND parent IS NULL',
array($name, 'folder', 'mahara'),
'id', 'id', 0, 1
);
if (!$folders) {
$description = get_string_from_language(get_config('lang'), 'adminpublicdirdescription', 'admin');
$data = (object) array('title' => $name,
'description' => $description,
......@@ -1204,25 +1201,21 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
$f->commit();
$folderid = $f->get('id');
}
return $folderid;
return $folders[0]->id;
}
public static function change_public_folder_name($oldlang, $newlang) {
$oldname = get_string_from_language($oldlang, 'adminpublicdirname', 'admin');
$folderid = get_field_sql("
SELECT
a.id
FROM {artefact} a
INNER JOIN {artefact_file_files} f ON a.id = f.artefact
WHERE a.title = ?
AND a.artefacttype = ?
AND a.institution = 'mahara'
AND a.parent IS NULL", array($oldname, 'folder'));
if (!$folderid) {
$folders = get_records_select_array(
'artefact',
'title = ? AND artefacttype = ? AND institution = ? AND parent IS NULL',
array($oldname, 'folder', 'mahara'),
'id', 'id', 0, 1
);
if (!$folders) {
return;
}
$folderid = $folders[0]->id;
$name = get_string_from_language($newlang, 'adminpublicdirname', 'admin');
$description = get_string_from_language($newlang, 'adminpublicdirdescription', 'admin');
if (!empty($name)) {
......
......@@ -24,9 +24,12 @@
*
*/
class LeapExportInternal extends LeapExportArtefactPlugin {
/*
* For more information about internal LEAP export, see:
* http://wiki.mahara.org/Developer_Area/Import//Export/LEAP_Export/Internal_Artefact_Plugin
*/
class LeapExportInternal extends LeapExportArtefactPlugin {
public function get_export_xml() {
$element = new LeapExportElementInternal($this->exporter, $this->artefacts);
return $element->get_export_xml();
......@@ -44,9 +47,11 @@ class LeapExportElementInternal extends LeapExportElement {
}
public function assign_smarty_vars() {
$user = $this->get('exporter')->get('user');
$userid = $user->get('id');
$this->smarty->assign('artefacttype', 'internal');
$this->smarty->assign('artefactplugin', 'internal');
$this->smarty->assign('title', display_name($this->get('exporter')->get('user'), $this->get('exporter')->get('user')));
$this->smarty->assign('title', display_name($user, $user));
// If this ID is changed, you'll have to change it in author.tpl too
$this->smarty->assign('id', 'portfolio:artefactinternal');
$this->smarty->assign('leaptype', $this->get_leap_type());
......@@ -82,6 +87,21 @@ class LeapExportElementInternal extends LeapExportElement {
}
$this->smarty->assign('persondata', $persondata);
$this->smarty->assign('spacialdata', $spacialdata);
// Grab profile icons and link to them, making sure the default is first
if ($icons = get_column_sql("SELECT id
FROM {artefact}
WHERE artefacttype = 'profileicon'
AND owner = ?
ORDER BY id = (
SELECT profileicon FROM {usr} WHERE id = ?
) DESC, id", array($userid, $userid))) {
foreach ($icons as $icon) {
$icon = artefact_instance_from_id($icon);
$this->add_artefact_link($icon, 'related');
}
$this->smarty->assign('links', $this->links);
}
}
public function get_template_path() {
......
<
......@@ -34,7 +34,6 @@ defined('INTERNAL') || die();
*
* TODO:
* - how do we want to handle potentially overwriting data?
* - We are exporting all services as field:id, not field:im - awaiting clarification on the list
* - Address for person (leap:spatial) - our export might have to be modified
* to output them in a more "correct" order for other systems
* - Validate the values of profile fields coming in? Especially email
......@@ -131,29 +130,21 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
);
/**
* 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 profile importer tries to import raw profile fields using the
* strategy mechanism, but most of the useful profile information is stored
* in the person entry corresponding to the author.
*
* 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.
* it's not present too. So all the person importing is handled in import_author_data()
*/
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImport $importer) {
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImportLeap $importer) {
$strategies = array();
// 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) {
if (PluginImportLeap::is_rdf_type($entry, $importer, 'entry') && $correctplugintype) {
$strategies[] = array(
'strategy' => self::STRATEGY_IMPORT_AS_PROFILE_FIELD,
'score' => 100,
......@@ -164,7 +155,7 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
return $strategies;
}
public static function import_using_strategy(SimpleXMLElement $entry, PluginImport $importer, $strategy, array $otherentries) {
public static function import_using_strategy(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries) {
$artefactmapping = array();
switch ($strategy) {
case self::STRATEGY_IMPORT_AS_PROFILE_FIELD:
......@@ -181,12 +172,7 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
if (count($artefactpluginelement) == 1) {
$artefactpluginelement = $artefactpluginelement[0];
$maharaattributes = array();
foreach ($artefactpluginelement->attributes(PluginImportLeap::NS_MAHARA)
as $key => $value) {
$maharaattributes[$key] = (string)$value;
}
$maharaattributes = PluginImportLeap::get_attributes($artefactpluginelement, PluginImportLeap::NS_MAHARA);
if (isset($maharaattributes['type']) && in_array($maharaattributes['type'], $types)) {
$artefactmapping[(string)$entry->id] = array(self::create_artefact($importer, $maharaattributes['type'], PluginImportLeap::get_entry_content($entry, $importer)));
}
......@@ -199,16 +185,18 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
}
/**
* Custom hook to import data about the feed author.
* Import data about the feed author.
*
* If we have a persondata element for them, we can import lots of
* different information about them into Mahara's profile section.
* Otherwise, we can only import some very basic information from the
* <author> element.
*
* @param PluginImport $importer The importer
* @param PluginImportLeap $importer The importer
* @param string $persondataid The ID of the person entry corresponding
* to the author, if there is one
*/
public static function import_author_data(PluginImport $importer, $persondataid) {
public static function import_author_data(PluginImportLeap $importer, $persondataid) {
if ($persondataid) {
// Grab all the leap:persondata elements and import them
$person = $importer->get_entry_by_id($persondataid);
......@@ -221,10 +209,7 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
// Most of the rest of the profile data comes from leap:persondata elements
$persondata = $person->xpath('leap:persondata');
foreach ($persondata as $item) {
$leapattributes = array();
foreach ($item->attributes(PluginImportLeap::NS_LEAP) as $key => $value) {
$leapattributes[$key] = (string)$value;
}
$leapattributes = PluginImportLeap::get_attributes($item, PluginImportLeap::NS_LEAP);
if (!isset($leapattributes['field'])) {
// 'Field' is required
......@@ -245,6 +230,24 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
if (count($addressdata) == 1) {
self::import_addressdata($importer, $addressdata[0]);
}
// Set default profile icon. We look at rel="related" links on this
// element, and take the first one that we turned into a profile
// icon to be the default. In future versions of the spec, we may use
// a "depicts" type relationship to explicitly identify them.
foreach ($person->link as $link) {
if ($importer->curie_equals($link['rel'], '', 'related') && isset($link['href'])) {
$artefactids = $importer->get_artefactids_imported_by_entryid((string)$link['href']);
if (count($artefactids) == 1 && $potentialicon = artefact_instance_from_id($artefactids[0])) {
if ($potentialicon->get('artefacttype') == 'profileicon') {
$importer->get('usrobj')->profileicon = $potentialicon->get('id');
$importer->get('usrobj')->commit();
// The first one we find in the export is the profile icon
break;
}
}
}
}
}
else {
$author = $importer->get('xml')->xpath('//a:feed/a:author[1]');
......@@ -281,7 +284,7 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
/**
* Attempts to import a persondata element
*/
private static function import_persondata(PluginImport $importer, SimpleXMLElement $item, array $leapattributes) {
private static function import_persondata(PluginImportLeap $importer, SimpleXMLElement $item, array $leapattributes) {
$field = $leapattributes['field'];
if (isset(self::$persondatafields[$field]['mahara_fieldname'])) {
......@@ -309,7 +312,7 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
/**
* Attempts to import a persondata field with leap:field="id"
*/
public static function import_persondata_id(PluginImport $importer, SimpleXMLElement $item, array $leapattributes) {
private static function import_persondata_id(PluginImportLeap $importer, SimpleXMLElement $item, array $leapattributes) {
if ($leapattributes['field'] == 'id' && !isset($leapattributes['service'])) {
// 'id' must have a service set
// http://wiki.cetis.ac.uk/2009-03/LEAP2A_personal_data#service
......@@ -331,15 +334,11 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
/**
* Attempts to import a persondata field with leap:field="website"
*/
private static function import_persondata_website(PluginImport $importer, SimpleXMLEntry $item, array $leapattributes) {
private static function import_persondata_website(PluginImportLeap $importer, SimpleXMLEntry $item, array $leapattributes) {
// We've been given a 'website' field, but Mahara has three profile
// fields for website. So we need to examine it deeper to establish
// which field it should import into
$maharaattributes = array();
foreach ($item->attributes(PluginImportLeap::NS_MAHARA)
as $key => $value) {
$maharaattributes[$key] = (string)$value;
}
$maharaattributes = PluginImportLeap::get_attributes($item, PluginImportLeap::NS_MAHARA);
if (isset($maharaattributes['artefactplugin'])
&& isset($maharaattributes['artefacttype'])
......@@ -367,14 +366,10 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
/**
* Attempts to import a persondata field with leap:field="other"
*/
private static function import_persondata_other(PluginImport $importer, SimpleXMLEntry $item, array $leapattributes) {
private static function import_persondata_other(PluginImportLeap $importer, SimpleXMLEntry $item, array $leapattributes) {
// The only 'other' field we can actually import is one we recognise as
// 'student ID'
$maharaattributes = array();
foreach ($item->attributes(PluginImportLeap::NS_MAHARA)
as $key => $value) {
$maharaattributes[$key] = (string)$value;
}
$maharaattributes = PluginImportLeap::get_attributes($item, PluginImportLeap::NS_MAHARA);
if (isset($maharaattributes['artefactplugin'])