Initial Redmine tooling and local plugin forks

This commit is contained in:
Jason Thistlethwaite
2026-04-24 22:01:18 +00:00
commit 9f682af0eb
683 changed files with 56878 additions and 0 deletions
@@ -0,0 +1,16 @@
namespace :redmine do
namespace :contacts do
desc <<-END_DESC
Clear tags table.
rake redmine:contacts:clear_tags_table RAILS_ENV="production"
END_DESC
task :clear_tags_table => :environment do
ActiveRecord::Migration.remove_column(:tags, :color) if RedmineCrm::Tag.column_names.include?("color")
ActiveRecord::Migration.remove_column(:tags, :created_at) if RedmineCrm::Tag.column_names.include?("created_at")
ActiveRecord::Migration.remove_column(:tags, :updated_at) if RedmineCrm::Tag.column_names.include?("updated_at")
end
end
end
@@ -0,0 +1,69 @@
namespace :redmine do
namespace :contacts do
desc <<-END_DESC
Drop settings.
rake redmine:contacts:drop_settings RAILS_ENV="production" plugin="plugin_redmine_contacts"
Plugins:
plugin_redmine_contacts: Redmine CRM plugin
plugin_redmine_contacts_helpdesk: Redmine Helpdesk plugin
plugin_redmine_contacts_invoices: Redmine Invoices plugin
END_DESC
task :drop_settings => :environment do
plugin_name = ENV['plugin']
Setting[plugin_name.to_sym] = {} if plugin_name
end
desc <<-END_DESC
Set plugin settings.
rake redmine:contacts:settings RAILS_ENV="production" plugin="plugin_redmine_contacts" setting="list_partial_style" value="list"
rake redmine:contacts:settings RAILS_ENV="production" project="helpdesk" setting="contacts_show_deals_tab" value="1"
Plugins:
plugin_redmine_contacts: Redmine CRM plugin
plugin_redmine_contacts_helpdesk: Redmine Helpdesk plugin
plugin_redmine_contacts_invoices: Redmine Invoices plugin
END_DESC
task :settings => :environment do
plugin_name = ENV['plugin']
setting = ENV['setting']
value = ENV['value']
project = ENV['project']
if (plugin_name.blank? && project.blank?) || setting.blank? || value.blank?
puts "RedmineCRM: Params plugin, setting and value should be present"
return
end
if project
ContactsSetting[setting, Project.find(project).id] = value
else
plugin_settings = Setting[plugin_name.to_sym]
plugin_settings[setting] = value
Setting[plugin_name.to_sym] = plugin_settings
end
end
desc <<-END_DESC
Load CRM plugin default data.
END_DESC
task :load_default_data => :environment do
DealStatus.create(:name => l(:label_deal_status_pending), :status_type => DealStatus::OPEN_STATUS, :is_default => true, :color => "AAAAAA".hex)
DealStatus.create(:name => l(:label_deal_status_won), :status_type => DealStatus::WON_STATUS, :is_default => false, :color => "008000".hex)
DealStatus.create(:name => l(:label_deal_status_lost), :status_type => DealStatus::LOST_STATUS, :is_default => false, :color => "FF0000".hex)
end
end
end
@@ -0,0 +1,154 @@
namespace :redmine do
namespace :email do
namespace :contacts do
desc <<-END_DESC
Read an email from standard input.
General options:
unknown_user=ACTION how to handle emails from an unknown user
ACTION can be one of the following values:
ignore: email is ignored (default)
accept: accept as anonymous user
create: create a user account
no_permission_check=1 disable permission checking when receiving
the email
Issue attributes control options:
project=PROJECT identifier of the target project
status=STATUS name of the target status
tracker=TRACKER name of the target tracker
category=CATEGORY name of the target category
priority=PRIORITY name of the target priority
allow_override=ATTRS allow email content to override attributes
specified by previous options
ATTRS is a comma separated list of attributes
Examples:
# No project specified. Emails MUST contain the 'Project' keyword:
rake redmine:email:read RAILS_ENV="production" < raw_email
# Fixed project and default tracker specified, but emails can override
# both tracker and priority attributes:
rake redmine:email:contacts:read RAILS_ENV="production" \\
project=foo \\
tracker=bug \\
allow_override=tracker,priority < raw_email
END_DESC
task :read => :environment do
options = { :contact => {} }
# %w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
# options[:allow_override] = ENV['allow_override'] if ENV['allow_override']
# options[:unknown_user] = ENV['unknown_user'] if ENV['unknown_user']
# options[:no_permission_check] = ENV['no_permission_check'] if ENV['no_permission_check']
ContactsMailer.receive(STDIN.read, options)
end
desc <<-END_DESC
Read emails from an IMAP server.
General options:
unknown_user=ACTION how to handle emails from an unknown user
ACTION can be one of the following values:
ignore: email is ignored (default)
accept: accept as anonymous user
create: create a user account
no_permission_check=1 disable permission checking when receiving
the email
Available IMAP options:
host=HOST IMAP server host (default: 127.0.0.1)
port=PORT IMAP server port (default: 143)
ssl=SSL Use SSL? (default: false)
username=USERNAME IMAP account
password=PASSWORD IMAP password
folder=FOLDER IMAP folder to read (default: INBOX)
Issue attributes control options:
project=PROJECT identifier of the target project
status=STATUS name of the target status
tracker=TRACKER name of the target tracker
category=CATEGORY name of the target category
priority=PRIORITY name of the target priority
allow_override=ATTRS allow email content to override attributes
specified by previous options
ATTRS is a comma separated list of attributes
Processed emails control options:
move_on_success=MAILBOX move emails that were successfully received
to MAILBOX instead of deleting them
move_on_failure=MAILBOX move emails that were ignored to MAILBOX
Examples:
# No project specified. Emails MUST contain the 'Project' keyword:
rake redmine:email:contacts:receive_imap RAILS_ENV="production" \\
host=imap.foo.bar username=redmine@example.net password=xxx
# Fixed project and default tracker specified, but emails can override
# both tracker and priority attributes:
rake redmine:email:receive_imap RAILS_ENV="production" \\
host=imap.foo.bar username=redmine@example.net password=xxx ssl=1 \\
project=foo \\
tracker=bug
END_DESC
task :receive_imap => :environment do
imap_options = {:host => ENV['host'],
:port => ENV['port'],
:ssl => ENV['ssl'],
:username => ENV['username'],
:password => ENV['password'],
:folder => ENV['folder'],
:move_on_success => ENV['move_on_success'],
:move_on_failure => ENV['move_on_failure']}
options = { :issue => {} }
%w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
options[:allow_override] = ENV['allow_override'] if ENV['allow_override']
options[:unknown_user] = ENV['unknown_user'] if ENV['unknown_user']
options[:no_permission_check] = ENV['no_permission_check'] if ENV['no_permission_check']
RedmineContacts::Mailer.check_imap(ContactsMailer, imap_options, options)
end
desc <<-END_DESC
Read emails from an POP3 server.
Available POP3 options:
host=HOST POP3 server host (default: 127.0.0.1)
port=PORT POP3 server port (default: 110)
username=USERNAME POP3 account
password=PASSWORD POP3 password
apop=1 use APOP authentication (default: false)
delete_unprocessed=1 delete messages that could not be processed
successfully from the server (default
behaviour is to leave them on the server)
See redmine:email:contacts:receive_imap for more options and examples.
END_DESC
task :receive_pop3 => :environment do
pop_options = {:host => ENV['host'],
:port => ENV['port'],
:apop => ENV['apop'],
:username => ENV['username'],
:password => ENV['password'],
:delete_unprocessed => ENV['delete_unprocessed']}
options = { :issue => {} }
%w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
options[:allow_override] = ENV['allow_override'] if ENV['allow_override']
options[:unknown_user] = ENV['unknown_user'] if ENV['unknown_user']
options[:no_permission_check] = ENV['no_permission_check'] if ENV['no_permission_check']
RedmineContacts::Mailer.check_pop3(ContactsMailer, pop_options, options)
end
end
end
end