07-18-2017, 06:38 PM
My last code was just an example I created from scratch to show multiple buttons to adapt to the messaging script as I didn't have access to the code at the time. Your buttons both have the same name (Submit). If you give your buttons unique names (delete and unarchive), you can check for that button in $_POST['buttonName'] and process that button's function, otherwise you'll have to check the value to determine the function you want.
as opposed to .
Also in your Unarchive/Delete modal, I'd change the checkbox name to have a prefix for the array:
Now you can do:
Again this is untested but try these changes and see how it goes. I had to hack up your code enough to work with my site that a full hastebin wouldn't help much.
Code:
if (isset($_POST['delete']))
Code:
if (isset($_POST['submit']) && $_POST['submit'] = 'delete')
Also in your Unarchive/Delete modal, I'd change the checkbox name to have a prefix for the array:
Code:
<input type="checkbox" name="checkbox[<?=$m2->id?>]" value="<?=$m2->id?>"/>
Now you can do:
Code:
if (isset($_POST['delete'])) {
Code:
$delete = $_POST['checkbox'];
Code:
if (count($delete) > 0 && $deletion_count = deleteThread($deletions,$user->data()->id,1)) {
Code:
$successes[] = lang("MESSAGE_DELETE_SUCCESSFUL", array($deletion_count));
Code:
}
Code:
else {
Code:
$errors[] = lang("SQL_ERROR");
Code:
}
Code:
}
Code:
if (isset($_POST['unarchive'])) {
Code:
$unarchives= $_POST['unarchive'];
Code:
if (count($unarchives) > 0 && $unarchive_count = unarchiveThread(...) {
Code:
$successes[] = lang("MESSAGE_UNARCHIVE_SUCCESSFUL", array($unarchive_count));
Code:
}
Code:
else {
Code:
$errors[] = lang("SQL_ERROR");
Code:
}
Code:
}
Again this is untested but try these changes and see how it goes. I had to hack up your code enough to work with my site that a full hastebin wouldn't help much.