本文整理汇总了PHP中CRM_Activity_BAO_Activity::_exportableFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Activity_BAO_Activity::_exportableFields方法的具体用法?PHP CRM_Activity_BAO_Activity::_exportableFields怎么用?PHP CRM_Activity_BAO_Activity::_exportableFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Activity_BAO_Activity
的用法示例。
在下文中一共展示了CRM_Activity_BAO_Activity::_exportableFields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Get the exportable fields for Activities
*
* @return array array of exportable Fields
* @access public
*/
function &exportableFields()
{
if (!self::$_exportableFields) {
if (!self::$_exportableFields) {
self::$_exportableFields = array();
}
// TO DO, ideally we should retrieve all fields from xml, in this case since activity processing is done
// my case hence we have defined fields as case_*
//require_once 'CRM/Activity/DAO/Activity.php';
//$fields = CRM_Activity_DAO_Acivity::export( );
//set title to activity fields
$fields = array('case_subject' => array('title' => ts('Activity Subject'), 'type' => CRM_Utils_Type::T_STRING), 'case_source_contact_id' => array('title' => ts('Activity Reporter'), 'type' => CRM_Utils_Type::T_STRING), 'case_recent_activity_date' => array('title' => ts('Activity Actual Date'), 'type' => CRM_Utils_Type::T_DATE), 'case_scheduled_activity_date' => array('title' => ts('Activity Scheduled Date'), 'type' => CRM_Utils_Type::T_DATE), 'case_recent_activity_type' => array('title' => ts('Activity Type'), 'type' => CRM_Utils_Type::T_INT), 'case_activity_status_id' => array('title' => ts('Activity Status'), 'type' => CRM_Utils_Type::T_INT), 'case_activity_duration' => array('title' => ts('Activity Duration'), 'type' => CRM_Utils_Type::T_INT), 'case_activity_medium_id' => array('title' => ts('Activity Medium'), 'type' => CRM_Utils_Type::T_INT), 'case_activity_details' => array('title' => ts('Activity Details'), 'type' => CRM_Utils_Type::T_TEXT), 'case_activity_is_auto' => array('title' => ts('Activity Auto-generated?'), 'type' => CRM_Utils_Type::T_BOOLEAN));
// add custom data for case activities
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Activity'));
self::$_exportableFields = $fields;
}
return self::$_exportableFields;
}
示例2: petitionemail_create_custom_fields
/**
* Create the custom fields used to record subject and body
*
*/
function petitionemail_create_custom_fields()
{
$group = 'petitionemail';
$key = 'petitionemail_custom_message_fields';
$ret = CRM_Core_BAO_Setting::getItem($group, $key);
if (!empty($ret)) {
// Ensure it exists
$sql = "SELECT id FROM civicrm_custom_group WHERE id = %0";
$dao = CRM_Core_DAO::executeQuery($sql, array(0 => array($ret, 'Integer')));
$dao->fetch();
if ($dao->N == 1) {
return $ret;
}
// Delete this variable - probably the user deleted the profile not knowing
// what it was used for.
$sql = "DELETE FROM civicrm_setting WHERE group_name = %0 AND name = %1";
$params = array(0 => array($group, 'String'), 1 => array($key, 'String'));
CRM_Core_DAO::executeQuery($sql, $params);
}
// Get the value of the petition activity id so our custom group
// will only extend Activities of type Petition.
$sql = "SELECT v.value FROM civicrm_option_group g JOIN \n civicrm_option_value v ON g.id = v.option_group_id WHERE g.name = 'activity_type'\n AND v.name = 'petition'";
$dao = CRM_Core_DAO::executeQuery($sql);
$dao->fetch();
if ($dao->N > 0) {
$activity_type_id = $dao->value;
$params = array('version' => 3, 'name' => 'PetitionEmailMessageFields', 'title' => 'Petition Email Message Fields', 'extends' => 'Activity', 'extends_entity_column_value' => array($activity_type_id), 'style' => 'Inline', 'collapse_display' => 1, 'is_active' => 1, 'api.custom_field.create' => array(array('custom_group_id' => '$value.id', 'label' => 'Custom Message', 'name' => 'Petition_Email_Custom_Message', 'data_type' => 'Memo', 'html_type' => 'TextArea', 'is_required' => 0, 'is_searchable' => 0, 'is_active' => 1), array('custom_group_id' => '$value.id', 'label' => 'Custom Subject', 'name' => 'Petition_Email_Custom_Subject', 'data_type' => 'String', 'html_type' => 'Text', 'is_required' => 0, 'is_searchable' => 0, 'is_active' => 1)));
try {
$results = civicrm_api3('CustomGroup', 'create', $params);
} catch (CiviCRM_API3_Exception $e) {
$session = CRM_Core_Session::singleton();
$session->setStatus(ts("Error creating the petition custom fields."));
$session->setStatus($e->getMessage());
return FALSE;
}
$values = array_pop($results['values']);
$id = $values['id'];
CRM_Core_BAO_Setting::setItem($id, $group, $key);
// Start complex process for clearing the cache of available fields.
// We need to clear the cache so that when we create a profile that
// depends on these fields, we won't get an error that it's an invalid field.
// First clear the static array of exportableFields which is used to determine
// if a field is valid when being used in a profile.
CRM_Activity_BAO_Activity::$_exportableFields = NULL;
// Next clear the cache so we don't pull from an already populated cache.
CRM_Utils_System::flushCache();
// Lastly, we have to call the function that is called to validate fields,
// but specifying that we want to force the re-fecthing of fields to unset
// yet another static variable.
CRM_Core_BAO_UFField::getAvailableFieldsFlat(TRUE);
return $id;
}
return FALSE;
}