/** * Create Note * * This API is used for creating a note. * Required parameters : entity_id AND note * * @param array $params an associative array of name/value property values of civicrm_note * * @return array note id if note is created otherwise is_error = 1 * @access public */ function &civicrm_note_create(&$params) { _civicrm_initialize(); if (!is_array($params)) { return civicrm_create_error('Params is not an array'); } if (!CRM_Utils_Array::value('id', $params)) { if (!isset($params['entity_table']) || !isset($params['entity_id']) || !isset($params['note']) || !isset($params['contact_id'])) { return civicrm_create_error('Required parameter missing'); } } else { if (!isset($params['id']) && !isset($params['contact_id'])) { return civicrm_create_error('Required parameter missing'); } } $contactID = CRM_Utils_Array::value('contact_id', $params); if (!isset($params['modified_date'])) { $params['modified_date'] = date("Ymd"); } $ids = array(); $ids = array('id' => CRM_Utils_Array::value('id', $params)); $noteBAO = CRM_Core_BAO_Note::add($params, $ids); if (is_a($noteBAO, 'CRM_Core_Error')) { $error = civicrm_create_error("Note could not be created"); return $error; } else { $note = array(); _civicrm_object_to_array($noteBAO, $note); $note['is_error'] = 0; } return $note; }
/** * Create a Event * * This API is used for creating a Event * * @param array $params an associative array of title/value property values of civicrm_event * * @return array of newly created event property values. * @access public */ function civicrm_event_create(&$params) { _civicrm_initialize(); if (!is_array($params)) { return civicrm_create_error('Params is not an array'); } if (!isset($params['title']) || !isset($params['event_type_id']) || !isset($params['start_date'])) { return civicrm_create_error('Missing require fields ( title, event type id,start date)'); } $error = _civicrm_check_required_fields($params, 'CRM_Event_DAO_Event'); if ($error['is_error']) { return civicrm_create_error($error['error_message']); } // 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'] = $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; }
/** * 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()); } }
/** * Provides group nesting record(s) given parent and/or child id. * * @param array $params an array containing at least child_group_id or parent_group_id * * @return array list of group nesting records */ function civicrm_group_nesting_get(&$params) { _civicrm_initialize(); if (!is_array($params)) { return civicrm_create_error('Params need to be of type array!'); } if (!array_key_exists('child_group_id', $params) && !array_key_exists('parent_group_id', $params)) { return civicrm_create_error(ts('At least one of child_group_id or parent_group_id is a required field')); } require_once 'CRM/Contact/DAO/GroupNesting.php'; $dao = new CRM_Contact_DAO_GroupNesting(); if (array_key_exists('child_group_id', $params)) { $dao->child_group_id = $params['child_group_id']; } if (array_key_exists('parent_group_id', $params)) { $dao->parent_group_id = $params['parent_group_id']; } $values = array(); if ($dao->find()) { while ($dao->fetch()) { $temp = array(); _civicrm_object_to_array($dao, $temp); $values[$dao->id] = $temp; } $values['is_error'] = 0; } else { return civicrm_create_error('No records found.'); } return $values; }
/** * Create a new domain * * @param array $params * @return array */ function civicrm_domain_create($params) { require_once 'CRM/Core/BAO/Domain.php'; if (!is_array($params)) { return civicrm_create_error('Params need to be of type array!'); } if (empty($params)) { return civicrm_create_error('Params cannot be empty!'); } $domain = CRM_Core_BAO_Domain::create($params); $domain_array = array(); _civicrm_object_to_array($domain, $domain_array); return $domain_array; }
/** * Function to create activity type * * @param array $params associated array of fields * $params['option_value_id'] is required for updation of activity type * * @return array $activityType created / updated activity type * * @access public */ function civicrm_activity_type_create($params) { require_once 'CRM/Core/OptionGroup.php'; if (!isset($params['label']) || !isset($params['weight'])) { return civicrm_create_error(ts('Required parameter "label / weight" not found')); } $action = 1; $groupParams = array('name' => 'activity_type'); if ($optionValueID = CRM_Utils_Array::value('option_value_id', $params)) { $action = 2; } require_once 'CRM/Core/OptionValue.php'; $activityObject = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $action, $optionValueID); $activityType = array(); _civicrm_object_to_array($activityObject, $activityType); return $activityType; }
/** * create / update a PCP entry * * @param array $params (reference ) input parameters - need id and contribution_type_id * * @return array (reference ) PCP / PCPBlock result * @static void * @access public */ function &civicrm_pcp_create( &$params ) { _civicrm_initialize( ); $values = array( ); require_once 'CRM/Contribute/BAO/PCP.php'; $pcpBlock = CRM_Utils_Array::value( 'pcpBlock', $params, TRUE ); // true creates/updates a pcpBlock, false creates/updates a users pcp $pcp = CRM_Contribute_BAO_PCP::add( $params, $pcpBlock ); if ( is_a( $pcp, 'CRM_Core_Error' ) ) { return civicrm_create_error( ts( 'Failed to create pcp' ) ); } _civicrm_object_to_array($pcp, $pcpArray); return $pcpArray; }
/** * 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_contributionpage_create( &$params ) { _civicrm_initialize( ); $values = array( ); require_once 'CRM/Contribute/BAO/ContributionPage.php'; $ids = array( ); if ( CRM_Utils_Array::value( 'id', $params ) ) { } $contributionPage = CRM_Contribute_BAO_ContributionPage::create( $params ); if ( is_a( $contributionPage, 'CRM_Core_Error' ) ) { return civicrm_create_error( ts( 'Failed to create contributionPage' ) ); } _civicrm_object_to_array($contributionPage, $contributeArray); return $contributeArray; }
/** * 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'); }
/** * Add a contribution type * * @param array $params (reference ) input parameters * * @return array (reference ) contributionType id and other fields * @static void * @access public */ function &civicrm_contributiontype_add( &$params ) { _civicrm_initialize( ); $values = array( ); require_once 'CRM/Contribute/BAO/ContributionType.php'; $ids = array( ); if ( CRM_Utils_Array::value( 'id', $params ) ) { $ids['contributionType'] = $params['id']; unset($params['id']); // we don't need it in params } $contributionType = CRM_Contribute_BAO_ContributionType::add( $params, $ids ); if ( is_a( $contributionType, 'CRM_Core_Error' ) ) { return civicrm_create_error( ts( 'Failed to add contribution type' ) ); } _civicrm_object_to_array($contributionType, $contributeArray); return $contributeArray; }
/** * Create a Contact Membership * * This API is used for creating a Membership for a contact. * Required parameters : membership_type_id and status_id. * * @param array $params an associative array of name/value property values of civicrm_membership * * @return array of newly created membership property values. * @access public */ function civicrm_membership_contact_create(&$params) { _civicrm_initialize(); if (!is_array($params)) { return civicrm_create_error('Params is not an array'); } if (!isset($params['membership_type_id']) || !isset($params['contact_id']) || isset($params['is_override']) && !$params['status_id']) { return civicrm_create_error(ts('Required parameter missing')); } $values = array(); $error = _civicrm_membership_format_params($params, $values); if (is_a($error, 'CRM_Core_Error')) { return civicrm_create_error('Membership is not created'); } $params = array_merge($values, $params); require_once 'CRM/Core/Action.php'; $action = CRM_Core_Action::ADD; //for edit membership id should be present if (CRM_Utils_Array::value('id', $params)) { $ids = array('membership' => $params['id'], 'user_id' => $params['contact_id']); $action = CRM_Core_Action::UPDATE; } //need to pass action to handle related memberships. $params['action'] = $action; require_once 'CRM/Member/BAO/Membership.php'; $membershipBAO = CRM_Member_BAO_Membership::create($params, $ids, true); if (array_key_exists('is_error', $membershipBAO)) { // In case of no valid status for given dates, $membershipBAO // is going to contain 'is_error' => "Error Message" return civicrm_create_error(ts('The membership can not be saved, no valid membership status for given dates')); } $membership = array(); _civicrm_object_to_array($membershipBAO, $membership); $values = array(); $values['id'] = $membership['id']; $values['is_error'] = 0; return $values; }
/** * Use this API to create a new group. See the CRM Data Model for custom_group property definitions * $params['class_name'] is a required field, class being extended. * * @param $params array Associative array of property name/value pairs to insert in group. * * * @return Newly create custom_group object * * @access public */ function civicrm_custom_group_create($params) { _civicrm_initialize(); if (!is_array($params)) { return civicrm_create_error("params is not an array"); } // Require either param['class_name'] (string) - for backwards compatibility - OR parm['extends'] (array) // If passing extends array - set class_name (e.g. 'Contact', 'Participant'...) as extends[0]. You may optionally // pass an extends_entity_column_value as extends[1] (e.g. an Activity Type ID). if (isset($params['class_name']) && trim($params['class_name'])) { $params['extends'][0] = trim($params['class_name']); } else { if (!isset($params['extends']) || !is_array($params['extends'])) { return civicrm_create_error("Params must include either 'class_name' (string) or 'extends' (array)."); } else { if (!isset($params['extends'][0]) || !trim($params['extends'][0])) { return civicrm_create_error("First item in params['extends'] must be a class name (e.g. 'Contact')."); } } } $error = _civicrm_check_required_fields($params, 'CRM_Core_DAO_CustomGroup'); require_once 'CRM/Utils/String.php'; if (!isset($params['title']) || !trim($params['title'])) { return civicrm_create_error("Title parameter is required."); } if (!isset($params['style']) || !trim($params['style'])) { $params['style'] = 'Inline'; } if (is_a($error, 'CRM_Core_Error')) { return civicrm_create_error($error->_errors[0]['message']); } require_once 'CRM/Core/BAO/CustomGroup.php'; $customGroup = CRM_Core_BAO_CustomGroup::create($params); _civicrm_object_to_array($customGroup, $values); if (is_a($customGroup, 'CRM_Core_Error')) { return civicrm_create_error($customGroup->_errors[0]['message']); } else { $values['is_error'] = 0; } if (CRM_Utils_Array::value('html_type', $params)) { $params['custom_group_id'] = $customGroup->id; $fieldValues = civicrm_custom_field_create($params); $values = array_merge($values, $fieldValues['result']); } return $values; }
/** * Retrieve a specific Activity by Id. * * @param int $activityId * * @return array (reference) activity object * @access public */ function _civicrm_activity_get($activityId, $returnCustom = false) { $dao = new CRM_Activity_BAO_Activity(); $dao->id = $activityId; if ($dao->find(true)) { $activity = array(); _civicrm_object_to_array($dao, $activity); //also return custom data if needed. if ($returnCustom && !empty($activity)) { $customdata = civicrm_activity_custom_get(array('activity_id' => $activityId, 'activity_type_id' => $activity['activity_type_id'])); $activity = array_merge($activity, $customdata); } return $activity; } else { return false; } }
/** * Add or update a plege * * @param array $params (reference ) input parameters. Fields from interogate function should all work * * @return array (reference ) array representing created pledge * @static void * @access public */ function &civicrm_pledge_create(&$params) { _civicrm_initialize(); if (empty($params)) { return civicrm_create_error('No input parameters present'); } if (!is_array($params)) { return civicrm_create_error('Input parameters is not an array'); } //check for required fields $error = _civicrm_pledge_check_params($params); if (civicrm_error($error)) { return $error; } $values = array(); require_once 'CRM/Pledge/BAO/Pledge.php'; //check that fields are in appropriate format. Dates will be formatted (within reason) by this function $error = _civicrm_pledge_format_params($params, $values, TRUE); if (civicrm_error($error)) { return $error; } $pledge = CRM_Pledge_BAO_Pledge::create($values); if (is_a($pledge, 'CRM_Core_Error')) { return civicrm_create_error($pledge->_errors[0]['message']); } else { _civicrm_object_to_array($pledge, $pledgeArray); $pledgeArray['is_error'] = 0; } _civicrm_object_to_array($pledge, $pledgeArray); return $pledgeArray; }
/** * Update an existing membership status * * This api is used for updating an existing membership status. * Required parrmeters : id of a membership status * * @param Array $params an associative array of name/value property values of civicrm_membership_status * * @return array of updated membership status property values * @access public */ function &civicrm_membership_status_update(&$params) { _civicrm_initialize(); if (!is_array($params)) { return civicrm_create_error('Params is not an array'); } if (!isset($params['id'])) { return civicrm_create_error('Required parameter missing'); } require_once 'CRM/Member/BAO/MembershipStatus.php'; $membershipStatusBAO =& new CRM_Member_BAO_MembershipStatus(); $membershipStatusBAO->id = $params['id']; if ($membershipStatusBAO->find(true)) { $fields = $membershipStatusBAO->fields(); foreach ($fields as $name => $field) { if (array_key_exists($name, $params)) { $membershipStatusBAO->{$name} = $params[$name]; } } $membershipStatusBAO->save(); } $membershipStatus = array(); _civicrm_object_to_array(clone $membershipStatusBAO, $membershipStatus); $membershipStatus['is_error'] = 0; return $membershipStatus; }
/** * * @param <type> $params * @return <type> */ function &civicrm_contribution_format_create(&$params) { _civicrm_initialize(); // return error if we have no params if (empty($params)) { return civicrm_create_error('Input Parameters empty'); } $error = _civicrm_contribute_check_params($params); if (civicrm_error($error)) { return $error; } $values = array(); $error = _civicrm_contribute_format_params($params, $values); if (civicrm_error($error)) { return $error; } $error = _civicrm_contribute_duplicate_check($params); if (civicrm_error($error)) { return $error; } $ids = array(); CRM_Contribute_BAO_Contribution::resolveDefaults($params, true); $contribution = CRM_Contribute_BAO_Contribution::create($params, $ids); _civicrm_object_to_array($contribution, $contributeArray); return $contributeArray; }
/** * Create a Contact Membership * * This API is used for creating a Membership for a contact. * Required parameters : membership_type_id and status_id. * * @param array $params an associative array of name/value property values of civicrm_membership * * @return array of newly created membership property values. * @access public */ function civicrm_membership_contact_create(&$params) { _civicrm_initialize(); $error = _civicrm_membership_check_params($params); if (civicrm_error($error)) { return $error; } $values = array(); $error = _civicrm_membership_format_params($params, $values); if (civicrm_error($error)) { return $error; } $params = array_merge($values, $params); require_once 'CRM/Core/Action.php'; $action = CRM_Core_Action::ADD; // we need user id during add mode $ids = array('userId' => $params['contact_id']); //for edit membership id should be present if (CRM_Utils_Array::value('id', $params)) { $ids = array('membership' => $params['id'], 'userId' => $params['contact_id']); $action = CRM_Core_Action::UPDATE; } //need to pass action to handle related memberships. $params['action'] = $action; require_once 'CRM/Member/BAO/Membership.php'; $membershipBAO = CRM_Member_BAO_Membership::create($params, $ids, true); if (array_key_exists('is_error', $membershipBAO)) { // In case of no valid status for given dates, $membershipBAO // is going to contain 'is_error' => "Error Message" return civicrm_create_error(ts('The membership can not be saved, no valid membership status for given dates')); } $membership = array(); _civicrm_object_to_array($membershipBAO, $membership); $values = array(); $values['id'] = $membership['id']; $values['is_error'] = 0; return $values; }
/** * Function to get all relationship type * retruns An array of Relationship_type * * @access public */ function civicrm_relationship_types_get($params = null) { _civicrm_initialize(); require_once 'CRM/Contact/DAO/RelationshipType.php'; $relationshipTypes = array(); $relationshipType = array(); $relationType = new CRM_Contact_DAO_RelationshipType(); if (!empty($params) && is_array($params)) { $properties = array_keys($relationType->fields()); foreach ($properties as $name) { if (array_key_exists($name, $params)) { $relationType->{$name} = $params[$name]; } } } $relationType->find(); while ($relationType->fetch()) { _civicrm_object_to_array(clone $relationType, $relationshipType); $relationshipTypes[] = $relationshipType; } return $relationshipTypes; }
/** * Retrieve one / all contribution(s) / membership(s) linked to a * membership / contrbution. * * @param array $params (reference ) input parameters * * @return array (reference ) array of properties, if error an array with an error id and error message * @static void * @access public */ function &civicrm_membershipcontributionlink_get(&$params) { _civicrm_initialize(); if (empty($params)) { return civicrm_create_error(ts('No input parameters present')); } if (!is_array($params)) { return civicrm_create_error(ts('Input parameters is not an array')); } require_once 'CRM/Member/DAO/MembershipPayment.php'; $mpDAO =& new CRM_Member_DAO_MembershipPayment(); $mpDAO->copyValues($params); $mpDAO->id = CRM_Utils_Array::value('membership_contribution_id', $params); $mpDAO->find(); $values = array(); while ($mpDAO->fetch()) { _civicrm_object_to_array($mpDAO, $mpArray); $mpArray['membership_contribution_id'] = $mpDAO->id; unset($mpArray['id']); $values[$mpDAO->id] = $mpArray; } return $values; }
/** * @todo Move this to ContactFormat.php * @deprecated */ function civicrm_contact_format_create(&$params) { _civicrm_initialize(); CRM_Core_DAO::freeResult(); // return error if we have no params if (empty($params)) { return civicrm_create_error('Input Parameters empty'); } $error = _civicrm_required_formatted_contact($params); if (civicrm_error($error)) { return $error; } $error = _civicrm_validate_formatted_contact($params); if (civicrm_error($error)) { return $error; } //get the prefix id etc if exists require_once 'CRM/Contact/BAO/Contact.php'; CRM_Contact_BAO_Contact::resolveDefaults($params, TRUE); require_once 'CRM/Import/Parser.php'; if (CRM_Utils_Array::value('onDuplicate', $params) != CRM_Import_Parser::DUPLICATE_NOCHECK) { CRM_Core_Error::reset(); $error = _civicrm_duplicate_formatted_contact($params); if (civicrm_error($error)) { return $error; } } $contact = CRM_Contact_BAO_Contact::create($params, CRM_Utils_Array::value('fixAddress', $params)); _civicrm_object_to_array($contact, $contactArray); return $contactArray; }
/** * Use this API to update uf field . See the CRM Data Model for uf_field property definitions * * @param $params array Associative array of property name/value pairs to update in field. * * @param $fieldId int A valid uf field id that to be updated. * * @return updated $ufFieldArray array * * @access public */ function civicrm_uf_field_update($params, $fieldId) { _civicrm_initialize(); if (!isset($fieldId)) { return civicrm_create_error("parameter fieldId is not set"); } if (!is_array($params)) { return civicrm_create_error("params is not an array "); } $field_type = CRM_Utils_Array::value('field_type', $params); $field_name = CRM_Utils_Array::value('field_name', $params); $location_type_id = CRM_Utils_Array::value('location_type_id', $params); $phone_type = CRM_Utils_Array::value('phone_type', $params); $params['field_name'] = array($field_type, $field_name, $location_type_id, $phone_type); require_once 'CRM/Core/BAO/UFField.php'; $UFField = new CRM_core_BAO_UFField(); $UFField->id = $fieldId; if (!CRM_Utils_Array::value('group_id', $params) && $UFField->find(TRUE)) { $params['group_id'] = $UFField->uf_group_id; } $ids = array(); if ($UFField->find(TRUE)) { $ids['uf_group'] = $UFField->uf_group_id; } else { return civicrm_create_error("there is no field for this fieldId"); } $ids['uf_field'] = $fieldId; if (CRM_Core_BAO_UFField::duplicateField($params, $ids)) { return civicrm_create_error("The field was not added. It already exists in this profile."); } $ufField = CRM_Core_BAO_UFField::add($params, $ids); _civicrm_object_to_array($ufField, $ufFieldArray); return $ufFieldArray; }
/** * This function is called when action is browse * * return null * @access public */ function listContribution() { $controller =& new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), null); $controller->setEmbedded(true); $controller->reset(); $controller->set('limit', 12); $controller->set('cid', $this->_contactId); $controller->set('context', 'user'); $controller->set('force', 1); $controller->process(); $controller->run(); //add honor block require_once 'CRM/Contribute/BAO/Contribution.php'; $params = array(); $params = CRM_Contribute_BAO_Contribution::getHonorContacts($this->_contactId); if (!empty($params)) { // assign vars to templates $this->assign('honorRows', $params); $this->assign('honor', true); } require_once 'CRM/Contribute/Form/ContributionBase.php'; require_once 'CRM/Contribute/BAO/ContributionRecur.php'; $recur =& new CRM_Contribute_DAO_ContributionRecur(); $recur->contact_id = $this->_contactId; $recur->is_test = 0; $recur->find(); $config =& CRM_Core_Config::singleton(); $recurStatus = CRM_Contribute_PseudoConstant::contributionStatus(); require_once 'CRM/Core/Payment.php'; require_once 'api/v2/utils.php'; $recurRow = array(); $recurIDs = array(); while ($recur->fetch()) { $mode = $recur->is_test ? 'test' : 'live'; $paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($recur->id, $mode); if (!$paymentProcessor) { continue; } // note that we are passing a CRM_Core_Page object ($this) as if it were a form here: $paymentObject =& CRM_Core_Payment::singleton($mode, 'Contribute', $paymentProcessor, $this); _civicrm_object_to_array($recur, $values); $values['cancelSubscriptionUrl'] = $paymentObject->cancelSubscriptionURL(); $values['recur_status'] = $recurStatus[$values['contribution_status_id']]; $recurRow[$values['id']] = $values; $recurIDs[] = $values['id']; //reset $paymentObject for checking other paymenet processor //recurring url $paymentObject = null; } if (is_array($recurIDs) && !empty($recurIDs)) { $getCount = CRM_Contribute_BAO_ContributionRecur::getCount($recurIDs); foreach ($getCount as $key => $val) { $recurRow[$key]['completed'] = $val; $recurRow[$key]['link'] = CRM_Utils_System::url('civicrm/contribute/search', "reset=1&force=1&recur={$key}"); } } $this->assign('recurRows', $recurRow); if (!empty($recurRow)) { $this->assign('recur', true); } else { $this->assign('recur', false); } }
function civicrm_contributionsoft_create( &$params ) { _civicrm_initialize( ); require_once 'CRM/Contribute/BAO/Contribution.php'; $softContribution = CRM_Contribute_BAO_Contribution::addSoftContribution( $params ); _civicrm_object_to_array($softContribution, $softContributionArray); return $softContributionArray; }
/** * * @param <type> $params * * @return <type> */ function &civicrm_pledge_payment_format_create(&$params) { _civicrm_initialize(); // return error if we have no params if (empty($params)) { return civicrm_create_error('Input Parameters empty'); } $error = _civicrm_pledge_check_params($params); if (civicrm_error($error)) { return $error; } $values = array(); $error = _civicrm_pledge_format_params($params, $values); if (civicrm_error($error)) { return $error; } $error = _civicrm_pledge_duplicate_check($params); if (civicrm_error($error)) { return $error; } $ids = array(); CRM_Pledge_BAO_Pledge::resolveDefaults($params, TRUE); $pledge = CRM_Pledge_BAO_Pledge::create($params, $ids); _civicrm_object_to_array($pledge, $pledgeArray); return $pledgeArray; }
/** * Get a Tag. * * This api is used for finding an existing tag. * Either id or name of tag are required parameters for this api. * * @param array $params an associative array of name/value pairs. * * @return array details of found tag else error * @access public */ function civicrm_tag_get($params) { _civicrm_initialize(); require_once 'CRM/Core/BAO/Tag.php'; $tagBAO =& new CRM_Core_BAO_Tag(); if (!is_array($params)) { return civicrm_create_error('Params is not an array.'); } if (!isset($params['id']) && !isset($params['name'])) { return civicrm_create_error('Required parameters missing.'); } $properties = array('id', 'name', 'description', 'parent_id'); foreach ($properties as $name) { if (array_key_exists($name, $params)) { $tagBAO->{$name} = $params[$name]; } } if (!$tagBAO->find(true)) { return civicrm_create_error('Exact match not found.'); } _civicrm_object_to_array($tagBAO, $tag); return $tag; }
/** * Update an existing membership type * * This api is used for updating an existing membership type. * Required parrmeters : id of a membership type * * @param Array $params an associative array of name/value property values of civicrm_membership_type * * @return array of updated membership type property values * @access public */ function &civicrm_membership_type_update(&$params) { if (!is_array($params)) { return civicrm_create_error('Params need to be of type array!'); } if (empty($params)) { return civicrm_create_error('No input parameters present'); } if (!isset($params['id'])) { return civicrm_create_error('Required parameter missing'); } require_once 'CRM/Member/BAO/MembershipType.php'; $membershipTypeBAO =& new CRM_Member_BAO_MembershipType(); $membershipTypeBAO->id = $params['id']; if ($membershipTypeBAO->find(true)) { $fields = $membershipTypeBAO->fields(); foreach ($fields as $name => $field) { if (array_key_exists($name, $params)) { $membershipTypeBAO->{$name} = $params[$name]; } } $membershipTypeBAO->save(); } $membershipType = array(); _civicrm_object_to_array($membershipTypeBAO, $membershipType); $membershipTypeBAO->free(); return $membershipType; }
/** * * @param <type> $params * @return <type> */ function civicrm_group_organization_create(&$params) { if (!is_array($params)) { return civicrm_create_error(ts('Input parameter is not an array')); } if (empty($params)) { return civicrm_create_error('No input parameter present'); } if (!array_key_exists('organization_id', $params) || !array_key_exists('group_id', $params)) { return civicrm_create_error(ts('organization_id and group_id are required field')); } require_once 'CRM/Contact/BAO/GroupOrganization.php'; $groupOrgBAO = CRM_Contact_BAO_GroupOrganization::add($params); if (is_a($groupOrgBAO, 'CRM_Core_Error')) { return civicrm_create_error("Group Organization can not be created"); } _civicrm_object_to_array($groupOrgBAO, $values); return civicrm_create_success($values); }
/** * Update an existing contact participant payment * * This api is used for updating an existing contact participant payment * Required parameters : id of a participant_payment * * @param Array $params an associative array of name/value property values of civicrm_participant_payment * * @return array of updated participant_payment property values * @access public */ function &civicrm_participant_payment_update(&$params) { _civicrm_initialize(); if (!is_array($params)) { $error = civicrm_create_error('Params is not an array'); return $error; } if (!isset($params['id'])) { $error = civicrm_create_error('Required parameter missing'); return $error; } $ids = array(); $ids['id'] = $params['id']; require_once 'CRM/Event/BAO/ParticipantPayment.php'; $payment = CRM_Event_BAO_ParticipantPayment::create($params, $ids); $participantPayment = array(); _civicrm_object_to_array($payment, $participantPayment); return $participantPayment; }
/** * Returns array of groups matching a set of one or more group properties * * @param array $params (referance) Array of one or more valid * property_name=>value pairs. If $params is set * as null, all groups will be returned * * @return array (referance) Array of matching groups * @access public */ function civicrm_group_get(&$params) { _civicrm_initialize(); if (!is_null($params) && !is_array($params)) { return civicrm_create_error('Params should be array'); } $returnProperties = array(); foreach ($params as $n => $v) { if (substr($n, 0, 7) == 'return.') { $returnProperties[] = substr($n, 7); } } if (!empty($returnProperties)) { $returnProperties[] = 'id'; } $groupObjects = CRM_Contact_BAO_Group::getGroups($params, $returnProperties); if (count($groupObjects) == 0) { return civicrm_create_error('No such group exists'); } $groups = array(); foreach ($groupObjects as $group) { _civicrm_object_to_array($group, $groups[$group->id]); } return $groups; }
/** * takes an associative array and updates a uf join array * * @param array $params assoc array of name/value pairs * * @return array updated CRM_Core_DAO_UFJoin Array * @access public * */ function civicrm_uf_join_edit($params) { if (!is_array($params)) { return civicrm_create_error("params is not an array"); } if (empty($params)) { return civicrm_create_error("params is an empty array"); } if (!isset($params['uf_group_id'])) { return civicrm_create_error("uf_group_id is required field"); } $ufJoin = CRM_Core_BAO_UFJoin::create($params); _civicrm_object_to_array($ufJoin, $ufJoinArray); return $ufJoinArray; }