Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-06-23-18-25-12
[civicrm-core.git] / CRM / Event / Cart / Page / AddToCart.php
1 <?php
2
3 /**
4 * Class CRM_Event_Cart_Page_AddToCart
5 */
6 class CRM_Event_Cart_Page_AddToCart extends CRM_Core_Page {
7 function run() {
8 $transaction = new CRM_Core_Transaction();
9
10 $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
11 if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id, 'register for events')) {
12 CRM_Core_Error::fatal(ts('You do not have permission to register for this event'));
13 }
14
15 $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
16 $event_in_cart = $cart->add_event($this->_id);
17
18 $url=CRM_Utils_System::url('civicrm/event/view_cart');
19 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)));
20
21 $transaction->commit();
22
23 return CRM_Utils_System::redirect($_SERVER['HTTP_REFERER']);
24 }
25 }
26
27
28