本文整理汇总了PHP中CRM_Core_BAO_Setting::validateSettingsInput方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Setting::validateSettingsInput方法的具体用法?PHP CRM_Core_BAO_Setting::validateSettingsInput怎么用?PHP CRM_Core_BAO_Setting::validateSettingsInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_Setting
的用法示例。
在下文中一共展示了CRM_Core_BAO_Setting::validateSettingsInput方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDb
/**
* Update the DB record for this setting.
*
* @param string $name
* The simple name of the setting.
* @param mixed $value
* The new value of the setting.
*/
protected function setDb($name, $value)
{
if (\CRM_Core_BAO_Setting::isUpgradeFromPreFourOneAlpha1()) {
// civicrm_setting table is not going to be present.
return;
}
$fields = array();
$fieldsToSet = \CRM_Core_BAO_Setting::validateSettingsInput(array($name => $value), $fields);
//We haven't traditionally validated inputs to setItem, so this breaks things.
//foreach ($fieldsToSet as $settingField => &$settingValue) {
// self::validateSetting($settingValue, $fields['values'][$settingField]);
//}
$metadata = $fields['values'][$name];
$dao = new \CRM_Core_DAO_Setting();
$dao->name = $name;
$dao->domain_id = $this->domainId;
if ($this->contactId) {
$dao->contact_id = $this->contactId;
$dao->is_domain = 0;
} else {
$dao->is_domain = 1;
}
$dao->find(TRUE);
if (isset($metadata['on_change'])) {
foreach ($metadata['on_change'] as $callback) {
call_user_func(\Civi\Core\Resolver::singleton()->get($callback), unserialize($dao->value), $value, $metadata, $this->domainId);
}
}
if (\CRM_Utils_System::isNull($value)) {
$dao->value = 'null';
} else {
$dao->value = serialize($value);
}
$dao->created_date = \CRM_Utils_Time::getTime('Ymdhis');
$session = \CRM_Core_Session::singleton();
if (\CRM_Contact_BAO_Contact_Utils::isContactId($session->get('userID'))) {
$dao->created_id = $session->get('userID');
}
$dao->save();
$dao->free();
}
示例2: setDb
/**
* Update the DB record for this setting.
*
* @param string $name
* The simple name of the setting.
* @param mixed $value
* The new value of the setting.
*/
protected function setDb($name, $value)
{
if (\CRM_Core_BAO_Setting::isUpgradeFromPreFourOneAlpha1()) {
// civicrm_setting table is not going to be present.
return;
}
$fields = array();
$fieldsToSet = \CRM_Core_BAO_Setting::validateSettingsInput(array($name => $value), $fields);
//We haven't traditionally validated inputs to setItem, so this breaks things.
//foreach ($fieldsToSet as $settingField => &$settingValue) {
// self::validateSetting($settingValue, $fields['values'][$settingField]);
//}
$metadata = $fields['values'][$name];
$dao = new \CRM_Core_DAO_Setting();
$dao->name = $name;
$dao->domain_id = $this->domainId;
if ($this->contactId) {
$dao->contact_id = $this->contactId;
$dao->is_domain = 0;
} else {
$dao->is_domain = 1;
}
$dao->find(TRUE);
if (isset($metadata['on_change'])) {
foreach ($metadata['on_change'] as $callback) {
call_user_func(\Civi\Core\Resolver::singleton()->get($callback), unserialize($dao->value), $value, $metadata, $this->domainId);
}
}
if (!is_array($value) && \CRM_Utils_System::isNull($value)) {
$dao->value = 'null';
} else {
$dao->value = serialize($value);
}
if (!isset(\Civi::$statics[__CLASS__]['upgradeMode'])) {
\Civi::$statics[__CLASS__]['upgradeMode'] = \CRM_Core_Config::isUpgradeMode();
}
if (\Civi::$statics[__CLASS__]['upgradeMode'] && \CRM_Core_DAO::checkFieldExists('civicrm_setting', 'group_name')) {
$dao->group_name = 'placeholder';
}
$dao->created_date = \CRM_Utils_Time::getTime('YmdHis');
$session = \CRM_Core_Session::singleton();
if (\CRM_Contact_BAO_Contact_Utils::isContactId($session->get('userID'))) {
$dao->created_id = $session->get('userID');
}
if ($dao->id) {
$dao->save();
} else {
// Cannot use $dao->save(); in upgrade mode (eg WP + Civi 4.4=>4.7), the DAO will refuse
// to save the field `group_name`, which is required in older schema.
\CRM_Core_DAO::executeQuery(\CRM_Utils_SQL_Insert::dao($dao)->toSQL());
}
$dao->free();
}