New method get_stash_itemids()

This will be useful to build inforef.xml files.
This commit is contained in:
David Mudrak 2011-05-20 09:40:47 +02:00
parent 01b922fe70
commit 6d73f18573
2 changed files with 29 additions and 0 deletions

View File

@ -410,6 +410,23 @@ class moodle1_converter extends base_converter {
}
}
/**
* Returns the list of stashed $itemids in the given stash
*
* @param string $stashname
* @return array
*/
public function get_stash_itemids($stashname) {
global $DB;
$search = array(
'backupid' => $this->get_id(),
'itemname' => $stashname
);
return array_keys($DB->get_records('backup_ids_temp', $search, '', 'itemid'));
}
/**
* Generates an artificial context id
*

View File

@ -108,6 +108,18 @@ class moodle1_converter_test extends UnitTestCase {
$this->assertIdentical('Hello', $converter->get_stash('tempinfo', 1));
$this->assertIdentical('World', $converter->get_stash('tempinfo', 2));
// test get_stash_itemids()
$ids = $converter->get_stash_itemids('course_fileref');
$this->assertIsA($ids, 'array');
$this->assertTrue(empty($ids));
$converter->set_stash('course_fileref', null, 34);
$converter->set_stash('course_fileref', null, 52);
$ids = $converter->get_stash_itemids('course_fileref');
$this->assertEqual(2, count($ids));
$this->assertTrue(in_array(34, $ids));
$this->assertTrue(in_array(52, $ids));
$converter->drop_stash_storage();
}