Revision 1297:0a574315af3e .svn/pristine/5e

View differences:

.svn/pristine/5e/5e390f603bdbad7d66b593eb5193b691dc1766d9.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2012  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 RolesController < ApplicationController
19
  layout 'admin'
20

  
21
  before_filter :require_admin, :except => [:index, :show]
22
  before_filter :require_admin_or_api_request, :only => [:index, :show]
23
  before_filter :find_role, :only => [:show, :edit, :update, :destroy]
24
  accept_api_auth :index, :show
25

  
26
  def index
27
    respond_to do |format|
28
      format.html {
29
        @role_pages, @roles = paginate :roles, :per_page => 25, :order => 'builtin, position'
30
        render :action => "index", :layout => false if request.xhr?
31
      }
32
      format.api {
33
        @roles = Role.givable.all
34
      }
35
    end
36
  end
37

  
38
  def show
39
    respond_to do |format|
40
      format.api
41
    end
42
  end
43

  
44
  def new
45
    # Prefills the form with 'Non member' role permissions by default
46
    @role = Role.new(params[:role] || {:permissions => Role.non_member.permissions})
47
    if params[:copy].present? && @copy_from = Role.find_by_id(params[:copy])
48
      @role.copy_from(@copy_from)
49
    end
50
    @roles = Role.sorted.all
51
  end
52

  
53
  def create
54
    @role = Role.new(params[:role])
55
    if request.post? && @role.save
56
      # workflow copy
57
      if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from]))
58
        @role.workflow_rules.copy(copy_from)
59
      end
60
      flash[:notice] = l(:notice_successful_create)
61
      redirect_to :action => 'index'
62
    else
63
      @roles = Role.sorted.all
64
      render :action => 'new'
65
    end
66
  end
67

  
68
  def edit
69
  end
70

  
71
  def update
72
    if request.put? and @role.update_attributes(params[:role])
73
      flash[:notice] = l(:notice_successful_update)
74
      redirect_to :action => 'index'
75
    else
76
      render :action => 'edit'
77
    end
78
  end
79

  
80
  def destroy
81
    @role.destroy
82
    redirect_to :action => 'index'
83
  rescue
84
    flash[:error] =  l(:error_can_not_remove_role)
85
    redirect_to :action => 'index'
86
  end
87

  
88
  def permissions
89
    @roles = Role.sorted.all
90
    @permissions = Redmine::AccessControl.permissions.select { |p| !p.public? }
91
    if request.post?
92
      @roles.each do |role|
93
        role.permissions = params[:permissions][role.id.to_s]
94
        role.save
95
      end
96
      flash[:notice] = l(:notice_successful_update)
97
      redirect_to :action => 'index'
98
    end
99
  end
100

  
101
  private
102

  
103
  def find_role
104
    @role = Role.find(params[:id])
105
  rescue ActiveRecord::RecordNotFound
106
    render_404
107
  end
108
end
.svn/pristine/5e/5e3af8c4c7c28bed0a24a4354356c4d0b62d7883.svn-base
1
syntax: glob
2

  
3
.project
4
.loadpath
5
config/additional_environment.rb
6
config/configuration.yml
7
config/database.yml
8
config/email.yml
9
config/initializers/session_store.rb
10
config/initializers/secret_token.rb
11
coverage
12
db/*.db
13
db/*.sqlite3
14
db/schema.rb
15
files/*
16
lib/redmine/scm/adapters/mercurial/redminehelper.pyc
17
lib/redmine/scm/adapters/mercurial/redminehelper.pyo
18
log/*.log*
19
log/mongrel_debug
20
public/dispatch.*
21
public/plugin_assets
22
tmp/*
23
tmp/cache/*
24
tmp/pdf/*
25
tmp/sessions/*
26
tmp/sockets/*
27
tmp/test/*
28
tmp/thumbnails/*
29
vendor/cache
30
vendor/rails
31
*.rbc
32

  
33
.svn/
34
.git/
35

  
36
.bundle
37
Gemfile.lock
38
Gemfile.local
39

  
.svn/pristine/5e/5e5c7a06369997d780ba724ee2cb92a1682a8e99.svn-base
1
<div class="contextual">
2
<% if User.current.allowed_to?(:manage_issue_relations, @project) %>
3
  <%= toggle_link l(:button_add), 'new-relation-form', {:focus => 'relation_issue_to_id'} %>
4
<% end %>
5
</div>
6

  
7
<p><strong><%=l(:label_related_issues)%></strong></p>
8

  
9
<% if @relations.present? %>
10
<form>
11
<table class="list issues">
12
<% @relations.each do |relation| %>
13
<tr class="issue hascontextmenu" id="relation-<%= relation.id %>">
14
<td class="checkbox"><%= check_box_tag("ids[]", relation.other_issue(@issue).id, false, :id => nil) %></td>
15
<td class="subject"><%= l(relation.label_for(@issue)) %> <%= "(#{l('datetime.distance_in_words.x_days', :count => relation.delay)})" if relation.delay && relation.delay != 0 %>
16
    <%= h(relation.other_issue(@issue).project) + ' - ' if Setting.cross_project_issue_relations? %>
17
    <%= link_to_issue(relation.other_issue(@issue), :truncate => 60) %>
18
</td>
19
<td class="status"><%=h relation.other_issue(@issue).status.name %></td>
20
<td class="start_date"><%= format_date(relation.other_issue(@issue).start_date) %></td>
21
<td class="due_date"><%= format_date(relation.other_issue(@issue).due_date) %></td>
22
<td class="buttons"><%= link_to image_tag('link_break.png'),
23
                                {:controller => 'issue_relations', :action => 'destroy', :id => relation},
24
                                :remote => true,
25
                                :method => :delete,
26
                                :data => {:confirm => l(:text_are_you_sure)},
27
                                :title => l(:label_relation_delete) if User.current.allowed_to?(:manage_issue_relations, @project) %></td>
28
</tr>
29
<% end %>
30
</table>
31
</form>
32
<% end %>
33

  
34
<%= form_for @relation, {
35
                 :as => :relation, :remote => true,
36
                 :url => {:controller => 'issue_relations', :action => 'create', :issue_id => @issue},
37
                 :method => :post,
38
                 :html => {:id => 'new-relation-form', :style => (@relation ? '' : 'display: none;')}
39
               } do |f| %>
40
<%= render :partial => 'issue_relations/form', :locals => {:f => f}%>
41
<% end %>

Also available in: Unified diff