コード例 #1
0
ファイル: comment.php プロジェクト: nicolasconnault/moodle2.0
}
$mform = new mod_data_comment_form();
$mform->set_data(array('mode' => $mode, 'page' => $page, 'rid' => $record->id, 'commentid' => $commentid));
if ($comment) {
    $format = $comment->format;
    $content = $comment->content;
    if (can_use_html_editor()) {
        $options = new object();
        $options->smiley = false;
        $options->filter = false;
        $content = format_text($content, $format, $options);
        $format = FORMAT_HTML;
    }
    $mform->set_data(array('content' => $content, 'format' => $format));
}
if ($mform->is_cancelled()) {
    redirect('view.php?rid=' . $record->id . '&page=' . $page);
}
switch ($mode) {
    case 'add':
        if (!($formadata = $mform->get_data())) {
            break;
            // something is wrong here, try again
        }
        $newcomment = new object();
        $newcomment->userid = $USER->id;
        $newcomment->created = time();
        $newcomment->modified = time();
        $newcomment->content = $formadata->content;
        $newcomment->recordid = $formadata->rid;
        if ($DB->insert_record('data_comments', $newcomment)) {