/** * create a contribution page * * @param array $params (reference ) input parameters - need id and contribution_type_id * * @return array (reference ) contributionType id and other fields * @static void * @access public */ function &civicrm_payment_dodirectpayment( &$params ) { _civicrm_initialize( ); if( ! is_array($params) ) { return civicrm_create_error( 'Params need to be of type array!' ); } civicrm_verify_mandatory ($params,null,array ('mode', 'component')); $mode = CRM_Utils_Array::value( 'mode', $params ); $component = CRM_Utils_Array::value( 'component', $params ); // 'Contribute' unset($params['mode']); unset($params['component']); $paymentProcessor = $params['paymentProcessor']; unset($params['paymentProcessor']); $form = NULL; // todo add that in later $payment =& CRM_Core_Payment::singleton($mode, $paymentProcessor, $form); $result =& $payment->doDirectPayment( $params ); if(is_object($result) && get_class($result) == 'CRM_Core_Error') { return civicrm_create_error($result->_errors[0]['code']); } return $result; }
/** * Create a Event * * This API is used for creating a Event * * @param array $params (reference ) input parameters * Allowed @params array keys are: * {@schema Event/Event.xml} * * @return array of newly created event property values. * @access public */ function civicrm_event_create(&$params) { _civicrm_initialize(true); try { civicrm_api_check_permission(__FUNCTION__, $params, true); civicrm_verify_mandatory($params, 'CRM_Event_DAO_Event', array('start_date', 'event_type_id', 'title')); // Do we really want $params[id], even if we have // $params[event_id]? if yes then please uncomment the below line //$ids['event' ] = $params['id']; $ids['eventTypeId'] = (int) $params['event_type_id']; $ids['startDate'] = $params['start_date']; $ids['event_id'] = CRM_Utils_Array::value('event_id', $params); require_once 'CRM/Event/BAO/Event.php'; $eventBAO = CRM_Event_BAO_Event::create($params, $ids); if (is_a($eventBAO, 'CRM_Core_Error')) { return civicrm_create_error("Event is not created"); } else { $event = array(); _civicrm_object_to_array($eventBAO, $event); $values = array(); $values['event_id'] = $event['id']; $values['is_error'] = 0; } return $values; } catch (Exception $e) { return civicrm_create_error($e->getMessage()); } }
function civicrm_uf_misc_match_id_get($params) { civicrm_verify_mandatory ($params,null,array ('uf_id')); $ufID = CRM_Utils_Array::value( 'uf_id', $params ); return civicrm_uf_match_id_get($ufID); }
/** * create a contribution page * * @param array $params (reference ) input parameters - need id and contribution_type_id * * @return array (reference ) contributionType id and other fields * @static void * @access public */ function &civicrm_paymentprocessor_getpayment( &$params ) { _civicrm_initialize( ); if( ! is_array($params) ) { return civicrm_create_error( 'Params need to be of type array!' ); } civicrm_verify_mandatory ($params,null,array ('id', 'mode')); $id = CRM_Utils_Array::value( 'id', $params ); $mode = CRM_Utils_Array::value( 'mode', $params ); $paymentProcessor =& CRM_Core_BAO_PaymentProcessor::getPayment($id, $mode); return $paymentProcessor; }
/** * Deletes an existing Tag * * @param array $params * * @return boolean | error true if successfull, error otherwise * @access public */ function civicrm_tag_delete(&$params) { _civicrm_initialize(); $errorScope = CRM_Core_TemporaryErrorScope::useException(); try { civicrm_verify_mandatory($params, NULL, array('tag_id')); $tagID = CRM_Utils_Array::value('tag_id', $params); require_once 'CRM/Core/BAO/Tag.php'; return CRM_Core_BAO_Tag::del($tagID) ? civicrm_create_success() : civicrm_create_error(ts('Could not delete tag')); } catch (Exception $e) { if (CRM_Core_Error::$modeException) { throw $e; } return civicrm_create_error($e->getMessage()); } }
/** * Function to update relationship * * @param array $params Associative array of property name/value pairs to update the relationship * * @return array Array with relationship information * * @access public * */ function civicrm_relationship_update($params) { try { _civicrm_initialize(); $errorScope = CRM_Core_TemporaryErrorScope::useException(); /* * Erik Hommel, 5 Oct 2010 : fix for CRM-6895 * check if required field relationship_id is in the parms. As the * CRM_Contact_BAO_Relationship::getRelatonship throws up some issues * (CRM-6905) the relationship is retrieved with a direct query */ civicrm_verify_mandatory($params, 'CRM_Contact_DAO_Relationship', array('relationship_id')); $names = array('id', 'contact_id_a', 'contact_id_b', 'relationship_type_id', 'start_date', 'end_date', 'is_active', 'description', 'is_permission_a_b', 'is_permission_b_a', 'case_id'); $relationship_id = (int) $params['relationship_id']; $query = "SELECT * FROM civicrm_relationship WHERE id = {$relationship_id}"; $daoRelations = CRM_Core_DAO::executeQuery($query); while ($daoRelations->fetch()) { foreach ($names as $name) { $current_values[$name] = $daoRelations->{$name}; } } $params = array_merge($current_values, $params); $params['start_date'] = date("Ymd", strtotime($params['start_date'])); $params['end_date'] = date("Ymd", strtotime($params['end_date'])); return civicrm_relationship_create($params); } catch (PEAR_Exception $e) { return civicrm_create_error($e->getMessage()); } catch (Exception $e) { return civicrm_create_error($e->getMessage()); } }
function civicrm_pcp_search_owner(&$params) { if( ! is_array($params) ) { return civicrm_create_error( 'Params need to be of type array!' ); } civicrm_verify_mandatory ($params,null,array ('search')); require_once 'api/v2/Contact.php'; $search_term = CRM_Utils_Array::value( 'search', $params, TRUE ); $query = "SELECT DISTINCT(cc.id) as id, pcp.title, CONCAT_WS( ' :: ', display_name, sort_name, email, phone, street_address, city, ste.name, coy.name ) as data FROM civicrm_pcp pcp left join civicrm_contact cc on ( pcp.contact_id = cc.id ) LEFT JOIN civicrm_email eml ON ( cc.id = eml.contact_id AND eml.is_primary = 1 ) LEFT JOIN civicrm_phone phe ON ( cc.id = phe.contact_id AND phe.is_primary = 1 ) LEFT JOIN civicrm_address sts ON ( cc.id = sts.contact_id AND sts.is_primary = 1) LEFT JOIN civicrm_state_province ste ON ( sts.state_province_id = ste.id ) LEFT JOIN civicrm_country coy ON ( sts.country_id = coy.id ) WHERE pcp.title like '%" . mysql_real_escape_string($search_term) . "%' or sort_name LIKE '%" . mysql_real_escape_string($search_term) . "%' or display_name LIKE '%" . mysql_real_escape_string($search_term) . "%' ORDER BY sort_name"; $dao = CRM_Core_DAO::executeQuery( $query ); while ( $dao->fetch( ) ) { // we don't care about our very strange data string //$civi_matches[$dao->id] = $dao->data; $params = array( 'contact_id' => $dao->id ); $contact = civicrm_contact_get($params); $contact = array_pop($contact); $contact['pcp_title'] = $dao->title; $civi_matches[$dao->id] = $contact; } $results = array('Results' => $civi_matches); return $results; }