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(); }
function stub_out_and_inherit() { $transaction = new CRM_Core_Transaction(); foreach ($this->cart->get_main_events_in_carts() as $event_in_cart) { if (empty($event_in_cart->participants)) { $participant = CRM_Event_Cart_BAO_MerParticipant::create(array('cart_id' => $this->cart->id, 'event_id' => $event_in_cart->event_id, 'contact_id' => self::find_or_create_contact($this->getContactID()))); $participant->save(); $event_in_cart->add_participant($participant); } $event_in_cart->save(); } $transaction->commit(); }
function remove_participant_from_cart() { $participant = CRM_Event_Cart_BAO_MerParticipant::get_by_id($_GET['id']); $participant->delete(); CRM_Utils_System::civiExit(); }
function postProcess() { if (!array_key_exists('event', $this->_submitValues)) { return; } // XXX de facto primary key $email_to_contact_id = array(); foreach ($this->_submitValues['event'] as $event_id => $participants) { foreach ($participants['participant'] as $participant_id => $fields) { if (array_key_exists($fields['email'], $email_to_contact_id)) { $contact_id = $email_to_contact_id[$fields['email']]; } else { $contact_id = self::find_or_create_contact($this->getContactID(), $fields); $email_to_contact_id[$fields['email']] = $contact_id; } $participant = $this->cart->get_event_in_cart_by_event_id($event_id)->get_participant_by_id($participant_id); if ($participant->contact_id && $contact_id != $participant->contact_id) { $defaults = array(); $params = array('id' => $participant->contact_id); $temporary_contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults); foreach ($this->cart->get_subparticipants($participant) as $subparticipant) { $subparticipant->contact_id = $contact_id; $subparticipant->save(); } $participant->contact_id = $contact_id; $participant->save(); if ($temporary_contact->is_deleted) { #ARGH a permissions check prevents us from using skipUndelete, #so we potentially leave records pointing to this contact for now #CRM_Contact_BAO_Contact::deleteContact($temporary_contact->id); $temporary_contact->delete(); } } //TODO security check that participant ids are already in this cart $participant_params = array('id' => $participant_id, 'cart_id' => $this->cart->id, 'event_id' => $event_id, 'contact_id' => $contact_id, 'email' => $fields['email']); $participant = new CRM_Event_Cart_BAO_MerParticipant($participant_params); $participant->save(); $this->cart->add_participant_to_cart($participant); if (array_key_exists('field', $this->_submitValues) && array_key_exists($participant_id, $this->_submitValues['field'])) { $custom_fields = array_merge($participant->get_form()->get_participant_custom_data_fields()); CRM_Contact_BAO_Contact::createProfileContact($this->_submitValues['field'][$participant_id], $custom_fields, $contact_id); } } } $this->cart->save(); }
/** * @return array */ public function setDefaultValues() { $defaults = parent::setDefaultValues(); $config = CRM_Core_Config::singleton(); $default_country = new CRM_Core_DAO_Country(); $default_country->iso_code = $config->defaultContactCountry(); $default_country->find(TRUE); $defaults["billing_country_id-{$this->_bltID}"] = $default_country->id; if (self::getContactID() && !self::is_administrator()) { $params = array('id' => self::getContactID()); $contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults); foreach ($contact->email as $email) { if ($email['is_billing']) { $defaults["billing_contact_email"] = $email['email']; } } if (empty($defaults['billing_contact_email'])) { foreach ($contact->email as $email) { if ($email['is_primary']) { $defaults["billing_contact_email"] = $email['email']; } } } $defaults["billing_first_name"] = $contact->first_name; $defaults["billing_middle_name"] = $contact->middle_name; $defaults["billing_last_name"] = $contact->last_name; $billing_address = CRM_Event_Cart_BAO_MerParticipant::billing_address_from_contact($contact); if ($billing_address != NULL) { $defaults["billing_street_address-{$this->_bltID}"] = $billing_address['street_address']; $defaults["billing_city-{$this->_bltID}"] = $billing_address['city']; $defaults["billing_postal_code-{$this->_bltID}"] = $billing_address['postal_code']; $defaults["billing_state_province_id-{$this->_bltID}"] = $billing_address['state_province_id']; $defaults["billing_country_id-{$this->_bltID}"] = $billing_address['country_id']; } } $defaults["source"] = $this->description; return $defaults; }
function postProcess() { $params = $this->controller->exportValues($this->_name); $main_event_in_cart = $this->cart->get_event_in_cart_by_event_id($this->conference_event->id); foreach ($this->cart->events_in_carts as $event_in_cart) { if ($event_in_cart->event->parent_event_id == $this->conference_event->id) { $event_in_cart->remove_participant_by_contact_id($this->contact_id); if (empty($event_in_cart->participants)) { $this->cart->remove_event_in_cart($event_in_cart->id); } } } $slot_index = -1; foreach ($this->events_by_slot as $slot_name => $events) { $slot_index++; $field_name = "slot_{$slot_index}"; $session_event_id = CRM_Utils_Array::value($field_name, $params, NULL); if (!$session_event_id) { continue; } $event_in_cart = $this->cart->add_event($session_event_id); $values = array(); CRM_Core_DAO::storeValues($this->main_participant, $values); $values['id'] = NULL; $values['event_id'] = $event_in_cart->event_id; $participant = CRM_Event_Cart_BAO_MerParticipant::create($values); $participant->save(); $event_in_cart->add_participant($participant); } $this->cart->save(); }
/** * @param null $event_cart */ public function load_associations($event_cart = NULL) { if ($this->assocations_loaded) { return; } $this->assocations_loaded = TRUE; $params = array('id' => $this->event_id); $defaults = array(); $this->event = CRM_Event_BAO_Event::retrieve($params, $defaults); if ($event_cart != NULL) { $this->event_cart = $event_cart; $this->event_cart_id = $event_cart->id; } else { $this->event_cart = CRM_Event_Cart_BAO_Cart::find_by_id($this->event_cart_id); } $participants = CRM_Event_Cart_BAO_MerParticipant::find_all_by_event_and_cart_id($this->event_id, $this->event_cart->id); foreach ($participants as $participant) { $participant->load_associations(); $this->add_participant($participant); } }