OSDN Git Service

temp
[pettanr/pettanr.git] / app / controllers / pictures_controller.rb
index 7cfaf3c..959f171 100644 (file)
@@ -1,25 +1,33 @@
 class PicturesController < ApplicationController
   layout 'test' if MagicNumber['test_layout']
-  before_filter :authenticate_user!, :only => [:show, :credit, :md5]
-  before_filter :authenticate_author, :only => [:show, :credit, :md5]
-  before_filter :authenticate_artist, :only => [:md5]
+  if MagicNumber['run_mode'] == 0
+    before_filter :authenticate_user, :only => []
+    before_filter :authenticate_author, :only => []
+  else
+    before_filter :authenticate_user, :only => []
+    before_filter :authenticate_resource_reader, :only => [:show, :credit, :search]
+    before_filter :authenticate_author, :only => []
+  end
   before_filter :authenticate_admin!, :only => [:list, :browse]
   
   def show
-    @picture = Picture.show(params[:id], @author)
+    @item = Picture.show(params[:id], @operators)
 
     respond_to do |format|
-      opt = {:type => @picture.mime_type, :disposition=>"inline"}
-      format.png { send_data(@picture.restore(params[:subdir]), opt ) }
-      format.gif { send_data(@picture.restore(params[:subdir]), opt ) }
-      format.jpeg { send_data(@picture.restore(params[:subdir]), opt ) }
-      format.html 
-      format.json { render :json => @picture.to_json}
+      opt = {:type => @item.mime_type, :disposition=>"inline"}
+      format.png { send_data(@item.restore(params[:subdir]), opt ) }
+      format.gif { send_data(@item.restore(params[:subdir]), opt ) }
+      format.jpeg { send_data(@item.restore(params[:subdir]), opt ) }
+      format.html {
+        @picture = @item
+      }
+      format_prof format
+      format.json { render :json => @item.to_json}
     end
   end
   
   def credit
-    @picture = Picture.show(params[:id], @author)
+    @picture = Picture.show(params[:id], [@user, @admin, @demand_user])
 
     respond_to do |format|
       format.html { render :layout => false } # show.html.erb
@@ -27,7 +35,7 @@ class PicturesController < ApplicationController
     end
   end
   
-  def md5
+  def search
     @pictures = Picture.list_by_md5(params[:md5])
     
     respond_to do |format|