1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-12 17:44:37 +02:00
This commit is contained in:
e107steved
2011-01-12 14:12:47 +00:00
parent 0ed0909b03
commit 01d690bdc0
4 changed files with 79 additions and 36 deletions

View File

@@ -274,32 +274,32 @@ class private_message
* When physically deleted, any attachments are deleted as well
*
* @param integer $pmid - ID of the PM
* @param boolean $force - set to TRUE to force deletion of unread PMs
* @return boolean|string - FALSE if PM not found, or other DB error. String if successful
*/
function del($pmid)
function del($pmid, $force = FALSE)
{
$pmid = (int)$pmid;
$ret = '';
$del_pm = FALSE;
$newvals = '';
if($this->e107->sql->db_Select('private_msg', '*', 'pm_id = '.$pmid.' AND (pm_from = '.USERID.' OR pm_to = '.USERID.')'))
{
$row = $this->e107->sql->db_Fetch();
if($row['pm_to'] == USERID)
if (!$force && ($row['pm_to'] == USERID))
{
$newvals = 'pm_read_del = 1';
$ret .= LAN_PM_42.'<br />';
if($row['pm_sent_del'] == 1) { $del_pm = TRUE; }
if($row['pm_sent_del'] == 1) { $force = TRUE; }
}
if($row['pm_from'] == USERID)
if (!$force && ($row['pm_from'] == USERID))
{
if($newvals != '') { $del_pm = TRUE; }
if($newvals != '') { $force = TRUE; }
$newvals = 'pm_sent_del = 1';
$ret .= LAN_PM_43."<br />";
if($row['pm_read_del'] == 1) { $del_pm = TRUE; }
if($row['pm_read_del'] == 1) { $force = TRUE; }
}
if($del_pm == TRUE)
if($force == TRUE)
{
// Delete any attachments and remove PM from db
$attachments = explode(chr(0), $row['pm_attachments']);