Zeile 6 | Zeile 6 |
---|
* Website: http://mybb.com * License: http://mybb.com/about/license *
|
* Website: http://mybb.com * License: http://mybb.com/about/license *
|
* $Id: pm.php 5380 2011-02-21 12:04:43Z Tomm $
| * $Id: pm.php 5756 2012-03-09 15:05:12Z Tomm $
|
*/
// Disallow direct access to this file for security reasons
| */
// Disallow direct access to this file for security reasons
|
Zeile 141 | Zeile 141 |
---|
*/ function verify_recipient() {
|
*/ function verify_recipient() {
|
global $db, $mybb, $lang;
| global $cache, $db, $mybb, $lang;
|
$pm = &$this->data;
| $pm = &$this->data;
|
Zeile 155 | Zeile 155 |
---|
{ $this->set_error("no_recipients"); return false;
|
{ $this->set_error("no_recipients"); return false;
|
}
| }
|
foreach(array("to", "bcc") as $recipient_type) { if(!is_array($pm[$recipient_type])) { $pm[$recipient_type] = array($pm[$recipient_type]);
|
foreach(array("to", "bcc") as $recipient_type) { if(!is_array($pm[$recipient_type])) { $pm[$recipient_type] = array($pm[$recipient_type]);
|
}
| }
|
foreach($pm[$recipient_type] as $username) { $username = trim($username);
| foreach($pm[$recipient_type] as $username) { $username = trim($username);
|
Zeile 196 | Zeile 196 |
---|
if(count($pm['toid']) <= 0) { $this->set_error("no_recipients");
|
if(count($pm['toid']) <= 0) { $this->set_error("no_recipients");
|
return false; }
| return false; }
|
if(is_array($pm[$recipient_type])) { foreach($pm[$recipient_type] as $uid)
| if(is_array($pm[$recipient_type])) { foreach($pm[$recipient_type] as $uid)
|
Zeile 247 | Zeile 247 |
---|
// 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
|
if($this->admin_override != true && $sender_permissions['cancp'] != 1)
| if(($this->admin_override != true && $sender_permissions['cancp'] != 1) && $sender_permissions['canoverridepm'] != 1)
|
{ $ignorelist = explode(",", $user['ignorelist']); if(!empty($ignorelist) && in_array($pm['fromid'], $ignorelist)) { $this->set_error("recipient_is_ignoring", array($user['username']));
|
{ $ignorelist = explode(",", $user['ignorelist']); if(!empty($ignorelist) && in_array($pm['fromid'], $ignorelist)) { $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 267 | Zeile 267 |
---|
// 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'])
|
{
| {
|
$this->set_error("recipient_pms_disabled", array($user['username'])); return false; }
| $this->set_error("recipient_pms_disabled", array($user['username'])); return false; }
|
Zeile 279 | Zeile 279 |
---|
if(trim($user['language']) != '' && $lang->language_exists($user['language'])) { $uselang = trim($user['language']);
|
if(trim($user['language']) != '' && $lang->language_exists($user['language'])) { $uselang = trim($user['language']);
|
}
| }
|
elseif($mybb->settings['bblanguage'])
|
elseif($mybb->settings['bblanguage'])
|
{
| {
|
$uselang = $mybb->settings['bblanguage'];
|
$uselang = $mybb->settings['bblanguage'];
|
} else {
| } else {
|
$uselang = "english"; } if($uselang == $mybb->settings['bblanguage'] || !$uselang)
| $uselang = "english"; } if($uselang == $mybb->settings['bblanguage'] || !$uselang)
|
Zeile 304 | Zeile 304 |
---|
} $emailmessage = $lang->sprintf($emailmessage, $user['username'], $mybb->settings['bbname'], $mybb->settings['bburl']); $emailsubject = $lang->sprintf($emailsubject, $mybb->settings['bbname']);
|
} $emailmessage = $lang->sprintf($emailmessage, $user['username'], $mybb->settings['bbname'], $mybb->settings['bburl']); $emailsubject = $lang->sprintf($emailsubject, $mybb->settings['bbname']);
|
my_mail($user['email'], $emailsubject, $emailmessage);
| $new_email = array( "mailto" => $db->escape_string($user['email']), "mailfrom" => '', "subject" => $db->escape_string($emailsubject), "message" => $db->escape_string($emailmessage), "headers" => '' );
$db->insert_query("mailqueue", $new_email); $cache->update_mailqueue();
|
if($this->admin_override != true) {
| if($this->admin_override != true) {
|
Zeile 367 | Zeile 377 |
---|
$this->set_error("pm_flooding", array($time_to_wait)); } return false;
|
$this->set_error("pm_flooding", array($time_to_wait)); } return false;
|
} }
| } }
|
// All is well that ends well - return true. return true; }
/** * Verifies if the various 'options' for sending PMs are valid.
|
// All is well that ends well - return true. return true; }
/** * Verifies if the various 'options' for sending PMs are valid.
|
*
| *
|
* @return boolean True when valid, false when invalid. */ function verify_options()
| * @return boolean True when valid, false when invalid. */ function verify_options()
|
Zeile 425 | Zeile 435 |
---|
$this->verify_options();
|
$this->verify_options();
|
$plugins->run_hooks_by_ref("datahandler_pm_validate", $this);
| $plugins->run_hooks("datahandler_pm_validate", $this);
|
// Choose the appropriate folder to save in. if($pm['saveasdraft'])
|
// Choose the appropriate folder to save in. if($pm['saveasdraft'])
|
{
| {
|
$pm['folder'] = 3;
|
$pm['folder'] = 3;
|
} else {
| } else {
|
$pm['folder'] = 1; }
// We are done validating, return. $this->set_validated(true);
|
$pm['folder'] = 1; }
// We are done validating, return. $this->set_validated(true);
|
if(count($this->get_errors()) > 0) {
| if(count($this->get_errors()) > 0) {
|
return false; } else
| return false; } else
|
Zeile 456 | Zeile 466 |
---|
*/ function insert_pm() {
|
*/ function insert_pm() {
|
global $db, $mybb, $plugins, $lang;
| global $cache, $db, $mybb, $plugins, $lang;
|
// Yes, validating is required. if(!$this->get_validated()) { die("The PM needs to be validated before inserting it into the DB.");
|
// Yes, validating is required. if(!$this->get_validated()) { die("The PM needs to be validated before inserting it into the DB.");
|
}
| }
|
if(count($this->get_errors()) > 0) { die("The PM is not valid.");
| if(count($this->get_errors()) > 0) { die("The PM is not valid.");
|
Zeile 483 | Zeile 493 |
---|
if(!is_array($pm['recipients'])) { $recipient_list = array();
|
if(!is_array($pm['recipients'])) { $recipient_list = array();
|
}
| }
|
else { // Build recipient list foreach($pm['recipients'] as $recipient) { if($recipient['bcc'])
|
else { // Build recipient list foreach($pm['recipients'] as $recipient) { if($recipient['bcc'])
|
{
| {
|
$recipient_list['bcc'][] = $recipient['uid']; } else
| $recipient_list['bcc'][] = $recipient['uid']; } else
|
Zeile 539 | Zeile 549 |
---|
if($pm['saveasdraft']) { $this->pm_insert_data['uid'] = $pm['sender']['uid'];
|
if($pm['saveasdraft']) { $this->pm_insert_data['uid'] = $pm['sender']['uid'];
|
|
|
// If this is a reply, then piggyback into the deletetime to let us know in the future if($pm['do'] == "reply" || $pm['do'] == "replyall") { $this->pm_insert_data['deletetime'] = $pm['pmid']; }
|
// If this is a reply, then piggyback into the deletetime to let us know in the future if($pm['do'] == "reply" || $pm['do'] == "replyall") { $this->pm_insert_data['deletetime'] = $pm['pmid']; }
|
$plugins->run_hooks_by_ref("datahandler_pm_insert_updatedraft", $this);
| $plugins->run_hooks("datahandler_pm_insert_updatedraft", $this);
|
$db->insert_query("privatemessages", $this->pm_insert_data);
// If this is a draft, end it here - below deals with complete messages
| $db->insert_query("privatemessages", $this->pm_insert_data);
// If this is a draft, end it here - below deals with complete messages
|
Zeile 554 | Zeile 564 |
---|
"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 568 | Zeile 578 |
---|
$uselang = $recipient['language']; } elseif($mybb->settings['bblanguage'])
|
$uselang = $recipient['language']; } elseif($mybb->settings['bblanguage'])
|
{
| {
|
$uselang = $mybb->settings['bblanguage']; } else
| $uselang = $mybb->settings['bblanguage']; } else
|
Zeile 588 | Zeile 598 |
---|
$userlang->load("messages"); $emailsubject = $userlang->emailsubject_newpm; $emailmessage = $userlang->email_newpm;
|
$userlang->load("messages"); $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']);
|
my_mail($recipient['email'], $emailsubject, $emailmessage);
| $new_email = array( "mailto" => $db->escape_string($recipient['email']), "mailfrom" => '', "subject" => $db->escape_string($emailsubject), "message" => $db->escape_string($emailmessage), "headers" => '' );
$db->insert_query("mailqueue", $new_email); $cache->update_mailqueue();
|
}
$this->pm_insert_data['uid'] = $recipient['uid']; $this->pm_insert_data['toid'] = $recipient['uid'];
|
}
$this->pm_insert_data['uid'] = $recipient['uid']; $this->pm_insert_data['toid'] = $recipient['uid'];
|
$plugins->run_hooks_by_ref("datahandler_pm_insert", $this);
| $plugins->run_hooks("datahandler_pm_insert", $this);
|
$this->pmid = $db->insert_query("privatemessages", $this->pm_insert_data);
// If PM noices/alerts are on, show!
| $this->pmid = $db->insert_query("privatemessages", $this->pm_insert_data);
// If PM noices/alerts are on, show!
|
Zeile 644 | Zeile 664 |
---|
// If we're saving a copy if($pm['options']['savecopy'] != 0) {
|
// If we're saving a copy if($pm['options']['savecopy'] != 0) {
|
if(count($recipient_list['to']) == 1)
| if(isset($recipient_list['to']) && count($recipient_list['to']) == 1)
|
{ $this->pm_insert_data['toid'] = $uid; }
| { $this->pm_insert_data['toid'] = $uid; }
|
Zeile 657 | Zeile 677 |
---|
$this->pm_insert_data['status'] = 1; $this->pm_insert_data['receipt'] = 0;
|
$this->pm_insert_data['status'] = 1; $this->pm_insert_data['receipt'] = 0;
|
$plugins->run_hooks_by_ref("datahandler_pm_insert_savedcopy", $this);
| $plugins->run_hooks("datahandler_pm_insert_savedcopy", $this);
|
$db->insert_query("privatemessages", $this->pm_insert_data);
// Because the sender saved a copy, update their total pm count
| $db->insert_query("privatemessages", $this->pm_insert_data);
// Because the sender saved a copy, update their total pm count
|