/** * create a friend * * @param array $params (reference ) input parameters - need id and contribution_type_id * * @return (none) * @static void * @access public */ function &civicrm_friend_create( &$params ) { _civicrm_initialize( ); $values = array( ); require_once 'CRM/Contribute/BAO/ContributionType.php'; $ids = array( ); if ( CRM_Utils_Array::value( 'id', $params ) ) { } $friend = CRM_Friend_BAO_Friend::create( $params ); if ( is_a( $friend, 'CRM_Core_Error' ) ) { return civicrm_create_error( ts( 'Failed to create Friend' ) ); } _civicrm_object_to_array($friend, $friendArray); return array('message' => 'Friend Added'); }
/** * Process the form submission. * * * @return void */ public function postProcess() { // get the submitted form values. $formValues = $this->controller->exportValues($this->_name); $formValues['entity_id'] = $this->_entityId; $formValues['entity_table'] = $this->_entityTable; $formValues['source_contact_id'] = $this->_contactID; $formValues['is_test'] = $this->_action ? 1 : 0; $formValues['title'] = $this->_title; $formValues['campaign_id'] = $this->_campaignId; CRM_Friend_BAO_Friend::create($formValues); $this->assign('status', 'thankyou'); $defaults = array(); $defaults['entity_id'] = $this->_entityId; $defaults['entity_table'] = $this->_entityTable; CRM_Friend_BAO_Friend::getValues($defaults); if ($this->_entityTable == 'civicrm_pcp') { $defaults['thankyou_text'] = $defaults['thankyou_title'] = ts('Thank you for your support'); $defaults['thankyou_text'] = ts('Thanks for supporting this campaign by spreading the word to your friends.'); } elseif ($this->_entityTable == 'civicrm_contribution_page') { // If this is tell a friend after contributing, give donor link to create their own fundraising page if ($linkText = CRM_PCP_BAO_PCP::getPcpBlockStatus($defaults['entity_id'], $defaults['entity_table'])) { $linkTextUrl = CRM_Utils_System::url('civicrm/contribute/campaign', "action=add&reset=1&pageId={$defaults['entity_id']}&component=contribute", FALSE, NULL, TRUE, TRUE); $this->assign('linkTextUrl', $linkTextUrl); $this->assign('linkText', $linkText); } } elseif ($this->_entityTable == 'civicrm_event') { // If this is tell a friend after registering for an event, give donor link to create their own fundraising page require_once 'CRM/PCP/BAO/PCP.php'; if ($linkText = CRM_PCP_BAO_PCP::getPcpBlockStatus($defaults['entity_id'], $defaults['entity_table'])) { $linkTextUrl = CRM_Utils_System::url('civicrm/contribute/campaign', "action=add&reset=1&pageId={$defaults['entity_id']}&component=event", FALSE, NULL, TRUE, TRUE); $this->assign('linkTextUrl', $linkTextUrl); $this->assign('linkText', $linkText); } } CRM_Utils_System::setTitle($defaults['thankyou_title']); $this->assign('thankYouText', $defaults['thankyou_text']); }
/** * The function sets the deafult values of the form. * * @param array $defaults * (reference) the default values. * * @return booelan * whether anything was found */ public static function getValues(&$defaults) { if (empty($defaults)) { return NULL; } $friend = new CRM_Friend_BAO_Friend(); $friend->copyValues($defaults); $found = $friend->find(TRUE); CRM_Core_DAO::storeValues($friend, $defaults); return $found; }
/** * Function to actually build the form * * @return void * @access public */ public function buildQuickForm() { $this->assignToTemplate(); $productID = $this->get('productID'); $option = $this->get('option'); $membershipTypeID = $this->get('membershipTypeID'); $this->assign('receiptFromEmail', CRM_Utils_Array::value('receipt_from_email', $this->_values)); if ($productID) { CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, FALSE, $productID, $option); } if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_priceSetId, 'is_quick_config')) { $this->assign('lineItem', $this->_lineItem); } else { if (is_array($membershipTypeID)) { $membershipTypeID = current($membershipTypeID); } $this->assign('is_quick_config', 1); $this->_params['is_quick_config'] = 1; } $this->assign('priceSetID', $this->_priceSetId); $this->assign('useForMember', $this->get('useForMember')); $params = $this->_params; $honor_block_is_active = $this->get('honor_block_is_active'); if ($honor_block_is_active && (!empty($params["honor_first_name"]) && !empty($params["honor_last_name"]) || !empty($params["honor_email"]))) { $this->assign('honor_block_is_active', $honor_block_is_active); $this->assign('honor_block_title', CRM_Utils_Array::value('honor_block_title', $this->_values)); $prefix = CRM_Core_PseudoConstant::individualPrefix(); $honor = CRM_Core_PseudoConstant::honor(); $this->assign('honor_type', $honor[$params["honor_type_id"]]); $this->assign('honor_prefix', $params["honor_prefix_id"] ? $prefix[$params["honor_prefix_id"]] : ' '); $this->assign('honor_first_name', $params["honor_first_name"]); $this->assign('honor_last_name', $params["honor_last_name"]); $this->assign('honor_email', $params["honor_email"]); } $qParams = "reset=1&id={$this->_id}"; //pcp elements if ($this->_pcpId) { $qParams .= "&pcpId={$this->_pcpId}"; $this->assign('pcpBlock', TRUE); foreach (array('pcp_display_in_roll', 'pcp_is_anonymous', 'pcp_roll_nickname', 'pcp_personal_note') as $val) { if (CRM_Utils_Array::value($val, $this->_params)) { $this->assign($val, $this->_params[$val]); } } } $this->assign('qParams', $qParams); if ($membershipTypeID) { $transactionID = $this->get('membership_trx_id'); $membershipAmount = $this->get('membership_amount'); $renewalMode = $this->get('renewal_mode'); $this->assign('membership_trx_id', $transactionID); $this->assign('membership_amount', $membershipAmount); $this->assign('renewal_mode', $renewalMode); CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, FALSE, $membershipTypeID, TRUE, NULL, $this->_membershipContactID); } $this->_separateMembershipPayment = $this->get('separateMembershipPayment'); $this->assign("is_separate_payment", $this->_separateMembershipPayment); $this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE); $this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE); if (CRM_Utils_Array::value('hidden_onbehalf_profile', $params)) { $ufJoinParams = array('module' => 'onBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id); $OnBehalfProfile = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams); $profileId = $OnBehalfProfile[0]; $fieldTypes = array('Contact', 'Organization'); $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization'); $fieldTypes = array_merge($fieldTypes, $contactSubType); if (is_array($this->_membershipBlock) && !empty($this->_membershipBlock)) { $fieldTypes = array_merge($fieldTypes, array('Membership')); } else { $fieldTypes = array_merge($fieldTypes, array('Contribution')); } $this->buildCustom($profileId, 'onbehalfProfile', TRUE, TRUE, $fieldTypes); } $this->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $this->_params)); $this->assign('receive_date', CRM_Utils_Date::mysqlToIso(CRM_Utils_Array::value('receive_date', $this->_params))); $defaults = array(); $options = array(); $fields = array(); $removeCustomFieldTypes = array('Contribution'); foreach ($this->_fields as $name => $dontCare) { if ($name == 'onbehalf') { foreach ($dontCare as $key => $value) { $fields['onbehalf'][$key] = 1; } } else { $fields[$name] = 1; } } $fields['state_province'] = $fields['country'] = $fields['email'] = 1; $contact = $this->_params = $this->controller->exportValues('Main'); foreach ($fields as $name => $dontCare) { if ($name == 'onbehalf') { foreach ($dontCare as $key => $value) { //$defaults[$key] = $contact['onbehalf'][$key]; if (isset($contact['onbehalf'][$key])) { $defaults[$key] = $contact['onbehalf'][$key]; } if (isset($contact['onbehalf']["{$key}_id"])) { $defaults["{$key}_id"] = $contact['onbehalf']["{$key}_id"]; } } } elseif (isset($contact[$name])) { $defaults[$name] = $contact[$name]; if (substr($name, 0, 7) == 'custom_') { $timeField = "{$name}_time"; if (isset($contact[$timeField])) { $defaults[$timeField] = $contact[$timeField]; } } elseif (in_array($name, array('addressee', 'email_greeting', 'postal_greeting')) && CRM_Utils_Array::value($name . '_custom', $contact)) { $defaults[$name . '_custom'] = $contact[$name . '_custom']; } } } // now fix all state country selectors CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults); $this->_submitValues = array_merge($this->_submitValues, $defaults); $this->setDefaults($defaults); $values['entity_id'] = $this->_id; $values['entity_table'] = 'civicrm_contribution_page'; CRM_Friend_BAO_Friend::retrieve($values, $data); $tellAFriend = FALSE; if ($this->_pcpId) { if ($this->_pcpBlock['is_tellfriend_enabled']) { $this->assign('friendText', ts('Tell a Friend')); $subUrl = "eid={$this->_pcpId}&blockId={$this->_pcpBlock['id']}&pcomponent=pcp"; $tellAFriend = TRUE; } } elseif (CRM_Utils_Array::value('is_active', $data)) { $friendText = $data['title']; $this->assign('friendText', $friendText); $subUrl = "eid={$this->_id}&pcomponent=contribute"; $tellAFriend = TRUE; } if ($tellAFriend) { if ($this->_action & CRM_Core_Action::PREVIEW) { $url = CRM_Utils_System::url("civicrm/friend", "reset=1&action=preview&{$subUrl}"); } else { $url = CRM_Utils_System::url("civicrm/friend", "reset=1&{$subUrl}"); } $this->assign('friendURL', $url); } $this->freeze(); // can we blow away the session now to prevent hackery // CRM-9491 $this->controller->reset(); }
/** * Function to process the form * * @access public * @return None */ public function postProcess() { // get the submitted form values. $formValues = $this->controller->exportValues($this->_name); $formValues['entity_table'] = 'civicrm_contribution_page'; $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); }
/** * Function to build the form * * @return void * @access public */ public function buildQuickForm() { // Assign the email address from a contact id lookup as in CRM_Event_BAO_Event->sendMail() $primaryContactId = $this->get('primaryContactId'); if ($primaryContactId) { list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($primaryContactId); $this->assign('email', $email); } $this->assignToTemplate(); if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) { $lineItemForTemplate = array(); foreach ($this->_lineItem as $key => $value) { if (!empty($value)) { $lineItemForTemplate[$key] = $value; } } if (!empty($lineItemForTemplate)) { $this->assign('lineItem', $lineItemForTemplate); } } $this->assign('totalAmount', $this->_totalAmount); $hookDiscount = $this->get('hookDiscount'); if ($hookDiscount) { $this->assign('hookDiscount', $hookDiscount); } $this->assign('receive_date', $this->_receiveDate); $this->assign('trxn_id', $this->_trxnId); //cosider total amount. $this->assign('isAmountzero', $this->_totalAmount <= 0 ? TRUE : FALSE); $this->assign('defaultRole', FALSE); if (CRM_Utils_Array::value('defaultRole', $this->_params[0]) == 1) { $this->assign('defaultRole', TRUE); } $defaults = array(); $fields = array(); if (!empty($this->_fields)) { foreach ($this->_fields as $name => $dontCare) { $fields[$name] = 1; } } $fields['state_province'] = $fields['country'] = $fields['email'] = 1; foreach ($fields as $name => $dontCare) { if (isset($this->_params[0][$name])) { $defaults[$name] = $this->_params[0][$name]; if (substr($name, 0, 7) == 'custom_') { $timeField = "{$name}_time"; if (isset($this->_params[0][$timeField])) { $defaults[$timeField] = $this->_params[0][$timeField]; } } elseif (in_array($name, CRM_Contact_BAO_Contact::$_greetingTypes) && !empty($this->_params[0][$name . '_custom'])) { $defaults[$name . '_custom'] = $this->_params[0][$name . '_custom']; } } } $this->_submitValues = array_merge($this->_submitValues, $defaults); $this->setDefaults($defaults); $params['entity_id'] = $this->_eventId; $params['entity_table'] = 'civicrm_event'; $data = array(); CRM_Friend_BAO_Friend::retrieve($params, $data); if (!empty($data['is_active'])) { $friendText = $data['title']; $this->assign('friendText', $friendText); if ($this->_action & CRM_Core_Action::PREVIEW) { $url = CRM_Utils_System::url('civicrm/friend', "eid={$this->_eventId}&reset=1&action=preview&pcomponent=event"); } else { $url = CRM_Utils_System::url('civicrm/friend', "eid={$this->_eventId}&reset=1&pcomponent=event"); } $this->assign('friendURL', $url); } $this->freeze(); //lets give meaningful status message, CRM-4320. $isOnWaitlist = $isRequireApproval = FALSE; if ($this->_allowWaitlist && !$this->_allowConfirmation) { $isOnWaitlist = TRUE; } if ($this->_requireApproval && !$this->_allowConfirmation) { $isRequireApproval = TRUE; } $this->assign('isOnWaitlist', $isOnWaitlist); $this->assign('isRequireApproval', $isRequireApproval); // find pcp info $dao = new CRM_PCP_DAO_PCPBlock(); $dao->entity_table = 'civicrm_event'; $dao->entity_id = $this->_eventId; $dao->is_active = 1; $dao->find(TRUE); if ($dao->id) { $this->assign('pcpLink', CRM_Utils_System::url('civicrm/contribute/campaign', 'action=add&reset=1&pageId=' . $this->_eventId . '&component=event')); $this->assign('pcpLinkText', $dao->link_text); } // Assign Participant Count to Lineitem Table $this->assign('pricesetFieldsCount', CRM_Price_BAO_PriceSet::getPricesetCount($this->_priceSetId)); // can we blow away the session now to prevent hackery $this->controller->reset(); }
/** * Browse all events. * * @return void */ public function browse() { Civi::resources()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header'); $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this); $createdId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, 0); if (strtolower($this->_sortByCharacter) == 'all' || !empty($_POST)) { $this->_sortByCharacter = ''; $this->set('sortByCharacter', ''); } $this->_force = $this->_searchResult = NULL; $this->search(); $params = array(); $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE); $this->_searchResult = CRM_Utils_Request::retrieve('searchResult', 'Boolean', $this); $whereClause = $this->whereClause($params, FALSE, $this->_force); $this->pagerAToZ($whereClause, $params); $params = array(); $whereClause = $this->whereClause($params, TRUE, $this->_force); // because is_template != 1 would be to simple $whereClause .= ' AND (is_template = 0 OR is_template IS NULL)'; $this->pager($whereClause, $params); list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount(); // get all custom groups sorted by weight $manageEvent = array(); $query = "\n SELECT *\n FROM civicrm_event\n WHERE {$whereClause}\nORDER BY start_date desc\n LIMIT {$offset}, {$rowCount}"; $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Event_DAO_Event'); $permissions = CRM_Event_BAO_Event::checkPermission(); //get all campaigns. $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE); // get the list of active event pcps $eventPCPS = array(); $pcpDao = new CRM_PCP_DAO_PCPBlock(); $pcpDao->entity_table = 'civicrm_event'; $pcpDao->find(); while ($pcpDao->fetch()) { $eventPCPS[$pcpDao->entity_id] = $pcpDao->entity_id; } // 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'); $this->assign('eventCartEnabled', $enableCart); $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID))); $eventType = CRM_Core_OptionGroup::values('event_type'); while ($dao->fetch()) { if (in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])) { $manageEvent[$dao->id] = array(); $repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($dao->id, 'civicrm_event'); $manageEvent[$dao->id]['repeat'] = ''; if ($repeat) { $manageEvent[$dao->id]['repeat'] = ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])); } CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]); // form all action links $action = array_sum(array_keys($this->links())); if ($dao->is_active) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } if (!in_array($dao->id, $permissions[CRM_Core_Permission::DELETE])) { $action -= CRM_Core_Action::DELETE; } if (!in_array($dao->id, $permissions[CRM_Core_Permission::EDIT])) { $action -= CRM_Core_Action::UPDATE; } $manageEvent[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), TRUE, 'event.manage.list', 'Event', $dao->id); $params = array('entity_id' => $dao->id, 'entity_table' => 'civicrm_event', 'is_active' => 1); $defaults['location'] = CRM_Core_BAO_Location::getValues($params, TRUE); $manageEvent[$dao->id]['friend'] = CRM_Friend_BAO_Friend::getValues($params); if (isset($defaults['location']['address'][1]['city'])) { $manageEvent[$dao->id]['city'] = $defaults['location']['address'][1]['city']; } if (isset($defaults['location']['address'][1]['state_province_id'])) { $manageEvent[$dao->id]['state_province'] = CRM_Core_PseudoConstant::stateProvince($defaults['location']['address'][1]['state_province_id']); } //show campaigns on selector. $manageEvent[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns); $manageEvent[$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, $mapping->getId()); $manageEvent[$dao->id]['is_pcp_enabled'] = CRM_Utils_Array::value($dao->id, $eventPCPS); $manageEvent[$dao->id]['event_type'] = CRM_Utils_Array::value($manageEvent[$dao->id]['event_type_id'], $eventType); $manageEvent[$dao->id]['is_repeating_event'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_RecurringEntity', $dao->id, 'parent_id', 'entity_id'); // allow hooks to set 'field' value which allows configuration pop-up to show a tab as enabled/disabled CRM_Utils_Hook::tabset('civicrm/event/manage/rows', $manageEvent, array('event_id' => $dao->id)); } } $manageEvent['tab'] = self::tabs($enableCart); $this->assign('rows', $manageEvent); $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1'); $statusTypesPending = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0'); $findParticipants['statusCounted'] = implode(', ', array_values($statusTypes)); $findParticipants['statusNotCounted'] = implode(', ', array_values($statusTypesPending)); $this->assign('findParticipants', $findParticipants); }
/** * 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(); }
/** * Build the form object. * * @return void */ public function buildQuickForm() { $this->assignToTemplate(); $productID = $this->get('productID'); $option = $this->get('option'); $membershipTypeID = $this->get('membershipTypeID'); $this->assign('receiptFromEmail', CRM_Utils_Array::value('receipt_from_email', $this->_values)); if ($productID) { CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, FALSE, $productID, $option); } if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) { $this->assign('lineItem', $this->_lineItem); } else { if (is_array($membershipTypeID)) { $membershipTypeID = current($membershipTypeID); } $this->assign('is_quick_config', 1); $this->_params['is_quick_config'] = 1; } $this->assign('priceSetID', $this->_priceSetId); $this->assign('useForMember', $this->get('useForMember')); $params = $this->_params; $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); if ($invoicing) { $getTaxDetails = FALSE; $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings); foreach ($this->_lineItem as $key => $value) { foreach ($value as $v) { if (isset($v['tax_rate'])) { if ($v['tax_rate'] != '') { $getTaxDetails = TRUE; } } } } $this->assign('getTaxDetails', $getTaxDetails); $this->assign('taxTerm', $taxTerm); $this->assign('totalTaxAmount', $params['tax_amount']); } if ($this->_honor_block_is_active && !empty($params['soft_credit_type_id'])) { $honorName = NULL; $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE); $this->assign('honor_block_is_active', $this->_honor_block_is_active); $this->assign('soft_credit_type', $softCreditTypes[$params['soft_credit_type_id']]); CRM_Contribute_BAO_ContributionSoft::formatHonoreeProfileFields($this, $params['honor'], $params['honoree_profile_id']); $fieldTypes = array('Contact'); $fieldTypes[] = CRM_Core_BAO_UFGroup::getContactType($params['honoree_profile_id']); $this->buildCustom($params['honoree_profile_id'], 'honoreeProfileFields', TRUE, 'honor', $fieldTypes); } $qParams = "reset=1&id={$this->_id}"; //pcp elements if ($this->_pcpId) { $qParams .= "&pcpId={$this->_pcpId}"; $this->assign('pcpBlock', TRUE); foreach (array('pcp_display_in_roll', 'pcp_is_anonymous', 'pcp_roll_nickname', 'pcp_personal_note') as $val) { if (!empty($this->_params[$val])) { $this->assign($val, $this->_params[$val]); } } } $this->assign('qParams', $qParams); if ($membershipTypeID) { $transactionID = $this->get('membership_trx_id'); $membershipAmount = $this->get('membership_amount'); $renewalMode = $this->get('renewal_mode'); $this->assign('membership_trx_id', $transactionID); $this->assign('membership_amount', $membershipAmount); $this->assign('renewal_mode', $renewalMode); $this->buildMembershipBlock($this->_membershipContactID, FALSE, $membershipTypeID, TRUE, NULL); if (!empty($params['auto_renew'])) { $this->assign('auto_renew', TRUE); } } $this->_separateMembershipPayment = $this->get('separateMembershipPayment'); $this->assign("is_separate_payment", $this->_separateMembershipPayment); $this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE); $this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE); if (!empty($params['hidden_onbehalf_profile'])) { $ufJoinParams = array('module' => 'onBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id); $OnBehalfProfile = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams); $profileId = $OnBehalfProfile[0]; $fieldTypes = array('Contact', 'Organization'); $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization'); $fieldTypes = array_merge($fieldTypes, $contactSubType); if (is_array($this->_membershipBlock) && !empty($this->_membershipBlock)) { $fieldTypes = array_merge($fieldTypes, array('Membership')); } else { $fieldTypes = array_merge($fieldTypes, array('Contribution')); } $this->buildCustom($profileId, 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes); } $this->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $this->_params)); $this->assign('receive_date', CRM_Utils_Date::mysqlToIso(CRM_Utils_Array::value('receive_date', $this->_params))); $defaults = array(); $fields = array(); foreach ($this->_fields as $name => $dontCare) { if ($name != 'onbehalf' || $name != 'honor') { $fields[$name] = 1; } } $fields['state_province'] = $fields['country'] = $fields['email'] = 1; $contact = $this->_params = $this->controller->exportValues('Main'); foreach ($fields as $name => $dontCare) { if (isset($contact[$name])) { $defaults[$name] = $contact[$name]; if (substr($name, 0, 7) == 'custom_') { $timeField = "{$name}_time"; if (isset($contact[$timeField])) { $defaults[$timeField] = $contact[$timeField]; } } elseif (in_array($name, array('addressee', 'email_greeting', 'postal_greeting')) && !empty($contact[$name . '_custom'])) { $defaults[$name . '_custom'] = $contact[$name . '_custom']; } } } $this->_submitValues = array_merge($this->_submitValues, $defaults); $this->setDefaults($defaults); $values['entity_id'] = $this->_id; $values['entity_table'] = 'civicrm_contribution_page'; CRM_Friend_BAO_Friend::retrieve($values, $data); $tellAFriend = FALSE; if ($this->_pcpId) { if ($this->_pcpBlock['is_tellfriend_enabled']) { $this->assign('friendText', ts('Tell a Friend')); $subUrl = "eid={$this->_pcpId}&blockId={$this->_pcpBlock['id']}&pcomponent=pcp"; $tellAFriend = TRUE; } } elseif (!empty($data['is_active'])) { $friendText = $data['title']; $this->assign('friendText', $friendText); $subUrl = "eid={$this->_id}&pcomponent=contribute"; $tellAFriend = TRUE; } if ($tellAFriend) { if ($this->_action & CRM_Core_Action::PREVIEW) { $url = CRM_Utils_System::url("civicrm/friend", "reset=1&action=preview&{$subUrl}"); } else { $url = CRM_Utils_System::url("civicrm/friend", "reset=1&{$subUrl}"); } $this->assign('friendURL', $url); } $this->freeze(); // can we blow away the session now to prevent hackery // CRM-9491 $this->controller->reset(); }
/** * Function to actually build the form * * @return void * @access public */ public function buildQuickForm() { $this->assignToTemplate(); $productID = $this->get('productID'); $option = $this->get('option'); $membershipTypeID = $this->get('membershipTypeID'); $this->assign('receiptFromEmail', CRM_Utils_Array::value('receipt_from_email', $this->_values)); if ($productID) { require_once 'CRM/Contribute/BAO/Premium.php'; CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, false, $productID, $option); } $this->assign('lineItem', $this->_lineItem); $this->assign('priceSetID', $this->_priceSetId); $params = $this->_params; $honor_block_is_active = $this->get('honor_block_is_active'); if ($honor_block_is_active && (!empty($params["honor_first_name"]) && !empty($params["honor_last_name"]) || !empty($params["honor_email"]))) { $this->assign('honor_block_is_active', $honor_block_is_active); $this->assign('honor_block_title', CRM_Utils_Array::value('honor_block_title', $this->_values)); require_once "CRM/Core/PseudoConstant.php"; $prefix = CRM_Core_PseudoConstant::individualPrefix(); $honor = CRM_Core_PseudoConstant::honor(); $this->assign('honor_type', $honor[$params["honor_type_id"]]); $this->assign('honor_prefix', $params["honor_prefix_id"] ? $prefix[$params["honor_prefix_id"]] : ' '); $this->assign('honor_first_name', $params["honor_first_name"]); $this->assign('honor_last_name', $params["honor_last_name"]); $this->assign('honor_email', $params["honor_email"]); } //pcp elements if ($this->_pcpId) { $this->assign('pcpBlock', true); foreach (array('pcp_display_in_roll', 'pcp_is_anonymous', 'pcp_roll_nickname', 'pcp_personal_note') as $val) { if (CRM_Utils_Array::value($val, $this->_params)) { $this->assign($val, $this->_params[$val]); } } } if ($membershipTypeID) { $transactionID = $this->get('membership_trx_id'); $membershipAmount = $this->get('membership_amount'); $renewalMode = $this->get('renewal_mode'); $this->assign('membership_trx_id', $transactionID); $this->assign('membership_amount', $membershipAmount); $this->assign('renewal_mode', $renewalMode); CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, false, $membershipTypeID, true, null, $this->_membershipContactID); } $this->_separateMembershipPayment = $this->get('separateMembershipPayment'); $this->assign("is_separate_payment", $this->_separateMembershipPayment); $this->buildCustom($this->_values['custom_pre_id'], 'customPre', true); $this->buildCustom($this->_values['custom_post_id'], 'customPost', true); $this->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $this->_params)); $this->assign('receive_date', CRM_Utils_Date::mysqlToIso(CRM_Utils_Array::value('receive_date', $this->_params))); $defaults = array(); $options = array(); $fields = array(); require_once "CRM/Core/BAO/CustomGroup.php"; $removeCustomFieldTypes = array('Contribution'); foreach ($this->_fields as $name => $dontCare) { $fields[$name] = 1; } $fields['state_province'] = $fields['country'] = $fields['email'] = 1; $contact = $this->_params = $this->controller->exportValues('Main'); foreach ($fields as $name => $dontCare) { if (isset($contact[$name])) { $defaults[$name] = $contact[$name]; if (substr($name, 0, 7) == 'custom_') { $timeField = "{$name}_time"; if (isset($contact[$timeField])) { $defaults[$timeField] = $contact[$timeField]; } } else { if (in_array($name, array('addressee', 'email_greeting', 'postal_greeting')) && CRM_Utils_Array::value($name . '_custom', $contact)) { $defaults[$name . '_custom'] = $contact[$name . '_custom']; } } } } $this->_submitValues = array_merge($this->_submitValues, $defaults); $this->setDefaults($defaults); require_once 'CRM/Friend/BAO/Friend.php'; $values['entity_id'] = $this->_id; $values['entity_table'] = 'civicrm_contribution_page'; CRM_Friend_BAO_Friend::retrieve($values, $data); $tellAFriend = false; if ($this->_pcpId) { if ($this->_pcpBlock['is_tellfriend_enabled']) { $this->assign('friendText', ts('Tell a Friend')); $subUrl = "eid={$this->_pcpId}&blockId={$this->_pcpBlock['id']}&page=pcp"; $tellAFriend = true; } } else { if (CRM_Utils_Array::value('is_active', $data)) { $friendText = $data['title']; $this->assign('friendText', $friendText); $subUrl = "eid={$this->_id}&page=contribution"; $tellAFriend = true; } } if ($tellAFriend) { if ($this->_action & CRM_Core_Action::PREVIEW) { $url = CRM_Utils_System::url("civicrm/friend", "reset=1&action=preview&{$subUrl}"); } else { $url = CRM_Utils_System::url("civicrm/friend", "reset=1&{$subUrl}"); } $this->assign('friendURL', $url); } $this->freeze(); // can we blow away the session now to prevent hackery }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { $this->assignToTemplate(); $this->buildCustom($this->_values['custom_pre_id'], 'customPre', true); $this->buildCustom($this->_values['custom_post_id'], 'customPost', true); $this->assign('lineItem', $this->_lineItem); $this->assign('totalAmount', $this->_totalAmount); $hookDiscount = $this->get('hookDiscount'); if ($hookDiscount) { $this->assign('hookDiscount', $hookDiscount); } $this->assign('receive_date', $this->_receiveDate); $this->assign('trxn_id', $this->_trxnId); if (CRM_Utils_Array::value('amount', $this->_params[0]) == 0) { $this->assign('isAmountzero', 1); } $this->assign('defaultRole', false); if (CRM_Utils_Array::value('defaultRole', $this->_params[0]) == 1) { $this->assign('defaultRole', true); } $defaults = array(); $fields = array(); if (!empty($this->_fields)) { foreach ($this->_fields as $name => $dontCare) { $fields[$name] = 1; } } $fields['state_province'] = $fields['country'] = $fields['email'] = 1; foreach ($fields as $name => $dontCare) { if (isset($this->_params[0][$name])) { $defaults[$name] = $this->_params[0][$name]; if (in_array($name, array('addressee', 'email_greeting', 'postal_greeting')) && CRM_Utils_Array::value($name . '_custom', $this->_params[0])) { $defaults[$name . '_custom'] = $this->_params[0][$name . '_custom']; } } } $this->setDefaults($defaults); require_once 'CRM/Friend/BAO/Friend.php'; $params['entity_id'] = $this->_eventId; $params['entity_table'] = 'civicrm_event'; CRM_Friend_BAO_Friend::retrieve($params, $data); if (CRM_Utils_Array::value('is_active', $data)) { $friendText = $data['title']; $this->assign('friendText', $friendText); if ($this->_action & CRM_Core_Action::PREVIEW) { $url = CRM_Utils_System::url("civicrm/friend", "eid={$this->_eventId}&reset=1&action=preview&page=event"); } else { $url = CRM_Utils_System::url("civicrm/friend", "eid={$this->_eventId}&reset=1&page=event"); } $this->assign('friendURL', $url); } $this->freeze(); //lets give meaningful status message, CRM-4320. $isOnWaitlist = $isRequireApproval = false; if ($this->_allowWaitlist && !$this->_allowConfirmation) { $isOnWaitlist = true; } if ($this->_requireApproval && !$this->_allowConfirmation) { $isRequireApproval = true; } $this->assign('isOnWaitlist', $isOnWaitlist); $this->assign('isRequireApproval', $isRequireApproval); // can we blow away the session now to prevent hackery $this->controller->reset(); }
/** * 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(); }
/** * browse all events * * @return void */ function browse() { $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this); $createdId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false, 0); if ($this->_sortByCharacter == 1 || !empty($_POST)) { $this->_sortByCharacter = ''; $this->set('sortByCharacter', ''); } $this->_force = $this->_searchResult = null; $this->search(); $config = CRM_Core_Config::singleton(); $params = array(); $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, false); $this->_searchResult = CRM_Utils_Request::retrieve('searchResult', 'Boolean', $this); $whereClause = $this->whereClause($params, false, $this->_force); $this->pagerAToZ($whereClause, $params); $params = array(); $whereClause = $this->whereClause($params, true, $this->_force); $whereClause .= ' AND (is_template = 0 OR is_template IS NULL)'; // because is_template != 1 would be to simple $this->pager($whereClause, $params); list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount(); // get all custom groups sorted by weight $manageEvent = array(); $query = "\n SELECT *\n FROM civicrm_event\n WHERE {$whereClause}\nORDER BY start_date desc\n LIMIT {$offset}, {$rowCount}"; $dao = CRM_Core_DAO::executeQuery($query, $params, true, 'CRM_Event_DAO_Event'); $permissions = CRM_Event_BAO_Event::checkPermission(); while ($dao->fetch()) { if (in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])) { $manageEvent[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]); // form all action links $action = array_sum(array_keys($this->links())); if ($dao->is_active) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } if (!in_array($dao->id, $permissions[CRM_Core_Permission::DELETE])) { $action -= CRM_Core_Action::DELETE; } if (!in_array($dao->id, $permissions[CRM_Core_Permission::EDIT])) { $action -= CRM_Core_Action::UPDATE; } $manageEvent[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), true); $params = array('entity_id' => $dao->id, 'entity_table' => 'civicrm_event', 'is_active' => 1); require_once 'CRM/Core/BAO/Location.php'; $defaults['location'] = CRM_Core_BAO_Location::getValues($params, true); require_once 'CRM/Friend/BAO/Friend.php'; $manageEvent[$dao->id]['friend'] = CRM_Friend_BAO_Friend::getValues($params); if (isset($defaults['location']['address'][1]['city'])) { $manageEvent[$dao->id]['city'] = $defaults['location']['address'][1]['city']; } if (isset($defaults['location']['address'][1]['state_province_id'])) { $manageEvent[$dao->id]['state_province'] = CRM_Core_PseudoConstant::stateProvince($defaults['location']['address'][1]['state_province_id']); } } } $this->assign('rows', $manageEvent); require_once 'CRM/Event/PseudoConstant.php'; $statusTypes = CRM_Event_PseudoConstant::participantStatus(null, 'is_counted = 1'); $statusTypesPending = CRM_Event_PseudoConstant::participantStatus(null, 'is_counted = 0'); $findParticipants['statusCounted'] = implode(', ', array_values($statusTypes)); $findParticipants['statusNotCounted'] = implode(', ', array_values($statusTypesPending)); $this->assign('findParticipants', $findParticipants); }
/** * 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(); }