Ejemplo n.º 1
0
 function print_content()
 {
     global $CFG, $PAGE;
     $version = wiki_get_version($this->version->id);
     $wiki = $PAGE->activityrecord;
     if (wiki_user_can_edit($this->subwiki, $wiki) && wiki_restore_page($this->page, $version, $this->modcontext)) {
         redirect($CFG->wwwroot . '/mod/wiki/view.php?pageid=' . $this->page->id, get_string('restoring', 'wiki', $version->version), 3);
     } else {
         print_error('restoreerror', 'wiki', $version->version);
     }
 }
Ejemplo n.º 2
0
    function print_content() {
        global $CFG, $PAGE;

        require_capability('mod/wiki:managewiki', $this->modcontext, NULL, true, 'nomanagewikipermission', 'wiki');

        $version = wiki_get_version($this->version->id);
        if (wiki_restore_page($this->page, $version->content, $version->userid)) {
            redirect($CFG->wwwroot . '/mod/wiki/view.php?pageid=' . $this->page->id, get_string('restoring', 'wiki', $version->version), 3);
        } else {
            print_error('restoreerror', 'wiki', $version->version);
        }
    }
Ejemplo n.º 3
0
 /**
  * Test page_version_restored event.
  */
 public function test_page_version_restored()
 {
     $this->setUp();
     $page = $this->wikigenerator->create_first_page($this->wiki);
     $context = context_module::instance($this->wiki->cmid);
     $version = wiki_get_current_version($page->id);
     // Triggering and capturing the event.
     $sink = $this->redirectEvents();
     wiki_restore_page($page, $version, $context);
     $events = $sink->get_events();
     $this->assertCount(2, $events);
     $event = array_pop($events);
     // Checking that the event contains the expected values.
     $this->assertInstanceOf('\\mod_wiki\\event\\page_version_restored', $event);
     $this->assertEquals($context, $event->get_context());
     $this->assertEquals($version->id, $event->objectid);
     $this->assertEquals($page->id, $event->other['pageid']);
     $expected = array($this->course->id, 'wiki', 'restore', 'view.php?pageid=' . $page->id, $page->id, $this->wiki->cmid);
     $this->assertEventLegacyLogData($expected, $event);
     $this->assertEventContextNotUsed($event);
 }