]> source.dussan.org Git - redmine.git/commitdiff
Merged r6203 and r6204 from trunk.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 9 Jul 2011 11:42:12 +0000 (11:42 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 9 Jul 2011 11:42:12 +0000 (11:42 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.2-stable@6205 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project.rb
app/views/projects/index.api.rsb
app/views/projects/show.api.rsb

index c9d00e9b78eed7d9001fe450bfc750a69c21ecf5..c3b55308320f2cb8c0800660221984efea0c23ac 100644 (file)
@@ -118,6 +118,11 @@ class Project < ActiveRecord::Base
     visible(user).find(:all, :limit => count, :order => "created_on DESC")     
   end  
 
+  # Returns true if the project is visible to +user+ or to the current user.
+  def visible?(user=User.current)
+    user.allowed_to?(:view_project, self)
+  end
+  
   def self.visible_by(user=nil)
     ActiveSupport::Deprecation.warn "Project.visible_by is deprecated and will be removed in Redmine 1.3.0. Use Project.visible_condition instead."
     visible_condition(user || User.current)
index 121300c12c2fb466dd7611645ab64498bb2c530b..552c1f65e393243e0aa4ca996b20fe58b9c88f9c 100644 (file)
@@ -5,7 +5,7 @@ api.array :projects, api_meta(:total_count => @project_count, :offset => @offset
       api.name        project.name
       api.identifier  project.identifier
       api.description project.description
-      api.parent(:id => project.parent_id, :name => project.parent.name) unless project.parent.nil?
+      api.parent(:id => project.parent.id, :name => project.parent.name) if project.parent && project.parent.visible?
       
       render_api_custom_values project.visible_custom_field_values, api
       
index e08f77b6645d9fbcb1102eaff9c19fe18dc2b9c3..561896a64c74ddf3c9444c1d1dcb3c147fb2c76b 100644 (file)
@@ -4,6 +4,7 @@ api.project do
   api.identifier  @project.identifier
   api.description @project.description
   api.homepage    @project.homepage
+  api.parent(:id => @project.parent.id, :name => @project.parent.name) if @project.parent && @project.parent.visible?
   
   render_api_custom_values @project.visible_custom_field_values, api