if ($mybb->input['inlinetype'] == 'search') {
         $posts = getids($mybb->input['searchid'], 'search');
     } else {
         $posts = getids($tid, 'thread');
     }
     if (count($posts) < 1) {
         error($lang->error_inline_nopostsselected);
     }
     $pids = array();
     if (!is_moderator_by_pids($posts, "canmanagethreads")) {
         error_no_permission();
     }
     foreach ($posts as $pid) {
         $pids[] = intval($pid);
     }
     $moderation->unapprove_posts($pids);
     log_moderator_action($modlogdata, $lang->multi_unapprove_posts);
     if ($mybb->input['inlinetype'] == 'search') {
         clearinline($mybb->input['searchid'], 'search');
     } else {
         clearinline($tid, 'thread');
     }
     moderation_redirect(get_thread_link($thread['tid']), $lang->redirect_inline_postsunapproved);
     break;
 default:
     require_once MYBB_ROOT . "inc/class_custommoderation.php";
     $custommod = new CustomModeration();
     $tool = $custommod->tool_info(intval($mybb->input['action']));
     if ($tool !== false) {
         // Verify incoming POST request
         verify_post_check($mybb->input['my_post_key']);
예제 #2
0
 /**
  * Updates a post that is already in the database.
  *
  */
 function update_post()
 {
     global $db, $mybb, $plugins;
     // Yes, validating is required.
     if ($this->get_validated() != true) {
         die("The post needs to be validated before inserting it into the DB.");
     }
     if (count($this->get_errors()) > 0) {
         die("The post is not valid.");
     }
     $post =& $this->data;
     $post['pid'] = (int) $post['pid'];
     $existing_post = get_post($post['pid']);
     $post['tid'] = $existing_post['tid'];
     $post['fid'] = $existing_post['fid'];
     $forum = get_forum($post['fid']);
     $forumpermissions = forum_permissions($post['fid'], $post['uid']);
     // Check if this is the first post in a thread.
     $options = array("order_by" => "dateline", "order_dir" => "asc", "limit_start" => 0, "limit" => 1);
     $query = $db->simple_select("posts", "pid", "tid='" . (int) $post['tid'] . "'", $options);
     $first_post_check = $db->fetch_array($query);
     if ($first_post_check['pid'] == $post['pid']) {
         $first_post = true;
     } else {
         $first_post = false;
     }
     // Decide on the visibility of this post.
     $ismod = is_moderator($post['fid'], "", $post['uid']);
     // Keep visibility for unapproved and deleted posts
     if ($existing_post['visible'] == 0) {
         $visible = 0;
     } elseif ($existing_post['visible'] == -1) {
         $visible = -1;
     } elseif ($forumpermissions['mod_edit_posts'] == 1 && !$ismod) {
         $visible = 0;
         require_once MYBB_ROOT . "inc/class_moderation.php";
         $moderation = new Moderation();
         $moderation->unapprove_posts(array($post['pid']));
     } else {
         $visible = 1;
     }
     // Update the thread details that might have been changed first.
     if ($first_post) {
         $this->tid = $post['tid'];
         if (isset($post['prefix'])) {
             $this->thread_update_data['prefix'] = (int) $post['prefix'];
         }
         if (isset($post['subject'])) {
             $this->thread_update_data['subject'] = $db->escape_string($post['subject']);
         }
         if (isset($post['icon'])) {
             $this->thread_update_data['icon'] = (int) $post['icon'];
         }
         if (count($this->thread_update_data) > 0) {
             $plugins->run_hooks("datahandler_post_update_thread", $this);
             $db->update_query("threads", $this->thread_update_data, "tid='" . (int) $post['tid'] . "'");
         }
     }
     // Prepare array for post updating.
     $this->pid = $post['pid'];
     if (isset($post['subject'])) {
         $this->post_update_data['subject'] = $db->escape_string($post['subject']);
     }
     if (isset($post['message'])) {
         $this->post_update_data['message'] = $db->escape_string($post['message']);
     }
     if (isset($post['editreason']) && trim($post['editreason']) != '') {
         $this->post_update_data['editreason'] = $db->escape_string(trim($post['editreason']));
     }
     if (isset($post['icon'])) {
         $this->post_update_data['icon'] = (int) $post['icon'];
     }
     if (isset($post['options'])) {
         if (isset($post['options']['disablesmilies'])) {
             $this->post_update_data['smilieoff'] = $db->escape_string($post['options']['disablesmilies']);
         }
         if (isset($post['options']['signature'])) {
             $this->post_update_data['includesig'] = $db->escape_string($post['options']['signature']);
         }
     }
     // If we need to show the edited by, let's do so.
     if ($mybb->settings['showeditedby'] == 1 && !is_moderator($post['fid'], "caneditposts", $post['edit_uid']) || $mybb->settings['showeditedbyadmin'] == 1 && is_moderator($post['fid'], "caneditposts", $post['edit_uid'])) {
         $this->post_update_data['edituid'] = (int) $post['edit_uid'];
         $this->post_update_data['edittime'] = TIME_NOW;
     }
     $plugins->run_hooks("datahandler_post_update", $this);
     $db->update_query("posts", $this->post_update_data, "pid='" . (int) $post['pid'] . "'");
     // Automatic subscription to the thread
     if ($post['options']['subscriptionmethod'] != "" && $post['uid'] > 0) {
         switch ($post['options']['subscriptionmethod']) {
             case "pm":
                 $notification = 2;
                 break;
             case "email":
                 $notification = 1;
                 break;
             default:
                 $notification = 0;
         }
         require_once MYBB_ROOT . "inc/functions_user.php";
         add_subscribed_thread($post['tid'], $notification, $post['uid']);
     } else {
         $db->delete_query("threadsubscriptions", "uid='" . (int) $post['uid'] . "' AND tid='" . (int) $post['tid'] . "'");
     }
     update_forum_lastpost($post['fid']);
     update_last_post($post['tid']);
     // Return the thread's first post id and whether or not it is visible.
     $this->return_values = array('visible' => $visible, 'first_post' => $first_post);
     $plugins->run_hooks("datahandler_post_update_end", $this);
     return $this->return_values;
 }
예제 #3
0
function spamalyser_unapprove_edit(&$ph)
{
    require_once MYBB_ROOT . 'inc/class_moderation.php';
    $moderation = new Moderation();
    $moderation->unapprove_posts(array($ph->data['pid']));
    $ph->post_update_data['visible'] = 0;
    $GLOBALS['plugins']->remove_hook('datahandler_post_update', 'spamalyser_unapprove_edit');
    // update lang messages
    global $lang;
    $lang->load('spamalyser');
    $lang->redirect_thread_moderation = $lang->spamalyser_redirect_newthread_spam_blocked;
    $lang->redirect_post_moderation = $lang->spamalyser_redirect_newreply_spam_blocked;
}