ae_users_legacy 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/LICENSE +20 -0
  2. data/README +47 -0
  3. data/Rakefile +49 -0
  4. data/VERSION +1 -0
  5. data/ae_users_legacy.gemspec +126 -0
  6. data/app/controllers/account_controller.rb +167 -0
  7. data/app/controllers/auth_controller.rb +202 -0
  8. data/app/controllers/permission_controller.rb +172 -0
  9. data/app/helpers/account_helper.rb +2 -0
  10. data/app/helpers/auth_helper.rb +5 -0
  11. data/app/helpers/permission_helper.rb +2 -0
  12. data/app/models/account.rb +50 -0
  13. data/app/models/auth_notifier.rb +34 -0
  14. data/app/models/auth_ticket.rb +39 -0
  15. data/app/models/email_address.rb +17 -0
  16. data/app/models/login.rb +23 -0
  17. data/app/models/open_id_identity.rb +5 -0
  18. data/app/models/permission.rb +57 -0
  19. data/app/models/person.rb +156 -0
  20. data/app/models/role.rb +7 -0
  21. data/app/views/account/_personal_info.rhtml +35 -0
  22. data/app/views/account/_procon_profile.rhtml +3 -0
  23. data/app/views/account/_signup_form.html.erb +39 -0
  24. data/app/views/account/activate.rhtml +6 -0
  25. data/app/views/account/activation_error.rhtml +11 -0
  26. data/app/views/account/change_password.rhtml +3 -0
  27. data/app/views/account/edit_profile.rhtml +117 -0
  28. data/app/views/account/signup.rhtml +9 -0
  29. data/app/views/account/signup_noactivation.rhtml +7 -0
  30. data/app/views/account/signup_success.rhtml +8 -0
  31. data/app/views/auth/_auth_form.rhtml +54 -0
  32. data/app/views/auth/_forgot_form.html.erb +12 -0
  33. data/app/views/auth/_mini_auth_form.rhtml +17 -0
  34. data/app/views/auth/_openid_auth_form.html.erb +14 -0
  35. data/app/views/auth/_other_login_options.html.erb +24 -0
  36. data/app/views/auth/auth_form.js.erb +62 -0
  37. data/app/views/auth/forgot.rhtml +3 -0
  38. data/app/views/auth/forgot_form.rhtml +6 -0
  39. data/app/views/auth/index.css.erb +23 -0
  40. data/app/views/auth/login.rhtml +6 -0
  41. data/app/views/auth/needs_activation.rhtml +6 -0
  42. data/app/views/auth/needs_person.html.erb +32 -0
  43. data/app/views/auth/needs_profile.rhtml +14 -0
  44. data/app/views/auth/openid_login.html.erb +6 -0
  45. data/app/views/auth/resend_activation.rhtml +3 -0
  46. data/app/views/auth_notifier/account_activation.rhtml +13 -0
  47. data/app/views/auth_notifier/generated_password.rhtml +10 -0
  48. data/app/views/permission/_add_grantee.rhtml +47 -0
  49. data/app/views/permission/_role_member.rhtml +8 -0
  50. data/app/views/permission/_show.rhtml +81 -0
  51. data/app/views/permission/_userpicker.rhtml +0 -0
  52. data/app/views/permission/add_role_member.rhtml +3 -0
  53. data/app/views/permission/admin.rhtml +45 -0
  54. data/app/views/permission/edit.rhtml +9 -0
  55. data/app/views/permission/edit_role.rhtml +63 -0
  56. data/app/views/permission/grant.rhtml +10 -0
  57. data/db/migrate/002_create_accounts.rb +17 -0
  58. data/db/migrate/003_create_email_addresses.rb +17 -0
  59. data/db/migrate/004_create_people.rb +24 -0
  60. data/db/migrate/013_simplify_signup.rb +15 -0
  61. data/db/migrate/014_create_permissions.rb +16 -0
  62. data/db/migrate/015_create_roles.rb +18 -0
  63. data/db/migrate/016_refactor_people.rb +36 -0
  64. data/db/migrate/017_people_permissions.rb +9 -0
  65. data/generators/ae_users/USAGE +14 -0
  66. data/generators/ae_users/ae_users_generator.rb +12 -0
  67. data/generators/ae_users/templates/add.png +0 -0
  68. data/generators/ae_users/templates/admin.png +0 -0
  69. data/generators/ae_users/templates/group.png +0 -0
  70. data/generators/ae_users/templates/logout.png +0 -0
  71. data/generators/ae_users/templates/migration.rb +25 -0
  72. data/generators/ae_users/templates/openid.gif +0 -0
  73. data/generators/ae_users/templates/remove.png +0 -0
  74. data/generators/ae_users/templates/user.png +0 -0
  75. data/init.rb +1 -0
  76. data/install.rb +1 -0
  77. data/lib/ae_users.rb +687 -0
  78. data/rails/init.rb +17 -0
  79. data/tasks/ae_users_tasks.rake +4 -0
  80. data/test/ae_users_test.rb +8 -0
  81. data/uninstall.rb +1 -0
  82. metadata +177 -0
@@ -0,0 +1,117 @@
1
+ <h1>Edit your profile</h1>
2
+
3
+ <style type="text/css">
4
+ form {
5
+ max-width: 640px;
6
+ }
7
+ </style>
8
+
9
+ <% if @person.account -%>
10
+ <% form_for("password", nil, :url => {:action => 'change_password'},
11
+ :html => {:id => 'change_password_form'}) do |f| %>
12
+ <h2>Change password</h2>
13
+ <table>
14
+ <tr>
15
+ <th style="text-align: right;">
16
+ <label for="password_password1">New password</label>
17
+ </th>
18
+ <td>
19
+ <%= f.password_field "password1", :label => "New password" %>
20
+ </td>
21
+ </tr>
22
+ <tr>
23
+ <th style="text-align: right;">
24
+ <label for="password_password2">Confirm new password</label>
25
+ </th>
26
+ <td>
27
+ <%= f.password_field "password2", :label => "New password" %>
28
+ </td>
29
+ </tr>
30
+ </table>
31
+ <p>
32
+ <%= submit_tag "Change password" %>
33
+ </p>
34
+ <% end %>
35
+ <% end -%>
36
+
37
+ <h2>OpenID Identities</h2>
38
+
39
+ <p>OpenID is a free and easy way to use a single digital identity across the Internet. For more information,
40
+ <%= link_to "visit the OpenID web site", "http://www.openid.net" %>.</p>
41
+
42
+ <table>
43
+ <% @person.open_id_identities.each do |id| -%>
44
+ <tr>
45
+ <td></td>
46
+ <td>
47
+ <%= image_tag "ae_users/openid.gif" %>
48
+ <i><%=h id.identity_url %></i>
49
+ </td>
50
+ <td><%= button_to "Delete", {:action => "delete_openid", :id => id.id}, {:confirm => "Are you sure you wish to remove this OpenID?"} %></td>
51
+ </tr>
52
+ <% end -%>
53
+ <tr>
54
+ <% form_for("add_openid", nil, :url => {:action => "add_openid"}) do |f| -%>
55
+ <td>Add new OpenID:</td>
56
+ <td><%= text_field_tag "openid_url", @openid_url, :style => "background: #FFFFFF url('#{image_path "ae_users/openid.gif"}') no-repeat scroll 0pt 50%; padding-left: 18px; width: 60%;" %></td>
57
+ <td><%= submit_tag "Add" %></td>
58
+ <% end -%>
59
+ </tr>
60
+ </table>
61
+
62
+ <% form_for("email_addresses", nil, :url => {:action => 'edit_email_addresses'},
63
+ :html => {:id => 'edit_email_addresses_form'}) do |f| %>
64
+
65
+ <h2>Edit email addresses</h2>
66
+
67
+ <p>Note: every account must have one "primary" email address. This is the one the site will use
68
+ to send you email (for example, if you forget your password).</p>
69
+
70
+ <table>
71
+ <tr>
72
+ <th></th>
73
+ <th>Address</th>
74
+ <th>Primary</th>
75
+ <th>Delete</th>
76
+ </tr>
77
+ <% @person.email_addresses.each do |addr| -%>
78
+ <tr>
79
+ <td></td>
80
+ <td>
81
+ <i><%= addr.address %></i>
82
+ </td>
83
+ <td>
84
+ <%= radio_button_tag "primary", addr.id, addr.primary %>
85
+ </td>
86
+ <td>
87
+ <%= check_box_tag "delete", addr.id %>
88
+ </td>
89
+ </tr>
90
+ <% end -%>
91
+ <tr>
92
+ <td>Add new address:</td>
93
+ <td>
94
+ <%= text_field_tag "new_address", "", :style => "width: 100%" %>
95
+ </td>
96
+ <td>
97
+ <%= radio_button_tag "primary", "new" %>
98
+ </td>
99
+ </tr>
100
+ </table>
101
+ <%= submit_tag "Edit email addresses" %>
102
+ <% end %>
103
+
104
+ <% form_for("person", @person, :url => {:action => 'edit_profile'},
105
+ :html => {:id => 'edit_profile_form'}) do |f| %>
106
+ <%= render :partial => 'personal_info', :locals => {:f => f} %>
107
+ <% if @app_profile -%>
108
+
109
+ <% form_for("app_profile", @app_profile) do |profile_form| %>
110
+ <%= render :partial => "account/#{@app_profile.class.name.tableize.singularize}",
111
+ :locals => {:f => profile_form}%>
112
+ <%= submit_tag "Edit profile" %>
113
+ <% end %>
114
+ <% else -%>
115
+ <%= submit_tag "Edit profile" %>
116
+ <% end -%>
117
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <% form_for("person", @person, :url => {:action => 'signup'},
2
+ :html => {:id => 'signup_form'}) do |f| -%>
3
+
4
+ <h1>Sign up</h1>
5
+ <p>Thanks for creating an account! We just need a few pieces of information from you before we can complete your
6
+ signup process.</p>
7
+
8
+ <%= render :partial => 'signup_form', :locals => { :f => f } %>
9
+ <% end -%>
@@ -0,0 +1,7 @@
1
+ <h1>Signup Complete</h1>
2
+
3
+ <p>Thanks for signing up! Your account has been created, <b>but there was an error attempting to send you an
4
+ activation email</b>. (This is not your problem, it's ours.)</p>
5
+
6
+ <p>Your account has therefore been activated immediately. You can use the form in the upper right-hand corner
7
+ of the page to log in.</p>
@@ -0,0 +1,8 @@
1
+ <h1>Signup Complete</h1>
2
+
3
+ <p>Thanks for signing up! Your account has been created, <b>but we still need you to activate it</b> in order to
4
+ verify that the email address you entered really belongs to you. We've sent an activation email to the address
5
+ you entered, and when you receive it, please follow the link in that message to activate
6
+ your account.</p>
7
+
8
+ <p>If you don't get the activation email, please contact the site administrators to let them know.</p>
@@ -0,0 +1,54 @@
1
+ <%= auth_stylesheet %>
2
+
3
+ <% form_for('login', @login, :url => {:action => 'login', :controller => 'auth'},
4
+ :html => {:class => 'auth_form'} ) do |f| -%>
5
+ <% if not logged_in? %>
6
+ <script type="text/javascript" src="<%=url_for :controller => 'auth', :action => "auth_form",
7
+ :format => "js", :openid_url => params[:openid_url] %>"></script>
8
+
9
+ <%= f.hidden_field "return_to" %>
10
+
11
+ <p>
12
+ <label for="login_email" class="block">Email address</label>
13
+ <%= text_field "login", "email", :tabindex => 1%>
14
+ </p>
15
+
16
+ <% if AeUsers.signup_allowed? -%>
17
+ <p>
18
+ <label class="block">Do you have a password?</label>
19
+ <%= f.radio_button "have_password", "false" %> <label for="login_have_password_false">No, I am a new user.</label>
20
+ <br/>
21
+ <%= f.radio_button "have_password", "true" %> <label for="login_have_password_true">Yes, my password is:</label>
22
+ <div style="margin-left: 2em; margin-top: 0; padding-top: 0;">
23
+ <%= password_field "login", "password" %>
24
+ </div>
25
+ </p>
26
+ <% else -%>
27
+ <p>
28
+ <label for="password" class="block">Password</label>
29
+ <%= password_field "login", "password", :tabindex => 2 %>
30
+ </p>
31
+ <% end -%>
32
+
33
+ <p style="text-align: center;">
34
+ <%= submit_tag "Log in", :style => "width: 20%; display: inline" %>
35
+ </p>
36
+
37
+ <% else %>
38
+ <div style="text-align: right; margin-right: 1em;">
39
+ <p>You are currently logged in as <%= logged_in_person.name %>.</p>
40
+ <p>
41
+ <% if logged_in_person.administrator? -%>
42
+ <%= image_tag "ae_users/admin.png" %>
43
+ <%= link_to "Administration", :controller => 'permission', :action => 'admin' %>
44
+ <span style="margin-right: 1em;">&nbsp;</span>
45
+ <% end -%>
46
+ <%= image_tag "ae_users/user.png" %>
47
+ <%= link_to "Edit profile", :controller => 'account', :action => 'edit_profile' %>
48
+ <span style="margin-right: 1em;">&nbsp;</span>
49
+ <%= image_tag "ae_users/logout.png" %>
50
+ <%= link_to "Log out", :controller => :auth, :action => :logout %>
51
+ </p>
52
+ </div>
53
+ <% end %>
54
+ <% end -%>
@@ -0,0 +1,12 @@
1
+ <%= auth_stylesheet %>
2
+
3
+ <% form_for "forgot", @forgot, :url => {:action => 'forgot', :controller => 'auth'},
4
+ :html => {:id => 'forgot_form', :style => 'max-width: 400px;', :class => 'auth_form'} do |f| %>
5
+
6
+ <label for="email" class="block">Email address:</label>
7
+ <%= text_field_tag "email" %>
8
+
9
+ <p style="text-align: center;">
10
+ <%= submit_tag "Email me a new password", :style => "width: 90%; display: inline" %>
11
+ </p>
12
+ <% end %>
@@ -0,0 +1,17 @@
1
+ <div class="authbox">
2
+ <% if logged_in? -%>
3
+ <%= image_tag('ae_users/user.png') %>
4
+ <%= link_to logged_in_person.name,
5
+ :controller => 'account', :action => 'edit_profile' %>
6
+ <% if logged_in_person.administrator? -%>
7
+ |
8
+ <%= image_tag "ae_users/admin.png" %>
9
+ <%= link_to "Administration", :controller => 'permission', :action => 'admin' %>
10
+ <% end -%>
11
+ |
12
+ <%= image_tag "ae_users/logout.png" %>
13
+ <%= link_to "Log out", :controller => 'auth', :action => 'logout' %>
14
+ <% else -%>
15
+ <%= link_to "Log in", :controller => 'auth', :action => 'login', :return_to => url_for() %>
16
+ <% end -%>
17
+ </div>
@@ -0,0 +1,14 @@
1
+ <%= auth_stylesheet %>
2
+
3
+ <% form_for('login', @login, :url => {:action => 'openid_login', :controller => 'auth'},
4
+ :html => {:class => 'auth_form'} ) do |f| -%>
5
+
6
+ <%= f.hidden_field "return_to" %>
7
+
8
+ <label for="openid_url" class="block">OpenID</label>
9
+ <%= text_field_tag "openid_url" %>
10
+
11
+ <p style="text-align: center;">
12
+ <%= submit_tag "Log in with OpenID", :style => "width: 50%; display: inline" %>
13
+ </p>
14
+ <% end -%>
@@ -0,0 +1,24 @@
1
+ <% unless logged_in? -%>
2
+ <ul id="other_login_options">
3
+ <% if params[:action] == "login" -%>
4
+ <li>
5
+ <%= link_to "I forgot my password", :controller => "auth", :action => "forgot_form" %>
6
+ </li>
7
+ <% end -%>
8
+ <% if params[:action] == "openid_login" -%>
9
+ <li>
10
+ <%= link_to "What's OpenID?", "http://www.openid.net", :target => "_blank" %>
11
+ </li>
12
+ <% end -%>
13
+ <% unless params[:action] == "openid_login" -%>
14
+ <li>
15
+ <%= link_to "Log in with OpenID", :controller => "auth", :action => "openid_login", :return_to => @login.return_to %>
16
+ </li>
17
+ <% end -%>
18
+ <% unless params[:action] == "login" -%>
19
+ <li>
20
+ <%= link_to "Log in with a password", :controller => "auth", :action => "login", :return_to => @login.return_to %>
21
+ </li>
22
+ <% end -%>
23
+ </ul>
24
+ <% end -%>
@@ -0,0 +1,62 @@
1
+ <% if AeUsers.js_framework == "jquery" -%>
2
+ function chooseHavePassword() {
3
+ val = jQuery('.auth_form input[name="login[have_password]"]:checked').val();
4
+ var $password = jQuery('.auth_form input[name="login[password]"]');
5
+ $password.val("");
6
+
7
+ if (val == "true") {
8
+ $password.attr('disabled', '');
9
+ $password.focus();
10
+ } else {
11
+ $password.attr('disabled', 'disabled');
12
+ }
13
+ }
14
+
15
+ function emailKeyPressListener(event) {
16
+ if (event.keyCode == 9) {
17
+ jQuery('.auth_form input[name="login[have_password]"][value="true"]').attr('checked', 'checked');
18
+ chooseHavePassword();
19
+ return false;
20
+ }
21
+ }
22
+
23
+ jQuery(document).ready(function () {
24
+ <% if (params[:login] and params[:login][:password]) -%>
25
+ jQuery('.auth_form input[name="login[have_password]"][value="false"]').attr('checked', 'checked');
26
+ <% end -%>
27
+ chooseHavePassword();
28
+ jQuery('.auth_form input[name="login[have_password]"]').bind('change', chooseHavePassword);
29
+ jQuery('.auth_form input[name="login[email]"]').bind('keydown', emailKeyPressListener);
30
+ });
31
+ <% else -%>
32
+ function chooseHavePassword() {
33
+ val = $('login_have_password_true').checked;
34
+ password = $('login_password');
35
+ password.value = "";
36
+
37
+ if (val) {
38
+ password.disabled = false;
39
+ password.focus();
40
+ } else {
41
+ password.disabled = true;
42
+ }
43
+ }
44
+
45
+ function emailKeyPressListener(event) {
46
+ if (event.keyCode == 9) {
47
+ $('login_have_password_true').checked = true;
48
+ chooseHavePassword();
49
+ Event.stop(event);
50
+ }
51
+ }
52
+
53
+ Event.observe(window, 'load', function () {
54
+ <% if (params[:login] and params[:login][:password]) -%>
55
+ $('login_have_password_true').checked = true;
56
+ <% end -%>
57
+ chooseHavePassword();
58
+ $('login_have_password_true').observe('change', chooseHavePassword);
59
+ $('login_have_password_false').observe('change', chooseHavePassword);
60
+ $('login_email').observe('keydown', emailKeyPressListener);
61
+ });
62
+ <% end -%>
@@ -0,0 +1,3 @@
1
+ <h1>Thank you</h1>
2
+
3
+ <p>A new password has been generated and emailed to you.</p>
@@ -0,0 +1,6 @@
1
+ <h1>I forgot my password...</h1>
2
+
3
+ <p>No problem. Just type in your email address below and we'll <b>reset your password to a random one</b>, and send
4
+ it to you via email.</p>
5
+
6
+ <%= render :partial => 'forgot_form' %>
@@ -0,0 +1,23 @@
1
+ .auth_form {
2
+ margin-left: 0.5em;
3
+ width: 300px;
4
+ }
5
+ .auth_form input {
6
+ width: 100%;
7
+ }
8
+ .auth_form input[type=radio], .auth_form input[type=checkbox] {
9
+ width: auto;
10
+ }
11
+ .auth_form label.block {
12
+ margin-left: -0.5em;
13
+ font-weight: bold;
14
+ display: block;
15
+ }
16
+ #openid_url {
17
+ background-color: #fff;
18
+ background-image: url(<%= image_path "ae_users/openid.gif" %>);
19
+ background-position: left;
20
+ background-repeat: no-repeat;
21
+ padding-left: 18px;
22
+ width: 90%;
23
+ }
@@ -0,0 +1,6 @@
1
+ <div id="login">
2
+ <h2>Log in</h2>
3
+ <%= render :partial => 'auth_form' %>
4
+ </div>
5
+
6
+ <%= render :partial => 'other_login_options' %>
@@ -0,0 +1,6 @@
1
+ <h1>Account not activated</h1>
2
+
3
+ <p>That account hasn't been activated yet. If you want to try resending the activation email (because you
4
+ didn't receive it, or accidentally deleted it), click the button below.</p>
5
+
6
+ <p><%= button_to "Resend activation email", :action => 'resend_activation', :account => params[:account], :email => params[:email] %></p>
@@ -0,0 +1,32 @@
1
+ <h2>Welcome!</h2>
2
+
3
+ <p>This is the first time you've visited this site. We just need a few pieces of information
4
+ from you before we can log you in. We've attempted to get as much of it as possible from your
5
+ OpenID provider, but some of it may be missing and/or incorrect. Please check the following form
6
+ before pressing "Save changes" below.</p>
7
+
8
+ <%= auth_stylesheet %>
9
+
10
+ <% form_for("person", @person, :url => {:action => 'needs_person'},
11
+ :html => {:id => 'edit_profile_form', :style => "max-width: 800px;"}) do |f| %>
12
+ <%= hidden_field_tag "return_to", params[:return_to] %>
13
+ <%= render :partial => 'account/personal_info', :locals => {:f => f} %>
14
+
15
+ <p>
16
+ <label for="email" class="block">Email:</label>
17
+ <%= text_field_tag "email", params[:email] %>
18
+ </p>
19
+
20
+ <% if @app_profile -%>
21
+
22
+ <% form_for("app_profile", @app_profile) do |profile_form| %>
23
+ <%= render :partial => "account/#{@app_profile.class.name.tableize.singularize}",
24
+ :locals => {:f => profile_form}%>
25
+ <label></label>
26
+ <%= submit_tag %>
27
+ <% end %>
28
+ <% else -%>
29
+ <label></label>
30
+ <%= submit_tag %>
31
+ <% end -%>
32
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <h1>Update your profile</h1>
2
+
3
+ <p>Hello! It appears this is the first time you've logged into this site. Before you log in,
4
+ please take a moment to update your personal information below.</p>
5
+
6
+ <%= auth_stylesheet %>
7
+
8
+ <% form_for("app_profile", @app_profile, :html => {:class => 'auth_form'}) do |profile_form| %>
9
+ <%= hidden_field_tag "return_to", params[:return_to] %>
10
+ <%= hidden_field_tag "person", @person.id %>
11
+ <%= render :partial => "account/#{@app_profile.class.name.tableize.singularize}",
12
+ :locals => {:f => profile_form}%>
13
+ <%= submit_tag "Update your profile" %>
14
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <div id="openid_login">
2
+ <h2>Log in with OpenID</h2>
3
+ <%= render :partial => 'openid_auth_form' %>
4
+ </div>
5
+
6
+ <%= render :partial => "other_login_options" %>
@@ -0,0 +1,3 @@
1
+ <h1>Thank you</h1>
2
+
3
+ <p>A new activation key has been generated, and an email has been sent to your address.</p>
@@ -0,0 +1,13 @@
1
+ Dear <%=@name%>,
2
+
3
+ Thank you for signing up for an account on <%=@server_name%>! There's just one more
4
+ step you need to do before you can use it: we need you to verify that this email address
5
+ belongs to you.
6
+
7
+ To do that, simply go to:
8
+
9
+ <%= url_for :only_path => false, :controller => "account", :action => "activate", :account => @account.id, :activation_key => @account.activation_key, :escape => false%>
10
+
11
+ Thanks again for signing up!
12
+
13
+ - The Management
@@ -0,0 +1,10 @@
1
+ Dear <%=@name%>,
2
+
3
+ You have requested a password reset for your account on <%=@server_name%>. This has been
4
+ completed. Your new password is:
5
+
6
+ <%= @password %>
7
+
8
+ Thanks!
9
+
10
+ - The Management
@@ -0,0 +1,47 @@
1
+ <% if AeUsers.js_framework == "prototype" -%>
2
+ <ul style="list-style-type: none; padding-left: 0;">
3
+ <% for grantee in @grantees do -%>
4
+ <li granteeName="<%=h grantee.name %>">
5
+ <% if grantee.kind_of? Role -%>
6
+ <table>
7
+ <tr>
8
+ <td>
9
+ <%= image_tag "ae_users/group.png", :style => "float: left;" %>
10
+ <div class="grantee_id" style="display: none;"><%= grantee.class.name %>:<%= grantee.id %></div>
11
+ </td>
12
+ <td>
13
+ <b><%=h grantee.name %></b><br/>
14
+ <i><%=pluralize(grantee.people.count, "person")%></i>
15
+ </td>
16
+ </tr>
17
+ </table>
18
+ <% elsif grantee.kind_of? Person -%>
19
+ <table>
20
+ <tr>
21
+ <td>
22
+ <%= image_tag "ae_users/user.png", :style => "float: left;" %>
23
+ <div class="grantee_id" style="display: none;"><%= grantee.class.name %>:<%= grantee.id %></div>
24
+ </td>
25
+ <td>
26
+ <b><%=h grantee.name %></b><br/>
27
+ <i>
28
+ <% if grantee.primary_email_address.nil? -%>
29
+ No email address
30
+ <% else -%>
31
+ <%=h grantee.primary_email_address %>
32
+ <% end -%>
33
+ </td>
34
+ </tr>
35
+ </table>
36
+ <% end -%>
37
+ </li>
38
+ <% end -%>
39
+ </ul>
40
+
41
+ <% elsif AeUsers.js_framework == "jquery" -%>
42
+
43
+ <% for grantee in @grantees do -%>
44
+ <%=grantee.name %><% if grantee.kind_of? Role %> (<%= pluralize(grantee.people.count, "person") %>)<% end %>|<%=grantee.class.name %>:<%= grantee.id %>
45
+ <% end -%>
46
+
47
+ <% end -%>
@@ -0,0 +1,8 @@
1
+ <li id="person_<%=person.id%>"><%= image_tag "ae_users/user.png" %>
2
+ <%=h person.name %>
3
+ <%= link_to_remote "Remove",
4
+ { :url => { :controller => "permission", :action => "remove_role_member", :id => person.id, :role => @role.id },
5
+ :success => "$('person_#{person.id}').remove();",
6
+ :confirm => "Are you sure you want to remove that member from this role?" },
7
+ { :class => "permission_action" } %>
8
+ </li>
@@ -0,0 +1,81 @@
1
+ <style type="text/css">
2
+ div.auto_complete {
3
+ z-index: 1000;
4
+ }
5
+
6
+ .permission_action {
7
+ font-size: 80%;
8
+ text-transform: uppercase;
9
+ text-decoration: none;
10
+ color: #444;
11
+ background-color: #ffc;
12
+ }
13
+ </style>
14
+ <%= auto_complete_stylesheet %>
15
+
16
+ <% div_for item, :permissions do %>
17
+ <ul>
18
+ <% permission_names(item).each do |perm| -%>
19
+ <li><b><%=h(perm.to_s.humanize)%></b>:
20
+ <% grants = permission_grants(item, perm) -%>
21
+ <% if grants.length == 0 -%>
22
+ <% if all_permitted?(item, perm) -%>
23
+ everybody
24
+ <% elsif grants.length == 0 -%>
25
+ <span id="<%= perm %>_nobody">nobody</span>
26
+ <% end -%>
27
+ <% else -%>
28
+ <% grants.each_index do |i| -%>
29
+ <% grant = grants[i] -%>
30
+ <span id="grant_<%=grant.id%>">
31
+ <% if grant.grantee.kind_of? Role -%>
32
+ <%= image_tag "ae_users/group.png" %>
33
+ <% elsif grant.grantee.kind_of? Person -%>
34
+ <%= image_tag "ae_users/user.png" %>
35
+ <% end -%>
36
+ <% if grant.grantee -%>
37
+ <%= h(grant.grantee.name) %>
38
+ <% else -%>
39
+ Unknown entity
40
+ <% end -%>
41
+ <% if logged_in? and logged_in_person.permitted?(item, "change_permissions") and not (grant.grantee == logged_in_person) -%>
42
+ <%= link_to_remote "Remove",
43
+ { :url => { :controller => "permission", :action => "revoke", :id => grant.id, :format => "js" },
44
+ :success => "$('grant_#{grant.id}').remove();",
45
+ :confirm => "Are you sure you want to revoke that permission?",
46
+ :failure => "alert(request.responseText)" },
47
+ { :class => "permission_action" } %>
48
+ <% end -%>
49
+
50
+ <% if i < grants.length - 1 %>, <% end %>
51
+ </span>
52
+ <% end -%>
53
+ <% end -%>
54
+ <% if logged_in? and logged_in_person.permitted?(item, "change_permissions") -%>
55
+ <div id="<%= perm %>_insert_grants_here" style="display: inline;"></div>
56
+ | <span id="grant_open_<%=perm%>">
57
+ <%= link_to_function "Add", "$('grant_open_#{perm}').toggle(); $('grant_#{perm}').toggle(); $('#{perm}_grantee_shim').focus();",
58
+ :class => "permission_action" %>
59
+ </span>
60
+ <span id="grant_<%=perm %>" style="display: none;">
61
+ <%= link_to_function "&laquo;", "$('grant_open_#{perm}').toggle(); $('grant_#{perm}').toggle();",
62
+ :class => "permission_action" %>
63
+ <%= user_picker "#{perm}_grantee", :roles => true,
64
+ :callback => "nobody = $('#{perm}_nobody');
65
+ if (nobody) {
66
+ nobody.remove();
67
+ }
68
+ new Ajax.Updater('#{perm}_insert_grants_here', '#{url_for :controller => 'permission', :action => 'grant', :perm => full_permission_name(item, perm),
69
+ :item_klass => item.class.name, :item_id => item.id, :escape => false}',
70
+ {
71
+ parameters: { 'klass': klass, 'id': id },
72
+ insertion: Insertion.Bottom,
73
+ }
74
+ );" %>
75
+ </span>
76
+ <% end -%>
77
+ </li>
78
+ <% end -%>
79
+ </ul>
80
+ <% end %>
81
+
File without changes
@@ -0,0 +1,3 @@
1
+ <li><%= image_tag "ae_users/user.png" %>
2
+ <%=h @person.name %>
3
+ </li>