Exemplo n.º 1
0
 /**
  * @param int $userID
  * @param int $eventID
  * @param string $ticketID
  * @param int $timestamp
  * @param int $externalTime
  * @param string $externalRef
  * @param string $status
  * @param TicketType $ticketType
  * @param int $price
  * @param int $amount Default 1
  */
 public function logTicketPurchase($userID, $eventID, $ticketID, $timestamp, $externalTime, $externalRef, $status, TicketType $ticketType, $price, $amount = 1)
 {
     // Integers
     $userID = intval($userID);
     $eventID = intval($eventID);
     $timestamp = intval($timestamp);
     $externalTime = intval($externalTime);
     $amount = intval($amount);
     // Strings, misc.
     $externalRef = db_escape($externalRef);
     $status = db_escape($status);
     $price = db_escape($price);
     $ticketID = db_escape($ticketID);
     $query = sprintf("INSERT INTO `%s` (`ticketType`, `eventID`, `userID`, `ticketID`, `timestamp`, `externalTime`, `externalRef`, `price`, `amount`, `status`)\nVALUES (%d, %d, %d, '%s', %d, %d, '%s', '%s', %d, '%s');", db_prefix() . "_ticketLogs", $ticketType->getTicketTypeID(), $eventID, $userID, $ticketID, $timestamp, $externalTime, $externalRef, $price, $amount, $status);
     db_query($query);
 }
Exemplo n.º 2
0
 /**
  * Adds a tickettype to user and checks if user has ordered the maximum allowed then calls addTicketType().
  * 
  * @see addTicketType
  * @param TicketType $ticketType The ticket type to add.
  * @param int $amount Amount to add.
  * @param User|null $creator If an moderator has added this ticket, send the mods User object.
  * @return bool False if amount is reached, true on success.
  */
 public function validateAddTicketType(TicketType $ticketType, $amount = 1, $creator = null)
 {
     global $sessioninfo, $sql_prefix, $maxTicketsPrUser;
     // Validate that user has not ordered too much.
     $hasAmount = 0;
     $canAmount = isset($maxTicketsPrUser) && is_numeric($maxTicketsPrUser) ? intval($maxTicketsPrUser) : 1;
     $tickets = $this->getTickets();
     if (count($tickets) > 0) {
         foreach ($tickets as $value) {
             if ($value->getTicketTypeID() == $ticketType->getTicketTypeID()) {
                 $hasAmount++;
             }
         }
     }
     if ($hasAmount >= $canAmount) {
         return false;
     }
     // Call Addtickettype too do the rest
     $insertIDs = $this->addTicketType($ticketType, $amount, $crator);
     return $insertIDs;
 }