| # View helper methods available to all users templates in the application. |
| #--###################################################################### |
| # Copyright (c) 2006 LogicaCMG |
| # |
| # All rights reserved. This program and the accompanying materials |
| # are made available under the terms of the Eclipse Public License v1.0 |
| # which accompanies this distribution, and is available at |
| # http://www.eclipse.org/legal/epl-v10.html |
| # |
| # Contributors: |
| # |
| # Onno van der Straaten:: initial implementation |
| #++###################################################################### |
| # {Copyright (c) 2006 LogicaCMG}[link:files/COPYRIGHT.html] |
| |
| module UsersHelper |
| |
| def link_to_user_actions(theUser) |
| returning link = [] do |
| if cadmin? |
| if !mine?(theUser) |
| link << link_to(image_tag("sendpassword", :border => 0, :align=>"middle", :title=>'(re)Send password to user'), {:controller => 'users', :action => 'resend', :id => theUser.id}, :confirm => 'Are you sure! This will reset the current password of ' + theUser.name + "!", :post => true) |
| link << link_to(image_tag("up", :border => 0, :align=>"middle", :title=>'Make this user the central administrator'), {:controller => 'users', :action => 'cadmin', :id => theUser.id}, :confirm => 'Are you sure? There can only be one!' ) if theUser.admin? |
| link << link_to(image_tag("down", :border => 0, :align=>"middle", :title=>'Revoke administrator privileges'), :controller => 'users', :action => 'admin', :id => theUser.id, :admin => 'N' ) if theUser.admin? |
| link << link_to(image_tag("up" , :border => 0, :align=>"middle", :title=>'Grant administrator privileges'), :controller => 'users', :action => 'admin', :id => theUser.id, :admin => 'Y' ) if !theUser.admin? |
| link << link_to(image_tag("delete", :border => 0, :align=>"middle", :title=>'Delete this User'), {:controller => 'users', :action => 'destroy', :id => theUser.id}, :confirm => 'Not properly implemented yet! Leads to corruption if user has versions, comments. This user has ' + theUser.versions_count.to_s + " versions and " + theUser.comments_count.to_s + " comments!") |
| end |
| elsif admin? |
| if !mine?(theUser) |
| link << link_to(image_tag("up" , :border => 0, :align=>"middle", :title=>'Grant administrator privileges'), :controller => 'users', :action => 'make_admin', :id => theUser.id, :admin => 'Y' ) if !theUser.admin? |
| end |
| end |
| end.join("\n") |
| end |
| |
| end |