function addpost_submit(Pieform $form, $values)
{
    global $USER, $SESSION;
    $parentid = param_integer('parent');
    $postid = insert_record('interaction_forum_post', (object) array('topic' => $values['topic'], 'poster' => $USER->get('id'), 'parent' => $parentid, 'subject' => $values['subject'], 'body' => $values['body'], 'ctime' => db_format_timestamp(time())), 'id', true);
    $delay = get_config_plugin('interaction', 'forum', 'postdelay');
    if (!is_null($delay) && $delay == 0) {
        PluginInteractionForum::interaction_forum_new_post(array($postid));
    }
    $SESSION->add_ok_msg(get_string('addpostsuccess', 'interaction.forum'));
    redirect('/interaction/forum/topic.php?id=' . $values['topic'] . '#post' . $postid);
}
예제 #2
0
파일: view.php 프로젝트: kienv/mahara
 } else {
     if ($moderator && $type == 'closed') {
         set_field_select('interaction_forum_topic', 'closed', 1, 'id IN (' . implode(',', $checked) . ')', array());
         $SESSION->add_ok_msg(get_string('topicclosedsuccess', 'interaction.forum'));
     } else {
         if ($moderator && $type == 'open') {
             set_field_select('interaction_forum_topic', 'closed', 0, 'id IN (' . implode(',', $checked) . ')', array());
             $SESSION->add_ok_msg(get_string('topicopenedsuccess', 'interaction.forum'));
         } else {
             if ($moderator && $type == 'moveto') {
                 $newforumid = param_integer('newforum');
                 // Check if the new forum is in the current group
                 $newforum = interaction_instance_from_id($newforumid);
                 if ($newforum && $newforum->get('group') == $forum->groupid) {
                     set_field_select('interaction_forum_topic', 'forum', $newforumid, 'id IN (' . implode(',', $checked) . ')', array());
                     PluginInteractionForum::interaction_forum_new_post($checked);
                     $SESSION->add_ok_msg(get_string('topicmovedsuccess', 'interaction.forum', count($checked)));
                 }
             } else {
                 if ($type == 'subscribe' && !$forum->subscribed) {
                     db_begin();
                     foreach ($checked as $key => $value) {
                         if (!record_exists('interaction_forum_subscription_topic', 'user', $USER->get('id'), 'topic', $value)) {
                             insert_record('interaction_forum_subscription_topic', (object) array('user' => $USER->get('id'), 'topic' => $value, 'key' => PluginInteractionForum::generate_unsubscribe_key()));
                         }
                     }
                     db_commit();
                     $SESSION->add_ok_msg(get_string('topicsubscribesuccess', 'interaction.forum'));
                 } else {
                     if ($type == 'unsubscribe' && !$forum->subscribed) {
                         delete_records_sql('DELETE FROM {interaction_forum_subscription_topic}
예제 #3
0
파일: editpost.php 프로젝트: patkira/mahara
function addpost_submit(Pieform $form, $values)
{
    global $USER, $SESSION;
    require_once 'embeddedimage.php';
    $parentid = param_integer('parent');
    $post = (object) array('topic' => $values['topic'], 'poster' => $USER->get('id'), 'parent' => $parentid, 'subject' => $values['subject'], 'body' => $values['body'], 'ctime' => db_format_timestamp(time()));
    $sendnow = isset($values['sendnow']) && $values['sendnow'] ? 1 : 0;
    // See if the same content has been submitted in the last 5 seconds. If so, don't add this post.
    $oldpost = get_record_select('interaction_forum_post', 'topic = ? AND poster = ? AND parent = ? AND subject = ? AND body = ? AND ctime > ?', array($post->topic, $post->poster, $post->parent, $post->subject, $post->body, db_format_timestamp(time() - 5)), 'id');
    if ($oldpost) {
        redirect(get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $values['topic'] . '&post=' . $oldpost->id);
    }
    $postrec = new stdClass();
    $postid = $postrec->id = insert_record('interaction_forum_post', $post, 'id', true);
    $postrec->path = get_field('interaction_forum_post', 'path', 'id', $parentid) . '/' . sprintf('%010d', $postrec->id);
    update_record('interaction_forum_post', $postrec);
    // Rewrite the post id into links in the body
    $groupid = get_groupid_from_postid($postid);
    $newbody = EmbeddedImage::prepare_embedded_images($post->body, 'post', $postid, $groupid);
    $newbody = PluginInteractionForum::prepare_post_body($newbody, $postid);
    if (!empty($newbody) && $newbody != $post->body) {
        set_field('interaction_forum_post', 'body', $newbody, 'id', $postid);
    }
    if ($sendnow == 0) {
        $delay = get_config_plugin('interaction', 'forum', 'postdelay');
    } else {
        $delay = 0;
    }
    if (!is_null($delay) && $delay == 0) {
        PluginInteractionForum::interaction_forum_new_post(array($postid));
    }
    $SESSION->add_ok_msg(get_string('addpostsuccess', 'interaction.forum'));
    if (is_using_probation() && $post->parent) {
        $parentposter = get_field('interaction_forum_post', 'poster', 'id', $post->parent);
        vouch_for_probationary_user($parentposter);
    }
    redirect(get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $values['topic'] . '&post=' . $postid);
}
예제 #4
0
function addtopic_submit(Pieform $form, $values)
{
    global $USER, $SESSION;
    $forumid = param_integer('forum');
    $groupid = get_field('interaction_instance', '"group"', 'id', $forumid);
    db_begin();
    $topicid = insert_record('interaction_forum_topic', (object) array('forum' => $forumid, 'sticky' => isset($values['sticky']) && $values['sticky'] ? 1 : 0, 'closed' => isset($values['closed']) && $values['closed'] ? 1 : 0), 'id', true);
    $sendnow = isset($values['sendnow']) && $values['sendnow'] ? 1 : 0;
    $post = (object) array('topic' => $topicid, 'poster' => $USER->get('id'), 'subject' => $values['subject'], 'body' => $values['body'], 'ctime' => db_format_timestamp(time()));
    $postid = insert_record('interaction_forum_post', $post, 'id', true);
    set_field('interaction_forum_post', 'path', sprintf('%010d', $postid), 'id', $postid);
    // Rewrite the post id into links in the body
    $newbody = EmbeddedImage::prepare_embedded_images($post->body, 'topic', $topicid, $groupid);
    $newbody = PluginInteractionForum::prepare_post_body($newbody, $postid);
    if (!empty($newbody) && $newbody != $post->body) {
        set_field('interaction_forum_post', 'body', $newbody, 'id', $postid);
    }
    if (!record_exists('interaction_forum_subscription_forum', 'user', $USER->get('id'), 'forum', $forumid)) {
        insert_record('interaction_forum_subscription_topic', (object) array('user' => $USER->get('id'), 'topic' => $topicid, 'key' => PluginInteractionForum::generate_unsubscribe_key()));
    }
    db_commit();
    if ($sendnow == 0) {
        $delay = get_config_plugin('interaction', 'forum', 'postdelay');
    } else {
        $delay = 0;
    }
    if (!is_null($delay) && $delay == 0) {
        PluginInteractionForum::interaction_forum_new_post(array($postid));
    }
    $SESSION->add_ok_msg(get_string('addtopicsuccess', 'interaction.forum'));
    redirect('/interaction/forum/topic.php?id=' . $topicid);
}
function addtopic_submit(Pieform $form, $values)
{
    global $USER, $SESSION;
    $forumid = param_integer('forum');
    db_begin();
    $topicid = insert_record('interaction_forum_topic', (object) array('forum' => $forumid, 'sticky' => isset($values['sticky']) && $values['sticky'] ? 1 : 0, 'closed' => isset($values['closed']) && $values['closed'] ? 1 : 0), 'id', true);
    $postid = insert_record('interaction_forum_post', (object) array('topic' => $topicid, 'poster' => $USER->get('id'), 'subject' => $values['subject'], 'body' => $values['body'], 'ctime' => db_format_timestamp(time())), 'id', true);
    if (!record_exists('interaction_forum_subscription_forum', 'user', $USER->get('id'), 'forum', $forumid)) {
        insert_record('interaction_forum_subscription_topic', (object) array('user' => $USER->get('id'), 'topic' => $topicid, 'key' => PluginInteractionForum::generate_unsubscribe_key()));
    }
    db_commit();
    $delay = get_config_plugin('interaction', 'forum', 'postdelay');
    if (!is_null($delay) && $delay == 0) {
        PluginInteractionForum::interaction_forum_new_post(array($postid));
    }
    $SESSION->add_ok_msg(get_string('addtopicsuccess', 'interaction.forum'));
    redirect('/interaction/forum/topic.php?id=' . $topicid);
}