$rp_id = isset($_GET['rp_id']) ? $_GET['rp_id'] : ''; if (!empty($rp_id)) { USES_evlist_class_repeat(); $Rep = new evRepeat($rp_id); $pagetitle = COM_stripslashes($Rep->Event->title); echo $Rep->Detail('', '', 'event_print'); exit; } else { // Shouldn't be in this file without an event ID to display or edit echo COM_refresh(EVLIST_URL . '/index.php'); exit; } break; case 'printtickets': if ($_EV_CONF['enable_rsvp'] && !COM_isAnonUser()) { USES_evlist_class_ticket(); $eid = COM_sanitizeID($_GET['eid'], false); $doc = evTicket::PrintTickets($eid, 0, $_USER['uid']); echo $doc; exit; } else { $content .= 'Function not available'; } break; case 'view': default: if (empty($eid)) { // Default action, view the calendar or event COM_setArgNames(array('eid', 'ts', 'range', 'cat')); $eid = COM_sanitizeID(COM_getArgument('eid'), false); }
/** * Register a user for an event. * * @param integer $num_attendees Number of attendees, default 1 * @param integer $uid User ID to register, 0 for current user * @return integer Message code, zero for success */ public function Register($num_attendees = 1, $tick_type = 0, $uid = 0) { global $_TABLES, $_USER, $_EV_CONF, $LANG_EVLIST; if ($_EV_CONF['enable_rsvp'] != 1) { return 0; } // Make sure that registrations are enabled and that the current user // has access to this event. If $uid > 0, then this is an admin // registering another user, don't check access if ($this->Event->options['use_rsvp'] == 0 || $uid == 0 && !$this->Event->hasAccess(2)) { LGLIB_storeMessage($LANG_EVLIST['messages'][20]); return 20; } elseif ($this->Event->options['use_rsvp'] == 1) { // Registering for entire event, all repeats $rp_id = 0; } else { // Registering for a single occurance $rp_id = $this->rp_id; } if (!isset($this->Event->options['tickets'][$tick_type])) { LGLIB_storeMessage($LANG_EVLIST['messages'][24]); return 24; } $uid = $uid == 0 ? (int) $_USER['uid'] : (int) $uid; $num_attendees = (int) $num_attendees; $fee = (double) $this->Event->options['tickets'][$tick_type]['fee']; // Check that the current user isn't already registered // TODO: Allow registrations up to max count, or to waitlist //if ($this->isRegistered()) { // return 21; //} // Check that the event isn't already full, or that // waitlisting is disabled $total_reg = $this->TotalRegistrations(); $new_total = $total_reg + $num_attendees; if ($this->Event->options['max_rsvp'] > 0 && $this->Event->options['max_rsvp'] <= $new_total) { if ($this->Event->options['rsvp_waitlist'] == 0 || $fee > 0) { // Event is full, no waiting list. Can't waitlist paid tickets. LGLIB_storeMessage($LANG_EVLIST['messages'][22]); return 22; } else { // Set message indicating the waiting list and continue to register $waitlist = $new_total - $this->Event->options['max_rsvp']; if ($waitlist == $num_attendees) { // All tickets are waitlisted $str = $LANG_EVLIST['all']; } else { $str = $waitlist; } LGLIB_storeMessage($LANG_EVLIST['messages']['22'] . ' ' . sprintf($LANG_EVLIST['messages'][27], $str)); } } if ($fee > 0) { // add tickes to the shopping cart. Tickets will be created // when paid. $this->AddToCart($tick_type, $num_attendees); LGLIB_storeMessage($LANG_EVLIST['messages']['24']); $status = LGLIB_invokeService('paypal', 'getURL', array('type' => 'checkout'), $url, $msg); if ($status == PLG_RET_OK) { LGLIB_storeMessage(sprintf($LANG_EVLIST['messages']['26'], $url), '', true); } } else { LGLIB_storeMessage($LANG_EVLIST['messages'][24]); } // for free tickets, just create the ticket records USES_evlist_class_tickettype(); USES_evlist_class_ticket(); $TickType = new evTicketType($tick_type); if ($TickType->event_pass) { $t_rp_id = 0; } else { $t_rp_id = $this->rp_id; } for ($i = 0; $i < $num_attendees; $i++) { evTicket::Create($this->Event->id, $tick_type, $t_rp_id, $fee, $uid); } /*if ($fee < .01) { DB_query("INSERT INTO {$_TABLES['evlist_rsvp']} SET ev_id = '{$this->Event->id}', rp_id = '{$rp_id}', uid = '{$uid}', num_attendees = '{$num_attendees}', dt_reg = " . time()); if (DB_error()) return 23; } else { $this->AddToCart($tick_type, $num_attendees); }*/ return 0; }
/** * Handle the purchase of a product via IPN message. * * @param array $args Array of item and IPN data * @param array &$output Return array * @param string &$svc_msg Unused * @return integer Return value */ function service_handlePurchase_evlist($args, &$output, &$svc_msg) { global $_TABLES, $LANG_PHOTO, $_CONF; $item = $args['item']; $paypal_data = $args['ipn_data']; $item_id = explode(':', $item['item_id']); $quantity = (int) $item['quantity']; // Must have an item ID following the plugin name if (!is_array($item_id) || !isset($item_id[1])) { return PLG_RET_ERROR; } // Initialize the output array $output = array('product_id' => $item['item_id'], 'name' => $item['name'], 'short_description' => $item['name'], 'price' => (double) $item['price'], 'expiration' => NULL, 'download' => 0, 'file' => ''); // User ID is provided in the 'custom' field, so make sure it's numeric. if (is_numeric($paypal_data['custom']['uid'])) { $uid = (int) $paypal_data['custom']['uid']; } else { $uid = 1; } // Initialize an array of payment info to log $pmt_info = array('type' => 'payment', 'payment_date' => $paypal_data['sql_date'], 'txn_id' => $paypal_data['txn_id'], 'amount' => (double) $item['price']); switch ($item_id[1]) { case 'eventfee': // Get event, ticket_type and repeat ID $item_parts = explode('/', $item_id[2]); if (count($item_parts) < 3) { return PLG_RET_ERROR; } $ev_id = $item_parts[0]; $tick_type = $item_parts[1]; $rp_id = $item_parts[2]; USES_evlist_class_tickettype(); USES_evlist_class_repeat(); // includes event class $TickType = new evTicketType($tick_type); $repeats = array(); if ($rp_id > 0) { $repeats[] = $rp_id; // Ticket to a single occurrence $Rp = new evRepeat($rp_id); $Ev = $Rp->Event; $dt_info = $Rp->start_date1 . ' ' . $Rp->start_time1; } else { // rp_id = 0, make sure it's an event pass if ($TickType->event_pass) { $Ev = new evEvent($ev_id); $dt_info = $Ev->date_start1 . ' ' . $Ev->time_start1; } else { return PLG_RET_ERROR; } } $ev_fee = (double) $Ev->options['tickets'][$tick_type]['fee']; $output['price'] = $ev_fee; $output['name'] = $TickType->description . ': ' . $Ev->Detail->title . ', ' . $dt_info; $output['short_description'] = $output['name']; // TODO: fix to handle qty > 1, need loop and calc per-item pmt amt. USES_evlist_class_ticket(); $unpaid = evTicket::MarkPaid($quantity, $ev_id, $rp_id, $uid); if ($unpaid < 0) { EVLIST_Log("ALERT: {$quantity} tickets paid for user {$uid} for event {$ev_id}, exceeds unpaid count by {$unpaid}"); } else { EVLIST_Log("{$quantity} tickets paid for user {$uid}, event {$ev_id}/{$rp_id}"); } /*$tick = new evTicket(); $tick->ev_id = $ev_id; $tick->tic_type = $tick_type; $tick->fee = $ev_fee; $tick->uid = $uid; $tick->paid = $tick->fee; //foreach ($repeats as $save_rp_id) { $tick->rp_id = $rp_id; $tick->Save(); //} //$tick_id = evTicket::Create($ev_id, $rp_id, $tick_type, $ev_fee, $uid); //evTicket::AddPayment($tick_id, $ev_fee); */ break; } return PLG_RET_OK; }