当前位置: 首页>>代码示例>>PHP>>正文


PHP civicrm_create_success函数代码示例

本文整理汇总了PHP中civicrm_create_success函数的典型用法代码示例。如果您正苦于以下问题:PHP civicrm_create_success函数的具体用法?PHP civicrm_create_success怎么用?PHP civicrm_create_success使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了civicrm_create_success函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: civicrm_membership_delete

/**
 * 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');
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:22,代码来源:Membership.php

示例2: civicrm_activity_contact_get

/**
 * 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'));
    }
}
开发者ID:ksecor,项目名称:civicrm,代码行数:25,代码来源:ActivityContact.php

示例3: civicrm_activity_contact_get

/**
 * 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'));
    }
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:30,代码来源:ActivityContact.php

示例4: civicrm_tag_delete

/**
 * 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());
    }
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:24,代码来源:Tag.php

示例5: civicrm_pledge_delete

/**
 * Delete a pledge
 *
 * @param  array   $params           array included 'pledge_id' of pledge to delete
 *
 * @return boolean        true if success, else false
 * @static void
 * @access public
 */
function civicrm_pledge_delete(&$params)
{
    if (!empty($params['id'])) {
        //handle field name or unique db name
        $params['pledge_id'] = $params['id'];
    }
    $pledgeID = CRM_Utils_Array::value('pledge_id', $params);
    if (!$pledgeID) {
        return civicrm_create_error('Could not find pledge_id in input parameters');
    }
    require_once 'CRM/Pledge/BAO/Pledge.php';
    if (CRM_Pledge_BAO_Pledge::deletePledge($pledgeID)) {
        return civicrm_create_success();
    } else {
        return civicrm_create_error('Could not delete pledge');
    }
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:26,代码来源:Pledge.php

示例6: civicrm_contact_relationship_get

/**
 * Function to get the relationship
 *
 * @param array   $contact_a          (reference ) input parameters.
 * @param array   $contact_b          (reference ) input parameters.
 * @param array   $relationshipTypes  an array of Relationship Type Name.
 * @param string  $sort               sort all relationship by relationshipId (eg asc/desc)
 *
 * @return        Array of all relationship.
 *
 * @access  public
 */
function civicrm_contact_relationship_get($contact_a, $contact_b = NULL, $relationshipTypes = NULL, $sort = NULL)
{
    if (!is_array($contact_a)) {
        return civicrm_create_error(ts('Input parameter is not an array'));
    }
    if (!isset($contact_a['contact_id'])) {
        return civicrm_create_error(ts('Could not find contact_id in input parameters.'));
    }
    require_once 'CRM/Contact/BAO/Relationship.php';
    $contactID = $contact_a['contact_id'];
    $relationships = CRM_Contact_BAO_Relationship::getRelationship($contactID);
    if (!empty($relationshipTypes)) {
        $result = array();
        foreach ($relationshipTypes as $relationshipName) {
            foreach ($relationships as $key => $relationship) {
                if ($relationship['relation'] == $relationshipName) {
                    $result[$key] = $relationship;
                }
            }
        }
        $relationships = $result;
    }
    if (isset($contact_b['contact_id'])) {
        $cid = $contact_b['contact_id'];
        $result = array();
        foreach ($relationships as $key => $relationship) {
            if ($relationship['cid'] == $cid) {
                $result[$key] = $relationship;
            }
        }
        $relationships = $result;
    }
    //sort by relationship id
    if ($sort) {
        if (strtolower($sort) == 'asc') {
            ksort($relationships);
        } elseif (strtolower($sort) == 'desc') {
            krsort($relationships);
        }
    }
    //handle custom data.
    require_once 'CRM/Core/BAO/CustomGroup.php';
    foreach ($relationships as $relationshipId => $values) {
        $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Relationship', CRM_Core_DAO::$_nullObject, $relationshipId, FALSE, $values['civicrm_relationship_type_id']);
        $formatTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, CRM_Core_DAO::$_nullObject);
        $defaults = array();
        CRM_Core_BAO_CustomGroup::setDefaults($formatTree, $defaults);
        if (!empty($defaults)) {
            foreach ($defaults as $key => $val) {
                $relationships[$relationshipId][$key] = $val;
            }
        }
    }
    if ($relationships) {
        return civicrm_create_success($relationships);
    } else {
        return civicrm_create_error(ts('Invalid Data'));
    }
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:71,代码来源:Relationship.php

示例7: civicrm_case_delete

/**
 * Delete a specified case.
 *
 * @param  array( //REQUIRED:
 *                  'case_id'           => int
 *
 *                //OPTIONAL
 *                  'move_to_trash'     => bool (defaults to false)
 *
 * @return boolean: true if success, else false
 *
 * @access public
 */
function civicrm_case_delete(&$params)
{
    _civicrm_initialize();
    //check parameters
    $errors = _civicrm_case_check_params($params, 'delete');
    if ($errors) {
        return $errors;
    }
    if (CRM_Case_BAO_Case::deleteCase($params['case_id'], $params['move_to_trash'])) {
        return civicrm_create_success(ts('Case Deleted'));
    } else {
        return civicrm_create_error(ts('Could not delete case.'));
    }
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:27,代码来源:Case.php

示例8: _civicrm_location_update


//.........这里部分代码省略.........
    foreach (array('email', 'phone', 'im', 'openid') as $name) {
        if (CRM_Utils_Array::value($name, $params) && is_array($params[$name])) {
            $blockCount = 0;
            $contact[$name] = array();
            foreach ($params[$name] as $val) {
                $contact[$name][++$blockCount] = $val;
                // check for primary and billing.
                if (CRM_Utils_Array::value('is_primary', $val)) {
                    $primary[$name][$blockCount] = true;
                }
                if (CRM_Utils_Array::value('is_billing', $val)) {
                    $primary[$name][$blockCount] = true;
                }
            }
        } else {
            // get values from db blocks so we dont lose them.
            if (!CRM_Utils_Array::value($name, $locations) || !is_array($locations[$name])) {
                continue;
            }
            $contact[$name] = $locations[$name];
        }
    }
    $addressCount = 1;
    if (CRM_Utils_Array::value(1, $params['address']) && !empty($params['address'][1])) {
        $contact['address'][$addressCount] = $params['address'][1];
        // check for primary and billing address.
        if (CRM_Utils_Array::value('is_primary', $params['address'][1])) {
            $primary['address'][$addressCount] = true;
        }
        if (CRM_Utils_Array::value('is_billing', $params['address'][1])) {
            $billing['address'][$addressCount] = true;
        }
        // format state and country.
        foreach (array('state_province', 'country') as $field) {
            $fName = $field == 'state_province' ? 'stateProvinceAbbreviation' : 'countryIsoCode';
            if (CRM_Utils_Array::value($field, $contact['address'][$addressCount]) && is_numeric($contact['address'][$addressCount][$field])) {
                $fValue =& $contact['address'][$addressCount][$field];
                eval('$fValue = CRM_Core_PseudoConstant::' . $fName . '( $fValue );');
                //kill the reference.
                unset($fValue);
            }
        }
    }
    //handle primary and billing reset.
    foreach (array('email', 'phone', 'im', 'address', 'openid') as $name) {
        if (!array_key_exists($name, $contact) || CRM_Utils_System::isNull($contact[$name])) {
            continue;
        }
        $errorMsg = null;
        $primaryBlockIndex = $billingBlockIndex = 0;
        if (array_key_exists($name, $primary)) {
            if (count($primary[$name]) > 1) {
                $errorMsg .= ts("<br />Multiple Primary %1.", array(1 => $name));
            } else {
                $primaryBlockIndex = key($primary[$name]);
            }
        }
        if (array_key_exists($name, $billing)) {
            if (count($billing[$name]) > 1) {
                $errorMsg .= ts("<br />Multiple Billing %1.", array(1 => $name));
            } else {
                $billingBlockIndex = key($billing[$name]);
            }
        }
        if ($errorMsg) {
            return civicrm_create_error($errorMsg);
        }
        foreach ($contact[$name] as $count => &$values) {
            if ($primaryBlockIndex && $count != $primaryBlockIndex) {
                $values['is_primary'] = false;
            }
            if ($billingBlockIndex && $count != $billingBlockIndex) {
                $values['is_billing'] = false;
            }
            // kill the reference.
            unset($values);
        }
    }
    // get all ids if not present.
    require_once 'CRM/Contact/BAO/Contact.php';
    CRM_Contact_BAO_Contact::resolveDefaults($contact, true);
    $location = CRM_Core_BAO_Location::create($contact);
    if (empty($location)) {
        return civicrm_create_error(ts("Location not created"));
    }
    $locArray = array();
    $blocks = array('address', 'phone', 'email', 'im', 'openid');
    $locationTypeId = null;
    foreach ($blocks as $block) {
        for ($i = 0; $i < count($location[$block]); $i++) {
            $locArray[$block][$i] = $location[$block][$i]->id;
            $locationTypeId = $location[$block][$i]->location_type_id;
        }
    }
    // CRM-4800
    if (3.0 != CRM_Utils_Array::value('version', $params)) {
        $locArray['location_type_id'] = $locationTypeId;
    }
    return civicrm_create_success($locArray);
}
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:Location.php

示例9: civicrm_tag_delete

/**
 * Deletes an existing Tag
 *
 * @param  array  $params
 * 
 * @return boolean | error  true if successfull, error otherwise
 * @access public
 */
function civicrm_tag_delete(&$params)
{
    if (!is_array($params)) {
        return civicrm_create_error(ts('Input parameters is not an array'));
    }
    $tagID = CRM_Utils_Array::value('tag_id', $params);
    if (!$tagID) {
        return civicrm_create_error(ts('Could not find tag_id in input parameters'));
    }
    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'));
}
开发者ID:ksecor,项目名称:civicrm,代码行数:20,代码来源:Tag.php

示例10: civicrm_activity_delete

/**
 * 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'));
    }
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:25,代码来源:Activity.php

示例11: _civicrm_validate_formatted_contact

/**
 * Validate a formatted contact parameter list.
 *
 * @param array $params  Structured parameter list (as in crm_format_params)
 *
 * @return bool|CRM_Core_Error
 * @access public
 */
function _civicrm_validate_formatted_contact(&$params)
{
    /* Look for offending email addresses */
    if (array_key_exists('email', $params)) {
        foreach ($params['email'] as $count => $values) {
            if (!is_array($values)) {
                continue;
            }
            if ($email = CRM_Utils_Array::value('email', $values)) {
                //validate each email
                if (!CRM_Utils_Rule::email($email)) {
                    return civicrm_create_error('No valid email address');
                }
                //check for loc type id.
                if (!CRM_Utils_Array::value('location_type_id', $values)) {
                    return civicrm_create_error('Location Type Id missing.');
                }
            }
        }
    }
    /* Validate custom data fields */
    if (is_array($params['custom'])) {
        foreach ($params['custom'] as $key => $custom) {
            if (is_array($custom)) {
                $valid = CRM_Core_BAO_CustomValue::typecheck($custom['type'], $custom['value']);
                if (!$valid) {
                    return civicrm_create_error('Invalid value for custom field \'' . $custom['name'] . '\'');
                }
                if ($custom['type'] == 'Date') {
                    $params['custom'][$key]['value'] = str_replace('-', '', $params['custom'][$key]['value']);
                }
            }
        }
    }
    return civicrm_create_success(true);
}
开发者ID:ksecor,项目名称:civicrm,代码行数:44,代码来源:utils.php

示例12: civicrm_mailer_event_open

/**
 * Handle an open event
 *
 * @param array $params
 *
 * @return array
 */
function civicrm_mailer_event_open($params)
{
    $errors = _civicrm_mailer_check_params($params, array('event_queue_id'));
    if (!empty($errors)) {
        return $errors;
    }
    $queue = $params['event_queue_id'];
    $success = CRM_Mailing_Event_BAO_Opened::open($queue);
    if (!$success) {
        return civicrm_create_error(ts('mailer open event failed'));
    }
    return civicrm_create_success();
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:20,代码来源:Mailer.php

示例13: civicrm_note_delete

/**
 * Deletes an existing note
 * 
 * This API is used for deleting a note
 * 
 * @param  Int  $noteID   Id of the note to be deleted
 * 
 * @return null
 * @access public
 */
function civicrm_note_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 Note ID');
        return $error;
    }
    $result = new CRM_Core_BAO_Note();
    return $result->del($params['id']) ? civicrm_create_success() : civicrm_create_error('Error while deleting Note');
}
开发者ID:ksecor,项目名称:civicrm,代码行数:24,代码来源:Note.php

示例14: civicrm_custom_field_delete

/**
 * 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();
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:25,代码来源:CustomGroup.php

示例15: civicrm_contribution_delete

/**
 * Delete a contribution
 *
 * @param  array   $params           (reference ) input parameters
 *
 * @return boolean        true if success, else false
 * @static void
 * @access public
 */
function civicrm_contribution_delete(&$params)
{
    $contributionID = CRM_Utils_Array::value('contribution_id', $params);
    if (!$contributionID) {
        return civicrm_create_error(ts('Could not find contribution_id in input parameters'));
    }
    require_once 'CRM/Contribute/BAO/Contribution.php';
    if (CRM_Contribute_BAO_Contribution::deleteContribution($contributionID)) {
        return civicrm_create_success();
    } else {
        return civicrm_create_error(ts('Could not delete contribution'));
    }
}
开发者ID:ksecor,项目名称:civicrm,代码行数:22,代码来源:Contribute.php


注:本文中的civicrm_create_success函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。