Class: AdminController

Inherits:
BaseController show all
Defined in:
app/controllers/admin_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#advertise, #cache_action?, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index

Methods included from BaseHelper

#add_friend_link, #ajax_spinner_for, #avatar_for, #block_to_partial, #box, #city_cloud, #clippings_link, #commentable_url, #container_title, #excerpt_with_jump, #flash_class, #forum_page?, #is_current_user_and_featured?, #jumbotron, #last_active, #more_comments_links, #page_title, #paginating_links, #possesive, #profile_completeness, #render_jumbotron, #render_widgets, #rounded, #search_posts_title, #search_user_posts_path, #show_footer_content?, #tag_auto_complete_field, #time_ago_in_words, #time_ago_in_words_or_date, #tiny_mce_init_if_needed, #tiny_mce_js, #topnav_tab, #truncate_words, #truncate_words_with_highlight, #widget

Methods included from LocalizedApplication

#get_matching_ui_locale, #get_sorted_langs_from_accept_header, #get_valid_lang_from_accept_header, #set_locale

Methods included from AuthenticatedSystem

#login_by_token, #update_last_seen_at

Instance Method Details

#activate_userObject


55
56
57
58
59
60
# File 'app/controllers/admin_controller.rb', line 55

def activate_user
  user = User.find(params[:id])
  user.activate
  flash[:notice] = :the_user_was_activated.l
  redirect_to :action => :users
end

#clear_cacheObject


4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/admin_controller.rb', line 4

def clear_cache
  case Rails.cache
    when ActiveSupport::Cache::FileStore
      dir = Rails.cache.cache_path
      unless dir == Rails.public_path
        FileUtils.rm_r(Dir.glob(dir+"/*")) rescue Errno::ENOENT
        Rails.logger.info("Cache directory fully swept.")
      end
      flash[:notice] = :cache_cleared.l
    else
      Rails.logger.warn("Cache not swept: you must override AdminController#clear_cache to support #{Rails.cache}")
  end
  redirect_to admin_dashboard_path and return
end

#commentsObject


49
50
51
52
53
# File 'app/controllers/admin_controller.rb', line 49

def comments
  @search = Comment.search(params[:q])
  @comments = @search.result.distinct
  @comments = @comments.order("created_at DESC").page(params[:page]).per(100)
end

#deactivate_userObject


62
63
64
65
66
67
# File 'app/controllers/admin_controller.rb', line 62

def deactivate_user
  user = User.find(params[:id])
  user.deactivate
  flash[:notice] = :the_user_was_deactivated.l
  redirect_to :action => :users
end

#eventsObject


19
20
21
# File 'app/controllers/admin_controller.rb', line 19

def events
  @events = Event.order('start_time DESC').page(params[:page])
end

#messagesObject


23
24
25
26
# File 'app/controllers/admin_controller.rb', line 23

def messages
  @user = current_user
  @messages = Message.order('created_at DESC').page(params[:page]).per(50)
end

#subscribersObject


69
70
71
72
73
74
75
76
77
78
# File 'app/controllers/admin_controller.rb', line 69

def subscribers
  @users = User.where("notify_community_news = ? AND users.activated_at IS NOT NULL", (params[:unsubs] ? false : true))

  respond_to do |format|
    format.xml {
      render :xml => @users.to_xml(:only => [:login, :email])
    }
  end

end

#usersObject


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/admin_controller.rb', line 28

def users
  @users = User.recent
  user = User.arel_table

  if params['login']
    @users = @users.where(user[:login].matches("%#{params['login']}%"))
  end
  if params['email']
    @users = @users.where(user[:email].matches("%#{params['email']}%"))
  end

  @users = @users.page(params[:page]).per(100)

  respond_to do |format|
    format.html
    format.xml {
      render :xml => @users.to_xml(:except => [ :password, :crypted_password, :single_access_token, :perishable_token, :password_salt, :persistence_token ])
    }
  end
end