diff --git a/app/controllers/admin/admin_panel_controller.rb b/app/controllers/admin/admin_panel_controller.rb
index 59c87a7..6c2b103 100644
--- a/app/controllers/admin/admin_panel_controller.rb
+++ b/app/controllers/admin/admin_panel_controller.rb
@@ -71,22 +71,4 @@ class AdminPanelController < AdminController
end
end
end
-
- def manage_organizations_status
- scope = environment.organizations
- @filter = params[:filter] || 'any'
- @title = "Organization profiles"
- @title = @title+" - "+@filter if @filter != 'any'
-
- if @filter == 'enabled'
- scope = scope.visible
- elsif @filter == 'disabled'
- scope = scope.disabled
- end
-
- scope = scope.order('name ASC')
-
- @q = params[:q]
- @collection = find_by_contents(:organizations, environment, scope, @q, {:per_page => 10, :page => params[:npage]})[:results]
- end
end
diff --git a/app/controllers/admin/organizations_controller.rb b/app/controllers/admin/organizations_controller.rb
new file mode 100644
index 0000000..25f413c
--- /dev/null
+++ b/app/controllers/admin/organizations_controller.rb
@@ -0,0 +1,66 @@
+class OrganizationsController < AdminController
+
+ protect 'manage_environment_organizations', :environment
+
+ def index
+ @filter = params[:filter] || 'any'
+ @title = _('Organization profiles')
+ @type = params[:type] || "any"
+ @types_filter = [[_('All'), 'any'], [_('Community'), 'Community'], [_('Enterprise'), 'Enterprise']]
+ @types_filter = @types_filter | @plugins.dispatch(:organization_types_filter_options)
+
+ scope = @plugins.dispatch_first(:filter_manage_organization_scope, @type)
+ if scope.blank?
+ scope = environment.organizations
+ scope = scope.where(:type => @type) if @type != 'any'
+ end
+
+ if @filter == 'enabled'
+ scope = scope.visible
+ elsif @filter == 'disabled'
+ scope = scope.disabled
+ end
+
+ scope = scope.order('name ASC')
+
+ @q = params[:q]
+ @collection = find_by_contents(:organizations, environment, scope, @q, {:per_page => per_page, :page => params[:npage]})[:results]
+ end
+
+ def activate
+ organization = environment.organizations.find(params[:id])
+ if organization.enable
+ render :text => (_('%s enabled') % organization.name).to_json
+ else
+ render :text => (_('%s could not be enabled') % organization.name).to_json
+ end
+ end
+
+ def deactivate
+ organization = environment.organizations.find(params[:id])
+ if organization.disable
+ render :text => (_('%s disabled') % organization.name).to_json
+ else
+ render :text => (_('%s could not be disable') % organization.name).to_json
+ end
+ end
+
+ def destroy
+ if request.post?
+ organization = environment.organizations.find(params[:id])
+ if organization && organization.destroy
+ render :text => (_('%s removed') % organization.name).to_json
+ else
+ render :text => (_('%s could not be removed') % organization.name).to_json
+ end
+ else
+ render :nothing => true
+ end
+ end
+
+ private
+
+ def per_page
+ 10
+ end
+end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index cf567d2..befcecc 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -14,7 +14,7 @@ module UsersHelper
select_field = select_tag(:filter, options, :onchange => onchange)
content_tag('div',
content_tag('strong', _('Filter')) + ': ' + select_field,
- :class => "environment-users-customize-search"
+ :class => "environment-profiles-customize-search"
)
end
diff --git a/app/models/environment.rb b/app/models/environment.rb
index e101216..050708a 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -29,6 +29,7 @@ class Environment < ActiveRecord::Base
'manage_environment_roles' => N_('Manage environment roles'),
'manage_environment_validators' => N_('Manage environment validators'),
'manage_environment_users' => N_('Manage environment users'),
+ 'manage_environment_organizations' => N_('Manage environment organizations'),
'manage_environment_templates' => N_('Manage environment templates'),
'manage_environment_licenses' => N_('Manage environment licenses'),
'manage_environment_trusted_sites' => N_('Manage environment trusted sites'),
diff --git a/app/models/profile.rb b/app/models/profile.rb
index 9319918..3220fd2 100644
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -957,11 +957,19 @@ private :generate_url, :url_options
self.save
end
+ def disabled?
+ !visible
+ end
+
def enable
self.visible = true
self.save
end
+ def enabled?
+ visible
+ end
+
def control_panel_settings_button
{:title => _('Edit Profile'), :icon => 'edit-profile'}
end
diff --git a/app/views/admin_panel/index.html.erb b/app/views/admin_panel/index.html.erb
index f5980be..eab20d5 100644
--- a/app/views/admin_panel/index.html.erb
+++ b/app/views/admin_panel/index.html.erb
@@ -18,9 +18,9 @@
<%= link_to _('User roles'), :controller => 'role' %> |
<%= link_to _('Users'), :controller => 'users' %> |
+ <%= link_to _('Organizations'), :controller => 'organizations' %> |
<%= link_to _('Profile templates'), :controller => 'templates' %> |
<%= link_to _('Fields'), :controller => 'features', :action => 'manage_fields' %> |
- <%= link_to _('Manage organizations status'), :action => 'manage_organizations_status' %> |
diff --git a/app/views/admin_panel/manage_organizations_status.html.erb b/app/views/admin_panel/manage_organizations_status.html.erb
deleted file mode 100644
index 3a708f1..0000000
--- a/app/views/admin_panel/manage_organizations_status.html.erb
+++ /dev/null
@@ -1,69 +0,0 @@
-<%= _('Manage organizations') %>
-
-<%= form_tag( { :action => 'manage_organizations_status' }, :method => 'get', :class => 'users-search' ) do %>
-
-
-
- <%= text_field_tag 'q', @q, :title => _("Find profiles"), :style=>"width:85%" %>
-
-
- <%= submit_button(:search, _('Search')) %>
-
-
-
-
-
-
-
-
-
-
-
- <%= _('Member') %> |
- <%= _('Actions') %> |
-
-
- <% @collection.each do |p| %>
-
- <%= link_to_profile p.short_name, p.identifier, :title => p.name %> |
-
-
-
- <% if p.visible %>
- <%= button_without_text :'deactivate-user', _('Deactivate'), {:controller => "profile_editor", :action => 'deactivate_profile', :profile => p.identifier, :id => p.id}, :confirm => _("Do you want to deactivate this profile ?") %>
- <% else %>
- <%= button_without_text :'activate-user', _('Activate'), {:controller => "profile_editor", :action => 'activate_profile', :profile => p.identifier, :id => p.id}, :confirm => _("Do you want to activate this profile ?") %>
- <% end %>
- <%= button_without_text :'delete', _('Remove'), {:controller => "profile_editor", :action => 'destroy_profile', :profile => p.identifier, :id => p.id, :return_to => "/admin/admin_panel/manage_organizations_status"}, :method => :post, :confirm => _("Do you want to deactivate this profile ?") %>
-
- |
-
- <% end %>
-
-
-<% end %>
-
-<%= pagination_links @collection, {:param_name => 'npage', :page_links => true} %>
-
-<% button_bar do %>
- <%= button :back, _('Back'), :controller => 'admin_panel' %>
-<% end %>
-
-
\ No newline at end of file
diff --git a/app/views/organizations/_results.html.erb b/app/views/organizations/_results.html.erb
new file mode 100644
index 0000000..03bd40c
--- /dev/null
+++ b/app/views/organizations/_results.html.erb
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+ <%= _('Profile') %> |
+ <%= _('Actions') %> |
+ <%= _('Type') %>
+
+ <%= select_tag(:type, options_for_select(@types_filter, @type)) %>
+ |
+
+
+ <% @collection.each do |p| %>
+
+ <%= link_to_profile p.short_name, p.identifier, :title => p.name %> |
+
+
+
+ <% if p.visible %>
+ <%= button_without_text :'deactivate-user', _('Deactivate'), {:action => 'deactivate', :id => p.id}, :class => 'action', 'data-confirm' => _("Do you want to deactivate this organization?") %>
+ <% else %>
+ <%= button_without_text :'activate-user', _('Activate'), {:action => 'activate', :id => p.id}, :class => 'action', 'data-confirm' => _("Do you want to activate this organization?") %>
+ <% end %>
+ <%= button_without_text :'delete', _('Remove'), {:action => 'destroy', :id => p.id}, :class => 'action', 'data-method' => :post, 'data-confirm' => _("Do you want to destroy this organization?") %>
+
+ |
+
+ <%= _("#{p.type}") %> |
+
+ <% end %>
+
+
+
+ <%= pagination_links @collection, {:param_name => 'npage', :page_links => true} %>
+
+
diff --git a/app/views/organizations/index.html.erb b/app/views/organizations/index.html.erb
new file mode 100644
index 0000000..0370a3d
--- /dev/null
+++ b/app/views/organizations/index.html.erb
@@ -0,0 +1,30 @@
+<%= _('Organizations') %>
+
+<%= form_tag( { :action => 'index' }, :method => 'get', :id => 'manage-profiles' ) do %>
+
+
+
+ <%= text_field_tag 'q', @q, :title => _('Find organizations'), :style=>"width:85%" %>
+
+
+ <%= submit_button(:search, _('Search')) %>
+
+
+
+
+ <%= render :partial => 'results' %>
+
+ <% button_bar do %>
+ <%= button :back, _('Back'), :controller => 'admin_panel' %>
+ <% end %>
+<% end %>
+
+<%= javascript_include_tag 'manage-organizations' %>
diff --git a/app/views/organizations/index.js.erb b/app/views/organizations/index.js.erb
new file mode 120000
index 0000000..be47f81
--- /dev/null
+++ b/app/views/organizations/index.js.erb
@@ -0,0 +1 @@
+../../views/shared/admin/profiles/index.js.rb
\ No newline at end of file
diff --git a/app/views/shared/admin/profiles/index.js.rb b/app/views/shared/admin/profiles/index.js.rb
new file mode 100644
index 0000000..c7e295f
--- /dev/null
+++ b/app/views/shared/admin/profiles/index.js.rb
@@ -0,0 +1 @@
+jQuery('#manage-profiles .results').replaceWith('<%= escape_javascript(render 'results') %>');
diff --git a/app/views/users/_users_list.html.erb b/app/views/users/_users_list.html.erb
index 97bf13f..8b219aa 100644
--- a/app/views/users/_users_list.html.erb
+++ b/app/views/users/_users_list.html.erb
@@ -1,5 +1,5 @@
-