本文整理汇总了PHP中CRM_Core_OptionValue类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_OptionValue类的具体用法?PHP CRM_Core_OptionValue怎么用?PHP CRM_Core_OptionValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_OptionValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: civicrm_api3_activity_type_create
/**
* Create activity type.
*
* @param array $params
*
* @return array
* created / updated activity type
*
* @deprecated use the OptionValue api instead
*/
function civicrm_api3_activity_type_create($params)
{
$action = 1;
$groupParams = array('name' => 'activity_type');
if ($optionValueID = CRM_Utils_Array::value('option_value_id', $params)) {
$action = 2;
}
$activityObject = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $action, $optionValueID);
$activityType = array();
_civicrm_api3_object_to_array($activityObject, $activityType[$activityObject->id]);
return civicrm_api3_create_success($activityType, $params, 'activity_type', 'create');
}
示例2: run
function run()
{
CRM_Utils_System::setTitle(ts("Configuration Checklist"));
$this->assign('recentlyViewed', FALSE);
$destination = CRM_Utils_System::url('civicrm/admin/configtask', 'reset=1', FALSE, NULL, FALSE);
$destination = urlencode($destination);
$this->assign('destination', $destination);
CRM_Core_OptionValue::getValues(array('name' => 'from_email_address'), $optionValue);
if (!empty($optionValue)) {
list($id) = array_keys($optionValue);
$this->assign('fromEmailId', $id);
}
return parent::run();
}
示例3: 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;
}
示例4: run
function run()
{
CRM_Utils_System::setTitle(ts("Configuration Checklist"));
$this->assign('recentlyViewed', FALSE);
$destination = CRM_Utils_System::url('civicrm/admin/configtask', 'reset=1', FALSE, NULL, FALSE);
$destination = urlencode($destination);
$this->assign('destination', $destination);
CRM_Core_OptionValue::getValues(array('name' => 'from_email_address'), $optionValue);
if (!empty($optionValue)) {
list($id) = array_keys($optionValue);
$this->assign('fromEmailId', $id);
}
$payPalProId = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType', 'PayPal', 'id', 'name');
if ($payPalProId) {
$this->assign('payPalProId', $payPalProId);
}
return parent::run();
}
示例5: array
static function &longForShortMapping()
{
static $longForShortMapping = null;
if ($longForShortMapping === null) {
$rows = array();
CRM_Core_OptionValue::getValues(array('name' => 'languages'), $rows);
$longForShortMapping = array();
foreach ($rows as $row) {
$longForShortMapping[$row['value']] = $row['name'];
}
// hand-crafted enforced overrides for language variants
$longForShortMapping['zh'] = 'zh_CN';
$longForShortMapping['en'] = 'en_US';
$longForShortMapping['fr'] = 'fr_FR';
$longForShortMapping['pt'] = 'pt_PT';
$longForShortMapping['es'] = 'es_ES';
}
return $longForShortMapping;
}
示例6: array
/**
* @return array
*/
public static function &longForShortMapping()
{
static $longForShortMapping = NULL;
if ($longForShortMapping === NULL) {
$rows = array();
CRM_Core_OptionValue::getValues(array('name' => 'languages'), $rows);
$longForShortMapping = array();
foreach ($rows as $row) {
$longForShortMapping[$row['value']] = $row['name'];
}
// hand-crafted enforced overrides for language variants
// NB: when adding support for a regional override for a new language below, update
// relevant comments in templates/CRM/common/civicrm.settings.php.template as well
$longForShortMapping['zh'] = defined("CIVICRM_LANGUAGE_MAPPING_ZH") ? CIVICRM_LANGUAGE_MAPPING_ZH : 'zh_CN';
$longForShortMapping['en'] = defined("CIVICRM_LANGUAGE_MAPPING_EN") ? CIVICRM_LANGUAGE_MAPPING_EN : 'en_US';
$longForShortMapping['fr'] = defined("CIVICRM_LANGUAGE_MAPPING_FR") ? CIVICRM_LANGUAGE_MAPPING_FR : 'fr_FR';
$longForShortMapping['pt'] = defined("CIVICRM_LANGUAGE_MAPPING_PT") ? CIVICRM_LANGUAGE_MAPPING_PT : 'pt_PT';
$longForShortMapping['es'] = defined("CIVICRM_LANGUAGE_MAPPING_ES") ? CIVICRM_LANGUAGE_MAPPING_ES : 'es_ES';
}
return $longForShortMapping;
}
示例7: array
/**
* Combine all the exportable fields from the lower levels object.
*
* Currently we are using importable fields as exportable fields
*
* @param int|string $contactType contact Type
* @param bool $status
* True while exporting primary contacts.
* @param bool $export
* True when used during export.
* @param bool $search
* True when used during search, might conflict with export param?.
*
* @param bool $withMultiRecord
*
* @return array
* array of exportable Fields
*/
public static function &exportableFields($contactType = 'Individual', $status = FALSE, $export = FALSE, $search = FALSE, $withMultiRecord = FALSE)
{
if (empty($contactType)) {
$contactType = 'All';
}
$cacheKeyString = "exportableFields {$contactType}";
$cacheKeyString .= $export ? '_1' : '_0';
$cacheKeyString .= $status ? '_1' : '_0';
$cacheKeyString .= $search ? '_1' : '_0';
//CRM-14501 it turns out that the impact of permissioning here is sometimes inconsistent. The field that
//calculates custom fields takes into account the logged in user & caches that for all users
//as an interim fix we will cache the fields by contact
$cacheKeyString .= '_' . CRM_Core_Session::getLoggedInContactID();
if (!self::$_exportableFields || !CRM_Utils_Array::value($cacheKeyString, self::$_exportableFields)) {
if (!self::$_exportableFields) {
self::$_exportableFields = array();
}
// check if we can retrieve from database cache
$fields = CRM_Core_BAO_Cache::getItem('contact fields', $cacheKeyString);
if (!$fields) {
$fields = CRM_Contact_DAO_Contact::export();
// The fields are meant for contact types.
if (in_array($contactType, array('Individual', 'Household', 'Organization', 'All'))) {
$fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType));
}
// add current employer for individuals
$fields = array_merge($fields, array('current_employer' => array('name' => 'organization_name', 'title' => ts('Current Employer'))));
$locationType = array('location_type' => array('name' => 'location_type', 'where' => 'civicrm_location_type.name', 'title' => ts('Location Type')));
$IMProvider = array('im_provider' => array('name' => 'im_provider', 'where' => 'civicrm_im.provider_id', 'title' => ts('IM Provider')));
$locationFields = array_merge($locationType, CRM_Core_DAO_Address::export(), CRM_Core_DAO_Phone::export(), CRM_Core_DAO_Email::export(), $IMProvider, CRM_Core_DAO_IM::export(TRUE), CRM_Core_DAO_OpenID::export());
$locationFields = array_merge($locationFields, CRM_Core_BAO_CustomField::getFieldsForImport('Address'));
foreach ($locationFields as $key => $field) {
$locationFields[$key]['hasLocationType'] = TRUE;
}
$fields = array_merge($fields, $locationFields);
//add world region
$fields = array_merge($fields, CRM_Core_DAO_Worldregion::export());
$fields = array_merge($fields, CRM_Contact_DAO_Contact::export());
//website fields
$fields = array_merge($fields, CRM_Core_DAO_Website::export());
if ($contactType != 'All') {
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($contactType, $status, FALSE, $search, TRUE, $withMultiRecord));
} else {
foreach (array('Individual', 'Household', 'Organization') as $type) {
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type, FALSE, FALSE, $search, TRUE, $withMultiRecord));
}
}
//fix for CRM-791
if ($export) {
$fields = array_merge($fields, array('groups' => array('title' => ts('Group(s)'), 'name' => 'groups'), 'tags' => array('title' => ts('Tag(s)'), 'name' => 'tags'), 'notes' => array('title' => ts('Note(s)'), 'name' => 'notes')));
} else {
$fields = array_merge($fields, array('group' => array('title' => ts('Group(s)'), 'name' => 'group'), 'tag' => array('title' => ts('Tag(s)'), 'name' => 'tag'), 'note' => array('title' => ts('Note(s)'), 'name' => 'note')));
}
//Sorting fields in alphabetical order(CRM-1507)
foreach ($fields as $k => $v) {
$sortArray[$k] = CRM_Utils_Array::value('title', $v);
}
$fields = array_merge($sortArray, $fields);
//unset the field which are not related to their contact type.
if ($contactType != 'All') {
$commonValues = array('Individual' => array('household_name', 'legal_name', 'sic_code', 'organization_name', 'email_greeting_custom', 'postal_greeting_custom', 'addressee_custom'), 'Household' => array('first_name', 'middle_name', 'last_name', 'formal_title', 'job_title', 'gender_id', 'prefix_id', 'suffix_id', 'birth_date', 'organization_name', 'legal_name', 'legal_identifier', 'sic_code', 'home_URL', 'is_deceased', 'deceased_date', 'current_employer', 'email_greeting_custom', 'postal_greeting_custom', 'addressee_custom', 'prefix_id', 'suffix_id'), 'Organization' => array('first_name', 'middle_name', 'last_name', 'formal_title', 'job_title', 'gender_id', 'prefix_id', 'suffix_id', 'birth_date', 'household_name', 'email_greeting_custom', 'postal_greeting_custom', 'prefix_id', 'suffix_id', 'gender_id', 'addressee_custom', 'is_deceased', 'deceased_date', 'current_employer'));
foreach ($commonValues[$contactType] as $value) {
unset($fields[$value]);
}
}
CRM_Core_BAO_Cache::setItem($fields, 'contact fields', $cacheKeyString);
}
self::$_exportableFields[$cacheKeyString] = $fields;
}
if (!$status) {
$fields = self::$_exportableFields[$cacheKeyString];
} else {
$fields = array_merge(array('' => array('title' => ts('- Contact Fields -'))), self::$_exportableFields[$cacheKeyString]);
}
return $fields;
}
示例8: getContributionFields
/**
* Function to get list of contribution fields for profile
* For now we only allow custom contribution fields to be in
* profile
*
* @return return the list of contribution fields
* @static
* @access public
*/
static function getContributionFields()
{
$contributionFields =& CRM_Contribute_DAO_Contribution::export();
require_once 'CRM/Core/OptionValue.php';
$contributionFields = array_merge($contributionFields, CRM_Core_OptionValue::getFields($mode = 'contribute'));
require_once 'CRM/Contribute/DAO/ContributionType.php';
$contributionFields = array_merge($contributionFields, CRM_Contribute_DAO_ContributionType::export());
foreach ($contributionFields as $key => $var) {
if ($key == 'contribution_contact_id') {
continue;
}
$fields[$key] = $var;
}
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Contribution'));
return $fields;
}
示例9: postProcess
/**
* Function to process the form
*
* @access public
*
* @return void
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
$fieldValues = array('option_group_id' => $this->_gid);
$wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues);
if (CRM_Core_BAO_OptionValue::del($this->_id)) {
CRM_Core_Session::setStatus(ts('Selected Survey type has been deleted.'), ts('Record Deleted'), 'success');
}
} else {
$params = $ids = array();
$params = $this->exportValues();
// set db value of filter in params if filter is non editable
if ($this->_id && !array_key_exists('filter', $params)) {
$params['filter'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'filter', 'id');
}
$groupParams = array('name' => $this->_gName);
$params['component_id'] = CRM_Core_Component::getComponentID('CiviCampaign');
$optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_id);
CRM_Core_Session::setStatus(ts('The Survey type \'%1\' has been saved.', array(1 => $optionValue->label)), ts('Saved'), 'success');
}
}
示例10: getContributionFields
/**
* Get list of contribution fields for profile.
* For now we only allow custom contribution fields to be in
* profile
*
* @param bool $addExtraFields
* True if special fields needs to be added.
*
* @return array
* the list of contribution fields
*/
public static function getContributionFields($addExtraFields = TRUE)
{
$contributionFields = CRM_Contribute_DAO_Contribution::export();
$contributionFields = array_merge($contributionFields, CRM_Core_OptionValue::getFields($mode = 'contribute'));
if ($addExtraFields) {
$contributionFields = array_merge($contributionFields, self::getSpecialContributionFields());
}
$contributionFields = array_merge($contributionFields, CRM_Financial_DAO_FinancialType::export());
foreach ($contributionFields as $key => $var) {
if ($key == 'contribution_contact_id') {
continue;
} elseif ($key == 'contribution_campaign_id') {
$var['title'] = ts('Campaign');
}
$fields[$key] = $var;
}
$fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Contribution'));
return $fields;
}
示例11: upgrade
function upgrade($rev)
{
// fix CRM-5270: if civicrm_report_instance.description is localised,
// recreate it based on the first locale’s description_xx_YY contents
// and drop all the description_xx_YY columns
if (!CRM_Core_DAO::checkFieldExists('civicrm_report_instance', 'description')) {
require_once 'CRM/Core/DAO/Domain.php';
$domain = new CRM_Core_DAO_Domain();
$domain->find(true);
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_report_instance ADD description VARCHAR(255)");
CRM_Core_DAO::executeQuery("UPDATE civicrm_report_instance SET description = description_{$locales[0]}");
CRM_Core_DAO::executeQuery("DROP TRIGGER civicrm_report_instance_before_insert");
foreach ($locales as $locale) {
CRM_Core_DAO::executeQuery("DROP VIEW civicrm_report_instance_{$locale}");
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_report_instance DROP description_{$locale}");
}
}
//We execute some part of php after sql and then again sql
//So using conditions for skipping some part of sql CRM-4575
$upgrade =& new CRM_Upgrade_Form();
//Run the SQL file (1)
$upgrade->processSQL($rev);
//replace with ; in report instance
$sql = "UPDATE civicrm_report_instance \n SET form_values = REPLACE(form_values,'#',';') ";
CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
//delete unnecessary activities
$bulkEmailID = CRM_Core_OptionGroup::getValue('activity_type', 'Bulk Email', 'name');
if ($bulkEmailID) {
$mailingActivityIds = array();
$query = " \n SELECT max( ca.id ) as aid, \n ca.source_record_id sid\n FROM civicrm_activity ca\n WHERE ca.activity_type_id = %1 \n GROUP BY ca.source_record_id";
$params = array(1 => array($bulkEmailID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
while ($dao->fetch()) {
$updateQuery = "\n UPDATE civicrm_activity_target cat, civicrm_activity ca \n SET cat.activity_id = {$dao->aid} \n WHERE ca.source_record_id IS NOT NULL AND\n ca.activity_type_id = %1 AND \n ca.id <> {$dao->aid} AND \n ca.source_record_id = {$dao->sid} AND \n ca.id = cat.activity_id";
$updateParams = array(1 => array($bulkEmailID, 'Integer'));
CRM_Core_DAO::executeQuery($updateQuery, $updateParams);
$deleteQuery = " \n DELETE ca.* \n FROM civicrm_activity ca \n WHERE ca.source_record_id IS NOT NULL AND \n ca.activity_type_id = %1 AND \n ca.id <> {$dao->aid} AND \n ca.source_record_id = {$dao->sid}";
$deleteParams = array(1 => array($bulkEmailID, 'Integer'));
CRM_Core_DAO::executeQuery($deleteQuery, $deleteParams);
}
}
//CRM-4453
//lets insert column in civicrm_aprticipant table
$query = "\n ALTER TABLE `civicrm_participant` \n ADD `fee_currency` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '3 character string, value derived from config setting.' AFTER `discount_id`";
CRM_Core_DAO::executeQuery($query);
//get currency from contribution table if exists/default
//insert currency when fee_amount != NULL or event is paid.
$query = "\n SELECT civicrm_participant.id \n FROM civicrm_participant\n LEFT JOIN civicrm_event \n ON ( civicrm_participant.event_id = civicrm_event.id )\n WHERE civicrm_participant.fee_amount IS NOT NULL OR \n civicrm_event.is_monetary = 1";
$participant = CRM_Core_DAO::executeQuery($query);
while ($participant->fetch()) {
$query = "\n SELECT civicrm_contribution.currency \n FROM civicrm_contribution, \n civicrm_participant_payment\n WHERE civicrm_contribution.id = civicrm_participant_payment.contribution_id AND \n civicrm_participant_payment.participant_id = {$participant->id}";
$currencyID = CRM_Core_DAO::singleValueQuery($query);
if (!$currencyID) {
$config =& CRM_Core_Config::singleton();
$currencyID = $config->defaultCurrency;
}
//finally update participant record.
CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Participant', $participant->id, 'fee_currency', $currencyID);
}
//CRM-4575
//check whether {contact.name} is set in mailing labels
require_once 'CRM/Core/BAO/Preferences.php';
$mailingFormat = CRM_Core_BAO_Preferences::value('mailing_format');
$addNewAddressee = true;
if (strpos($mailingFormat, '{contact.contact_name}') === false) {
$addNewAddressee = false;
} else {
//else compare individual name format with default individual addressee.
$individualNameFormat = CRM_Core_BAO_Preferences::value('individual_name_format');
$defaultAddressee = CRM_Core_OptionGroup::values('addressee', false, false, false, " AND v.filter = 1 AND v.is_default = 1", 'label');
if (array_search($individualNameFormat, $defaultAddressee) !== false) {
$addNewAddressee = false;
}
}
require_once 'CRM/Utils/System.php';
$docURL = CRM_Utils_System::docURL2('Update Greetings and Address Data for Contacts', false, null, null, 'color: white; text-decoration: underline;');
if ($addNewAddressee) {
//otherwise insert new token in addressee and set as a default
$addresseeGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'addressee', 'id', 'name');
$optionValueParams = array('label' => $individualNameFormat, 'is_active' => 1, 'contactOptions' => 1, 'filter' => 1, 'is_default' => 1, 'reset_default_for' => array('filter' => "0, 1"));
$action = CRM_Core_Action::ADD;
$addresseeGroupParams = array('name' => 'addressee');
$fieldValues = array('option_group_id' => $addresseeGroupId);
$weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues);
$optionValueParams['weight'] = $weight;
$addresseeToken = CRM_Core_OptionValue::addOptionValue($optionValueParams, $addresseeGroupParams, $action, $optionId = null);
$afterUpgradeMessage = ts("During this upgrade, Postal Addressee values have been stored for each contact record using the system default format - %2.You will need to run the included command-line script to update your Individual contact records to use the \"Individual Name Format\" previously specified for your site %1", array(1 => $docURL, 2 => array_pop($defaultAddressee)));
} else {
$afterUpgradeMessage = ts("Email Greeting, Postal Greeting and Postal Addressee values have been stored for all contact records based on the system default formats. If you want to use a different format for any of these contact fields - you can run the provided command line script to update contacts to a different format %1 ", array(1 => $docURL));
}
//replace contact.contact_name with contact.addressee in civicrm_preference.mailing_format
$updateQuery = "\n UPDATE civicrm_preferences \n SET `mailing_format` = \n replace(`mailing_format`, '{contact.contact_name}','{contact.addressee}')";
CRM_Core_DAO::executeQuery($updateQuery);
//drop column individual_name_format
$alterQuery = "\n ALTER TABLE `civicrm_preferences`\n DROP `individual_name_format`";
CRM_Core_DAO::executeQuery($alterQuery);
//set status message for default greetings
$template =& CRM_Core_Smarty::singleton();
$template->assign('afterUpgradeMessage', $afterUpgradeMessage);
//.........这里部分代码省略.........
示例12: preProcess
function preProcess()
{
require_once 'api/v2/Contact.php';
require_once 'CRM/Core/BAO/CustomGroup.php';
require_once 'CRM/Core/OptionGroup.php';
require_once 'CRM/Core/OptionValue.php';
if (!CRM_Core_Permission::check('administer CiviCRM')) {
CRM_Core_Error::fatal(ts('You do not have access to this page'));
}
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true);
$oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, true);
$rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, false);
$gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, false);
$session =& CRM_Core_Session::singleton();
// context fixed.
if ($rgid) {
$urlParam = "reset=1&action=browse&rgid={$rgid}";
if ($gid) {
$urlParam .= "&gid={$gid}";
}
$session->pushUserContext(CRM_Utils_system::url('civicrm/admin/dedupefind', $urlParam));
}
// ensure that oid is not the current user, if so refuse to do the merge
if ($session->get('userID') == $oid) {
$display_name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $oid, 'display_name');
$message = ts('The contact record which is linked to the currently logged in user account - \'%1\' - cannot be deleted.', array(1 => $display_name));
CRM_Core_Error::statusBounce($message);
}
$diffs = CRM_Dedupe_Merger::findDifferences($cid, $oid);
$mainParams = array('contact_id' => $cid, 'return.display_name' => 1);
$otherParams = array('contact_id' => $oid, 'return.display_name' => 1);
// API 2 has to have the requested fields spelt-out for it
foreach (CRM_Dedupe_Merger::$validFields as $field) {
$mainParams["return.{$field}"] = $otherParams["return.{$field}"] = 1;
}
$main =& civicrm_contact_get($mainParams);
//CRM-4524
$main = reset($main);
if ($main['contact_id'] != $cid) {
CRM_Core_Error::fatal(ts('The main contact record does not exist'));
}
$other =& civicrm_contact_get($otherParams);
//CRM-4524
$other = reset($other);
if ($other['contact_id'] != $oid) {
CRM_Core_Error::fatal(ts('The other contact record does not exist'));
}
$this->assign('contact_type', $main['contact_type']);
$this->assign('main_name', $main['display_name']);
$this->assign('other_name', $other['display_name']);
$this->assign('main_cid', $main['contact_id']);
$this->assign('other_cid', $other['contact_id']);
$this->_cid = $cid;
$this->_oid = $oid;
$this->_rgid = $rgid;
$this->_contactType = $main['contact_type'];
$this->addElement('checkbox', 'toggleSelect', null, null, array('onclick' => "return toggleCheckboxVals('move_',this);"));
require_once "CRM/Contact/DAO/Contact.php";
$fields =& CRM_Contact_DAO_Contact::fields();
// FIXME: there must be a better way
foreach (array('main', 'other') as $moniker) {
$contact =& ${$moniker};
$specialValues[$moniker] = array('preferred_communication_method' => $contact['preferred_communication_method']);
$names = array('preferred_communication_method' => array('newName' => 'preferred_communication_method_display', 'groupName' => 'preferred_communication_method'));
CRM_Core_OptionGroup::lookupValues($specialValues[$moniker], $names);
}
foreach (CRM_Core_OptionValue::getFields() as $field => $params) {
$fields[$field]['title'] = $params['title'];
}
if (!isset($diffs['contact'])) {
$diffs['contact'] = array();
}
foreach ($diffs['contact'] as $field) {
foreach (array('main', 'other') as $moniker) {
$contact =& ${$moniker};
$value = CRM_Utils_Array::value($field, $contact);
$label = isset($specialValues[$moniker][$field]) ? $specialValues[$moniker]["{$field}_display"] : $value;
if ($fields[$field]['type'] == CRM_Utils_Type::T_DATE) {
if ($value) {
$value = str_replace('-', '', $value);
$label = CRM_Utils_Date::customFormat($label);
} else {
$value = "null";
}
} elseif ($fields[$field]['type'] == CRM_Utils_Type::T_BOOLEAN) {
if ($label === '0') {
$label = ts('[ ]');
}
if ($label === '1') {
$label = ts('[x]');
}
}
$rows["move_{$field}"][$moniker] = $label;
if ($moniker == 'other') {
if ($value === null) {
$value = 'null';
}
if ($value === 0 or $value === '0') {
$value = $this->_qfZeroBug;
}
//.........这里部分代码省略.........
示例13: optionExists
static function optionExists($value, $options)
{
return CRM_Core_OptionValue::optionExists($value, $options[0], $options[1], $options[2], CRM_Utils_Array::value(3, $options, 'name'));
}
示例14: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
if (CRM_Core_BAO_OptionValue::del($this->_id)) {
CRM_Core_Session::setStatus(ts('Selected %1 Report has been deleted.', array(1 => $this->_GName)));
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/report/options/report_template', "reset=1"));
} else {
CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_GName)));
CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $fieldValues);
}
} else {
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
$ids = array();
$groupParams = array('name' => 'report_template');
$optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_id);
CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(1 => 'Report Template', 2 => $optionValue->label)));
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/report/options/report_template', "reset=1"));
}
}
示例15: getRowsElementsAndInfo
/**
* A function to build an array of information required by merge function and the merge UI.
*
* @param int $mainId
* Main contact with whom merge has to happen.
* @param int $otherId
* Duplicate contact which would be deleted after merge operation.
*
* @return array|bool|int
* 'main_loc_block' => Stores all location blocks associated with the 'main' contact
*/
public static function getRowsElementsAndInfo($mainId, $otherId)
{
$qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
// Fetch contacts
foreach (array('main' => $mainId, 'other' => $otherId) as $moniker => $cid) {
$params = array('contact_id' => $cid, 'version' => 3, 'return' => array_merge(array('display_name'), self::getContactFields()));
$result = civicrm_api('contact', 'get', $params);
if (empty($result['values'][$cid]['contact_type'])) {
return FALSE;
}
${$moniker} = $result['values'][$cid];
}
$fields = CRM_Contact_DAO_Contact::fields();
// FIXME: there must be a better way
foreach (array('main', 'other') as $moniker) {
$contact =& ${$moniker};
$preferred_communication_method = CRM_Utils_array::value('preferred_communication_method', $contact);
$value = empty($preferred_communication_method) ? array() : $preferred_communication_method;
$specialValues[$moniker] = array('preferred_communication_method' => $value, 'communication_style_id' => $value);
if (!empty($contact['preferred_communication_method'])) {
// api 3 returns pref_comm_method as an array, which breaks the lookup; so we reconstruct
$prefCommList = is_array($specialValues[$moniker]['preferred_communication_method']) ? implode(CRM_Core_DAO::VALUE_SEPARATOR, $specialValues[$moniker]['preferred_communication_method']) : $specialValues[$moniker]['preferred_communication_method'];
$specialValues[$moniker]['preferred_communication_method'] = CRM_Core_DAO::VALUE_SEPARATOR . $prefCommList . CRM_Core_DAO::VALUE_SEPARATOR;
}
$names = array('preferred_communication_method' => array('newName' => 'preferred_communication_method_display', 'groupName' => 'preferred_communication_method'));
CRM_Core_OptionGroup::lookupValues($specialValues[$moniker], $names);
if (!empty($contact['communication_style'])) {
$specialValues[$moniker]['communication_style_id_display'] = $contact['communication_style'];
}
}
static $optionValueFields = array();
if (empty($optionValueFields)) {
$optionValueFields = CRM_Core_OptionValue::getFields();
}
foreach ($optionValueFields as $field => $params) {
$fields[$field]['title'] = $params['title'];
}
$compareFields = self::retrieveFields($main, $other);
$rows = $elements = $relTableElements = $migrationInfo = array();
foreach ($compareFields['contact'] as $field) {
if ($field == 'contact_sub_type') {
// CRM-15681 don't display sub-types in UI
continue;
}
foreach (array('main', 'other') as $moniker) {
$contact =& ${$moniker};
$value = CRM_Utils_Array::value($field, $contact);
if (isset($specialValues[$moniker][$field]) && is_string($specialValues[$moniker][$field])) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . trim($specialValues[$moniker][$field], CRM_Core_DAO::VALUE_SEPARATOR) . CRM_Core_DAO::VALUE_SEPARATOR;
}
$label = isset($specialValues[$moniker]["{$field}_display"]) ? $specialValues[$moniker]["{$field}_display"] : $value;
if (!empty($fields[$field]['type']) && $fields[$field]['type'] == CRM_Utils_Type::T_DATE) {
if ($value) {
$value = str_replace('-', '', $value);
$label = CRM_Utils_Date::customFormat($label);
} else {
$value = "null";
}
} elseif (!empty($fields[$field]['type']) && $fields[$field]['type'] == CRM_Utils_Type::T_BOOLEAN) {
if ($label === '0') {
$label = ts('[ ]');
}
if ($label === '1') {
$label = ts('[x]');
}
} elseif ($field == 'individual_prefix' || $field == 'prefix_id') {
$label = CRM_Utils_Array::value('individual_prefix', $contact);
$value = CRM_Utils_Array::value('prefix_id', $contact);
$field = 'prefix_id';
} elseif ($field == 'individual_suffix' || $field == 'suffix_id') {
$label = CRM_Utils_Array::value('individual_suffix', $contact);
$value = CRM_Utils_Array::value('suffix_id', $contact);
$field = 'suffix_id';
} elseif ($field == 'gender_id' && !empty($value)) {
$genderOptions = civicrm_api3('contact', 'getoptions', array('field' => 'gender_id'));
$label = $genderOptions['values'][$value];
} elseif ($field == 'current_employer_id' && !empty($value)) {
$label = "{$value} (" . CRM_Contact_BAO_Contact::displayName($value) . ")";
}
$rows["move_{$field}"][$moniker] = $label;
if ($moniker == 'other') {
//CRM-14334
if ($value === NULL || $value == '') {
$value = 'null';
}
if ($value === 0 or $value === '0') {
$value = $qfZeroBug;
}
if (is_array($value) && empty($value[1])) {
//.........这里部分代码省略.........