##// END OF EJS Templates
Applied 'register notice' patch by Matt Jones....
Applied 'register notice' patch by Matt Jones. The user is now redirected to the login screen after having registered. git-svn-id: http://redmine.rubyforge.org/svn/trunk@601 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r537:6446c312beab
r598:acebceb1d74b
Show More
permission.rb
68 lines | 2.2 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # redMine - project management software
# Copyright (C) 2006 Jean-Philippe Lang
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class Permission < ActiveRecord::Base
has_and_belongs_to_many :roles
validates_presence_of :controller, :action, :description
GROUPS = {
100 => :label_project,
200 => :label_member_plural,
300 => :label_version_plural,
400 => :label_issue_category_plural,
600 => :label_query_plural,
1000 => :label_issue_plural,
1100 => :label_news_plural,
1200 => :label_document_plural,
1300 => :label_attachment_plural,
Jean-Philippe Lang
Simple time tracking functionality added. Time can be logged at issue or project level....
r365 1400 => :label_repository,
Jean-Philippe Lang
Per project forums added....
r526 1500 => :label_time_tracking,
Jean-Philippe Lang
Added the ability to destroy wiki pages (content and its history are deleted from the database)....
r537 1700 => :label_wiki_page_plural,
Jean-Philippe Lang
Per project forums added....
r526 2000 => :label_board_plural
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 }.freeze
@@cached_perms_for_public = nil
@@cached_perms_for_roles = nil
def name
self.controller + "/" + self.action
end
def group_id
(self.sort / 100)*100
end
def self.allowed_to_public(action)
@@cached_perms_for_public ||= find(:all, :conditions => ["is_public=?", true]).collect {|p| "#{p.controller}/#{p.action}"}
@@cached_perms_for_public.include? action
end
def self.allowed_to_role(action, role)
@@cached_perms_for_roles ||=
begin
perms = {}
find(:all, :include => :roles).each {|p| perms.store "#{p.controller}/#{p.action}", p.roles.collect {|r| r.id } }
perms
end
Jean-Philippe Lang
Various code cleaning, mainly on User, Permission and IssueStatus models....
r411 allowed_to_public(action) or (role && @@cached_perms_for_roles[action] && @@cached_perms_for_roles[action].include?(role.id))
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
def self.allowed_to_role_expired
@@cached_perms_for_roles = nil
Jean-Philippe Lang
Initial commit...
r2 end
end