コード例 #1
0
 function __construct($id)
 {
     $this->registration = Registration::load(array('order_id' => $id));
     if (!$this->registration) {
         error_exit("That registration does not exist");
     }
     $this->event = Event::load(array('registration_id' => $this->registration->registration_id));
     registration_add_to_menu($this->registration);
 }
コード例 #2
0
ファイル: event.php プロジェクト: h07r0d/leaguerunner
 function get_registration_for($user_id = null)
 {
     return Registration::load(array('user_id' => $user_id, 'registration_id' => $this->registration_id));
 }
コード例 #3
0
ファイル: permissions.php プロジェクト: roboshed/leaguerunner
function registration_permissions(&$user, $action, $id, $registration)
{
    global $lr_session;
    if (!$lr_session || !$lr_session->user) {
        return false;
    }
    switch ($action) {
        case 'view':
            if ($id && is_null($registration)) {
                $registration = Registration::load(array('order_id' => $id));
            }
            if (!is_null($registration) && $lr_session->is_complete() && $registration->user_id == $lr_session->user->user_id) {
                return 1;
            }
            break;
        case 'viewnotes':
        case 'edit':
        case 'addpayment':
        case 'delpayment':
            // Only admin can edit
            break;
        case 'register':
            // Only admins can register other players
            if (!is_null($id)) {
                return $id == $lr_session->user->user_id || $lr_session->is_admin();
            }
            // Otherwise, only players with completed profiles can register
            return $lr_session->user->is_active() && $lr_session->is_complete();
        case 'unregister':
            // Players may only unregister themselves from events before paying.
            // TODO: should be $registration->user_can_unregister()
            if ($lr_session->user->is_active() && $lr_session->is_complete() && $registration->user_id == $lr_session->user->user_id) {
                if ($registration->payment != 'Unpaid' && $registration->payment != 'Pending') {
                    // Don't allow user to unregister from paid events themselves -- admin must do it
                    return 0;
                }
                return 1;
            }
            return 0;
        case 'history':
            // Players with completed profiles can view their own history
            if ($id) {
                return $lr_session->is_complete() && $lr_session->user->user_id == $id;
            } else {
                return $lr_session->is_complete();
            }
        case 'statistics':
        case 'download':
            // admin only
            break;
    }
    return false;
}
コード例 #4
0
ファイル: PaypalHandler.php プロジェクト: h07r0d/leaguerunner
 /**
  * Checks information received from PayPal to ensure it's correct data.
  * If correct, stores updated transaction details.
  *
  * @param int $order_id Registration # of event being paid
  * @param float $mc_gross Amount paid by user during the PayPal checkout
  * @param int $paid_by User ID of player who made the payment
  */
 function validatePayment($order_id, $mc_gross, $paid_by)
 {
     // is the item number a valid registration?
     $registration = Registration::load(array('order_id' => $order_id));
     if (!$registration) {
         $status = array('status' => false, 'message' => 'Invalid Registration ID');
         return $status;
     }
     // has registration been already paid?
     //if ($registration->payment_type == 'Paid') {
     //	$status = array('status' => false, 'message' =>'Registration '.$order_id.' already paid in full');
     //	return $status;
     //}
     // is the registration attached to the correct Event
     $event = Event::load(array('registration_id' => $registration->registration_id));
     if (!$event) {
         $status = array('status' => false, 'message' => 'Invalid Event ID');
         return $status;
     }
     // does the price paid and registration cost match?
     if ($mc_gross != $event->cost) {
         $status = array('status' => false, 'message' => 'Amount Paid does not match Registration Cost');
         return $status;
     }
     // Payment is valid, and should be saved
     $payment = new RegistrationPayment();
     $payment->set('order_id', $registration->order_id);
     // TODO:  PDT returns from PayPal are logged under the Paypal account.
     // Would be nice to find a better way to do this instead of a Paypal user account
     $payment->set('entered_by', 999);
     // assign requrired values to the RegistrationPayment from the talkback results
     $payment->set('payment_type', 'Full');
     $payment->set('payment_amount', $mc_gross);
     $payment->set('payment_method', 'PayPal');
     $payment->set('paid_by', $paid_by);
     $payment->set('date_paid', date("Y-m-d"));
     // Save the payment if it's not already stored in the database
     // It's possible that the IPN payment beats the user PDT return.
     // Still need to ensure user is informed correctly, while not displaying any errors.
     if ($registration->payment_type != 'Paid') {
         if (!$payment->save()) {
             $status = array('status' => false, message => "Couldn't save payment to database");
             return $status;
         }
         // update registration in question
         $registration->set('payment', 'Paid');
         if (!$registration->save()) {
             $status = array('status' => false, message => "Internal error: couldn't save changes to registration");
         }
     }
     // if successful, return the $payment to handle/display to user
     return array('status' => true, 'message' => $payment);
 }