id = $id; $this->mailSender = $mailSender; $this->subject = $subject; $this->mailboxFolderID = $mailboxFolderID; $this->mailUID = $mailUID; $this->messageID = $messageID; $this->processed = $processed; } /** * Get the value of ID * * * @return int * */ public function getID() { return $this->id; } /** * Set the value of ID * * * @param int id * */ public function setID($id) { $this->id = $id; } /** * Get the value of Mail Sender * * * @return string * */ public function getMailSender() { return $this->mailSender; } /** * Set the value of Mail Sender * * * @param string mailSender * */ public function setMailSender($mailSender) { $this->mailSender = $mailSender; } /** * Get the value of Subject * * * @return string * */ public function getSubject() { return $this->subject; } /** * Set the value of Subject * * * @param string subject * */ public function setSubject($subject) { $this->subject = $subject; } /** * Get the value of Mailbox Folder ID * * * @return int * */ public function getMailboxFolderID() { return $this->mailboxFolderID; } /** * Set the value of Mailbox Folder ID * * * @param int mailboxFolderID * */ public function setMailboxFolderID($mailboxFolderID) { $this->mailboxFolderID = $mailboxFolderID; } /** * Get the value of Mail UID * * * @return int * */ public function getMailUID() { return $this->mailUID; } /** * Set the value of Mail * * * @param int mailUID * */ public function setMailUID($mailUID) { $this->mailUID = $mailUID; } /** * Get the value of Message ID * * * @return string * */ public function getMessageID() { return $this->messageID; } /** * Set the value of Message ID * * * @param string messageID * */ public function setMessageID($messageID) { $this->messageID = $messageID; } /** * Get the value of processed * * * @return int * */ public function getProcessed() { return $this->processed; } /** * Set the value of processed * * * @param int mailUID * */ public function setProcessed($processed) { $this->processed = $processed; } public function getMailRecipient() { global $db; return $db->selectStringQuery("SELECT `mailboxes`.`username` FROM `mailboxes` WHERE `mailboxes`.`id` = (SELECT `mailbox-folders`.`mailbox_id` FROM `mailbox-folders`WHERE `mailbox-folders`.`id` = (SELECT `mails`.`mailbox_folder_id` FROM `mails` WHERE `mails`.`id` = " . $this->getID() . "));"); } /** * Save Mail to DB * * * @return void * */ public function save() { global $db; if($this->getID() == NULL) { $this->setID("'NULL'"); } $db->insertQuery("INSERT INTO `mails` (`id`, `mail_sender`, `subject`, `mailbox_folder_id`, `mail_uid`, `message_id`, `processed`) VALUES (" . $this->getID() . ", '" . $this->getMailSender() . "', '" . $this->getSubject() . "', " . $this->getMailboxFolderID() . ", " . $this->getMailUID() . ", '" . $this->getMessageID() . "', " . $this->getProcessed() . ") ON DUPLICATE KEY UPDATE `mail_sender` = '" . $this->getMailSender() . "', `subject` = '" . $this->getSubject() . "', `mailbox_folder_id` = " . $this->getMailboxFolderID() . ", `mail_uid` = " . $this->getMailUID() . ", `message_id` = '" . $this->getMessageID() . "', `processed` = " . $this->getProcessed() . ";"); if($this->getID() == "'NULL'") { $this->setID(NULL); } } /** * Get Mail by Mail-ID * * @param int $mailID ID of Mail * * @return Mail * */ public static function getMailByMailID($mailID) { global $db; $mails = $db->selectQuery("SELECT * FROM `mails` WHERE `id` = " . $mailID . ";"); $return = array(); if(!$mails) { return false; } foreach($mails as $mail) { $return[] = new Mail($mail->id, $mail->mail_sender, $mail->subject, $mail->mailbox_folder_id, $mail->mail_uid, $mail->message_id, $mail->processed); } return $return[0]; } /** * Get Mail by Mail information * * @param int $mailboxFolder ID of mailbox-Folder * @param int $mailUID UID of Mail * * @return Mail/bool Selected Mail, or false if not found * */ public static function getMailByMessageID($messageID) { global $db; $mails = $db->selectQuery("SELECT * FROM `mails` WHERE `message_id` = '" . $messageID . "';"); $return = array(); if(!$mails) { return false; } foreach($mails as $mail) { $return[] = new Mail($mail->id, $mail->mail_sender, $mail->subject, $mail->mailbox_folder_id, $mail->mail_uid, $mail->message_id, $mail->processed); } return $return[0]; } /** * Get Mails by Label ID * * @param int $labelID ID of Label * * @return Array(Mail) Array with selected Mails * */ public static function getMailsByLabelID($labelID) { global $db; $mails = $db->selectQuery("SELECT `mails`.* FROM `mails` JOIN `mailbox-folders` ON `mailbox-folders`.id = `mails`.mailbox_folder_id WHERE `mailbox-folders`.label_id = " . $labelID . ";"); if(!$mails) { return false; } $return = array(); foreach($mails as $mail) { $return[] = new Mail($mail->id, $mail->mail_sender, $mail->subject, $mail->mailbox_folder_id, $mail->mail_uid, $mail->message_id, $mail->processed); } return $return; } } ?>