infopark_rails_connector 6.9.1.3.22208381 → 6.9.2.1.125136549
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/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,84 +0,0 @@
|
|
1
|
-
module RailsConnector
|
2
|
-
#
|
3
|
-
# This controller provides an interface for rating CMS objects.
|
4
|
-
#
|
5
|
-
# =Before Filters
|
6
|
-
# <tt>load_object</tt>: finds the Obj instance using <tt>params[:obj_id]</tt>
|
7
|
-
# <tt>ensure_object_is_rateable</tt>: renders nothing unless <tt>@obj.allow_rating?</tt> AND <tt>user_has_already_rated?(@obj.id)</tt> return <tt>true</tt>.
|
8
|
-
#
|
9
|
-
# =Hooks
|
10
|
-
#
|
11
|
-
# <tt>after_create</tt>: redefine this method in your application in order to specify additional functionality that should occur after a rating has been created.
|
12
|
-
#
|
13
|
-
# Example:
|
14
|
-
#
|
15
|
-
# class RatingsController < RailsConnector::DefaultRatingsController
|
16
|
-
# private
|
17
|
-
# def after_create
|
18
|
-
# # * send an email
|
19
|
-
# # * create an inquiry in the OMC
|
20
|
-
# end
|
21
|
-
# end
|
22
|
-
class DefaultRatingsController < ApplicationController
|
23
|
-
|
24
|
-
before_filter :load_object
|
25
|
-
before_filter :ensure_object_is_rateable, :only => [:rate]
|
26
|
-
before_filter :ensure_admin, :only => :reset
|
27
|
-
|
28
|
-
layout nil
|
29
|
-
|
30
|
-
# Rate a CMS object.
|
31
|
-
def rate
|
32
|
-
respond_to do |format|
|
33
|
-
format.html do
|
34
|
-
score = params[:score].to_i
|
35
|
-
if @obj.rate(score)
|
36
|
-
store_rating_in_session(@obj.id, score)
|
37
|
-
after_create
|
38
|
-
end
|
39
|
-
render :partial => "cms/rating"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# Reset rating for a CMS object.
|
45
|
-
def reset
|
46
|
-
respond_to do |format|
|
47
|
-
format.html do
|
48
|
-
@obj.reset_rating
|
49
|
-
store_rating_in_session(@obj.id, nil)
|
50
|
-
redirect_to :back
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
def after_create;end
|
58
|
-
|
59
|
-
def load_object
|
60
|
-
@obj = Obj.find(params[:id])
|
61
|
-
end
|
62
|
-
|
63
|
-
def ensure_object_is_rateable
|
64
|
-
render(:nothing => true) if (!@obj.allow_rating? || user_has_already_rated?(@obj.id))
|
65
|
-
unless @obj.allow_anonymous_rating? or logged_in?
|
66
|
-
render '/errors/403_forbidden', :status => 403
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def user_has_already_rated?(obj_id)
|
71
|
-
session[:rated_objs] && session[:rated_objs][obj_id]
|
72
|
-
end
|
73
|
-
|
74
|
-
def store_rating_in_session(obj_id, score)
|
75
|
-
session[:rated_objs] ||= {}
|
76
|
-
session[:rated_objs][obj_id] = score
|
77
|
-
end
|
78
|
-
|
79
|
-
def ensure_admin
|
80
|
-
render("errors/403_forbidden", :status => 403) unless admin?
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module RailsConnector
|
2
|
-
#
|
3
|
-
# This class provides a default controller implementation for rendering an RSS feed.
|
4
|
-
# It should be customized by subclassing.
|
5
|
-
#
|
6
|
-
# The RSS feature assumes that you have a root object specified whose direct children will be used as feed entries.
|
7
|
-
#
|
8
|
-
# Specify the RSS root in
|
9
|
-
# <code><em>RAILS_ROOT</em>/config/initializers/rails_connector.rb</code>:
|
10
|
-
# RailsConnector::Configuration::Rss.root = lambda { NamedLink.get_object('news') }
|
11
|
-
class DefaultRssController < DefaultCmsController
|
12
|
-
#
|
13
|
-
# This action renders the built-in RSS feed.
|
14
|
-
#
|
15
|
-
# To customize feed's layout, override either this method, or the apropriate view.
|
16
|
-
#
|
17
|
-
# @return [void]
|
18
|
-
def index
|
19
|
-
respond_to do |format|
|
20
|
-
format.rss
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
protected
|
25
|
-
|
26
|
-
def load_object
|
27
|
-
@obj = Configuration::Rss.root
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'will_paginate'
|
2
|
-
|
3
|
-
module RailsConnector
|
4
|
-
|
5
|
-
# This class provides a default controller implementation for searching.
|
6
|
-
# It should be customized by subclassing.
|
7
|
-
class DefaultSearchController < ApplicationController
|
8
|
-
class_attribute :options
|
9
|
-
self.options = {:limit => 10}
|
10
|
-
|
11
|
-
# Fetches search hits and paginates them.
|
12
|
-
# In case of an error, flashes appropriate error messages.
|
13
|
-
#
|
14
|
-
# For use in views, hits are stored in the <tt>@hits</tt> variable.
|
15
|
-
# Pagination is done using the limit option (defaults to 10).
|
16
|
-
# You can change that limit by subclassing <tt>DefaultSearchController</tt>
|
17
|
-
# and then overwriting to <tt>CustomSearchController.options = {:limit => X}</tt>.
|
18
|
-
#
|
19
|
-
# To customize the pagination, you should subclass DefaultSearchController:
|
20
|
-
#
|
21
|
-
# class SearchController < RailsConnector::DefaultSearchController
|
22
|
-
# def search
|
23
|
-
# # What this method should do:
|
24
|
-
# # * Initialize a SearchRequest obj
|
25
|
-
# # * Paginate the results
|
26
|
-
# # * Fill the @hits variable for your views
|
27
|
-
# # * Flash on errors
|
28
|
-
# end
|
29
|
-
# end
|
30
|
-
def search
|
31
|
-
unless (@query = params[:q]).blank?
|
32
|
-
@hits = WillPaginate::Collection.create(current_page, options[:limit]) do |pager|
|
33
|
-
result = SearchRequest.new(@query, options.merge(:offset => pager.offset)).fetch_hits
|
34
|
-
pager.replace(result)
|
35
|
-
pager.total_entries = result.total_hits
|
36
|
-
end
|
37
|
-
else
|
38
|
-
flash.now[:errors] = I18n.t(:"rails_connector.controllers.search.specify_query")
|
39
|
-
end
|
40
|
-
rescue SES::SearchError => e
|
41
|
-
logger.error(e)
|
42
|
-
flash.now[:errors] = I18n.t(:"rails_connector.controllers.search.try_another_key")
|
43
|
-
rescue Errno::ECONNREFUSED, Errno::EAFNOSUPPORT
|
44
|
-
flash.now[:errors] = I18n.t(:"rails_connector.controllers.search.search_disabled")
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
# This is just a convenience wrapper so the +options+ hash can be
|
50
|
-
# accessed easily from an instance of this class.
|
51
|
-
def options
|
52
|
-
self.class.options
|
53
|
-
end
|
54
|
-
|
55
|
-
def current_page
|
56
|
-
[params[:page].to_i, 1].max
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
@@ -1,269 +0,0 @@
|
|
1
|
-
require 'recaptcha'
|
2
|
-
require 'active_resource/exceptions'
|
3
|
-
|
4
|
-
module RailsConnector
|
5
|
-
|
6
|
-
# This class provides a default controller implementation for user functionality.
|
7
|
-
# It should be customized by subclassing.
|
8
|
-
#
|
9
|
-
# To change how all actions contacting the WebCRM behave in case of an WebCRM error,
|
10
|
-
# override +on_crm_error+ in your subclassed controller. See Crm::Callbacks for details.
|
11
|
-
#
|
12
|
-
# To override what attributes are writable by the user when registering or editing profiles,
|
13
|
-
# use +editable_attributes_on_register+ and +editable_attributes_on_edit+, respectively.
|
14
|
-
# This can be done in your <tt>rails_connector.rb</tt> or in +UserController+ directly.
|
15
|
-
#
|
16
|
-
# By default, users can submit their first name, last name, email and company name.
|
17
|
-
class DefaultUserController < ApplicationController
|
18
|
-
|
19
|
-
before_filter :check_editable_attribute_configuration
|
20
|
-
before_filter :redirect_to_login_unless_logged_in, :only => [
|
21
|
-
:edit, :edit_password, :profile
|
22
|
-
]
|
23
|
-
before_filter :check_recaptcha_keypair
|
24
|
-
around_filter :handle_crm_errors
|
25
|
-
|
26
|
-
cattr_accessor :editable_attributes_on_register, :editable_attributes_on_edit
|
27
|
-
self.editable_attributes_on_register = {
|
28
|
-
:contact => [:gender, :first_name, :last_name, :email, :phone, :language],
|
29
|
-
}
|
30
|
-
self.editable_attributes_on_edit = {
|
31
|
-
:contact => [:first_name, :last_name, :email, :phone, :language],
|
32
|
-
}
|
33
|
-
|
34
|
-
include Crm::Localizable
|
35
|
-
include Crm::Sanitization
|
36
|
-
include Crm::Callbacks
|
37
|
-
include ReCaptcha::AppHelper
|
38
|
-
|
39
|
-
def self.store_user_attrs_in_session=(fields)
|
40
|
-
raise %Q{
|
41
|
-
DefaultUserController doesn't maintain which fields are stored in the session anymore.
|
42
|
-
Please use RailsConnector::Configuration.store_user_attrs_in_session instead.
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
# Displays a profile page containing links to all available actions
|
47
|
-
def profile
|
48
|
-
end
|
49
|
-
|
50
|
-
# Logs a CRM user in.
|
51
|
-
#
|
52
|
-
# After successful login, user attributes are stored in <tt>session[:user]</tt>.
|
53
|
-
#
|
54
|
-
# To change which fields are stored in the session use
|
55
|
-
# +RailsConnector::Configuration.store_user_attrs_in_session+.
|
56
|
-
#
|
57
|
-
# Use +current_user+ for a Contact object of the attributes stored in the session.
|
58
|
-
#
|
59
|
-
# The user will be redirected to the path given in the return_to param. If no
|
60
|
-
# return_to param is set, the user will be redirected to the profile page.
|
61
|
-
#
|
62
|
-
# If you merely want to change what happens before or after a user is authenticated,
|
63
|
-
# do not override this method but override +before_authenticate+ or +after_authenticate+.
|
64
|
-
def login
|
65
|
-
if request.post?
|
66
|
-
@user = Infopark::Crm::Contact.new(params[:user] || {:login => nil, :password => nil})
|
67
|
-
before_authenticate
|
68
|
-
@user = Infopark::Crm::Contact.authenticate(@user.login, @user.password)
|
69
|
-
if @user
|
70
|
-
after_authenticate
|
71
|
-
flash[:notice] = tcon('login_successful')
|
72
|
-
self.current_user = @user
|
73
|
-
redirect_to params[:return_to].blank? ?
|
74
|
-
user_path(:action => 'profile') :
|
75
|
-
params[:return_to]
|
76
|
-
else
|
77
|
-
flash.now[:error] = tcon('login_failed')
|
78
|
-
end
|
79
|
-
end
|
80
|
-
rescue Infopark::Crm::Errors::AuthenticationFailed, ActiveResource::ResourceInvalid
|
81
|
-
flash.now[:error] = tcon('login_failed')
|
82
|
-
ensure
|
83
|
-
@user.password = nil if @user
|
84
|
-
end
|
85
|
-
|
86
|
-
# Logs the user out by setting <tt>session[:user]</tt> to +nil+.
|
87
|
-
#
|
88
|
-
# To change the behavior before or after invalidating the session,
|
89
|
-
# override +before_logout+ or +after_logout+.
|
90
|
-
def logout
|
91
|
-
before_logout
|
92
|
-
self.current_user = nil
|
93
|
-
after_logout
|
94
|
-
redirect_to params[:return_to].blank? ? root_path : params[:return_to]
|
95
|
-
end
|
96
|
-
|
97
|
-
# Creates a WebCRM user.
|
98
|
-
#
|
99
|
-
# The user login is automatically set to his/her e-mail.
|
100
|
-
#
|
101
|
-
# If you merely want to change what happens before or after a user is registered,
|
102
|
-
# do not override this method but override +before_register+ or +after_register+.
|
103
|
-
def new
|
104
|
-
@user = Infopark::Crm::Contact.new
|
105
|
-
# Load some default attributes so that form_for is working
|
106
|
-
@user.load(Crm::CONTACT_DEFAULT_ATTRS.merge(sanitize_user_params(params[:user],
|
107
|
-
self.class.editable_attributes_on_register)))
|
108
|
-
if request.post?
|
109
|
-
if RailsConnector::Configuration.use_recaptcha_on_user_registration &&
|
110
|
-
!validate_recap(params, @user.errors)
|
111
|
-
raise ActiveResource::ResourceInvalid, "captcha failed"
|
112
|
-
end
|
113
|
-
before_register
|
114
|
-
register
|
115
|
-
after_register
|
116
|
-
redirect_to(:action => "register_pending")
|
117
|
-
end
|
118
|
-
rescue ActiveResource::ResourceInvalid
|
119
|
-
flash.now[:error] = tcon('registration_failed')
|
120
|
-
end
|
121
|
-
|
122
|
-
def register_pending
|
123
|
-
end
|
124
|
-
|
125
|
-
# Lets the user change his/her user details.
|
126
|
-
def edit
|
127
|
-
@user = Infopark::Crm::Contact.find(current_user.id)
|
128
|
-
if request.post? || request.put?
|
129
|
-
@user.load(sanitize_user_params(params[:user], self.class.editable_attributes_on_edit))
|
130
|
-
@user.save
|
131
|
-
flash[:notice] = tcon('edit_successful')
|
132
|
-
redirect_to(:action => 'profile')
|
133
|
-
end
|
134
|
-
rescue ActiveResource::ResourceInvalid
|
135
|
-
flash.now[:error] = tcon('edit_failed')
|
136
|
-
end
|
137
|
-
|
138
|
-
# Lets the user change his/her password.
|
139
|
-
#
|
140
|
-
# Validates the new password using +validate_edit_password_params_for+.
|
141
|
-
def edit_password
|
142
|
-
if request.post?
|
143
|
-
validate_edit_password_params_for(params[:user])
|
144
|
-
@user = Infopark::Crm::Contact.authenticate(current_user.login, params[:user][:old_password])
|
145
|
-
@user.password_set(params[:user][:new_password])
|
146
|
-
flash[:notice] = tcon('edit_password_successful')
|
147
|
-
redirect_to(:action => "profile")
|
148
|
-
end
|
149
|
-
rescue ActiveResource::ResourceInvalid, Infopark::Crm::Errors::AuthenticationFailed
|
150
|
-
flash.now[:error] = tcon('edit_password_failed')
|
151
|
-
end
|
152
|
-
|
153
|
-
# Lets the user request a new password (double opt-in).
|
154
|
-
#
|
155
|
-
# Uses the +ConfirmationMailer+ for sending out the confirmation message.
|
156
|
-
def forgot_password
|
157
|
-
if request.post?
|
158
|
-
user = Infopark::Crm::Contact.search(:params => {:login => params[:user][:login]}).first
|
159
|
-
if user
|
160
|
-
confirmation_link = set_password_url_for(user)
|
161
|
-
ConfirmationMailer.reset_password(user.email, confirmation_link).deliver
|
162
|
-
flash[:notice] = tcon('reset_password_successful')
|
163
|
-
redirect_to(:action => "forgot_password")
|
164
|
-
else
|
165
|
-
flash.now[:error] = tcon('request_password_failed')
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def set_password
|
171
|
-
if request.get? && params[:token].blank?
|
172
|
-
flash[:error] = tcon('token_url_invalid')
|
173
|
-
elsif request.post?
|
174
|
-
if params[:user][:new_password].blank?
|
175
|
-
flash.now[:error] = tcon('password_cannot_be_empty')
|
176
|
-
elsif params[:user][:new_password] != params[:user][:new_password_confirm]
|
177
|
-
flash.now[:error] = tcon('password_does_not_match_confirmation')
|
178
|
-
else
|
179
|
-
Infopark::Crm::Contact.password_set(params[:user][:new_password], params[:user][:token])
|
180
|
-
flash[:notice] = tcon('password_set')
|
181
|
-
redirect_to(:action => 'login')
|
182
|
-
end
|
183
|
-
end
|
184
|
-
rescue ActiveResource::ResourceNotFound => e
|
185
|
-
flash[:error] = tcon('set_password_failed')
|
186
|
-
end
|
187
|
-
|
188
|
-
protected
|
189
|
-
|
190
|
-
def check_editable_attribute_configuration
|
191
|
-
raise RuntimeError if editable_attributes_on_edit[:contact].nil? ||
|
192
|
-
editable_attributes_on_register[:contact].nil?
|
193
|
-
rescue
|
194
|
-
raise ConfigurationError, "editable_attributes in UserController is not configured correctly"
|
195
|
-
end
|
196
|
-
|
197
|
-
def register
|
198
|
-
if @user.email.blank?
|
199
|
-
@user.errors.add(:base, tcon('email_blank'))
|
200
|
-
raise ActiveResource::ResourceInvalid.new("E-mail can't be blank")
|
201
|
-
end
|
202
|
-
@user.login = @user.email
|
203
|
-
@user.save!
|
204
|
-
confirmation_link = set_password_url_for(@user)
|
205
|
-
ConfirmationMailer.register_confirmation(@user.email, confirmation_link).deliver
|
206
|
-
flash[:notice] = tcon('registration_successful_awaiting_confirmation')
|
207
|
-
end
|
208
|
-
|
209
|
-
def tcon(x)
|
210
|
-
t("rails_connector.controllers.user.#{x}")
|
211
|
-
end
|
212
|
-
|
213
|
-
ALL_CRM_ERRORS = [
|
214
|
-
Errno::ECONNREFUSED,
|
215
|
-
ActiveResource::ForbiddenAccess,
|
216
|
-
ActiveResource::UnauthorizedAccess,
|
217
|
-
ActiveResource::BadRequest
|
218
|
-
]
|
219
|
-
|
220
|
-
# invoke user defined callback when an error related to WebCRM occurs
|
221
|
-
def handle_crm_errors
|
222
|
-
yield
|
223
|
-
rescue *ALL_CRM_ERRORS => e
|
224
|
-
on_crm_error(e)
|
225
|
-
default_render unless performed?
|
226
|
-
end
|
227
|
-
|
228
|
-
# Filter to force users to login by redirecting.
|
229
|
-
def redirect_to_login_unless_logged_in
|
230
|
-
redirect_to login_path unless logged_in?
|
231
|
-
end
|
232
|
-
|
233
|
-
# Checks if constants RCC_PUB and RCC_PRIV are set (for reCaptcha)
|
234
|
-
#
|
235
|
-
# Used as a filter in this controller.
|
236
|
-
def check_recaptcha_keypair
|
237
|
-
return true unless RailsConnector::Configuration.use_recaptcha_on_user_registration
|
238
|
-
unless Object.const_defined?(:RCC_PUB) && Object.const_defined?(:RCC_PRIV)
|
239
|
-
raise RuntimeError, <<-EOS
|
240
|
-
|
241
|
-
reCaptcha requires the constants RCC_PUB and RCC_PRIV to be set.
|
242
|
-
Please sign up for the reCaptcha webservice if you haven't already done so.
|
243
|
-
|
244
|
-
Then set your public key in RCC_PUB and your private key in RCC_PRIV.
|
245
|
-
EOS
|
246
|
-
end
|
247
|
-
true
|
248
|
-
end
|
249
|
-
|
250
|
-
# Validates the password for a given user.
|
251
|
-
#
|
252
|
-
# Used by #edit_password.
|
253
|
-
def validate_edit_password_params_for(params)
|
254
|
-
if params[:new_password].empty? || params[:new_password] != params[:new_password_confirm]
|
255
|
-
raise ActiveResource::ResourceInvalid.new(
|
256
|
-
"password is empty or does not match confirmation"
|
257
|
-
)
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
# Generates a URL for password confirmation.
|
262
|
-
def set_password_url_for(user)
|
263
|
-
url_for(
|
264
|
-
:action => "set_password",
|
265
|
-
:token => user.password_request(:params => {:only_get_token => true})
|
266
|
-
)
|
267
|
-
end
|
268
|
-
end
|
269
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module RailsConnector
|
2
|
-
|
3
|
-
class TimeMachineController < ApplicationController
|
4
|
-
|
5
|
-
protect_from_forgery :except => :set_preview_time
|
6
|
-
|
7
|
-
before_filter :only_available_in_editor_mode
|
8
|
-
|
9
|
-
def index
|
10
|
-
@language = params[:language] || 'de'
|
11
|
-
@preview_time = session[:preview_time] || Time.now
|
12
|
-
end
|
13
|
-
|
14
|
-
# Set the preview time to the Time as specified by the parameter <tt>:preview_time</tt>.
|
15
|
-
def set_preview_time
|
16
|
-
if preview_time = params[:preview_time]
|
17
|
-
pt = Time.from_iso(preview_time)
|
18
|
-
pt = nil if pt <= Time.now
|
19
|
-
handle_request pt
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
# Resets the preview time, so <tt>Time::now</tt> will be used as preview time afterwards.
|
24
|
-
def reset_preview_time
|
25
|
-
handle_request nil
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def handle_request(preview_time)
|
31
|
-
session[:preview_time] = preview_time
|
32
|
-
if request.xhr?
|
33
|
-
render :js => "window.location.reload();"
|
34
|
-
else
|
35
|
-
render :nothing => true
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def only_available_in_editor_mode
|
40
|
-
unless Configuration.editor_interface_enabled?
|
41
|
-
render :template => 'errors/403_forbidden', :status => 403, :content_type => Mime::HTML
|
42
|
-
return false
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|