infopark_rails_connector 6.9.1.3.22208381 → 6.9.2.1.125136549
Sign up to get free protection for your applications and to get access to all the features.
- data/README +2 -14
- data/app/assets/javascripts/infopark_rails_connector.js.erb +0 -3
- data/app/assets/stylesheets/infopark_rails_connector.css.erb +0 -4
- data/app/controllers/rails_connector/default_cms_controller.rb +0 -1
- data/app/helpers/rails_connector/default_cms_helper.rb +0 -6
- data/app/helpers/rails_connector/layout_helper.rb +2 -7
- data/app/views/cms/index.html.erb +0 -2
- data/app/views/errors/410_gone.html.erb +2 -2
- data/config/ca-bundle.crt +1 -1
- data/config/cms_routes.rb +2 -1
- data/config/locales/de.rails_connector.views.yml +0 -78
- data/config/locales/en.rails_connector.views.yml +0 -78
- data/lib/generators/rails_connector/install/install_generator.rb +0 -1
- data/lib/generators/rails_connector/install/templates/initializers/rails_connector.rb +0 -27
- data/lib/rails_connector/cms_accessible.rb +0 -4
- data/lib/rails_connector/configuration.rb +9 -72
- data/lib/rails_connector/engine.rb +0 -18
- metadata +3 -181
- data/app/assets/images/ratings/star.gif +0 -0
- data/app/assets/images/time_machine/calendar-menuarrow.gif +0 -0
- data/app/assets/images/time_machine/calendar_bg.png +0 -0
- data/app/assets/images/time_machine/icon.png +0 -0
- data/app/assets/images/time_machine/slider_bg.png +0 -0
- data/app/assets/images/time_machine/slider_handle.png +0 -0
- data/app/assets/images/time_machine/timemachine_bg.png +0 -0
- data/app/assets/javascripts/comments.js +0 -29
- data/app/assets/javascripts/initializer.js +0 -9
- data/app/assets/javascripts/ratings.js +0 -26
- data/app/assets/javascripts/time_machine.js +0 -8
- data/app/assets/javascripts/time_machine/calendar-setup.js +0 -200
- data/app/assets/javascripts/time_machine/calendar.js +0 -1806
- data/app/assets/javascripts/time_machine/lang/calendar-de.js +0 -127
- data/app/assets/javascripts/time_machine/lang/calendar-en.js +0 -127
- data/app/assets/javascripts/time_machine/lang/calendar-es.js +0 -129
- data/app/assets/javascripts/time_machine/lang/calendar-fr.js +0 -125
- data/app/assets/javascripts/time_machine/lang/calendar-it.js +0 -124
- data/app/assets/javascripts/time_machine/slider.js +0 -278
- data/app/assets/stylesheets/ratings.css +0 -97
- data/app/assets/stylesheets/time_machine.css +0 -6
- data/app/assets/stylesheets/time_machine/time_machine.css +0 -292
- data/app/controllers/comments_controller.rb +0 -6
- data/app/controllers/crm_form_controller.rb +0 -6
- data/app/controllers/rails_connector/default_comments_controller.rb +0 -70
- data/app/controllers/rails_connector/default_crm_form_controller.rb +0 -167
- data/app/controllers/rails_connector/default_ratings_controller.rb +0 -84
- data/app/controllers/rails_connector/default_rss_controller.rb +0 -30
- data/app/controllers/rails_connector/default_search_controller.rb +0 -60
- data/app/controllers/rails_connector/default_user_controller.rb +0 -269
- data/app/controllers/rails_connector/time_machine_controller.rb +0 -48
- data/app/controllers/ratings_controller.rb +0 -6
- data/app/controllers/rss_controller.rb +0 -6
- data/app/controllers/search_controller.rb +0 -6
- data/app/controllers/seo_sitemap_controller.rb +0 -12
- data/app/controllers/user_controller.rb +0 -6
- data/app/helpers/crm_form_helper.rb +0 -6
- data/app/helpers/rails_connector/default_crm_form_helper.rb +0 -58
- data/app/helpers/rails_connector/default_ratings_helper.rb +0 -38
- data/app/helpers/rails_connector/default_user_helper.rb +0 -90
- data/app/helpers/rails_connector/error_messages_helper.rb +0 -23
- data/app/helpers/rails_connector/link_helper.rb +0 -93
- data/app/helpers/rails_connector/mandatory_label_helper.rb +0 -10
- data/app/helpers/rails_connector/menu_helper.rb +0 -73
- data/app/helpers/rails_connector/micronav_helper.rb +0 -109
- data/app/helpers/rails_connector/seo_helper.rb +0 -44
- data/app/helpers/rails_connector/time_machine_helper.rb +0 -26
- data/app/helpers/rails_connector/tracking_helper.rb +0 -32
- data/app/helpers/ratings_helper.rb +0 -4
- data/app/helpers/user_helper.rb +0 -6
- data/app/mailers/confirmation_mailer.rb +0 -15
- data/app/models/crm_form.rb +0 -2
- data/app/models/rails_connector/default_comment.rb +0 -30
- data/app/models/rails_connector/default_rating.rb +0 -22
- data/app/views/cms/_comments.html.erb +0 -44
- data/app/views/cms/_rating.html.erb +0 -31
- data/app/views/comments/_comment.html.erb +0 -28
- data/app/views/confirmation_mailer/register_confirmation.erb +0 -5
- data/app/views/confirmation_mailer/reset_password.erb +0 -5
- data/app/views/crm_form/_flash_messages.html.erb +0 -11
- data/app/views/crm_form/_form.html.erb +0 -17
- data/app/views/crm_form/confirmation.html.erb +0 -3
- data/app/views/crm_form/index.html.erb +0 -5
- data/app/views/crm_form/not_logged_in.html.erb +0 -1
- data/app/views/layouts/rails_connector/time_machine.html.erb +0 -12
- data/app/views/rails_connector/time_machine/index.html.erb +0 -88
- data/app/views/rss/_item.rss.builder +0 -11
- data/app/views/rss/index.rss.builder +0 -11
- data/app/views/search/_hit.html.erb +0 -11
- data/app/views/search/_hits.html.erb +0 -11
- data/app/views/search/_mini_panel.html.erb +0 -4
- data/app/views/search/_pagination.html.erb +0 -5
- data/app/views/search/_panel.html.erb +0 -4
- data/app/views/search/search.html.erb +0 -12
- data/app/views/seo_sitemap/show.xml.builder +0 -16
- data/app/views/user/_flash_messages.html.erb +0 -11
- data/app/views/user/edit.html.erb +0 -6
- data/app/views/user/edit_password.html.erb +0 -11
- data/app/views/user/forgot_password.html.erb +0 -7
- data/app/views/user/login.html.erb +0 -15
- data/app/views/user/new.html.erb +0 -13
- data/app/views/user/profile.html.erb +0 -8
- data/app/views/user/register_pending.html.erb +0 -1
- data/app/views/user/set_password.html.erb +0 -14
- data/config/locales/de.rails_connector.controllers.yml +0 -28
- data/config/locales/de.rails_connector.helpers.yml +0 -9
- data/config/locales/de.rails_connector.models.yml +0 -8
- data/config/locales/en.rails_connector.controllers.yml +0 -28
- data/config/locales/en.rails_connector.helpers.yml +0 -9
- data/config/locales/en.rails_connector.models.yml +0 -8
- data/config/routes.rb +0 -31
- data/lib/generators/rails_connector/comments/comments_generator.rb +0 -20
- data/lib/generators/rails_connector/comments/templates/migration.rb +0 -16
- data/lib/generators/rails_connector/install/templates/initializers/crm_connector.rb +0 -22
- data/lib/generators/rails_connector/ratings/ratings_generator.rb +0 -20
- data/lib/generators/rails_connector/ratings/templates/migration.rb +0 -14
- data/lib/rails_connector/commentable.rb +0 -23
- data/lib/rails_connector/configuration/google_analytics.rb +0 -29
- data/lib/rails_connector/configuration/rss.rb +0 -46
- data/lib/rails_connector/crm.rb +0 -282
- data/lib/rails_connector/googlebot_checker.rb +0 -46
- data/lib/rails_connector/liquid_support.rb +0 -25
- data/lib/rails_connector/liquid_support/field_value_drop.rb +0 -22
- data/lib/rails_connector/liquid_support/general_helper_tag.rb +0 -44
- data/lib/rails_connector/liquid_support/link_drop.rb +0 -22
- data/lib/rails_connector/liquid_support/liquid_template_handler.rb +0 -162
- data/lib/rails_connector/liquid_support/named_object_drop.rb +0 -14
- data/lib/rails_connector/liquid_support/obj_drop.rb +0 -43
- data/lib/rails_connector/liquid_support/obj_filters.rb +0 -77
- data/lib/rails_connector/rateable.rb +0 -57
- data/lib/rails_connector/seo.rb +0 -52
- data/lib/rails_connector/ses.rb +0 -81
- data/lib/rails_connector/syndicateable.rb +0 -11
- data/lib/search_request.rb +0 -2
@@ -1,6 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
-
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
-
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
-
*= require_tree ./time_machine
|
6
|
-
*/
|
@@ -1,292 +0,0 @@
|
|
1
|
-
body {
|
2
|
-
color:#fff;
|
3
|
-
font-size:11px;
|
4
|
-
font-family:'Lucida Grande', Helvetica, Verdana, Arial, sans-serif;
|
5
|
-
background-color:#333;
|
6
|
-
}
|
7
|
-
|
8
|
-
#time-machine {
|
9
|
-
width:425px;
|
10
|
-
height:300px;
|
11
|
-
margin:auto;
|
12
|
-
margin-top:20px;
|
13
|
-
padding:0;
|
14
|
-
background:transparent url(../time_machine/timemachine_bg.png) no-repeat;
|
15
|
-
}
|
16
|
-
|
17
|
-
#slider {
|
18
|
-
width:375px;
|
19
|
-
height:50px;
|
20
|
-
margin-left:25px;
|
21
|
-
margin-top:15px;
|
22
|
-
}
|
23
|
-
|
24
|
-
#track {
|
25
|
-
width:375px;
|
26
|
-
height:23px;
|
27
|
-
background:transparent url(../time_machine/slider_bg.png) no-repeat;
|
28
|
-
}
|
29
|
-
|
30
|
-
#handle {
|
31
|
-
height:21px;
|
32
|
-
width:50px;
|
33
|
-
margin:2px;
|
34
|
-
padding-right:2px;
|
35
|
-
background:transparent url(../time_machine/slider_handle.png) no-repeat 0 2px;
|
36
|
-
cursor:move;
|
37
|
-
}
|
38
|
-
|
39
|
-
#display {
|
40
|
-
padding-top:5px;
|
41
|
-
width:375px;
|
42
|
-
text-align:center;
|
43
|
-
}
|
44
|
-
|
45
|
-
#calendar {
|
46
|
-
width:250px;
|
47
|
-
height:200px;
|
48
|
-
padding-top:20px;
|
49
|
-
margin-left:87px;
|
50
|
-
}
|
51
|
-
|
52
|
-
/* The main calendar widget. DIV containing a table. */
|
53
|
-
|
54
|
-
.calendar {
|
55
|
-
height:200px;
|
56
|
-
position:relative;
|
57
|
-
display: none;
|
58
|
-
font-size: 11px;
|
59
|
-
color: #fff;
|
60
|
-
cursor: default;
|
61
|
-
background:transparent url(../time_machine/calendar_bg.png) no-repeat;
|
62
|
-
font-family: tahoma,verdana,sans-serif;
|
63
|
-
}
|
64
|
-
|
65
|
-
.calendar table {
|
66
|
-
margin:10px;
|
67
|
-
font-size: 11px;
|
68
|
-
color: #fff;
|
69
|
-
cursor: default;
|
70
|
-
background:none;
|
71
|
-
font-family: tahoma,verdana,sans-serif;
|
72
|
-
}
|
73
|
-
|
74
|
-
/* Header part -- contains navigation buttons and day names. */
|
75
|
-
|
76
|
-
.calendar .button { /* "<<", "<", ">", ">>" buttons have this class */
|
77
|
-
text-align: center;
|
78
|
-
padding: 1px;
|
79
|
-
border-bottom: 1px solid #666;
|
80
|
-
}
|
81
|
-
|
82
|
-
.calendar .nav {
|
83
|
-
background: transparent url(../time_machine/calendar-menuarrow.gif) no-repeat 100% 100%;
|
84
|
-
}
|
85
|
-
|
86
|
-
.calendar thead .title { /* This holds the current "month, year" */
|
87
|
-
font-weight: bold;
|
88
|
-
padding: 1px;
|
89
|
-
border: 1px solid #000;
|
90
|
-
background:none;
|
91
|
-
color: #fff;
|
92
|
-
text-align: center;
|
93
|
-
border-bottom: 1px solid #666;
|
94
|
-
}
|
95
|
-
|
96
|
-
.calendar thead .headrow { /* Row <TR> containing navigation buttons */
|
97
|
-
}
|
98
|
-
|
99
|
-
.calendar thead .daynames { /* Row <TR> containing the day names */
|
100
|
-
}
|
101
|
-
|
102
|
-
.calendar thead .name { /* Cells <TD> containing the day names */
|
103
|
-
border-bottom:1px solid #666;
|
104
|
-
padding:2px;
|
105
|
-
text-align:center;
|
106
|
-
background:none;
|
107
|
-
}
|
108
|
-
|
109
|
-
.calendar thead .weekend { /* How a weekend day name shows in header */
|
110
|
-
color: #fff;
|
111
|
-
}
|
112
|
-
|
113
|
-
.calendar thead .hilite { /* How do the buttons in header appear when hover */
|
114
|
-
padding: 0px;
|
115
|
-
background-color: #999;
|
116
|
-
}
|
117
|
-
|
118
|
-
.calendar thead .active { /* Active (pressed) buttons in header */
|
119
|
-
padding: 2px 0px 0px 2px;
|
120
|
-
background-color: #fff;
|
121
|
-
color:#333;
|
122
|
-
}
|
123
|
-
|
124
|
-
/* The body part -- contains all the days in month. */
|
125
|
-
|
126
|
-
.calendar tbody .day { /* Cells <TD> containing month days dates */
|
127
|
-
width: 2em;
|
128
|
-
text-align: right;
|
129
|
-
padding: 2px 4px 2px 2px;
|
130
|
-
}
|
131
|
-
.calendar tbody .day.othermonth {
|
132
|
-
font-size: 80%;
|
133
|
-
color: #aaa;
|
134
|
-
}
|
135
|
-
.calendar tbody .day.othermonth.oweekend {
|
136
|
-
color: #faa;
|
137
|
-
}
|
138
|
-
|
139
|
-
.calendar table .wn {
|
140
|
-
padding: 2px 3px 2px 2px;
|
141
|
-
border-right: 1px solid #666;
|
142
|
-
background:none;
|
143
|
-
}
|
144
|
-
|
145
|
-
.calendar tbody .rowhilite td {
|
146
|
-
background: #999;
|
147
|
-
}
|
148
|
-
|
149
|
-
.calendar tbody .rowhilite td.wn {
|
150
|
-
background: #999;
|
151
|
-
}
|
152
|
-
|
153
|
-
.calendar tbody td.hilite { /* Hovered cells <TD> */
|
154
|
-
background:#666
|
155
|
-
}
|
156
|
-
|
157
|
-
.calendar tbody td.active { /* Active (pressed) cells <TD> */
|
158
|
-
padding: 2px 2px 0px 2px;
|
159
|
-
border: 1px solid;
|
160
|
-
border-color:#000;
|
161
|
-
}
|
162
|
-
|
163
|
-
.calendar tbody td.selected { /* Cell showing selected date */
|
164
|
-
font-weight: bold;
|
165
|
-
padding: 2px 2px 0px 2px;
|
166
|
-
border: 1px solid;
|
167
|
-
border-color: #000;
|
168
|
-
background:#aaa;
|
169
|
-
color:#fff;
|
170
|
-
}
|
171
|
-
|
172
|
-
.calendar tbody td.weekend { /* Cells showing weekend days */
|
173
|
-
color: #f00;
|
174
|
-
}
|
175
|
-
|
176
|
-
.calendar tbody td.today { /* Cell showing today date */
|
177
|
-
font-weight: bold;
|
178
|
-
color: #3366ff;
|
179
|
-
}
|
180
|
-
|
181
|
-
.calendar tbody .disabled { color: #999; }
|
182
|
-
|
183
|
-
.calendar tbody .emptycell { /* Empty cells (the best is to hide them) */
|
184
|
-
visibility: hidden;
|
185
|
-
}
|
186
|
-
|
187
|
-
.calendar tbody .emptyrow { /* Empty row (some months need less than 6 rows) */
|
188
|
-
display: none;
|
189
|
-
}
|
190
|
-
|
191
|
-
/* The footer part -- status bar and "Close" button */
|
192
|
-
|
193
|
-
.calendar tfoot .footrow { /* The <TR> in footer (only one right now) */
|
194
|
-
}
|
195
|
-
|
196
|
-
.calendar tfoot .ttip { /* Tooltip (status bar) cell <TD> */
|
197
|
-
background: #e8f0f4;
|
198
|
-
padding: 2px;
|
199
|
-
border: 1px solid #000;
|
200
|
-
background: #666;
|
201
|
-
color: #fff;
|
202
|
-
text-align: center;
|
203
|
-
}
|
204
|
-
|
205
|
-
.calendar tfoot .hilite { /* Hover style for buttons in footer */
|
206
|
-
border-top: 1px solid #fff;
|
207
|
-
border-right: 1px solid #000;
|
208
|
-
border-bottom: 1px solid #000;
|
209
|
-
border-left: 1px solid #fff;
|
210
|
-
padding: 1px;
|
211
|
-
background: #d8e0e4;
|
212
|
-
}
|
213
|
-
|
214
|
-
.calendar tfoot .active { /* Active (pressed) style for buttons in footer */
|
215
|
-
padding: 2px 0px 0px 2px;
|
216
|
-
border-top: 1px solid #000;
|
217
|
-
border-right: 1px solid #fff;
|
218
|
-
border-bottom: 1px solid #fff;
|
219
|
-
border-left: 1px solid #000;
|
220
|
-
}
|
221
|
-
|
222
|
-
/* Combo boxes (menus that display months/years for direct selection) */
|
223
|
-
|
224
|
-
.calendar .combo {
|
225
|
-
position: absolute;
|
226
|
-
display: none;
|
227
|
-
width: 4em;
|
228
|
-
top: 0px;
|
229
|
-
left: 0px;
|
230
|
-
cursor: default;
|
231
|
-
background: #999;
|
232
|
-
font-size: 90%;
|
233
|
-
padding: 1px;
|
234
|
-
z-index: 100;
|
235
|
-
}
|
236
|
-
|
237
|
-
.calendar .combo .label,
|
238
|
-
.calendar .combo .label-IEfix {
|
239
|
-
text-align: center;
|
240
|
-
padding: 1px;
|
241
|
-
}
|
242
|
-
|
243
|
-
.calendar .combo .label-IEfix {
|
244
|
-
width: 4em;
|
245
|
-
}
|
246
|
-
|
247
|
-
.calendar .combo .active {
|
248
|
-
background: #c8d0d4;
|
249
|
-
padding: 0px;
|
250
|
-
}
|
251
|
-
|
252
|
-
.calendar .combo .hilite {
|
253
|
-
background: #333;
|
254
|
-
color: #fff;
|
255
|
-
}
|
256
|
-
|
257
|
-
.calendar td.time {
|
258
|
-
border-top: 1px solid #000;
|
259
|
-
padding: 1px 0px;
|
260
|
-
text-align: center;
|
261
|
-
background-color: #e8f0f4;
|
262
|
-
}
|
263
|
-
|
264
|
-
.calendar td.time .hour,
|
265
|
-
.calendar td.time .minute,
|
266
|
-
.calendar td.time .ampm {
|
267
|
-
padding: 0px 3px 0px 4px;
|
268
|
-
border: 1px solid #889;
|
269
|
-
font-weight: bold;
|
270
|
-
background-color: #fff;
|
271
|
-
}
|
272
|
-
|
273
|
-
.calendar td.time .ampm {
|
274
|
-
text-align: center;
|
275
|
-
}
|
276
|
-
|
277
|
-
.calendar td.time .colon {
|
278
|
-
padding: 0px 2px 0px 3px;
|
279
|
-
font-weight: bold;
|
280
|
-
}
|
281
|
-
|
282
|
-
.calendar td.time span.hilite {
|
283
|
-
border-color: #000;
|
284
|
-
background-color: #667;
|
285
|
-
color: #fff;
|
286
|
-
}
|
287
|
-
|
288
|
-
.calendar td.time span.active {
|
289
|
-
border-color: #f00;
|
290
|
-
background-color: #000;
|
291
|
-
color: #0f0;
|
292
|
-
}
|
@@ -1,70 +0,0 @@
|
|
1
|
-
module RailsConnector
|
2
|
-
#
|
3
|
-
# This class provides a default controller implementation for comment creation.
|
4
|
-
# It should only be used indirectly via a subclass named {CommentsController}.
|
5
|
-
#
|
6
|
-
# The controller actions only respond to XMLHttpRequests (Ajax).
|
7
|
-
class DefaultCommentsController < ApplicationController
|
8
|
-
layout nil
|
9
|
-
|
10
|
-
before_filter :ensure_object_is_commentable, :only => :create
|
11
|
-
before_filter :ensure_admin, :only => :delete
|
12
|
-
|
13
|
-
#
|
14
|
-
# Creates a comment and calls the +after_create+ callback.
|
15
|
-
#
|
16
|
-
def create
|
17
|
-
respond_to do |format|
|
18
|
-
format.js do
|
19
|
-
@comment = @obj.comments.create(
|
20
|
-
if logged_in?
|
21
|
-
params[:comment].merge({
|
22
|
-
:name => "#{current_user.first_name} #{current_user.last_name}",
|
23
|
-
:email => current_user.email
|
24
|
-
})
|
25
|
-
else
|
26
|
-
params[:comment]
|
27
|
-
end
|
28
|
-
)
|
29
|
-
if @comment.errors.empty?
|
30
|
-
after_create
|
31
|
-
html = render_to_string(:partial => "comments/comment", :locals => {:comment => @comment})
|
32
|
-
render :json => {:comment => html}.to_json
|
33
|
-
else
|
34
|
-
render :json => {:errors => @comment.errors.keys}.to_json
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
#
|
41
|
-
# Deletes a comment.
|
42
|
-
# Allowed only to an admin.
|
43
|
-
#
|
44
|
-
def delete
|
45
|
-
respond_to do |format|
|
46
|
-
format.html do
|
47
|
-
@comment = Comment.find(params[:id])
|
48
|
-
@comment.destroy
|
49
|
-
redirect_to :back
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
def ensure_object_is_commentable
|
57
|
-
@obj = Obj.find(params[:obj_id])
|
58
|
-
render :nothing => true unless @obj.allow_comments?
|
59
|
-
unless @obj.allow_anonymous_comments? or logged_in?
|
60
|
-
render '/errors/403_forbidden', :status => 403
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def ensure_admin
|
65
|
-
render("errors/403_forbidden", :status => 403) unless admin?
|
66
|
-
end
|
67
|
-
|
68
|
-
def after_create; end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,167 +0,0 @@
|
|
1
|
-
module RailsConnector
|
2
|
-
# This class provides a default controller implementation for WebCRM form using custom attributes.
|
3
|
-
# It should be customized by subclassing.
|
4
|
-
class DefaultCrmFormController < DefaultCmsController
|
5
|
-
|
6
|
-
include Crm::Localizable
|
7
|
-
include Crm::Sanitization
|
8
|
-
|
9
|
-
before_filter :authorize
|
10
|
-
|
11
|
-
class_attribute :editable_attributes_on_register
|
12
|
-
self.editable_attributes_on_register = {
|
13
|
-
:contact => [:gender, :first_name, :last_name, :email]
|
14
|
-
}
|
15
|
-
|
16
|
-
def index
|
17
|
-
unless logged_in?
|
18
|
-
@user = Infopark::Crm::Contact.new(:language => default_language)
|
19
|
-
@user.load(sanitize_user_params(params[:user], editable_attributes_on_register))
|
20
|
-
end
|
21
|
-
@activity = Infopark::Crm::Activity.new(:state => activity_state, :kind => activity_kind)
|
22
|
-
@activity.load(sanitize_activity_params(params[:activity]))
|
23
|
-
if request.post?
|
24
|
-
if logged_in?
|
25
|
-
@activity.contact_id = current_user.id
|
26
|
-
else
|
27
|
-
if @user.email.blank?
|
28
|
-
@user.errors.add(:email, t(:'rails_connector.errors.messages.blank'))
|
29
|
-
raise ActiveResource::ResourceInvalid.new("E-mail can't be blank")
|
30
|
-
end
|
31
|
-
@user.save!
|
32
|
-
@activity.contact_id = @user.id
|
33
|
-
end
|
34
|
-
before_saving_activity(@activity)
|
35
|
-
@activity.save
|
36
|
-
raise ActiveResource::ResourceInvalid, "activity invalid" unless @activity.valid?
|
37
|
-
after_saving_activity(@activity)
|
38
|
-
end
|
39
|
-
rescue ActiveResource::ResourceInvalid => e
|
40
|
-
flash.now[:error] = t("rails_connector.controllers.crm_form.submit_failed")
|
41
|
-
end
|
42
|
-
|
43
|
-
protected
|
44
|
-
|
45
|
-
# Returns the activity kind to create.
|
46
|
-
# Override this method for custom logic to get from a given OBJ to an activity kind.
|
47
|
-
#
|
48
|
-
# Defaults to +@obj[:activity_kind]+ or 'contact form' if the former is +nil+.
|
49
|
-
def activity_kind
|
50
|
-
@obj[:activity_kind] || 'contact form'
|
51
|
-
end
|
52
|
-
|
53
|
-
# Returns the state of a new activity.
|
54
|
-
#
|
55
|
-
# Defaults to the first state assigned to +activity_kind+.
|
56
|
-
def activity_state
|
57
|
-
Infopark::Crm::CustomType.find(activity_kind).states.first
|
58
|
-
end
|
59
|
-
|
60
|
-
# Returns the language for a new contact, in case you don't have a language field in your form.
|
61
|
-
#
|
62
|
-
# If you want your visitors to choose their language, don't override this method!
|
63
|
-
# Instead, include :language in your +editable_attributes_on_register+ and add
|
64
|
-
# an additional form field to the corresponding view.
|
65
|
-
#
|
66
|
-
# Defaults to the current locale.
|
67
|
-
def default_language
|
68
|
-
I18n.locale.to_s
|
69
|
-
end
|
70
|
-
|
71
|
-
# Provides a callback to change the given activity in-place before saving it.
|
72
|
-
# Be aware that this method may modify the argument.
|
73
|
-
#
|
74
|
-
# This method may be used to prepend the activity's title or otherwise customize
|
75
|
-
# the behavior without having to override #index.
|
76
|
-
#
|
77
|
-
# By default, it assigns a default title if +has_title_input_field?+ is +false+.
|
78
|
-
def before_saving_activity(activity)
|
79
|
-
activity.title = "Website form submission" unless has_title_input_field?
|
80
|
-
end
|
81
|
-
|
82
|
-
# Provides a callback after saving the activity.
|
83
|
-
# This method may be overridden to render a confirmation text,
|
84
|
-
# or redirect the user to a separate confirmation page.
|
85
|
-
#
|
86
|
-
# The method is also available as helper in your views.
|
87
|
-
#
|
88
|
-
# By default, it renders crm_form/confirmation
|
89
|
-
def after_saving_activity(activity)
|
90
|
-
render 'crm_form/confirmation'
|
91
|
-
end
|
92
|
-
|
93
|
-
# Used by views to determine if input field for title should be rendered.
|
94
|
-
# Override this method to return +false+ if you want to set the title programmatically.
|
95
|
-
#
|
96
|
-
# By default, it returns +true+
|
97
|
-
def has_title_input_field?
|
98
|
-
true
|
99
|
-
end
|
100
|
-
helper_method :has_title_input_field?
|
101
|
-
|
102
|
-
# Sanitizes the given hash of POST parameters, cleaning out any key-value pairs that are
|
103
|
-
# potentially dangerous if set by the user.
|
104
|
-
# This prevents users from setting arbitrary activity properties, such as kind or state,
|
105
|
-
# and custom attributes that are not to be set by users.
|
106
|
-
#
|
107
|
-
# By default, it returns a hash only with title and custom values.
|
108
|
-
def sanitize_activity_params(activity_params_or_nil)
|
109
|
-
activity_params_whitelist = [:title]
|
110
|
-
(activity_params_or_nil || {}).reject do |attr, value|
|
111
|
-
!(attr.starts_with?('custom_') && allow_custom_attribute?(attr)) &&
|
112
|
-
!activity_params_whitelist.include?(attr.to_sym)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
# Default before_filter for this controller that renders
|
117
|
-
# +crm_form/not_logged_in+ if the user is not logged in.
|
118
|
-
#
|
119
|
-
# Drop a custom view to change the look, or override this method
|
120
|
-
# if you want different behavior, like a redirect.
|
121
|
-
def authorize
|
122
|
-
render 'not_logged_in' unless logged_in? || allow_anonymous?
|
123
|
-
end
|
124
|
-
|
125
|
-
# Returns +true+ if users should see the form even when they are not logged in.
|
126
|
-
# In that case, the WebCRM activity includes a registration request so that a contact
|
127
|
-
# can be created from it.
|
128
|
-
#
|
129
|
-
# The method is also available as helper in your views.
|
130
|
-
#
|
131
|
-
# By default, it returns +false+, i.e. only logged-in users can see the form
|
132
|
-
def allow_anonymous?
|
133
|
-
false
|
134
|
-
end
|
135
|
-
helper_method :allow_anonymous?
|
136
|
-
|
137
|
-
# Returns +true+ if users should be able to fill in the given custom attribute.
|
138
|
-
#
|
139
|
-
# The method is also available as helper and used in +custom_fields_for+ in
|
140
|
-
# +CrmFormHelper+.
|
141
|
-
#
|
142
|
-
# By default, it returns +true+ for any attribute, i.e. every custom attribute
|
143
|
-
# can be filled in by the user.
|
144
|
-
def allow_custom_attribute?(attribute_name)
|
145
|
-
true
|
146
|
-
end
|
147
|
-
helper_method :allow_custom_attribute?
|
148
|
-
|
149
|
-
# Returns a hash of attributes users are allowed to change in their profile.
|
150
|
-
# Use it in your views and your controller.
|
151
|
-
# The hash has only one key, +:contact+, with an array of symbols.
|
152
|
-
#
|
153
|
-
# Do not override this (instance) method. Assign a new hash in your subclass:
|
154
|
-
#
|
155
|
-
# class CrmFormController < RailsConnector::DefaultCrmFormController
|
156
|
-
#
|
157
|
-
# self.editable_attributes_on_register = {
|
158
|
-
# :contact => [:first_name, :last_name, :email]
|
159
|
-
# }
|
160
|
-
#
|
161
|
-
# end
|
162
|
-
def editable_attributes_on_register
|
163
|
-
self.class.editable_attributes_on_register
|
164
|
-
end
|
165
|
-
helper_method :editable_attributes_on_register
|
166
|
-
end
|
167
|
-
end
|