Example #1
0
	function Delete($ID)
	{
		global $DB;
		$ID = IntVal($ID);
		$db_msg = CMailMessage::GetList(Array(), Array("MAILBOX_ID"=>$ID));
		while($msg = $db_msg->Fetch())
		{
			if(!CMailMessage::Delete($msg["ID"]))
				return false;
		}

		$db_flt = CMailFilter::GetList(Array(), Array("MAILBOX_ID"=>$ID));
		while($flt = $db_flt->Fetch())
		{
			if(!CMailFilter::Delete($flt["ID"]))
				return false;
		}

		$db_log = CMailLog::GetList(Array(), Array("MAILBOX_ID"=>$ID));
		while($log = $db_log->Fetch())
		{
			if(!CMailLog::Delete($log["ID"]))
				return false;
		}

		$db_mbox = CMailbox::GetList(array('ID' => $ID, 'ACTIVE' => 'Y', '!USER_ID' => 0));
		if ($mbox = $db_mbox->fetch())
		{
			CUserCounter::Clear($mbox['USER_ID'], 'mail_unseen', $mbox['LID']);

			CUserOptions::DeleteOption('global', 'last_mail_check_'.$mbox['LID'], false, $mbox['USER_ID']);
			CUserOptions::DeleteOption('global', 'last_mail_check_success_'.$mbox['LID'], false, $mbox['USER_ID']);
		}

		CAgent::RemoveAgent("CMailbox::CheckMailAgent(".$ID.");", "mail");

		$strSql = "DELETE FROM b_mail_message_uid WHERE MAILBOX_ID=".$ID;
		if(!$DB->Query($strSql, true))
			return false;

		CMailbox::SMTPReload();
		$strSql = "DELETE FROM b_mail_mailbox WHERE ID=".$ID;
		return $DB->Query($strSql, true);
	}
Example #2
0
 function Delete($ID)
 {
     global $DB;
     $ID = IntVal($ID);
     $db_msg = CMailMessage::GetList(array(), array("MAILBOX_ID" => $ID));
     while ($msg = $db_msg->Fetch()) {
         if (!CMailMessage::Delete($msg["ID"])) {
             return false;
         }
     }
     $db_flt = CMailFilter::GetList(array(), array("MAILBOX_ID" => $ID));
     while ($flt = $db_flt->Fetch()) {
         if (!CMailFilter::Delete($flt["ID"])) {
             return false;
         }
     }
     $db_log = CMailLog::GetList(array(), array("MAILBOX_ID" => $ID));
     while ($log = $db_log->Fetch()) {
         if (!CMailLog::Delete($log["ID"])) {
             return false;
         }
     }
     CAgent::RemoveAgent("CMailbox::CheckMailAgent(" . $ID . ");", "mail");
     $strSql = "DELETE FROM b_mail_message_uid WHERE MAILBOX_ID=" . $ID;
     if (!$DB->Query($strSql, true)) {
         return false;
     }
     CMailbox::SMTPReload();
     $strSql = "DELETE FROM b_mail_mailbox WHERE ID=" . $ID;
     return $DB->Query($strSql, true);
 }