lib/include/class_log.rb in knjappserver-0.0.19 vs lib/include/class_log.rb in knjappserver-0.0.20
- old
+ new
@@ -1,7 +1,11 @@
class Knjappserver::Log < Knj::Datarow
- def self.list(d)
+ has_many [
+ {:class => :Log_link, :col => :log_id, :method => :links, :depends => true, :autodelete => true}
+ ]
+
+ def self.list(d, &block)
sql = "SELECT #{table}.* FROM #{table}"
if d.args["object_lookup"]
data_val = d.ob.get_by(:Log_data_value, {"value" => d.args["object_lookup"].class.name})
return [] if !data_val #if this data-value cannot be found, nothing has been logged for the object. So just return empty array here and skip the rest.
@@ -28,11 +32,11 @@
sql << ret[:sql_where]
sql << ret[:sql_order]
sql << ret[:sql_limit]
- return d.ob.list_bysql(:Log, sql)
+ return d.ob.list_bysql(:Log, sql, &block)
end
def self.add(d)
d.data[:date_saved] = Time.now if !d.data.key?(:date_saved)
end
@@ -69,23 +73,23 @@
def meta
ob.args[:knjappserver].log_data_hash(self[:meta_keys_data_id], self[:meta_values_data_id])
end
+ def session
+ ob.args[:knjappserver].log_data_hash(self[:session_keys_data_id], self[:session_values_data_id])
+ end
+
def ip
meta_d = self.meta
return meta_d[:HTTP_X_FORWARDED_FOR] if meta_d.has_key?(:HTTP_X_FORWARDED_FOR)
return meta_d[:REMOTE_ADDR] if meta_d.has_key?(:REMOTE_ADDR)
return "[no ip logged]"
end
def first_line
lines = self.text.to_s.split("\n").first.to_s
- end
-
- def links(args = {})
- return ob.list(:Log_link, {"log" => self}.merge(args))
end
def objects_html(ob_use)
html = ""
first = true
\ No newline at end of file