Class: Scrivito::UserDefinition
- Inherits:
-
Object
- Object
- Scrivito::UserDefinition
- Defined in:
- app/cms/scrivito/user_definition.rb
Instance Method Summary collapse
-
#can_always(verb, subject, message = nil) ⇒ Object
Adds an explicit rule that allows the user to always execute an action.
-
#can_never(verb, subject, message = nil) ⇒ Object
Adds an explicit rule that forbids the user to execute an action.
-
#description(description_string = nil, &description_proc) ⇒ Object
Defines the user description to be displayed in the in-place UI, e.g.
-
#is_admin! ⇒ Object
Enables the user to create workspaces, to read from, write to, publish, delete workspaces, and to invite others to collaborate on any workspace.
-
#restrict_obj_publish(options) {|attribute| ... } ⇒ Object
Lets you restrict a user’s capability to publish a specific CMS object.
-
#suggest_users(&suggest_users_proc) {|input| ... } ⇒ Object
Defines the proc for fetching users for autocompletion purposes in the in-place UI.
-
#ui_locale(language) ⇒ Object
Lets you specify the user’s in-place UI language.
Instance Method Details
#can_always(verb, subject, message = nil) ⇒ Object
Usually, the memberships of a workspace decide whether a user is allowed or not to perform a specific action. This method lets you add an exception to this logic and thus should be used carefully.
By default, all users are allowed to create a new workspace.
Adds an explicit rule that allows the user to always execute an action. A rule consists of an action verb, the subject of the action, and an optional message.
41 42 43 44 |
# File 'app/cms/scrivito/user_definition.rb', line 41 def can_always(verb, subject, = nil) assert_no_conflict(:never, verb, subject) @explicit_rules << [:always, verb, subject, ] end |
#can_never(verb, subject, message = nil) ⇒ Object
Usually, the memberships of a workspace decide whether a user is allowed or not to perform a specific action. This method lets you add an exception to this logic and thus should be used carefully.
By default, all users are allowed to create a new workspace. Use this method to forbid a user to create a new workspace.
Adds an explicit rule that forbids the user to execute an action. A rule consists of an action verb, the subject of the action, and an optional message.
79 80 81 82 |
# File 'app/cms/scrivito/user_definition.rb', line 79 def can_never(verb, subject, = nil) assert_no_conflict(:always, verb, subject) @explicit_rules << [:never, verb, subject, ] end |
#description(description_string = nil, &description_proc) ⇒ Object
The description is calculated “lazily”. The calculated description is cached.
Defines the user description to be displayed in the in-place UI, e.g. in the workspace menu.
120 121 122 123 124 125 126 |
# File 'app/cms/scrivito/user_definition.rb', line 120 def description(description_string = nil, &description_proc) if description_string description { description_string } else @description_proc = description_proc end end |
#is_admin! ⇒ Object
Enables the user to create workspaces, to read from, write to, publish, delete workspaces, and to invite others to collaborate on any workspace.
90 91 92 |
# File 'app/cms/scrivito/user_definition.rb', line 90 def is_admin! @explicit_rules = User::VERBS.map { |verb| [:always, verb, :workspace, nil] } end |
#restrict_obj_publish(options) {|attribute| ... } ⇒ Object
Lets you restrict a user’s capability to publish a specific CMS object. Each registered callback may refer to one attribute of an object. Multiple callbacks are possible.
199 200 201 |
# File 'app/cms/scrivito/user_definition.rb', line 199 def restrict_obj_publish(, &block) restriction_set.add(, &block) end |
#suggest_users(&suggest_users_proc) {|input| ... } ⇒ Object
Only the first 20 users returned are displayed in the in-place UI.
suggest_users_proc
may also be invoked with an empty string.
Defines the proc for fetching users for autocompletion purposes in the in-place UI. User autocompletion is used in the settings dialog of a workspace. If the proc is not set, Scrivito::User.find is used to fetch the suggested users, assuming the input is part of the user id.
155 156 157 |
# File 'app/cms/scrivito/user_definition.rb', line 155 def suggest_users(&suggest_users_proc) @suggest_users_proc = suggest_users_proc end |
#ui_locale(language) ⇒ Object
Lets you specify the user’s in-place UI language.
Overrides auto-detection from browser language. Overrides the application-wide scrivito UI locale configuration.
220 221 222 |
# File 'app/cms/scrivito/user_definition.rb', line 220 def ui_locale(language) @ui_locale = language end |