. namespace mod_book; /** * Book helper * * @package mod_book * @copyright 2023 Laurent David * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class helper { /** * Check if we are on the last visible chapter of the book. * * @param int $chapterid * @param array $chapters chapter list provided by book_preload_chapters * @see book_preload_chapters * @return bool */ public static function is_last_visible_chapter(int $chapterid, array $chapters): bool { $lastchapterid = 0; foreach ($chapters as $ch) { if ($ch->hidden) { continue; } $lastchapterid = $ch->id; } return $chapterid == $lastchapterid; } }