本文整理汇总了PHP中restore_log_date_changes函数的典型用法代码示例。如果您正苦于以下问题:PHP restore_log_date_changes函数的具体用法?PHP restore_log_date_changes怎么用?PHP restore_log_date_changes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了restore_log_date_changes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: qcreate_restore_mods
function qcreate_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;
//if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('Qcreate', $restore, $info['MOD']['#'], array('TIMEOPEN', 'TIMECLOSE'));
}
//Now, build the QCREATE record structure
$qcreate = new object();
$qcreate->course = $restore->course_id;
$qcreate->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$qcreate->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
$qcreate->graderatio = backup_todb($info['MOD']['#']['GRADERATIO']['0']['#']);
$qcreate->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
$qcreate->introformat = backup_todb($info['MOD']['#']['INTROFORMAT']['0']['#']);
$qcreate->allowed = backup_todb($info['MOD']['#']['ALLOWED']['0']['#']);
$qcreate->totalrequired = backup_todb($info['MOD']['#']['TOTALREQUIRED']['0']['#']);
$qcreate->studentqaccess = backup_todb($info['MOD']['#']['STUDENTQACCESS']['0']['#']);
$qcreate->timesync = 0;
$qcreate->timeopen = backup_todb($info['MOD']['#']['TIMEOPEN']['0']['#']);
$qcreate->timeclose = backup_todb($info['MOD']['#']['TIMECLOSE']['0']['#']);
$qcreate->timecreated = backup_todb($info['MOD']['#']['TIMECREATED']['0']['#']);
$qcreate->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//We have to recode the grade field if it is <0 (scale)
if ($qcreate->grade < 0) {
$scale = backup_getid($restore->backup_unique_code, "scale", abs($qcreate->grade));
if ($scale) {
$qcreate->grade = -$scale->new_id;
}
}
//The structure is equal to the db, so insert the qcreate
$newid = insert_record("qcreate", $qcreate);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("modulename", "qcreate") . " \"" . format_string(stripslashes($qcreate->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);
$status = qcreate_requireds_restore_mods($mod->id, $newid, $info, $restore) && $status;
//Now check if want to restore user data and do it.
if (restore_userdata_selected($restore, 'qcreate', $mod->id)) {
//Restore qcreate_grades
$status = qcreate_grades_restore_mods($mod->id, $newid, $info, $restore) && $status;
}
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
示例2: 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;
}
示例3: wiki_restore_mods
function wiki_restore_mods($mod, $restore)
{
global $CFG, $DB;
$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;
//if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('Wiki', $restore, $info['MOD']['#'], array('TIMEMODIFIED'));
}
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the wiki record structure
$wiki->course = $restore->course_id;
$wiki->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$wiki->intro = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']);
$wiki->pagename = backup_todb($info['MOD']['#']['PAGENAME']['0']['#']);
$wiki->wtype = backup_todb($info['MOD']['#']['WTYPE']['0']['#']);
$wiki->ewikiprinttitle = backup_todb($info['MOD']['#']['EWIKIPRINTTITLE']['0']['#']);
$wiki->htmlmode = backup_todb($info['MOD']['#']['HTMLMODE']['0']['#']);
$wiki->ewikiacceptbinary = backup_todb($info['MOD']['#']['EWIKIACCEPTBINARY']['0']['#']);
$wiki->disablecamelcase = backup_todb($info['MOD']['#']['DISABLECAMELCASE']['0']['#']);
$wiki->setpageflags = backup_todb($info['MOD']['#']['SETPAGEFLAGS']['0']['#']);
$wiki->strippages = backup_todb($info['MOD']['#']['STRIPPAGES']['0']['#']);
$wiki->removepages = backup_todb($info['MOD']['#']['REMOVEPAGES']['0']['#']);
$wiki->revertchanges = backup_todb($info['MOD']['#']['REVERTCHANGES']['0']['#']);
$wiki->initialcontent = backup_todb($info['MOD']['#']['INITIALCONTENT']['0']['#']);
$wiki->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//The structure is equal to the db, so insert the wiki
$newid = $DB->insert_record("wiki", $wiki);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("modulename", "wiki") . " \"" . format_string($wiki->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, 'wiki', $mod->id)) {
//Restore wiki_entries
$status = wiki_entries_restore_mods($mod->id, $newid, $info, $restore);
}
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
示例4: journal_restore_mods
function journal_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;
//if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('Journal', $restore, $info['MOD']['#'], array('TIMEMODIFIED'));
}
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the JOURNAL record structure
$journal->course = $restore->course_id;
$journal->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$journal->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
$journal->introformat = backup_todb($info['MOD']['#']['INTROFORMAT']['0']['#']);
$journal->days = backup_todb($info['MOD']['#']['DAYS']['0']['#']);
$journal->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']);
$journal->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//We have to recode the assessed field if it is <0 (scale)
if ($journal->assessed < 0) {
$scale = backup_getid($restore->backup_unique_code, "scale", abs($journal->assessed));
if ($scale) {
$journal->assessed = -$scale->new_id;
}
}
//The structure is equal to the db, so insert the journal
$newid = insert_record("journal", $journal);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("modulename", "journal") . " \"" . format_string(stripslashes($journal->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, 'journal', $mod->id)) {
//Restore journal_entries
$status = journal_entries_restore_mods($mod->id, $newid, $info, $restore);
}
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
示例5: game_restore_mods
function game_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;
//if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('Game', $restore, $info['MOD']['#'], array('TIMEOPEN', 'TIMECLOSE'));
}
//Now, build the GAME record structure
$game = new stdClass();
$game->course = $restore->course_id;
$mod_info = $info['MOD'];
$fields = array('name', 'sourcemodule', 'quizid', 'glossaryid', 'glossarycategoryid', 'questioncategoryid', 'bookid', 'gameinputid', 'gamekind', 'param1', 'param2', 'param3', 'param4', 'param5', 'param6', 'param7', 'param8', 'timemodified', 'bottomtext', 'grademethod', 'grade', 'decimalpoints', 'popup', 'review', 'attempts', 'glossaryid2', 'glossarycategoryid2', 'language');
game_restore_record($mod_info, $game, $fields);
game_recode($restore->backup_unique_code, $game, 'quizid', 'quiz');
game_recode($restore->backup_unique_code, $game, 'glossaryid', 'glossary');
game_recode($restore->backup_unique_code, $game, 'glossarycategoryid', 'glossary_categories');
game_recode($restore->backup_unique_code, $game, 'glossaryid2', 'glossary');
game_recode($restore->backup_unique_code, $game, 'glossarycategoryid2', 'glossary_categories');
game_restore_stamp($info, $restore, $map_question_categories, 'QUESTION_CATEGORIES', 'QUESTION_CATEGORY');
game_restore_stamp($info, $restore, $map_questions, 'QUESTIONS', 'QUESTION');
game_recode_questioncategoryid($game, $map_question_categories);
game_recode($restore->backup_unique_code, $game, 'bookid', 'book');
//The structure is equal to the db, so insert the game
$newid = insert_record("game", $game);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("modulename", "game") . " \"" . format_string(stripslashes($game->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, 'game', $mod->id)) {
$status = game_restore_grades($newid, $info, $restore);
$status = game_restore_snakes_database($info, $restore);
$status = game_restore_bookquiz_questions($newid, $info, $restore, $map_question_categories);
//Restore game_attempts
$status = game_attempts_restore_mods($newid, $info, $restore, $map_questions);
}
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
示例6: blended_restore_mods
function blended_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
// if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('Blended', $restore, $info['MOD']['#'], array('TIMEOPEN', 'TIMECLOSE'));
}
//Now, build the BLENDED record structure
$blended->course = $restore->course_id;
$blended->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$blended->description = backup_todb($info['MOD']['#']['DESCRIPTION']['0']['#']);
$blended->idmethod = backup_todb($info['MOD']['#']['IDMETHOD']['0']['#']);
$blended->idtype = backup_todb($info['MOD']['#']['IDTYPE']['0']['#']);
$blended->codebartype = backup_todb($info['MOD']['#']['CODEBARTYPE']['0']['#']);
$blended->lengthuserinfo = backup_todb($info['MOD']['#']['LENGTHUSERINFO']['0']['#']);
$blended->teammethod = backup_todb($info['MOD']['#']['TEAMMETHOD']['0']['#']);
$blended->numteams = backup_todb($info['MOD']['#']['NUMTEAMS']['0']['#']);
$blended->nummembers = backup_todb($info['MOD']['#']['MUMMEMBERS']['0']['#']);
$blended->assignment = backup_todb($info['MOD']['#']['ASSIGNMENT']['0']['#']);
$blended->randomkey = backup_todb($info['MOD']['#']['RANDOMKEY']['0']['#']);
//The structure is equal to the db, so insert the chat
$newid = insert_record("blended", $blended);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("modulename", "chat") . " \"" . format_string(stripslashes($blended->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, 'blended', $mod->id)) {
//Restore chat_messages
$status = blended_jobs_restore_mods($newid, $info, $restore);
}
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
示例7: nanogong_restore_mods
function nanogong_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;
//if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('NanoGong', $restore, $info['MOD']['#'], array('TIMEDUE', 'TIMEAVAILABLE'));
}
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
// Now, build the NANOGONG record structure
$nanogong->course = $restore->course_id;
$nanogong->id = backup_todb($info['MOD']['#']['ID']['0']['#']);
$nanogong->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$nanogong->message = backup_todb($info['MOD']['#']['MESSAGE']['0']['#']);
$nanogong->color = backup_todb($info['MOD']['#']['COLOR']['0']['#']);
$nanogong->maxduration = backup_todb($info['MOD']['#']['MAXDURATION']['0']['#']);
$nanogong->maxmessages = backup_todb($info['MOD']['#']['MAXMESSAGES']['0']['#']);
$nanogong->maxscore = backup_todb($info['MOD']['#']['MAXSCORE']['0']['#']);
$nanogong->allowguestaccess = backup_todb($info['MOD']['#']['ALLOWGUESTACCESS']['0']['#']);
$nanogong->timecreated = backup_todb($info['MOD']['#']['TIMECREATED']['0']['#']);
$nanogong->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//The structure is equal to the db, so insert the nanogong
$newid = insert_record("nanogong", $nanogong);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("modulename", "nanogong") . " \"" . format_string(stripslashes($nanogong->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, 'nanogong', $mod->id)) {
//Restore nanogong messages
$status = nanogong_messages_restore_mods($mod->id, $newid, $info, $restore);
}
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
示例8: checklist_restore_mods
function checklist_restore_mods($mod, $restore)
{
global $CFG, $db;
$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;
//if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('checklist', $restore, $info['MOD']['#'], array('TIMECREATED', 'TIMEMODIFIED'));
}
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the CHECKLIST record structure
$checklist = new stdClass();
$checklist->course = $restore->course_id;
$checklist->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$checklist->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
$checklist->introformat = backup_todb($info['MOD']['#']['INTROFORMAT']['0']['#']);
$checklist->timecreated = backup_todb($info['MOD']['#']['TIMECREATED']['0']['#']);
$checklist->timecreated += $restore->course_startdateoffset;
$checklist->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
$checklist->timemodified += $restore->course_startdateoffset;
$checklist->useritemsallowed = backup_todb($info['MOD']['#']['USERITEMSALLOWED']['0']['#']);
$checklist->teacheredit = backup_todb($info['MOD']['#']['TEACHEREDIT']['0']['#']);
$checklist->theme = backup_todb($info['MOD']['#']['THEME']['0']['#']);
$checklist->duedatesoncalendar = backup_todb_chk_optional_field($info['MOD'], 'DUEDATESONCALENDAR', false);
$checklist->teachercomments = backup_todb_chk_optional_field($info['MOD'], 'TEACHERCOMMENTS', false);
$newid = insert_record('checklist', $checklist);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string('modulename', 'checklist') . " \"" . format_string(stripslashes($checklist->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);
$checklist->id = $newid;
$restore_user = restore_userdata_selected($restore, 'checklist', $mod->id);
$status = checklist_items_restore($newid, $info, $restore, $restore_user);
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
示例9: 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;
}
示例10: realtimequiz_restore_mods
function realtimequiz_restore_mods($mod, $restore)
{
global $CFG, $db;
$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;
//if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('Realtimequiz', $restore, $info['MOD']['#'], array('ASSESSTIMESTART', 'ASSESSTIMEFINISH'));
}
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the REALTIMEQUIZ record structure
$quiz->course = $restore->course_id;
$quiz->type = backup_todb($info['MOD']['#']['TYPE']['0']['#']);
$quiz->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$quiz->questiontime = backup_todb($info['MOD']['#']['QUESTIONTIME']['0']['#']);
$newid = insert_record("realtimequiz", $quiz);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("modulename", "realtimequiz") . " \"" . format_string(stripslashes($quiz->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);
$quiz->id = $newid;
$restore_user = false;
//Now check if want to restore user data and do it.
if (restore_userdata_selected($restore, 'realtimequiz', $mod->id)) {
$status = realtimequiz_sessions_restore($newid, $info, $restore);
$restore_user = true;
}
// Restore the questions and answers (and any submissions)
if ($status) {
$status = realtimequiz_questions_restore($newid, $info, $restore, $restore_user);
}
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
示例11: chat_restore_mods
function chat_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
// if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('Chat', $restore, $info['MOD']['#'], array('CHATTIME'));
}
//Now, build the CHAT record structure
$chat->course = $restore->course_id;
$chat->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$chat->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
$chat->keepdays = backup_todb($info['MOD']['#']['KEEPDAYS']['0']['#']);
$chat->studentlogs = backup_todb($info['MOD']['#']['STUDENTLOGS']['0']['#']);
$chat->schedule = backup_todb($info['MOD']['#']['SCHEDULE']['0']['#']);
$chat->chattime = backup_todb($info['MOD']['#']['CHATTIME']['0']['#']);
$chat->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//The structure is equal to the db, so insert the chat
$newid = insert_record("chat", $chat);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("modulename", "chat") . " \"" . format_string(stripslashes($chat->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, 'chat', $mod->id)) {
//Restore chat_messages
$status = chat_messages_restore_mods($mod->id, $newid, $info, $restore);
}
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
示例12: stampcoll_restore_mods
/**
* Restore the module
*
* @param object $mod Module to restore from XML
* @param object $restore Restore process settings
* @return boolean True if success, False if failure
*/
function stampcoll_restore_mods($mod, $restore)
{
$status = true;
//Get record from backup_ids
$data = backup_getid($restore->backup_unique_code, $mod->modtype, $mod->id);
if ($data) {
//get completed xmlized object
$info = $data->info;
//if necessary, write to restorelog and adjust date/time fields
if (!empty($restore->course_startdateoffset)) {
restore_log_date_changes('Stamp collection', $restore, $info['MOD']['#'], array('TIMEMODIFIED'));
}
//traverse_xmlize($info); //Debug
//print_object($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array'] = ''; //Debug
//build the record structure
$stampcoll = new stdClass();
$stampcoll->course = $restore->course_id;
$stampcoll->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$stampcoll->text = backup_todb($info['MOD']['#']['TEXT']['0']['#']);
$stampcoll->format = backup_todb($info['MOD']['#']['FORMAT']['0']['#']);
$stampcoll->image = backup_todb($info['MOD']['#']['IMAGE']['0']['#']);
$stampcoll->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
$stampcoll->displayzero = backup_todb($info['MOD']['#']['DISPLAYZERO']['0']['#']);
// following was added in Moodle 1.9. If it is not present, consider stampcoll as anonymous
// (we did not keep the giver id pre 1.9)
if (isset($info['MOD']['#']['ANONYMOUS']['0']['#'])) {
$stampcoll->anonymous = backup_todb($info['MOD']['#']['ANONYMOUS']['0']['#']);
} else {
$stampcoll->anonymous = 1;
}
//following two fields get dropped in Moodle 1.9. Therefore they might or not be there
//depending on whether we are restoring a 1.8 or 1.9 backup
if (isset($info['MOD']['#']['PUBLISH']['0']['#'])) {
$stampcoll->publish = backup_todb($info['MOD']['#']['PUBLISH']['0']['#']);
}
if (isset($info['MOD']['#']['TEACHERCANCOLLECT']['0']['#'])) {
$stampcoll->teachercancollect = backup_todb($info['MOD']['#']['TEACHERCANCOLLECT']['0']['#']);
}
//the structure is equal to the db now, so insert the stampcoll
$newid = insert_record('stampcoll', $stampcoll);
//do some output
if (!defined('RESTORE_SILENTLY')) {
echo '<li>' . get_string('modulename', 'stampcoll') . ' "' . format_string(stripslashes($stampcoll->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);
//check if user wants to restore user data and do it
if (restore_userdata_selected($restore, 'stampcoll', $mod->id)) {
$status = stampcoll_restore_collected_stamps($mod->id, $newid, $info, $restore);
}
// if the backup was made in 1.8, we need to convert PUBLISH and TEACHERCANCOLLECT into
// local role overrides
if (isset($stampcoll->publish) && isset($stampcoll->teachercancollect)) {
$cmid = $restore->mods['stampcoll']->instances[$mod->id]->restored_as_course_module;
$context = get_context_instance(CONTEXT_MODULE, $cmid);
if (!($editingteacherroles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW))) {
notice('Default editing teacher role was not found. Roles and permissions ' . 'for the stampcoll module will have to be manually set.');
}
if (!($teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW))) {
notice('Default teacher role was not found. Roles and permissions ' . 'for the stampcoll module will have to be manually set.');
}
if (!($studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW))) {
notice('Default student role was not found. Roles and permissions ' . 'for the stampcoll module will have to be manually set.');
}
// collection with publish set to STAMPCOLL_PUBLISH_NONE
if ($stampcoll->publish == 0) {
// prevent students from viewing own stamps
foreach ($studentroles as $studentrole) {
assign_capability('mod/stampcoll:viewownstamps', CAP_PREVENT, $studentrole->id, $context->id);
}
}
// collection with publish set to STAMPCOLL_PUBLISH_ALL
if ($stampcoll->publish == 2) {
// allow students to view others' stamps
foreach ($studentroles as $studentrole) {
assign_capability('mod/stampcoll:viewotherstamps', CAP_ALLOW, $studentrole->id, $context->id);
}
}
// collection which allows teachers to collect stamps
if ($stampcoll->teachercancollect == 1) {
foreach ($editingteacherroles as $teacherrole) {
assign_capability('mod/stampcoll:collectstamps', CAP_ALLOW, $teacherrole->id, $context->id);
}
foreach ($teacherroles as $teacherrole) {
assign_capability('mod/stampcoll:collectstamps', CAP_ALLOW, $teacherrole->id, $context->id);
}
}
}
} else {
// insert_record() failed
//.........这里部分代码省略.........
示例13: quiz_restore_mods
function quiz_restore_mods($mod, $restore)
{
global $CFG;
$status = true;
//Hook to call Moodle < 1.5 Quiz Restore
if ($restore->backup_version < 2005043000) {
include_once "restorelibpre15.php";
return quiz_restore_pre15_mods($mod, $restore);
}
//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;
//if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('Quiz', $restore, $info['MOD']['#'], array('TIMEOPEN', 'TIMECLOSE'));
}
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ record structure
$quiz = new stdClass();
$quiz->course = $restore->course_id;
$quiz->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$quiz->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
$quiz->timeopen = backup_todb($info['MOD']['#']['TIMEOPEN']['0']['#']);
$quiz->timeclose = backup_todb($info['MOD']['#']['TIMECLOSE']['0']['#']);
$quiz->optionflags = backup_todb($info['MOD']['#']['OPTIONFLAGS']['0']['#']);
$quiz->penaltyscheme = backup_todb($info['MOD']['#']['PENALTYSCHEME']['0']['#']);
$quiz->attempts = backup_todb($info['MOD']['#']['ATTEMPTS_NUMBER']['0']['#']);
$quiz->attemptonlast = backup_todb($info['MOD']['#']['ATTEMPTONLAST']['0']['#']);
$quiz->grademethod = backup_todb($info['MOD']['#']['GRADEMETHOD']['0']['#']);
$quiz->decimalpoints = backup_todb($info['MOD']['#']['DECIMALPOINTS']['0']['#']);
$quiz->review = backup_todb($info['MOD']['#']['REVIEW']['0']['#']);
$quiz->questionsperpage = backup_todb($info['MOD']['#']['QUESTIONSPERPAGE']['0']['#']);
$quiz->shufflequestions = backup_todb($info['MOD']['#']['SHUFFLEQUESTIONS']['0']['#']);
$quiz->shuffleanswers = backup_todb($info['MOD']['#']['SHUFFLEANSWERS']['0']['#']);
$quiz->questions = backup_todb($info['MOD']['#']['QUESTIONS']['0']['#']);
$quiz->sumgrades = backup_todb($info['MOD']['#']['SUMGRADES']['0']['#']);
$quiz->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
$quiz->timecreated = backup_todb($info['MOD']['#']['TIMECREATED']['0']['#']);
$quiz->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
$quiz->timelimit = backup_todb($info['MOD']['#']['TIMELIMIT']['0']['#']);
$quiz->password = backup_todb($info['MOD']['#']['PASSWORD']['0']['#']);
$quiz->subnet = backup_todb($info['MOD']['#']['SUBNET']['0']['#']);
$quiz->popup = backup_todb($info['MOD']['#']['POPUP']['0']['#']);
$quiz->delay1 = isset($info['MOD']['#']['DELAY1']['0']['#']) ? backup_todb($info['MOD']['#']['DELAY1']['0']['#']) : '';
$quiz->delay2 = isset($info['MOD']['#']['DELAY2']['0']['#']) ? backup_todb($info['MOD']['#']['DELAY2']['0']['#']) : '';
//We have to recode the questions field (a list of questions id and pagebreaks)
$quiz->questions = quiz_recode_layout($quiz->questions, $restore);
//The structure is equal to the db, so insert the quiz
$newid = insert_record("quiz", $quiz);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("modulename", "quiz") . " \"" . format_string(stripslashes($quiz->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);
//We have to restore the question_instances now (course level table)
$status = quiz_question_instances_restore_mods($newid, $info, $restore);
//We have to restore the feedback now (course level table)
$status = quiz_feedback_restore_mods($newid, $info, $restore, $quiz);
//We have to restore the question_versions now (course level table)
$status = quiz_question_versions_restore_mods($newid, $info, $restore);
//Now check if want to restore user data and do it.
if (restore_userdata_selected($restore, 'quiz', $mod->id)) {
//Restore quiz_attempts
$status = quiz_attempts_restore_mods($newid, $info, $restore);
if ($status) {
//Restore quiz_grades
$status = quiz_grades_restore_mods($newid, $info, $restore);
}
}
} else {
$status = false;
}
} else {
$status = false;
}
return $status;
}
示例14: quiz_restore_pre15_mods
function quiz_restore_pre15_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;
//if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('Quiz', $restore, $info['MOD']['#'], array('TIMEOPEN', 'TIMECLOSE'));
}
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the QUIZ record structure
$quiz->course = $restore->course_id;
$quiz->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$quiz->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
$quiz->timeopen = backup_todb($info['MOD']['#']['TIMEOPEN']['0']['#']);
$quiz->timeclose = backup_todb($info['MOD']['#']['TIMECLOSE']['0']['#']);
$quiz->attempts = backup_todb($info['MOD']['#']['ATTEMPTS_NUMBER']['0']['#']);
$quiz->attemptonlast = backup_todb($info['MOD']['#']['ATTEMPTONLAST']['0']['#']);
$quiz->feedback = backup_todb($info['MOD']['#']['FEEDBACK']['0']['#']);
$quiz->correctanswers = backup_todb($info['MOD']['#']['CORRECTANSWERS']['0']['#']);
$quiz->grademethod = backup_todb($info['MOD']['#']['GRADEMETHOD']['0']['#']);
if (isset($info['MOD']['#']['DECIMALPOINTS']['0']['#'])) {
//Only if it's set, to apply DB default else.
$quiz->decimalpoints = backup_todb($info['MOD']['#']['DECIMALPOINTS']['0']['#']);
}
$quiz->review = backup_todb($info['MOD']['#']['REVIEW']['0']['#']);
$quiz->questionsperpage = backup_todb($info['MOD']['#']['QUESTIONSPERPAGE']['0']['#']);
$quiz->shufflequestions = backup_todb($info['MOD']['#']['SHUFFLEQUESTIONS']['0']['#']);
$quiz->shuffleanswers = backup_todb($info['MOD']['#']['SHUFFLEANSWERS']['0']['#']);
$quiz->questions = backup_todb($info['MOD']['#']['QUESTIONS']['0']['#']);
$quiz->sumgrades = backup_todb($info['MOD']['#']['SUMGRADES']['0']['#']);
$quiz->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
$quiz->timecreated = backup_todb($info['MOD']['#']['TIMECREATED']['0']['#']);
$quiz->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
$quiz->timelimit = backup_todb($info['MOD']['#']['TIMELIMIT']['0']['#']);
$quiz->password = backup_todb($info['MOD']['#']['PASSWORD']['0']['#']);
$quiz->subnet = backup_todb($info['MOD']['#']['SUBNET']['0']['#']);
$quiz->popup = backup_todb($info['MOD']['#']['POPUP']['0']['#']);
//We have to recode the questions field (a list of questions id)
$newquestions = array();
if ($questionsarr = explode(",", $quiz->questions)) {
foreach ($questionsarr as $key => $value) {
if ($question = backup_getid($restore->backup_unique_code, "question", $value)) {
$newquestions[] = $question->new_id;
}
}
}
$quiz->questions = implode(",", $newquestions);
//Recalculate the questions field to include page breaks if necessary
$quiz->questions = quiz_repaginate($quiz->questions, $quiz->questionsperpage);
//Calculate the new review field contents (logic extracted from upgrade)
$review = QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_RESPONSES + QUIZ_REVIEW_SCORES;
if ($quiz->feedback) {
$review += QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_FEEDBACK;
}
if ($quiz->correctanswers) {
$review += QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_ANSWERS;
}
if ($quiz->review & 1) {
$review += QUIZ_REVIEW_CLOSED;
}
if ($quiz->review & 2) {
$review += QUIZ_REVIEW_OPEN;
}
$quiz->review = $review;
//The structure is equal to the db, so insert the quiz
$newid = insert_record("quiz", $quiz);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("modulename", "quiz") . " \"" . format_string(stripslashes($quiz->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);
//We have to restore the quiz_question_instances now (old quiz_question_grades, course level)
$status = quiz_question_instances_restore_pre15_mods($newid, $info, $restore);
//We have to restore the question_versions now (course level table)
$status = quiz_question_versions_restore_pre15_mods($newid, $info, $restore);
//Now check if want to restore user data and do it.
if (restore_userdata_selected($restore, 'quiz', $mod->id)) {
//Restore quiz_attempts
$status = quiz_attempts_restore_pre15_mods($newid, $info, $restore, $quiz->questions);
if ($status) {
//Restore quiz_grades
$status = quiz_grades_restore_pre15_mods($newid, $info, $restore);
}
}
} else {
$status = false;
}
} else {
$status = false;
}
//.........这里部分代码省略.........
示例15: forum_restore_mods
function forum_restore_mods($mod, $restore)
{
global $CFG, $DB;
$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;
//if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('Forum', $restore, $info['MOD']['#'], array('ASSESSTIMESTART', 'ASSESSTIMEFINISH'));
}
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//Now, build the FORUM record structure
$forum->course = $restore->course_id;
$forum->type = backup_todb($info['MOD']['#']['TYPE']['0']['#']);
$forum->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$forum->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
// These get dropped in Moodle 1.7 when the new Roles System gets
// set up. Therefore they might or not be there depending on whether
// we are restoring a 1.6+ forum or a 1.7 or later forum backup.
if (isset($info['MOD']['#']['OPEN']['0']['#'])) {
$forum->open = backup_todb($info['MOD']['#']['OPEN']['0']['#']);
}
if (isset($info['MOD']['#']['ASSESSPUBLIC']['0']['#'])) {
$forum->assesspublic = backup_todb($info['MOD']['#']['ASSESSPUBLIC']['0']['#']);
}
$forum->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']);
$forum->assesstimestart = backup_todb($info['MOD']['#']['ASSESSTIMESTART']['0']['#']);
$forum->assesstimefinish = backup_todb($info['MOD']['#']['ASSESSTIMEFINISH']['0']['#']);
$forum->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']);
$forum->scale = backup_todb($info['MOD']['#']['SCALE']['0']['#']);
$forum->forcesubscribe = backup_todb($info['MOD']['#']['FORCESUBSCRIBE']['0']['#']);
$forum->trackingtype = backup_todb($info['MOD']['#']['TRACKINGTYPE']['0']['#']);
$forum->rsstype = backup_todb($info['MOD']['#']['RSSTYPE']['0']['#']);
$forum->rssarticles = backup_todb($info['MOD']['#']['RSSARTICLES']['0']['#']);
$forum->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
$forum->warnafter = isset($info['MOD']['#']['WARNAFTER']['0']['#']) ? backup_todb($info['MOD']['#']['WARNAFTER']['0']['#']) : '';
$forum->blockafter = isset($info['MOD']['#']['BLOCKAFTER']['0']['#']) ? backup_todb($info['MOD']['#']['BLOCKAFTER']['0']['#']) : '';
$forum->blockperiod = isset($info['MOD']['#']['BLOCKPERIOD']['0']['#']) ? backup_todb($info['MOD']['#']['BLOCKPERIOD']['0']['#']) : '';
$forum->completiondiscussions = isset($info['MOD']['#']['COMPLETIONDISCUSSIONS']['0']['#']) ? backup_todb($info['MOD']['#']['COMPLETIONDISCUSSIONS']['0']['#']) : 0;
$forum->completionreplies = isset($info['MOD']['#']['COMPLETIONREPLIES']['0']['#']) ? backup_todb($info['MOD']['#']['COMPLETIONREPLIES']['0']['#']) : 0;
$forum->completionposts = isset($info['MOD']['#']['COMPLETIONPOSTS']['0']['#']) ? backup_todb($info['MOD']['#']['COMPLETIONPOSTS']['0']['#']) : 0;
//We have to recode the scale field if it's <0 (positive is a grade, not a scale)
if ($forum->scale < 0) {
$scale = backup_getid($restore->backup_unique_code, "scale", abs($forum->scale));
if ($scale) {
$forum->scale = -$scale->new_id;
}
}
$newid = $DB->insert_record("forum", $forum);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("modulename", "forum") . " \"" . format_string($forum->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);
$forum->id = $newid;
//Now check if want to restore user data and do it.
if (restore_userdata_selected($restore, 'forum', $mod->id)) {
//Restore forum_subscriptions
$status = forum_subscriptions_restore_mods($newid, $info, $restore);
if ($status) {
//Restore forum_discussions
$status = forum_discussions_restore_mods($newid, $info, $restore);
}
if ($status) {
//Restore forum_read
$status = forum_read_restore_mods($newid, $info, $restore);
}
}
// If forum type is single, just recreate the initial discussion/post automatically
// if it hasn't been created still (because no user data was selected on backup or
// restore.
if ($forum->type == 'single' && !$DB->record_exists('forum_discussions', array('forum' => $newid))) {
//Load forum/lib.php
require_once $CFG->dirroot . '/mod/forum/lib.php';
// Calculate the default format
if (can_use_html_editor()) {
$defaultformat = FORMAT_HTML;
} else {
$defaultformat = FORMAT_MOODLE;
}
//Create discussion/post data
$sd = new stdClass();
$sd->course = $forum->course;
$sd->forum = $newid;
$sd->name = $forum->name;
$sd->intro = $forum->intro;
$sd->assessed = $forum->assessed;
$sd->messageformat = $defaultformat;
$sd->mailnow = false;
//Insert dicussion/post data
$sdid = forum_add_discussion($sd, $sd->intro, $forum);
//Now, mark the initial post of the discussion as mailed!
//.........这里部分代码省略.........