activeldap 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. data/CHANGES +61 -0
  2. data/README +8 -1
  3. data/Rakefile +4 -1
  4. data/benchmark/bench-al.rb +12 -2
  5. data/examples/al-admin/app/controllers/account_controller.rb +4 -3
  6. data/examples/al-admin/app/controllers/application.rb +5 -2
  7. data/examples/al-admin/app/controllers/directory_controller.rb +3 -1
  8. data/examples/al-admin/app/controllers/users_controller.rb +19 -4
  9. data/examples/al-admin/app/controllers/welcome_controller.rb +4 -2
  10. data/examples/al-admin/app/helpers/application_helper.rb +7 -1
  11. data/examples/al-admin/app/helpers/url_helper.rb +4 -0
  12. data/examples/al-admin/app/models/ldap_user.rb +4 -0
  13. data/examples/al-admin/app/views/_entry/{_attributes_information.rhtml → _attributes_information.html.erb} +0 -0
  14. data/examples/al-admin/app/views/_entry/{_entry.rhtml → _entry.html.erb} +0 -0
  15. data/examples/al-admin/app/views/_schema/{_aliases.rhtml → _aliases.html.erb} +0 -0
  16. data/examples/al-admin/app/views/_switcher/{_after.rhtml → _after.html.erb} +0 -0
  17. data/examples/al-admin/app/views/_switcher/{_before.rhtml → _before.html.erb} +0 -0
  18. data/examples/al-admin/app/views/account/{login.rhtml → login.html.erb} +0 -0
  19. data/examples/al-admin/app/views/account/{sign_up.rhtml → sign_up.html.erb} +0 -0
  20. data/examples/al-admin/app/views/attributes/{_attributes.rhtml → _attributes.html.erb} +0 -0
  21. data/examples/al-admin/app/views/attributes/{_detail.rhtml → _detail.html.erb} +0 -0
  22. data/examples/al-admin/app/views/attributes/{index.rhtml → index.html.erb} +0 -0
  23. data/examples/al-admin/app/views/attributes/{show.rhtml → show.html.erb} +0 -0
  24. data/examples/al-admin/app/views/directory/{_tree.rhtml → _tree.html.erb} +0 -0
  25. data/examples/al-admin/app/views/directory/{_tree_view_js.rhtml → _tree_view_js.html.erb} +4 -5
  26. data/examples/al-admin/app/views/directory/{index.rhtml → index.html.erb} +0 -0
  27. data/examples/al-admin/app/views/directory/{populate.rhtml → populate.html.erb} +0 -0
  28. data/examples/al-admin/app/views/layouts/{_footer.rhtml → _footer.html.erb} +0 -0
  29. data/examples/al-admin/app/views/layouts/{_header_menu.rhtml → _header_menu.html.erb} +0 -0
  30. data/examples/al-admin/app/views/layouts/{_main_menu.rhtml → _main_menu.html.erb} +0 -0
  31. data/examples/al-admin/app/views/layouts/{application.rhtml → application.html.erb} +3 -2
  32. data/examples/al-admin/app/views/object_classes/{_attributes.rhtml → _attributes.html.erb} +0 -0
  33. data/examples/al-admin/app/views/object_classes/{_object_classes.rhtml → _object_classes.html.erb} +0 -0
  34. data/examples/al-admin/app/views/object_classes/{index.rhtml → index.html.erb} +0 -0
  35. data/examples/al-admin/app/views/object_classes/{show.rhtml → show.html.erb} +0 -0
  36. data/examples/al-admin/app/views/syntaxes/{_detail.rhtml → _detail.html.erb} +0 -0
  37. data/examples/al-admin/app/views/syntaxes/{_syntaxes.rhtml → _syntaxes.html.erb} +0 -0
  38. data/examples/al-admin/app/views/syntaxes/{index.rhtml → index.html.erb} +0 -0
  39. data/examples/al-admin/app/views/syntaxes/{show.rhtml → show.html.erb} +0 -0
  40. data/examples/al-admin/app/views/users/{_attributes_update_form.rhtml → _attributes_update_form.html.erb} +0 -0
  41. data/examples/al-admin/app/views/users/{_form.rhtml → _form.html.erb} +0 -0
  42. data/examples/al-admin/app/views/users/{_object_classes_update_form.rhtml → _object_classes_update_form.html.erb} +7 -1
  43. data/examples/al-admin/app/views/users/{_password_change_form.rhtml → _password_change_form.html.erb} +0 -0
  44. data/examples/al-admin/app/views/users/{edit.rhtml → edit.html.erb} +0 -0
  45. data/examples/al-admin/app/views/users/{index.rhtml → index.html.erb} +0 -0
  46. data/examples/al-admin/app/views/users/{show.rhtml → show.html.erb} +0 -0
  47. data/examples/al-admin/app/views/welcome/{index.rhtml → index.html.erb} +0 -0
  48. data/examples/al-admin/config/boot.rb +96 -32
  49. data/examples/al-admin/config/environment.rb +30 -36
  50. data/examples/al-admin/config/environments/development.rb +2 -5
  51. data/examples/al-admin/config/environments/production.rb +1 -0
  52. data/examples/al-admin/config/environments/test.rb +4 -1
  53. data/examples/al-admin/config/initializers/exception_notifier.rb +2 -0
  54. data/examples/al-admin/config/initializers/gettext.rb +1 -0
  55. data/examples/al-admin/config/initializers/inflections.rb +10 -0
  56. data/examples/al-admin/config/initializers/mime_types.rb +5 -0
  57. data/examples/al-admin/config/initializers/ralative_url_support.rb +1 -0
  58. data/examples/al-admin/config/routes.rb +24 -12
  59. data/examples/al-admin/lib/authenticated_system.rb +1 -1
  60. data/examples/al-admin/lib/tasks/gettext.rake +1 -1
  61. data/examples/al-admin/po/en/al-admin.po +102 -100
  62. data/examples/al-admin/po/ja/al-admin.po +112 -110
  63. data/examples/al-admin/po/nl/al-admin.po +117 -110
  64. data/examples/al-admin/public/javascripts/controls.js +484 -354
  65. data/examples/al-admin/public/javascripts/dragdrop.js +88 -58
  66. data/examples/al-admin/public/javascripts/effects.js +396 -364
  67. data/examples/al-admin/public/javascripts/prototype.js +2817 -1107
  68. data/examples/al-admin/public/stylesheets/base.css +5 -0
  69. data/examples/al-admin/script/performance/request +3 -0
  70. data/lib/active_ldap.rb +13 -10
  71. data/lib/active_ldap/adapter/base.rb +159 -43
  72. data/lib/active_ldap/adapter/jndi.rb +175 -0
  73. data/lib/active_ldap/adapter/jndi_connection.rb +180 -0
  74. data/lib/active_ldap/adapter/ldap.rb +91 -46
  75. data/lib/active_ldap/adapter/ldap_ext.rb +19 -5
  76. data/lib/active_ldap/adapter/net_ldap.rb +52 -44
  77. data/lib/active_ldap/association/has_many_wrap.rb +1 -1
  78. data/lib/active_ldap/attributes.rb +20 -95
  79. data/lib/active_ldap/base.rb +195 -186
  80. data/lib/active_ldap/callbacks.rb +33 -0
  81. data/lib/active_ldap/command.rb +3 -3
  82. data/lib/active_ldap/connection.rb +21 -3
  83. data/lib/active_ldap/distinguished_name.rb +18 -11
  84. data/lib/active_ldap/entry_attribute.rb +78 -0
  85. data/lib/active_ldap/human_readable.rb +20 -0
  86. data/lib/active_ldap/ldif.rb +860 -10
  87. data/lib/active_ldap/object_class.rb +6 -4
  88. data/lib/active_ldap/operations.rb +129 -22
  89. data/lib/active_ldap/schema.rb +118 -9
  90. data/lib/active_ldap/schema/syntaxes.rb +33 -16
  91. data/lib/active_ldap/validations.rb +74 -65
  92. data/po/en/active-ldap.po +378 -768
  93. data/po/ja/active-ldap.po +935 -868
  94. data/rails/plugin/active_ldap/init.rb +40 -2
  95. data/test/al-test-utils.rb +78 -58
  96. data/test/command.rb +51 -1
  97. data/test/test-unit-ext/priority.rb +29 -6
  98. data/test/test_adapter.rb +21 -2
  99. data/test/test_attributes.rb +13 -0
  100. data/test/test_base.rb +51 -1
  101. data/test/test_connection.rb +2 -1
  102. data/test/test_connection_per_class.rb +55 -1
  103. data/test/test_connection_per_dn.rb +29 -1
  104. data/test/test_find.rb +73 -0
  105. data/test/test_ldif.rb +1829 -15
  106. data/test/test_load.rb +126 -0
  107. data/test/test_object_class.rb +23 -5
  108. data/test/test_schema.rb +28 -0
  109. data/test/test_syntax.rb +22 -11
  110. data/test/test_user.rb +16 -25
  111. data/test/test_useradd-binary.rb +1 -1
  112. data/test/test_usermod-binary-add-time.rb +1 -1
  113. data/test/test_usermod-binary-add.rb +1 -1
  114. data/test/test_validation.rb +100 -22
  115. metadata +77 -71
  116. data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
  117. data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
  118. data/examples/al-admin/app/views/layouts/_flash_box.rhtml +0 -4
  119. data/examples/al-admin/public/stylesheets/common.css +0 -2
  120. data/examples/al-admin/script/breakpointer +0 -3
data/CHANGES CHANGED
@@ -1,3 +1,64 @@
1
+ 0.10.0:
2
+ * Implemented LDIF parser.
3
+ * Improved validation:
4
+ * Added some validations.
5
+ * Fixed SINGLE-VALUE validation. [#17763]
6
+ (Reported by Naoto Morishima)
7
+ * Supported JNDI as backend.
8
+ * Improved auto reconnection.
9
+ * Supported Rails 2.0.2.
10
+ * Improved performance. (4x)
11
+ * [API CHANGE]: removed "'binary' =>" from getter result.
12
+ e.g., before:
13
+ user.user_certificate # => {"binary" => "..."}
14
+ now:
15
+ user.user_certificate # => "..."
16
+ * Added :excluded_classed ldap_mapping option.
17
+ * Logged operation time used for LDAP operation.
18
+ * Improved API:
19
+ * Accepted non String value for find(:value => XXX).
20
+ (Suggested by Marc Dequèn)
21
+ * Accepted DN as ActiveLdap::Base.new(XXX).
22
+ (Reported by Jeremy Pruitt)
23
+ * Treated empty password for smiple bind as anonymous bind.
24
+ (Suggested by Bodaniel Jeans)
25
+ * Ensured adding "objectClass" for find's :attribute value. [#16946]
26
+ (Suggested by Nobody)
27
+ * Fixed a GeneralizedTime type casting bug.
28
+ (Reported by Bodaniel Jeanes)
29
+
30
+ 0.9.1:
31
+ * Implemented LDIF parser.
32
+ * Improved validation:
33
+ * Added some validations.
34
+ * Fixed SINGLE-VALUE validation. [#17763]
35
+ (Reported by Naoto Morishima)
36
+ * Supported JNDI as backend.
37
+ * Improved auto reconnection.
38
+ * Supported Rails 2.0.2.
39
+ * Improved performance. (4x)
40
+ * [API CHANGE]: removed "'binary' =>" from getter result.
41
+ e.g.
42
+ before:
43
+ user.user_certificate # => {"binary" => "..."}
44
+ now:
45
+ user.user_certificate # => "..."
46
+ * Added :excluded_classed ldap_mapping option.
47
+ * Logged operation time used for LDAP operation.
48
+ * Improved API:
49
+ * Accepted non String value for find(:value => XXX).
50
+ (Suggested by Marc Dequèn)
51
+ * Accepted DN as ActiveLdap::Base.new(XXX).
52
+ (Reported by Jeremy Pruitt)
53
+ * Treated empty password for smiple bind as anonymous bind.
54
+ (Suggested by Bodaniel Jeans)
55
+ * Ensured adding "objectClass" for find's :attribute value. [#16946]
56
+ (Suggested by Nobody)
57
+ * Fixed a GeneralizedTime type casting bug.
58
+ (Reported by Bodaniel Jeanes)
59
+ * Supported :base and :prefix search/find option value escaping.
60
+ (Suggested by David Morton)
61
+
1
62
  0.9.0:
2
63
  * Improved DN handling.
3
64
  * Supported attribute value validation by LDAP schema.
data/README CHANGED
@@ -84,7 +84,7 @@ THANKS
84
84
  This list may not be correct. If you notice mistakes of this
85
85
  list, please point out.
86
86
 
87
- * Nobody: Bug reports.
87
+ * Nobody: Bug reports and API improveent ideas.
88
88
  * James Hughes: Bug reports and advices and documentations.
89
89
  * Buzz Chopra: Documentations.
90
90
  * Christoph Lipp: Bug reports.
@@ -99,3 +99,10 @@ list, please point out.
99
99
  * Christoph Lipp: Tell us character escape syntax.
100
100
  * Kevin McCarthy: Patches.
101
101
  * Perry Smith: Patches, bug reports and indications.
102
+ * Marc Dequènes: API suggestions.
103
+ * Jeremy Pruitt: A bug report.
104
+ * Bodaniel Jeanes:
105
+ * A suggestion for behavior on simple bind with empty password.
106
+ * Bug reports.
107
+ * Naoto Morishima:
108
+ * Bug reports.
data/Rakefile CHANGED
@@ -23,9 +23,10 @@ white_list_paths =
23
23
  [
24
24
  "rails/plugin/active_ldap/generators/scaffold_al/templates/ldap.yml"
25
25
  ]
26
- Find.find(base_dir) do |target|
26
+ Find.find(base_dir + File::SEPARATOR) do |target|
27
27
  target = truncate_base_dir[target]
28
28
  components = target.split(File::SEPARATOR)
29
+ next if components.empty?
29
30
  if components.size == 1 and !File.directory?(target)
30
31
  next unless base_dir_included_components.include?(components[0])
31
32
  end
@@ -54,6 +55,8 @@ project = Hoe.new('activeldap', ActiveLdap::VERSION) do |project|
54
55
  project.changes = project.paragraphs_of('CHANGES', 0..1).join("\n\n")
55
56
  project.extra_deps = ['activerecord']
56
57
  project.rdoc_pattern = /(?:^(?:lib|bin)|\AREADME\z)/
58
+ project.remote_rdoc_dir = "doc"
59
+ project.rsync_args += " --chmod=Dg+ws,Fg+w"
57
60
  project.spec_extras = {
58
61
  :requirements => ['ruby-ldap >= 0.8.2', '(Open)LDAP server'],
59
62
  :autorequire => 'active_ldap',
@@ -26,6 +26,7 @@ LDAP_BASE = config[:base]
26
26
  LDAP_PREFIX = options.prefix
27
27
  LDAP_USER = config[:bind_dn]
28
28
  LDAP_PASSWORD = config[:password]
29
+ LDAP_METHOD = config[:method]
29
30
 
30
31
  class ALUser < ActiveLdap::Base
31
32
  ldap_mapping :dn_attribute => 'uid', :prefix => LDAP_PREFIX,
@@ -74,7 +75,11 @@ end
74
75
 
75
76
  def ldap_connection
76
77
  require 'ldap'
77
- conn = LDAP::Conn.new(LDAP_HOST, LDAP_PORT)
78
+ if LDAP_METHOD == :tls
79
+ conn = LDAP::SSLConn.new(LDAP_HOST, LDAP_PORT, true)
80
+ else
81
+ conn = LDAP::Conn.new(LDAP_HOST, LDAP_PORT)
82
+ end
78
83
  conn.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
79
84
  conn.bind(LDAP_USER, LDAP_PASSWORD) if LDAP_USER and LDAP_PASSWORD
80
85
  conn
@@ -87,6 +92,7 @@ def net_ldap_connection
87
92
  net_ldap_conn = Net::LDAP::Connection.new(:host => LDAP_HOST,
88
93
  :port => LDAP_PORT)
89
94
  if LDAP_USER and LDAP_PASSWORD
95
+ net_ldap_conn.setup_encryption(:method => :start_tls) if LDAP_METHOD == :tls
90
96
  net_ldap_conn.bind(:method => :simple,
91
97
  :username => LDAP_USER,
92
98
  :password => LDAP_PASSWORD)
@@ -166,19 +172,23 @@ def main(do_populate)
166
172
  al_count_without_object_creation = 0
167
173
  ldap_count = 0
168
174
  net_ldap_count = 0
169
- Benchmark.bm(20) do |x|
175
+ Benchmark.bmbm(20) do |x|
170
176
  [1].each do |n|
177
+ GC.start
171
178
  x.report("%3dx: AL" % n) {n.times {al_count = search_al}}
179
+ GC.start
172
180
  x.report("%3dx: AL(No Obj)" % n) do
173
181
  n.times do
174
182
  al_count_without_object_creation = search_al_without_object_creation
175
183
  end
176
184
  end
185
+ GC.start
177
186
  if ldap_conn
178
187
  x.report("%3dx: LDAP" % n) do
179
188
  n.times {ldap_count = search_ldap(ldap_conn)}
180
189
  end
181
190
  end
191
+ GC.start
182
192
  if net_ldap_conn
183
193
  x.report("%3dx: Net::LDAP" % n) do
184
194
  n.times {net_ldap_count = search_net_ldap(net_ldap_conn)}
@@ -21,9 +21,9 @@ class AccountController < ApplicationController
21
21
  }
22
22
  end
23
23
  redirect_back_or_default(top_url)
24
- flash[:notice] = _("Logged in successfully")
24
+ flash.now[:notice] = _("Logged in successfully")
25
25
  else
26
- flash[:notice] = _("Login or Password is incorrect")
26
+ flash.now[:notice] = _("Login or Password is incorrect")
27
27
  end
28
28
  end
29
29
 
@@ -50,7 +50,8 @@ class AccountController < ApplicationController
50
50
 
51
51
  private
52
52
  def force_logout
53
- current_user.forget_me if logged_in?
53
+ return true unless logged_in?
54
+ current_user.forget_me
54
55
  self.current_user = nil
55
56
  cookies.delete :auth_token
56
57
  reset_session
@@ -2,8 +2,11 @@
2
2
  # Likewise, all the methods added will be available for all controllers.
3
3
 
4
4
  class ApplicationController < ActionController::Base
5
- # Pick a unique cookie name to distinguish our session data from others'
6
- session :session_key => '_al-admin_session_id'
5
+ helper :all # include all helpers, all the time
6
+
7
+ # See ActionController::RequestForgeryProtection for details
8
+ # Uncomment the :secret if you're not using the cookie session store
9
+ protect_from_forgery # :secret => '5965eefc93d824a9c145fe8edb6d1a36'
7
10
 
8
11
  init_gettext "al-admin"
9
12
 
@@ -16,7 +16,9 @@ class DirectoryController < ApplicationController
16
16
  else
17
17
  @entry = Entry.find(dn, find_options)
18
18
  end
19
- render(:partial => "_entry/entry", :object => @entry)
19
+ erb = "<%= render(:partial => '_entry/entry', :object => @entry) %>"
20
+ erb = "<div>\n#{erb}\n</div>"
21
+ render(:inline => erb)
20
22
  end
21
23
 
22
24
  def populate
@@ -19,8 +19,14 @@ class UsersController < ApplicationController
19
19
  def update
20
20
  @user = find(params[:id])
21
21
  previous_user_password = @user.user_password
22
- @user.replace_class(params["object-classes"])
23
- if @user.update_attributes(params[:user])
22
+ object_class_error_message = nil
23
+ begin
24
+ @user.replace_class(params["object-classes"])
25
+ rescue ActiveLdap::RequiredObjectClassMissed
26
+ object_class_error_message = $!.message
27
+ end
28
+ if @user.update_attributes(params[:user]) and
29
+ object_class_error_message.nil?
24
30
  if previous_user_password != @user.user_password and @user.connected?
25
31
  @user.bind(@user.password)
26
32
  end
@@ -28,20 +34,29 @@ class UsersController < ApplicationController
28
34
  redirect_to :action => 'show', :id => @user
29
35
  else
30
36
  @user.password = @user.password_confirmation = nil
37
+ @user.errors.add("objectClass", object_class_error_message)
31
38
  render :action => 'edit'
32
39
  end
33
40
  end
34
41
 
35
42
  def update_object_classes
36
43
  @user = find(params[:id])
37
- @user.replace_class(params["object-classes"])
44
+ begin
45
+ @user.replace_class(params["object-classes"])
46
+ rescue ActiveLdap::RequiredObjectClassMissed
47
+ flash.now[:inline_notice] = $!.message
48
+ erb = "<%= flash_box(flash[:inline_notice], :need_container => true) %>"
49
+ render(:inline => erb, :status => 400)
50
+ return
51
+ end
38
52
  available_attributes = @user.attribute_names(true)
39
53
  attributes = {}
40
54
  (params[:user] || {}).each do |key, value|
41
55
  attributes[key] = value if available_attributes.include?(key)
42
56
  end
43
57
  @user.attributes = attributes
44
- render(:partial => "attributes_update_form")
58
+ erb = "<div>\n<%= render(:partial => 'attributes_update_form') %>\n</div>"
59
+ render(:inline => erb)
45
60
  end
46
61
 
47
62
  private
@@ -2,9 +2,11 @@ class WelcomeController < ApplicationController
2
2
  include UrlHelper
3
3
 
4
4
  def index
5
- unless logged_in?
5
+ if Entry.empty?
6
+ redirect_to(populate_path)
7
+ elsif !logged_in?
6
8
  flash.keep(:notice)
7
- redirect_to(:login_path)
9
+ redirect_to(login_path)
8
10
  end
9
11
  end
10
12
  end
@@ -2,12 +2,18 @@
2
2
  module ApplicationHelper
3
3
  include UrlHelper
4
4
 
5
- def flash_box(message)
5
+ def flash_box(message, options={})
6
+ return '' if message.nil?
6
7
  id = "flash-box"
7
8
  fade_out = Proc.new {|page| page.visual_effect(:fade, id)}
9
+ message = content_tag(:p, h(message), :class => "notice")
8
10
  flash_box_div = content_tag("div", "\n#{message}\n",
9
11
  :id => id,
10
12
  :onclick => update_page(&fade_out))
13
+ if options[:need_container]
14
+ flash_box_div = content_tag("div", "\n #{flash_box_div}\n",
15
+ :class => "flash-box-container")
16
+ end
11
17
  set_opacity = update_page {|page| page[id].setOpacity("0.8")}
12
18
  effect = update_page do |page|
13
19
  page.delay(5) do
@@ -10,4 +10,8 @@ module UrlHelper
10
10
  def sign_up_path
11
11
  url_for(:controller => "/account", :action => "sign_up")
12
12
  end
13
+
14
+ def populate_path
15
+ url_for(:controller => "/directory", :action => "populate")
16
+ end
13
17
  end
@@ -38,6 +38,10 @@ class LdapUser < ActiveLdap::Base
38
38
  (ActiveLdap::DN.parse(dn) - ActiveLdap::DN.parse(self.class.base)).to_s
39
39
  end
40
40
 
41
+ def system_user
42
+ @system_user ||= User.find_by_dn(dn)
43
+ end
44
+
41
45
  private
42
46
  def encrypt_password
43
47
  return if password.blank?
@@ -18,9 +18,8 @@ treeView.addSelectItemCallback(function (element)
18
18
  $(<%= entry_id.to_json %>).update(message);
19
19
  }
20
20
 
21
- new Ajax.Updater({success: <%= entry_id.to_json %>},
22
- <%= url_for(:action => "entry").to_json %>,
23
- {parameters: {dn: selectedDN},
24
- evalScripts: true,
25
- onFailure: failureHandler});
21
+ <%= remote_function(:update => {:success => entry_id},
22
+ :url => url_for(:action => "entry"),
23
+ :with => "'dn=' + selectedDN",
24
+ :failure => "failureHandler") %>;
26
25
  });
@@ -13,7 +13,8 @@
13
13
  <%= stylesheet_link_tag('rails') %>
14
14
  <%= stylesheet_link_tag('spinelz/treeview.css') %>
15
15
  <%= stylesheet_link_tag('spinelz/switcher.css') %>
16
- <%= stylesheet_link_tag('common') %>
16
+ <%= stylesheet_link_tag('base') %>
17
+ <%= stylesheet_link_tag('structure') %>
17
18
  <%= stylesheet_link_tag(@controller.controller_name.gsub(/_/, "-")) %>
18
19
  <%= javascript_include_tag(:defaults) %>
19
20
  <%= javascript_include_tag("spinelz_lib/spinelz_util.js") %>
@@ -34,7 +35,7 @@
34
35
  <hr class="clear" />
35
36
  </div>
36
37
 
37
- <%= render(:partial => "layouts/flash_box") %>
38
+ <%= flash_box(flash[:notice]) %>
38
39
 
39
40
  <div class="body">
40
41
  <div class="content">
@@ -1,6 +1,7 @@
1
1
  <%
2
2
  using_object_classes = @user.classes
3
3
  available_object_classes = @user.schema.object_classes.collect(&:name)
4
+ update_failure_id = 'object-classes-obdate-failure'
4
5
  %>
5
6
 
6
7
  <% switcher("object-classes", _("Update objectClasses")) do %>
@@ -33,8 +34,13 @@
33
34
  <% end %>
34
35
 
35
36
  <%= javascript_tag("function updateAttributesForm(form) {" +
36
- remote_function(:update => attributes_form_id,
37
+ remote_function(:update => {
38
+ :success => attributes_form_id,
39
+ :failure => update_failure_id,
40
+ },
37
41
  :url => {:action => :update_object_classes,
38
42
  :id => @user},
39
43
  :with => 'Form.serialize(form)') +
40
44
  "}") %>
45
+
46
+ <div id="<%= h(update_failure_id) %>"></div>
@@ -1,45 +1,109 @@
1
- # Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb
1
+ # Don't change this file!
2
+ # Configure your app in config/environment.rb and config/environments/*.rb
2
3
 
3
- unless defined?(RAILS_ROOT)
4
- root_path = File.join(File.dirname(__FILE__), '..')
4
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
5
 
6
- unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
7
- require 'pathname'
8
- root_path = Pathname.new(root_path).cleanpath(true).to_s
9
- end
6
+ module Rails
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ preinitialize
11
+ pick_boot.run
12
+ end
13
+ end
10
14
 
11
- RAILS_ROOT = root_path
12
- end
15
+ def booted?
16
+ defined? Rails::Initializer
17
+ end
18
+
19
+ def pick_boot
20
+ (vendor_rails? ? VendorBoot : GemBoot).new
21
+ end
22
+
23
+ def vendor_rails?
24
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
25
+ end
13
26
 
14
- unless defined?(Rails::Initializer)
15
- if File.directory?("#{RAILS_ROOT}/vendor/rails")
16
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
17
- else
18
- require 'rubygems'
27
+ # FIXME : Ruby 1.9
28
+ def preinitialize
29
+ load(preinitializer_path) if File.exists?(preinitializer_path)
30
+ end
19
31
 
20
- environment_without_comments = IO.readlines(File.dirname(__FILE__) + '/environment.rb').reject { |l| l =~ /^#/ }.join
21
- environment_without_comments =~ /[^#]RAILS_GEM_VERSION = '([\d.]+)'/
22
- rails_gem_version = $1
32
+ def preinitializer_path
33
+ "#{RAILS_ROOT}/config/preinitializer.rb"
34
+ end
35
+ end
23
36
 
24
- if version = defined?(RAILS_GEM_VERSION) ? RAILS_GEM_VERSION : rails_gem_version
25
- # Asking for 1.1.6 will give you 1.1.6.5206, if available -- makes it easier to use beta gems
26
- rails_gem = Gem.cache.search('rails', "~>#{version}.0").sort_by { |g| g.version.version }.last
37
+ class Boot
38
+ def run
39
+ load_initializer
40
+ Rails::Initializer.run(:set_load_path)
41
+ end
42
+ end
27
43
 
28
- if rails_gem
29
- gem "rails", "=#{rails_gem.version.version}"
30
- require rails_gem.full_gem_path + '/lib/initializer'
44
+ class VendorBoot < Boot
45
+ def load_initializer
46
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
47
+ end
48
+ end
49
+
50
+ class GemBoot < Boot
51
+ def load_initializer
52
+ self.class.load_rubygems
53
+ load_rails_gem
54
+ require 'initializer'
55
+ end
56
+
57
+ def load_rails_gem
58
+ if version = self.class.gem_version
59
+ gem 'rails', version
31
60
  else
32
- STDERR.puts %(Cannot find gem for Rails ~>#{version}.0:
33
- Install the missing gem with 'gem install -v=#{version} rails', or
34
- change environment.rb to define RAILS_GEM_VERSION with your desired version.
35
- )
61
+ gem 'rails'
62
+ end
63
+ rescue Gem::LoadError => load_error
64
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
65
+ exit 1
66
+ end
67
+
68
+ class << self
69
+ def rubygems_version
70
+ Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
71
+ end
72
+
73
+ def gem_version
74
+ if defined? RAILS_GEM_VERSION
75
+ RAILS_GEM_VERSION
76
+ elsif ENV.include?('RAILS_GEM_VERSION')
77
+ ENV['RAILS_GEM_VERSION']
78
+ else
79
+ parse_gem_version(read_environment_rb)
80
+ end
81
+ end
82
+
83
+ def load_rubygems
84
+ require 'rubygems'
85
+
86
+ unless rubygems_version >= '0.9.4'
87
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
88
+ exit 1
89
+ end
90
+
91
+ rescue LoadError
92
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
36
93
  exit 1
37
94
  end
38
- else
39
- gem "rails"
40
- require 'initializer'
95
+
96
+ def parse_gem_version(text)
97
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
98
+ end
99
+
100
+ private
101
+ def read_environment_rb
102
+ File.read("#{RAILS_ROOT}/config/environment.rb")
103
+ end
41
104
  end
42
105
  end
43
-
44
- Rails::Initializer.run(:set_load_path)
45
106
  end
107
+
108
+ # All that for this:
109
+ Rails.boot!