Example #1
0
}
if (!($book = get_record('hiperbook', 'id', $cm->instance))) {
    error('Course module is incorrect');
}
$db->debug = true;
switch ($mode) {
    case 'hiperbook':
        hiperbook_unlock_hiperbook($bookid, $lock);
        break;
    case 'navpath':
        hiperbook_unlock_navpath($navpathid, $lock);
        break;
    case 'chapter':
        hiperbook_unlock_chapter($chapterid, $lock);
        break;
    case 'page':
        hiperbook_unlock_page($pageid, $lock);
        break;
    case 'tip':
        hiperbook_unlock_tip($tipid, $lock);
        break;
    case 'hotword':
        hiperbook_unlock_hotword($hotwordid, $lock);
        break;
    case 'suggestion':
        hiperbook_unlock_suggestion($suggestionid, $lock);
        break;
}
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);
redirect($_SERVER['HTTP_REFERER']);
Example #2
0
function hiperbook_unlock_page($pageid, $lock)
{
    global $CFG;
    if ($lock == 1) {
        $value = 0;
    } else {
        $value = 1;
    }
    $page = get_record('hiperbook_chapters_pages', 'id', $pageid);
    $page->opentostudents = $value;
    $page->content = addslashes($page->content);
    if (!update_record('hiperbook_chapters_pages', $page)) {
        error('Could not update your page!!!');
    }
    $tips = get_records_select('hiperbook_pages_tips', 'idpage=' . $page->id, 'id');
    foreach ($tips as $tip) {
        hiperbook_unlock_tip($tip->idtip, $lock);
    }
    $suggs = get_records_select('hiperbook_pages_suggestions', 'idpage=' . $page->id, 'id');
    foreach ($suggs as $sugg) {
        hiperbook_unlock_suggestion($sugg->idsuggestion, $lock);
    }
    $hws = get_records_select('hiperbook_pages_hotwords', 'idpage=' . $page->id, 'id');
    foreach ($hws as $hw) {
        hiperbook_unlock_hotword($hw->idhotword, $lock);
    }
}