Feature #1554 » private_messages-2011-12-14-v1.3.patch
| app/helpers/journals_helper.rb (working copy) | ||
|---|---|---|
|
onclick = "new Ajax.Request('#{url_for(url)}', {asynchronous:true, evalScripts:true, method:'get'}); return false;"
|
||
|
link_to text, '#', options.merge(:onclick => onclick)
|
||
|
end
|
||
|
def only_private_messages?(journals)
|
||
|
journals.each do |journal|
|
||
|
return false if ! journal.private
|
||
|
end
|
||
|
|
||
|
true
|
||
|
end
|
||
|
end
|
||
| app/models/mailer.rb (working copy) | ||
|---|---|---|
|
# Mailer.deliver_issue_edit(journal) => sends an email to issue recipients
|
||
|
def issue_edit(journal)
|
||
|
issue = journal.journalized.reload
|
||
|
private = journal[:private]
|
||
|
redmine_headers 'Project' => issue.project.identifier,
|
||
|
'Issue-Id' => issue.id,
|
||
|
'Issue-Author' => issue.author.login
|
||
| ... | ... | |
|
message_id journal
|
||
|
references issue
|
||
|
@author = journal.user
|
||
|
recipients issue.recipients
|
||
|
@recipients ||= []
|
||
|
watchers = issue.watcher_recipients - @recipients
|
||
|
processed_recipients = prepare_receivers issue.recipients, issue.project, private
|
||
|
processed_watchers = prepare_receivers watchers, issue.project, private
|
||
|
recipients processed_recipients
|
||
|
# Watchers in cc
|
||
|
cc(issue.watcher_recipients - @recipients)
|
||
|
cc(processed_watchers)
|
||
|
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] "
|
||
|
s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
|
||
|
s << "[PRIVATE] " if journal.private
|
||
|
s << issue.subject
|
||
|
subject s
|
||
|
body :issue => issue,
|
||
| ... | ... | |
|
def mylogger
|
||
|
Rails.logger
|
||
|
end
|
||
|
# Method for recipients or watchers preparation
|
||
|
def prepare_receivers(receivers, project, private)
|
||
|
processed_receivers = Array.new()
|
||
|
receivers.each do |recepient|
|
||
|
current_user = User.find_by_mail(recepient)
|
||
|
can_see_private_messages = current_user.allowed_to?(:view_private_messages, project)
|
||
|
if private
|
||
|
next if ! can_see_private_messages
|
||
|
end
|
||
|
processed_receivers << recepient
|
||
|
end
|
||
|
processed_receivers
|
||
|
end
|
||
|
end
|
||
|
# Patch TMail so that message_id is not overwritten
|
||
| app/models/mail_handler.rb (working copy) | ||
|---|---|---|
|
issue.safe_attributes = issue_attributes_from_keywords(issue)
|
||
|
issue.safe_attributes = {'custom_field_values' => custom_field_values_from_keywords(issue)}
|
||
|
journal.notes = cleaned_up_text_body
|
||
|
journal.private = 1 if !email.subject.to_s.index('[PRIVATE]').nil?
|
||
|
add_attachments(issue)
|
||
|
issue.save!
|
||
|
logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
|
||
| app/models/issue.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def init_journal(user, notes = "")
|
||
|
@current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
|
||
|
def init_journal(user, notes = "", private = false)
|
||
|
@current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes, :private => private)
|
||
|
@issue_before_change = self.clone
|
||
|
@issue_before_change.status = self.status
|
||
|
@custom_values_before_change = {}
|
||
| app/controllers/issues_controller.rb (working copy) | ||
|---|---|---|
|
@time_entry.attributes = params[:time_entry]
|
||
|
@notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil)
|
||
|
@issue.init_journal(User.current, @notes)
|
||
|
@private_message = params[:private_message] || false
|
||
|
@issue.init_journal(User.current, @notes, @private_message)
|
||
|
@issue.safe_attributes = params[:issue]
|
||
|
end
|
||
| app/controllers/journals_controller.rb (working copy) | ||
|---|---|---|
|
(render_403; return false) unless @journal.editable_by?(User.current)
|
||
|
if request.post?
|
||
|
@journal.update_attributes(:notes => params[:notes]) if params[:notes]
|
||
|
@journal.update_attributes(:private => params[:private_message] || false)
|
||
|
@journal.destroy if @journal.details.empty? && @journal.notes.blank?
|
||
|
call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params})
|
||
|
respond_to do |format|
|
||
| app/controllers/activities_controller.rb (working copy) | ||
|---|---|---|
|
events = @activity.events(@date_from, @date_to)
|
||
|
events.delete_if { |e| e.is_a?(Journal) && e.private && !User.current.allowed_to?(:view_private_messages, @project) }
|
||
|
if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language])
|
||
|
respond_to do |format|
|
||
|
format.html {
|
||
| app/views/journals/_notes_form.html.erb (working copy) | ||
|---|---|---|
|
<%= link_to l(:button_cancel), '#', :onclick => "Element.remove('journal-#{@journal.id}-form'); " +
|
||
|
"Element.show('journal-#{@journal.id}-notes'); return false;" %></p>
|
||
|
<%= check_box_tag :private_message, true, @journal.private, :id => "private_message_#{@journal.id}" %>
|
||
|
<%= label_tag "private_message_#{@journal.id}", 'Private message', :style => 'font-weight:bold;' %>
|
||
|
|
||
|
<div id="journal_<%= @journal.id %>_preview" class="wiki"></div>
|
||
|
<% end %>
|
||
|
<%= wikitoolbar_for "journal_#{@journal.id}_notes" %>
|
||
| app/views/issues/show.html.erb (working copy) | ||
|---|---|---|
|
<% end %>
|
||
|
<% if @journals.present? %>
|
||
|
<div id="history">
|
||
|
<h3><%=l(:label_history)%></h3>
|
||
|
<%= render :partial => 'history', :locals => { :issue => @issue, :journals => @journals } %>
|
||
|
</div>
|
||
|
<% view_private = User.current.allowed_to?(:view_private_messages, @project) %>
|
||
|
<% if ! only_private_messages?(@journals) || view_private %>
|
||
|
<div id="history">
|
||
|
<h3><%=l(:label_history)%></h3>
|
||
|
<%= render :partial => 'history', :locals => { :issue => @issue, :journals => @journals } %>
|
||
|
</div>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
| app/views/issues/_edit.html.erb (working copy) | ||
|---|---|---|
|
:method => :put,
|
||
|
:multipart => true} do |f| %>
|
||
|
<%= error_messages_for 'issue', 'time_entry' %>
|
||
|
<% view_private = User.current.allowed_to?(:view_private_messages, @project) %>
|
||
|
<div class="box">
|
||
|
<% if @edit_allowed || !@allowed_statuses.empty? %>
|
||
|
<fieldset class="tabular"><legend><%= l(:label_change_properties) %>
|
||
| ... | ... | |
|
<%= wikitoolbar_for 'notes' %>
|
||
|
<%= call_hook(:view_issues_edit_notes_bottom, { :issue => @issue, :notes => @notes, :form => f }) %>
|
||
|
<% if view_private %>
|
||
|
<%= check_box_tag :private_message, true, false %>
|
||
|
<%= label_tag :private_message, 'Private message', :style => 'font-weight:bold;' %>
|
||
|
<% end %>
|
||
|
<p><%=l(:label_attachment_plural)%><br /><%= render :partial => 'attachments/form' %></p>
|
||
|
</fieldset>
|
||
|
</div>
|
||
| ... | ... | |
|
}, :accesskey => accesskey(:preview) %>
|
||
|
<% end %>
|
||
|
<div id="preview" class="wiki"></div>
|
||
|
<div id="preview" class="wiki"></div>
|
||
| app/views/issues/_history.html.erb (working copy) | ||
|---|---|---|
|
<% reply_links = authorize_for('issues', 'edit') -%>
|
||
|
<% view_private = User.current.allowed_to?(:view_private_messages, @project) %>
|
||
|
<% @skipped = 0 %>
|
||
|
<% for journal in journals %>
|
||
|
<div id="change-<%= journal.id %>" class="<%= journal.css_classes %>">
|
||
|
<h4><div class="journal-link"><%= link_to "##{journal.indice}", :anchor => "note-#{journal.indice}" %></div>
|
||
|
<% private = journal.private %>
|
||
|
<% if private %>
|
||
|
<% if ! view_private %>
|
||
|
<% @skipped += 1 %>
|
||
|
<% next %>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
<div id="change-<%= journal.id %>" class="<%= journal.css_classes %><%= ' private' if journal.private %>">
|
||
|
<h4><div class="journal-link"><%= link_to "##{journal.indice - @skipped}", :anchor => "note-#{journal.indice - @skipped}" %></div>
|
||
|
<%= avatar(journal.user, :size => "24") %>
|
||
|
<%= content_tag('a', '', :name => "note-#{journal.indice}")%>
|
||
|
<%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %></h4>
|
||
|
<%= content_tag('a', '', :name => "note-#{journal.indice - @skipped}")%>
|
||
|
<%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %>
|
||
|
<% if journal.private %>
|
||
|
<span>[PRIVATE]</span>
|
||
|
<% end %>
|
||
|
</h4>
|
||
|
<% if journal.details.any? %>
|
||
|
<ul class="details">
|
||
| lib/redmine.rb (working copy) | ||
|---|---|---|
|
map.permission :view_issue_watchers, {}
|
||
|
map.permission :add_issue_watchers, {:watchers => :new}
|
||
|
map.permission :delete_issue_watchers, {:watchers => :destroy}
|
||
|
# Private messages
|
||
|
map.permission :view_private_messages, {}
|
||
|
end
|
||
|
map.project_module :time_tracking do |map|
|
||