本文整理汇总了PHP中backup_getid函数的典型用法代码示例。如果您正苦于以下问题:PHP backup_getid函数的具体用法?PHP backup_getid怎么用?PHP backup_getid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了backup_getid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: webscheme_restore_mods
function webscheme_restore_mods($mod, $restore)
{
global $CFG;
$status = true;
//Get record from backup_ids
$data = backup_getid($restore->backup_unique_code, $mod->modtype, $mod->id);
if ($data) {
//Now get completed xmlized object
$info = $data->info;
// (STOLEN FROM CHOICE) if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('Webscheme', $restore, $info['MOD']['#'], array('TIMEOPEN', 'TIMECLOSE'));
}
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the WEBSCHEME record structure
$webscheme->course = $restore->course_id;
$webscheme->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$webscheme->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
$webscheme->introformat = backup_todb($info['MOD']['#']['INTROFORMAT']['0']['#']);
$webscheme->timecreated = $info['MOD']['#']['TIMECREATED']['0']['#'];
$webscheme->timemodified = $info['MOD']['#']['TIMEMODIFIED']['0']['#'];
$ws_settings = $info['MOD']['#']['WS_SETTINGS']['0']['#'];
$ws_settings = backup_todb(html_entity_decode($ws_settings));
$webscheme->ws_settings = $ws_settings;
$ws_events = $info['MOD']['#']['WS_EVENTS']['0']['#'];
$ws_events = backup_todb(html_entity_decode($ws_events));
$webscheme->ws_events = $ws_events;
$ws_initexpr = $info['MOD']['#']['WS_INITEXPR']['0']['#'];
$ws_initexpr = backup_todb(html_entity_decode($ws_initexpr));
$webscheme->ws_initexpr = $ws_initexpr;
$ws_loadurls = $info['MOD']['#']['WS_LOADURLS']['0']['#'];
$ws_loadurls = backup_todb(html_entity_decode($ws_loadurls));
$webscheme->ws_loadurls = $ws_loadurls;
$ws_html = $info['MOD']['#']['WS_HTML']['0']['#'];
$ws_html = backup_todb(html_entity_decode($ws_html));
$webscheme->ws_html = $ws_html;
//The structure is equal to the db, so insert the webscheme
// ah? Do we need to addslashes or anything?
$newid = insert_record("webscheme", $webscheme);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("modulename", "webscheme") . " \"" . format_string($webscheme->name, true) . "\"</li>";
}
backup_flush(300);
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code, $mod->modtype, $mod->id, $newid);
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
示例2: restore
function restore($old_question_id, $new_question_id, $info, $restore)
{
global $DB;
$status = true;
//Get the multianswers array
$multianswers = $info['#']['MULTIANSWERS']['0']['#']['MULTIANSWER'];
//Iterate over multianswers
for ($i = 0; $i < sizeof($multianswers); $i++) {
$mul_info = $multianswers[$i];
//We need this later
$oldid = backup_todb($mul_info['#']['ID']['0']['#']);
//Now, build the question_multianswer record structure
$multianswer = new stdClass();
$multianswer->question = $new_question_id;
$multianswer->sequence = backup_todb($mul_info['#']['SEQUENCE']['0']['#']);
//We have to recode the sequence field (a list of question ids)
//Extracts question id from sequence
$sequence_field = "";
$in_first = true;
//$tok = strtok($multianswer->sequence,",");
$tok = explode(",", $multianswer->sequence);
while (list($key, $value) = each($tok)) {
if (!empty($value)) {
//Get the answer from reader_backup_ids
$question = backup_getid($restore->backup_unique_code, "question", $value);
if ($question) {
if ($in_first) {
$sequence_field .= $question->new_id;
$in_first = false;
} else {
$sequence_field .= "," . $question->new_id;
}
}
}
}
//We have the answers field recoded to its new ids
$multianswer->sequence = $sequence_field;
//The structure is equal to the db, so insert the question_multianswer
$newid = $DB->insert_record("question_multianswer", $multianswer);
//Save ids in reader_backup_ids
if ($newid) {
backup_putid($restore->backup_unique_code, "question_multianswer", $oldid, $newid);
}
//Do some output
if (($i + 1) % 50 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo ".";
if (($i + 1) % 1000 == 0) {
echo "<br />";
}
}
backup_flush(300);
}
}
return $status;
}
示例3: restore_hook
protected function restore_hook($restore, $lock)
{
if (!empty($lock['id'])) {
$item = backup_getid($restore->backup_unique_code, 'grade_items', $lock['id']);
if ($item and !empty($item->new_id)) {
$lock['id'] = $item->new_id;
return $lock;
}
}
return false;
}
示例4: restore_hook
protected function restore_hook($restore, $lock)
{
if (!empty($lock['cmid'])) {
// Get the new course module ID
$cmid = backup_getid($restore->backup_unique_code, 'course_modules', $lock['cmid']);
if ($cmid and !empty($cmid->new_id)) {
$lock['cmid'] = $cmid->new_id;
return $lock;
}
}
return false;
}
示例5: textanalysis_restore_mods
function textanalysis_restore_mods($mod, $restore)
{
global $CFG, $oldidarray;
$status = true;
//Get record from backup_ids
$data = backup_getid($restore->backup_unique_code, $mod->modtype, $mod->id);
if ($data) {
//Now get completed xmlized object
$info = $data->info;
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
// if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('textanalysis', $restore, $info['MOD']['#'], array('TEXTANALYSISTIME'));
}
//Now, build the textanalysis record structure
$textanalysis->course = $restore->course_id;
$textanalysis->teacher = backup_todb($info['MOD']['#']['TEACHER']['0']['#']);
$textanalysis->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$textanalysis->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
$textanalysis->type = backup_todb($info['MOD']['#']['TYPE']['0']['#']);
$textanalysis->time = backup_todb($info['MOD']['#']['TIME']['0']['#']);
$user = backup_getid($restore->backup_unique_code, "user", $textanalysis->teacher);
if ($user) {
$textanalysis->teacher = $user->new_id;
}
//The structure is equal to the db, so insert the textanalysis
$newid = insert_record("textanalysis", $textanalysis);
//Do some output
//if (!defined('RESTORE_SILENTLY')) {
// echo "<li>".get_string("modulename","textanalysis")." \"".format_string(stripslashes($textanalysis->name),true)."\"</li>";
//}
//backup_flush(300);
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code, $mod->modtype, $mod->id, $newid);
//Now check if want to restore user data and do it.
if (restore_userdata_selected($restore, 'textanalysis', $mod->id)) {
//Restore textanalysis_messages
}
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
示例6: poodllpairwork_restore_mods
/**
* restores a complete module
* @param object $mod
* @param object $restore
* @uses $CFG
*/
function poodllpairwork_restore_mods($mod, $restore)
{
global $CFG;
$status = true;
//Get record from backup_ids
$data = backup_getid($restore->backup_unique_code, $mod->modtype, $mod->id);
if ($data) {
//Now get completed xmlized object
$info = $data->info;
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the poodllpairwork record structure
$poodllpairwork->course = $restore->course_id;
$poodllpairwork->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$poodllpairwork->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
$poodllpairwork->introa = backup_todb($info['MOD']['#']['INTROA']['0']['#']);
$poodllpairwork->introb = backup_todb($info['MOD']['#']['INTROB']['0']['#']);
$poodllpairwork->sessiontype = backup_todb($info['MOD']['#']['SESSIONTYPE']['0']['#']);
$poodllpairwork->introformat = backup_todb($info['MOD']['#']['INTROFORMAT']['0']['#']);
$poodllpairwork->timecreated = backup_todb($info['MOD']['#']['TIMECREATED']['0']['#']);
$poodllpairwork->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//The structure is equal to the db, so insert the poodllpairwork
$newid = insert_record('poodllpairwork', $poodllpairwork);
//Do some output
echo '<ul><li>' . get_string('modulename', 'poodllpairwork') . " \"" . $poodllpairwork->name . "\"<br>";
backup_flush(300);
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code, $mod->modtype, $mod->id, $newid);
//Now restore files
$status = $status && poodllpairwork_restore_files($mod->id, $newid, $restore);
} else {
$status = false;
}
//Finalize ul
echo '</ul>';
} else {
$status = false;
}
return $status;
}
示例7: restore_data
public static function restore_data($data, $restore)
{
$status = false;
foreach ($data as $datum) {
switch ($datum->name) {
case 'moduleid':
// Relink module ID
$newid = backup_getid($restore->backup_unique_code, 'course_modules', $datum->value);
if (isset($newid->new_id)) {
$datum->value = $newid->new_id;
$status = update_record('pagemenu_link_data', $datum);
}
break;
default:
debugging('Deleting unknown data type: ' . $datum->name);
// Not recognized
delete_records('pagemenu_link_data', 'id', $datum->id);
break;
}
}
return $status;
}
示例8: wwassignment_restore_mods
function wwassignment_restore_mods($mod, $restore)
{
global $CFG;
$status = true;
//Get record from backup_ids
$data = backup_getid($restore->backup_unique_code, $mod->modtype, $mod->id);
if ($data) {
//Now get completed xmlized object
$info = $data->info;
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ record structure
$wwassignment = new stdClass();
$wwassignment->course = $restore->course_id;
$wwassignment->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$wwassignment->description = backup_todb($info['MOD']['#']['DESCRIPTION']['0']['#']);
$wwassignment->webwork_set = backup_todb($info['MOD']['#']['WEBWORK_SET']['0']['#']);
//The structure is equal to the db, so insert the quiz
$newid = insert_record("wwassignment", $wwassignment);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("modulename", "wwassignment") . " \"" . format_string(stripslashes($wwassignment->name), true) . "\"</li>";
}
backup_flush(300);
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code, $mod->modtype, $mod->id, $newid);
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
示例9: write_role_assignments_xml
function write_role_assignments_xml($bf, $preferences, $context, $startlevel)
{
/// write role_assign code here
fwrite($bf, start_tag("ROLES_ASSIGNMENTS", $startlevel, true));
if ($roles = get_roles_with_assignment_on_context($context)) {
foreach ($roles as $role) {
/// Skip non-selected roles
if (!isset($preferences->backuproleassignments[$role->id])) {
continue;
}
fwrite($bf, start_tag("ROLE", $startlevel + 1, true));
fwrite($bf, full_tag("ID", $startlevel + 2, false, $role->id));
fwrite($bf, full_tag("NAME", $startlevel + 2, false, $role->name));
fwrite($bf, full_tag("SHORTNAME", $startlevel + 2, false, $role->shortname));
fwrite($bf, start_tag("ASSIGNMENTS", $startlevel + 2, true));
if ($assignments = get_users_from_role_on_context($role, $context)) {
foreach ($assignments as $assignment) {
/// Role assignments are only sent to backup if the user is one target user
if (backup_getid($preferences->backup_unique_code, 'user', $assignment->userid)) {
fwrite($bf, start_tag("ASSIGNMENT", $startlevel + 3, true));
fwrite($bf, full_tag("USERID", $startlevel + 4, false, $assignment->userid));
fwrite($bf, full_tag("HIDDEN", $startlevel + 4, false, $assignment->hidden));
fwrite($bf, full_tag("TIMESTART", $startlevel + 4, false, $assignment->timestart));
fwrite($bf, full_tag("TIMEEND", $startlevel + 4, false, $assignment->timeend));
fwrite($bf, full_tag("TIMEMODIFIED", $startlevel + 4, false, $assignment->timemodified));
if (!isset($assignment->modifierid)) {
$assignment->modifierid = 0;
}
fwrite($bf, full_tag("MODIFIERID", $startlevel + 4, false, $assignment->modifierid));
fwrite($bf, full_tag("ENROL", $startlevel + 4, false, $assignment->enrol));
fwrite($bf, full_tag("SORTORDER", $startlevel + 4, false, $assignment->sortorder));
fwrite($bf, end_tag("ASSIGNMENT", $startlevel + 3, true));
}
}
}
fwrite($bf, end_tag("ASSIGNMENTS", $startlevel + 2, true));
fwrite($bf, end_tag("ROLE", $startlevel + 1, true));
}
}
fwrite($bf, end_tag("ROLES_ASSIGNMENTS", $startlevel, true));
}
示例10: learning_decode_format_content_links
/**
* Return content decoded to support interactivities linking.
* This is called automatically from
* {@link restore_decode_content_links_worker()} function
* in the restore process.
*
* @param string $content Content to be dencoded
* @param object $restore Restore preferences object
* @return string The dencoded content
**/
function learning_decode_format_content_links($content, $restore)
{
global $CFG;
$searchstring = '/\\$@(COURSEFORMATFRONTPAGE)\\*([0-9]+)@\\$/';
preg_match_all($searchstring, $content, $foundset);
if ($foundset[0]) {
// iterate of $foundset[2] and $foundset[3] they are the old_ids
foreach ($foundset[2] as $key => $old_id) {
$rec = backup_getid($restore->backup_unique_code, 'format_page', $old_id);
$searchstring = '/\\$@(COURSEFORMATFRONTPAGE)\\*(' . $old_id . ')@\\$/';
if (!empty($rec->new_id)) {
$content = preg_replace($searchstring, $CFG->wwwroot . '/index.php?page=' . $rec->new_id, $content);
} else {
// it's a link to an external site so leave alone
$content = preg_replace($searchstring, $restore->original_wwwroot . '/index.php?page=' . $old_id, $content);
}
}
}
$searchstring = '/\\$@(COURSEFORMATPAGE)\\*([0-9]+)\\*([0-9]+)@\\$/';
preg_match_all($searchstring, $content, $foundset);
if ($foundset[0]) {
// iterate of $foundset[2] and $foundset[3] they are the old_ids
foreach ($foundset[2] as $key => $old_id) {
$old_id2 = $foundset[3][$key];
$rec = backup_getid($restore->backup_unique_code, 'course', $old_id);
$rec2 = backup_getid($restore->backup_unique_code, 'format_page', $old_id2);
$searchstring = '/\\$@(COURSEFORMATPAGE)\\*(' . $old_id . ')\\*(' . $old_id2 . ')@\\$/';
if (!empty($rec->new_id) && !empty($rec2->new_id)) {
$content = preg_replace($searchstring, $CFG->wwwroot . '/course/view.php?id=' . $rec->new_id . '&page=' . $rec2->new_id, $content);
} else {
// it's a link to an external site so leave alone
$content = preg_replace($searchstring, $restore->original_wwwroot . '/course/view.php?id=' . $old_id . '&page=' . $old_id2, $content);
}
}
}
$searchstring = '/\\$@(COURSEFORMATMANAGEMENU)\\*([0-9]+)@\\$/';
preg_match_all($searchstring, $content, $foundset);
if ($foundset[0]) {
// iterate of $foundset[2] and $foundset[3] they are the old_ids
foreach ($foundset[2] as $key => $old_id) {
$rec = backup_getid($restore->backup_unique_code, 'course', $old_id);
$searchstring = '/\\$@(COURSEFORMATMANAGEMENU)\\*(' . $old_id . ')@\\$/';
if (!empty($rec->new_id)) {
$content = preg_replace($searchstring, $CFG->wwwroot . '/course/format/page/managemenu.php?id=' . $rec->new_id, $content);
} else {
// it's a link to an external site so leave alone
$content = preg_replace($searchstring, $restore->original_wwwroot . '/course/format/page/managemenu.php?id=' . $old_id, $content);
}
}
}
return $content;
}
示例11: endElementUsers
function endElementUsers($parser, $tagName)
{
global $CFG;
//Check if we are into USERS zone
if ($this->tree[3] == "USERS") {
//if (trim($this->content)) //Debug
// echo "C".str_repeat(" ",($this->level+2)*2).$this->getContents()."<br />\n"; //Debug
//echo $this->level.str_repeat(" ",$this->level*2)."</".$tagName."><br />\n"; //Debug
//Dependig of different combinations, do different things
if ($this->level == 4) {
switch ($tagName) {
case "USER":
//Increment counter
$this->counter++;
//Save to db, only save if record not already exist
// if there already is an new_id for this entry, just use that new_id?
$newuser = backup_getid($this->preferences->backup_unique_code, "user", $this->info->tempuser->id);
if (isset($newuser->new_id)) {
$newid = $newuser->new_id;
} else {
$newid = null;
}
backup_putid($this->preferences->backup_unique_code, "user", $this->info->tempuser->id, $newid, $this->info->tempuser);
//Do some output
if ($this->counter % 10 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo ".";
if ($this->counter % 200 == 0) {
echo "<br />";
}
}
backup_flush(300);
}
//Delete temp obejct
unset($this->info->tempuser);
break;
}
}
if ($this->level == 5) {
switch ($tagName) {
case "ID":
$this->info->users[$this->getContents()] = $this->getContents();
$this->info->tempuser->id = $this->getContents();
break;
case "AUTH":
$this->info->tempuser->auth = $this->getContents();
break;
case "CONFIRMED":
$this->info->tempuser->confirmed = $this->getContents();
break;
case "POLICYAGREED":
$this->info->tempuser->policyagreed = $this->getContents();
break;
case "DELETED":
$this->info->tempuser->deleted = $this->getContents();
break;
case "USERNAME":
$this->info->tempuser->username = $this->getContents();
break;
case "PASSWORD":
$this->info->tempuser->password = $this->getContents();
break;
case "IDNUMBER":
$this->info->tempuser->idnumber = $this->getContents();
break;
case "FIRSTNAME":
$this->info->tempuser->firstname = $this->getContents();
break;
case "LASTNAME":
$this->info->tempuser->lastname = $this->getContents();
break;
case "EMAIL":
$this->info->tempuser->email = $this->getContents();
break;
case "EMAILSTOP":
$this->info->tempuser->emailstop = $this->getContents();
break;
case "ICQ":
$this->info->tempuser->icq = $this->getContents();
break;
case "SKYPE":
$this->info->tempuser->skype = $this->getContents();
break;
case "AIM":
$this->info->tempuser->aim = $this->getContents();
break;
case "YAHOO":
$this->info->tempuser->yahoo = $this->getContents();
break;
case "MSN":
$this->info->tempuser->msn = $this->getContents();
break;
case "PHONE1":
$this->info->tempuser->phone1 = $this->getContents();
break;
case "PHONE2":
$this->info->tempuser->phone2 = $this->getContents();
break;
case "INSTITUTION":
$this->info->tempuser->institution = $this->getContents();
//.........这里部分代码省略.........
示例12: restore
function restore($old_question_id, $new_question_id, $info, $restore)
{
$status = true;
//Get the calculated-s array
$calculateds = $info['#']['CALCULATED'];
//Iterate over calculateds
for ($i = 0; $i < sizeof($calculateds); $i++) {
$cal_info = $calculateds[$i];
//traverse_xmlize($cal_info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the question_calculated record structure
$calculated->question = $new_question_id;
$calculated->answer = backup_todb($cal_info['#']['ANSWER']['0']['#']);
$calculated->tolerance = backup_todb($cal_info['#']['TOLERANCE']['0']['#']);
$calculated->tolerancetype = backup_todb($cal_info['#']['TOLERANCETYPE']['0']['#']);
$calculated->correctanswerlength = backup_todb($cal_info['#']['CORRECTANSWERLENGTH']['0']['#']);
$calculated->correctanswerformat = backup_todb($cal_info['#']['CORRECTANSWERFORMAT']['0']['#']);
////We have to recode the answer field
$answer = backup_getid($restore->backup_unique_code, "question_answers", $calculated->answer);
if ($answer) {
$calculated->answer = $answer->new_id;
}
//The structure is equal to the db, so insert the question_calculated
$newid = insert_record("question_calculated", $calculated);
//Do some output
if (($i + 1) % 50 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo ".";
if (($i + 1) % 1000 == 0) {
echo "<br />";
}
}
backup_flush(300);
}
//Now restore numerical_units
$status = question_restore_numerical_units($old_question_id, $new_question_id, $cal_info, $restore);
//Now restore dataset_definitions
if ($status && $newid) {
$status = question_restore_dataset_definitions($old_question_id, $new_question_id, $cal_info, $restore);
}
if (!$newid) {
$status = false;
}
}
return $status;
}
示例13: restore_recode_answer
function restore_recode_answer($state, $restore)
{
// The answer looks like 'randomXX-ANSWER', where XX is
// the id of the used question and ANSWER the actual
// response to that question.
// However, there may still be old-style states around,
// which store the id of the wrapped question in the
// state of the random question and store the response
// in a separate state for the wrapped question
global $QTYPES, $DB;
$answer_field = "";
if (ereg('^random([0-9]+)-(.*)$', $state->answer, $answerregs)) {
// Recode the question id in $answerregs[1]
// Get the question from backup_ids
if (!($wrapped = backup_getid($restore->backup_unique_code, "question", $answerregs[1]))) {
echo 'Could not recode question in random-' . $answerregs[1] . '<br />';
return $answer_field;
}
// Get the question type for recursion
if (!($wrappedquestion->qtype = $DB->get_field('question', 'qtype', array('id' => $wrapped->new_id)))) {
echo 'Could not get qtype while recoding question random-' . $answerregs[1] . '<br />';
return $answer_field;
}
$newstate = $state;
$newstate->question = $wrapped->new_id;
$newstate->answer = $answerregs[2];
$answer_field = 'random' . $wrapped->new_id . '-';
// Recode the answer field in $answerregs[2] depending on
// the qtype of question with id $answerregs[1]
$answer_field .= $QTYPES[$wrappedquestion->qtype]->restore_recode_answer($newstate, $restore);
} else {
// Handle old-style states
$answer_link = backup_getid($restore->backup_unique_code, "question", $state->answer);
if ($answer_link) {
$answer_field = $answer_link->new_id;
}
}
return $answer_field;
}
示例14: hotpot_decode_content_link
function hotpot_decode_content_link($scriptname, $paramname, $paramvalue, &$restore)
{
global $CFG;
$table = '';
switch ($paramname) {
case 'id':
switch ($scriptname) {
case 'index':
$table = 'course';
break;
case 'report':
case 'review':
case 'view':
$table = 'course_modules';
break;
case 'attempt':
$table = 'hotpot_attempts';
break;
}
break;
case 'hp':
case 'hotpotid':
$table = 'hotpot';
break;
}
$new_id = 0;
if ($table) {
if ($rec = backup_getid($restore->backup_unique_code, $table, $paramvalue)) {
$new_id = $rec->new_id;
}
}
return "{$CFG->wwwroot}/mod/hotpot/{$scriptname}.php?{$paramname}={$new_id}";
}
示例15: wiki_decode_content_links
function wiki_decode_content_links($content, $restore)
{
global $CFG;
$result = $content;
//Link to the list of wikis
$searchstring = '/\\$@(WIKIINDEX)\\*([0-9]+)@\\$/';
//We look for it
preg_match_all($searchstring, $content, $foundset);
//If found, then we are going to look for its new id (in backup tables)
if ($foundset[0]) {
//print_object($foundset); //Debug
//Iterate over foundset[2]. They are the old_ids
foreach ($foundset[2] as $old_id) {
//We get the needed variables here (course id)
$rec = backup_getid($restore->backup_unique_code, "course", $old_id);
//Personalize the searchstring
$searchstring = '/\\$@(WIKIINDEX)\\*(' . $old_id . ')@\\$/';
//If it is a link to this course, update the link to its new location
if ($rec->new_id) {
//Now replace it
$result = preg_replace($searchstring, $CFG->wwwroot . '/mod/wiki/index.php?id=' . $rec->new_id, $result);
} else {
//It's a foreign link so leave it as original
$result = preg_replace($searchstring, $restore->original_wwwroot . '/mod/wiki/index.php?id=' . $old_id, $result);
}
}
}
//Link to wiki view by moduleid
$searchstring = '/\\$@(WIKIVIEWBYID)\\*([0-9]+)@\\$/';
//We look for it
preg_match_all($searchstring, $result, $foundset);
//If found, then we are going to look for its new id (in backup tables)
if ($foundset[0]) {
//print_object($foundset); //Debug
//Iterate over foundset[2]. They are the old_ids
foreach ($foundset[2] as $old_id) {
//We get the needed variables here (course_modules id)
$rec = backup_getid($restore->backup_unique_code, "course_modules", $old_id);
//Personalize the searchstring
$searchstring = '/\\$@(WIKIVIEWBYID)\\*(' . $old_id . ')@\\$/';
//If it is a link to this course, update the link to its new location
if ($rec->new_id) {
//Now replace it
$result = preg_replace($searchstring, $CFG->wwwroot . '/mod/wiki/view.php?id=' . $rec->new_id, $result);
} else {
//It's a foreign link so leave it as original
$result = preg_replace($searchstring, $restore->original_wwwroot . '/mod/wiki/view.php?id=' . $old_id, $result);
}
}
}
return $result;
}