コード例 #1
0
                if ($found and $ch->subchapter) {
                    $fs->delete_area_files($context->id, 'mod_book', 'chapter', $ch->id);
                    $DB->delete_records('book_chapters', array('id' => $ch->id));
                    \mod_book\event\chapter_deleted::create_from_chapter($book, $context, $ch)->trigger();
                } else {
                    if ($found) {
                        break;
                    }
                }
            }
        }
        $chapters->close();
    }
    $fs->delete_area_files($context->id, 'mod_book', 'chapter', $chapter->id);
    $DB->delete_records('book_chapters', array('id' => $chapter->id));
    \mod_book\event\chapter_deleted::create_from_chapter($book, $context, $chapter)->trigger();
    book_preload_chapters($book);
    // Fix structure.
    $DB->set_field('book', 'revision', $book->revision + 1, array('id' => $book->id));
    redirect('view.php?id=' . $cm->id);
}
echo $OUTPUT->header();
echo $OUTPUT->heading($book->name);
// The operation has not been confirmed yet so ask the user to do so.
if ($chapter->subchapter) {
    $strconfirm = get_string('confchapterdelete', 'mod_book');
} else {
    $strconfirm = get_string('confchapterdeleteall', 'mod_book');
}
echo '<br />';
$continue = new moodle_url('/mod/book/delete.php', array('id' => $cm->id, 'chapterid' => $chapter->id, 'confirm' => 1));
コード例 #2
0
ファイル: events_test.php プロジェクト: evltuma/moodle
 public function test_chapter_deleted()
 {
     // There is no proper API to call to delete chapters for a book, so what we are
     // doing here is simply making sure that the events returns the right information.
     $course = $this->getDataGenerator()->create_course();
     $book = $this->getDataGenerator()->create_module('book', array('course' => $course->id));
     $bookgenerator = $this->getDataGenerator()->get_plugin_generator('mod_book');
     $context = context_module::instance($book->cmid);
     $chapter = $bookgenerator->create_chapter(array('bookid' => $book->id));
     $event = \mod_book\event\chapter_deleted::create_from_chapter($book, $context, $chapter);
     $legacy = array($course->id, 'book', 'update', 'view.php?id=' . $book->cmid, $book->id, $book->cmid);
     // Triggering and capturing the event.
     $sink = $this->redirectEvents();
     $event->trigger();
     $events = $sink->get_events();
     $this->assertCount(1, $events);
     $event = reset($events);
     // Checking that the event contains the expected values.
     $this->assertInstanceOf('\\mod_book\\event\\chapter_deleted', $event);
     $this->assertEquals(context_module::instance($book->cmid), $event->get_context());
     $this->assertEquals($chapter->id, $event->objectid);
     $this->assertEquals($chapter, $event->get_record_snapshot('book_chapters', $chapter->id));
     $this->assertEventLegacyLogData($legacy, $event);
     $this->assertEventContextNotUsed($event);
 }
コード例 #3
0
ファイル: delete.php プロジェクト: EmmanuelYupit/educursos
                    $event->add_record_snapshot('book_chapters', $ch);
                    $event->trigger();
                } else {
                    if ($found) {
                        break;
                    }
                }
            }
        }
        $chapters->close();
    }
    $fs->delete_area_files($context->id, 'mod_book', 'chapter', $chapter->id);
    $DB->delete_records('book_chapters', array('id' => $chapter->id));
    add_to_log($course->id, 'course', 'update mod', '../mod/book/view.php?id=' . $cm->id, 'book ' . $book->id);
    $params = array('context' => $context, 'objectid' => $chapter->id);
    $event = \mod_book\event\chapter_deleted::create($params);
    $event->add_record_snapshot('book_chapters', $chapter);
    $event->set_legacy_logdata(array($course->id, 'book', 'update', 'view.php?id=' . $cm->id, $book->id, $cm->id));
    $event->trigger();
    book_preload_chapters($book);
    // Fix structure.
    $DB->set_field('book', 'revision', $book->revision + 1, array('id' => $book->id));
    redirect('view.php?id=' . $cm->id);
}
echo $OUTPUT->header();
echo $OUTPUT->heading($book->name);
// The operation has not been confirmed yet so ask the user to do so.
if ($chapter->subchapter) {
    $strconfirm = get_string('confchapterdelete', 'mod_book');
} else {
    $strconfirm = get_string('confchapterdeleteall', 'mod_book');