本文整理汇总了PHP中CRM_Utils_Weight::getDefaultWeight方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Weight::getDefaultWeight方法的具体用法?PHP CRM_Utils_Weight::getDefaultWeight怎么用?PHP CRM_Utils_Weight::getDefaultWeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Weight
的用法示例。
在下文中一共展示了CRM_Utils_Weight::getDefaultWeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaultValues
/**
* This function sets the default values for the form. MobileProvider that in edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return None
*/
public function setDefaultValues()
{
$defaults = array();
$defaults =& parent::setDefaultValues();
//finding default weight to be put
if (!isset($defaults['weight']) || !$defaults['weight']) {
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Member_DAO_MembershipType');
}
//setting default relationshipType
if (isset($defaults['relationship_type_id'])) {
//$defaults['relationship_type_id'] = $defaults['relationship_type_id'].'_a_b';
$defaults['relationship_type_id'] = $defaults['relationship_type_id'] . '_' . $defaults['relationship_direction'];
}
$config =& CRM_Core_Config::singleton();
//setting default fixed_period_start_day & fixed_period_rollover_day
$periods = array('fixed_period_start_day', 'fixed_period_rollover_day');
foreach ($periods as $per) {
if (isset($defaults[$per])) {
$dat = $defaults[$per];
$dat = $dat < 999 ? '0' . $dat : $dat;
$defaults[$per] = array();
$defaults[$per][$config->dateformatMonthVar] = substr($dat, 0, 2);
$defaults[$per]['d'] = substr($dat, 2, 3);
}
}
return $defaults;
}
示例2: setDefaultValues
/**
* This function sets the default values for the form. MobileProvider that in edit/view mode
* the default values are retrieved from the database
*
* @access public
*
* @return None
*/
public function setDefaultValues()
{
$defaults = array();
$defaults = parent::setDefaultValues();
//finding default weight to be put
if (!isset($defaults['weight']) || !$defaults['weight']) {
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Member_DAO_MembershipType');
}
//setting default relationshipType
if (isset($defaults['relationship_type_id'])) {
//$defaults['relationship_type_id'] = $defaults['relationship_type_id'].'_a_b';
// Set values for relation type select box
$relTypeIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, $defaults['relationship_type_id']);
$relDirections = explode(CRM_Core_DAO::VALUE_SEPARATOR, $defaults['relationship_direction']);
$defaults['relationship_type_id'] = array();
foreach ($relTypeIds as $key => $value) {
$defaults['relationship_type_id'][] = $value . '_' . $relDirections[$key];
}
}
$config = CRM_Core_Config::singleton();
//setting default fixed_period_start_day & fixed_period_rollover_day
$periods = array('fixed_period_start_day', 'fixed_period_rollover_day');
foreach ($periods as $per) {
if (isset($defaults[$per])) {
$dat = $defaults[$per];
$dat = $dat < 999 ? '0' . $dat : $dat;
$defaults[$per] = array();
$defaults[$per]['M'] = substr($dat, 0, 2);
$defaults[$per]['d'] = substr($dat, 2, 3);
}
}
return $defaults;
}
示例3: createEntry
public function createEntry($id, $key)
{
$e = self::$_extensions;
$ids = array();
$groupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::OPTION_GROUP_NAME, 'id', 'name');
$params = array('option_group_id' => $groupId, 'weight' => CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $groupId)), 'label' => $e['per_id'][$id]['label'], 'name' => $e['per_id'][$id]['label'], 'value' => $key, 'grouping' => $e['per_id'][$id]['type'], 'is_active' => 1);
$optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
}
示例4: setDefaultValues
/**
* Set default values for the form. MobileProvider that in edit/view mode
* the default values are retrieved from the database
*
*
* @return void
*/
public function setDefaultValues()
{
$defaults = parent::setDefaultValues();
//finding default weight to be put
if (empty($defaults['weight'])) {
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Member_DAO_MembershipStatus');
}
return $defaults;
}
示例5: setDefaultValues
/**
* This function sets the default values for the form. MobileProvider that in edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return None
*/
public function setDefaultValues()
{
$defaults = array();
$defaults =& parent::setDefaultValues();
//finding default weight to be put
if (!CRM_Utils_Array::value('weight', $defaults)) {
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Member_DAO_MembershipStatus');
}
return $defaults;
}
示例6: install
public function install()
{
if (array_key_exists($this->ext->key, $this->customSearches)) {
CRM_Core_Error::fatal('This custom search is already registered.');
}
$weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $this->groupId));
$params = array('option_group_id' => $this->groupId, 'weight' => $weight, 'description' => $this->ext->label . ' (' . $this->ext->key . ')', 'name' => $this->ext->key, 'value' => max($this->customSearches) + 1, 'label' => $this->ext->key, 'is_active' => 1);
$ids = array();
$optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
}
示例7: setDefaultValues
/**
* Set default values.
*
* @return array
*/
public function setDefaultValues()
{
$defaults = parent::setDefaultValues();
if (empty($defaults['weight'])) {
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Event_DAO_ParticipantStatusType');
}
$this->_isReserved = CRM_Utils_Array::value('is_reserved', $defaults);
if ($this->_isReserved) {
$this->freeze(array('name', 'class', 'is_active'));
}
return $defaults;
}
示例8: onPreInstall
/**
* @param CRM_Extension_Info $info
*
* @return bool
* @throws Exception
*/
public function onPreInstall(CRM_Extension_Info $info)
{
$customSearchesByName = $this->getCustomSearchesByName();
if (array_key_exists($info->key, $customSearchesByName)) {
CRM_Core_Error::fatal('This custom search is already registered.');
}
$weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $this->groupId));
$params = array('option_group_id' => $this->groupId, 'weight' => $weight, 'description' => $info->label . ' (' . $info->key . ')', 'name' => $info->key, 'value' => max($customSearchesByName) + 1, 'label' => $info->key, 'is_active' => 1);
$ids = array();
$optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
return $optionValue ? TRUE : FALSE;
}
示例9: setDefaultValues
function setDefaultValues()
{
$defaults = parent::setDefaultValues();
if (!CRM_Utils_Array::value('weight', $defaults)) {
require_once 'CRM/Utils/Weight.php';
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Event_DAO_ParticipantStatusType');
}
$this->_isReserved = $defaults['is_reserved'];
if ($this->_isReserved) {
$this->freeze(array('name', 'class', 'is_active'));
}
return $defaults;
}
示例10: setDefaultValues
function setDefaultValues()
{
$defaults = array();
if ($this->_action & CRM_Core_Action::DELETE) {
return $defaults;
}
if ($this->_id) {
$params = array('id' => $this->_id);
$defaults = array();
CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_OptionValue', $params, $defaults);
} else {
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $this->_opID));
}
return $defaults;
}
示例11: install
public function install()
{
if (array_key_exists($this->ext->key, $this->customReports)) {
CRM_Core_Error::fatal('This report is already registered.');
}
if ($this->ext->typeInfo['component'] === 'Contact') {
$compId = 'null';
} else {
$comp = CRM_Core_Component::get($this->ext->typeInfo['component']);
$compId = $comp->componentID;
}
if (empty($compId)) {
CRM_Core_Error::fatal("Component for which you're trying to install the extension (" . $this->ext->typeInfo['component'] . ") is currently disabled.");
}
$weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $this->groupId));
$ids = array();
$params = array('label' => $this->ext->label . ' (' . $this->ext->key . ')', 'value' => $this->ext->typeInfo['reportUrl'], 'name' => $this->ext->key, 'weight' => $weight, 'description' => $this->ext->label . ' (' . $this->ext->key . ')', 'component_id' => $compId, 'option_group_id' => $this->groupId, 'is_active' => 1);
$optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
}
示例12: civicrm_api3_option_value_create
/**
* Add a OptionValue. OptionValues are used to classify CRM entities (including Contacts, Groups and Actions).
*
* Allowed @params array keys are:
*
* {@example OptionValueCreate.php}
*
* @return array of newly created option_value property values.
* {@getfields OptionValue_create}
* @access public
*/
function civicrm_api3_option_value_create($params)
{
$weight = 0;
if (!array_key_exists('label', $params) && array_key_exists('name', $params)) {
// no idea why that's a "mandatory" field
$params['label'] = $params['name'];
}
if (!CRM_Utils_Array::value('value', $params) && array_key_exists('option_group_id', $params)) {
require_once 'CRM/Utils/Weight.php';
$fieldValues = array('option_group_id' => $params['option_group_id']);
// use the next available value
/* CONVERT(value, DECIMAL) is used to convert varchar
field 'value' to decimal->integer */
$params['value'] = (int) CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues, 'CONVERT(value, DECIMAL)');
$weight = $params['value'];
}
if (!array_key_exists('weight', $params) && array_key_exists('value', $params)) {
// no idea why that's a "mandatory" field
$params['weight'] = $params['value'];
} elseif (array_key_exists('weight', $params) && $params['weight'] == 'next') {
// weight is numeric, so it's safe-ish to treat symbol 'next' as magical value
$params['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $params['option_group_id']));
}
if (array_key_exists('component', $params)) {
if (empty($params['component'])) {
$params['component_id'] = '';
} else {
$params['component_id'] = array_search($params['component'], CRM_Core_PseudoConstant::component());
}
unset($params['component']);
}
if (CRM_Utils_Array::value('id', $params)) {
$ids = array('optionValue' => $params['id']);
}
$optionValueBAO = CRM_Core_BAO_OptionValue::add($params, $ids);
civicrm_api('option_value', 'getfields', array('version' => 3, 'cache_clear' => 1));
$values = array();
_civicrm_api3_object_to_array($optionValueBAO, $values[$optionValueBAO->id]);
return civicrm_api3_create_success($values, $params);
}
示例13: setDefaultValues
/**
* This function sets the default values for the form. MobileProvider that in edit/view mode
* the default values are retrieved from the database
*
* @access public
*
* @return None
*/
public function setDefaultValues()
{
$defaults = parent::setDefaultValues();
// get the member org display name
if ($this->_id && CRM_Utils_Array::value('member_of_contact_id', $defaults)) {
$this->assign('member_org_id', $defaults['member_of_contact_id']);
}
//finding default weight to be put
if (!isset($defaults['weight']) || !$defaults['weight']) {
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Member_DAO_MembershipType');
}
//setting default relationshipType
if (isset($defaults['relationship_type_id'])) {
//$defaults['relationship_type_id'] = $defaults['relationship_type_id'].'_a_b';
// Set values for relation type select box
$relTypeIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, $defaults['relationship_type_id']);
$relDirections = explode(CRM_Core_DAO::VALUE_SEPARATOR, $defaults['relationship_direction']);
$defaults['relationship_type_id'] = array();
foreach ($relTypeIds as $key => $value) {
$defaults['relationship_type_id'][] = $value . '_' . $relDirections[$key];
}
}
//setting default fixed_period_start_day & fixed_period_rollover_day
$periods = array('fixed_period_start_day', 'fixed_period_rollover_day');
foreach ($periods as $per) {
if (isset($defaults[$per])) {
$date = $defaults[$per];
$defaults[$per] = array();
if ($date > 31) {
$date = $date < 999 ? '0' . $date : $date;
$defaults[$per]['M'] = substr($date, 0, 2);
$defaults[$per]['d'] = substr($date, 2, 3);
} else {
//special case when only day is rollover and duration is month
$defaults['month_fixed_period_rollover_day']['d'] = $date;
}
}
}
return $defaults;
}
示例14: array
/**
* Get the default PDF Page Format values.
*
* @return array
* Name/value pairs containing the default PDF Page Format values.
*/
public static function &getDefaultValues()
{
$params = array('is_active' => 1, 'is_default' => 1);
$defaults = array();
if (!self::retrieve($params, $defaults)) {
foreach (self::$optionValueFields as $name => $field) {
$defaults[$name] = $field['default'];
}
$filter = array('option_group_id' => self::_getGid());
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $filter);
// also set the id to avoid NOTICES, CRM-8454
$defaults['id'] = NULL;
}
return $defaults;
}
示例15: 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);
//.........这里部分代码省略.........