| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- <?php
- class Mail {
- private $id = NULL;
- private $mailSender = NULL;
- private $subject = NULL;
- private $mailboxFolderID = NULL;
- private $mailUID = NULL;
- private $processed = NULL;
- public function __construct($id, $mailSender, $subject, $mailboxFolderID, $mailUID, $processed) {
- $this->id = $id;
- $this->mailSender = $mailSender;
- $this->subject = $subject;
- $this->mailboxFolderID = $mailboxFolderID;
- $this->mailUID = $mailUID;
- $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 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`, `processed`) VALUES (" . $this->getID() . ", '" . $this->getMailSender() . "', '" . $this->getSubject() . "', " . $this->getMailboxFolderID() . ", " . $this->getMailUID() . ", " . $this->getProcessed() . ") ON DUPLICATE KEY UPDATE `mail_sender` = '" . $this->getMailSender() . "', `subject` = '" . $this->getSubject() . "', `mailbox_folder_id` = " . $this->getMailboxFolderID() . ", `mail_uid` = " . $this->getMailUID() . ", `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->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 getMailByMailInfo($mailboxFolder, $mailUID) {
- global $db;
- $mails = $db->selectQuery("SELECT * FROM `mails` WHERE `mailbox_folder_id` = " . $mailboxFolder . " AND `mail_uid` = " . $mailUID . ";");
- $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->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->processed);
- }
- return $return;
- }
- }
- ?>
|