sugoi-mail 0.1.0 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -1,14 +1,15 @@
|
|
1
1
|
class MailinglistController < ApplicationController
|
2
|
-
verify :only => [ 'show', 'edit', '
|
2
|
+
verify :only => [ 'show', 'edit', 'remove' ],
|
3
3
|
:params => :id,
|
4
4
|
:add_flash => { :notice => 'Missing mailinglist ID.' },
|
5
5
|
:redirect_to => { :action => 'list' }
|
6
6
|
|
7
|
-
def
|
7
|
+
def remove
|
8
|
+
flash[:notice] = 'The mailing list was successfully destroyed.'
|
8
9
|
if request.post?
|
9
10
|
Mailinglist.find(params[:id]).destroy
|
10
11
|
flash[:notice] = 'The mailinglist was successfully destroyed.'
|
11
|
-
redirect_to :action => '
|
12
|
+
redirect_to :controller => "account", :action => 'welcome'
|
12
13
|
else
|
13
14
|
flash[:notice] = 'Click Destroy to destroy the mailinglist.'
|
14
15
|
redirect_to :action => 'edit', :id => params[:id]
|
@@ -16,36 +17,89 @@ class MailinglistController < ApplicationController
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def edit
|
20
|
+
#session[:mailinglist_id] = params[:id]
|
19
21
|
if request.post?
|
20
22
|
@mailinglist = Mailinglist.find(params[:id])
|
21
23
|
if @mailinglist.update_attributes(params[:mailinglist])
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
@mailinglist.mailinglist_class = MailinglistClass.find_by_id params[:mailinglist_class_id]
|
25
|
+
if @mailinglist.save
|
26
|
+
flash[:notice] = 'The mailinglist was successfully edited.'
|
27
|
+
session[:user] = User.find session[:user].id
|
28
|
+
redirect_to :action => 'show', :id => @mailinglist
|
29
|
+
end
|
26
30
|
end
|
27
31
|
else
|
28
|
-
|
32
|
+
@mailinglist = Mailinglist.find(params[:id])
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
32
36
|
def list
|
33
|
-
|
37
|
+
session[:user] = User.find session[:user].id
|
38
|
+
@mailinglists = session[:user].mailinglists
|
39
|
+
# @mailinglist_pages, @mailinglists = paginate(:mailinglists)
|
34
40
|
end
|
35
41
|
|
36
42
|
def new
|
43
|
+
session[:domain] = Domain.find(session[:domain_id])
|
37
44
|
if request.post?
|
38
45
|
@mailinglist = Mailinglist.new(params[:mailinglist])
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
46
|
+
domain = session[:domain]
|
47
|
+
if domain then
|
48
|
+
@mailinglist.user = User.find_by_login_and_domain_id params[:user], domain.id
|
49
|
+
@mailinglist.mailinglist_class = MailinglistClass.find_by_id params[:mailinglist_class_id]
|
50
|
+
if @mailinglist.save
|
51
|
+
flash[:notice] = 'A new mailinglist was successfully added.'
|
52
|
+
session[:user] = User.find session[:user].id
|
53
|
+
redirect_to :action => 'list'
|
54
|
+
end
|
55
|
+
else
|
56
|
+
flash[:notice] = 'Mailinglist could not be added - domain is nil'
|
57
|
+
end
|
43
58
|
else
|
44
|
-
|
59
|
+
#@mailinglist = Mailinglist.new
|
45
60
|
end
|
46
61
|
end
|
47
62
|
|
48
63
|
def show
|
64
|
+
session[:user] = User.find session[:user].id
|
49
65
|
@mailinglist = Mailinglist.find(params[:id])
|
50
66
|
end
|
67
|
+
|
68
|
+
def openposting
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
def new_address
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
def add_address
|
77
|
+
if request.post?
|
78
|
+
@mailinglist = Mailinglist.find(session[:mailinglist_id])
|
79
|
+
# address = Address.new(params[:address])
|
80
|
+
@mailinglist.subscribe params[:address][:address]
|
81
|
+
session[:user] = User.find session[:user].id
|
82
|
+
redirect_to :action => "show", :id => @mailinglist
|
83
|
+
else
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def new_mailinglist_class
|
88
|
+
session[:domain] = Domain.find(session[:domain_id])
|
89
|
+
if request.post?
|
90
|
+
@mailinglist_class = MailinglistClass.new(params[:mailinglist_class])
|
91
|
+
domain = session[:domain]
|
92
|
+
if domain then
|
93
|
+
#@mailinglist.user = User.find_by_login_and_domain_id params[:user], domain.id
|
94
|
+
#@mailinglist.mailinglist_class = MailinglistClass.find_by_id params[:mailinglist_class_id]
|
95
|
+
if @mailinglist_class.save
|
96
|
+
flash[:notice] = 'A new mailinglist class was successfully added.'
|
97
|
+
session[:user] = User.find session[:user].id
|
98
|
+
redirect_to :controller => "account", :action => "welcome"
|
99
|
+
end
|
100
|
+
else
|
101
|
+
flash[:notice] = 'Mailinglist class could not be added - domain is nil'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
51
105
|
end
|
@@ -45,20 +45,21 @@ class MailserviceController < ApplicationController
|
|
45
45
|
private
|
46
46
|
|
47
47
|
def domain_logged_in?
|
48
|
-
raise "Not logged into domain" unless
|
48
|
+
raise "Not logged into domain" unless session[:domain_id]
|
49
49
|
true
|
50
50
|
end
|
51
51
|
|
52
52
|
def user_logged_in?
|
53
53
|
domain_logged_in?
|
54
|
-
raise "Not logged in as user" unless
|
54
|
+
raise "Not logged in as user" unless session[:user_id]
|
55
55
|
true
|
56
56
|
end
|
57
57
|
|
58
58
|
|
59
59
|
def user_admin?
|
60
60
|
user_logged_in?
|
61
|
-
raise "No privileges to perform that operation" unless
|
61
|
+
raise "No privileges to perform that operation" unless \
|
62
|
+
User.find(session[:user_id]).domainadmin?
|
62
63
|
true
|
63
64
|
end
|
64
65
|
|
@@ -68,7 +69,7 @@ class MailserviceController < ApplicationController
|
|
68
69
|
user_logged_in?
|
69
70
|
mailinglist = Mailinglist.find_by_id(mailinglist_id)
|
70
71
|
raise "Mailing list not found" unless mailinglist
|
71
|
-
unless
|
72
|
+
unless session[:user_id] == mailinglist.user_id
|
72
73
|
begin
|
73
74
|
user_admin?
|
74
75
|
rescue
|
@@ -97,14 +98,17 @@ class MailserviceController < ApplicationController
|
|
97
98
|
|
98
99
|
# Log into the domain.
|
99
100
|
def domain_login domainname, password
|
100
|
-
|
101
|
+
domain = Domain.authenticate(domainname, password)
|
102
|
+
if domain
|
103
|
+
session[:domain_id]=Domain.authenticate(domainname, password).id
|
104
|
+
end
|
101
105
|
domain_logged_in
|
102
106
|
end
|
103
107
|
|
104
108
|
# Log out of the domain.
|
105
109
|
def domain_logout
|
106
|
-
if
|
107
|
-
|
110
|
+
if session[:domain_id] then
|
111
|
+
session[:domain_id] = nil
|
108
112
|
true
|
109
113
|
else
|
110
114
|
false
|
@@ -113,16 +117,18 @@ class MailserviceController < ApplicationController
|
|
113
117
|
|
114
118
|
# Verify whether the domain is logged in or not.
|
115
119
|
def domain_logged_in
|
116
|
-
not
|
120
|
+
not session[:domain_id].nil?
|
117
121
|
end
|
118
122
|
|
119
123
|
# Returns the domain name.
|
120
124
|
def domain_name
|
121
|
-
|
125
|
+
Domain.find(session[:domain_id]).name
|
122
126
|
end
|
123
127
|
|
124
|
-
|
125
|
-
|
128
|
+
#========================================================================
|
129
|
+
# Administrator methods
|
130
|
+
#========================================================================
|
131
|
+
|
126
132
|
# Returns true if the user is an administrator and false otherwise
|
127
133
|
def is_admin
|
128
134
|
user_admin? rescue false
|
@@ -130,23 +136,28 @@ class MailserviceController < ApplicationController
|
|
130
136
|
|
131
137
|
# Creates a new user. NOTE: This method requires that you're
|
132
138
|
# already signed in as an administrator.
|
133
|
-
def admin_user_signup login, password, password_confirmation
|
139
|
+
def admin_user_signup login, description, password, password_confirmation,
|
140
|
+
mailinglist_admin, domain_admin
|
134
141
|
user_admin?
|
135
142
|
|
136
143
|
user=User.new
|
137
144
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
145
|
+
user.login=login
|
146
|
+
user.domain_id=session[:domain_id]
|
147
|
+
user.password=password
|
148
|
+
user.password_confirmation=password_confirmation
|
149
|
+
user.mailinglistadmin = mailinglist_admin
|
150
|
+
user.domainadmin = domain_admin
|
151
|
+
if user.save then
|
152
|
+
#this is a disgusting hack
|
153
|
+
user.password = password
|
154
|
+
user.password_confirmation = password_confirmation
|
155
|
+
user.save
|
156
|
+
user.mailinglist.description = description
|
157
|
+
user.mailinglist.save
|
158
|
+
return true
|
148
159
|
else
|
149
|
-
|
160
|
+
raise user.errors.sort.map { |e| "#{e[0]}: #{e[1]}" }.join("\n")
|
150
161
|
end
|
151
162
|
end
|
152
163
|
|
@@ -154,10 +165,17 @@ class MailserviceController < ApplicationController
|
|
154
165
|
def admin_user_list
|
155
166
|
user_admin?
|
156
167
|
|
157
|
-
all_users=User.find_all_by_domain_id
|
168
|
+
all_users=User.find_all_by_domain_id session[:domain_id]
|
158
169
|
return all_users.map { |u| [ u.login, u.description ] }
|
159
170
|
end
|
160
171
|
|
172
|
+
# Returns all users in this domain, as a hash
|
173
|
+
def admin_user_collection
|
174
|
+
user_admin?
|
175
|
+
all_users=User.find_all_by_domain_id session[:domain_id]
|
176
|
+
return all_users
|
177
|
+
end
|
178
|
+
|
161
179
|
# Resets a user's password.
|
162
180
|
def admin_user_reset_password login, password, password_confirmation
|
163
181
|
user_admin?
|
@@ -183,10 +201,13 @@ class MailserviceController < ApplicationController
|
|
183
201
|
if login_confirmation != login then
|
184
202
|
raise "Login and login confirmation not the same"
|
185
203
|
end
|
186
|
-
|
204
|
+
if User.find(session[:user_id]).login == login then
|
205
|
+
raise "Trying to delete yourself? Very funny"
|
206
|
+
end
|
207
|
+
|
187
208
|
u=User.find_by_login login
|
188
209
|
if u then
|
189
|
-
u.
|
210
|
+
User.delete u.id
|
190
211
|
return true
|
191
212
|
else
|
192
213
|
return false
|
@@ -212,7 +233,7 @@ class MailserviceController < ApplicationController
|
|
212
233
|
def admin_mailinglists_all
|
213
234
|
user_admin?
|
214
235
|
|
215
|
-
Mailinglist.
|
236
|
+
Mailinglist.find_all_by_domain_id session[:domain_id]
|
216
237
|
end
|
217
238
|
|
218
239
|
#========================================================================
|
@@ -223,49 +244,59 @@ class MailserviceController < ApplicationController
|
|
223
244
|
# otherwise false.
|
224
245
|
def user_login username, password
|
225
246
|
domain_logged_in?
|
226
|
-
|
247
|
+
|
248
|
+
session[:user_id] = nil
|
249
|
+
|
250
|
+
user = User.authenticate username, password
|
251
|
+
|
252
|
+
if user
|
253
|
+
session[:user_id]=user.id
|
254
|
+
end
|
255
|
+
|
227
256
|
user_logged_in
|
228
257
|
end
|
229
258
|
|
230
259
|
# Logs the user out.
|
231
|
-
def user_logout;
|
260
|
+
def user_logout; session[:user_id] = nil; end
|
232
261
|
|
233
262
|
# Returns whether the user is logged in or not.
|
234
|
-
def user_logged_in; not
|
263
|
+
def user_logged_in; not session[:user_id].nil?; end
|
235
264
|
|
236
265
|
# Returns the user's username.
|
237
|
-
def user_name;
|
266
|
+
def user_name; User.find(session[:user_id]).login; end
|
238
267
|
|
239
268
|
# Returns all the mailing lists that belong to this user.
|
240
269
|
def user_mailinglists
|
241
270
|
user_logged_in?
|
242
|
-
Mailinglist.find_all_by_user_id(
|
243
|
-
[
|
271
|
+
Mailinglist.find_all_by_user_id(session[:user_id]) -
|
272
|
+
[ User.find(session[:user_id]).mailinglist ]
|
244
273
|
end
|
245
274
|
|
246
275
|
# Returns the user's email address.
|
247
276
|
def user_email_address
|
248
277
|
user_logged_in?
|
249
|
-
|
278
|
+
User.find(session[:user_id]).address
|
250
279
|
end
|
251
280
|
|
252
281
|
# Returns all addresses belonging to this user.
|
253
282
|
def user_email_addresses
|
254
283
|
user_logged_in?
|
255
|
-
|
284
|
+
User.find(session[:user_id]).addresses.map { |a| a.address }
|
256
285
|
end
|
257
286
|
|
258
287
|
# Returns all _confirmed_ email addresses belonging to this user
|
259
288
|
def user_email_addresses_confirmed
|
260
289
|
user_logged_in?
|
261
|
-
|
290
|
+
User.find(session[:user_id]).mailinglist .
|
291
|
+
confirmed_addresses.map { |a| a.address }
|
262
292
|
end
|
263
293
|
|
264
294
|
# Returns all yet-to-be-confirmed email addresses belong to this
|
265
295
|
# user.
|
266
296
|
def user_email_addresses_unconfirmed
|
267
297
|
user_logged_in?
|
268
|
-
|
298
|
+
User.find(session[:user_id]).mailinglist .
|
299
|
+
pending_addresses.map { |a| a.address }
|
269
300
|
end
|
270
301
|
|
271
302
|
# Allows the user to confirm his email address on the web instead of
|
@@ -273,7 +304,7 @@ class MailserviceController < ApplicationController
|
|
273
304
|
def user_email_address_confirm(address,code)
|
274
305
|
user_logged_in?
|
275
306
|
address_obj=Address.find_by_address(address)
|
276
|
-
ml
|
307
|
+
ml=User.find(session[:user_id]).mailinglist
|
277
308
|
if ml.confirm(address_obj,code) then
|
278
309
|
ml.save
|
279
310
|
else
|
@@ -284,7 +315,7 @@ class MailserviceController < ApplicationController
|
|
284
315
|
# Lets the user change his password.
|
285
316
|
def user_change_password(old_password, password, password_confirmation)
|
286
317
|
user_logged_in?
|
287
|
-
user
|
318
|
+
user=User.find(session[:user_id])
|
288
319
|
if User.authenticate(user.login, old_password) then
|
289
320
|
user.password=password
|
290
321
|
user.password_confirmation=password_confirmation
|
@@ -306,20 +337,21 @@ class MailserviceController < ApplicationController
|
|
306
337
|
def user_real_name
|
307
338
|
user_logged_in?
|
308
339
|
|
309
|
-
|
340
|
+
User.find(session[:user_id]).description
|
310
341
|
end
|
311
342
|
|
312
343
|
# Allows the user to change his real name.
|
313
344
|
def user_change_real_name password, new_name
|
314
345
|
user_logged_in?
|
315
|
-
user
|
346
|
+
user=User.find(session[:user_id])
|
316
347
|
|
317
348
|
if User.authenticate(user.login, password) then
|
318
|
-
user.
|
319
|
-
|
349
|
+
ml = user.mailinglist
|
350
|
+
ml.description=new_name
|
351
|
+
if ml.save
|
320
352
|
return new_name
|
321
353
|
else
|
322
|
-
errstr =
|
354
|
+
errstr = ml.errors.sort.map do |fac, err|
|
323
355
|
"#{fac}: #{err}"
|
324
356
|
end.join("\n")
|
325
357
|
|
@@ -333,16 +365,17 @@ class MailserviceController < ApplicationController
|
|
333
365
|
# Adds a new email address to this user.
|
334
366
|
def user_email_addresses_add(address)
|
335
367
|
user_logged_in?
|
336
|
-
|
337
|
-
|
368
|
+
user = User.find(session[:user_id])
|
369
|
+
if user.mailinglist.subscribe address then
|
370
|
+
user.mailinglist.save
|
338
371
|
end
|
339
|
-
|
372
|
+
user.mailinglist.addresses
|
340
373
|
end
|
341
374
|
|
342
375
|
# Removes an email address from the user's email address list.
|
343
376
|
def user_email_addresses_remove(address)
|
344
377
|
user_logged_in?
|
345
|
-
|
378
|
+
User.find(session[:user_id]).mailinglist.unsubscribe address
|
346
379
|
end
|
347
380
|
|
348
381
|
# Creates a mailing list of type +mailinglist_class+. Retrieve the
|
@@ -356,24 +389,16 @@ class MailserviceController < ApplicationController
|
|
356
389
|
end
|
357
390
|
|
358
391
|
m=Mailinglist.new(:name => mailinglist_name,
|
359
|
-
:mailinglist_class_id => mailinglist_class_id,
|
360
|
-
:
|
361
|
-
|
362
|
-
if m.save then
|
363
|
-
return m.address
|
364
|
-
else
|
365
|
-
nil
|
366
|
-
end
|
367
|
-
else
|
368
|
-
nil
|
369
|
-
end
|
392
|
+
:mailinglist_class_id => mailinglist_class_id.id,
|
393
|
+
:user_id => session[:user_id])
|
394
|
+
m.save
|
370
395
|
end
|
371
396
|
|
372
397
|
# Returns a list of the names of all the mailing list classes.
|
373
398
|
def mailinglist_classes
|
374
399
|
# the first mailing list class is special (it's reserved for
|
375
400
|
# forwarding addresses).
|
376
|
-
MailinglistClass.
|
401
|
+
MailinglistClass.find(:all, :conditions => "id > 1").map { |mlc| mlc.name }
|
377
402
|
end
|
378
403
|
|
379
404
|
# Returns the attributes of the mailing list class +mlclass+. Use
|
@@ -398,7 +423,8 @@ class MailserviceController < ApplicationController
|
|
398
423
|
def mailinglist_find_by_name name
|
399
424
|
user_logged_in?
|
400
425
|
|
401
|
-
m=Mailinglist.find_by_address
|
426
|
+
m=Mailinglist.find_by_address \
|
427
|
+
"#{name}@#{Domain.find(session[:domain_id]).name}"
|
402
428
|
if m then m[0].id end
|
403
429
|
end
|
404
430
|
|
@@ -408,8 +434,6 @@ class MailserviceController < ApplicationController
|
|
408
434
|
|
409
435
|
if m.destroy
|
410
436
|
true
|
411
|
-
else
|
412
|
-
false
|
413
437
|
end
|
414
438
|
end
|
415
439
|
|
@@ -435,8 +459,6 @@ class MailserviceController < ApplicationController
|
|
435
459
|
def mailinglist_subscribe mailinglist_id, address
|
436
460
|
if my_mailing_list(mailinglist_id).subscribe(address)
|
437
461
|
true
|
438
|
-
else
|
439
|
-
false
|
440
462
|
end
|
441
463
|
end
|
442
464
|
|
@@ -462,36 +484,36 @@ class MailserviceController < ApplicationController
|
|
462
484
|
def mailinglist_unsubscribe mailinglist_id, address
|
463
485
|
if my_mailing_list(mailinglist_id).unsubscribe(address)
|
464
486
|
true
|
465
|
-
else
|
466
|
-
false
|
467
487
|
end
|
468
488
|
end
|
469
489
|
|
470
|
-
# Returns the IDs of all the messages messages sent to this mailing
|
471
|
-
# list.
|
472
|
-
#
|
473
|
-
# This should probably do something more useful like return all
|
474
|
-
# new messages since some datestamp or something.
|
475
|
-
def mailinglist_messages mailinglist_id
|
476
|
-
my_mailing_list(mailinglist_id).messages
|
477
|
-
end
|
478
|
-
|
479
|
-
#========================================================================
|
480
|
-
# Message methods
|
481
|
-
#========================================================================
|
482
|
-
|
483
|
-
# Returns the message with the id +id+.
|
484
|
-
def message message_id
|
485
|
-
readable_message(id)
|
486
|
-
end
|
487
|
-
|
488
|
-
# Return the message that this one's a response to.
|
489
|
-
def message_parent message_id
|
490
|
-
readable_message(id).parent
|
491
|
-
end
|
492
|
-
|
493
|
-
# Returns all responses to this message.
|
494
|
-
def message_responses message_id
|
495
|
-
readable_message(id).children.map { |m| m.id }
|
496
|
-
end
|
497
490
|
end
|
491
|
+
|
492
|
+
## TODO: implement message-handling functionality properly
|
493
|
+
## #========================================================================
|
494
|
+
## # Message methods
|
495
|
+
## #========================================================================
|
496
|
+
##
|
497
|
+
## # Returns the IDs of all the messages messages sent to this mailing
|
498
|
+
## # list.
|
499
|
+
## #
|
500
|
+
## # This should probably do something more useful like return all
|
501
|
+
## # new messages since some datestamp or something.
|
502
|
+
## def mailinglist_messages mailinglist_id
|
503
|
+
## my_mailing_list(mailinglist_id).messages
|
504
|
+
## end
|
505
|
+
##
|
506
|
+
## # Returns the message with the id +id+.
|
507
|
+
## def message message_id
|
508
|
+
## readable_message(id)
|
509
|
+
## end
|
510
|
+
##
|
511
|
+
## # Return the message that this one's a response to.
|
512
|
+
## def message_parent message_id
|
513
|
+
## readable_message(id).parent
|
514
|
+
## end
|
515
|
+
##
|
516
|
+
## # Returns all responses to this message.
|
517
|
+
## def message_responses message_id
|
518
|
+
## readable_message(id).children.map { |m| m.id }
|
519
|
+
## end
|