Class: UserController
Constant Summary
KitController::Pagebase
Instance Attribute Summary
#is_image_request, #kit_request, #layout_name_being_used, #requested_url, #template_being_used
Instance Method Summary
collapse
#anti_spam_okay?, #app_name, #can_moderate, #can_use, #captcha_okay?, #check_and_record_goal, #csv_headers, #dif, #edit_page_path, #feature?, #get_asset, #get_view_content, #host_name, #info_page_path, #kit_layout_in_use, #kit_render, #kit_session, #kit_session_end, #link_to, #mailchimp_connect, #mobile_template, #no_read, #no_write, #not_found, #not_found_404, #offline, #page_path, #render, #render_error, #render_page, #render_page_by_url, #routing_error, #sanity_check_okay?, #session_id, #set_requested_url, #show_form, #stylesheets, #super_render, #user_sees_menu?
Instance Method Details
#attribute ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'app/controllers/user_controller.rb', line 36
def attribute
@user = current_user
uav = UserAttributeValue.find_or_initialize_by_user_id_and_user_attribute_id(@user.id, params[:id])
uav.value = params[:user_attribute_value][:value]
uav.updated_by = current_user
uav.system_id = _sid
uav.save
@user.update_index
Activity.add(_sid, "Set attribute '#{uav.user_attribute.name}' to '#{uav.value}' by '#{@user.email}'", current_user, "Users")
respond_with_bip(uav)
end
|
#check_display_name ⇒ Object
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'app/controllers/user_controller.rb', line 114
def check_display_name
name = params[:name]
if (name.length<2)
render :text=>"Too short"
else
if User.sys(_sid).where(:display_name=>name).count > 0
render :text=>"Name in use"
else
render :text=> ""
end
end
end
|
#display_name ⇒ Object
105
106
107
108
109
110
111
112
|
# File 'app/controllers/user_controller.rb', line 105
def display_name
current_user.display_name = params[:user][:display_name]
if current_user.display_name.is_blank?
current_user.display_name = nil
end
current_user.save!
redirect_to request.referer
end
|
#edit_profile ⇒ Object
28
29
30
31
32
33
34
|
# File 'app/controllers/user_controller.rb', line 28
def edit_profile
form = Preference.get_cached(_sid, 'user_profile_edit_form')
if form.not_blank?
render :inline=>form, :layout=>Preference.get_cached!(0,"user_profile_layout", "application") return
end
end
|
#preferences ⇒ Object
8
9
10
11
12
13
|
# File 'app/controllers/user_controller.rb', line 8
def preferences
@page_title = 'Preferences'
@user = current_user
end
|
#profile ⇒ Object
15
16
17
18
19
|
# File 'app/controllers/user_controller.rb', line 15
def profile
@page_title = "Your Profile"
@user = current_user
show_profile(true)
end
|
#remove_profile_attribute ⇒ Object
50
51
52
53
54
|
# File 'app/controllers/user_controller.rb', line 50
def remove_profile_attribute
UserAttributeValue.delete_all(["user_id = #{current_user.id} and user_attribute_id = ?", params[:id]])
redirect_to "/user/profile"
end
|
#update ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'app/controllers/user_controller.rb', line 56
def update
@user = current_user
@errors = {}
at_least_one = false
all_okay = true
UserAttribute.sys(_sid).where("owner_visible = 1").each do |ua|
if val = params[ua.code_name.to_sym]
if (ua.form_field_type.has_asset? && val) || (!ua.form_field_type.has_asset?)
uav = UserAttributeValue.where(:user_id=>@user.id).where(:user_attribute_id=>ua.id).first
unless uav
uav = UserAttributeValue.create(:user_id=>@user.id, :user_attribute_id=>ua.id)
end
if ua.form_field_type.has_asset?
uav.asset = val
uav.value = ''
else
uav.value = val
end
uav.updated_by = current_user.id
if uav.save
at_least_one = true
else
all_okay = false
end
Activity.add(_sid, "Set attribute '#{uav.user_attribute.name}' to '#{uav.value}' by '#{@user.email}'", current_user, "Users")
else
if ua.is_mandatory?
@errors[ua.id] = {:message=>"You must enter a value for '#{ua.name}'", :field=>"field_#{ua.id}"}
all_okay = false
end
end
end
end
if at_least_one
@user.update_index
end
if all_okay
flash[:info] = "Profile updated"
redirect_to "/user/profile"
else
flash[:info] = "There were errors"
render "user/edit_profile"
end
end
|
#user_profile ⇒ Object
21
22
23
24
25
|
# File 'app/controllers/user_controller.rb', line 21
def user_profile
@user = User.find_sys_id(_sid,params[:id])
@page_title = "Profile for '#{@user.display_name || 'Anonymous User'}'"
show_profile(false)
end
|