~ubuntu-branches/ubuntu/trusty/moodle/trusty-proposed

« back to all changes in this revision

Viewing changes to mod/wiki/backup/moodle2/restore_wiki_stepslib.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2013-11-22 14:09:51 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20131122140951-91mw814y48z5ts8r
Tags: 2.5.3-1
* New upstream version: 2.5.3.
  - Incorporates CAS security patch.
  - Fixes security issues CVE-2013-4522, CVE-2013-4523,
    CVE-2013-4524, CVE-2013-4525, CVE-2013-6780.

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
    protected function process_wiki_subwiki($data) {
71
71
        global $DB;
72
72
 
73
 
 
74
 
        $data = (object)$data;
 
73
        $data = (object) $data;
75
74
        $oldid = $data->id;
76
75
        $data->wikiid = $this->get_new_parentid('wiki');
77
 
        $data->groupid = $this->get_mappingid('group', $data->groupid);
78
 
        $data->userid = $this->get_mappingid('user', $data->userid);
79
 
 
80
 
        $newitemid = $DB->insert_record('wiki_subwikis', $data);
 
76
 
 
77
        // If the groupid is not equal to zero, get the mapping for the group.
 
78
        if ((int) $data->groupid !== 0) {
 
79
            $data->groupid = $this->get_mappingid('group', $data->groupid);
 
80
        }
 
81
 
 
82
        // If the userid is not equal to zero, get the mapping for the user.
 
83
        if ((int) $data->userid !== 0) {
 
84
            $data->userid = $this->get_mappingid('user', $data->userid);
 
85
        }
 
86
 
 
87
        // If these values are not equal to false then a mapping was successfully made.
 
88
        if ($data->groupid !== false && $data->userid !== false) {
 
89
            $newitemid = $DB->insert_record('wiki_subwikis', $data);
 
90
        } else {
 
91
            $newitemid = false;
 
92
        }
 
93
 
81
94
        $this->set_mapping('wiki_subwiki', $oldid, $newitemid);
82
95
    }
 
96
 
83
97
    protected function process_wiki_page($data) {
84
98
        global $DB;
85
99
 
86
 
        $data = (object)$data;
 
100
        $data = (object) $data;
87
101
        $oldid = $data->id;
88
102
        $data->subwikiid = $this->get_new_parentid('wiki_subwiki');
89
103
        $data->userid = $this->get_mappingid('user', $data->userid);
91
105
        $data->timecreated = $this->apply_date_offset($data->timecreated);
92
106
        $data->timerendered = $this->apply_date_offset($data->timerendered);
93
107
 
94
 
        $newitemid = $DB->insert_record('wiki_pages', $data);
95
 
        $this->set_mapping('wiki_page', $oldid, $newitemid, true); // There are files related to this
 
108
        // Check that we were able to get a parentid for this page.
 
109
        if ($data->subwikiid !== false) {
 
110
            $newitemid = $DB->insert_record('wiki_pages', $data);
 
111
        } else {
 
112
            $newitemid = false;
 
113
        }
 
114
 
 
115
        $this->set_mapping('wiki_page', $oldid, $newitemid, true);
96
116
    }
 
117
 
97
118
    protected function process_wiki_version($data) {
98
119
        global $DB;
99
120