/** * 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']); }