Zeile 34 | Zeile 34 |
---|
* @var string */ public $language_prefix = 'pmdata';
|
* @var string */ public $language_prefix = 'pmdata';
|
|
|
/** * Array of data inserted in to a private message. *
| /** * Array of data inserted in to a private message. *
|
Zeile 48 | Zeile 48 |
---|
* @var array */ public $pm_update_data = array();
|
* @var array */ public $pm_update_data = array();
|
|
|
/** * PM ID currently being manipulated by the datahandlers.
|
/** * PM ID currently being manipulated by the datahandlers.
|
*/ public $pmid = 0;
| */ public $pmid = 0;
|
/** * Verifies a private message subject. *
| /** * Verifies a private message subject. *
|
Zeile 73 | Zeile 73 |
---|
if(!trim_blank_chrs($subject)) { $this->set_error("missing_subject");
|
if(!trim_blank_chrs($subject)) { $this->set_error("missing_subject");
|
return false; } return true; }
/**
| return false; } return true; }
/**
|
* Verifies if a message for a PM is valid. * * @return boolean True when valid, false when invalid.
| * Verifies if a message for a PM is valid. * * @return boolean True when valid, false when invalid.
|
Zeile 102 | Zeile 102 |
---|
* @return boolean True when valid, false when invalid. */ function verify_sender()
|
* @return boolean True when valid, false when invalid. */ function verify_sender()
|
{
| {
|
global $db, $mybb, $lang;
$pm = &$this->data;
| global $db, $mybb, $lang;
$pm = &$this->data;
|
Zeile 151 | Zeile 151 |
---|
// We have our recipient usernames but need to fetch user IDs if(array_key_exists("to", $pm)) {
|
// We have our recipient usernames but need to fetch user IDs if(array_key_exists("to", $pm)) {
|
if((count($pm['to']) <= 0 || trim(implode("", $pm['to'])) == "") && !$pm['saveasdraft']) { $this->set_error("no_recipients"); return false; }
foreach(array("to", "bcc") as $recipient_type)
| foreach(array("to", "bcc") as $recipient_type) { if(!isset($pm[$recipient_type])) { $pm[$recipient_type] = array(); } if(!is_array($pm[$recipient_type])) { $pm[$recipient_type] = array($pm[$recipient_type]); }
$pm[$recipient_type] = array_map('trim', $pm[$recipient_type]); $pm[$recipient_type] = array_filter($pm[$recipient_type]);
// No recipients? Skip query if(empty($pm[$recipient_type])) { if($recipient_type == 'to' && !$pm['saveasdraft']) { $this->set_error("no_recipients"); return false; } continue; }
$recipientUsernames = array_map(array($db, 'escape_string'), $pm[$recipient_type]); $recipientUsernames = "'".implode("','", $recipientUsernames)."'";
$query = $db->simple_select('users', '*', 'username IN('.$recipientUsernames.')');
$validUsernames = array();
while($user = $db->fetch_array($query)) { if($recipient_type == "bcc") { $user['bcc'] = 1; }
$recipients[] = $user; $validUsernames[] = $user['username']; }
foreach($pm[$recipient_type] as $username) { if(!in_array($username, $validUsernames)) { $invalid_recipients[] = $username; } } } } // We have recipient IDs else { foreach(array("toid", "bccid") as $recipient_type)
|
{
|
{
|
| if(!isset($pm[$recipient_type])) { $pm[$recipient_type] = array(); }
|
if(!is_array($pm[$recipient_type])) { $pm[$recipient_type] = array($pm[$recipient_type]);
|
if(!is_array($pm[$recipient_type])) { $pm[$recipient_type] = array($pm[$recipient_type]);
|
} foreach($pm[$recipient_type] as $username) { $username = trim($username); if(empty($username)) { continue; } // Check that this recipient actually exists $query = $db->simple_select("users", "*", "username='".$db->escape_string($username)."'"); $user = $db->fetch_array($query); if($recipient_type == "bcc") { $user['bcc'] = 1;
| } $pm[$recipient_type] = array_map('intval', $pm[$recipient_type]); $pm[$recipient_type] = array_filter($pm[$recipient_type]);
// No recipients? Skip query if(empty($pm[$recipient_type])) { if($recipient_type == 'toid' && !$pm['saveasdraft']) { $this->set_error("no_recipients"); return false; } continue; }
$recipientUids = "'".implode("','", $pm[$recipient_type])."'";
$query = $db->simple_select('users', '*', 'uid IN('.$recipientUids.')');
$validUids = array();
while($user = $db->fetch_array($query)) { if($recipient_type == "bccid") { $user['bcc'] = 1;
|
}
|
}
|
if($user['uid'])
| $recipients[] = $user; $validUids[] = $user['uid']; }
foreach($pm[$recipient_type] as $uid) { if(!in_array($uid, $validUids))
|
{
|
{
|
$recipients[] = $user; } else { $invalid_recipients[] = $username;
| $invalid_recipients[] = $uid;
|
} } }
|
} } }
|
} // We have recipient IDs else { foreach(array("toid", "bccid") as $recipient_type) { if(count($pm['toid']) <= 0) { $this->set_error("no_recipients"); return false; } if(is_array($pm[$recipient_type])) { foreach($pm[$recipient_type] as $uid) { // Check that this recipient actually exists $query = $db->simple_select("users", "*", "uid='".intval($uid)."'"); $user = $db->fetch_array($query); if($recipient_type == "bccid") { $user['bcc'] = 1; } if($user['uid']) { $recipients[] = $user; } else { $invalid_recipients[] = $uid; } } } } }
| }
|
// If we have one or more invalid recipients and we're not saving a draft, error if(count($invalid_recipients) > 0) { $invalid_recipients = implode(", ", array_map("htmlspecialchars_uni", $invalid_recipients)); $this->set_error("invalid_recipients", array($invalid_recipients)); return false;
|
// If we have one or more invalid recipients and we're not saving a draft, error if(count($invalid_recipients) > 0) { $invalid_recipients = implode(", ", array_map("htmlspecialchars_uni", $invalid_recipients)); $this->set_error("invalid_recipients", array($invalid_recipients)); return false;
|
}
| }
|
$sender_permissions = user_permissions($pm['fromid']);
// Are we trying to send this message to more users than the permissions allow?
| $sender_permissions = user_permissions($pm['fromid']);
// Are we trying to send this message to more users than the permissions allow?
|
Zeile 237 | Zeile 272 |
---|
{ $this->set_error("too_many_recipients", array($sender_permissions['maxpmrecipients'])); }
|
{ $this->set_error("too_many_recipients", array($sender_permissions['maxpmrecipients'])); }
|
|
|
// Now we're done with that we loop through each recipient foreach($recipients as $user) { // Collect group permissions for this recipient. $recipient_permissions = user_permissions($user['uid']);
|
// Now we're done with that we loop through each recipient foreach($recipients as $user) { // Collect group permissions for this recipient. $recipient_permissions = user_permissions($user['uid']);
|
|
|
// See if the sender is on the recipients ignore list and that either // - admin_override is set or // - sender is an administrator
| // See if the sender is on the recipients ignore list and that either // - admin_override is set or // - sender is an administrator
|
Zeile 254 | Zeile 289 |
---|
{ $this->set_error("recipient_is_ignoring", array($user['username'])); }
|
{ $this->set_error("recipient_is_ignoring", array($user['username'])); }
|
|
|
// Is the recipient only allowing private messages from their buddy list? if($mybb->settings['allowbuddyonly'] == 1 && $user['receivefrombuddy'] == 1) {
| // Is the recipient only allowing private messages from their buddy list? if($mybb->settings['allowbuddyonly'] == 1 && $user['receivefrombuddy'] == 1) {
|
Zeile 264 | Zeile 299 |
---|
$this->set_error("recipient_has_buddy_only", array(htmlspecialchars_uni($user['username']))); } }
|
$this->set_error("recipient_has_buddy_only", array(htmlspecialchars_uni($user['username']))); } }
|
|
|
// Can the recipient actually receive private messages based on their permissions or user setting? if(($user['receivepms'] == 0 || $recipient_permissions['canusepms'] == 0) && !$pm['saveasdraft']) {
| // Can the recipient actually receive private messages based on their permissions or user setting? if(($user['receivepms'] == 0 || $recipient_permissions['canusepms'] == 0) && !$pm['saveasdraft']) {
|
Zeile 272 | Zeile 307 |
---|
return false; } }
|
return false; } }
|
|
|
// Check to see if the user has reached their private message quota - if they have, email them. if($recipient_permissions['pmquota'] != "0" && $user['totalpms'] >= $recipient_permissions['pmquota'] && $recipient_permissions['cancp'] != 1 && $sender_permissions['cancp'] != 1 && !$pm['saveasdraft'] && !$this->admin_override) {
| // Check to see if the user has reached their private message quota - if they have, email them. if($recipient_permissions['pmquota'] != "0" && $user['totalpms'] >= $recipient_permissions['pmquota'] && $recipient_permissions['cancp'] != 1 && $sender_permissions['cancp'] != 1 && !$pm['saveasdraft'] && !$this->admin_override) {
|
Zeile 287 | Zeile 322 |
---|
else { $uselang = "english";
|
else { $uselang = "english";
|
}
| }
|
if($uselang == $mybb->settings['bblanguage'] || !$uselang) { $emailsubject = $lang->emailsubject_reachedpmquota;
| if($uselang == $mybb->settings['bblanguage'] || !$uselang) { $emailsubject = $lang->emailsubject_reachedpmquota;
|
Zeile 315 | Zeile 350 |
---|
$db->insert_query("mailqueue", $new_email); $cache->update_mailqueue();
|
$db->insert_query("mailqueue", $new_email); $cache->update_mailqueue();
|
|
|
if($this->admin_override != true) { $this->set_error("recipient_reached_quota", array($user['username'])); } }
|
if($this->admin_override != true) { $this->set_error("recipient_reached_quota", array($user['username'])); } }
|
|
|
// Everything looks good, assign some specifics about the recipient $pm['recipients'][$user['uid']] = array( "uid" => $user['uid'],
| // Everything looks good, assign some specifics about the recipient $pm['recipients'][$user['uid']] = array( "uid" => $user['uid'],
|
Zeile 332 | Zeile 367 |
---|
"pmnotify" => $user['pmnotify'], "language" => $user['language'] );
|
"pmnotify" => $user['pmnotify'], "language" => $user['language'] );
|
|
|
// If this recipient is defined as a BCC recipient, save it if($user['bcc'] == 1)
|
// If this recipient is defined as a BCC recipient, save it if($user['bcc'] == 1)
|
{
| {
|
$pm['recipients'][$user['uid']]['bcc'] = 1; } } return true; }
|
$pm['recipients'][$user['uid']]['bcc'] = 1; } } return true; }
|
|
|
/** * Verify that the user is not flooding the system. *
| /** * Verify that the user is not flooding the system. *
|
Zeile 352 | Zeile 387 |
---|
global $mybb, $db;
$pm = &$this->data;
|
global $mybb, $db;
$pm = &$this->data;
|
|
|
// Check if post flooding is enabled within MyBB or if the admin override option is specified. if($mybb->settings['pmfloodsecs'] > 0 && $pm['fromid'] != 0 && $this->admin_override == false) { // Fetch the senders profile data. $sender = get_user($pm['fromid']);
|
// Check if post flooding is enabled within MyBB or if the admin override option is specified. if($mybb->settings['pmfloodsecs'] > 0 && $pm['fromid'] != 0 && $this->admin_override == false) { // Fetch the senders profile data. $sender = get_user($pm['fromid']);
|
|
|
// Calculate last post $query = $db->simple_select("privatemessages", "dateline", "fromid='".$db->escape_string($pm['fromid'])."' AND toid != '0'", array('order_by' => 'dateline', 'order_dir' => 'desc', 'limit' => 1)); $sender['lastpm'] = $db->fetch_field($query, "dateline");
| // Calculate last post $query = $db->simple_select("privatemessages", "dateline", "fromid='".$db->escape_string($pm['fromid'])."' AND toid != '0'", array('order_by' => 'dateline', 'order_dir' => 'desc', 'limit' => 1)); $sender['lastpm'] = $db->fetch_field($query, "dateline");
|
Zeile 371 | Zeile 406 |
---|
if($time_to_wait == 1) { $this->set_error("pm_flooding_one_second");
|
if($time_to_wait == 1) { $this->set_error("pm_flooding_one_second");
|
}
| }
|
else { $this->set_error("pm_flooding", array($time_to_wait));
| else { $this->set_error("pm_flooding", array($time_to_wait));
|
Zeile 404 | Zeile 439 |
---|
else { $options['readreceipt'] = 0;
|
else { $options['readreceipt'] = 0;
|
}
| }
|
return true; }
|
return true; }
|
|
|
/** * Validate an entire private message. *
| /** * Validate an entire private message. *
|
Zeile 416 | Zeile 451 |
---|
function validate_pm() { global $plugins;
|
function validate_pm() { global $plugins;
|
|
|
$pm = &$this->data;
|
$pm = &$this->data;
|
|
|
if(!$pm['savedraft']) { $this->verify_pm_flooding(); }
|
if(!$pm['savedraft']) { $this->verify_pm_flooding(); }
|
|
|
// Verify all PM assets. $this->verify_subject();
|
// Verify all PM assets. $this->verify_subject();
|
|
|
$this->verify_sender();
|
$this->verify_sender();
|
|
|
$this->verify_recipient();
|
$this->verify_recipient();
|
|
|
$this->verify_message();
$this->verify_options();
| $this->verify_message();
$this->verify_options();
|
Zeile 510 | Zeile 545 |
---|
} } }
|
} } }
|
$recipient_list = serialize($recipient_list);
| |
$this->pm_insert_data = array( 'fromid' => intval($pm['sender']['uid']),
| $this->pm_insert_data = array( 'fromid' => intval($pm['sender']['uid']),
|
Zeile 524 | Zeile 558 |
---|
'smilieoff' => $pm['options']['disablesmilies'], 'receipt' => intval($pm['options']['readreceipt']), 'readtime' => 0,
|
'smilieoff' => $pm['options']['disablesmilies'], 'receipt' => intval($pm['options']['readreceipt']), 'readtime' => 0,
|
'recipients' => $db->escape_string($recipient_list)
| 'recipients' => $db->escape_string(serialize($recipient_list))
|
);
// Check if we're updating a draft or not.
| );
// Check if we're updating a draft or not.
|
Zeile 539 | Zeile 573 |
---|
// This draft was a reply to a PM $pm['pmid'] = $draftcheck['deletetime']; $pm['do'] = "reply";
|
// This draft was a reply to a PM $pm['pmid'] = $draftcheck['deletetime']; $pm['do'] = "reply";
|
}
| }
|
// Delete the old draft as we no longer need it $db->delete_query("privatemessages", "pmid='{$draftcheck['pmid']}'");
| // Delete the old draft as we no longer need it $db->delete_query("privatemessages", "pmid='{$draftcheck['pmid']}'");
|
Zeile 564 | Zeile 598 |
---|
"draftsaved" => 1 ); }
|
"draftsaved" => 1 ); }
|
|
|
// Save a copy of the PM for each of our recipients foreach($pm['recipients'] as $recipient) {
| // Save a copy of the PM for each of our recipients foreach($pm['recipients'] as $recipient) {
|
Zeile 580 | Zeile 614 |
---|
elseif($mybb->settings['bblanguage']) { $uselang = $mybb->settings['bblanguage'];
|
elseif($mybb->settings['bblanguage']) { $uselang = $mybb->settings['bblanguage'];
|
}
| }
|
else { $uselang = "english";
| else { $uselang = "english";
|
Zeile 599 | Zeile 633 |
---|
$emailsubject = $userlang->emailsubject_newpm; $emailmessage = $userlang->email_newpm; }
|
$emailsubject = $userlang->emailsubject_newpm; $emailmessage = $userlang->email_newpm; }
|
|
|
if(!$pm['sender']['username']) { $pm['sender']['username'] = $lang->mybb_engine; }
|
if(!$pm['sender']['username']) { $pm['sender']['username'] = $lang->mybb_engine; }
|
|
|
$emailmessage = $lang->sprintf($emailmessage, $recipient['username'], $pm['sender']['username'], $mybb->settings['bbname'], $mybb->settings['bburl']); $emailsubject = $lang->sprintf($emailsubject, $mybb->settings['bbname']);
|
$emailmessage = $lang->sprintf($emailmessage, $recipient['username'], $pm['sender']['username'], $mybb->settings['bbname'], $mybb->settings['bburl']); $emailsubject = $lang->sprintf($emailsubject, $mybb->settings['bbname']);
|
|
|
$new_email = array( "mailto" => $db->escape_string($recipient['email']), "mailfrom" => '',
| $new_email = array( "mailto" => $db->escape_string($recipient['email']), "mailfrom" => '',
|