Class: AutoCompletesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/auto_completes_controller.rb

Overview

– copyright ChiliProject is a project management system.

Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

See doc/COPYRIGHT.rdoc for more details. ++

Instance Method Summary collapse

Methods included from Redmine::MenuManager::MenuController

#current_menu_item, included, #menu_items, #redirect_to_project_menu_item

Methods included from Redmine::Search::Controller

#default_search_scope, #default_search_scopes, included

Methods included from Redmine::I18n

#current_language, #day_name, #find_language, #format_date, #format_time, included, #l, #l_hours, #l_or_humanize, #ll, #month_name, #set_language_if_valid, #valid_languages

Instance Method Details

#issuesObject


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/auto_completes_controller.rb', line 19

def issues
  @issues = []
  q = params[:q].to_s

  if q.present?
    query = (params[:scope] == "all" && Setting.cross_project_issue_relations?) ? Issue : @project.issues

    @issues |= query.visible.find_all_by_id(q.to_i) if q =~ /^\d+$/

    @issues |= query.visible.find(:all,
                                  :limit => 10,
                                  :order => "#{Issue.table_name}.id ASC",
                                  :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE :q OR CAST(#{Issue.table_name}.id AS CHAR(13)) LIKE :q", {:q => "%#{q.downcase}%" }])
  end

  render :layout => false
end

#projectsObject


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

def projects
  @principal = Principal.find(params[:id])
  @projects = Project.active.like(params[:q]).find(:all, :limit => 100) - @principal.projects
  render :layout => false
end

#usersObject


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/auto_completes_controller.rb', line 37

def users
  if params[:remove_group_members].present?
    @group = Group.find(params[:remove_group_members])
    @removed_users = @group.users
  end

  if params[:remove_watchers].present? && params[:klass].present?
    watcher_class = params[:klass].constantize
    if watcher_class.included_modules.include?(Redmine::Acts::Watchable) # check class is a watching class
      @object = watcher_class.find(params[:remove_watchers])
      @removed_users = @object.watcher_users
    end
  end

  @removed_users ||= []

  if params[:include_groups]
    user_finder = Principal
  else
    user_finder = User
  end

  @users = user_finder.active.like(params[:q]).find(:all, :limit => 100) - @removed_users
  render :layout => false
end