本文整理汇总了PHP中_civicrm_object_to_array函数的典型用法代码示例。如果您正苦于以下问题:PHP _civicrm_object_to_array函数的具体用法?PHP _civicrm_object_to_array怎么用?PHP _civicrm_object_to_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_civicrm_object_to_array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _civicrm_initialize
/**
* 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;
}
示例2: civicrm_event_create
/**
* 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;
}
示例3: civicrm_event_create
/**
* 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());
}
}
示例4: civicrm_group_nesting_get
/**
* 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;
}
示例5: civicrm_domain_create
/**
* 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;
}
示例6: civicrm_activity_type_create
/**
* 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;
}
示例7: _civicrm_initialize
/**
* 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;
}
示例8: _civicrm_initialize
/**
* 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;
}
示例9: _civicrm_initialize
/**
* 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');
}
示例10: _civicrm_initialize
/**
* 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;
}
示例11: civicrm_membership_contact_create
/**
* 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;
}
示例12: civicrm_custom_group_create
/**
* 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;
}
示例13: _civicrm_activity_get
/**
* 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;
}
}
示例14: _civicrm_initialize
/**
* 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;
}
示例15: _civicrm_initialize
/**
* 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;
}