features_controller.rb
2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
class FeaturesController < AdminController
protect 'edit_environment_features', :environment
def index
@features = Environment.available_features.sort_by{|k,v|v}
end
def manage_blocks
@blocks = [ ArticleBlock,
TagsBlock,
RecentDocumentsBlock,
ProfileInfoBlock,
LinkListBlock,
MyNetworkBlock,
FeedReaderBlock,
ProfileImageBlock,
LocationBlock,
SlideshowBlock,
ProfileSearchBlock,
HighlightsBlock,
FriendsBlock,
FavoriteEnterprisesBlock,
CommunitiesBlock,
EnterprisesBlock,
MembersBlock,
DisabledEnterpriseMessageBlock,
ProductCategoriesBlock,
FeaturedProductsBlock,
FansBlock,
ProductsBlock ]
@blocks += plugins.dispatch(:extra_blocks)
@blocks.sort_by! { |block| block.name }
end
post_only :update
def update
if @environment.update_attributes(params[:environment])
session[:notice] = _('Features updated successfully.')
redirect_to :action => 'index'
else
render :action => 'index'
end
end
post_only :update_blocks
def update_blocks
params[:environment].delete(:available_blocks)
if @environment.update_attributes(params[:environment])
session[:notice] = _('Blocks updated successfully.')
redirect_to :action => 'manage_blocks'
else
render :action => 'manage_blocks'
end
end
def manage_fields
@person_fields = Person.fields
@enterprise_fields = Enterprise.fields
@community_fields = Community.fields
end
def manage_person_fields
environment.custom_person_fields = params[:person_fields]
if environment.save!
session[:notice] = _('Person fields updated successfully.')
else
flash[:error] = _('Person fields not updated successfully.')
end
redirect_to :action => 'manage_fields'
end
def manage_enterprise_fields
environment.custom_enterprise_fields = params[:enterprise_fields]
if environment.save!
session[:notice] = _('Enterprise fields updated successfully.')
else
flash[:error] = _('Enterprise fields not updated successfully.')
end
redirect_to :action => 'manage_fields'
end
def manage_community_fields
environment.custom_community_fields = params[:community_fields]
if environment.save!
session[:notice] = _('Community fields updated successfully.')
else
flash[:error] = _('Community fields not updated successfully.')
end
redirect_to :action => 'manage_fields'
end
def search_members
arg = params[:q].downcase
result = environment.people.find(:all, :conditions => ['LOWER(name) LIKE ?', "%#{arg}%"])
render :text => prepare_to_token_input(result).to_json
end
end