Zeile 53 | Zeile 53 |
---|
* post = New post * thread = New thread * edit = Editing a thread or post
|
* post = New post * thread = New thread * edit = Editing a thread or post
|
| * * @var string
|
*/ public $action;
|
*/ public $action;
|
|
|
/** * Array of data inserted in to a post.
|
/** * Array of data inserted in to a post.
|
*
| *
|
* @var array */ public $post_insert_data = array();
| * @var array */ public $post_insert_data = array();
|
Zeile 67 | Zeile 69 |
---|
* Array of data used to update a post. * * @var array
|
* Array of data used to update a post. * * @var array
|
*/
| */
|
public $post_update_data = array();
/**
| public $post_update_data = array();
/**
|
Zeile 76 | Zeile 78 |
---|
* @var int */ public $pid = 0;
|
* @var int */ public $pid = 0;
|
|
|
/** * Array of data inserted in to a thread.
|
/** * Array of data inserted in to a thread.
|
* * @var array */
| * * @var array */
|
public $thread_insert_data = array();
|
public $thread_insert_data = array();
|
/**
| /**
|
* Array of data used to update a thread. * * @var array */ public $thread_update_data = array();
|
* Array of data used to update a thread. * * @var array */ public $thread_update_data = array();
|
|
|
/** * Thread ID currently being manipulated by the datahandlers.
|
/** * Thread ID currently being manipulated by the datahandlers.
|
*
| *
|
* @var int */ public $tid = 0;
/** * Values to be returned after inserting/updating a post/thread.
|
* @var int */ public $tid = 0;
/** * Values to be returned after inserting/updating a post/thread.
|
*
| *
|
* @var array
|
* @var array
|
*/
| */
|
public $return_values = array();
|
public $return_values = array();
|
| /** * Is this the first post of a thread when editing * * @var boolean */ public $first_post = false;
|
/** * Verifies the author of a post and fetches the username if necessary. *
| /** * Verifies the author of a post and fetches the username if necessary. *
|
Zeile 112 | Zeile 121 |
---|
*/ function verify_author() {
|
*/ function verify_author() {
|
global $mybb;
| global $mybb, $lang;
|
$post = &$this->data;
| $post = &$this->data;
|
Zeile 120 | Zeile 129 |
---|
if(!isset($post['uid'])) { $this->set_error("invalid_user_id");
|
if(!isset($post['uid'])) { $this->set_error("invalid_user_id");
|
return false; }
| return false; }
|
// If we have a user id but no username then fetch the username. else if($post['uid'] > 0 && empty($post['username'])) {
| // If we have a user id but no username then fetch the username. else if($post['uid'] > 0 && empty($post['username'])) {
|
Zeile 130 | Zeile 139 |
---|
} // if the uid is 0 verify the username else if($post['uid'] == 0 && $post['username'] != $lang->guest)
|
} // if the uid is 0 verify the username else if($post['uid'] == 0 && $post['username'] != $lang->guest)
|
{
| {
|
// Set up user handler require_once MYBB_ROOT."inc/datahandlers/user.php"; $userhandler = new UserDataHandler();
|
// Set up user handler require_once MYBB_ROOT."inc/datahandlers/user.php"; $userhandler = new UserDataHandler();
|
|
|
$data_array = array('username' => $post['username']); $userhandler->set_data($data_array);
|
$data_array = array('username' => $post['username']); $userhandler->set_data($data_array);
|
|
|
if(!$userhandler->verify_username())
|
if(!$userhandler->verify_username())
|
{
| {
|
// invalid username
|
// invalid username
|
| $this->errors = array_merge($this->errors, $userhandler->get_errors()); return false; } if($userhandler->verify_username_exists()) { // username is in use
|
$this->errors = array_merge($this->errors, $userhandler->get_errors()); return false; }
| $this->errors = array_merge($this->errors, $userhandler->get_errors()); return false; }
|
Zeile 152 | Zeile 168 |
---|
$post['username'] = "Guest"; }
|
$post['username'] = "Guest"; }
|
// Sanitize the username $post['username'] = htmlspecialchars_uni($post['username']);
| |
return true; }
/** * Verifies a post subject. *
|
return true; }
/** * Verifies a post subject. *
|
* @param string True if the subject is valid, false if invalid.
| |
* @return boolean True when valid, false when not valid. */ function verify_subject()
| * @return boolean True when valid, false when not valid. */ function verify_subject()
|
Zeile 170 | Zeile 183 |
---|
$subject = &$post['subject']; $subject = trim_blank_chrs($subject);
|
$subject = &$post['subject']; $subject = trim_blank_chrs($subject);
|
// Are we editing an existing thread or post?
| |
if($this->method == "update" && $post['pid']) {
|
if($this->method == "update" && $post['pid']) {
|
if(empty($post['tid'])) { $query = $db->simple_select("posts", "tid", "pid='".(int)$post['pid']."'"); $post['tid'] = $db->fetch_field($query, "tid"); } // Here we determine if we're editing the first post of a thread or not. $options = array( "limit" => 1, "limit_start" => 0, "order_by" => "dateline", "order_dir" => "asc" ); $query = $db->simple_select("posts", "pid", "tid='".$post['tid']."'", $options); $first_check = $db->fetch_array($query); if($first_check['pid'] == $post['pid']) { $first_post = true; } else { $first_post = false; }
| |
// If this is the first post there needs to be a subject, else make it the default one.
|
// If this is the first post there needs to be a subject, else make it the default one.
|
if(my_strlen($subject) == 0 && $first_post)
| if(my_strlen($subject) == 0 && $this->first_post)
|
{ $this->set_error("firstpost_no_subject"); return false; } elseif(my_strlen($subject) == 0)
|
{ $this->set_error("firstpost_no_subject"); return false; } elseif(my_strlen($subject) == 0)
|
{
| {
|
$thread = get_thread($post['tid']); $subject = "RE: ".$thread['subject']; }
| $thread = get_thread($post['tid']); $subject = "RE: ".$thread['subject']; }
|
Zeile 216 | Zeile 205 |
---|
{ $thread = get_thread($post['tid']); $subject = "RE: ".$thread['subject'];
|
{ $thread = get_thread($post['tid']); $subject = "RE: ".$thread['subject'];
|
} }
| } }
|
// This is a new thread and we require that a subject is present. else { if(my_strlen($subject) == 0)
|
// This is a new thread and we require that a subject is present. else { if(my_strlen($subject) == 0)
|
{
| {
|
$this->set_error("missing_subject"); return false;
|
$this->set_error("missing_subject"); return false;
|
}
| }
|
}
// If post is reply and begins with "RE: ", remove 4 from subject length.
| }
// If post is reply and begins with "RE: ", remove 4 from subject length.
|
Zeile 241 | Zeile 230 |
---|
}
if($subject_length > 85)
|
}
if($subject_length > 85)
|
{
| {
|
// Subject is too long $this->set_error('subject_too_long', my_strlen($subject));
|
// Subject is too long $this->set_error('subject_too_long', my_strlen($subject));
|
return false;
| return false;
|
}
// Subject is valid - return true. return true; }
|
}
// Subject is valid - return true. return true; }
|
|
|
/** * Verifies a post message. *
|
/** * Verifies a post message. *
|
* @param string The message content.
| * @return bool
|
*/ function verify_message() {
| */ function verify_message() {
|
Zeile 267 | Zeile 256 |
---|
if(my_strlen($post['message']) == 0) { $this->set_error("missing_message");
|
if(my_strlen($post['message']) == 0) { $this->set_error("missing_message");
|
return false; }
| return false; }
|
// If this board has a maximum message length check if we're over it. Use strlen because SQL limits are in bytes else if(strlen($post['message']) > $mybb->settings['maxmessagelength'] && $mybb->settings['maxmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid']))
|
// If this board has a maximum message length check if we're over it. Use strlen because SQL limits are in bytes else if(strlen($post['message']) > $mybb->settings['maxmessagelength'] && $mybb->settings['maxmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid']))
|
{
| {
|
$this->set_error("message_too_long", array($mybb->settings['maxmessagelength'], strlen($post['message']))); return false; }
| $this->set_error("message_too_long", array($mybb->settings['maxmessagelength'], strlen($post['message']))); return false; }
|
Zeile 281 | Zeile 270 |
---|
else { if(!isset($post['fid']))
|
else { if(!isset($post['fid']))
|
{
| {
|
$post['fid'] = 0; } if(!$mybb->settings['mycodemessagelength'])
| $post['fid'] = 0; } if(!$mybb->settings['mycodemessagelength'])
|
Zeile 289 | Zeile 278 |
---|
// Check to see of the text is full of MyCode require_once MYBB_ROOT."inc/class_parser.php"; $parser = new postParser;
|
// Check to see of the text is full of MyCode require_once MYBB_ROOT."inc/class_parser.php"; $parser = new postParser;
|
|
|
$message = $parser->text_parse_message($post['message']);
if(my_strlen($message) < $mybb->settings['minmessagelength'] && $mybb->settings['minmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid']))
|
$message = $parser->text_parse_message($post['message']);
if(my_strlen($message) < $mybb->settings['minmessagelength'] && $mybb->settings['minmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid']))
|
{
| {
|
$this->set_error("message_too_short", array($mybb->settings['minmessagelength'])); return false; }
|
$this->set_error("message_too_short", array($mybb->settings['minmessagelength'])); return false; }
|
}
| }
|
else if(my_strlen($post['message']) < $mybb->settings['minmessagelength'] && $mybb->settings['minmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid'])) { $this->set_error("message_too_short", array($mybb->settings['minmessagelength']));
|
else if(my_strlen($post['message']) < $mybb->settings['minmessagelength'] && $mybb->settings['minmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid'])) { $this->set_error("message_too_short", array($mybb->settings['minmessagelength']));
|
return false; } } return true; }
| return false; } } return true; }
|
/** * Verifies the specified post options are correct.
| /** * Verifies the specified post options are correct.
|
Zeile 326 | Zeile 315 |
---|
/** * Verify that the user is not flooding the system. *
|
/** * Verify that the user is not flooding the system. *
|
* @return boolean True
| * @return boolean
|
*/ function verify_post_flooding() {
| */ function verify_post_flooding() {
|
Zeile 340 | Zeile 329 |
---|
if($this->verify_post_merge(true) !== true) { return true;
|
if($this->verify_post_merge(true) !== true) { return true;
|
}
| }
|
// Fetch the user information for this post - used to check their last post date. $user = get_user($post['uid']);
| // Fetch the user information for this post - used to check their last post date. $user = get_user($post['uid']);
|
Zeile 353 | Zeile 342 |
---|
if($time_to_wait == 1) { $this->set_error("post_flooding_one_second");
|
if($time_to_wait == 1) { $this->set_error("post_flooding_one_second");
|
}
| }
|
else { $this->set_error("post_flooding", array($time_to_wait));
| else { $this->set_error("post_flooding", array($time_to_wait));
|
Zeile 365 | Zeile 354 |
---|
return true; }
|
return true; }
|
| /** * @param bool $simple_mode * * @return array|bool */
|
function verify_post_merge($simple_mode=false) { global $mybb, $db, $session;
| function verify_post_merge($simple_mode=false) { global $mybb, $db, $session;
|
Zeile 503 | Zeile 497 |
---|
return false; } }
|
return false; } }
|
| return true;
|
}
/**
| }
/**
|
Zeile 529 | Zeile 525 |
---|
// Throw back a message if over the count with the number of images as well as the maximum number of images per post. $this->set_error("too_many_videos", array(1 => $video_count, 2 => $mybb->settings['maxpostvideos'])); return false;
|
// Throw back a message if over the count with the number of images as well as the maximum number of images per post. $this->set_error("too_many_videos", array(1 => $video_count, 2 => $mybb->settings['maxpostvideos'])); return false;
|
} } }
| } }
return true; }
|
/** * Verify the reply-to post. *
| /** * Verify the reply-to post. *
|
Zeile 620 | Zeile 618 |
---|
function verify_prefix() { $prefix = &$this->data['prefix'];
|
function verify_prefix() { $prefix = &$this->data['prefix'];
|
$prefix_cache = build_prefixes();
| |
// If a valid prefix isn't supplied, don't assign one. if(empty($prefix))
| // If a valid prefix isn't supplied, don't assign one. if(empty($prefix))
|
Zeile 744 | Zeile 740 |
---|
if($this->method != "update" && !$post['savedraft']) { $this->verify_post_flooding();
|
if($this->method != "update" && !$post['savedraft']) { $this->verify_post_flooding();
|
| }
// Are we editing an existing thread or post? if($this->method == "update") { if(empty($post['tid'])) { $query = $db->simple_select("posts", "tid", "pid='".(int)$post['pid']."'"); $post['tid'] = $db->fetch_field($query, "tid"); } // Here we determine if we're editing the first post of a thread or not. $options = array( "limit" => 1, "limit_start" => 0, "order_by" => "dateline", "order_dir" => "asc" ); $query = $db->simple_select("posts", "pid", "tid='".$post['tid']."'", $options); $first_check = $db->fetch_array($query); if($first_check['pid'] == $post['pid']) { $this->first_post = true; }
|
}
// Verify all post assets.
| }
// Verify all post assets.
|
Zeile 763 | Zeile 782 |
---|
$this->verify_message(); $this->verify_image_count(); $this->verify_video_count();
|
$this->verify_message(); $this->verify_image_count(); $this->verify_video_count();
|
}
| }
|
if($this->method == "insert" || array_key_exists('dateline', $post)) { $this->verify_dateline();
|
if($this->method == "insert" || array_key_exists('dateline', $post)) { $this->verify_dateline();
|
}
| }
|
if($this->method == "insert" || array_key_exists('replyto', $post)) { $this->verify_reply_to();
|
if($this->method == "insert" || array_key_exists('replyto', $post)) { $this->verify_reply_to();
|
}
| }
|
if($this->method == "insert" || array_key_exists('icon', $post))
|
if($this->method == "insert" || array_key_exists('icon', $post))
|
{
| {
|
$this->verify_post_icon(); }
if($this->method == "insert" || array_key_exists('options', $post)) { $this->verify_options();
|
$this->verify_post_icon(); }
if($this->method == "insert" || array_key_exists('options', $post)) { $this->verify_options();
|
}
| }
if($this->method == "update" && $this->first_post) { $this->verify_prefix(); }
|
$plugins->run_hooks("datahandler_post_validate_post", $this);
| $plugins->run_hooks("datahandler_post_validate_post", $this);
|
Zeile 862 | Zeile 886 |
---|
$modoptions = $post['modoptions']; $modlogdata['fid'] = $thread['fid']; $modlogdata['tid'] = $thread['tid'];
|
$modoptions = $post['modoptions']; $modlogdata['fid'] = $thread['fid']; $modlogdata['tid'] = $thread['tid'];
|
$newstick = $newclosed = '';
| |
if(!isset($modoptions['closethread']))
|
if(!isset($modoptions['closethread']))
|
{ $modoptions['closethread'] = 0; }
| { $modoptions['closethread'] = $closed; }
$modoptions_update = array();
|
// Close the thread. if($modoptions['closethread'] == 1 && $thread['closed'] != 1)
|
// Close the thread. if($modoptions['closethread'] == 1 && $thread['closed'] != 1)
|
{ $newclosed = "closed=1";
| { $modoptions_update['closed'] = $closed = 0;
|
log_moderator_action($modlogdata, $lang->thread_closed);
|
log_moderator_action($modlogdata, $lang->thread_closed);
|
$closed = 1; }
| }
|
// Open the thread. if($modoptions['closethread'] != 1 && $thread['closed'] == 1) {
|
// Open the thread. if($modoptions['closethread'] != 1 && $thread['closed'] == 1) {
|
$newclosed = "closed=0";
| $modoptions_update['closed'] = $closed = 1;
|
log_moderator_action($modlogdata, $lang->thread_opened);
|
log_moderator_action($modlogdata, $lang->thread_opened);
|
$closed = 0; }
| }
|
if(!isset($modoptions['stickthread']))
|
if(!isset($modoptions['stickthread']))
|
{ $modoptions['stickthread'] = 0; }
| { $modoptions['stickthread'] = $thread['sticky']; }
|
// Stick the thread. if($modoptions['stickthread'] == 1 && $thread['sticky'] != 1) {
|
// Stick the thread. if($modoptions['stickthread'] == 1 && $thread['sticky'] != 1) {
|
$newstick = "sticky='1'";
| $modoptions_update['sticky'] = 1;
|
log_moderator_action($modlogdata, $lang->thread_stuck);
|
log_moderator_action($modlogdata, $lang->thread_stuck);
|
}
| }
|
// Unstick the thread. if($modoptions['stickthread'] != 1 && $thread['sticky']) {
|
// Unstick the thread. if($modoptions['stickthread'] != 1 && $thread['sticky']) {
|
$newstick = "sticky='0'";
| $modoptions_update['sticky'] = 0;
|
log_moderator_action($modlogdata, $lang->thread_unstuck);
|
log_moderator_action($modlogdata, $lang->thread_unstuck);
|
}
// Execute moderation options. if($newstick && $newclosed)
| }
// Execute moderation options. if($modoptions_update)
|
{
|
{
|
$sep = ",";
| $db->update_query('threads', $modoptions_update, "tid='{$thread['tid']}'");
|
}
|
}
|
else { $sep = ''; } if($newstick || $newclosed) { $db->write_query(" UPDATE ".TABLE_PREFIX."threads SET {$newclosed}{$sep}{$newstick} WHERE tid='{$thread['tid']}' "); } }
| }
|
// Fetch the forum this post is being made in $forum = get_forum($post['fid']);
| // Fetch the forum this post is being made in $forum = get_forum($post['fid']);
|
Zeile 934 | Zeile 944 |
---|
$visible = 0; } else
|
$visible = 0; } else
|
{
| {
|
$visible = 1; }
// Are posts from this user being moderated? Change visibility if($mybb->user['uid'] == $post['uid'] && $mybb->user['moderateposts'] == 1)
|
$visible = 1; }
// Are posts from this user being moderated? Change visibility if($mybb->user['uid'] == $post['uid'] && $mybb->user['moderateposts'] == 1)
|
{
| {
|
$visible = 0; }
|
$visible = 0; }
|
}
| }
|
if(!isset($post['pid'])) { $post['pid'] = 0;
| if(!isset($post['pid'])) { $post['pid'] = 0;
|
Zeile 957 | Zeile 967 |
---|
{ $query = $db->simple_select("posts", "tid", "pid='{$post['pid']}' AND uid='{$post['uid']}' AND visible='-2'"); $draft_check = $db->fetch_field($query, "tid");
|
{ $query = $db->simple_select("posts", "tid", "pid='{$post['pid']}' AND uid='{$post['uid']}' AND visible='-2'"); $draft_check = $db->fetch_field($query, "tid");
|
}
| }
|
else { $draft_check = false;
| else { $draft_check = false;
|
Zeile 966 | Zeile 976 |
---|
if($this->method != "update" && $visible == 1) { $double_post = $this->verify_post_merge();
|
if($this->method != "update" && $visible == 1) { $double_post = $this->verify_post_merge();
|
|
|
// Only combine if they are both invisible (mod queue'd forum) or both visible if($double_post !== true && $double_post['visible'] == $visible) {
| // Only combine if they are both invisible (mod queue'd forum) or both visible if($double_post !== true && $double_post['visible'] == $visible) {
|
Zeile 978 | Zeile 988 |
---|
); $update_query['edituid'] = (int)$post['uid']; $update_query['edittime'] = TIME_NOW;
|
); $update_query['edituid'] = (int)$post['uid']; $update_query['edittime'] = TIME_NOW;
|
$query = $db->update_query("posts", $update_query, "pid='".$double_post['pid']."'");
| $db->update_query("posts", $update_query, "pid='".$double_post['pid']."'");
|
if($draft_check) {
| if($draft_check) {
|
Zeile 1016 | Zeile 1026 |
---|
$plugins->run_hooks("datahandler_post_insert_merge", $this);
return $this->return_values;
|
$plugins->run_hooks("datahandler_post_insert_merge", $this);
return $this->return_values;
|
} }
if($visible == 1 && $thread['visible'] == 1)
| } }
if($visible == 1 && $thread['visible'] == 1)
|
{ $now = TIME_NOW;
| { $now = TIME_NOW;
|
Zeile 1045 | Zeile 1055 |
---|
"uid" => $post['uid'], "username" => $db->escape_string($post['username']), "dateline" => (int)$post['dateline'],
|
"uid" => $post['uid'], "username" => $db->escape_string($post['username']), "dateline" => (int)$post['dateline'],
|
"message" => $db->escape_string($post['message']),
| "message" => $db->escape_string($post['message']),
|
"ipaddress" => $db->escape_binary($post['ipaddress']), "includesig" => $post['options']['signature'], "smilieoff" => $post['options']['disablesmilies'],
| "ipaddress" => $db->escape_binary($post['ipaddress']), "includesig" => $post['options']['signature'], "smilieoff" => $post['options']['disablesmilies'],
|
Zeile 1102 | Zeile 1112 |
---|
$done_users = array();
$subject = $parser->parse_badwords($thread['subject']);
|
$done_users = array();
$subject = $parser->parse_badwords($thread['subject']);
|
$excerpt = $parser->text_parse_message($post['message'], array('me_username' => $post['username'], 'filter_badwords' => 1, 'safe_html' => 1));
| $parser_options = array( 'me_username' => $post['username'], 'filter_badwords' => 1 );
$excerpt = $parser->text_parse_message($post['message'], $parser_options);
|
$excerpt = my_substr($excerpt, 0, $mybb->settings['subscribeexcerpt']).$lang->emailbit_viewthread;
// Fetch any users subscribed to this thread receiving instant notification and queue up their subscription notices
| $excerpt = my_substr($excerpt, 0, $mybb->settings['subscribeexcerpt']).$lang->emailbit_viewthread;
// Fetch any users subscribed to this thread receiving instant notification and queue up their subscription notices
|
Zeile 1124 | Zeile 1140 |
---|
while($subscribedmember = $db->fetch_array($query)) { if($done_users[$subscribedmember['uid']])
|
while($subscribedmember = $db->fetch_array($query)) { if($done_users[$subscribedmember['uid']])
|
{ continue; }
$args['users'][$subscribedmember['uid']] = (int)$subscribedmember['uid'];
| { continue; }
$args['users'][$subscribedmember['uid']] = (int)$subscribedmember['uid'];
|
$done_users[$subscribedmember['uid']] = 1;
|
$done_users[$subscribedmember['uid']] = 1;
|
|
|
$forumpermissions = forum_permissions($thread['fid'], $subscribedmember['uid']); if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) {
| $forumpermissions = forum_permissions($thread['fid'], $subscribedmember['uid']); if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) {
|
Zeile 1145 | Zeile 1161 |
---|
}
if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language']))
|
}
if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language']))
|
{
| {
|
$uselang = $subscribedmember['language']; } elseif($mybb->settings['orig_bblanguage']) { $uselang = $mybb->settings['orig_bblanguage'];
|
$uselang = $subscribedmember['language']; } elseif($mybb->settings['orig_bblanguage']) { $uselang = $mybb->settings['orig_bblanguage'];
|
}
| }
|
else { $uselang = "english";
| else { $uselang = "english";
|
Zeile 1229 | Zeile 1245 |
---|
update_last_post($post['tid']); update_forum_counters($post['fid'], array("posts" => "+1")); update_forum_lastpost($thread['fid']);
|
update_last_post($post['tid']); update_forum_counters($post['fid'], array("posts" => "+1")); update_forum_lastpost($thread['fid']);
|
}
| }
|
// Post is stuck in moderation queue else if($visible == 0) {
| // Post is stuck in moderation queue else if($visible == 0) {
|
Zeile 1281 | Zeile 1297 |
---|
global $mybb, $db, $plugins;
$thread = &$this->data;
|
global $mybb, $db, $plugins;
$thread = &$this->data;
|
|
|
// Validate all thread assets.
if(!$thread['savedraft'])
| // Validate all thread assets.
if(!$thread['savedraft'])
|
Zeile 1333 | Zeile 1349 |
---|
if(count($this->get_errors()) > 0) { return false;
|
if(count($this->get_errors()) > 0) { return false;
|
}
| }
|
else { return true; } }
|
else { return true; } }
|
|
|
/** * Insert a thread into the database. *
| /** * Insert a thread into the database. *
|
Zeile 1348 | Zeile 1364 |
---|
function insert_thread() { global $db, $mybb, $plugins, $cache, $lang;
|
function insert_thread() { global $db, $mybb, $plugins, $cache, $lang;
|
|
|
// Yes, validating is required. if(!$this->get_validated())
|
// Yes, validating is required. if(!$this->get_validated())
|
{
| {
|
die("The thread needs to be validated before inserting it into the DB."); } if(count($this->get_errors()) > 0) { die("The thread is not valid.");
|
die("The thread needs to be validated before inserting it into the DB."); } if(count($this->get_errors()) > 0) { die("The thread is not valid.");
|
}
$thread = &$this->data;
| }
$thread = &$this->data;
|
// Fetch the forum this thread is being made in $forum = get_forum($thread['fid']);
|
// Fetch the forum this thread is being made in $forum = get_forum($thread['fid']);
|
|
|
// This thread is being saved as a draft. if($thread['savedraft'])
|
// This thread is being saved as a draft. if($thread['savedraft'])
|
{
| {
|
$visible = -2; }
|
$visible = -2; }
|
|
|
// Thread is being made now and we have a bit to do. else {
| // Thread is being made now and we have a bit to do. else {
|
Zeile 1378 | Zeile 1394 |
---|
if($forumpermissions['modthreads'] == 1 && !is_moderator($thread['fid'], "", $thread['uid'])) { $visible = 0;
|
if($forumpermissions['modthreads'] == 1 && !is_moderator($thread['fid'], "", $thread['uid'])) { $visible = 0;
|
}
| }
|
else { $visible = 1;
|
else { $visible = 1;
|
}
| }
|
// Are posts from this user being moderated? Change visibility if($mybb->user['uid'] == $thread['uid'] && $mybb->user['moderateposts'] == 1) {
| // Are posts from this user being moderated? Change visibility if($mybb->user['uid'] == $thread['uid'] && $mybb->user['moderateposts'] == 1) {
|
Zeile 1424 | Zeile 1440 |
---|
$plugins->run_hooks("datahandler_post_insert_thread", $this);
$db->update_query("threads", $this->thread_insert_data, "tid='{$thread['tid']}'");
|
$plugins->run_hooks("datahandler_post_insert_thread", $this);
$db->update_query("threads", $this->thread_insert_data, "tid='{$thread['tid']}'");
|
$this->post_insert_data = array( "subject" => $db->escape_string($thread['subject']), "icon" => (int)$thread['icon'], "username" => $db->escape_string($thread['username']), "dateline" => (int)$thread['dateline'], "message" => $db->escape_string($thread['message']), "ipaddress" => $db->escape_binary(my_inet_pton(get_ip())), "includesig" => $thread['options']['signature'], "smilieoff" => $thread['options']['disablesmilies'],
| $this->post_insert_data = array( "subject" => $db->escape_string($thread['subject']), "icon" => (int)$thread['icon'], "username" => $db->escape_string($thread['username']), "dateline" => (int)$thread['dateline'], "message" => $db->escape_string($thread['message']), "ipaddress" => $db->escape_binary(my_inet_pton(get_ip())), "includesig" => $thread['options']['signature'], "smilieoff" => $thread['options']['disablesmilies'],
|
"visible" => $visible ); $plugins->run_hooks("datahandler_post_insert_thread_post", $this);
| "visible" => $visible ); $plugins->run_hooks("datahandler_post_insert_thread_post", $this);
|
Zeile 1483 | Zeile 1499 |
---|
$plugins->run_hooks("datahandler_post_insert_thread_post", $this);
$this->pid = $db->insert_query("posts", $this->post_insert_data);
|
$plugins->run_hooks("datahandler_post_insert_thread_post", $this);
$this->pid = $db->insert_query("posts", $this->post_insert_data);
|
|
|
// Now that we have the post id for this first post, update the threads table. $firstpostup = array("firstpost" => $this->pid); $db->update_query("threads", $firstpostup, "tid='{$this->tid}'");
| // Now that we have the post id for this first post, update the threads table. $firstpostup = array("firstpost" => $this->pid); $db->update_query("threads", $firstpostup, "tid='{$this->tid}'");
|
Zeile 1498 | Zeile 1514 |
---|
{ case "pm": $notification = 2;
|
{ case "pm": $notification = 2;
|
break;
| break;
|
case "email": $notification = 1; break;
| case "email": $notification = 1; break;
|
Zeile 1508 | Zeile 1524 |
---|
require_once MYBB_ROOT."inc/functions_user.php"; add_subscribed_thread($this->tid, $notification, $thread['uid']);
|
require_once MYBB_ROOT."inc/functions_user.php"; add_subscribed_thread($this->tid, $notification, $thread['uid']);
|
}
| }
|
// Perform any selected moderation tools. if(is_moderator($thread['fid'], "", $thread['uid']) && is_array($thread['modoptions']))
| // Perform any selected moderation tools. if(is_moderator($thread['fid'], "", $thread['uid']) && is_array($thread['modoptions']))
|
Zeile 1518 | Zeile 1534 |
---|
$modoptions = $thread['modoptions']; $modlogdata['fid'] = $thread['fid']; if(isset($thread['tid']))
|
$modoptions = $thread['modoptions']; $modlogdata['fid'] = $thread['fid']; if(isset($thread['tid']))
|
{
| {
|
$modlogdata['tid'] = $thread['tid'];
|
$modlogdata['tid'] = $thread['tid'];
|
}
$newclosed = $newstick = '';
| }
$modoptions_update = array();
|
// Close the thread.
|
// Close the thread.
|
if(isset($modoptions['closethread']) && $modoptions['closethread'] == 1) { $newclosed = "closed=1";
| if(!empty($modoptions['closethread'])) { $modoptions_update['closed'] = 1;
|
log_moderator_action($modlogdata, $lang->thread_closed);
|
log_moderator_action($modlogdata, $lang->thread_closed);
|
}
| }
|
// Stick the thread.
|
// Stick the thread.
|
if(isset($modoptions['stickthread']) && $modoptions['stickthread'] == 1)
| if(!empty($modoptions['stickthread']))
|
{
|
{
|
$newstick = "sticky='1'";
| $modoptions_update['sticky'] = 1;
|
log_moderator_action($modlogdata, $lang->thread_stuck); }
// Execute moderation options.
|
log_moderator_action($modlogdata, $lang->thread_stuck); }
// Execute moderation options.
|
if($newstick && $newclosed) { $sep = ","; } else { $sep = ''; } if($newstick || $newclosed) { $db->write_query(" UPDATE ".TABLE_PREFIX."threads SET $newclosed$sep$newstick WHERE tid='{$this->tid}' "); } }
| if($modoptions_update) { $db->update_query('threads', $modoptions_update, "tid='{$this->tid}'"); } }
|
if($visible == 1) { // If we have a registered user then update their post count and last post times.
| if($visible == 1) { // If we have a registered user then update their post count and last post times.
|
Zeile 1571 | Zeile 1575 |
---|
} // Update the post count if this forum allows post counts to be tracked if($forum['usepostcounts'] != 0)
|
} // Update the post count if this forum allows post counts to be tracked if($forum['usepostcounts'] != 0)
|
{
| {
|
$update_query['postnum'] = "postnum+1"; } if($forum['usethreadcounts'] != 0) { $update_query['threadnum'] = 'threadnum+1';
|
$update_query['postnum'] = "postnum+1"; } if($forum['usethreadcounts'] != 0) { $update_query['threadnum'] = 'threadnum+1';
|
}
| }
|
// Only update the table if we need to. if(!empty($update_query)) {
| // Only update the table if we need to. if(!empty($update_query)) {
|
Zeile 1629 | Zeile 1633 |
---|
{ // In a 'view own only' forum and not a moderator continue;
|
{ // In a 'view own only' forum and not a moderator continue;
|
}
| }
|
// Determine the language pack we'll be using to send this email in and load it if it isn't already. if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language']))
| // Determine the language pack we'll be using to send this email in and load it if it isn't already. if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language']))
|
Zeile 1732 | Zeile 1736 |
---|
/** * Updates a post that is already in the database. *
|
/** * Updates a post that is already in the database. *
|
| * @return array
|
*/ function update_post() {
| */ function update_post() {
|
Zeile 1757 | Zeile 1762 |
---|
$forum = get_forum($post['fid']); $forumpermissions = forum_permissions($post['fid'], $post['uid']);
|
$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']);
| // Decide on the visibility of this post. $ismod = is_moderator($post['fid'], "", $post['uid']);
|
Zeile 1801 | Zeile 1788 |
---|
}
// Update the thread details that might have been changed first.
|
}
// Update the thread details that might have been changed first.
|
if($first_post)
| if($this->first_post)
|
{ $this->tid = $post['tid'];
| { $this->tid = $post['tid'];
|
Zeile 1902 | Zeile 1889 |
---|
// Return the thread's first post id and whether or not it is visible. $this->return_values = array( 'visible' => $visible,
|
// Return the thread's first post id and whether or not it is visible. $this->return_values = array( 'visible' => $visible,
|
'first_post' => $first_post
| 'first_post' => $this->first_post
|
);
$plugins->run_hooks("datahandler_post_update_end", $this);
| );
$plugins->run_hooks("datahandler_post_update_end", $this);
|