SECTION=Navigation::SECTION_CONFIGURATION
- SPECIAL_CATEGORIES=%w(email encryption server_id)
+ LICENSES_CATEGORY='Licenses'
+ SERVER_ID_SUBCATEGORY='server_id'
+ SPECIAL_CATEGORIES=%w(email encryption) + [LICENSES_CATEGORY]
+
verify :method => :post, :only => %w(update), :redirect_to => {:action => :index}
before_filter :admin_required, :only => %w(index)
def load_properties
definitions_per_category = java_facade.propertyDefinitions.getPropertiesByCategory(@resource ? @resource.qualifier : nil)
@categories = definitions_per_category.keys + SPECIAL_CATEGORIES
- @categories = by_category_name(@categories)
+ @categories = by_category_name(@categories.uniq)
- default_category = nil
- default_category = @categories[0] if !@categories.empty?
+ default_category = @categories.empty? ? nil : @categories[0]
@category = params[:category] || default_category
not_found('category') unless @categories.include? @category
- @subcategory = params[:subcategory] || @category
@subcategories_per_categories = {}
definitions_per_category.each {|category, definitions_per_subcategories| @subcategories_per_categories.store(category, by_subcategory_name(category, definitions_per_subcategories.keys)) }
+
+ if (@subcategories_per_categories[LICENSES_CATEGORY].nil?)
+ @subcategories_per_categories.store(LICENSES_CATEGORY, [SERVER_ID_SUBCATEGORY])
+ else
+ @subcategories_per_categories[LICENSES_CATEGORY].push(SERVER_ID_SUBCATEGORY)
+ end
+
+ default_subcategory =
+ @subcategories_per_categories[@category].nil? ? nil :
+ ((@subcategories_per_categories[@category].include? @category) ? @category : @subcategories_per_categories[@category][0])
+ @subcategory = params[:subcategory] || default_subcategory
+
@definitions = definitions_per_category[@category] || {}
@definitions = @definitions[@subcategory] || []
end
-<% if SettingsController::SPECIAL_CATEGORIES.include?(@category) -%>
+<% if SettingsController::SPECIAL_CATEGORIES.include?(@category) && @category != SettingsController::LICENSES_CATEGORY -%>
<%= render 'special', :url => url_for(:controller => "#{@category}_configuration") -%>
<% else -%>
<% form_remote_tag :url => {:controller => 'settings', :action => 'update', :category => @category, :subcategory => @subcategory, :resource_id => @resource ? @resource.id : nil},
</li>
<% end -%>
</ul>
- <table class="data marginbottom10">
- <thead>
- <% if @subcategory == @category && !category_desc(@category).blank? -%>
- <tr>
- <td class="categoryDescription"><%= category_desc(@category) -%> </td>
- </tr>
- <% end -%>
- <% if @subcategory != @category && !subcategory_desc(@category, @subcategory).blank? -%>
- <tr>
- <td><%= subcategory_desc(@category, @subcategory) -%> </td>
- </tr>
- <% end -%>
- </thead>
- <tbody>
- <% by_property_index_or_name(@definitions).each do |property| -%>
- <tr class="property <%= cycle('even', 'odd', :name => 'properties') -%>">
- <td style="padding: 10px" id="block_<%= property.key -%>">
- <h3>
- <div><%= property_name(property) -%></div>
- <div class="note"><%= property.key -%></div>
- </h3>
- <% desc=property_description(property) -%>
- <% unless desc.blank? %>
- <p class="marginbottom10"><%= desc -%></p>
- <% end -%>
+ <% if @category == SettingsController::LICENSES_CATEGORY && @subcategory == SettingsController::SERVER_ID_SUBCATEGORY %>
+ <%= render 'special', :url => url_for(:controller => "#{SettingsController::SERVER_ID_SUBCATEGORY}_configuration") -%>
+ <% else %>
+ <table class="data marginbottom10">
+ <thead>
+ <% if @subcategory == @category && !category_desc(@category).blank? -%>
+ <tr>
+ <td class="categoryDescription"><%= category_desc(@category) -%> </td>
+ </tr>
+ <% end -%>
+ <% if @subcategory != @category && !subcategory_desc(@category, @subcategory).blank? -%>
+ <tr>
+ <td><%= subcategory_desc(@category, @subcategory) -%> </td>
+ </tr>
+ <% end -%>
+ </thead>
+ <tbody>
+ <% by_property_index_or_name(@definitions).each do |property| -%>
+ <tr class="property <%= cycle('even', 'odd', :name => 'properties') -%>">
+ <td style="padding: 10px" id="block_<%= property.key -%>">
+ <h3>
+ <div><%= property_name(property) -%></div>
+ <div class="note"><%= property.key -%></div>
+ </h3>
+ <% desc=property_description(property) -%>
+ <% unless desc.blank? %>
+ <p class="marginbottom10"><%= desc -%></p>
+ <% end -%>
- <% value = property_value(property) -%>
- <% if property.multi_values -%>
- <% value.each_with_index do |sub_value, index| -%>
- <%= render "settings/multi_value", :property => property, :value => sub_value, :hide_delete => index == 0 -%>
+ <% value = property_value(property) -%>
+ <% if property.multi_values -%>
+ <% value.each_with_index do |sub_value, index| -%>
+ <%= render "settings/multi_value", :property => property, :value => sub_value, :hide_delete => index == 0 -%>
+ <% end -%>
+ <div class="template" style="display:none;">
+ <%= render "settings/multi_value", :property => property, :value => nil, :hide_delete => false -%>
+ </div>
+ <button class="add_value"><%= message('settings.add') -%></button>
+ <br/>
+ <% else -%>
+ <%= render "settings/single_value", :property => property, :value => value -%>
<% end -%>
- <div class="template" style="display:none;">
- <%= render "settings/multi_value", :property => property, :value => nil, :hide_delete => false -%>
- </div>
- <button class="add_value"><%= message('settings.add') -%></button>
- <br/>
- <% else -%>
- <%= render "settings/single_value", :property => property, :value => value -%>
- <% end -%>
- <%= render "settings/error", :key => property.key -%>
+ <%= render "settings/error", :key => property.key -%>
- <% default_prop_value = (@resource ? Property.value(property.key, nil, property.defaultValue) : property.defaultValue) -%>
- <% unless default_prop_value.blank? -%>
- <div class="note"><%= message('default') %>: <%= property.type.to_s=='PASSWORD' ? '********' : h(default_prop_value) -%></div>
- <% end -%>
- </td>
- </tr>
- <% end -%>
+ <% default_prop_value = (@resource ? Property.value(property.key, nil, property.defaultValue) : property.defaultValue) -%>
+ <% unless default_prop_value.blank? -%>
+ <div class="note"><%= message('default') %>: <%= property.type.to_s=='PASSWORD' ? '********' : h(default_prop_value) -%></div>
+ <% end -%>
+ </td>
+ </tr>
+ <% end -%>
- <% unless @subcategory != @category || category_help(@category).blank? -%>
- <tr class="property <%= cycle('even', 'odd', :name => 'properties') -%>">
- <td class="help"><%= category_help(@category) -%> </td>
- </tr>
- <% end -%>
+ <% unless @subcategory != @category || category_help(@category).blank? -%>
+ <tr class="property <%= cycle('even', 'odd', :name => 'properties') -%>">
+ <td class="help"><%= category_help(@category) -%> </td>
+ </tr>
+ <% end -%>
- </tbody>
- </table>
- <% unless @definitions.empty? %>
- <div style="padding-left: 16px;">
- <%= hidden_field_tag('page_version', (params[:page_version] || 0).to_i + 1) -%>
- <%= submit_tag(message('settings.save_category', :params => [subcategory_name(@category, @subcategory)]), :id => 'submit_settings') -%>
- <img src="<%= ApplicationController.root_context -%>/images/loading.gif" id="loading_settings" style="display:none;">
- </div>
+ </tbody>
+ </table>
+ <% unless @definitions.empty? %>
+ <div style="padding-left: 16px;">
+ <%= hidden_field_tag('page_version', (params[:page_version] || 0).to_i + 1) -%>
+ <%= submit_tag(message('settings.save_category', :params => [subcategory_name(@category, @subcategory)]), :id => 'submit_settings') -%>
+ <img src="<%= ApplicationController.root_context -%>/images/loading.gif" id="loading_settings" style="display:none;">
+ </div>
+ <% end %>
<% end %>
<% end -%>
<% end -%>