本文整理汇总了PHP中civicrm_api3_verify_one_mandatory函数的典型用法代码示例。如果您正苦于以下问题:PHP civicrm_api3_verify_one_mandatory函数的具体用法?PHP civicrm_api3_verify_one_mandatory怎么用?PHP civicrm_api3_verify_one_mandatory使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了civicrm_api3_verify_one_mandatory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: civicrm_api3_membership_status_create
/**
* Create a Membership Status
*
* This API is used for creating a Membership Status
*
* @param array $params an associative array of name/value property values of civicrm_membership_status
*
* @return array of newly created membership status property values.
* {@getfields MembershipStatus_create}
* @access public
*/
function civicrm_api3_membership_status_create($params)
{
civicrm_api3_verify_one_mandatory($params, 'CRM_Member_DAO_MembershipStatus', array('name', 'label'));
//move before verifiy? DAO check requires?
if (empty($params['name'])) {
$params['name'] = CRM_Utils_Array::value('label', $params);
}
//don't allow duplicate names.
require_once 'CRM/Member/DAO/MembershipStatus.php';
$status = new CRM_Member_DAO_MembershipStatus();
$status->name = $params['name'];
if ($status->find(TRUE)) {
return civicrm_api3_create_error(ts('A membership status with this name already exists.'));
}
require_once 'CRM/Member/BAO/MembershipStatus.php';
$ids = array();
$membershipStatusBAO = CRM_Member_BAO_MembershipStatus::add($params, $ids);
if (is_a($membershipStatusBAO, 'CRM_Core_Error')) {
return civicrm_api3_create_error("Membership is not created");
} else {
$values = array();
$values['id'] = $membershipStatusBAO->id;
$values['is_error'] = 0;
return civicrm_api3_create_success($values, $params);
}
}
示例2: civicrm_api3_action_schedule_create
/**
* Create a new ActionSchedule.
*
* @param array $params
*
* @return array
*/
function civicrm_api3_action_schedule_create($params)
{
civicrm_api3_verify_one_mandatory($params, NULL, array('start_action_date', 'absolute_date'));
if (!array_key_exists('name', $params) && !array_key_exists('id', $params)) {
$params['name'] = CRM_Utils_String::munge($params['title']);
}
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'ActionSchedule');
}
示例3: civicrm_api3_dashboard_contact_create
/**
* Creates/Updates a new Dashboard Contact Entry.
*
* @param array $params
*
* @return array
*/
function civicrm_api3_dashboard_contact_create($params)
{
if (empty($params['id'])) {
civicrm_api3_verify_one_mandatory($params, NULL, array('dashboard_id'));
}
$errors = _civicrm_api3_dashboard_contact_check_params($params);
if ($errors !== NULL) {
return $errors;
}
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
示例4: civicrm_api3_event_create
/**
* Create a Event
*
* This API is used for creating a Event
*
* @param array $params input parameters
* Allowed @params array keys are:
* {@getfields event_create}
*
* @return array API result Array.
* @access public
*/
function civicrm_api3_event_create($params)
{
civicrm_api3_verify_one_mandatory($params, NULL, array('event_type_id', 'template_id'));
// Clone event from template
if (!empty($params['template_id']) && empty($params['id'])) {
$copy = CRM_Event_BAO_Event::copy($params['template_id']);
$params['id'] = $copy->id;
unset($params['template_id']);
}
_civicrm_api3_event_create_legacy_support_42($params);
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Event');
}
示例5: civicrm_api3_dashboard_create
/**
* Creates or updates an Dashlet.
*
* @param array $params Associative array of property name/value
* pairs for the Dashlet.
*
* @return array Array containing 'is_error' to denote success or failure and details of the created activity
*
*/
function civicrm_api3_dashboard_create($params)
{
if (empty($params['id'])) {
civicrm_api3_verify_one_mandatory($params, NULL, array('name', 'label', 'url', 'fullscreen_url'));
}
// create dashboard element
$dashboardBAO = CRM_Core_BAO_Dashboard::addDashlet($params);
if (isset($dashboardBAO->id)) {
_civicrm_api3_object_to_array($dashboardBAO, $dashboardArray[$dashboardBAO->id]);
return civicrm_api3_create_success($dashboardArray, $params, 'dashboard', 'create', $dashboardBAO);
}
}
示例6: civicrm_api3_uf_field_create
/**
* Defines 'uf field' within a group.
*
* @param array $params
* Array per getfields metadata.
*
* @throws API_Exception
*
* @return array
* Newly created $ufFieldArray
*/
function civicrm_api3_uf_field_create($params)
{
civicrm_api3_verify_one_mandatory($params, NULL, array('field_name', 'uf_group_id'));
$groupId = CRM_Utils_Array::value('uf_group_id', $params);
if ((int) $groupId < 1) {
throw new API_Exception('Params must be a field_name-carrying array and a positive integer.');
}
$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, CRM_Utils_Array::value('website_type_id', $params));
$phone_type = CRM_Utils_Array::value('phone_type_id', $params, CRM_Utils_Array::value('phone_type', $params));
if (!CRM_Core_BAO_UFField::isValidFieldName($field_name)) {
throw new API_Exception('The field_name is not valid');
}
$params['field_name'] = array($field_type, $field_name, $location_type_id, $phone_type);
if (!CRM_Utils_Array::value('group_id', $params)) {
$params['group_id'] = $groupId;
}
$ids = $ufFieldArray = array();
$ids['uf_group'] = $groupId;
$fieldId = CRM_Utils_Array::value('id', $params);
if (!empty($fieldId)) {
$UFField = new CRM_Core_BAO_UFField();
$UFField->id = $fieldId;
if ($UFField->find(TRUE)) {
$ids['uf_group'] = $UFField->uf_group_id;
if (!CRM_Utils_Array::value('group_id', $params)) {
// this copied here from previous api function - not sure if required
$params['group_id'] = $UFField->uf_group_id;
}
} else {
throw new API_Exception("there is no field for this fieldId");
}
$ids['uf_field'] = $fieldId;
}
if (CRM_Core_BAO_UFField::duplicateField($params, $ids)) {
throw new API_Exception("The field was not added. It already exists in this profile.");
}
//@todo why is this even optional? Surely weight should just be 'managed' ??
if (CRM_Utils_Array::value('option.autoweight', $params, TRUE)) {
$params['weight'] = CRM_Core_BAO_UFField::autoWeight($params);
}
$ufField = CRM_Core_BAO_UFField::add($params, $ids);
$fieldsType = CRM_Core_BAO_UFGroup::calculateGroupType($groupId, TRUE);
CRM_Core_BAO_UFGroup::updateGroupTypes($groupId, $fieldsType);
_civicrm_api3_object_to_array($ufField, $ufFieldArray[$ufField->id]);
civicrm_api3('profile', 'getfields', array('cache_clear' => TRUE));
return civicrm_api3_create_success($ufFieldArray, $params);
}
示例7: civicrm_api3_verify_one_mandatory
/**
* Get the list of voters (respondents, yet to record survey response) for a survey
*
* @param array $params (reference ) input parameters
*
* @return array (reference ) contact_id
* @static void
* @access public
*/
function &civicrm_api3_survey_voter_get($params)
{
civicrm_api3_verify_one_mandatory($params, 'CRM_Campaign_BAO_Survey', array('survey_id', 'id'));
if (array_key_exists('status_id', $params)) {
$status_id = $params['status_id'];
} else {
$status_id = null;
}
$surveyID = empty($params['survey_id']) ? $params['id'] : $params['survey_id'];
require_once 'CRM/Campaign/BAO/Survey.php';
$survey = new CRM_Campaign_BAO_Survey();
$voters = $survey->getSurveyVoterInfo($surveyID);
require_once 'CRM/Contact/BAO/Contact.php';
foreach ($voters as $key => $voterArray) {
$voters[$key]['voter_name'] = CRM_Contact_BAO_Contact::displayName($voterArray['voter_id']);
}
return civicrm_api3_create_success($voters, $params);
}
示例8: civicrm_api3_action_schedule_create
/**
* Create a new Action Schedule
*
* @param array $params
*
* @return array
*
* {@getfields action_schedule_create}
*/
function civicrm_api3_action_schedule_create($params)
{
if (empty($params['id'])) {
// an update does not require any mandatory parameters
civicrm_api3_verify_one_mandatory($params, NULL, array('title', 'mapping_id', 'entity_status', 'entity_value'));
}
$ids = array();
if (isset($params['id']) && !CRM_Utils_Rule::integer($params['id'])) {
return civicrm_api3_create_error('Invalid value for ID');
}
if (!array_key_exists('name', $params) && !array_key_exists('id', $params)) {
$params['name'] = CRM_Utils_String::munge($params['title']);
}
$actionSchedule = new CRM_Core_BAO_ActionSchedule();
$actionSchedule = CRM_Core_BAO_ActionSchedule::add($params, $ids);
$actSchedule = array();
_civicrm_api3_object_to_array($actionSchedule, $actSchedule[$actionSchedule->id]);
return civicrm_api3_create_success($actSchedule, $params, 'action_schedule', 'create', $actionSchedule);
}
示例9: civicrm_api3_survey_respondant_get
/**
* Get the list of signatories.
*
* @deprecated - api currently not supported
*
* @param array $params
* input parameters.
*
* @return array
*/
function civicrm_api3_survey_respondant_get(&$params)
{
civicrm_api3_verify_one_mandatory($params, NULL, array('survey_id', 'id'));
if (array_key_exists('survey_id', $params)) {
$surveyID = $params['survey_id'];
} else {
$surveyID = $params['id'];
}
$interviewerID = NULL;
if (array_key_exists('interviewer_id', $params)) {
$interviewerID = $params['interviewer_id'];
}
$statusIds = array();
if (array_key_exists('status_id', $params)) {
$statusIds = explode(',', $params['status_id']);
}
$respondants = CRM_Campaign_BAO_Survey::getSurveyActivities($surveyID, $interviewerID, $statusIds);
return civicrm_api3_create_success($respondants, $params, 'SurveyRespondant', 'get');
}
示例10: civicrm_api3_entity_tag_display
/**
*
* @param <type> $params
*
* @return <type>
* @todo EM 7 Jan 2011 - believe this should be deleted
* @deprecated
*/
function civicrm_api3_entity_tag_display($params)
{
civicrm_api3_verify_one_mandatory($params, NULL, array('entity_id', 'contact_id'));
$entityID = NULL;
$entityTable = 'civicrm_contact';
if (!($entityID = CRM_Utils_Array::value('entity_id', $params))) {
$entityID = CRM_Utils_Array::value('contact_id', $params);
}
if (CRM_Utils_Array::value('entity_table', $params)) {
$entityTable = $params['entity_table'];
}
require_once 'CRM/Core/BAO/EntityTag.php';
$values = CRM_Core_BAO_EntityTag::getTag($entityID, $entityTable);
$result = array();
$tags = CRM_Core_PseudoConstant::tag();
foreach ($values as $v) {
$result[] = $tags[$v];
}
return implode(',', $result);
}
示例11: civicrm_api3_saved_search_create
/**
* Create or update a saved search.
*
* @param array $params
* Associative array of property name-value pairs to insert in new saved search.
* @example SavedSearch/Create.php Std create example.
* @return array api result array
* {@getfields saved_search_create}
* @access public
*/
function civicrm_api3_saved_search_create($params)
{
civicrm_api3_verify_one_mandatory($params, NULL, array('form_values', 'where_clause'));
// The create function of the dao expects a 'formValues' that is
// not serialized. The get function returns form_values, that is
// serialized.
// So for the create API, I guess it should work for serialized and
// unserialized form_values.
if (isset($params["form_values"])) {
if (is_array($params["form_values"])) {
$params["formValues"] = $params["form_values"];
} else {
// Assume that form_values is serialized.
$params["formValues"] = unserialize($params["form_values"]);
}
}
$result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
_civicrm_api3_saved_search_result_cleanup($result);
return $result;
}
示例12: civicrm_api3_uf_field_create
/**
* Defines 'uf field' within a group.
*
* @param $groupId int Valid uf_group id
*
* @param $params array Associative array of property name/value pairs to create new uf field.
*
* @return Newly created $ufFieldArray array
*
* @access public
* {@getfields UFField_create}
* @example UFFieldCreate.php
*/
function civicrm_api3_uf_field_create($params)
{
civicrm_api3_verify_one_mandatory($params, NULL, array('field_name', 'uf_group_id'));
$groupId = CRM_Utils_Array::value('uf_group_id', $params);
if ((int) $groupId < 1) {
return civicrm_api3_create_error('Params must be a field_name-carrying array and a positive integer.');
}
$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);
if (!CRM_Utils_Array::value('group_id', $params)) {
$params['group_id'] = $groupId;
}
$ids = array();
$ids['uf_group'] = $groupId;
$fieldId = CRM_Utils_Array::value('id', $params);
if (!empty($fieldId)) {
$UFField = new CRM_core_BAO_UFField();
$UFField->id = $fieldId;
if ($UFField->find(TRUE)) {
$ids['uf_group'] = $UFField->uf_group_id;
if (!CRM_Utils_Array::value('group_id', $params)) {
// this copied here from previous api function - not sure if required
$params['group_id'] = $UFField->uf_group_id;
}
} else {
return civicrm_api3_create_error("there is no field for this fieldId");
}
$ids['uf_field'] = $fieldId;
}
if (CRM_Core_BAO_UFField::duplicateField($params, $ids)) {
return civicrm_api3_create_error("The field was not added. It already exists in this profile.");
}
$ufField = CRM_Core_BAO_UFField::add($params, $ids);
$fieldsType = CRM_Core_BAO_UFGroup::calculateGroupType($groupId, TRUE);
CRM_Core_BAO_UFGroup::updateGroupTypes($groupId, $fieldsType);
_civicrm_api3_object_to_array($ufField, $ufFieldArray[$ufField->id]);
return civicrm_api3_create_success($ufFieldArray, $params);
}
示例13: civicrm_api3_event_create
/**
* Create a Event
*
* This API is used for creating a Event
*
* @param array $params input parameters
* Allowed @params array keys are:
* {@getfields event_create}
*
* @return array API result Array.
* @access public
*/
function civicrm_api3_event_create($params)
{
civicrm_api3_verify_one_mandatory($params, NULL, array('event_type_id', 'template_id'));
// Clone event from template
if (!empty($params['template_id']) && empty($params['id'])) {
$copy = CRM_Event_BAO_Event::copy($params['template_id']);
$params['id'] = $copy->id;
unset($params['template_id']);
if (empty($params['is_template'])) {
$params['is_template'] = 0;
}
}
_civicrm_api3_event_create_legacy_support_42($params);
//format custom fields so they can be added
$values = array();
_civicrm_api3_custom_format_params($params, $values, 'Event');
$params = array_merge($values, $params);
$eventBAO = CRM_Event_BAO_Event::create($params);
$event = array();
_civicrm_api3_object_to_array($eventBAO, $event[$eventBAO->id]);
return civicrm_api3_create_success($event, $params);
}
示例14: civicrm_api3_loc_block_create
/**
* Create or update a LocBlock.
*
* @param array $params
* Name/value pairs to insert in new 'LocBlock'.
*
* @return array
* API result array.
*
* @throws \API_Exception
*/
function civicrm_api3_loc_block_create($params)
{
$entities = array();
$any_mandatory = array('address', 'address_id', 'phone', 'phone_id', 'im', 'im_id', 'email', 'email_id');
civicrm_api3_verify_one_mandatory($params, NULL, $any_mandatory);
// Call the appropriate api to create entities if any are passed in the params.
// This is basically chaining but in reverse - we create the sub-entities first
// because chaining does not work in reverse, or with keys like 'email_2'.
$items = array('address', 'email', 'phone', 'im');
foreach ($items as $item) {
foreach (array('', '_2') as $suf) {
$key = $item . $suf;
if (!empty($params[$key]) && is_array($params[$key])) {
$info = $params[$key];
// If all we get is an id don't bother calling the api.
if (count($info) == 1 && !empty($info['id'])) {
$params[$key . '_id'] = $info['id'];
} else {
$info['contact_id'] = CRM_Utils_Array::value('contact_id', $info, 'null');
$result = civicrm_api3($item, 'create', $info);
$entities[$key] = $result['values'][$result['id']];
$params[$key . '_id'] = $result['id'];
}
}
}
}
$dao = new CRM_Core_DAO_LocBlock();
$dao->copyValues($params);
$dao->save();
if (!empty($dao->id)) {
$values = array($dao->id => $entities);
_civicrm_api3_object_to_array($dao, $values[$dao->id]);
return civicrm_api3_create_success($values, $params, 'LocBlock', 'create', $dao);
}
throw new API_Exception('Unable to create LocBlock. Please check your params.');
}
示例15: civicrm_api3_contribution_recur_cancel
/**
* Cancel a recurring contribution of existing ContributionRecur given its id.
*
* @param array $params
* Array containing id of the recurring contribution.
*
* @return bool
* returns true is successfully cancelled
*/
function civicrm_api3_contribution_recur_cancel($params)
{
civicrm_api3_verify_one_mandatory($params, NULL, array('id'));
return CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution($params['id'], CRM_Core_DAO::$_nullObject) ? civicrm_api3_create_success() : civicrm_api3_create_error(ts('Error while cancelling recurring contribution'));
}