Sha256: 48ac234410868cf01e0ae267d1dbaf63bfb1e4d5f707c3299a653a7e6853fa08

Contents?: true

Size: 1.17 KB

Versions: 19

Compression:

Stored size: 1.17 KB

Contents

#
# A group represents a collection of permissions. Each User can be assigned to one or more groups, and the sum of
# their permissions from all groups combined represents what they can do.
#
class Group < ActiveRecord::Base

  GUEST_CODE = "guest"

  has_many :user_group_memberships
  has_many :users, :through => :user_group_memberships
  
  has_many :group_permissions
  has_many :permissions, :through => :group_permissions
  
  has_many :group_sections
  has_many :sections, :through => :group_sections
  
  belongs_to :group_type
    
  validates_presence_of :name
  
  named_scope :named, lambda{|n| {:conditions => {:name => n}}}
  named_scope :with_code, lambda{|c| {:conditions => {:code => c}}}
    
  named_scope :public, :include => :group_type, :conditions => ["group_types.cms_access = ?", false]
  named_scope :cms_access, :include => :group_type, :conditions => ["group_types.cms_access = ?", true]
  
  def guest?
    group_type && group_type.guest?
  end
  
  def cms_access?
    group_type && group_type.cms_access?
  end

  # Finds the guest group, which is a special group that represents public non-logged in users.
  def self.guest
    with_code(GUEST_CODE).first
  end

end

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
browsercms-3.1.5 app/models/group.rb
browsercms-3.1.4 app/models/group.rb
browsercms-3.1.3 app/models/group.rb
bf4-browsercms-3.1.0 app/models/group.rb
drujensen-browsercms-3.2.0 app/models/group.rb
browsercmsi-3.1.2 app/models/group.rb
browsercms-3.1.2 app/models/group.rb
browsercms-3.1.1 app/models/group.rb
browsercmsi-3.1.1 app/models/group.rb
browsercmsi-3.1.0 app/models/group.rb
browsercms-3.1.0 app/models/group.rb
we5-browsercms-3.1.0 app/models/group.rb
browsercms-3.0.6 app/models/group.rb
browsercms-3.0.5 app/models/group.rb
we5-browsercms-3.0.5.1 app/models/group.rb
we5-browsercms-3.0.5 app/models/group.rb
browsercms_s3-3.0.5 app/models/group.rb
browsercms-3.0.4 app/models/group.rb
browsercms-3.0.3 app/models/group.rb