OSDN Git Service

t#30266:oplg i18n
[pettanr/pettanr.git] / app / models / panel.rb
index 98437e4..ce18eec 100644 (file)
@@ -32,16 +32,22 @@ class Panel < ActiveRecord::Base
     self.author_id = au.id
   end
   
-  def visible? au
-    return false unless au
-    self.own?(au) or self.publish?
-  end
-  
   def own? au
-    return false unless au
+    return false unless au.is_a?(Author)
     self.author_id == au.id
   end
   
+  def visible? au
+    if au == nil
+      return false if MagicNumber['run_mode'] == 1
+    elsif au.is_a?(Author)
+      return true if self.own?(au)
+    else
+      return false
+    end
+    self.publish?
+  end
+  
   def usable? au
     visible? au
   end
@@ -193,6 +199,14 @@ class Panel < ActiveRecord::Base
     '[' + ary.map {|i| i.panel_elements_as_json }.join(',') + ']'
   end
   
+  def licensed_pictures
+    r = {}
+    ((self.panel_pictures || []) + (self.ground_pictures || [])).compact.each do |elm|
+      r[elm.picture_id] = elm.picture unless r[elm.picture_id]
+    end
+    r
+  end
+  
   def self.visible_count
     Panel.count
   end
@@ -252,7 +266,7 @@ class Panel < ActiveRecord::Base
     res
   end
   
-=begin\r
+=begin
   def self.validate_id ary, pid
     ary.map {|v|
       if pid