* @return object
*/
public static function create(&$params) {
- $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
- $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
- $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE);
+ if (empty($params['id'])) {
+ $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
+ $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
+ $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE);
+ }
- // action is taken depending upon the mode
$locationType = new CRM_Core_DAO_LocationType();
$locationType->copyValues($params);
-
- if ($params['is_default']) {
+ if (!empty($params['is_default'])) {
$query = "UPDATE civicrm_location_type SET is_default = 0";
CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
}
'OptionGroup',
'MailingRecipients',
'UFMatch',
- 'LocationType',
'CustomSearch',
'Extension',
'ReportTemplate',
'UFJoin',
'UFMatch',
'Extension',
- 'LocationType',
'System',
);
$this->onlyIDNonZeroCount['get'] = array(
'pcp_id',
),
),
+ 'LocationType' => array(
+ 'cant_update' => array(
+ // I'm on the fence about whether the test should skip or the behaviour is wrong.
+ // display_name is set to match name if display_name is not provided. It would be more 'normal'
+ // to only calculate a default IF id is not set - but perhaps the current behaviour is kind
+ // of what someone updating the name expects..
+ 'name',
+ ),
+ ),
'Pledge' => array(
'cant_update' => array(
'pledge_original_installment_amount',