/** * Get an Event. * * This api is used to retrieve all data for an existing Event. * Required parameters : id of event * * @param array $params an associative array of title/value property values of civicrm_event * * @return If successful array of event data; otherwise object of CRM_Core_Error. * @access public */ function crm_get_event($params) { _crm_initialize(); if (!is_array($params)) { return _crm_error('Params is not an array.'); } if (!isset($params['id'])) { return _crm_error('Required id (event ID) parameter is missing.'); } $event = array(); require_once 'CRM/Event/BAO/Event.php'; $eventBAO = new CRM_Event_BAO_Event(); $eventBAO->copyValues($params); $eventBAO->find(); while ($eventBAO->fetch()) { $event = array(); _crm_object_to_array(clone $eventBAO, $event); $event[$eventBAO->id] = $event; } return $event; }
/** * Delete uf field * * @param $ufField Object Valid uf_field object that to be deleted * * @return true on successful delete or return error * * @access public * */ function crm_delete_uf_field($ufField) { _crm_initialize(); $fieldId = $ufField->id; if (!isset($fieldId)) { return _crm_error("parameter {$fieldId} is not set "); } require_once 'CRM/Core/BAO/UFField.php'; return CRM_Core_BAO_UFField::del($fieldId); }
/** * Defines 'custom value' within a field for a specific entity table/id combination. * * @param $entity_table String Name of the table that this value is attached to * * @param $entity_id int ID of the object in the relevant table * * @param $custom_field object field type of the value * * @param $data Array data appropriate value for the above custom field * * @param $separator String separator for values for ckeckbox. * * @return newly created custom_value object * * @access public * * */ function crm_create_custom_value($entity_table, $entity_id, &$custom_field, &$data, $separator = null) { _crm_initialize(); if (!isset($entity_table)) { return _crm_error("parameter entity_table is not set "); } if (!isset($entity_id)) { return _crm_error("parameter entity_id is not set "); } if (!isset($custom_field->id) && !isset($custom_field->type)) { return _crm_error("field id ot type is not set in custom_field object"); } if ($separator) { $values = explode($separator, $data['value']); require_once 'CRM/Core/BAO/CustomOption.php'; $data['value'] = implode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, $values); } $data['type'] = $custom_field->data_type; $data['custom_field_id'] = $custom_field->id; $data['entity_table'] = $entity_table; $data['entity_id'] = $entity_id; require_once 'CRM/Core/BAO/CustomValue.php'; return CRM_Core_BAO_CustomValue::create($data); }
/** * Deletes an existing contact membership * * This API is used for deleting a contact membership * * @param Int $membershipID Id of the contact membership to be deleted * * @return null if successfull, object of CRM_Core_Error otherwise * @access public */ function crm_delete_membership($membershipID) { _crm_initialize(); if (empty($membershipID)) { return _crm_error('Invalid value for membershipID'); } require_once 'CRM/Member/BAO/Membership.php'; CRM_Member_BAO_Membership::deleteRelatedMemberships($membershipID); $membership = new CRM_Member_BAO_Membership(); $result = $membership->deleteMembership($membershipID); return $result ? null : _crm_error('Error while deleting Membership'); }
/** * confirm membership to a group * * @param CRM_Contact $group A valid group object (passed by reference). * @param array $contacts An array of one or more valid Contact objects (passed by reference). * * * @return null if success or CRM_Error (db error or contact was not valid) * * @access public */ function crm_confirm_group_contacts(&$group, $contacts) { _crm_initialize(); if (!is_a($group, 'CRM_Contact_BAO_Group') && !is_a($group, 'CRM_Contact_DAO_Group')) { return _crm_error('Invalid group object passed in'); } if (!is_array($contacts)) { return _crm_error('$contacts is not Array '); } foreach ($contacts as $contact) { if (!isset($contact->id)) { return _crm_error('Invalid contact object passed in'); } $member = CRM_Contact_BAO_GroupContact::getMembershipDetail($contact->id, $group->id); if ($member->status != 'Pending') { return _crm_error('Can not confirm subscription. Current group status is NOT Pending.'); } CRM_Contact_BAO_GroupContact::updateGroupMembershipStatus($contact->id, $group->id); } return null; }
/** * Delete a specified contribution. * * @param CRM_Contribution $contribution Contribution object to be deleted * * @return void|CRM_Core_Error An error if 'contribution' is invalid, * permissions are insufficient, etc. * * @access public * */ function crm_delete_contribution(&$contribution) { _crm_initialize(); if (!isset($contribution->id)) { return _crm_error('Invalid contribution object passed in'); } CRM_Contribute_BAO_Contribution::deleteContribution($contribution->id); }
function CRM_ProcessAuthorizeReport() { _crm_initialize(); $config =& CRM_Core_Config::singleton(); $config->userFramework = 'Soap'; $config->userFrameworkClass = 'CRM_Utils_System_Soap'; $config->userHookClass = 'CRM_Utils_Hook_Soap'; if (!function_exists('imap_headers')) { die('PHP IMAP extension required to use this script'); } if (defined('_CRM_PROCESS_AUTHORIZE_REPORT_DEBUG')) { $this->_debug = _CRM_PROCESS_AUTHORIZE_REPORT_DEBUG; error_reporting(E_ALL); ini_set('display_errors', true); } else { $this->_debug = false; ini_set('display_errors', false); } }
/** * Get all the groups that a contact is a member of with the given status * * @param CRM_Contact $contact Contact object whose groups we are interested in * * @return void|CRM_Core_Error An error if 'contact' is invalid, * * @access public * */ function crm_contact_groups(&$contact, $status = null) { _crm_initialize(); if (!isset($contact->id)) { return _crm_error('Invalid contact object passed in'); } require_once 'CRM/Contact/BAO/GroupContact.php'; $values =& CRM_Contact_BAO_GroupContact::getContactGroup($contact->id, $status, null, false); $groups = array(); foreach ($values as $value) { $group =& new CRM_Contact_DAO_Group(); foreach ($value as $k => $v) { if (!empty($v)) { $group->{$k} = $v; } } $groups[$group->id] = $group; } return $groups; }
/** * Returns array of location(s) for a contact * * @param object $contact A valid Contact object (passed by reference). * @param Array $location_type Valid location_type label Array. If NULL, all locations are returned. * * * @return An array of Location objects. 'location_id' and 'location_type' are always returned. * * @acces public * */ function crm_get_locations(&$contact, $location_types = null) { _crm_initialize(); if (!isset($contact->id)) { return _crm_error('$contact is not valid contact datatype'); } $params = array(); $params['contact_id'] = $contact->id; $params['entity_id'] = $contact->id; $locationDAO =& new CRM_Core_DAO_Location(); $locationDAO->entity_table = 'civicrm_contact'; $locationDAO->entity_id = $contact->id; $locationCount = $locationDAO->count(); $values = array(); $locations = CRM_Core_BAO_Location::getValues($params, $values, $ids, $locationCount); if (is_array($location_types) && count($location_types) > 0) { $newLocations = array(); foreach ($location_types as $locationName) { $LocationTypeDAO =& new CRM_Core_DAO_LocationType(); $LocationTypeDAO->name = $locationName; $LocationTypeDAO->find(); $LocationTypeDAO->fetch(); foreach ($locations as $location) { if ($location->location_type_id == $LocationTypeDAO->id) { $newLocations[] = $location; } } } if (empty($newLocations)) { return _crm_error('Location information is empty'); } return $newLocations; } return $locations; }
/** * Check if object is valid and has an id * * @param CRM_Core_DAO_ActivityHistory $historyDAO Activity History object to be checked * * @param boolean $checkForId - check if id is set * * @return true|CRM_Core_Error An error if 'contact' is invalid, * permissions are insufficient, etc. * * @access public * */ function _crm_check_activity_history_object(&$historyDAO, $checkForId = false) { _crm_initialize(); // check if valid DAO if (!is_a($historyDAO, 'CRM_Core_DAO_ActivityHistory')) { return _crm_error(ts('Invalid history object passed in')); } if ($checkForId && !isset($historyDAO->id)) { return _crm_error(ts('History object does not contain a primary key - it is needed for update operation')); } return true; }