/**
  * Set variables up before form is built.
  *
  * @return void
  */
 public function preProcess()
 {
     parent::preProcess();
     $setTab = CRM_Utils_Request::retrieve('setTab', 'Int', $this, FALSE, 0);
     $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => $this->_isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID)));
     $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $mapping, $this->_id);
     if ($reminderList && is_array($reminderList)) {
         // Add action links to each of the reminders
         foreach ($reminderList as &$format) {
             $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE;
             if ($format['is_active']) {
                 $action += CRM_Core_Action::DISABLE;
             } else {
                 $action += CRM_Core_Action::ENABLE;
             }
             $scheduleReminder = new CRM_Admin_Page_ScheduleReminders();
             $links = $scheduleReminder->links();
             $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&compId={$this->_id}";
             $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&compId={$this->_id}";
             $format['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $format['id']), ts('more'), FALSE, 'actionSchedule.manage.action', 'ActionSchedule', $this->_id);
         }
     }
     $this->assign('rows', $reminderList);
     $this->assign('setTab', $setTab);
     $this->assign('component', 'event');
     // Update tab "disabled" css class
     $this->ajaxResponse['tabValid'] = is_array($reminderList) && count($reminderList) > 0;
     $this->setPageTitle(ts('Scheduled Reminder'));
 }
Example #2
0
 public function postProcess()
 {
     $params = $this->exportValues();
     $params['id'] = $this->_id;
     CRM_Event_BAO_Event::add($params);
     parent::endPostProcess();
 }
Example #3
0
 /**
  * Set variables up before form is built.
  *
  * @return void
  */
 public function preProcess()
 {
     parent::preProcess();
     if ($this->_isTemplate) {
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'template_title');
     } else {
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'title');
     }
     if (!CRM_Event_BAO_Event::checkPermission($this->_id, CRM_Core_Permission::DELETE)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
 }
Example #4
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     parent::preProcess();
     //check for delete
     if (!CRM_Core_Permission::checkActionPermission('CiviEvent', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     if ($this->_isTemplate) {
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'template_title');
     } else {
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'title');
     }
 }
 /**
  * Process the form submission.
  *
  * @return void
  */
 public function postProcess()
 {
     // TODO:: is this required?
     $params = $this->controller->exportValues($this->_name);
     $existParams['page_id'] = $this->_id;
     $existParams['page_category'] = "civicrm_event";
     $existingEnrty = array();
     CRM_WebTracking_BAO_WebTracking::retrieve($existParams, $existingEnrty);
     // Setting up the params array with the values obtained from the form
     if (!empty($existingEnrty)) {
         $params['id'] = $existingEnrty['id'];
     }
     $params['page_id'] = $this->_id;
     $params['page_category'] = "civicrm_event";
     $params['enable_tracking'] = CRM_Utils_Array::value('enable_tracking', $params, FALSE);
     $params['tracking_id'] = CRM_Utils_Array::value('tracking_id', $params, NULL);
     $params['ga_event_tracking'] = CRM_Utils_Array::value('ga_event_tracking', $params, FALSE);
     $params['track_info'] = CRM_Utils_Array::value('track_info', $params, FALSE);
     $params['track_register'] = CRM_Utils_Array::value('track_register', $params, FALSE);
     $params['track_confirm_register'] = CRM_Utils_Array::value('track_confirm_register', $params, FALSE);
     $params['track_thank_you'] = CRM_Utils_Array::value('track_thank_you', $params, FALSE);
     $params['track_price_change'] = CRM_Utils_Array::value('track_price_change', $params, FALSE);
     $params['track_ecommerce'] = CRM_Utils_Array::value('track_ecommerce', $params, FALSE);
     $params['is_experiment'] = CRM_Utils_Array::value('is_experiment', $params, FALSE);
     $params['experiment_id'] = CRM_Utils_Array::value('experiment_id', $params, NULL);
     // Updating the database with the new entry
     $event = CRM_WebTracking_BAO_WebTracking::add($params);
     parent::endPostProcess();
 }
Example #6
0
 /**
  * Process the form submission.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     $params = $this->exportValues();
     $params['id'] = $this->_id;
     // format params
     $params['is_online_registration'] = CRM_Utils_Array::value('is_online_registration', $params, FALSE);
     $params['is_confirm_enabled'] = CRM_Utils_Array::value('is_confirm_enabled', $params, FALSE);
     // CRM-11182
     $params['is_multiple_registrations'] = CRM_Utils_Array::value('is_multiple_registrations', $params, FALSE);
     $params['allow_same_participant_emails'] = CRM_Utils_Array::value('allow_same_participant_emails', $params, FALSE);
     $params['requires_approval'] = CRM_Utils_Array::value('requires_approval', $params, FALSE);
     // reset is_email confirm if not online reg
     if (!$params['is_online_registration']) {
         $params['is_email_confirm'] = FALSE;
     }
     if (!$this->_isTemplate) {
         $params['registration_start_date'] = CRM_Utils_Date::processDate($params['registration_start_date'], $params['registration_start_date_time'], TRUE);
         $params['registration_end_date'] = CRM_Utils_Date::processDate($params['registration_end_date'], $params['registration_end_date_time'], TRUE);
     }
     CRM_Event_BAO_Event::add($params);
     // also update the ProfileModule tables
     $ufJoinParams = array('is_active' => 1, 'module' => 'CiviEvent', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
     // first delete all past entries
     CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
     $uf = array();
     $wt = 2;
     if (!empty($params['custom_pre_id'])) {
         $uf[1] = $params['custom_pre_id'];
         $wt = 1;
     }
     if (!empty($params['custom_post_id'])) {
         $uf[2] = $params['custom_post_id'];
     }
     if (!empty($params['custom_post_id_multiple'])) {
         $uf = array_merge($uf, $params['custom_post_id_multiple']);
     }
     $uf = array_values($uf);
     if (!empty($uf)) {
         foreach ($uf as $weight => $ufGroupId) {
             $ufJoinParams['weight'] = $weight + $wt;
             $ufJoinParams['uf_group_id'] = $ufGroupId;
             CRM_Core_BAO_UFJoin::create($ufJoinParams);
             unset($ufJoinParams['id']);
         }
     }
     // also update the ProfileModule tables
     $ufJoinParamsAdd = array('is_active' => 1, 'module' => 'CiviEvent_Additional', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
     // first delete all past entries
     CRM_Core_BAO_UFJoin::deleteAll($ufJoinParamsAdd);
     if (!empty($params['is_multiple_registrations'])) {
         $ufAdd = array();
         $wtAdd = 2;
         if (array_key_exists('additional_custom_pre_id', $params)) {
             if (empty($params['additional_custom_pre_id'])) {
                 $ufAdd[1] = $params['custom_pre_id'];
                 $wtAdd = 1;
             } elseif (CRM_Utils_Array::value('additional_custom_pre_id', $params) == 'none') {
             } else {
                 $ufAdd[1] = $params['additional_custom_pre_id'];
                 $wtAdd = 1;
             }
         }
         if (array_key_exists('additional_custom_post_id', $params)) {
             if (empty($params['additional_custom_post_id'])) {
                 $ufAdd[2] = $params['custom_post_id'];
             } elseif (CRM_Utils_Array::value('additional_custom_post_id', $params) == 'none') {
             } else {
                 $ufAdd[2] = $params['additional_custom_post_id'];
             }
         }
         if (!empty($params['additional_custom_post_id_multiple'])) {
             $additionalPostMultiple = array();
             foreach ($params['additional_custom_post_id_multiple'] as $key => $value) {
                 if (is_null($value) && !empty($params['custom_post_id'])) {
                     $additionalPostMultiple[$key] = $params['custom_post_id'];
                 } elseif ($value == 'none') {
                     continue;
                 } elseif ($value) {
                     $additionalPostMultiple[$key] = $value;
                 }
             }
             $ufAdd = array_merge($ufAdd, $additionalPostMultiple);
         }
         $ufAdd = array_values($ufAdd);
         if (!empty($ufAdd)) {
             foreach ($ufAdd as $weightAdd => $ufGroupIdAdd) {
                 $ufJoinParamsAdd['weight'] = $weightAdd + $wtAdd;
                 $ufJoinParamsAdd['uf_group_id'] = $ufGroupIdAdd;
                 CRM_Core_BAO_UFJoin::create($ufJoinParamsAdd);
                 unset($ufJoinParamsAdd['id']);
             }
         }
     }
     // get the profiles to evaluate what they collect
     $profileIds = array(CRM_Utils_Array::value('custom_pre_id', $params), CRM_Utils_Array::value('custom_post_id', $params));
     $additionalProfileIds = array(CRM_Utils_Array::value('additional_custom_pre_id', $params), CRM_Utils_Array::value('additional_custom_post_id', $params));
     // additional profile fields default to main if not set
     if (!is_numeric($additionalProfileIds[0])) {
         $additionalProfileIds[0] = $profileIds[0];
     }
     if (!is_numeric($additionalProfileIds[1])) {
         $additionalProfileIds[1] = $profileIds[1];
     }
     //add multiple profiles if set
     self::addMultipleProfiles($profileIds, $params, 'custom_post_id_multiple');
     self::addMultipleProfiles($additionalProfileIds, $params, 'additional_custom_post_id_multiple');
     $cantDedupe = FALSE;
     $rgId = CRM_Utils_Array::value('dedupe_rule_group_id', $params, 0);
     switch (self::canProfilesDedupe($profileIds, $rgId)) {
         case 0:
             $dedupeTitle = 'Duplicate Matching Impossible';
             $cantDedupe = ts("The selected profiles do not contain the fields necessary to match registrations with existing contacts.  This means all anonymous registrations will result in a new contact.");
             break;
         case 1:
             $dedupeTitle = 'Duplicate Contacts Possible';
             $cantDedupe = ts("The selected profiles can collect enough information to match registrations with existing contacts, but not all of the relevant fields are required.  Anonymous registrations may result in duplicate contacts.");
     }
     if (!empty($params['is_multiple_registrations'])) {
         switch (self::canProfilesDedupe($additionalProfileIds, $rgId)) {
             case 0:
                 $dedupeTitle = 'Duplicate Matching Impossible';
                 if ($cantDedupe) {
                     $cantDedupe = ts("The selected profiles do not contain the fields necessary to match registrations with existing contacts.  This means all anonymous registrations will result in a new contact.");
                 } else {
                     $cantDedupe = ts("The selected profiles do not contain the fields necessary to match additional participants with existing contacts.  This means all additional participants will result in a new contact.");
                 }
                 break;
             case 1:
                 if (!$cantDedupe) {
                     $dedupeTitle = 'Duplicate Contacts Possible';
                     $cantDedupe = ts("The selected profiles can collect enough information to match additional participants with existing contacts, but not all of the relevant fields are required.  This may result in duplicate contacts.");
                 }
         }
     }
     if ($cantDedupe) {
         CRM_Core_Session::setStatus($cantDedupe, $dedupeTitle, 'alert dedupenotify', array('expires' => 0));
     }
     // Update tab "disabled" css class
     $this->ajaxResponse['tabValid'] = !empty($params['is_online_registration']);
     parent::endPostProcess();
 }
Example #7
0
 /**
  * Function to process the form. Enables/disables Volunteer Project. If the
  * Project does not already exist, it is created, along with a "flexible" Need.
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     $form = $this->exportValues();
     $form['is_active'] = CRM_Utils_Array::value('is_active', $form, 0);
     $params = array('entity_id' => $this->_id, 'entity_table' => CRM_Event_DAO_Event::$_tableName);
     // see if this project already exists
     $projects = CRM_Volunteer_BAO_Project::retrieve($params);
     if (count($projects)) {
         // force an update rather than an insert
         $params['id'] = current($projects)->id;
     }
     // save the project record
     $params += array('is_active' => $form['is_active'], 'target_contact_id' => $form['target_contact_id']);
     $project = CRM_Volunteer_BAO_Project::create($params);
     // if the project doesn't already exist and the user enabled vol management,
     // create the flexible need
     if (count($projects) !== 1 && $form['is_active'] === '1') {
         $need = array('project_id' => $project->id, 'is_flexible' => '1', 'visibility_id' => CRM_Core_OptionGroup::getValue('visibility', 'public', 'name'));
         CRM_Volunteer_BAO_Need::create($need);
     }
     parent::endPostProcess();
 }
Example #8
0
 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     //format params
     $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
     $params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], $params['end_date_time'], true);
     $params['has_waitlist'] = CRM_Utils_Array::value('has_waitlist', $params, false);
     $params['is_map'] = CRM_Utils_Array::value('is_map', $params, false);
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, false);
     $params['is_public'] = CRM_Utils_Array::value('is_public', $params, false);
     $params['default_role_id'] = CRM_Utils_Array::value('default_role_id', $params, false);
     $params['id'] = $this->_id;
     //new event, so lets set the created_id
     if ($this->_action & CRM_Core_Action::ADD) {
         $session =& CRM_Core_Session::singleton();
         $params['created_id'] = $session->get('userID');
         $params['created_date'] = date('YmdHis');
     }
     $customFields = CRM_Core_BAO_CustomField::getFields('Event', false, false, CRM_Utils_Array::value('event_type_id', $params));
     $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_id, 'Event');
     require_once 'CRM/Event/BAO/Event.php';
     // copy all not explicitely set $params keys from the template (if it should be sourced)
     if (CRM_Utils_Array::value('template_id', $params)) {
         $defaults = array();
         $templateParams = array('id' => $params['template_id']);
         CRM_Event_BAO_Event::retrieve($templateParams, $defaults);
         unset($defaults['id']);
         unset($defaults['default_fee_id']);
         unset($defaults['default_discount_fee_id']);
         foreach ($defaults as $key => $value) {
             if (!isset($params[$key])) {
                 $params[$key] = $value;
             }
         }
     }
     $event = CRM_Event_BAO_Event::create($params);
     // now that we have the event’s id, do some more template-based stuff
     if (CRM_Utils_Array::value('template_id', $params)) {
         // copy event fees
         $ogParams = array('name' => "civicrm_event.amount.{$event->id}");
         $defaults = array();
         require_once 'CRM/Core/BAO/OptionGroup.php';
         if (is_null(CRM_Core_BAO_OptionGroup::retrieve($ogParams, $defaults))) {
             // Copy the Main Event Fees
             CRM_Core_BAO_OptionGroup::copyValue('event', $params['template_id'], $event->id);
             // Copy the Discount option Group and Values
             require_once 'CRM/Core/BAO/Discount.php';
             $optionGroupIds = CRM_Core_BAO_Discount::getOptionGroup($params['template_id'], "civicrm_event");
             foreach ($optionGroupIds as $id) {
                 $discountSuffix = '.discount.' . CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $id, 'label');
                 CRM_Core_BAO_OptionGroup::copyValue('event', $params['template_id'], $event->id, false, $discountSuffix);
             }
         }
         // copy price sets if any
         require_once 'CRM/Price/BAO/Set.php';
         $priceSetId = CRM_Price_BAO_Set::getFor('civicrm_event', $params['template_id']);
         if ($priceSetId) {
             CRM_Price_BAO_Set::addTo('civicrm_event', $event->id, $priceSetId);
         }
         // link profiles if none linked
         $ufParams = array('entity_table' => 'civicrm_event', 'entity_id' => $event->id);
         require_once 'CRM/Core/BAO/UFJoin.php';
         if (!CRM_Core_BAO_UFJoin::findUFGroupId($ufParams)) {
             CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin', array('entity_id' => $params['template_id'], 'entity_table' => 'civicrm_event'), array('entity_id' => $event->id));
         }
         // if no Tell-a-Friend defined, check whether there’s one for template and copy if so
         $tafParams = array('entity_table' => 'civicrm_event', 'entity_id' => $event->id);
         require_once 'CRM/Friend/BAO/Friend.php';
         if (!CRM_Friend_BAO_Friend::getValues($tafParams)) {
             $tafParams['entity_id'] = $params['template_id'];
             if (CRM_Friend_BAO_Friend::getValues($tafParams)) {
                 $tafParams['entity_id'] = $event->id;
                 CRM_Friend_BAO_Friend::addTellAFriend($tafParams);
             }
         }
     }
     $this->set('id', $event->id);
     if ($this->_action & CRM_Core_Action::ADD) {
         $urlParam = "action=update&reset=1&subPage=Location&id={$event->id}";
         // special case for 'Save and Done' consistency.
         if ($this->controller->getButtonName('submit') == "_qf_EventInfo_upload_done") {
             $urlParam = "action=update&reset=1&id={$event->id}";
             CRM_Core_Session::setStatus(ts("'%1' information has been saved.", array(1 => $this->getTitle())));
         }
         CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), $urlParam));
     }
     parent::endPostProcess();
 }
 /**
  * Process the form submission. Enables/disables Volunteer Project. If the
  * Project does not already exist, it is created, along with a "flexible" Need.
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     $form = $this->getSubmitValues();
     $form['is_active'] = CRM_Utils_Array::value('is_active', $form, 0);
     $params = array();
     if ($this->getProject()) {
         // force an update rather than an insert
         $params['id'] = $this->getProject()->id;
     }
     // save the project record
     $params += array('is_active' => $form['is_active'], 'target_contact_id' => $form['target_contact_id']);
     /* @var $project CRM_Volunteer_BAO_Project */
     $project = $this->saveProject($params);
     $this->saveProfileSelections($form['custom_signup_profiles']);
     self::validateProfileForDedupe($form['custom_signup_profiles']);
     parent::endPostProcess();
 }
Example #10
0
 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     // get the submitted form values.
     $formValues = $this->controller->exportValues($this->_name);
     // let's unset event id
     unset($formValues['id']);
     $formValues['entity_table'] = 'civicrm_event';
     $formValues['entity_id'] = $this->_id;
     $formValues['title'] = $formValues['tf_title'];
     $formValues['is_active'] = CRM_Utils_Array::value('tf_is_active', $formValues, false);
     if ($this->_action & CRM_Core_Action::UPDATE && $this->_friendId) {
         $formValues['id'] = $this->_friendId;
     }
     CRM_Friend_BAO_Friend::addTellAFriend($formValues);
     parent::endPostProcess();
 }
 public function postProcess()
 {
     $params = array();
     $params = $this->exportValues();
     if (trim($params['parent_event_name']) === '') {
         # believe me...
         $params['parent_event_id'] = '';
     }
     //update events table
     $params['id'] = $this->_id;
     CRM_Event_BAO_Event::add($params);
     parent::endPostProcess();
 }
 /**
  * Function to process the form
  *
  * @access public
  *
  * @return void
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         // delete reminder
         CRM_Core_BAO_ActionSchedule::del($this->_id);
         CRM_Core_Session::setStatus(ts('Selected Reminder has been deleted.'), ts('Record Deleted'), 'success');
         return;
     }
     $values = $this->controller->exportValues($this->getName());
     $keys = array('title', 'subject', 'absolute_date', 'group_id', 'record_activity', 'limit_to');
     foreach ($keys as $key) {
         $params[$key] = CRM_Utils_Array::value($key, $values);
     }
     $moreKeys = array('start_action_offset', 'start_action_unit', 'start_action_condition', 'start_action_date', 'repetition_frequency_unit', 'repetition_frequency_interval', 'end_frequency_unit', 'end_frequency_interval', 'end_action', 'end_date');
     if ($absoluteDate = CRM_Utils_Array::value('absolute_date', $params)) {
         $params['absolute_date'] = CRM_Utils_Date::processDate($absoluteDate);
         foreach ($moreKeys as $mkey) {
             $params[$mkey] = 'null';
         }
     } else {
         $params['absolute_date'] = 'null';
         foreach ($moreKeys as $mkey) {
             $params[$mkey] = CRM_Utils_Array::value($mkey, $values);
         }
     }
     $params['body_text'] = CRM_Utils_Array::value('text_message', $values);
     $params['body_html'] = CRM_Utils_Array::value('html_message', $values);
     if (CRM_Utils_Array::value('recipient', $values) == 'manual') {
         $params['recipient_manual'] = CRM_Utils_Array::value('recipient_manual_id', $values);
         $params['group_id'] = $params['recipient'] = $params['recipient_listing'] = 'null';
     } elseif (CRM_Utils_Array::value('recipient', $values) == 'group') {
         $params['group_id'] = $values['group_id'];
         $params['recipient_manual'] = $params['recipient'] = $params['recipient_listing'] = 'null';
     } elseif (!CRM_Utils_System::isNull($values['recipient_listing'])) {
         $params['recipient'] = CRM_Utils_Array::value('recipient', $values);
         $params['recipient_listing'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('recipient_listing', $values));
         $params['group_id'] = $params['recipient_manual'] = 'null';
     } else {
         $params['recipient'] = CRM_Utils_Array::value('recipient', $values);
         $params['group_id'] = $params['recipient_manual'] = $params['recipient_listing'] = 'null';
     }
     $params['mapping_id'] = $this->_mappingID;
     $params['entity_value'] = $this->_id;
     $params['entity_status'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $values['entity']);
     $params['is_active'] = CRM_Utils_Array::value('is_active', $values, 0);
     $params['is_repeat'] = CRM_Utils_Array::value('is_repeat', $values, 0);
     if (CRM_Utils_Array::value('is_repeat', $values) == 0) {
         $params['repetition_frequency_unit'] = 'null';
         $params['repetition_frequency_interval'] = 'null';
         $params['end_frequency_unit'] = 'null';
         $params['end_frequency_interval'] = 'null';
         $params['end_action'] = 'null';
         $params['end_date'] = 'null';
     }
     $params['name'] = CRM_Utils_String::munge($params['title'], '_', 64);
     $composeFields = array('template', 'saveTemplate', 'updateTemplate', 'saveTemplateName');
     $msgTemplate = NULL;
     //mail template is composed
     $composeParams = array();
     foreach ($composeFields as $key) {
         if (!empty($values[$key])) {
             $composeParams[$key] = $values[$key];
         }
     }
     if (!empty($composeParams['updateTemplate'])) {
         $templateParams = array('msg_text' => $params['body_text'], 'msg_html' => $params['body_html'], 'msg_subject' => $params['subject'], 'is_active' => TRUE);
         $templateParams['id'] = $values['template'];
         $msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
     }
     if (!empty($composeParams['saveTemplate'])) {
         $templateParams = array('msg_text' => $params['body_text'], 'msg_html' => $params['body_html'], 'msg_subject' => $params['subject'], 'is_active' => TRUE);
         $templateParams['msg_title'] = $composeParams['saveTemplateName'];
         $msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
     }
     if (isset($msgTemplate->id)) {
         $params['msg_template_id'] = $msgTemplate->id;
     } else {
         $params['msg_template_id'] = CRM_Utils_Array::value('template', $values);
     }
     CRM_Core_BAO_ActionSchedule::add($params, $ids);
     $status = ts("Your new Reminder titled %1 has been saved.", array(1 => "<strong>{$values['title']}</strong>"));
     CRM_Core_Session::setStatus($status, ts('Saved'), 'success');
     parent::endPostProcess();
 }
Example #13
0
 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     $params = $this->exportValues();
     $delteOldBlock = false;
     // if 'use existing location' option is selected -
     if ($params['location_option'] == 2 && CRM_Utils_Array::value('loc_event_id', $params) && $params['loc_event_id'] != $this->_oldLocBlockId) {
         // if new selected loc is different from old loc, update the loc_block_id
         // so that loc update would affect the selected loc and not the old one.
         $delteOldBlock = true;
         CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Event', $this->_id, 'loc_block_id', $params['loc_event_id']);
     }
     // if 'create new loc' option is selected, set the loc_block_id for this event to null
     // so that an update would result in creating a new loc.
     if ($this->_oldLocBlockId && $params['location_option'] == 1) {
         $delteOldBlock = true;
         CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Event', $this->_id, 'loc_block_id', 'null');
     }
     // if 'create new loc' optioin is selected OR selected new loc is different
     // from old one, go ahead and delete the old loc provided thats not being
     // used by any other event
     if ($this->_oldLocBlockId && $delteOldBlock) {
         CRM_Event_BAO_Event::deleteEventLocBlock($this->_oldLocBlockId, $this->_id);
     }
     // get ready with location block params
     $params['entity_table'] = 'civicrm_event';
     $params['entity_id'] = $this->_id;
     require_once 'CRM/Core/BAO/LocationType.php';
     $defaultLocationType =& CRM_Core_BAO_LocationType::getDefault();
     foreach (array('address', 'phone', 'email') as $block) {
         if (!CRM_Utils_Array::value($block, $params) || !is_array($params[$block])) {
             continue;
         }
         foreach ($params[$block] as $count => &$values) {
             if ($count == 1) {
                 $values['is_primary'] = 1;
             }
             $values['location_type_id'] = $defaultLocationType->id ? $defaultLocationType->id : 1;
         }
     }
     // create/update event location
     require_once 'CRM/Core/BAO/Location.php';
     $location = CRM_Core_BAO_Location::create($params, true, 'event');
     $params['loc_block_id'] = $location['id'];
     // finally update event params
     $params['id'] = $this->_id;
     require_once 'CRM/Event/BAO/Event.php';
     CRM_Event_BAO_Event::add($params);
     parent::endPostProcess();
 }
Example #14
0
 /**
  * Process the form submission.
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     //format params
     $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
     $params['end_date'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('end_date', $params), CRM_Utils_Array::value('end_date_time', $params), TRUE);
     $params['has_waitlist'] = CRM_Utils_Array::value('has_waitlist', $params, FALSE);
     $params['is_map'] = CRM_Utils_Array::value('is_map', $params, FALSE);
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     $params['is_public'] = CRM_Utils_Array::value('is_public', $params, FALSE);
     $params['is_share'] = CRM_Utils_Array::value('is_share', $params, FALSE);
     $params['default_role_id'] = CRM_Utils_Array::value('default_role_id', $params, FALSE);
     $params['id'] = $this->_id;
     $customFields = CRM_Core_BAO_CustomField::getFields('Event', FALSE, FALSE, CRM_Utils_Array::value('event_type_id', $params));
     $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_id, 'Event');
     //merge params with defaults from templates
     if (!empty($params['template_id'])) {
         $params = array_merge(CRM_Event_BAO_Event::getTemplateDefaultValues($params['template_id']), $params);
     }
     $event = CRM_Event_BAO_Event::create($params);
     // now that we have the event’s id, do some more template-based stuff
     if (!empty($params['template_id'])) {
         CRM_Event_BAO_Event::copy($params['template_id'], $event, TRUE);
     }
     $this->set('id', $event->id);
     $this->postProcessHook();
     if ($this->_action & CRM_Core_Action::ADD) {
         $url = 'civicrm/event/manage/location';
         $urlParams = "action=update&reset=1&id={$event->id}";
         // special case for 'Save and Done' consistency.
         if ($this->controller->getButtonName('submit') == '_qf_EventInfo_upload_done') {
             $url = 'civicrm/event/manage';
             $urlParams = 'reset=1';
             CRM_Core_Session::setStatus(ts("'%1' information has been saved.", array(1 => $this->getTitle())), ts('Saved'), 'success');
         }
         CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams));
     }
     parent::endPostProcess();
 }
 /**
  * Process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $params = array();
     $eventTitle = '';
     $params = $this->exportValues();
     $this->set('discountSection', 0);
     if (CRM_Utils_Array::value('_qf_Fee_submit', $_POST)) {
         $this->buildAmountLabel();
         $this->set('discountSection', 2);
         return;
     }
     if (array_key_exists('payment_processor', $params) && !CRM_Utils_System::isNull($params['payment_processor'])) {
         $params['payment_processor'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['payment_processor']));
     } else {
         $params['payment_processor'] = 'null';
     }
     $params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, 0);
     if ($this->_id) {
         // delete all the prior label values or discounts in the custom options table
         // and delete a price set if one exists
         if (CRM_Price_BAO_Set::removeFrom('civicrm_event', $this->_id)) {
             CRM_Core_BAO_Discount::del($this->_id, 'civicrm_event');
         }
     }
     if ($params['is_monetary']) {
         if (CRM_Utils_Array::value('price_set_id', $params)) {
             CRM_Price_BAO_Set::addTo('civicrm_event', $this->_id, $params['price_set_id']);
             if (CRM_Utils_Array::value('price_field_id', $params)) {
                 $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $params['price_field_id'], 'price_set_id');
                 CRM_Price_BAO_Set::setIsQuickConfig($priceSetID, 0);
             }
         } else {
             // if there are label / values, create custom options for them
             $labels = CRM_Utils_Array::value('label', $params);
             $values = CRM_Utils_Array::value('value', $params);
             $default = CRM_Utils_Array::value('default', $params);
             $options = array();
             if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
                 for ($i = 1; $i < self::NUM_OPTION; $i++) {
                     if (!empty($labels[$i]) && !CRM_Utils_System::isNull($values[$i])) {
                         $options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
                     }
                 }
                 if (!empty($options)) {
                     $params['default_fee_id'] = NULL;
                     if (!CRM_Utils_Array::value('price_set_id', $params)) {
                         if (!CRM_Utils_Array::value('price_field_id', $params)) {
                             $eventTitle = $this->_isTemplate ? $this->_defaultValues['template_title'] : $this->_defaultValues['title'];
                             if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_Set', $eventTitle, 'id', 'title')) {
                                 $setParams['name'] = $setParams['title'] = $eventTitle;
                             } elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_Set', $eventTitle . '_' . $this->_id, 'id', 'title')) {
                                 $setParams['name'] = $setParams['title'] = $eventTitle . '_' . $this->_id;
                             } else {
                                 $timeSec = explode(".", microtime(true));
                                 $setParams['name'] = $setParams['title'] = $eventTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
                             }
                             $setParams['is_quick_config'] = 1;
                             $setParams['extends'] = CRM_Core_Component::getComponentID('CiviEvent');
                             $priceSet = CRM_Price_BAO_Set::create($setParams);
                             $fieldParams['name'] = $fieldParams['label'] = $params['fee_label'];
                             $fieldParams['price_set_id'] = $priceSet->id;
                         } else {
                             foreach ($params['price_field_value'] as $arrayID => $fieldValueID) {
                                 if (empty($params['label'][$arrayID]) && empty($params['value'][$arrayID]) && !empty($fieldValueID)) {
                                     CRM_Price_BAO_FieldValue::setIsActive($fieldValueID, '0');
                                     unset($params['price_field_value'][$arrayID]);
                                 }
                             }
                             $fieldParams['id'] = CRM_Utils_Array::value('price_field_id', $params);
                             $fieldParams['option_id'] = $params['price_field_value'];
                             $priceSet->id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', CRM_Utils_Array::value('price_field_id', $params), 'price_set_id');
                         }
                         $fieldParams['html_type'] = 'Radio';
                         CRM_Price_BAO_Set::addTo('civicrm_event', $this->_id, $priceSet->id);
                         $fieldParams['option_label'] = $params['label'];
                         $fieldParams['option_amount'] = $params['value'];
                         foreach ($options as $value) {
                             $fieldParams['option_weight'][$value['weight']] = $value['weight'];
                         }
                         $fieldParams['default_option'] = $params['default'];
                         $priceField = CRM_Price_BAO_Field::create($fieldParams);
                     }
                 }
             }
             $discountPriceSets = CRM_Utils_Array::value('discount_price_set', $this->_defaultValues) ? $this->_defaultValues['discount_price_set'] : array();
             $discountFieldIDs = CRM_Utils_Array::value('discount_option_id', $this->_defaultValues) ? $this->_defaultValues['discount_option_id'] : array();
             if (CRM_Utils_Array::value('is_discount', $params) == 1) {
                 // if there are discounted set of label / values,
                 // create custom options for them
                 $labels = CRM_Utils_Array::value('discounted_label', $params);
                 $values = CRM_Utils_Array::value('discounted_value', $params);
                 $default = CRM_Utils_Array::value('discounted_default', $params);
                 if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
                     for ($j = 1; $j <= self::NUM_DISCOUNT; $j++) {
                         $discountOptions = array();
                         for ($i = 1; $i < self::NUM_OPTION; $i++) {
                             if (!empty($labels[$i]) && !empty($values[$i][$j])) {
                                 $discountOptions[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i][$j])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
                             }
                         }
                         if (!empty($discountOptions)) {
                             $fieldParams = array();
                             $params['default_discount_fee_id'] = NULL;
                             $keyCheck = $j - 1;
                             if (!CRM_Utils_Array::value($keyCheck, $discountPriceSets)) {
                                 if (!$eventTitle) {
                                     $eventTitle = strtolower(CRM_Utils_String::munge($this->_defaultValues['title'], '_', 200));
                                 }
                                 $setParams['title'] = $params['discount_name'][$j];
                                 if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_Set', $eventTitle . '_' . $params['discount_name'][$j], 'id', 'name')) {
                                     $setParams['name'] = $eventTitle . '_' . $params['discount_name'][$j];
                                 } elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_Set', $eventTitle . '_' . $params['discount_name'][$j] . '_' . $this->_id, 'id', 'name')) {
                                     $setParams['name'] = $eventTitle . '_' . $params['discount_name'][$j] . '_' . $this->_id;
                                 } else {
                                     $timeSec = explode(".", microtime(true));
                                     $setParams['name'] = $eventTitle . '_' . $params['discount_name'][$j] . '_' . date('is', $timeSec[0]) . $timeSec[1];
                                 }
                                 $setParams['is_quick_config'] = 1;
                                 $setParams['extends'] = CRM_Core_Component::getComponentID('CiviEvent');
                                 $priceSet = CRM_Price_BAO_Set::create($setParams);
                                 $priceSetID = $priceSet->id;
                             } else {
                                 $priceSetID = $discountPriceSets[$j - 1];
                                 unset($discountPriceSets[$j - 1]);
                                 $fieldParams['id'] = CRM_Core_DAO::getFieldValue('CRM_Price_BAO_Field', $priceSetID, 'id', 'price_set_id');
                             }
                             $fieldParams['name'] = $fieldParams['label'] = $params['fee_label'];
                             $fieldParams['is_required'] = 1;
                             $fieldParams['price_set_id'] = $priceSetID;
                             $fieldParams['html_type'] = 'Radio';
                             foreach ($discountOptions as $value) {
                                 $fieldParams['option_label'][$value['weight']] = $value['label'];
                                 $fieldParams['option_amount'][$value['weight']] = $value['value'];
                                 $fieldParams['option_weight'][$value['weight']] = $value['weight'];
                                 if (CRM_Utils_Array::value('is_default', $value)) {
                                     $fieldParams['default_option'] = $value['weight'];
                                 }
                                 if (CRM_Utils_Array::value($j, $discountFieldIDs) && CRM_Utils_Array::value($value['weight'] - 1, $discountFieldIDs[$j])) {
                                     $fieldParams['option_id'][$value['weight']] = $discountFieldIDs[$j][$value['weight'] - 1];
                                     unset($discountFieldIDs[$j][$value['weight'] - 1]);
                                 }
                             }
                             //create discount priceset
                             $priceField = CRM_Price_BAO_Field::create($fieldParams);
                             if (!empty($discountFieldIDs)) {
                                 foreach ($discountFieldIDs as $fID) {
                                     CRM_Price_BAO_FieldValue::setIsActive($fID, '0');
                                 }
                             }
                             $discountParams = array('entity_table' => 'civicrm_event', 'entity_id' => $this->_id, 'option_group_id' => $priceSetID, 'start_date' => CRM_Utils_Date::processDate($params["discount_start_date"][$j]), 'end_date' => CRM_Utils_Date::processDate($params["discount_end_date"][$j]));
                             CRM_Core_BAO_Discount::add($discountParams);
                         }
                     }
                 }
             }
             if (!empty($discountPriceSets)) {
                 foreach ($discountPriceSets as $setId) {
                     CRM_Price_BAO_Set::setIsQuickConfig($setId, 0);
                 }
             }
         }
     } else {
         if (CRM_Utils_Array::value('price_field_id', $params)) {
             $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $params['price_field_id'], 'price_set_id');
             CRM_Price_BAO_Set::setIsQuickConfig($priceSetID, 0);
         }
         $params['contribution_type_id'] = '';
     }
     //update events table
     $params['id'] = $this->_id;
     CRM_Event_BAO_Event::add($params);
     parent::endPostProcess();
 }
Example #16
0
 /**
  * Process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $params = array();
     $params = $this->exportValues();
     $this->set('discountSection', 0);
     if (CRM_Utils_Array::value('_qf_Fee_submit', $_POST)) {
         $this->buildAmountLabel();
         $this->set('discountSection', 1);
         CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/manage', '#isDiscount'));
         return;
     }
     $params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, 0);
     if ($this->_id) {
         require_once 'CRM/Price/BAO/Set.php';
         // delete all the prior label values or discounts in the custom options table
         // and delete a price set if one exists
         if (!CRM_Price_BAO_Set::removeFrom('civicrm_event', $this->_id)) {
             require_once 'CRM/Core/OptionGroup.php';
             CRM_Core_OptionGroup::deleteAssoc("civicrm_event.amount.{$this->_id}");
             CRM_Core_OptionGroup::deleteAssoc("civicrm_event.amount.{$this->_id}.discount.%", "LIKE");
         }
     }
     if ($params['is_monetary']) {
         if ($params['price_set_id']) {
             CRM_Price_BAO_Set::addTo('civicrm_event', $this->_id, $params['price_set_id']);
         } else {
             // if there are label / values, create custom options for them
             $labels = CRM_Utils_Array::value('label', $params);
             $values = CRM_Utils_Array::value('value', $params);
             $default = CRM_Utils_Array::value('default', $params);
             $options = array();
             if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
                 for ($i = 1; $i < self::NUM_OPTION; $i++) {
                     if (!empty($labels[$i]) && !CRM_Utils_System::isNull($values[$i])) {
                         $options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
                     }
                 }
                 if (!empty($options)) {
                     $params['default_fee_id'] = null;
                     CRM_Core_OptionGroup::createAssoc("civicrm_event.amount.{$this->_id}", $options, $params['default_fee_id']);
                 }
             }
             if (CRM_Utils_Array::value('is_discount', $params) == 1) {
                 // if there are discounted set of label / values,
                 // create custom options for them
                 $labels = CRM_Utils_Array::value('discounted_label', $params);
                 $values = CRM_Utils_Array::value('discounted_value', $params);
                 $default = CRM_Utils_Array::value('discounted_default', $params);
                 if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
                     for ($j = 1; $j <= self::NUM_DISCOUNT; $j++) {
                         $discountOptions = array();
                         for ($i = 1; $i < self::NUM_OPTION; $i++) {
                             if (!empty($labels[$i]) && CRM_Utils_Array::value($j, $values[$i])) {
                                 $discountOptions[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i][$j])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
                             }
                         }
                         if (!empty($discountOptions)) {
                             $params['default_discount_fee_id'] = null;
                             $discountOptionsGroupId = CRM_Core_OptionGroup::createAssoc("civicrm_event.amount.{$this->_id}.discount.{$params['discount_name'][$j]}", $discountOptions, $params['default_discount_fee_id'], $params['discount_name'][$j]);
                             $discountParams = array('entity_table' => 'civicrm_event', 'entity_id' => $this->_id, 'option_group_id' => $discountOptionsGroupId, 'start_date' => CRM_Utils_Date::format($params["discount_start_date"][$j]), 'end_date' => CRM_Utils_Date::format($params["discount_end_date"][$j]));
                             require_once 'CRM/Core/BAO/Discount.php';
                             CRM_Core_BAO_Discount::add($discountParams);
                         }
                     }
                 }
             }
         }
     } else {
         $params['contribution_type_id'] = '';
     }
     //update events table
     require_once 'CRM/Event/BAO/Event.php';
     $params['id'] = $this->_id;
     CRM_Event_BAO_Event::add($params);
     parent::endPostProcess();
 }
 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     $params = array();
     $params = $this->exportValues();
     $params['id'] = $this->_id;
     //format params
     $params['is_online_registration'] = CRM_Utils_Array::value('is_online_registration', $params, FALSE);
     $params['is_multiple_registrations'] = CRM_Utils_Array::value('is_multiple_registrations', $params, FALSE);
     $params['allow_same_participant_emails'] = CRM_Utils_Array::value('allow_same_participant_emails', $params, FALSE);
     $params['requires_approval'] = CRM_Utils_Array::value('requires_approval', $params, FALSE);
     // reset is_email confirm if not online reg
     if (!$params['is_online_registration']) {
         $params['is_email_confirm'] = FALSE;
     }
     if (!$this->_isTemplate) {
         $params['registration_start_date'] = CRM_Utils_Date::processDate($params['registration_start_date'], $params['registration_start_date_time'], TRUE);
         $params['registration_end_date'] = CRM_Utils_Date::processDate($params['registration_end_date'], $params['registration_end_date_time'], TRUE);
     }
     CRM_Event_BAO_Event::add($params);
     // also update the ProfileModule tables
     $ufJoinParams = array('is_active' => 1, 'module' => 'CiviEvent', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
     // first delete all past entries
     CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
     $uf = array();
     $wt = 2;
     if (!empty($params['custom_pre_id'])) {
         $uf[1] = $params['custom_pre_id'];
         $wt = 1;
     }
     if (!empty($params['custom_post_id'])) {
         $uf[2] = $params['custom_post_id'];
     }
     if (CRM_Utils_Array::value('custom_post_id_multiple', $params)) {
         $uf = array_merge($uf, $params['custom_post_id_multiple']);
     }
     $uf = array_values($uf);
     if (!empty($uf)) {
         foreach ($uf as $weight => $ufGroupId) {
             $ufJoinParams['weight'] = $weight + $wt;
             $ufJoinParams['uf_group_id'] = $ufGroupId;
             CRM_Core_BAO_UFJoin::create($ufJoinParams);
             unset($ufJoinParams['id']);
         }
     }
     // also update the ProfileModule tables
     $ufJoinParamsAdd = array('is_active' => 1, 'module' => 'CiviEvent_Additional', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
     // first delete all past entries
     CRM_Core_BAO_UFJoin::deleteAll($ufJoinParamsAdd);
     if (CRM_Utils_Array::value('is_multiple_registrations', $params)) {
         $ufAdd = array();
         $wtAdd = 2;
         if (array_key_exists('additional_custom_pre_id', $params)) {
             if (!CRM_Utils_Array::value('additional_custom_pre_id', $params)) {
                 $ufAdd[1] = $params['custom_pre_id'];
                 $wtAdd = 1;
             } elseif (CRM_Utils_Array::value('additional_custom_pre_id', $params) == 'none') {
             } else {
                 $ufAdd[1] = $params['additional_custom_pre_id'];
                 $wtAdd = 1;
             }
         }
         if (array_key_exists('additional_custom_post_id', $params)) {
             if (!CRM_Utils_Array::value('additional_custom_post_id', $params)) {
                 $ufAdd[2] = $params['custom_post_id'];
             } elseif (CRM_Utils_Array::value('additional_custom_post_id', $params) == 'none') {
             } else {
                 $ufAdd[2] = $params['additional_custom_post_id'];
             }
         }
         if (CRM_Utils_Array::value('additional_custom_post_id_multiple', $params)) {
             $additionalPostMultiple = array();
             foreach ($params['additional_custom_post_id_multiple'] as $key => $value) {
                 if (!$value && CRM_Utils_Array::value('custom_post_id', $params)) {
                     $additionalPostMultiple[$key] = $params['custom_post_id'];
                 } elseif ($value == 'none') {
                     continue;
                 } elseif ($value) {
                     $additionalPostMultiple[$key] = $value;
                 }
             }
             $ufAdd = array_merge($ufAdd, $additionalPostMultiple);
         }
         $ufAdd = array_values($ufAdd);
         if (!empty($ufAdd)) {
             foreach ($ufAdd as $weightAdd => $ufGroupIdAdd) {
                 $ufJoinParamsAdd['weight'] = $weightAdd + $wtAdd;
                 $ufJoinParamsAdd['uf_group_id'] = $ufGroupIdAdd;
                 CRM_Core_BAO_UFJoin::create($ufJoinParamsAdd);
                 unset($ufJoinParamsAdd['id']);
             }
         }
     }
     parent::endPostProcess();
 }
Example #18
0
 /**
  * Function to process the form
  *
  * @access public
  *
  * @return void
  */
 public function postProcess()
 {
     // get the submitted form values.
     $formValues = $this->controller->exportValues($this->_name);
     // let's unset event id
     unset($formValues['id']);
     $formValues['entity_table'] = 'civicrm_event';
     $formValues['entity_id'] = $this->_id;
     $formValues['title'] = $formValues['tf_title'];
     $formValues['is_active'] = CRM_Utils_Array::value('tf_is_active', $formValues, FALSE);
     $formValues['thankyou_title'] = CRM_Utils_Array::value('tf_thankyou_title', $formValues);
     $formValues['thankyou_text'] = CRM_Utils_Array::value('tf_thankyou_text', $formValues);
     if ($this->_action & CRM_Core_Action::UPDATE && $this->_friendId) {
         $formValues['id'] = $this->_friendId;
     }
     CRM_Friend_BAO_Friend::addTellAFriend($formValues);
     // Update tab "disabled" css class
     $this->ajaxResponse['tabValid'] = !empty($formValues['tf_is_active']);
     parent::endPostProcess();
 }
 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     //format params
     $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
     $params['end_date'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('end_date', $params), CRM_Utils_Array::value('end_date_time', $params), TRUE);
     $params['has_waitlist'] = CRM_Utils_Array::value('has_waitlist', $params, FALSE);
     $params['is_map'] = CRM_Utils_Array::value('is_map', $params, FALSE);
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     $params['is_public'] = CRM_Utils_Array::value('is_public', $params, FALSE);
     $params['is_share'] = CRM_Utils_Array::value('is_share', $params, FALSE);
     $params['default_role_id'] = CRM_Utils_Array::value('default_role_id', $params, FALSE);
     $params['id'] = $this->_id;
     $customFields = CRM_Core_BAO_CustomField::getFields('Event', FALSE, FALSE, CRM_Utils_Array::value('event_type_id', $params));
     $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_id, 'Event');
     //merge params with defaults from templates
     if (CRM_Utils_Array::value('template_id', $params)) {
         $params = array_merge(CRM_Event_BAO_Event::getTemplateDefaultValues($params['template_id']), $params);
     }
     $event = CRM_Event_BAO_Event::create($params);
     // now that we have the event’s id, do some more template-based stuff
     if (CRM_Utils_Array::value('template_id', $params)) {
         // copy price sets if any
         $priceSetId = CRM_Price_BAO_Set::getFor('civicrm_event', $params['template_id']);
         if ($priceSetId) {
             $isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $priceSetId, 'is_quick_config');
             if ($isQuickConfig) {
                 $copyPriceSet =& CRM_Price_BAO_Set::copy($priceSetId);
                 $priceSetId = $copyPriceSet->id;
             }
             CRM_Price_BAO_Set::addTo('civicrm_event', $event->id, $priceSetId);
         }
         // link profiles if none linked
         $ufParams = array('entity_table' => 'civicrm_event', 'entity_id' => $event->id);
         if (!CRM_Core_BAO_UFJoin::findUFGroupId($ufParams)) {
             CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin', array('entity_id' => $params['template_id'], 'entity_table' => 'civicrm_event'), array('entity_id' => $event->id));
         }
         // if no Tell-a-Friend defined, check whether there’s one for template and copy if so
         $tafParams = array('entity_table' => 'civicrm_event', 'entity_id' => $event->id);
         if (!CRM_Friend_BAO_Friend::getValues($tafParams)) {
             $tafParams['entity_id'] = $params['template_id'];
             if (CRM_Friend_BAO_Friend::getValues($tafParams)) {
                 $tafParams['entity_id'] = $event->id;
                 if (isset($tafParams['id'])) {
                     unset($tafParams['id']);
                 }
                 CRM_Friend_BAO_Friend::addTellAFriend($tafParams);
             }
         }
         //copy pcp settings
         CRM_Core_DAO::copyGeneric('CRM_PCP_DAO_PCPBlock', array('entity_id' => $params['template_id'], 'entity_table' => 'civicrm_event'), array('entity_id' => $event->id), array('replace' => array('target_entity_id' => $event->id)));
         //copy event schedule remainder
         CRM_Core_DAO::copyGeneric('CRM_Core_DAO_ActionSchedule', array('entity_value' => $params['template_id']), array('entity_value' => $event->id));
     }
     $this->set('id', $event->id);
     if ($this->_action & CRM_Core_Action::ADD) {
         $url = 'civicrm/event/manage/location';
         $urlParams = "action=update&reset=1&id={$event->id}";
         // special case for 'Save and Done' consistency.
         if ($this->controller->getButtonName('submit') == '_qf_EventInfo_upload_done') {
             $url = 'civicrm/event/manage';
             $urlParams = 'reset=1';
             CRM_Core_Session::setStatus(ts("'%1' information has been saved.", array(1 => $this->getTitle())));
         }
         CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams));
     }
     parent::endPostProcess();
 }
Example #20
0
 /**
  * @param CRM_Event_Form_ManageEvent $form
  *
  * @return array
  * @throws Exception
  */
 public static function process(&$form)
 {
     if ($form->getVar('_id') <= 0) {
         return NULL;
     }
     $default = array('link' => NULL, 'valid' => TRUE, 'active' => TRUE, 'current' => FALSE, 'class' => 'ajaxForm');
     $tabs = array();
     $tabs['settings'] = array('title' => ts('Info and Settings'), 'class' => 'ajaxForm livePage') + $default;
     $tabs['location'] = array('title' => ts('Event Location')) + $default;
     $tabs['fee'] = array('title' => ts('Fees')) + $default;
     $tabs['registration'] = array('title' => ts('Online Registration')) + $default;
     if (CRM_Core_Permission::check('administer CiviCRM') || CRM_Event_BAO_Event::checkPermission(NULL, CRM_Core_Permission::EDIT)) {
         $tabs['reminder'] = array('title' => ts('Schedule Reminders'), 'class' => 'livePage') + $default;
     }
     $tabs['conference'] = array('title' => ts('Conference Slots')) + $default;
     $tabs['friend'] = array('title' => ts('Tell a Friend')) + $default;
     $tabs['pcp'] = array('title' => ts('Personal Campaigns')) + $default;
     $tabs['repeat'] = array('title' => ts('Repeat')) + $default;
     // Repeat tab must refresh page when switching repeat mode so js & vars will get set-up
     if (!$form->_isRepeatingEvent) {
         unset($tabs['repeat']['class']);
     }
     // check if we're in shopping cart mode for events
     $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart');
     if (!$enableCart) {
         unset($tabs['conference']);
     }
     $eventID = $form->getVar('_id');
     if ($eventID) {
         // disable tabs based on their configuration status
         $sql = "\nSELECT     e.loc_block_id as is_location, e.is_online_registration, e.is_monetary, taf.is_active, pcp.is_active as is_pcp, sch.id as is_reminder, re.id as is_repeating_event\nFROM       civicrm_event e\nLEFT JOIN  civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id )\nLEFT JOIN  civicrm_pcp_block pcp   ON ( pcp.entity_table = 'civicrm_event' AND pcp.entity_id = e.id )\nLEFT JOIN  civicrm_action_mapping  map ON ( map.entity_value = 'civicrm_event' )\nLEFT JOIN  civicrm_action_schedule sch ON ( sch.mapping_id = map.id AND sch.entity_value = %1 )\nLEFT JOIN  civicrm_recurring_entity re ON ( e.id = re.entity_id AND re.entity_table = 'civicrm_event' )\nWHERE      e.id = %1\n";
         //Check if repeat is configured
         $eventHasParent = CRM_Core_BAO_RecurringEntity::getParentFor($eventID, 'civicrm_event');
         $params = array(1 => array($eventID, 'Integer'));
         $dao = CRM_Core_DAO::executeQuery($sql, $params);
         if (!$dao->fetch()) {
             CRM_Core_Error::fatal();
         }
         if (!$dao->is_location) {
             $tabs['location']['valid'] = FALSE;
         }
         if (!$dao->is_online_registration) {
             $tabs['registration']['valid'] = FALSE;
         }
         if (!$dao->is_monetary) {
             $tabs['fee']['valid'] = FALSE;
         }
         if (!$dao->is_active) {
             $tabs['friend']['valid'] = FALSE;
         }
         if (!$dao->is_pcp) {
             $tabs['pcp']['valid'] = FALSE;
         }
         if (!$dao->is_reminder) {
             $tabs['reminder']['valid'] = FALSE;
         }
         if (!$dao->is_repeating_event) {
             $tabs['repeat']['valid'] = FALSE;
         }
     }
     // see if any other modules want to add any tabs
     // note: status of 'valid' flag of any injected tab, needs to be taken care in the hook implementation.
     CRM_Utils_Hook::tabset('civicrm/event/manage', $tabs, array('event_id' => $eventID));
     $fullName = $form->getVar('_name');
     $className = CRM_Utils_String::getClassName($fullName);
     $new = '';
     // hack for special cases.
     switch ($className) {
         case 'Event':
             $attributes = $form->getVar('_attributes');
             $class = strtolower(basename(CRM_Utils_Array::value('action', $attributes)));
             break;
         case 'EventInfo':
             $class = 'settings';
             break;
         case 'ScheduleReminders':
             $class = 'reminder';
             break;
         default:
             $class = strtolower($className);
             break;
     }
     if (array_key_exists($class, $tabs)) {
         $tabs[$class]['current'] = TRUE;
         $qfKey = $form->get('qfKey');
         if ($qfKey) {
             $tabs[$class]['qfKey'] = "&qfKey={$qfKey}";
         }
     }
     if ($eventID) {
         $reset = !empty($_GET['reset']) ? 'reset=1&' : '';
         foreach ($tabs as $key => $value) {
             if (!isset($tabs[$key]['qfKey'])) {
                 $tabs[$key]['qfKey'] = NULL;
             }
             $action = 'update';
             if ($key == 'reminder') {
                 $action = 'browse';
             }
             $tabs[$key]['link'] = CRM_Utils_System::url("civicrm/event/manage/{$key}", "{$reset}action={$action}&id={$eventID}&component=event{$tabs[$key]['qfKey']}");
         }
     }
     return $tabs;
 }
Example #21
0
 /**
  * Process the form submission.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     // Source
     $params['entity_table'] = 'civicrm_event';
     $params['entity_id'] = $this->_id;
     // Target
     $params['target_entity_type'] = CRM_Utils_Array::value('target_entity_type', $params, 'event');
     if ($params['target_entity_type'] == 'event') {
         $params['target_entity_id'] = $this->_id;
     } else {
         $params['target_entity_id'] = CRM_Utils_Array::value('target_entity_id', $params, $this->_id);
     }
     $dao = new CRM_PCP_DAO_PCPBlock();
     $dao->entity_table = $params['entity_table'];
     $dao->entity_id = $this->_id;
     $dao->find(TRUE);
     $params['id'] = $dao->id;
     $params['is_active'] = CRM_Utils_Array::value('pcp_active', $params, FALSE);
     $params['is_approval_needed'] = CRM_Utils_Array::value('is_approval_needed', $params, FALSE);
     $params['is_tellfriend_enabled'] = CRM_Utils_Array::value('is_tellfriend_enabled', $params, FALSE);
     $dao = CRM_PCP_BAO_PCP::add($params);
     // Update tab "disabled" css class
     $this->ajaxResponse['tabValid'] = !empty($params['is_active']);
     parent::endPostProcess();
 }
Example #22
0
 /**
  * Process the form.
  */
 public function postProcess()
 {
     $eventTitle = '';
     $params = $this->exportValues();
     $this->set('discountSection', 0);
     if (!empty($_POST['_qf_Fee_submit'])) {
         $this->buildAmountLabel();
         $this->set('discountSection', 2);
         return;
     }
     if (!empty($params['payment_processor'])) {
         $params['payment_processor'] = str_replace(',', CRM_Core_DAO::VALUE_SEPARATOR, $params['payment_processor']);
     } else {
         $params['payment_processor'] = 'null';
     }
     $params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, 0);
     $params['is_billing_required'] = CRM_Utils_Array::value('is_billing_required', $params, 0);
     if ($this->_id) {
         // delete all the prior label values or discounts in the custom options table
         // and delete a price set if one exists
         //@todo note that this removes the reference from existing participants -
         // even where there is not change - redress?
         // note that a more tentative form of this is invoked by passing price_set_id as an array
         // to event.create see CRM-14069
         // @todo get all of this logic out of form layer (currently partially in BAO/api layer)
         if (CRM_Price_BAO_PriceSet::removeFrom('civicrm_event', $this->_id)) {
             CRM_Core_BAO_Discount::del($this->_id, 'civicrm_event');
         }
     }
     if ($params['is_monetary']) {
         if (!empty($params['price_set_id'])) {
             //@todo this is now being done in the event BAO if passed price_set_id as an array
             // per notes on that fn - looking at the api converting to an array
             // so calling via the api may cause this to be done in the api
             CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_id, $params['price_set_id']);
             if (!empty($params['price_field_id'])) {
                 $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $params['price_field_id'], 'price_set_id');
                 CRM_Price_BAO_PriceSet::setIsQuickConfig($priceSetID, 0);
             }
         } else {
             // if there are label / values, create custom options for them
             $labels = CRM_Utils_Array::value('label', $params);
             $values = CRM_Utils_Array::value('value', $params);
             $default = CRM_Utils_Array::value('default', $params);
             $options = array();
             if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
                 for ($i = 1; $i < self::NUM_OPTION; $i++) {
                     if (!empty($labels[$i]) && !CRM_Utils_System::isNull($values[$i])) {
                         $options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
                     }
                 }
                 if (!empty($options)) {
                     $params['default_fee_id'] = NULL;
                     if (empty($params['price_set_id'])) {
                         if (empty($params['price_field_id'])) {
                             $setParams['title'] = $eventTitle = $this->_isTemplate ? $this->_defaultValues['template_title'] : $this->_defaultValues['title'];
                             $eventTitle = strtolower(CRM_Utils_String::munge($eventTitle, '_', 245));
                             if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $eventTitle, 'id', 'name')) {
                                 $setParams['name'] = $eventTitle;
                             } elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $eventTitle . '_' . $this->_id, 'id', 'name')) {
                                 $setParams['name'] = $eventTitle . '_' . $this->_id;
                             } else {
                                 $timeSec = explode('.', microtime(TRUE));
                                 $setParams['name'] = $eventTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
                             }
                             $setParams['is_quick_config'] = 1;
                             $setParams['financial_type_id'] = $params['financial_type_id'];
                             $setParams['extends'] = CRM_Core_Component::getComponentID('CiviEvent');
                             $priceSet = CRM_Price_BAO_PriceSet::create($setParams);
                             $fieldParams['name'] = strtolower(CRM_Utils_String::munge($params['fee_label'], '_', 245));
                             $fieldParams['price_set_id'] = $priceSet->id;
                         } else {
                             foreach ($params['price_field_value'] as $arrayID => $fieldValueID) {
                                 if (empty($params['label'][$arrayID]) && empty($params['value'][$arrayID]) && !empty($fieldValueID)) {
                                     CRM_Price_BAO_PriceFieldValue::setIsActive($fieldValueID, '0');
                                     unset($params['price_field_value'][$arrayID]);
                                 }
                             }
                             $fieldParams['id'] = CRM_Utils_Array::value('price_field_id', $params);
                             $fieldParams['option_id'] = $params['price_field_value'];
                             $priceSet = new CRM_Price_BAO_PriceSet();
                             $priceSet->id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('price_field_id', $params), 'price_set_id');
                             if ($this->_defaultValues['financial_type_id'] != $params['financial_type_id']) {
                                 CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $priceSet->id, 'financial_type_id', $params['financial_type_id']);
                             }
                         }
                         $fieldParams['label'] = $params['fee_label'];
                         $fieldParams['html_type'] = 'Radio';
                         CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_id, $priceSet->id);
                         $fieldParams['option_label'] = $params['label'];
                         $fieldParams['option_amount'] = $params['value'];
                         $fieldParams['financial_type_id'] = $params['financial_type_id'];
                         foreach ($options as $value) {
                             $fieldParams['option_weight'][$value['weight']] = $value['weight'];
                         }
                         $fieldParams['default_option'] = $params['default'];
                         $priceField = CRM_Price_BAO_PriceField::create($fieldParams);
                     }
                 }
             }
             $discountPriceSets = !empty($this->_defaultValues['discount_price_set']) ? $this->_defaultValues['discount_price_set'] : array();
             $discountFieldIDs = !empty($this->_defaultValues['discount_option_id']) ? $this->_defaultValues['discount_option_id'] : array();
             if (CRM_Utils_Array::value('is_discount', $params) == 1) {
                 // if there are discounted set of label / values,
                 // create custom options for them
                 $labels = CRM_Utils_Array::value('discounted_label', $params);
                 $values = CRM_Utils_Array::value('discounted_value', $params);
                 $default = CRM_Utils_Array::value('discounted_default', $params);
                 if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
                     for ($j = 1; $j <= self::NUM_DISCOUNT; $j++) {
                         $discountOptions = array();
                         for ($i = 1; $i < self::NUM_OPTION; $i++) {
                             if (!empty($labels[$i]) && !CRM_Utils_System::isNull(CRM_Utils_Array::value($j, $values[$i]))) {
                                 $discountOptions[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i][$j])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
                             }
                         }
                         if (!empty($discountOptions)) {
                             $fieldParams = array();
                             $params['default_discount_fee_id'] = NULL;
                             $keyCheck = $j - 1;
                             $setParams = array();
                             if (empty($discountPriceSets[$keyCheck])) {
                                 if (!$eventTitle) {
                                     $eventTitle = strtolower(CRM_Utils_String::munge($this->_defaultValues['title'], '_', 200));
                                 }
                                 $setParams['title'] = $params['discount_name'][$j];
                                 if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $eventTitle . '_' . $params['discount_name'][$j], 'id', 'name')) {
                                     $setParams['name'] = $eventTitle . '_' . $params['discount_name'][$j];
                                 } elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $eventTitle . '_' . $params['discount_name'][$j] . '_' . $this->_id, 'id', 'name')) {
                                     $setParams['name'] = $eventTitle . '_' . $params['discount_name'][$j] . '_' . $this->_id;
                                 } else {
                                     $timeSec = explode('.', microtime(TRUE));
                                     $setParams['name'] = $eventTitle . '_' . $params['discount_name'][$j] . '_' . date('is', $timeSec[0]) . $timeSec[1];
                                 }
                                 $setParams['is_quick_config'] = 1;
                                 $setParams['financial_type_id'] = $params['financial_type_id'];
                                 $setParams['extends'] = CRM_Core_Component::getComponentID('CiviEvent');
                                 $priceSet = CRM_Price_BAO_PriceSet::create($setParams);
                                 $priceSetID = $priceSet->id;
                             } else {
                                 $priceSetID = $discountPriceSets[$j - 1];
                                 $setParams = array('title' => $params['discount_name'][$j], 'id' => $priceSetID);
                                 if ($this->_defaultValues['financial_type_id'] != $params['financial_type_id']) {
                                     $setParams['financial_type_id'] = $params['financial_type_id'];
                                 }
                                 CRM_Price_BAO_PriceSet::create($setParams);
                                 unset($discountPriceSets[$j - 1]);
                                 $fieldParams['id'] = CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceField', $priceSetID, 'id', 'price_set_id');
                             }
                             $fieldParams['name'] = $fieldParams['label'] = $params['fee_label'];
                             $fieldParams['is_required'] = 1;
                             $fieldParams['price_set_id'] = $priceSetID;
                             $fieldParams['html_type'] = 'Radio';
                             $fieldParams['financial_type_id'] = $params['financial_type_id'];
                             foreach ($discountOptions as $value) {
                                 $fieldParams['option_label'][$value['weight']] = $value['label'];
                                 $fieldParams['option_amount'][$value['weight']] = $value['value'];
                                 $fieldParams['option_weight'][$value['weight']] = $value['weight'];
                                 if (!empty($value['is_default'])) {
                                     $fieldParams['default_option'] = $value['weight'];
                                 }
                                 if (!empty($discountFieldIDs[$j]) && !empty($discountFieldIDs[$j][$value['weight']])) {
                                     $fieldParams['option_id'][$value['weight']] = $discountFieldIDs[$j][$value['weight']];
                                     unset($discountFieldIDs[$j][$value['weight']]);
                                 }
                             }
                             //create discount priceset
                             $priceField = CRM_Price_BAO_PriceField::create($fieldParams);
                             if (!empty($discountFieldIDs[$j])) {
                                 foreach ($discountFieldIDs[$j] as $fID) {
                                     CRM_Price_BAO_PriceFieldValue::setIsActive($fID, '0');
                                 }
                             }
                             $discountParams = array('entity_table' => 'civicrm_event', 'entity_id' => $this->_id, 'price_set_id' => $priceSetID, 'start_date' => CRM_Utils_Date::processDate($params['discount_start_date'][$j]), 'end_date' => CRM_Utils_Date::processDate($params['discount_end_date'][$j]));
                             CRM_Core_BAO_Discount::add($discountParams);
                         }
                     }
                 }
             }
             if (!empty($discountPriceSets)) {
                 foreach ($discountPriceSets as $setId) {
                     CRM_Price_BAO_PriceSet::setIsQuickConfig($setId, 0);
                 }
             }
         }
     } else {
         if (!empty($params['price_field_id'])) {
             $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $params['price_field_id'], 'price_set_id');
             CRM_Price_BAO_PriceSet::setIsQuickConfig($priceSetID, 0);
         }
         $params['financial_type_id'] = '';
         $params['is_pay_later'] = 0;
         $params['is_billing_required'] = 0;
     }
     //update 'is_billing_required'
     if (empty($params['is_pay_later'])) {
         $params['is_billing_required'] = FALSE;
     }
     //update events table
     $params['id'] = $this->_id;
     // skip update of financial type in price set
     $params['skipFinancialType'] = TRUE;
     CRM_Event_BAO_Event::add($params);
     // Update tab "disabled" css class
     $this->ajaxResponse['tabValid'] = !empty($params['is_monetary']);
     parent::endPostProcess();
 }
 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     $params = array();
     $params = $this->exportValues();
     $params['id'] = $this->_id;
     //format params
     $params['is_online_registration'] = CRM_Utils_Array::value('is_online_registration', $params, false);
     $params['is_multiple_registrations'] = CRM_Utils_Array::value('is_multiple_registrations', $params, false);
     $params['allow_same_participant_emails'] = CRM_Utils_Array::value('allow_same_participant_emails', $params, false);
     $params['requires_approval'] = CRM_Utils_Array::value('requires_approval', $params, false);
     // reset is_email confirm if not online reg
     if (!$params['is_online_registration']) {
         $params['is_email_confirm'] = false;
     }
     if (!$this->_isTemplate) {
         $params['registration_start_date'] = CRM_Utils_Date::processDate($params['registration_start_date'], $params['registration_start_date_time'], true);
         $params['registration_end_date'] = CRM_Utils_Date::processDate($params['registration_end_date'], $params['registration_end_date_time'], true);
     }
     require_once 'CRM/Event/BAO/Event.php';
     CRM_Event_BAO_Event::add($params);
     // also update the ProfileModule tables
     $ufJoinParams = array('is_active' => 1, 'module' => 'CiviEvent', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
     require_once 'CRM/Core/BAO/UFJoin.php';
     // first delete all past entries
     CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
     if (!empty($params['custom_pre_id'])) {
         $ufJoinParams['weight'] = 1;
         $ufJoinParams['uf_group_id'] = $params['custom_pre_id'];
         CRM_Core_BAO_UFJoin::create($ufJoinParams);
     }
     unset($ufJoinParams['id']);
     if (!empty($params['custom_post_id'])) {
         $ufJoinParams['weight'] = 2;
         $ufJoinParams['uf_group_id'] = $params['custom_post_id'];
         CRM_Core_BAO_UFJoin::create($ufJoinParams);
     }
     // CRM-4377: also update the profiles for additional participants
     $ufJoinParams['module'] = 'CiviEvent_Additional';
     $ufJoinParams['weight'] = 1;
     $ufJoinParams['uf_group_id'] = $params['custom_pre_id'];
     if ($params['additional_custom_pre_id'] == 'none') {
         $ufJoinParams['is_active'] = 0;
     } elseif ($params['additional_custom_pre_id']) {
         $ufJoinParams['uf_group_id'] = $params['additional_custom_pre_id'];
     }
     CRM_Core_BAO_UFJoin::create($ufJoinParams);
     $ufJoinParams['weight'] = 2;
     $ufJoinParams['uf_group_id'] = $params['custom_post_id'];
     if ($params['additional_custom_post_id'] == 'none') {
         $ufJoinParams['is_active'] = 0;
     } elseif ($params['additional_custom_post_id']) {
         //minor fix for CRM-4377
         $ufJoinParams['is_active'] = 1;
         $ufJoinParams['uf_group_id'] = $params['additional_custom_post_id'];
     }
     CRM_Core_BAO_UFJoin::create($ufJoinParams);
     parent::endPostProcess();
 }
Example #24
0
 public function postProcess()
 {
     if ($this->_id) {
         $params = $this->controller->exportValues($this->_name);
         if ($this->_parentEventStartDate && $this->_parentEventEndDate) {
             $interval = CRM_Core_BAO_RecurringEntity::getInterval($this->_parentEventStartDate, $this->_parentEventEndDate);
             $params['intervalDateColumns'] = array('end_date' => $interval);
         }
         $params['dateColumns'] = array('start_date');
         $params['excludeDateRangeColumns'] = array('start_date', 'end_date');
         $params['entity_table'] = 'civicrm_event';
         $params['entity_id'] = $this->_id;
         // CRM-16568 - check if parent exist for the event.
         $parentId = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event');
         $params['parent_entity_id'] = !empty($parentId) ? $parentId : $params['entity_id'];
         //Unset event id
         unset($params['id']);
         $url = 'civicrm/event/manage/repeat';
         $urlParams = "action=update&reset=1&id={$this->_id}";
         $linkedEntities = array(array('table' => 'civicrm_price_set_entity', 'findCriteria' => array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event'), 'linkedColumns' => array('entity_id'), 'isRecurringEntityRecord' => FALSE), array('table' => 'civicrm_uf_join', 'findCriteria' => array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event'), 'linkedColumns' => array('entity_id'), 'isRecurringEntityRecord' => FALSE), array('table' => 'civicrm_tell_friend', 'findCriteria' => array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event'), 'linkedColumns' => array('entity_id'), 'isRecurringEntityRecord' => TRUE), array('table' => 'civicrm_pcp_block', 'findCriteria' => array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event'), 'linkedColumns' => array('entity_id'), 'isRecurringEntityRecord' => TRUE));
         CRM_Core_Form_RecurringEntity::postProcess($params, 'civicrm_event', $linkedEntities);
         CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams));
     } else {
         CRM_Core_Error::fatal("Could not find Event ID");
     }
     parent::endPostProcess();
 }
 /**
  * Build the form object
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     if ($this->loadAngular) {
         $ang = new CRM_Volunteer_Page_Angular(null, null, CRM_Core_Resources::singleton());
         $ang->registerResources('ajax-snippet', false);
         CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.volunteer', 'js/CRM_Volunteer_Form_Volunteer.js', -1000, 'ajax-snippet');
         CRM_Core_Resources::singleton()->addStyleFile('org.civicrm.volunteer', 'css/volunteer_events.css');
         // Low weight, go before all the other Angular scripts. The trick is only needed in snippet mode.
         CRM_Core_Resources::singleton()->addScript("CRM.origJQuery = window.jQuery; window.jQuery = CRM.\$;", -1001, 'ajax-snippet');
         //High weight, go after all the other Angular scripts. The trick is only needed in snippet mode.
         CRM_Core_Resources::singleton()->addScript("window.jQuery = CRM.origJQuery; delete CRM.origJQuery", 1000, 'ajax-snippet');
     } else {
         parent::buildQuickForm();
     }
 }