profile_design_controller.rb
1.74 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
class ProfileDesignController < BoxOrganizerController
needs_profile
protect 'edit_profile_design', :profile
before_filter :protect_fixed_block, :only => [:save, :move_block]
def protect_fixed_block
block = boxes_holder.blocks.find(params[:id].gsub(/^block-/, ''))
if block.fixed && !current_person.is_admin?
render_access_denied
end
end
def available_blocks
blocks = [ ArticleBlock, TagsBlock, RecentDocumentsBlock, ProfileInfoBlock, LinkListBlock, MyNetworkBlock, FeedReaderBlock, ProfileImageBlock, LocationBlock, SlideshowBlock, ProfileSearchBlock, HighlightsBlock ]
blocks += plugins.dispatch(:extra_blocks)
# blocks exclusive to people
if profile.person?
blocks << FavoriteEnterprisesBlock
blocks << CommunitiesBlock
blocks << EnterprisesBlock
blocks += plugins.dispatch(:extra_blocks, :type => Person)
end
# blocks exclusive to communities
if profile.community?
blocks += plugins.dispatch(:extra_blocks, :type => Community)
end
# blocks exclusive for enterprises
if profile.enterprise?
blocks << DisabledEnterpriseMessageBlock
blocks << HighlightsBlock
blocks << ProductCategoriesBlock
blocks << FeaturedProductsBlock
blocks << FansBlock
blocks += plugins.dispatch(:extra_blocks, :type => Enterprise)
end
# product block exclusive for enterprises in environments that permits it
if profile.enterprise? && profile.environment.enabled?('products_for_enterprises')
blocks << ProductsBlock
end
# block exclusive to profiles that have blog
if profile.has_blog?
blocks << BlogArchivesBlock
end
if user.is_admin?(profile.environment)
blocks << RawHTMLBlock
end
blocks
end
end