MDL-4908 Forum: Add backup/restore steps for per-forum digest settings

This commit is contained in:
Andrew Nicols
2013-08-13 14:46:11 +01:00
parent 3d4cf54820
commit 2eb67dfa6c
3 changed files with 26 additions and 1 deletions
@@ -70,6 +70,11 @@ class backup_forum_activity_structure_step extends backup_activity_structure_ste
$subscription = new backup_nested_element('subscription', array('id'), array(
'userid'));
$digests = new backup_nested_element('digests');
$digest = new backup_nested_element('digest', array('id'), array(
'userid', 'maildigest'));
$readposts = new backup_nested_element('readposts');
$read = new backup_nested_element('read', array('id'), array(
@@ -89,6 +94,9 @@ class backup_forum_activity_structure_step extends backup_activity_structure_ste
$forum->add_child($subscriptions);
$subscriptions->add_child($subscription);
$forum->add_child($digests);
$digests->add_child($digest);
$forum->add_child($readposts);
$readposts->add_child($read);
@@ -118,6 +126,8 @@ class backup_forum_activity_structure_step extends backup_activity_structure_ste
$subscription->set_source_table('forum_subscriptions', array('forum' => backup::VAR_PARENTID));
$digest->set_source_table('forum_digests', array('forum' => backup::VAR_PARENTID));
$read->set_source_table('forum_read', array('forumid' => backup::VAR_PARENTID));
$track->set_source_table('forum_track_prefs', array('forumid' => backup::VAR_PARENTID));
@@ -143,6 +153,8 @@ class backup_forum_activity_structure_step extends backup_activity_structure_ste
$subscription->annotate_ids('user', 'userid');
$digest->annotate_ids('user', 'userid');
$read->annotate_ids('user', 'userid');
$track->annotate_ids('user', 'userid');
@@ -42,6 +42,7 @@ class restore_forum_activity_structure_step extends restore_activity_structure_s
$paths[] = new restore_path_element('forum_post', '/activity/forum/discussions/discussion/posts/post');
$paths[] = new restore_path_element('forum_rating', '/activity/forum/discussions/discussion/posts/post/ratings/rating');
$paths[] = new restore_path_element('forum_subscription', '/activity/forum/subscriptions/subscription');
$paths[] = new restore_path_element('forum_digest', '/activity/forum/digests/digest');
$paths[] = new restore_path_element('forum_read', '/activity/forum/readposts/read');
$paths[] = new restore_path_element('forum_track', '/activity/forum/trackedprefs/track');
}
@@ -149,6 +150,18 @@ class restore_forum_activity_structure_step extends restore_activity_structure_s
$newitemid = $DB->insert_record('forum_subscriptions', $data);
}
protected function process_forum_digest($data) {
global $DB;
$data = (object)$data;
$oldid = $data->id;
$data->forum = $this->get_new_parentid('forum');
$data->userid = $this->get_mappingid('user', $data->userid);
$newitemid = $DB->insert_record('forum_digests', $data);
}
protected function process_forum_read($data) {
global $DB;
+1 -1
View File
@@ -158,7 +158,7 @@ $string['emaildigesttype_help'] = 'The type of notification that you will receiv
$string['emaildigestupdated'] = 'The e-mail digest option was changed to \'{$a->maildigesttitle}\' for the forum \'{$a->forum}\'. {$a->maildigestdescription}';
$string['emaildigestupdated_default'] = 'Your default profile setting of \'{$a->maildigesttitle}\' was used for the forum \'{$a->forum}\'. {$a->maildigestdescription}.';
$string['emaildigest_0'] = 'You will receive one e-mail per forum post.';
$string['emaildigest_1'] = 'You will receive one digest e-mail per day containing the complete contents of each forum post.';
$string['emaildigest_1'] = 'You will receive one digest e-mail per day containing the complete contents of each forum post.';
$string['emaildigest_2'] = 'You will receive one digest e-mail per day containing the subject of each forum post.';
$string['emptymessage'] = 'Something was wrong with your post. Perhaps you left it blank, or the attachment was too big. Your changes have NOT been saved.';
$string['erroremptymessage'] = 'Post message cannot be empty';