comparison app/models/.svn/text-base/project.rb.svn-base @ 507:0c939c159af4 redmine-1.2

Update to Redmine 1.2.1 on 1.2-stable branch (Redmine SVN rev 6270)
author Chris Cannam
date Thu, 14 Jul 2011 10:32:19 +0100
parents cbce1fd3b1b7
children
comparison
equal deleted inserted replaced
441:cbce1fd3b1b7 507:0c939c159af4
116 # non public projects will be returned only if user is a member of those 116 # non public projects will be returned only if user is a member of those
117 def self.latest(user=nil, count=5) 117 def self.latest(user=nil, count=5)
118 visible(user).find(:all, :limit => count, :order => "created_on DESC") 118 visible(user).find(:all, :limit => count, :order => "created_on DESC")
119 end 119 end
120 120
121 # Returns true if the project is visible to +user+ or to the current user.
122 def visible?(user=User.current)
123 user.allowed_to?(:view_project, self)
124 end
125
121 def self.visible_by(user=nil) 126 def self.visible_by(user=nil)
122 ActiveSupport::Deprecation.warn "Project.visible_by is deprecated and will be removed in Redmine 1.3.0. Use Project.visible_condition instead." 127 ActiveSupport::Deprecation.warn "Project.visible_by is deprecated and will be removed in Redmine 1.3.0. Use Project.visible_condition instead."
123 visible_condition(user || User.current) 128 visible_condition(user || User.current)
124 end 129 end
125 130
542 547
543 # Returns an array of the enabled modules names 548 # Returns an array of the enabled modules names
544 def enabled_module_names 549 def enabled_module_names
545 enabled_modules.collect(&:name) 550 enabled_modules.collect(&:name)
546 end 551 end
547 552
553 # Enable a specific module
554 #
555 # Examples:
556 # project.enable_module!(:issue_tracking)
557 # project.enable_module!("issue_tracking")
558 def enable_module!(name)
559 enabled_modules << EnabledModule.new(:name => name.to_s) unless module_enabled?(name)
560 end
561
562 # Disable a module if it exists
563 #
564 # Examples:
565 # project.disable_module!(:issue_tracking)
566 # project.disable_module!("issue_tracking")
567 # project.disable_module!(project.enabled_modules.first)
568 def disable_module!(target)
569 target = enabled_modules.detect{|mod| target.to_s == mod.name} unless enabled_modules.include?(target)
570 target.destroy unless target.blank?
571 end
572
548 safe_attributes 'name', 573 safe_attributes 'name',
549 'description', 574 'description',
550 'homepage', 575 'homepage',
551 'is_public', 576 'is_public',
552 'identifier', 577 'identifier',