Skip to content

Commit

Permalink
Re-arranging function definition
Browse files Browse the repository at this point in the history
  • Loading branch information
polothy authored and mudrd8mz committed May 10, 2011
1 parent 142ec51 commit eba6af7
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions backup/util/helper/convert_helper.class.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public static function to_moodle2_format($tempdir, $format = NULL) {
*/ */
public static function set_inforef($contextid) { public static function set_inforef($contextid) {
global $DB; global $DB;


} }


public static function get_inforef($contextid) { public static function get_inforef($contextid) {
Expand All @@ -57,28 +57,29 @@ public static function obj_to_readable($obj) {
return implode(", ", array_map($mapper, array_keys($fields), array_values($fields))); 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; global $DB;


// Attempt to retrieve the contextid // Attempt to retrieve the contextid
$context = $DB->get_record('backup_ids_temp', array('backupid' => $converterid, $context = $DB->get_record('backup_ids_temp', array('itemid' => $instance, 'info' => $component));
'itemid' => $itemid));

if ($context) {
if($context) {
return $context->id; return $context->id;
} }


$context = new stdClass; $context = new stdClass;
$context->itemid = $itemid; $context->itemid = $instance;
$context->backupid = $converterid;
$context->itemname = 'context'; $context->itemname = 'context';
$context->info = $info; $context->info = $component;


if($id = $DB->insert('backup_ids_temp', $context)) { if (!is_null($converterid)) {
$context->backupid = $converterid;
}
if ($id = $DB->insert('backup_ids_temp', $context)) {
return $id; return $id;
} else { } else {
$msg = self::obj_to_readable($context); $msg = self::obj_to_readable($context);
throw new Exception(sprintf("Could not insert context record into temp table: %s", $msg)); throw new Exception(sprintf("Could not insert context record into temp table: %s", $msg));
} }
} }
} }

0 comments on commit eba6af7

Please sign in to comment.