before_filter :admin_required
def index
- @smtp_host = Property.value(configuration::SMTP_HOST, nil, configuration::SMTP_HOST_DEFAULT)
- @smtp_port = Property.value(configuration::SMTP_PORT, nil, configuration::SMTP_PORT_DEFAULT)
- @smtp_secure_connection = Property.value(configuration::SMTP_SECURE_CONNECTION, nil, configuration::SMTP_SECURE_CONNECTION)
- @smtp_username = Property.value(configuration::SMTP_USERNAME, nil, configuration::SMTP_USERNAME_DEFAULT)
- @smtp_password = Property.value(configuration::SMTP_PASSWORD, nil, configuration::SMTP_PASSWORD_DEFAULT)
- @email_from = Property.value(configuration::FROM, nil, configuration::FROM_DEFAULT)
- @email_prefix = Property.value(configuration::PREFIX, nil, configuration::PREFIX_DEFAULT)
- @server_base_url = Property.value(properties::SERVER_BASE_URL, nil, properties::SERVER_BASE_URL_DEFAULT_VALUE)
- params[:layout]='false'
+ @smtp_host = Property.value(configuration::SMTP_HOST, nil, configuration::SMTP_HOST_DEFAULT)
+ @smtp_port = Property.value(configuration::SMTP_PORT, nil, configuration::SMTP_PORT_DEFAULT)
+ @smtp_secure_connection = Property.value(configuration::SMTP_SECURE_CONNECTION, nil, configuration::SMTP_SECURE_CONNECTION)
+ @smtp_username = Property.value(configuration::SMTP_USERNAME, nil, configuration::SMTP_USERNAME_DEFAULT)
+ @smtp_password = Property.value(configuration::SMTP_PASSWORD, nil, configuration::SMTP_PASSWORD_DEFAULT)
+ @email_from = Property.value(configuration::FROM, nil, configuration::FROM_DEFAULT)
+ @email_prefix = Property.value(configuration::PREFIX, nil, configuration::PREFIX_DEFAULT)
+ @server_base_url = Property.value(properties::SERVER_BASE_URL, nil, properties::SERVER_BASE_URL_DEFAULT_VALUE)
+ params[:layout]='false'
end
def save
- Property.set(configuration::SMTP_HOST, params[:smtp_host])
- Property.set(configuration::SMTP_PORT, params[:smtp_port])
- Property.set(configuration::SMTP_SECURE_CONNECTION, params[:smtp_secure_connection])
- Property.set(configuration::SMTP_USERNAME, params[:smtp_username])
- Property.set(configuration::SMTP_PASSWORD, params[:smtp_password])
- Property.set(configuration::FROM, params[:email_from])
- Property.set(configuration::PREFIX, params[:email_prefix])
- flash[:notice] = message('email_configuration.settings_saved')
- redirect_to :action => 'index'
+ Property.set(configuration::SMTP_HOST, params[:smtp_host])
+ Property.set(configuration::SMTP_PORT, params[:smtp_port])
+ Property.set(configuration::SMTP_SECURE_CONNECTION, params[:smtp_secure_connection])
+ Property.set(configuration::SMTP_USERNAME, params[:smtp_username])
+ # Do not update password that wasn't updated
+ Property.set(configuration::SMTP_PASSWORD, params[:smtp_password]) unless params[:smtp_password] == Property::EXISTING_PASSWORD
+ Property.set(configuration::FROM, params[:email_from])
+ Property.set(configuration::PREFIX, params[:email_prefix])
+ flash[:notice] = message('email_configuration.settings_saved')
+ redirect_to :action => 'index'
end
def send_test_email
named_scope :with_resources, :conditions => 'resource_id is not null'
named_scope :with_users, :conditions => 'user_id is not null'
+ EXISTING_PASSWORD = '{{*******************}}'
+
def key
prop_key
end
text_value = value.to_s if defined? value
text_value = nil if text_value.blank?
+ # Load Java property definition
+ property_def = field_property_def(key) || property_def(key)
+
if text_value.blank?
return Property.clear(key, resource_id)
end
return prop
end
- unless prop
+ if !prop
prop = Property.new(:prop_key => key, :resource_id => resource_id, :user_id => user_id)
+ # Do not update password that wasn't updated
+ elsif property_def.type().to_s == PropertyType::TYPE_PASSWORD && text_value == EXISTING_PASSWORD
+ text_value = prop.text_value
end
prop.text_value = text_value
end
def java_definition
- @java_definition ||=
- begin
- Api::Utils.java_facade.propertyDefinitions.get(key)
- end
+ @java_definition ||= Property.property_def(key)
end
def java_field_definition
- @java_field_definition ||=
- begin
- if /(.*)\..*\.(.*)/.match(key)
- property_definition = Api::Utils.java_facade.propertyDefinitions.get(Regexp.last_match(1))
- if property_definition
- property_definition.fields.find { |field| field.key == Regexp.last_match(2) }
- end
- end
- end
+ @java_field_definition ||= Property.field_property_def(key)
end
def validation_error_message
array.map { |v| v.gsub(',', '%2C') }.join(',')
end
- private
-
def self.setGlobalProperty(key, value, resource_id, user_id)
Api::Utils.java_facade.setGlobalProperty(key, value) unless (resource_id || user_id)
end
+ private
+
def self.all(key, resource_id=nil, user_id=nil)
Property.with_key(key).with_resource(resource_id).with_user(user_id)
end
errors.add_to_base(validation_result.errorKey) unless validation_result.isValid()
end
end
+
+ def self.property_def(key)
+ begin
+ Api::Utils.java_facade.propertyDefinitions.get(key)
+ end
+ end
+
+ def self.field_property_def(key)
+ begin
+ if /(.*)\..*\.(.*)/.match(key)
+ property_definition = Api::Utils.java_facade.propertyDefinitions.get(Regexp.last_match(1))
+ if property_definition
+ property_definition.fields.find { |field| field.key == Regexp.last_match(2) }
+ end
+ end
+ end
+ end
+
end