コード例 #1
0
/**
 * 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;
}
コード例 #2
0
ファイル: Payment.php プロジェクト: ryanrd/DW-Campaigns
/**
 * 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;
}
コード例 #3
0
function &civicrm_survey_respondant_count(&$params)
{
    _civicrm_initialize();
    $petition = new CRM_Campaign_BAO_Petition();
    if (array_key_exists('groupby', $params) && $params['groupby'] == 'country') {
        $signaturesCount = $petition->getPetitionSignatureTotalbyCountry($params['survey_id']);
    } else {
        $signaturesCount = $petition->getPetitionSignatureTotal($params['survey_id']);
    }
    return $signaturesCount;
}
コード例 #4
0
ファイル: Membership.php プロジェクト: bhirsch/voipdev
/**
 * 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 civicrm_membership_delete(&$membershipID)
{
    _civicrm_initialize();
    if (empty($membershipID)) {
        return civicrm_create_error('Membership ID cannot be empty.');
    }
    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 ? civicrm_create_success() : civicrm_create_error('Error while deleting Membership');
}
コード例 #5
0
/**
 * 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;
}
コード例 #6
0
ファイル: ActivityContact.php プロジェクト: ksecor/civicrm
/**
 * Retrieve a set of activities, specific to given input params.
 *
 * @param  array  $params (reference ) input parameters.
 *
 * @return array (reference)  array of activities / error message.
 * @access public
 */
function civicrm_activity_contact_get($params)
{
    _civicrm_initialize();
    $contactId = CRM_Utils_Array::value('contact_id', $params);
    if (empty($contactId)) {
        return civicrm_create_error(ts("Required parameter not found"));
    }
    if (!is_numeric($contactId)) {
        return civicrm_create_error(ts("Invalid contact Id"));
    }
    $activities =& _civicrm_activities_get($contactId);
    if ($activities) {
        return civicrm_create_success($activities);
    } else {
        return civicrm_create_error(ts('Invalid Data'));
    }
}
コード例 #7
0
ファイル: Friend.php プロジェクト: ryanrd/DW-Campaigns
/**
 * 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');
}
コード例 #8
0
/**
 * 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;
}
コード例 #9
0
/**
 * Retrieve a set of activities, specific to given input params.
 *
 * @param  array  $params (reference ) input parameters.
 *
 * @return array (reference)  array of activities / error message.
 * @access public
 */
function civicrm_activity_contact_get($params)
{
    _civicrm_initialize();
    $contactId = CRM_Utils_Array::value('contact_id', $params);
    if (empty($contactId)) {
        return civicrm_create_error(ts("Required parameter not found"));
    }
    //check if $contactId is valid
    if (!is_numeric($contactId) || !preg_match('/^\\d+$/', $contactId)) {
        return civicrm_create_error(ts("Invalid contact Id"));
    }
    $activities =& _civicrm_activities_get($contactId);
    //show success for empty $activities array
    if (empty($activities)) {
        return civicrm_create_success(ts("0 activity record matching input params"));
    }
    if ($activities) {
        return civicrm_create_success($activities);
    } else {
        return civicrm_create_error(ts('Invalid Data'));
    }
}
コード例 #10
0
/**
 * Delete a specified Activity.
 * @param CRM_Activity $activity Activity object to be deleted
 *
 * @return void|CRM_Core_Error  An error if 'activityName or ID' is invalid,
 *                         permissions are insufficient, etc.
 *
 * @access public
 *
 */
function civicrm_activity_delete(&$params)
{
    _civicrm_initialize();
    $errors = array();
    //check for various error and required conditions
    $errors = _civicrm_activity_check_params($params);
    if (!empty($errors)) {
        return $errors;
    }
    if (CRM_Activity_BAO_Activity::deleteActivity($params)) {
        return civicrm_create_success();
    } else {
        return civicrm_create_error(ts('Could not delete activity'));
    }
}
コード例 #11
0
ファイル: Event.php プロジェクト: bhirsch/voipdev
/**
 * 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 civicrm_event_get(&$params)
{
    _civicrm_initialize();
    if (!is_array($params)) {
        return civicrm_create_error('Input parameters is not an array.');
    }
    if (empty($params)) {
        return civicrm_create_error('Params cannot be empty.');
    }
    $event =& civicrm_event_search($params);
    if (count($event) != 1 && !CRM_Utils_Array::value('returnFirst', $params)) {
        return civicrm_create_error(ts('%1 events matching input params', array(1 => count($event))));
    }
    if (civicrm_error($event)) {
        return $event;
    }
    $event = array_values($event);
    $event[0]['is_error'] = 0;
    return $event[0];
}
コード例 #12
0
ファイル: MembershipStatus.php プロジェクト: ksecor/civicrm
/**
 * 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;
}
コード例 #13
0
ファイル: Contribute.php プロジェクト: ksecor/civicrm
/**
 *
 * @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;
}
コード例 #14
0
/**
 * Retrieve a specific participant, given a set of input params
 * If more than one matching participant exists, return an error, unless
 * the client has requested to return the first found contact
 *
 * @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_contributionpage_get( &$params ) {
    _civicrm_initialize( );
 
    $values = array( );
    if ( empty( $params ) ) {
        $error = civicrm_create_error( ts( 'No input parameters present' ) );
        return $error;
    }
    
    if ( ! is_array( $params ) ) {
        $error = civicrm_create_error( ts( 'Input parameters is not an array' ) );
        return $error;
    }

    $contributionPage  =& civicrm_contributionpage_search( $params );
    
	if ( count( $contributionPage ) != 1 &&
		 ! CRM_Utils_Array::value( 'returnFirst', $params ) ) {

			if( ! CRM_Utils_Array::value( 'returnAll', $params) ) {
		 
				$error = civicrm_create_error( ts( '%1 contributionPages matching input params', array( 1 => count( $contributionPage ) ) ),
									   $contributionPage );
			} else {
				$return = array(
							'count' => count( $contributionPage ), 
							'results' => $contributionPage
						);
						
				return $return;
				
			}
		return $error;
	}

    if ( civicrm_error( $contributionPage ) ) {
        return $contributionPage;
    }

    $contributionPage = array_values( $contributionPage );
    return $contributionPage[0];
}
コード例 #15
0
ファイル: Location.php プロジェクト: ksecor/civicrm
/**
 * Returns array of location(s) for a contact
 * 
 * @param array $contact  a valid array of contact parameters
 *
 * @return array  an array of location parameters arrays
 *
 * @access public
 */
function civicrm_location_get($contact)
{
    _civicrm_initialize();
    if (!is_array($contact)) {
        return civicrm_create_error('Params need to be of type array!');
    }
    if (!isset($contact['contact_id'])) {
        return civicrm_create_error('$contact is not valid contact datatype');
    }
    $locationTypes = CRM_Utils_Array::value('location_type', $contact);
    if (is_array($locationTypes) && !count($locationTypes)) {
        return civicrm_create_error('Location type array can not be empty');
    }
    $location =& _civicrm_location_get($contact, $locationTypes);
    return $location;
}
コード例 #16
0
ファイル: MembershipContact.php プロジェクト: bhirsch/voipdev
/**
 * Get contact membership record.
 * 
 * This api is used for finding an existing membership record.
 * This api will also return the mebership records for the contacts
 * having mebership based on the relationship with the direct members.
 * 
 * @param  Array $params key/value pairs for contact_id and some
 *          options affecting the desired results; has legacy support
 *          for just passing the contact_id itself as the argument
 *
 * @return  Array of all found membership property values.
 * @access public
 */
function civicrm_membership_contact_get(&$params)
{
    _civicrm_initialize();
    $activeOnly = false;
    if (is_array($params)) {
        $contactID = CRM_Utils_Array::value('contact_id', $params);
        $activeOnly = CRM_Utils_Array::value('active_only', $params, false);
        if ($activeOnly == 1) {
            $activeOnly = true;
        } else {
            $activeOnly = false;
        }
    } elseif (CRM_Utils_Rule::integer($params)) {
        $contactID = $params;
    } else {
        return civicrm_create_error('Paramers can be only of type array or integer');
    }
    if (empty($contactID)) {
        return civicrm_create_error('Invalid value for ContactID.');
    }
    // get the membership for the given contact ID
    require_once 'CRM/Member/BAO/Membership.php';
    $membership = array('contact_id' => $contactID);
    $membershipValues = array();
    CRM_Member_BAO_Membership::getValues($membership, $membershipValues, $activeOnly);
    $recordCount = 0;
    if (empty($membershipValues)) {
        # No results is NOT an error!
        # return civicrm_create_error('No memberships for this contact.');
        $membershipValues['record_count'] = $recordCount;
        return $membershipValues;
    }
    $members[$contactID] = array();
    $relationships = array();
    foreach ($membershipValues as $membershipId => $values) {
        // populate the membership type name for the membership type id
        require_once 'CRM/Member/BAO/MembershipType.php';
        $membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($values['membership_type_id']);
        $membershipValues[$membershipId]['membership_name'] = $membershipType['name'];
        if (CRM_Utils_Array::value('relationship_type_id', $membershipType)) {
            $relationships[$membershipType['relationship_type_id']] = $membershipId;
        }
        // populating relationship type name.
        require_once 'CRM/Contact/BAO/RelationshipType.php';
        $relationshipType = new CRM_Contact_BAO_RelationshipType();
        $relationshipType->id = CRM_Utils_Array::value('relationship_type_id', $membershipType);
        if ($relationshipType->find(true)) {
            $membershipValues[$membershipId]['relationship_name'] = $relationshipType->name_a_b;
        }
        require_once 'CRM/Core/BAO/CustomGroup.php';
        $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Membership', CRM_Core_DAO::$_nullObject, $membershipId, false, $values['membership_type_id']);
        $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, CRM_Core_DAO::$_nullObject);
        $defaults = array();
        CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults);
        if (!empty($defaults)) {
            foreach ($defaults as $key => $val) {
                $membershipValues[$membershipId][$key] = $val;
            }
        }
        $recordCount++;
    }
    $members[$contactID] = $membershipValues;
    // populating contacts in members array based on their relationship with direct members.
    require_once 'CRM/Contact/BAO/Relationship.php';
    if (!empty($relationships)) {
        foreach ($relationships as $relTypeId => $membershipId) {
            // As members are not direct members, there should not be
            // membership id in the result array.
            unset($membershipValues[$membershipId]['id']);
            $relationship = new CRM_Contact_BAO_Relationship();
            $relationship->contact_id_b = $contactID;
            $relationship->relationship_type_id = $relTypeId;
            if ($relationship->find()) {
                while ($relationship->fetch()) {
                    clone $relationship;
                    $membershipValues[$membershipId]['contact_id'] = $relationship->contact_id_a;
                    $members[$contactID][$relationship->contact_id_a] = $membershipValues[$membershipId];
                }
            }
            $recordCount++;
        }
    }
    $members['record_count'] = $recordCount;
    return $members;
}
コード例 #17
0
/**
 * delete an existing group
 *
 * This method is used to delete any existing group. id of the group
 * to be deleted is required field in $params array
 *
 * @param array $params  (referance) array containing id of the group
 *                       to be deleted
 *
 * @return array  (referance) returns flag true if successfull, error
 *                message otherwise
 *
 * @access public
 */
function civicrm_group_delete(&$params)
{
    _civicrm_initialize();
    if (is_null($params) || !is_array($params) || !CRM_Utils_Array::value('id', $params)) {
        return civicrm_create_error('Required parameter missing');
    }
    CRM_Contact_BAO_Group::discard($params['id']);
    return civicrm_create_success(TRUE);
}
コード例 #18
0
ファイル: MembershipType.php プロジェクト: ksecor/civicrm
/**
 * Get a Membership Type.
 * 
 * This api is used for finding an existing membership type.
 * 
 * @param  array $params  an associative array of name/value property values of civicrm_membership_type
 * 
 * @return  Array of all found membership type property values.
 * @access public
 */
function civicrm_membership_type_get(&$params)
{
    _civicrm_initialize();
    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');
    }
    require_once 'CRM/Member/BAO/MembershipType.php';
    $membershipTypeBAO = new CRM_Member_BAO_MembershipType();
    $properties = array_keys($membershipTypeBAO->fields());
    foreach ($properties as $name) {
        if (array_key_exists($name, $params)) {
            $membershipTypeBAO->{$name} = $params[$name];
        }
    }
    if ($membershipTypeBAO->find()) {
        $membershipType = array();
        while ($membershipTypeBAO->fetch()) {
            _civicrm_object_to_array(clone $membershipTypeBAO, $membershipType);
            $membershipTypes[$membershipTypeBAO->id] = $membershipType;
        }
    } else {
        return civicrm_create_error('Exact match not found');
    }
    return $membershipTypes;
}
コード例 #19
0
/**
 * Deletes an existing Participant Payment
 *
 * This API is used for deleting a Participant Payment
 *
 * @param  Int  $participantPaymentID   Id of the Participant Payment to be deleted
 *
 * @return null if successfull, array with is_error=1 otherwise
 * @access public
 */
function civicrm_participant_payment_delete(&$params)
{
    _civicrm_initialize();
    if (!is_array($params)) {
        $error = civicrm_create_error('Params is not an array');
        return $error;
    }
    if (!CRM_Utils_Array::value('id', $params)) {
        $error = civicrm_create_error('Invalid or no value for Participant payment ID');
        return $error;
    }
    require_once 'CRM/Event/BAO/ParticipantPayment.php';
    $participant = new CRM_Event_BAO_ParticipantPayment();
    return $participant->deleteParticipantPayment($params) ? civicrm_create_success() : civicrm_create_error('Error while deleting participantPayment');
}
コード例 #20
0
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;
}
コード例 #21
0
/**
 * Delete uf field
 *
 * @param $fieldId int  Valid uf_field id that to be deleted
 *
 * @return true on successful delete or return error
 *
 * @access public
 *
 */
function civicrm_uf_field_delete($fieldId)
{
    _civicrm_initialize();
    if (!isset($fieldId)) {
        return civicrm_create_error("provide a valid fieldId.");
    }
    require_once 'CRM/Core/BAO/UFField.php';
    return CRM_Core_BAO_UFField::del($fieldId);
}
コード例 #22
0
ファイル: Note.php プロジェクト: ksecor/civicrm
/**
 * Retrieve a specific note, given a set of input params
 *
 * @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_note_get(&$params)
{
    _civicrm_initialize();
    $values = array();
    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'));
    }
    if (!is_numeric($params['entity_id'])) {
        return civicrm_create_error(ts("Invalid entity ID"));
    }
    if (!isset($params['entity_id']) && !isset($params['entity_table'])) {
        return civicrm_create_error('Required parameters missing.');
    }
    $note = CRM_Core_BAO_Note::getNote($params['entity_id'], $params['entity_table']);
    if (civicrm_error($note)) {
        return $note;
    }
    if (count($note) < 1) {
        return civicrm_create_error(ts('%1 notes matching the input parameters', array(1 => count($note))));
    }
    $note = array_values($note);
    $note['is_error'] = 0;
    return $note;
}
コード例 #23
0
/**
 * @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;
}
コード例 #24
0
/**
 * Use this API to delete an existing custom group field.
 *
 * @param $params     Array id of the field to be deleted
 *
 *       
 * @access public
 **/
function civicrm_custom_field_delete($params)
{
    _civicrm_initialize();
    if (!is_array($params)) {
        return civicrm_create_error('Params is not an array');
    }
    if (!CRM_Utils_Array::value('customFieldId', $params['result'])) {
        return civicrm_create_error('Invalid or no value for Custom Field ID');
    }
    require_once 'CRM/Core/DAO/CustomField.php';
    $field = new CRM_Core_DAO_CustomField();
    $field->id = $params['result']['customFieldId'];
    $field->find(true);
    require_once 'CRM/Core/BAO/CustomField.php';
    $customFieldDelete = CRM_Core_BAO_CustomField::deleteField($field);
    return $customFieldDelete ? civicrm_create_error('Error while deleting custom field') : civicrm_create_success();
}
コード例 #25
0
ファイル: Tag.php プロジェクト: ksecor/civicrm
/**
 * 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;
}
コード例 #26
0
/**
 * 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());
    }
}
コード例 #27
0
/**
 * 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;
}
コード例 #28
0
/**
 * Retrieve a set of pledges, given a set of input params
 *
 * @param  array   $params           (reference ) input parameters. Use interogate for possible fields
 *
 * @return array (reference )        array of pledges, if error an array with an error id and error message
 * @static void
 * @access public
 */
function &civicrm_pledge_get(&$params)
{
    _civicrm_initialize();
    if (!is_array($params)) {
        return civicrm_create_error('Input parameters is not an array');
    }
    $inputParams = array();
    $returnProperties = array();
    $otherVars = array('sort', 'offset', 'rowCount');
    $sort = NULL;
    $offset = 0;
    $rowCount = 25;
    foreach ($params as $n => $v) {
        if (substr($n, 0, 7) == 'return.') {
            $returnProperties[substr($n, 7)] = $v;
        } elseif (in_array($n, $otherVars)) {
            ${$n} = $v;
        } else {
            $inputParams[$n] = $v;
        }
    }
    // add is_test to the clause if not present
    if (!array_key_exists('pledge_test', $inputParams)) {
        $inputParams['pledge_test'] = 0;
    }
    require_once 'CRM/Pledge/BAO/Query.php';
    require_once 'CRM/Contact/BAO/Query.php';
    if (empty($returnProperties)) {
        $returnProperties = CRM_Pledge_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_PLEDGE);
    } else {
        $returnProperties['pledge_id'] = 1;
    }
    $newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams);
    $query = new CRM_Contact_BAO_Query($newParams, $returnProperties, NULL);
    list($select, $from, $where) = $query->query();
    $sql = "{$select} {$from} {$where}";
    if (!empty($sort)) {
        $sql .= " ORDER BY {$sort} ";
    }
    $sql .= " LIMIT {$offset}, {$rowCount} ";
    $dao = CRM_Core_DAO::executeQuery($sql);
    $pledge = array();
    while ($dao->fetch()) {
        if ($params['sequential']) {
            $pledge[] = $query->store($dao);
        } else {
            $pledge[$dao->pledge_id] = $query->store($dao);
        }
    }
    $dao->free();
    return $pledge;
}
コード例 #29
0
ファイル: GroupOrganization.php プロジェクト: bhirsch/voipdev
/**
 * Deletes an existing Group Organization
 * 
 * This API is used for deleting a Group Organization
 * 
 * @param  Array  $params  ID of the Group Organization to be deleted
 * 
 * @return null if successfull, array with is_error = 1 otherwise
 * @access public
 */
function civicrm_group_organization_remove(&$params)
{
    _civicrm_initialize();
    if (!is_array($params)) {
        $error = civicrm_create_error('Input parameter is not an array');
        return $error;
    }
    if (empty($params)) {
        return civicrm_create_error('No input parameter present');
    }
    if (!CRM_Utils_Array::value('id', $params)) {
        $error = civicrm_create_error('Invalid or no value for Group Organization ID');
        return $error;
    }
    require_once 'CRM/Contact/BAO/GroupOrganization.php';
    $result = CRM_Contact_BAO_GroupOrganization::delete($params);
    return $result ? civicrm_create_success(ts('Deleted Group Organization successfully')) : civicrm_create_error(ts('Could not delete Group Organization'));
}
コード例 #30
0
/**
 *
 * @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;
}