Permalink
Browse files

Re-arranging function definition

  • Loading branch information...
1 parent 142ec51 commit eba6af755cc3ad681e23c98581bcfa98a0d43b85 @mrmark mrmark committed with mudrd8mz Mar 14, 2011
Showing with 14 additions and 13 deletions.
  1. +14 −13 backup/util/helper/convert_helper.class.php
@@ -39,8 +39,8 @@ public static function to_moodle2_format($tempdir, $format = NULL) {
*/
public static function set_inforef($contextid) {
global $DB;
-
-
+
+
}
public static function get_inforef($contextid) {
@@ -57,28 +57,29 @@ public static function obj_to_readable($obj) {
return implode(", ", array_map($mapper, array_keys($fields), array_values($fields)));
}
- public static function get_contextid($converterid, $itemid, $info='component') {
+ public static function get_contextid($instance, $component = 'moodle', $converterid = NULL) {
global $DB;
// Attempt to retrieve the contextid
- $context = $DB->get_record('backup_ids_temp', array('backupid' => $converterid,
- 'itemid' => $itemid));
-
- if($context) {
+ $context = $DB->get_record('backup_ids_temp', array('itemid' => $instance, 'info' => $component));
+
+ if ($context) {
return $context->id;
}
$context = new stdClass;
- $context->itemid = $itemid;
- $context->backupid = $converterid;
+ $context->itemid = $instance;
$context->itemname = 'context';
- $context->info = $info;
-
- if($id = $DB->insert('backup_ids_temp', $context)) {
+ $context->info = $component;
+
+ if (!is_null($converterid)) {
+ $context->backupid = $converterid;
+ }
+ if ($id = $DB->insert('backup_ids_temp', $context)) {
return $id;
} else {
$msg = self::obj_to_readable($context);
throw new Exception(sprintf("Could not insert context record into temp table: %s", $msg));
- }
+ }
}
}

0 comments on commit eba6af7

Please sign in to comment.