/**
  * Set the Payment to be Published
  * 
  * Other responsibilities come with this transaction.
  * This is only set to published if a properly validated paypal amount comes back.
  */
 public function setPublished($num = null)
 {
     //reasons to fail
     if (is_null($num)) {
         return false;
     }
     if ($num < 1) {
         return false;
     }
     //loading resources
     require_once EBOOK_HELPERS . DS . 'mailer.php';
     $listings =& $this->getOneToMany('byrdlist_listings');
     //reasons to fail
     if (!$listings) {
         return false;
     }
     if (empty($listings)) {
         return false;
     }
     foreach ($listings as $listing) {
         //reasons to fail
         if ($listing->type() != 'auction') {
             continue;
         }
         //loading resources
         $payments = $listing->getOneToMany('byrdlist_payments');
         //reasons to fail
         if (empty($payments)) {
             break;
         }
         //initializing variables
         $total = $this->amount();
         foreach ($payments as $id => $payment) {
             if (!$payment->published()) {
                 continue;
             }
             $total = $total + $payment->amount();
         }
         //loading resources
         $lastbid =& $listing->last_bid();
         $bidauthor =& eFactory::getUser($lastbid->author_id());
         $author =& eFactory::getUser($listing->author_id());
         //more reasons to fail
         if ($total < $lastbid->amount()) {
             break;
         }
         BMailer::auctionPaidInFull($bidauthor, $listing);
         BMailer::notifyListingOwnerAuctionPaidInFull($author, $listing);
     }
     $this->published = 1;
     $this->store();
     return true;
 }