Пример #1
0
        //expired edit time is the most probable cause here
        print_error('erredittimeexpired', 'glossary', "view.php?id={$cm->id}&mode=entry&hook={$e}");
    }
} else {
    // new entry
    require_capability('mod/glossary:write', $context);
}
$mform =& new mod_glossary_entry_form(null, compact('cm', 'glossary', 'hook', 'mode', 'e', 'context'));
if ($mform->is_cancelled()) {
    if ($e) {
        redirect("view.php?id={$cm->id}&mode=entry&hook={$e}");
    } else {
        redirect("view.php?id={$cm->id}");
    }
} elseif ($fromform = $mform->get_data()) {
    trusttext_after_edit($fromform->definition, $context);
    if (!isset($fromform->usedynalink)) {
        $fromform->usedynalink = 0;
    }
    if (!isset($fromform->casesensitive)) {
        $fromform->casesensitive = 0;
    }
    if (!isset($fromform->fullmatch)) {
        $fromform->fullmatch = 0;
    }
    $timenow = time();
    $todb = new object();
    $todb->course = $glossary->course;
    $todb->glossaryid = $glossary->id;
    $todb->concept = trim($fromform->concept);
    $todb->definition = $fromform->definition;
Пример #2
0
/**
 * Edit existing comments
 */
function glossary_comment_edit()
{
    global $CFG, $USER;
    $cid = optional_param('cid', 0, PARAM_INT);
    // Comment ID
    if (!($comment = get_record('glossary_comments', 'id', $cid))) {
        error('Comment is incorrect');
    }
    if (!($entry = get_record('glossary_entries', 'id', $comment->entryid))) {
        error('Entry is incorrect');
    }
    if (!($glossary = get_record('glossary', 'id', $entry->glossaryid))) {
        error('Incorrect glossary');
    }
    if (!($cm = get_coursemodule_from_instance('glossary', $glossary->id))) {
        error('Course Module ID was incorrect');
    }
    if (!($course = get_record('course', 'id', $cm->course))) {
        error('Course is misconfigured');
    }
    require_login($course->id, false, $cm);
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    if (!$glossary->allowcomments and !has_capability('mod/glossary:managecomments', $context)) {
        error('You can\'t edit comments in this glossary!');
    }
    if ($comment->userid != $USER->id and !has_capability('mod/glossary:managecomments', $context)) {
        error('You can\'t edit other people\'s comments!');
    }
    $ineditperiod = time() - $comment->timemodified < $CFG->maxeditingtime || $glossary->editalways;
    if ((!has_capability('mod/glossary:comment', $context) or !$ineditperiod) and !has_capability('mod/glossary:managecomments', $context)) {
        error('You can\'t edit this. Time expired!');
    }
    $mform = new mod_glossary_comment_form();
    trusttext_prepare_edit($comment->entrycomment, $comment->format, can_use_html_editor(), $context);
    $mform->set_data(array('cid' => $cid, 'action' => 'edit', 'entrycomment' => $comment->entrycomment, 'format' => $comment->format));
    if ($data = $mform->get_data()) {
        trusttext_after_edit($data->entrycomment, $context);
        $updatedcomment = new object();
        $updatedcomment->id = $cid;
        $updatedcomment->entrycomment = $data->entrycomment;
        $updatedcomment->format = $data->format;
        $updatedcomment->timemodified = time();
        if (!update_record('glossary_comments', $updatedcomment)) {
            error('Could not update this comment');
        } else {
            add_to_log($course->id, 'glossary', 'update comment', "comments.php?id={$cm->id}&amp;eid={$entry->id}", "{$updatedcomment->id}", $cm->id);
        }
        redirect("comments.php?id={$cm->id}&amp;eid={$entry->id}");
    } else {
        glossary_comment_print_header($course, $cm, $glossary, $entry, 'edit');
        $mform->display();
        print_footer($course);
        die;
    }
}
Пример #3
0
 /**
  * Set body.
  *
  * @access public
  * @version 1.0
  * @param text $body Body
  */
 function set_body($body = '')
 {
     if (empty($body)) {
         $this->body = '';
         // Define one value
     } else {
         $context = get_context_instance(CONTEXT_COURSE, $this->course);
         trusttext_after_edit($body, $context);
         $this->body = $body;
     }
     return true;
 }
Пример #4
0
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
// setup course variable to force form language
// fix for MDL-6926
course_setup($course->id);
require_once 'post_form.php';
$mform_post = new mod_forum_post_form('post.php', array('course' => $course, 'coursecontext' => $coursecontext, 'modcontext' => $modcontext, 'forum' => $forum, 'post' => $post));
if ($fromform = $mform_post->get_data()) {
    require_login($course, false, $cm);
    if (empty($SESSION->fromurl)) {
        $errordestination = "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}";
    } else {
        $errordestination = $SESSION->fromurl;
    }
    // TODO add attachment processing
    //$fromform->attachment = isset($_FILES['attachment']) ? $_FILES['attachment'] : NULL;
    trusttext_after_edit($fromform->message, $modcontext);
    if ($fromform->edit) {
        // Updating a post
        $fromform->id = $fromform->edit;
        $message = '';
        //fix for bug #4314
        if (!($realpost = get_record('forum_posts', 'id', $fromform->id))) {
            $realpost = new object();
            $realpost->userid = -1;
        }
        // if user has edit any post capability
        // or has either startnewdiscussion or reply capability and is editting own post
        // then he can proceed
        // MDL-7066
        if (!($realpost->userid == $USER->id && (has_capability('mod/forum:replypost', $modcontext) || has_capability('mod/forum:startdiscussion', $modcontext)) || has_capability('mod/forum:editanypost', $modcontext))) {
            error("You can not update this post");
echo '</select>';
echo '<input type="hidden" name="courseid" value="' . $courseid . '" />';
echo '<input type="submit" value="' . get_string("update") . '" />';
echo '</form>';
echo "<div class='block_eportfolio_center'>";
print_simple_box(text_to_html(get_string("explainpersonal", "block_exabis_eportfolio")), 'center');
echo "</div>";
if ($edit) {
    if (!confirm_sesskey()) {
        print_error("badsessionkey", "block_exabis_eportfolio");
    }
    $informationform = new block_exabis_eportfolio_personal_information_form();
    if ($informationform->is_cancelled()) {
    } else {
        if ($fromform = $informationform->get_data()) {
            trusttext_after_edit($newentry->description, $context);
            block_exabis_eportfolio_set_user_preferences(array('description' => $fromform->description, 'persinfo_timemodified' => time()));
            // read new data from the database
            $userpreferences = block_exabis_eportfolio_get_user_preferences();
            $description = $userpreferences->description;
            print_simple_box(get_string("descriptionsaved", "block_exabis_eportfolio"), 'center', '40%', '#ccffbb');
        } else {
            $show_information = false;
            $informationform->set_data(array('courseid' => $courseid, 'description' => $description, 'cataction' => 'save', 'edit' => 1));
            $informationform->display();
        }
    }
}
if ($show_information) {
    echo '<table cellspacing="0" class="forumpost blogpost blog" width="100%">';
    echo '<tr class="header"><td class="picture left">';