/** * Finalize this expired listing * * 1. Send out an email * 2. Set as expired * */ public function finalizeListing() { //reasons to fail if (!$this->isClosed()) { return false; } // if the clock has NOT timed out if ($this->expired()) { return false; } // if its recorded in the database ALREADY //loading resources $author =& eFactory::getUser($this->author_id); $winner =& $this->getWinner(); require_once EBOOK_HELPERS . DS . 'mailer.php'; switch ($this->type()) { case 'auction': if ($this->isEmpty()) { BMailer::listingExpiredEmpty($author, $this); } else { BMailer::listingExpiredWinner($author, $this); BMailer::listingWinner($winner, $this); } break; case 'donation': if ($this->isEmpty()) { BMailer::donationExpiredEmpty($author, $this); } else { BMailer::donationExpiredWinner($author, $this); } break; case 'need': if ($this->isEmpty()) { BMailer::needExpiredEmpty($author, $this); } else { BMailer::needExpiredWinner($author, $this); } break; case 'financial': if ($this->isEmpty()) { BMailer::financialExpiredEmpty($author, $this); } else { BMailer::financialExpiredWinner($author, $this); } break; } $this->expired = 1; $this->store(); return true; }