diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb
index 58ba780..a2e644b 100644
--- a/lib/noosfero/plugin.rb
+++ b/lib/noosfero/plugin.rb
@@ -417,6 +417,8 @@ class Noosfero::Plugin
nil
end
+ # -> Adds adicional fields to a view
+ # returns = proc block that creates html code
def article_extra_fields(article)
nil
end
@@ -532,12 +534,6 @@ class Noosfero::Plugin
params
end
- # -> Checks adicional parameters passed through html
- # by the work_assignment plugin
- def check_extra_parameters(uploaded_files, params = {})
- nil
- end
-
# -> Finds objects by their contents
# returns = {:results => [a, b, c, ...], ...}
# P.S.: The plugin might add other informations on the return hash for its
diff --git a/plugins/work_assignment/controllers/myprofile/work_assignment_plugin_cms_controller.rb b/plugins/work_assignment/controllers/myprofile/work_assignment_plugin_cms_controller.rb
index 277cb30..7a63d98 100644
--- a/plugins/work_assignment/controllers/myprofile/work_assignment_plugin_cms_controller.rb
+++ b/plugins/work_assignment/controllers/myprofile/work_assignment_plugin_cms_controller.rb
@@ -1,13 +1,4 @@
class WorkAssignmentPluginCmsController < CmsController
append_view_path File.join(File.dirname(__FILE__) + '/../../views')
- def destroy
- @article = profile.articles.find(params[:id])
- if request.post?
- @article.destroy
- session[:notice] = _("\"#{@article.name}\" was removed.")
- referer = Rails.application.routes.recognize_path URI.parse(request.referer).path rescue nil
- redirect_to referer
- end
- end
end
\ No newline at end of file
diff --git a/plugins/work_assignment/lib/ext/email_contact.rb b/plugins/work_assignment/lib/ext/email_contact.rb
index c4f6182..9541334 100644
--- a/plugins/work_assignment/lib/ext/email_contact.rb
+++ b/plugins/work_assignment/lib/ext/email_contact.rb
@@ -53,18 +53,14 @@ class EmailContact
end
end
- def build_mail_message(environment, files_ids, parent_name)
- @files_paths = []
- @message
- @files_string = files_ids
- @files_id_list = @files_string.split(' ')
-
- @files_id_list.each do |file_id|
- @file = environment.articles.find_by_id(file_id)
- @real_file_url = "http://#{@file.url[:host]}:#{@file.url[:port]}/#{@file.url[:profile]}/#{@file.path}"
- @files_paths << @real_file_url
- @message = "
A file was sent to #{parent_name} and you are being notified."
- @message += "
Click here to access the file or use the URL below:
"
+ def build_mail_message(environment, uploaded_files, parent_id)
+ @article = environment.articles.find_by_id(parent_id)
+ @message = ""
+ if !@article.nil? && @article.type == "WorkAssignmentPlugin::WorkAssignment"
+ @message = @article.default_email + "
"
+ end
+ uploaded_files.each do |file|
+ @real_file_url = "http://#{file.url[:host]}:#{file.url[:port]}/#{file.url[:profile]}/#{file.path}"
@message += "
#{@real_file_url}"
end
@message
diff --git a/plugins/work_assignment/lib/work_assignment_plugin.rb b/plugins/work_assignment/lib/work_assignment_plugin.rb
index b04eba6..5ebe57e 100644
--- a/plugins/work_assignment/lib/work_assignment_plugin.rb
+++ b/plugins/work_assignment/lib/work_assignment_plugin.rb
@@ -53,15 +53,16 @@ class WorkAssignmentPlugin < Noosfero::Plugin
def cms_controller_filters
block = proc do
- @email_notification = params[:article_email_notification]
- if !@email_notification.nil? and @email_notification.include? "@"
- @subject = "#{@parent.name} file submission"
- @email_contact = user.build_email_contact(:name => user.name, :subject => @subject, :email => user.email, :receiver => @email_notification, :sender => user)
- @email_contact.message = @email_contact.build_mail_message(environment, @uploaded_files, @parent.name)
- if @email_contact.deliver
- session[:notice] = _('Notification successfully sent')
- else
- session[:notice] = _('Notification not sent')
+ if request.post? && params[:uploaded_files]
+ @email_notification = params[:article_email_notification]
+ unless @email_notification.include? "example@example.com, example2@example.com.br"
+ @email_contact = user.build_email_contact(:name => user.name, :subject => @parent.name, :email => user.email, :receiver => @email_notification, :sender => user)
+ @email_contact.message = @email_contact.build_mail_message(environment, @uploaded_files, @parent.id)
+ if @email_contact.deliver
+ session[:notice] = _('Notification successfully sent')
+ else
+ session[:notice] = _('Notification not sent')
+ end
end
end
end
@@ -76,8 +77,8 @@ class WorkAssignmentPlugin < Noosfero::Plugin
proc do
@article = Article.find_by_id(article)
if params[:parent_id] && !@article.nil? && @article.type == "WorkAssignmentPlugin::WorkAssignment"
- render :partial => 'notify_text_field', :locals => { :size => '45'}
- end
+ render :partial => 'notify_text_field', :locals => { :size => '45'}
+ end
end
end
diff --git a/plugins/work_assignment/lib/work_assignment_plugin/helper.rb b/plugins/work_assignment/lib/work_assignment_plugin/helper.rb
index abef4bc..a0ba207 100644
--- a/plugins/work_assignment/lib/work_assignment_plugin/helper.rb
+++ b/plugins/work_assignment/lib/work_assignment_plugin/helper.rb
@@ -64,6 +64,6 @@ module WorkAssignmentPlugin::Helper
end
def display_delete_button(article)
- expirable_button article, :delete, _('Delete'), {:controller =>'work_assignment_plugin_cms', :action => 'destroy', :id => article.id }, :method => :post, :confirm => delete_article_message(article)
+ expirable_button article, :delete, _('Delete'), {:controller =>'cms', :action => 'destroy', :id => article.id }, :method => :post, :confirm => delete_article_message(article)
end
end
diff --git a/plugins/work_assignment/lib/work_assignment_plugin/work_assignment.rb b/plugins/work_assignment/lib/work_assignment_plugin/work_assignment.rb
index 5acac19..616090c 100644
--- a/plugins/work_assignment/lib/work_assignment_plugin/work_assignment.rb
+++ b/plugins/work_assignment/lib/work_assignment_plugin/work_assignment.rb
@@ -1,10 +1,10 @@
class WorkAssignmentPlugin::WorkAssignment < Folder
settings_items :publish_submissions, :type => :boolean, :default => false
- settings_items :email_notification, :type => :boolean, :default => false
+ settings_items :default_email, :type => :string, :default => ""
attr_accessible :publish_submissions
- attr_accessible :email_notification
+ attr_accessible :default_email
def self.icon_name(article = nil)
'work-assignment'
diff --git a/plugins/work_assignment/public/text_field_css.js b/plugins/work_assignment/public/text_field_css.js
new file mode 100644
index 0000000..32c134e
--- /dev/null
+++ b/plugins/work_assignment/public/text_field_css.js
@@ -0,0 +1,22 @@
+ var element = jQuery("input[name='article_email_notification']");
+ var initialVal="example@example.com, example2@example.com.br";
+ var isEdited=false;
+ element.val(initialVal);
+
+ element.focus(function(){
+ if(!isEdited){
+ element.val("");
+ isEdited=true;
+ }
+
+ });
+
+ element.blur(function(){
+ if(element.val()==""){
+ element.val(initialVal);
+ isEdited=false;
+ }
+
+ });
+
+
diff --git a/plugins/work_assignment/views/cms/_notify_text_field.html.erb b/plugins/work_assignment/views/cms/_notify_text_field.html.erb
index 6298005..491fb5f 100644
--- a/plugins/work_assignment/views/cms/_notify_text_field.html.erb
+++ b/plugins/work_assignment/views/cms/_notify_text_field.html.erb
@@ -1 +1,5 @@
-<%= labelled_text_field(_('Send notification to: '), 'article_email_notification') %>
\ No newline at end of file
+