To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / app / controllers / context_menus_controller.rb @ 1541:2696466256ff

History | View | Annotate | Download (3.21 KB)

1
# Redmine - project management software
2
# Copyright (C) 2006-2014  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

    
18
class ContextMenusController < ApplicationController
19
  helper :watchers
20
  helper :issues
21

    
22
  before_filter :find_issues, :only => :issues
23

    
24
  def issues
25
    if (@issues.size == 1)
26
      @issue = @issues.first
27
    end
28
    @issue_ids = @issues.map(&:id).sort
29

    
30
    @allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
31

    
32
    @can = {:edit => User.current.allowed_to?(:edit_issues, @projects),
33
            :log_time => (@project && User.current.allowed_to?(:log_time, @project)),
34
            :update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)),
35
            :move => (@project && User.current.allowed_to?(:move_issues, @project)),
36
            :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
37
            :delete => User.current.allowed_to?(:delete_issues, @projects)
38
            }
39
    if @project
40
      if @issue
41
        @assignables = @issue.assignable_users
42
      else
43
        @assignables = @project.assignable_users
44
      end
45
      @trackers = @project.trackers
46
    else
47
      #when multiple projects, we only keep the intersection of each set
48
      @assignables = @projects.map(&:assignable_users).reduce(:&)
49
      @trackers = @projects.map(&:trackers).reduce(:&)
50
    end
51
    @versions = @projects.map {|p| p.shared_versions.open}.reduce(:&)
52

    
53
    @priorities = IssuePriority.active.reverse
54
    @back = back_url
55

    
56
    @options_by_custom_field = {}
57
    if @can[:edit]
58
      custom_fields = @issues.map(&:editable_custom_fields).reduce(:&).reject(&:multiple?)
59
      custom_fields.each do |field|
60
        values = field.possible_values_options(@projects)
61
        if values.present?
62
          @options_by_custom_field[field] = values
63
        end
64
      end
65
    end
66

    
67
    @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
68
    render :layout => false
69
  end
70

    
71
  def time_entries
72
    @time_entries = TimeEntry.where(:id => params[:ids]).preload(:project).to_a
73
    (render_404; return) unless @time_entries.present?
74

    
75
    @projects = @time_entries.collect(&:project).compact.uniq
76
    @project = @projects.first if @projects.size == 1
77
    @activities = TimeEntryActivity.shared.active
78
    @can = {:edit   => User.current.allowed_to?(:edit_time_entries, @projects),
79
            :delete => User.current.allowed_to?(:edit_time_entries, @projects)
80
            }
81
    @back = back_url
82
    render :layout => false
83
  end
84
end