| 1 | <?php |
| 2 | function delete_mail() { |
| 3 | global $node,$db,$error; |
| 4 | $user_id = $_SESSION['user_id']; |
| 5 | foreach ($_POST['message'] as $chosen =>$value) { |
| 6 | |
| 7 | $mail_id = intval($mail_id); |
| 8 | if ($mail_id == 0) |
| 9 | continue; |
| 10 | |
| 11 | $set = $db->query("select mail_read,mail_to from mail where mail_id = '$chosen' and mail_from = '$user_id'"); |
| 12 | $set->next(); |
| 13 | if ($set->getString('mail_read') == 'no') { |
| 14 | $db->query("delete from mail where mail_duplicate_id = '$chosen' and mail_from = '$user_id'"); |
| 15 | $db->update("update users set user_mail = user_mail - 1 where user_id = ". $set->getString('mail_to') .""); |
| 16 | } |
| 17 | $db->query("delete from mail where mail_id = '$chosen' and mail_user = '$user_id'"); |
| 18 | } |
| 19 | } |
| 20 | ?> |