Class Commenting
In: app/models/commenting.rb
Parent: ActiveRecord::Base

Methods

Public Instance methods

Destroys links from and to the same logi

[Source]

    # File app/models/commenting.rb, line 69
69:   def destroy_matching_link
70:     link = self.from_logi.from_links.find_by_to_logi_id(self.to_logi)
71:     if link
72:       link.destroy
73:     end
74:   end

Logs the link‘s creation to LogLog

[Source]

    # File app/models/commenting.rb, line 36
36:   def log_create_to_log_log
37:     if GlobalConfig.use_log_log
38:       # Has reply
39:       # four previous replyers and logi creator receive notice
40:       comments = self.from_logi.commenting_logis.find(:all,
41:           :limit => 5, :order => ["created_at DESC"])
42:       names = [self.from_logi.creator.unix_name] +
43:           comments[1..-1].collect {|l| l.creator.unix_name}
44:       channels = ['all', 'replies'] +
45:           names.uniq.collect {|n| 'for_' + n}
46:       m = LogLogMessage.new(
47:           :kind => "Reply",
48:           :channel_names => channels.join(','),
49:           :title => 'Received: ' + self.to_logi.current_title,
50:           :author => self.user.name,
51:           :text => self.to_logi.current_snippet,
52:           :url => GlobalConfig.site_url + self.to_logi.link.to_s)
53:       m.save
54:       # In reply to
55:       m = LogLogMessage.new(
56:           :kind => "Reply",
57:           :channel_name => 
58:               'for_' + self.to_logi.creator.unix_name,
59:           :title => 'To: ' + self.from_logi.current_title,
60:           :author => self.user.name,
61:           :text => self.from_logi.current_snippet,
62:           :url => GlobalConfig.site_url + self.from_logi.link.to_s)
63:       m.save
64:     end
65:   end

Validates that it is to a different logi.

[Source]

    # File app/models/commenting.rb, line 80
80:   def validate
81:     if self.from_logi == self.to_logi
82:       self.errors.add(:to_logi, t('defaults.error_cannot_point'))
83:     end
84:   end

[Validate]