Skip to content

Commit

Permalink
Merge branch 'user-segment' of git@charlie-dev.cykod.com:webiva-core …
Browse files Browse the repository at this point in the history
…into user-segment
  • Loading branch information
Doug Youch committed Jun 25, 2010
2 parents 1bd5e07 + 5b10158 commit 97b6275
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 17 deletions.
36 changes: 29 additions & 7 deletions app/controllers/members_controller.rb
Expand Up @@ -481,15 +481,26 @@ def create
end

def edit
cms_page_path ['People'],'Edit Contact'
@segment = UserSegment.find_by_id(params[:path][1]) unless params[:path][1].blank?

display_user_actions_table(false)

if @segment
cms_page_path [ 'People',
["%s",url_for(:action => 'index',:path => [ @segment.id ]),@segment.name]
],['Edit %s',nil,@user.name.to_s.strip.blank? ? @user.email : @user.name ]
else
cms_page_path ['People'],'Edit Contact'
end


user_id = params[:path][0]

@user = EndUser.find(user_id)


if @user.client_user_id || (@user.user_class.editor? && !myself.has_role?('editor_editors'))
redirect_to :action => 'index'
redirect_to :action => 'index', :path => @segment ? [ @segment.id ] : nil
return
end

Expand All @@ -500,7 +511,8 @@ def edit

# Don't let user class be upgrade to editor if the user can edit those
if @user.user_class.editor? && !myself.has_role?('editor_editors')
redirect_to :action => 'index'
redirect_to :action => 'index', :path => @segment ? [ @segment.id ] : nil

return
end

Expand Down Expand Up @@ -531,11 +543,13 @@ def edit
@user.action('/members/edit',:admin_user_id => myself.id, :level => 0)
update_subscriptions(@user,params[:subscription])
flash[:notice] = 'Saved User: "%s" ' / (@user.email.blank? ? @user.name : @user.email)
redirect_to :action =>'index'
redirect_to :action =>'index', :path => @segment ? [ @segment.id ] : nil

return
end
else
redirect_to :action =>'index'
redirect_to :action =>'index', :path => @segment ? [ @segment.id ] : nil

return
end
end
Expand Down Expand Up @@ -578,9 +592,17 @@ def display_user_actions_table(display=true)
def view
@user = EndUser.find(params[:path][0])

@segment = UserSegment.find_by_id(params[:path][1]) unless params[:path][1].blank?

display_user_actions_table(false)

cms_page_path [ 'People'],['%s',nil,@user.name.to_s.strip.blank? ? @user.email : @user.name ]

if @segment
cms_page_path [ 'People',
["%s",url_for(:action => 'index',:path => [ @segment.id ]),@segment.name]
],['%s',nil,@user.name.to_s.strip.blank? ? @user.email : @user.name ]
else
cms_page_path [ 'People'],['%s',nil,@user.name.to_s.strip.blank? ? @user.email : @user.name ]
end

handlers = get_handler_info(:members,:view)

Expand Down
15 changes: 6 additions & 9 deletions app/views/members/_targets_table.rhtml
Expand Up @@ -12,28 +12,25 @@
],
:more_actions => [['Delete Targets','delete','Delete the selected users?']],
:update => 'targets_table' do |t| %>
<% user_url = url_for(:action => 'view', :path => [ t.id, @segment ? @segment.id : nil].compact) %>
<tr <%= highlight_row "user",t.id %> >
<td nowrap='1'>
<%= entry_checkbox 'user',t.id %>
</td>
<td align='center' nowrap='1'>
<%= t.editor? ? '' : content_tag(:a, theme_image_tag('icons/actions/edit.gif'), {:href => url_for(:action => 'edit', :path => t.id)}) %>
<%= t.editor? ? '' : link_to(theme_image_tag('icons/actions/edit.gif'), :action => 'edit', :path => [ t.id, @segment ? @segment.id : nil ].compact) %>
</td>
<td align='center'>
<%= image = t.image ? t.image.image_tag(:thumb) : nil
if image
t.editor? ? image : content_tag(:a, image, {:href => url_for(:action => 'view', :path => t.id)})
else
'-'
end
<%= image = t.image ? t.image.image_tag(:icon) : ''
t.editor? ? image : link_to(image,user_url)
%>
</td>
<td>
<%= t.editor? ? h(t.name) : content_tag(:a, t.name, {:href => url_for(:action => 'view', :path => t.id)}) %>
<%= t.editor? ? h(t.name) : link_to(t.name, user_url) %>
</td>
<td>
<%= email = t.email.blank? ? 'No Email'.t : t.email
t.editor? ? h(email) : content_tag(:a, email, {:href => url_for(:action => 'view', :path => t.id)})
t.editor? ? h(email) : link_to(email, user_url)
%>
</td>

Expand Down
2 changes: 1 addition & 1 deletion app/views/members/view.rhtml
Expand Up @@ -17,7 +17,7 @@ MemberViewer = {

<% unless @user.client_user_id || (@user.user_class.editor? && !myself.has_role?('editor_editors')) %>
<% action_panel do |p| -%>
<%= p.link 'Edit User',:icon => 'edit.gif',:action => 'edit', :path => @user %>
<%= p.link 'Edit User',:icon => 'edit.gif',:action => 'edit', :path => [ @user, @segment ? @segment.id : nil ].compact %>
<%= p.link 'Login as User', { :icon => 'download.gif',:action => 'login', :path => @user }, :method => 'post' %>
<% end -%>
<hr/>
Expand Down

0 comments on commit 97b6275

Please sign in to comment.