self.author_id = au.id
end
- def own? au
- return false unless au.is_a?(Author)
+ def own? roles
+ roles = [roles] unless roles.respond_to?(:each)
+ au = Comic.get_author_from_roles roles
+ return false unless au
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)
+ def visible? roles
+ if MagicNumber['run_mode'] == 0
+ return false unless guest_role_check(roles)
else
- return false
+ return false unless reader_role_check(roles)
end
+ return true if self.own?(roles)
self.visible > 0
end
Comic.find(:all, opt)
end
- def self.show cid, au
+ def self.show cid, roles
opt = {}
opt.merge!(Comic.show_opt)
res = Comic.find(cid, opt)
- raise ActiveRecord::Forbidden unless res.visible?(au)
+ raise ActiveRecord::Forbidden unless res.visible?(roles)
res
end