Skip to content

Commit

Permalink
Merge pull request #7911 from Sesquipedalian/pm_compose2_this
Browse files Browse the repository at this point in the history
Fixes issue where SMF\Pm tried to use $this->current_label_redirect
  • Loading branch information
Sesquipedalian authored Nov 29, 2023
2 parents 4dd7e46 + 63ad0bc commit 2f11473
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
5 changes: 4 additions & 1 deletion Sources/Actions/PersonalMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,10 @@ public function send(): void
*/
public function send2(): void
{
PM::compose2();
// Message sent successfully?
if (PM::compose2()) {
Utils::redirectexit($this->current_label_redirect . ';done=sent');
}
}

/**
Expand Down
32 changes: 14 additions & 18 deletions Sources/PersonalMessage/PM.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,9 +827,11 @@ public static function compose(): void
/**
* Validates a composed personal message and then passes it to PM::send()
* if it is valid. If errors were found, or if the user requested a preview,
* will instead send the user back to the composition page.
* will return false.
*
* @return bool Whether the PM could be sent.
*/
public static function compose2(): void
public static function compose2(): bool
{
User::$me->isAllowedTo('pm_send');

Expand Down Expand Up @@ -1007,7 +1009,7 @@ public static function compose2(): void
if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) {
self::reportErrors($post_errors, $namedRecipientList, $recipientList);

return;
return false;
}

// Want to take a second glance before you send?
Expand All @@ -1032,7 +1034,7 @@ public static function compose2(): void
// Pretend they messed up but don't ignore if they really did :P.
self::reportErrors($post_errors, $namedRecipientList, $recipientList);

return;
return false;
}

// Adding a recipient cause javascript ain't working?
Expand All @@ -1048,7 +1050,7 @@ public static function compose2(): void

self::reportErrors([], $namedRecipientList, $recipientList);

return;
return false;
}

// Want to save this as a draft and think about it some more?
Expand All @@ -1058,7 +1060,7 @@ public static function compose2(): void

self::reportErrors($post_errors, $namedRecipientList, $recipientList);

return;
return false;
}

// Before we send the PM, let's make sure we don't have an abuse of numbers.
Expand All @@ -1070,7 +1072,7 @@ public static function compose2(): void

self::reportErrors($post_errors, $namedRecipientList, $recipientList);

return;
return false;
}

// Protect from message spamming.
Expand Down Expand Up @@ -1111,21 +1113,15 @@ public static function compose2(): void
'bcc' => array_intersect($recipientList['bcc'], Utils::$context['send_log']['failed']),
]);

return;
return false;
}

// Message sent successfully?
if (!empty(Utils::$context['send_log']) && empty(Utils::$context['send_log']['failed'])) {
$this->current_label_redirect = $this->current_label_redirect . ';done=sent';

// If we had a PM draft for this one, then its time to remove it since it was just sent
if (Utils::$context['drafts_save'] && !empty($_POST['id_draft'])) {
DraftPM::delete($_POST['id_draft']);
}
// If we had a PM draft for this one, then its time to remove it since it was just sent
if (Utils::$context['drafts_save'] && !empty($_POST['id_draft'])) {
DraftPM::delete($_POST['id_draft']);
}

// Go back to the where they sent from, if possible...
Utils::redirectexit($this->current_label_redirect);
return true;
}

/**
Expand Down

0 comments on commit 2f11473

Please sign in to comment.