예제 #1
0
    $navpath = get_record('hiperbook_navigationpath', 'navpathnum', $navigationnum, 'bookid', $cm->instance);
    $navchapter = get_record('hiperbook_navigation_chapters', 'chapterid', $chapterid, 'navigationid', $navpath->id);
    $parentnavchapter = get_record('hiperbook_navigation_chapters', 'id', $navchapter->parentnavchapterid, 'navigationid', $navpath->id);
    hiperbook_remove_chapter_navpath($chapterid, $navigationnum, $navchapter->parentnavchapterid->id, $cm);
    redirect("view.php?id={$cm->id}&chapterid={$parentnavchapter->chapterid}&navigationnum={$navigationnum}&target_navigation_chapter={$parentnavchapter->id}");
}
///remove o capitulo e todas a navegacoes
if ($confirm == 2 & $justnavpath == 0) {
    // the operation was confirmed.
    echo "kapput";
    add_to_log($course->id, 'course', 'update mod', '../mod/hiperbook/view.php?id=' . $cm->id, 'hiperbook ' . $book->id);
    add_to_log($course->id, 'hiperbook', 'update', 'view.php?id=' . $cm->id, $book->id, $cm->id);
    $navpath = get_record('hiperbook_navigationpath', 'navpathnum', $navigationnum, 'bookid', $cm->instance);
    $navchapter = get_record('hiperbook_navigation_chapters', 'chapterid', $chapterid, 'navigationid', $navpath->id);
    $parentnavchapter = get_record('hiperbook_navigation_chapters', 'id', $navchapter->parentnavchapterid, 'navigationid', $navpath->id);
    hiperbook_remove_chapter($chapterid, $cm);
    redirect("view.php?id={$cm->id}&chapterid={$parentnavchapter->chapterid}&navigationnum={$navigationnum}&target_navigation_chapter={$parentnavchapter->id}");
}
if ($justnavpath == 0 & $confirm == 0) {
    // não se sabe se deseja apagar apenas a nevagação ou o capitulo todo
    $strconfirm = "Deseja apagar apenas a navegação pelo capítulo? <br><br>\r\n\t\tSe <b>sim</b>, irá apagar apenas a indicação deste capítulo neste nível. Posteriormente você poderá utilizar este capítulo criando um link;<br><br>\r\n\t\tSe <b>não</b>, irá apagar o capitulo e sub capítulos, dicas e etc em todos os níveis. O capítulo é apagado em definitivo;";
    echo '<br />';
    notice_yesno("<b>{$chapter->title}</b><p>{$strconfirm}</p>", "delete.php?id={$cm->id}&chapterid={$chapterid}&justnavpath=1&confirm=1&sesskey={$USER->sesskey}&navigationnum={$navigationnum}", "delete.php?id={$cm->id}&chapterid={$chapterid}&justnavpath=0&confirm=1&sesskey={$USER->sesskey}&navigationnum={$navigationnum}");
}
if ($confirm == 1 & $justnavpath == 0) {
    // the operation has not been confirmed yet so ask the user to do so
    if ($chapter->subchapter) {
        $strconfirm = get_string('confchapterdelete', 'hiperbook');
    } else {
        $strconfirm = get_string('confchapterdeleteall', 'hiperbook');
    }
예제 #2
0
function hiperbook_delete_instance($id)
{
    /// Given an ID of an instance of this module,
    /// this function will permanently delete the instance
    /// and any data that depends on it.
    if (!($book = get_record('hiperbook', 'id', $id))) {
        return false;
    }
    $module = get_record('modules', 'name', 'hiperbook');
    $cm = get_record('course_modules', 'instance', $id, 'module', $module->id);
    $result = true;
    $chapters = get_records_select('hiperbook_chapters', "bookid = {$book->id}");
    foreach ($chapters as $chapter) {
        hiperbook_remove_chapter($chapter->id, $cm);
    }
    if (!delete_records('hiperbook_navigationpath', 'bookid', $book->id)) {
        $result = false;
    }
    if (!delete_records('hiperbook', 'id', $book->id)) {
        $result = false;
    }
    //echo 'funcao nao disponivel';
    return $result;
}