diff --git a/app/controllers/admin/admin_panel_controller.rb b/app/controllers/admin/admin_panel_controller.rb index 6c2b103..1ef33a4 100644 --- a/app/controllers/admin/admin_panel_controller.rb +++ b/app/controllers/admin/admin_panel_controller.rb @@ -71,4 +71,22 @@ class AdminPanelController < AdminController end end end + + def manage_profile_status + scope = environment.profiles + @filter = params[:filter] || 'any' + @title = "All 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(:people, scope, @q, {:per_page => 10, :page => params[:npage]})[:results] + end end diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index 21277ee..cf57ccf 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -90,6 +90,20 @@ class ProfileEditorController < MyProfileController end end - redirect_to "/" + redirect_to request.referer + end + + def activate_profile + if environment.admins.include?(current_person) + profile = Profile.find(params[:id]) + + if profile.enable + session[:notice] = _("The profile '#{profile.name}' was activated.") + else + session[:notice] = _('Could not activate the profile.') + end + end + + redirect_to request.referer end end diff --git a/app/models/profile.rb b/app/models/profile.rb index 3482a52..5e01201 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -121,6 +121,7 @@ class Profile < ActiveRecord::Base end scope :visible, :conditions => { :visible => true } + scope :disabled, :conditions => { :visible => false } scope :public, :conditions => { :visible => true, :public_profile => true } # Subclasses must override this method @@ -900,6 +901,11 @@ private :generate_url, :url_options def disable end + def enable + self.visible = true + self.save + 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 163a6a0..b238db3 100644 --- a/app/views/admin_panel/index.html.erb +++ b/app/views/admin_panel/index.html.erb @@ -20,6 +20,7 @@
| <%= _('Member') %> | +<%= _('Actions') %> | +
|---|---|
| <%= link_to_profile p.short_name, p.identifier, :title => p.name %> | + ++ + | +