sugoi-mail 0.1.0 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL +94 -0
- data/app/apis/mailservice_api.rb +32 -22
- data/app/controllers/account_controller.rb +38 -22
- data/app/controllers/address_controller.rb +2 -0
- data/app/controllers/application.rb +12 -1
- data/app/controllers/base_user_controller.rb +29 -0
- data/app/controllers/domain_controller.rb +7 -8
- data/app/controllers/mail_admin_controller.rb +275 -0
- data/app/controllers/mailinglist_controller.rb +68 -14
- data/app/controllers/mailservice_controller.rb +116 -94
- data/app/controllers/navigation_controller.rb +3 -0
- data/app/controllers/root_admin_controller.rb +346 -0
- data/app/controllers/sugoi_admin_controller.rb +16 -13
- data/app/helpers/base_user_helper.rb +2 -0
- data/app/helpers/mail_admin_helper.rb +7 -0
- data/app/helpers/navigation_helper.rb +2 -0
- data/app/helpers/root_admin_helper.rb +2 -0
- data/app/models/address.rb +3 -4
- data/app/models/domain.rb +1 -1
- data/app/models/mail_admin.rb +2 -0
- data/app/models/mailinglist.rb +41 -19
- data/app/models/mailinglist_class.rb +1 -0
- data/app/models/message.rb +18 -36
- data/app/models/proxy_link.rb +14 -6
- data/app/views/account/login.rhtml +14 -12
- data/app/views/account/logout.rhtml +4 -8
- data/app/views/account/welcome.rhtml +3 -13
- data/app/views/base_user/add_address.rhtml +3 -0
- data/app/views/base_user/edit_address.rhtml +3 -0
- data/app/views/base_user/edit_user_list.rhtml +21 -0
- data/app/views/base_user/list_mailinglists.rhtml +3 -0
- data/app/views/base_user/remove_address.rhtml +3 -0
- data/app/views/base_user/unsubscribe_self.rhtml +3 -0
- data/app/views/layouts/application.rhtml +47 -0
- data/app/views/layouts/login.rhtml +34 -0
- data/app/views/layouts/sugoi_admin.rhtml +1 -0
- data/app/views/mail_admin/_form.rhtml +11 -0
- data/app/views/mail_admin/edit_admin_message.rhtml +12 -0
- data/app/views/mail_admin/list_admin_messages.rhtml +20 -0
- data/app/views/mail_admin/new_admin_message.rhtml +0 -0
- data/app/views/mailinglist/_address_form.rhtml +23 -0
- data/app/views/mailinglist/_form.rhtml +10 -14
- data/app/views/mailinglist/_new_class_form.rhtml +16 -0
- data/app/views/mailinglist/_new_form.rhtml +30 -0
- data/app/views/mailinglist/edit.rhtml +11 -5
- data/app/views/mailinglist/list.rhtml +15 -15
- data/app/views/mailinglist/list_mailinglist_classes.rhtml +18 -0
- data/app/views/mailinglist/new.rhtml +5 -5
- data/app/views/mailinglist/new_address.rhtml +10 -0
- data/app/views/mailinglist/new_mailinglist_class.rhtml +8 -0
- data/app/views/mailinglist/show.rhtml +15 -13
- data/app/views/navigation/_base_add_address_module.rhtml +2 -0
- data/app/views/navigation/_base_edit_address_module.rhtml +2 -0
- data/app/views/navigation/_base_edit_user_list_module.rhtml +5 -0
- data/app/views/navigation/_base_index_module.rhtml +2 -0
- data/app/views/navigation/_base_list_mailinglists_module.rhtml +3 -0
- data/app/views/navigation/_base_remove_address_module.rhtml +2 -0
- data/app/views/navigation/_base_unsubscribe_self_module.rhtml +2 -0
- data/app/views/navigation/_base_welcome_module.rhtml +3 -0
- data/app/views/navigation/_nav_module.rhtml +77 -0
- data/app/views/navigation/_root_add_address_module.rhtml +3 -0
- data/app/views/navigation/_root_add_mailinglist_module.rhtml +3 -0
- data/app/views/navigation/_root_add_user_module.rhtml +3 -0
- data/app/views/navigation/_root_change_user_password_module.rhtml +3 -0
- data/app/views/navigation/_root_edit_address_module.rhtml +13 -0
- data/app/views/navigation/_root_edit_mailinglist_module.rhtml +12 -0
- data/app/views/navigation/_root_edit_user_list_module.rhtml +3 -0
- data/app/views/navigation/_root_edit_user_module.rhtml +10 -0
- data/app/views/navigation/_root_index_module.rhtml +4 -0
- data/app/views/navigation/_root_list_addresses_module.rhtml +11 -0
- data/app/views/navigation/_root_list_mailinglists_module.rhtml +11 -0
- data/app/views/navigation/_root_list_users_module.rhtml +12 -0
- data/app/views/navigation/_root_remove_address_module.rhtml +12 -0
- data/app/views/navigation/_root_remove_mailinglist_module.rhtml +12 -0
- data/app/views/navigation/_root_remove_user_module.rhtml +12 -0
- data/app/views/navigation/_root_show_user_module.rhtml +10 -0
- data/app/views/navigation/_root_welcome_module.rhtml +3 -0
- data/app/views/navigation/chooseNav.rhtml +0 -0
- data/app/views/navigation/logout.rhtml +8 -0
- data/app/views/root_admin/_form.rhtml +21 -0
- data/app/views/root_admin/add_address.rhtml +3 -0
- data/app/views/root_admin/add_mailinglist.rhtml +3 -0
- data/app/views/root_admin/admin_user_list.rhtml +29 -0
- data/app/views/root_admin/admin_user_new.rhtml +8 -0
- data/app/views/root_admin/change_user_password.rhtml +3 -0
- data/app/views/root_admin/edit_address.rhtml +3 -0
- data/app/views/root_admin/edit_mailinglist.rhtml +3 -0
- data/app/views/root_admin/edit_user_list.rhtml +3 -0
- data/app/views/root_admin/list_addresses.rhtml +3 -0
- data/app/views/root_admin/list_mailinglists.rhtml +3 -0
- data/app/views/root_admin/list_users.rhtml +32 -0
- data/app/views/root_admin/remove_address.rhtml +3 -0
- data/app/views/root_admin/remove_mailinglist.rhtml +3 -0
- data/app/views/root_admin/remove_user.rhtml +3 -0
- data/app/views/root_admin/show_user.rhtml +3 -0
- data/app/views/sugoi_admin/_command_description.rhtml +1 -1
- data/app/views/sugoi_admin/_command_list.rhtml +1 -1
- data/app/views/sugoi_admin/create_domain.rhtml +1 -1
- data/app/views/sugoi_admin/create_list.rhtml +1 -1
- data/app/views/sugoi_admin/create_user.rhtml +1 -1
- data/app/views/sugoi_admin/help.rhtml +1 -1
- data/app/views/sugoi_admin/init.rhtml +1 -1
- data/app/views/sugoi_admin/list_addresses.rhtml +1 -1
- data/app/views/sugoi_admin/list_domains.rhtml +1 -1
- data/app/views/sugoi_admin/list_mailinglist_classes.rhtml +1 -1
- data/app/views/sugoi_admin/list_mailinglists.rhtml +1 -1
- data/app/views/sugoi_admin/list_users.rhtml +1 -1
- data/app/views/sugoi_admin/set_config.rhtml +4 -1
- data/app/views/sugoi_admin/show_config.rhtml +1 -1
- data/app/views/sugoi_admin/subscribe.rhtml +1 -1
- data/app/views/sugoi_admin/unsubscribe.rhtml +1 -1
- data/bin/maild +1 -1
- data/bin/sugoi-mail +1 -1
- data/config/environment.rb +2 -2
- data/config/routes.rb +4 -2
- data/db/migrate/028_add_sessions.rb +15 -0
- data/db/schema.rb +56 -48
- data/lib/login_system.rb +6 -6
- data/lib/tasks/release.rake +2 -2
- data/public/404.html +27 -5
- data/public/500.html +27 -5
- data/public/images/celltop1.jpg +0 -0
- data/public/images/title11.jpg +0 -0
- data/public/{index.html → index_default.html} +0 -0
- data/public/javascripts/dragdrop.js +1 -1
- data/public/javascripts/effects.js +1 -1
- data/public/javascripts/prototype.js +1 -1
- data/public/stylesheets/global.css +201 -0
- data/public/stylesheets/scaffold.css +176 -11
- data/public/stylesheets/trestle.css +176 -11
- data/script/cover +6 -0
- data/script/process/inspector +3 -0
- data/test/all.rb +2 -0
- data/test/fixtures/helps.yml +1 -1
- data/test/fixtures/mailinglist_classes.yml +4 -4
- data/test/fixtures/messages.yml +22 -2
- data/test/functional/base_user_controller_test.rb +18 -0
- data/test/functional/mail_admin_controller_test.rb +18 -0
- data/test/functional/mailservice_controller_test.rb +164 -19
- data/test/functional/navigation_controller_test.rb +18 -0
- data/test/functional/root_admin_controller_test.rb +18 -0
- data/test/functional/sugoi_admin_controller_test.rb +68 -10
- data/test/functionals.rb +2 -1
- data/test/integration/test_soap.rb +3 -1
- data/test/unit/address_test.rb +16 -1
- data/test/unit/domain_test.rb +5 -12
- data/test/unit/mailinglist_class_test.rb +2 -2
- data/test/unit/mailinglist_test.rb +138 -3
- data/test/unit/message_test.rb +256 -1
- data/test/unit/proxy_link_test.rb +37 -0
- data/test/unit/sys_config_test.rb +6 -0
- data/test/unit/user_test.rb +20 -0
- data/test/units.rb +2 -1
- metadata +94 -8
- data/app/views/layouts/address.rhtml +0 -13
- data/app/views/layouts/scaffold.rhtml +0 -13
data/INSTALL
CHANGED
@@ -63,3 +63,97 @@ you already have) and say:
|
|
63
63
|
$ sugoi-mail install sugoi
|
64
64
|
|
65
65
|
This should, all being well, set up and start a sugoi-mail installation.
|
66
|
+
|
67
|
+
|
68
|
+
LUNAR LINUX
|
69
|
+
|
70
|
+
# lin rubygems sqlite3
|
71
|
+
# gem install -y sugoi-mail
|
72
|
+
$ sugoi-mail install <your-directory>
|
73
|
+
|
74
|
+
This is part of why I like Lunar Linux so much.
|
75
|
+
|
76
|
+
|
77
|
+
POSTFIX CONFIGURATION (with optional mail-jail) ------------------------------
|
78
|
+
- send questions to aavdacev@invio.co.jp before bothering dagbrown :)
|
79
|
+
|
80
|
+
1. Ensure Postfix is installed: ---
|
81
|
+
Postfix is the SMTP mail-server with which sugoi-mail will interface. Before proceeding you must ensure you have postfix installed. If it is not installed, run "sudo apt-get install postfix". When the installer asks for configuration types, select the "Internet" configuration and follow the prompts. By default postfix is installed into "/etc/postfix/", which is where you will find the configuration files (master.cf, main.cf).
|
82
|
+
|
83
|
+
2. Setup the transport for the sugoi-mail domain(s): ---
|
84
|
+
A transport specification tells the mail-server to pass an outgoing mail message to a client software. The default transport is SMTP (which sends mail to the Internet). All of the mail addressed to the domain(s) specified in this step will be directed into sugoi-mail's client (mailc) and then be processed by sugoi-mail. The transport files are to be put into the postfix directory (/etc/postfix/)
|
85
|
+
|
86
|
+
a) Configure postfix to recognize sugoi-mail and it's client (mailc). In the code below, replace USERNAME with the unix user account that will be running the application, and ensure this user exists on the system. A good default setting is your own username. Do not forget to specify the filepath of your sugoi-mail installation. Append the following into master.cf, as two lines: the first starting with "sugoi..." and the second, indented 2 spaces, starting with "flags..". This is the same format as already existing in master.cf
|
87
|
+
|
88
|
+
sugoi unix - n n - - pipe
|
89
|
+
flags=FDRq user=USERNAME argv=/[sugoi-mail-installpath]/bin/mailc --sender $sender $recipient
|
90
|
+
|
91
|
+
b) Create a file called "transport" in /etc/postfix/, to assign the domains for transports. This every entry in this file is formatted like so: "[domain] (whitespace) [transport]:[nexthop]" where [nexthop] is often left blank. A suggested 'transport' for sugoi-mail can look like so:
|
92
|
+
|
93
|
+
"my.domain.jp sugoi:"
|
94
|
+
|
95
|
+
where my.domain.jp can be changed to your liking, and "sugoi" is the name specified in step 2a. This would mean that all mail to xxx@my.domain.jp will be handled by sugoi mail's mailc client. You may add more domains on separate lines in the same format.
|
96
|
+
|
97
|
+
c) Postfix reads transport configuration files in binary format, text. This means you need to convert the file you just created into the proper format. Run the following to create 'transport.db', a postfix-readable file:
|
98
|
+
|
99
|
+
"sudo postmap transport"
|
100
|
+
|
101
|
+
d) Finally, Postfix need to know where to look for your transport specification. Append the following into the main.cf file (this is the configuration file you generated during installation):
|
102
|
+
|
103
|
+
"transport_maps = hash:/etc/postfix/transport"
|
104
|
+
|
105
|
+
NOTE: if this fails saying main.cf is missing, you may have skipped configuration and need to run "sudo dpkg-reconfigure postfix" to generate the default main.cf
|
106
|
+
|
107
|
+
e) Reload postfix to accept the new cofiguration by running:
|
108
|
+
|
109
|
+
"sudo postfix reload"
|
110
|
+
|
111
|
+
If postfix wasn't running, try "sudo postfix start"
|
112
|
+
|
113
|
+
f) Congratulations, (in theory) all mail sent to the domains you specified should now be handled by sugoi-mail. If something fails, checking /var/log/mail.log is a good idea
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
3. Optional 'Mail-Jail' Configuration For Testing:---
|
118
|
+
When testing a mail-software installating (such as sugoi-mail) it is a good idea to set up a mail-jail. A mail-jail is simply a mail-server configuration that prevents all outgoing mail to ever make it to the internet. Instead it dumps all of the mail sent to a folder on the system to use for testing. To configure the mail-jail on Postfix, follow these steps:
|
119
|
+
|
120
|
+
a) Create the text-file '/root/bin/dumpintofile', which is script that will create a new textfile for every email message that is forwarded to it. This file can be placed anywhere, the /root/bin/ is a good default location. This file will contain the following:
|
121
|
+
--------------------
|
122
|
+
|
123
|
+
#!/bin/sh
|
124
|
+
|
125
|
+
mkdir -p /tmp/maildumps
|
126
|
+
echo "$@" > /tmp/maildumps/dumptofile.$$
|
127
|
+
cat >> /tmp/maildumps/dumptofile.$$
|
128
|
+
|
129
|
+
--------------------
|
130
|
+
b) The permissions on this file must be set to read, write, and execute. Use the chmod command to set the permissions:
|
131
|
+
|
132
|
+
"sudo chmod a=rwx dumpintofile"
|
133
|
+
|
134
|
+
c) Now the transport for dumpintofile needs to be set up. Brief instructions are provided. For verbose instructions on setting up a transport read section 2 of this document.
|
135
|
+
|
136
|
+
i. Add the dumptofile catch-all entry to master.cf. Don't forget to set the username, change the filepath (if you created dumpintofile in something other than /root/bin, and indent "flags.." by two spaces:
|
137
|
+
|
138
|
+
dumpintofile unix - n n - - pipe
|
139
|
+
flags=FDRq user=USERNAME argv=/root/bin/dumpintofile --sender $sender $recipient
|
140
|
+
|
141
|
+
ii. Now set it such that all the mail not that does not have a specified transport in the transport.db file, will go to the file-dumping script, instead of SMPT (send to internet). Append the following to /etc/postfix/main.cf
|
142
|
+
|
143
|
+
“default_transport = dumpintofile:”
|
144
|
+
|
145
|
+
IMPORTANT: This will disable all outgoing mail from the server. Comment this line out to re-set SMTP as the default transport.
|
146
|
+
|
147
|
+
iii. Finally, if postfix was set up for a local-delivery system, reduce the number of aliases by commenting out the line in /etc/postfix/main.cf that looks like:
|
148
|
+
|
149
|
+
"mydestination = somedomain.com, sub.domain.com, localhost, localhost.localdomain ..."
|
150
|
+
|
151
|
+
This change will prevent mail to be delivered if it is sent to the current server's hostname. However, mail sent to user@localhost will still be delivered, so beware of this during testing.
|
152
|
+
|
153
|
+
d) Reload postfix for changes to take effect:
|
154
|
+
|
155
|
+
"sudo postfix reload"
|
156
|
+
|
157
|
+
e) Congratulations, your mail-jail is set up. Now all mail sent to domains not specified in the transport you set up in section 2 of this document will be sent into a file. You can find the messages in the directory: /tmp/maildumps/ , they will be text-files with the name "dumptofile.####". If the mail does not appear in that directory, try running "mailq" or viewing the logs found in /var/log/mail.log.
|
158
|
+
|
159
|
+
------------------------------------------------------------------------
|
data/app/apis/mailservice_api.rb
CHANGED
@@ -30,12 +30,18 @@ class MailserviceApi < ActionWebService::API::Base
|
|
30
30
|
|
31
31
|
api_method :admin_user_signup, :returns => [ :bool ],
|
32
32
|
:expects => [ { :login => :string },
|
33
|
+
{ :description => :string },
|
33
34
|
{ :password => :string },
|
34
|
-
{ :password_confirmation => :string }
|
35
|
+
{ :password_confirmation => :string },
|
36
|
+
{ :mailinglist_admin => :boolean },
|
37
|
+
{ :domain_admin => :boolean } ]
|
35
38
|
|
36
39
|
api_method :admin_user_list, :returns => [ [ [:string, :string] ] ],
|
37
40
|
:expects => [ ]
|
38
41
|
|
42
|
+
api_method :admin_user_collection, :returns => [ [ User ] ],
|
43
|
+
:expects => [ ]
|
44
|
+
|
39
45
|
api_method :admin_user_reset_password, :returns => [ :bool ],
|
40
46
|
:expects => [
|
41
47
|
{ :login => :string },
|
@@ -51,6 +57,9 @@ class MailserviceApi < ActionWebService::API::Base
|
|
51
57
|
:expects => [ { :mailinglist_name => :string },
|
52
58
|
{ :address => :string } ]
|
53
59
|
|
60
|
+
api_method :admin_mailinglists_all, :returns => [ [ Mailinglist ]],
|
61
|
+
:expects => [ ]
|
62
|
+
|
54
63
|
#------------------------------------------------------------------------
|
55
64
|
# user methods
|
56
65
|
#------------------------------------------------------------------------
|
@@ -64,7 +73,7 @@ class MailserviceApi < ActionWebService::API::Base
|
|
64
73
|
api_method :user_logged_in, :returns => [ :bool ], :expects => []
|
65
74
|
api_method :user_name, :returns => [ :string ], :expects => []
|
66
75
|
|
67
|
-
api_method :user_mailinglists, :returns => [ [
|
76
|
+
api_method :user_mailinglists, :returns => [ [ Mailinglist ] ],
|
68
77
|
:expects => []
|
69
78
|
|
70
79
|
api_method :user_email_address, :returns => [ :string ], :expects => []
|
@@ -108,7 +117,7 @@ class MailserviceApi < ActionWebService::API::Base
|
|
108
117
|
# mailing list methods
|
109
118
|
#------------------------------------------------------------------------
|
110
119
|
|
111
|
-
api_method :mailinglist_create, :returns => [ :
|
120
|
+
api_method :mailinglist_create, :returns => [ :boolean ],
|
112
121
|
:expects => [ { :name => :string },
|
113
122
|
{ :mailinglist_class => :string } ]
|
114
123
|
|
@@ -156,23 +165,24 @@ class MailserviceApi < ActionWebService::API::Base
|
|
156
165
|
{ :address => :string }
|
157
166
|
]
|
158
167
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
168
|
+
## TODO: Implement message handling functionality
|
169
|
+
## api_method :mailinglist_messages, :returns => [ [ :integer ] ],
|
170
|
+
## :expects => [
|
171
|
+
## { :mailinglist_id => :integer }
|
172
|
+
## ]
|
173
|
+
##
|
174
|
+
## api_method :message, :returns => [ Message ],
|
175
|
+
## :expects => [
|
176
|
+
## { :message_id => :integer }
|
177
|
+
## ]
|
178
|
+
##
|
179
|
+
## api_method :message_parent, :returns => [ :integer ],
|
180
|
+
## :expects => [
|
181
|
+
## { :message_id => :integer }
|
182
|
+
## ]
|
183
|
+
##
|
184
|
+
## api_method :message_responses, :returns => [ [ :integer ] ],
|
185
|
+
## :expects => [
|
186
|
+
## { :message_id => :integer }
|
187
|
+
## ]
|
178
188
|
end
|
@@ -1,28 +1,11 @@
|
|
1
1
|
class AccountController < ApplicationController
|
2
|
-
layout 'scaffold'
|
3
|
-
|
4
2
|
include LoginSystem
|
5
|
-
|
6
|
-
def login
|
7
|
-
case @request.method
|
8
|
-
when :post
|
9
|
-
if @session[:user] = User.authenticate(@params[:user_login], @params[:user_password])
|
10
|
-
|
11
|
-
flash['notice'] = "Login successful"
|
12
|
-
redirect_back_or_default :action => "welcome"
|
13
|
-
else
|
14
|
-
flash.now['notice'] = "Login unsuccessful"
|
15
|
-
|
16
|
-
@login = @params[:user_login]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
3
|
|
21
4
|
def signup
|
22
|
-
if
|
23
|
-
@user = User.new(
|
5
|
+
if request.post?
|
6
|
+
@user = User.new(params[:user])
|
24
7
|
if @user.save
|
25
|
-
|
8
|
+
session[:user] = User.authenticate(@user.login, params[:user][:password])
|
26
9
|
flash['notice'] = "Signup successful"
|
27
10
|
redirect_back_or_default :action => "welcome"
|
28
11
|
end
|
@@ -30,10 +13,43 @@ class AccountController < ApplicationController
|
|
30
13
|
end
|
31
14
|
|
32
15
|
def logout
|
33
|
-
|
16
|
+
session[:navList] = :logout
|
17
|
+
session[:user] = nil
|
18
|
+
redirect_back_or_default :action => "login"
|
34
19
|
end
|
35
20
|
|
36
|
-
def
|
21
|
+
def login
|
22
|
+
case request.method
|
23
|
+
when :post
|
24
|
+
if session[:user] = User.authenticate(params[:user_login], params[:user_password])
|
25
|
+
session[:user_id] = :id # THIS MIGHT BE WRONG, SUPPOSED TO BE ABLE TO ACCESS USER'S BY ID STORED IN SESSION
|
26
|
+
flash['notice'] = "Login successful"
|
27
|
+
redirect_back_or_default :action => "welcome"
|
28
|
+
else
|
29
|
+
flash.now['notice'] = "Login unsuccessful"
|
30
|
+
|
31
|
+
@login = params[:user_login]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def welcome
|
37
|
+
@controller_name = controller_name
|
38
|
+
@action_name = action_name
|
39
|
+
session[:user] = User.find session[:user].id
|
40
|
+
|
41
|
+
@mailinglists = session[:user].mailinglists
|
42
|
+
|
43
|
+
@mailinglist_classes = MailinglistClass.find(:all)
|
44
|
+
|
45
|
+
domain_name = session[:domain]
|
46
|
+
domain = Domain.find_by_name domain_name
|
47
|
+
if domain then
|
48
|
+
@users = User.find_all_by_domain_id domain.id
|
49
|
+
else
|
50
|
+
# error "Domain \"#{domain_name}\" does not exist."
|
51
|
+
end
|
52
|
+
#session[:navList] = :welcome //not needed??
|
37
53
|
end
|
38
54
|
|
39
55
|
end
|
@@ -1,4 +1,15 @@
|
|
1
1
|
# Filters added to this controller will be run for all controllers in the application.
|
2
2
|
# Likewise, all the methods added will be available for all controllers.
|
3
3
|
class ApplicationController < ActionController::Base
|
4
|
-
|
4
|
+
before_filter :initialize_variables
|
5
|
+
|
6
|
+
protected
|
7
|
+
|
8
|
+
def initialize_variables
|
9
|
+
@controller_name = controller_name
|
10
|
+
@action_name = action_name
|
11
|
+
@users = User.find(:all)
|
12
|
+
@mailinglist_classes = MailinglistClass.find(:all)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class BaseUserController < ApplicationController
|
2
|
+
|
3
|
+
def edit_user_list
|
4
|
+
@mailinglists = session[:user].mailinglists
|
5
|
+
end
|
6
|
+
|
7
|
+
def list_mailinglists
|
8
|
+
end
|
9
|
+
|
10
|
+
def unsubscribe_self
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_address
|
14
|
+
end
|
15
|
+
|
16
|
+
def remove_address
|
17
|
+
end
|
18
|
+
|
19
|
+
def show_address
|
20
|
+
end
|
21
|
+
|
22
|
+
def edit_address
|
23
|
+
end
|
24
|
+
|
25
|
+
def show_mailinglist
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -1,34 +1,33 @@
|
|
1
1
|
class DomainController < ApplicationController
|
2
2
|
include DomainSystem
|
3
|
-
layout 'scaffold'
|
4
3
|
|
5
4
|
def login
|
6
|
-
case
|
5
|
+
case request.method
|
7
6
|
when :post
|
8
|
-
if
|
7
|
+
if session[:domain] = Domain.authenticate(params[:domain_name], params[:domain_password])
|
9
8
|
|
10
9
|
flash['notice'] = "Login successful"
|
11
10
|
redirect_back_or_default :action => "welcome"
|
12
11
|
else
|
13
12
|
flash.now['notice'] = "Login unsuccessful"
|
14
13
|
|
15
|
-
@login =
|
14
|
+
@login = params[:domain_login]
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
20
19
|
def signup
|
21
|
-
@domain = Domain.new(
|
20
|
+
@domain = Domain.new(params[:domain])
|
22
21
|
|
23
|
-
if
|
24
|
-
|
22
|
+
if request.post? and @domain.save
|
23
|
+
session[:domain] = Domain.authenticate(@domain.name, params[:domain][:password])
|
25
24
|
flash['notice'] = "Signup successful"
|
26
25
|
redirect_back_or_default :action => "welcome"
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
29
|
def logout
|
31
|
-
|
30
|
+
session[:domain] = nil
|
32
31
|
end
|
33
32
|
|
34
33
|
def welcome
|
@@ -0,0 +1,275 @@
|
|
1
|
+
class MailAdminController < ApplicationController
|
2
|
+
def list_admin_messages
|
3
|
+
@mailinglist = Mailinglist.find_by_id(params[:id])
|
4
|
+
@adminmessages = AdminMessage.find(@mailinglist.welcome_admin_message_id, @mailinglist.confirmed_admin_message_id, @mailinglist.sayonara_admin_message_id)
|
5
|
+
end
|
6
|
+
|
7
|
+
def edit_admin_message
|
8
|
+
if request.post?
|
9
|
+
@adminmessage = AdminMessage.find(params[:id])
|
10
|
+
if @adminmessage.update_attributes(params[:adminmessage])
|
11
|
+
if @adminmessage.save
|
12
|
+
flash[:notice] = 'The admin message was successfully edited.'
|
13
|
+
session[:user] = User.find session[:user].id
|
14
|
+
redirect_to :controller => 'mailinglist',
|
15
|
+
:action => 'show',
|
16
|
+
:id => params[:id]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
else
|
20
|
+
@adminmessage = AdminMessage.find(params[:id])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def new_admin_message
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def remove_admin_message
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# private
|
33
|
+
# def get_password
|
34
|
+
# password = ask "Password: " do |q| q.echo = false end
|
35
|
+
# confirmation = ask "Confirm: " do |q| q.echo = false end
|
36
|
+
#
|
37
|
+
# return [ password, confirmation ]
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# def format_errors errors
|
41
|
+
# errors.map do |facility, text|
|
42
|
+
# " #{facility}: #{text}\n"
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# def error(error_text)
|
47
|
+
# callername = caller[0].gsub(/.*\`(\w+)\'.*/, '\1')
|
48
|
+
# @error = "#{callername}: #{error_text}"
|
49
|
+
# nil
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# def message(message_text)
|
53
|
+
# callername = caller[0].gsub(/.*\`(\w+)\'.*/, '\1')
|
54
|
+
# @messages ||= []
|
55
|
+
# @messages << "#{callername}: #{message_text}"
|
56
|
+
# end
|
57
|
+
#
|
58
|
+
# def ask_description(thing)
|
59
|
+
# description = ask "Description for #{thing}: "
|
60
|
+
# if description == "" then description = nil end
|
61
|
+
# description
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# public
|
65
|
+
#
|
66
|
+
# def init
|
67
|
+
# @alreadythere = []
|
68
|
+
# [ MailinglistClass, AdminMessage, SysConfig, Help ].each do |table|
|
69
|
+
# fixture = YAML.load(File.read(File.join(RAILS_ROOT,
|
70
|
+
# "test",
|
71
|
+
# "fixtures",
|
72
|
+
# table.name.tableize +
|
73
|
+
# ".yml")))
|
74
|
+
# fixture.values.sort_by do |values| values["id"].to_i end .
|
75
|
+
# each do |values|
|
76
|
+
# begin
|
77
|
+
# table.find values["id"]
|
78
|
+
# @alreadythere << "%s[%s]" % [ table.name, values["id"] ]
|
79
|
+
# rescue ActiveRecord::RecordNotFound
|
80
|
+
# configvar = table.new values
|
81
|
+
# configvar.id = values["id"].to_i # hohoho
|
82
|
+
# configvar.save
|
83
|
+
# end
|
84
|
+
# end
|
85
|
+
# end
|
86
|
+
# end
|
87
|
+
#
|
88
|
+
# def show_config(var_name=nil)
|
89
|
+
# unless var_name
|
90
|
+
# @config_vars = SysConfig.find_all
|
91
|
+
# else
|
92
|
+
# @config_vars = SysConfig.find_all_by_name(var_name)
|
93
|
+
# end
|
94
|
+
# end
|
95
|
+
#
|
96
|
+
# def set_config(var_name, new_value)
|
97
|
+
# @config_var = SysConfig.find_by_name(var_name)
|
98
|
+
# @config_var.value = new_value
|
99
|
+
# @config_var.save
|
100
|
+
# end
|
101
|
+
#
|
102
|
+
# def list_domains
|
103
|
+
# @domains = Domain.find_all
|
104
|
+
# end
|
105
|
+
#
|
106
|
+
# def list_mailinglists(domain_name)
|
107
|
+
# domain = Domain.find_by_name(domain_name)
|
108
|
+
# if domain then
|
109
|
+
# @mailinglists = domain.mailinglists
|
110
|
+
# else
|
111
|
+
# error "#{domain_name}: not found"
|
112
|
+
# end
|
113
|
+
# end
|
114
|
+
#
|
115
|
+
# def list_addresses(mailinglist_address)
|
116
|
+
# @mailinglist = Mailinglist.find_by_address(mailinglist_address)
|
117
|
+
# if @mailinglist then
|
118
|
+
# @mailinglist=@mailinglist[0]
|
119
|
+
# @addresses = @mailinglist.addresses
|
120
|
+
# else
|
121
|
+
# error "#{mailinglist_address}: not found"
|
122
|
+
# end
|
123
|
+
# end
|
124
|
+
#
|
125
|
+
# def create_domain(domain_name)
|
126
|
+
# @messages = []
|
127
|
+
#
|
128
|
+
# domain = Domain.find_by_name domain_name
|
129
|
+
# if domain == nil then
|
130
|
+
# password, confirmation = get_password
|
131
|
+
# domain = Domain.new
|
132
|
+
# domain.name = domain_name
|
133
|
+
# domain.password = password
|
134
|
+
# domain.password_confirmation = confirmation
|
135
|
+
# if domain.save then
|
136
|
+
# message "Domain \"#{domain_name}\" created successfully."
|
137
|
+
# else
|
138
|
+
# error "Could not create domain \"#{domain_name}\":\n" +
|
139
|
+
# format_errors(domain.errors).join
|
140
|
+
# end
|
141
|
+
# else
|
142
|
+
# error "Domain \"#{domain_name}\" already exists."
|
143
|
+
# end
|
144
|
+
# end
|
145
|
+
#
|
146
|
+
# def create_user domain_name, username,
|
147
|
+
# email_address = nil,
|
148
|
+
# description = nil
|
149
|
+
# domain = Domain.find_by_name domain_name
|
150
|
+
# if domain then
|
151
|
+
# password, password_confirmation = get_password
|
152
|
+
#
|
153
|
+
# if email_address == nil then
|
154
|
+
# email_address = ask "Address to forward #{username}'s email to: "
|
155
|
+
# if email_address == "" then email_address = nil end
|
156
|
+
# end
|
157
|
+
#
|
158
|
+
# description ||= ask_description(username)
|
159
|
+
#
|
160
|
+
# user = User.new
|
161
|
+
# user.domain = domain
|
162
|
+
# user.login = username
|
163
|
+
# user.password = password
|
164
|
+
# user.password_confirmation = password_confirmation
|
165
|
+
# user.description = description
|
166
|
+
# user.domainadmin = false
|
167
|
+
# user.mailadmin = false
|
168
|
+
#
|
169
|
+
# if user.save then
|
170
|
+
# message "User \"#{username}@#{domain_name}\" created successfully"
|
171
|
+
# if email_address then
|
172
|
+
# addr=Address.find_or_create_by_address(email_address)
|
173
|
+
# user.addresses << addr
|
174
|
+
# end
|
175
|
+
# else
|
176
|
+
# error "User \"#{username}@#{domain_name}\" was not created:\n" +
|
177
|
+
# format_errors(user.errors).join("\n")
|
178
|
+
# end
|
179
|
+
# else
|
180
|
+
# error "Domain \"#{domain_name}\" does not exist."
|
181
|
+
# end
|
182
|
+
# end
|
183
|
+
#
|
184
|
+
# def list_users domain_name
|
185
|
+
# domain = Domain.find_by_name domain_name
|
186
|
+
# if domain then
|
187
|
+
# @users = User.find_all_by_domain_id domain.id
|
188
|
+
# else
|
189
|
+
# error "Domain \"#{domain_name}\" does not exist."
|
190
|
+
# end
|
191
|
+
# end
|
192
|
+
#
|
193
|
+
# def list_mailinglist_classes
|
194
|
+
# @mailinglist_classes = MailinglistClass.find :all, :order => :id
|
195
|
+
# end
|
196
|
+
#
|
197
|
+
# def list_mlclasses
|
198
|
+
# list_mailinglist_classes
|
199
|
+
# render "sugoi_admin/list_mailinglist_classes"
|
200
|
+
# end
|
201
|
+
#
|
202
|
+
# def create_list mailinglist_name,
|
203
|
+
# domain_name, user_name, description = nil, mailinglist_class_id = 2
|
204
|
+
#
|
205
|
+
# mlclass = begin
|
206
|
+
# MailinglistClass.find mailinglist_class_id.to_i
|
207
|
+
# rescue ActiveRecord::RecordNotFound
|
208
|
+
# nil
|
209
|
+
# end
|
210
|
+
# unless mlclass
|
211
|
+
# return error("Invalid mailing list class: #{mailinglist_class_id}")
|
212
|
+
# end
|
213
|
+
#
|
214
|
+
# domain = Domain.find_by_name domain_name
|
215
|
+
# unless domain
|
216
|
+
# return error("Domain \"#{domain_name}\" not found.")
|
217
|
+
# end
|
218
|
+
#
|
219
|
+
# user = User.find_by_login_and_domain_id user_name, domain.id
|
220
|
+
# unless user
|
221
|
+
# return error("User \"#{user_name}\" not found "+
|
222
|
+
# "in domain \"#{domain_name}\".")
|
223
|
+
# end
|
224
|
+
#
|
225
|
+
# ml=Mailinglist.new
|
226
|
+
# ml.user = user
|
227
|
+
# ml.description = description
|
228
|
+
# ml.mailinglist_class = mlclass
|
229
|
+
# ml.name = mailinglist_name
|
230
|
+
#
|
231
|
+
# if ml.save then
|
232
|
+
# message "Mailing list \"#{ml.address}\" created successfully."
|
233
|
+
# end
|
234
|
+
# end
|
235
|
+
#
|
236
|
+
# def subscribe(mailinglist_address, new_address)
|
237
|
+
# address=Address.find_or_create_by_address new_address
|
238
|
+
# ml=Mailinglist.find_by_address(mailinglist_address)
|
239
|
+
# unless ml
|
240
|
+
# return error("Mailing list \"#{mailinglist_address}\" not found.")
|
241
|
+
# end
|
242
|
+
# ml=ml[0]
|
243
|
+
# ml.addresses << address
|
244
|
+
# message "Subscribed \"#{new_address}\" to \"#{mailinglist_address}\""
|
245
|
+
# end
|
246
|
+
#
|
247
|
+
# def unsubscribe(mailinglist_address, address_to_remove)
|
248
|
+
# address = Address.find_by_address address_to_remove
|
249
|
+
# unless address
|
250
|
+
# return error("Address \"#{address_to_remove}\" unknown.")
|
251
|
+
# end
|
252
|
+
#
|
253
|
+
# mailinglist = Mailinglist.find_by_address mailinglist_address
|
254
|
+
# unless mailinglist
|
255
|
+
# return error("Mailing list \"#{mailinglist_address}\" unknown.")
|
256
|
+
# end
|
257
|
+
#
|
258
|
+
# @mailinglist = mailinglist[0]
|
259
|
+
#
|
260
|
+
# unless @mailinglist.addresses.member? address
|
261
|
+
# return error("Address \"#{address}\" not in " + "
|
262
|
+
# mailing list \"#{mailinglist_address}\"")
|
263
|
+
# end
|
264
|
+
#
|
265
|
+
# @removed_addresses=@mailinglist.remove_addresses address
|
266
|
+
# end
|
267
|
+
#
|
268
|
+
# def help(command=nil)
|
269
|
+
# if command
|
270
|
+
# @help = Help.find_by_facility_and_command self.class.name, command
|
271
|
+
# else
|
272
|
+
# @help = Help.find_all_by_facility self.class.name
|
273
|
+
# end
|
274
|
+
# end
|
275
|
+
end
|