mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
New method get_stash_itemids()
This will be useful to build inforef.xml files.
This commit is contained in:
parent
01b922fe70
commit
6d73f18573
2 changed files with 29 additions and 0 deletions
|
@ -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
|
* Generates an artificial context id
|
||||||
*
|
*
|
||||||
|
|
|
@ -108,6 +108,18 @@ class moodle1_converter_test extends UnitTestCase {
|
||||||
$this->assertIdentical('Hello', $converter->get_stash('tempinfo', 1));
|
$this->assertIdentical('Hello', $converter->get_stash('tempinfo', 1));
|
||||||
$this->assertIdentical('World', $converter->get_stash('tempinfo', 2));
|
$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();
|
$converter->drop_stash_storage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue