First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
34
sites/all/modules/civicrm/CRM/Event/Cart/Page/AddToCart.php
Normal file
34
sites/all/modules/civicrm/CRM/Event/Cart/Page/AddToCart.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class CRM_Event_Cart_Page_AddToCart
|
||||
*/
|
||||
class CRM_Event_Cart_Page_AddToCart extends CRM_Core_Page {
|
||||
/**
|
||||
* This function takes care of all the things common to all pages.
|
||||
*
|
||||
* This typically involves assigning the appropriate smarty variables :)
|
||||
*/
|
||||
public function run() {
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
|
||||
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
|
||||
if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id, 'register for events')) {
|
||||
CRM_Core_Error::fatal(ts('You do not have permission to register for this event'));
|
||||
}
|
||||
|
||||
$cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
|
||||
$event_in_cart = $cart->add_event($this->_id);
|
||||
|
||||
$url = CRM_Utils_System::url('civicrm/event/view_cart');
|
||||
CRM_Utils_System::setUFMessage(ts("<b>%1</b> has been added to your cart. <a href='%2'>View your cart.</a>", array(
|
||||
1 => $event_in_cart->event->title,
|
||||
2 => $url,
|
||||
)));
|
||||
|
||||
$transaction->commit();
|
||||
|
||||
return CRM_Utils_System::redirect($_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class CRM_Event_Cart_Page_CheckoutAJAX
|
||||
*/
|
||||
class CRM_Event_Cart_Page_CheckoutAJAX {
|
||||
public function add_participant_to_cart() {
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
$cart_id = CRM_Utils_Request::retrieve('cart_id', 'Integer');
|
||||
$event_id = CRM_Utils_Request::retrieve('event_id', 'Integer');
|
||||
|
||||
$cart = CRM_Event_Cart_BAO_Cart::find_by_id($cart_id);
|
||||
|
||||
$params_array = array(
|
||||
'cart_id' => $cart->id,
|
||||
'contact_id' => CRM_Event_Cart_Form_Cart::find_or_create_contact(),
|
||||
'event_id' => $event_id,
|
||||
);
|
||||
|
||||
//XXX security?
|
||||
$participant = CRM_Event_Cart_BAO_MerParticipant::create($params_array);
|
||||
$participant->save();
|
||||
|
||||
$form = new CRM_Core_Form();
|
||||
$pform = new CRM_Event_Cart_Form_MerParticipant($participant);
|
||||
$pform->appendQuickForm($form);
|
||||
|
||||
$renderer = $form->getRenderer();
|
||||
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$templateDir = $config->templateDir;
|
||||
if (is_array($templateDir)) {
|
||||
$templateDir = array_pop($templateDir);
|
||||
}
|
||||
$requiredTemplate = file_get_contents($templateDir . '/CRM/Form/label.tpl');
|
||||
$renderer->setRequiredTemplate($requiredTemplate);
|
||||
|
||||
$template = CRM_Core_Smarty::singleton();
|
||||
$template->assign('form', $form->toSmarty());
|
||||
$template->assign('participant', $participant);
|
||||
$output = $template->fetch("CRM/Event/Cart/Form/Checkout/Participant.tpl");
|
||||
$transaction->commit();
|
||||
echo $output;
|
||||
CRM_Utils_System::civiExit();
|
||||
}
|
||||
|
||||
public function remove_participant_from_cart() {
|
||||
$id = CRM_Utils_Request::retrieve('id', 'Integer');
|
||||
$participant = CRM_Event_Cart_BAO_MerParticipant::get_by_id($id);
|
||||
$participant->delete();
|
||||
|
||||
CRM_Utils_System::civiExit();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class CRM_Event_Cart_Page_RemoveFromCart
|
||||
*/
|
||||
class CRM_Event_Cart_Page_RemoveFromCart extends CRM_Core_Page {
|
||||
/**
|
||||
* This function takes care of all the things common to all pages.
|
||||
*
|
||||
* This typically involves assigning the appropriate smarty variables :)
|
||||
*/
|
||||
public function run() {
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
|
||||
$cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
|
||||
$cart->load_associations();
|
||||
$event_in_cart = $cart->get_event_in_cart_by_event_id($this->_id);
|
||||
$removed_event = $cart->remove_event_in_cart($event_in_cart->id);
|
||||
$removed_event_title = $removed_event->event->title;
|
||||
CRM_Core_Session::setStatus(ts("<b>%1</b> has been removed from your cart.", array(1 => $removed_event_title)), '', 'success');
|
||||
$transaction->commit();
|
||||
return CRM_Utils_System::redirect($_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
|
||||
}
|
23
sites/all/modules/civicrm/CRM/Event/Cart/Page/ViewCart.php
Normal file
23
sites/all/modules/civicrm/CRM/Event/Cart/Page/ViewCart.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class CRM_Event_Cart_Page_ViewCart
|
||||
*/
|
||||
class CRM_Event_Cart_Page_ViewCart extends CRM_Core_Page {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function run() {
|
||||
$transaction = new CRM_Core_Transaction();
|
||||
|
||||
$cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
|
||||
$cart->load_associations();
|
||||
$this->assign('events_in_carts', $cart->get_main_events_in_carts());
|
||||
$this->assign('events_count', count($cart->get_main_events_in_carts()));
|
||||
|
||||
$transaction->commit();
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue