Class: Scrivito::User
- Inherits:
-
Object
- Object
- Scrivito::User
- Defined in:
- app/cms/scrivito/user.rb
Constant Summary collapse
- VERBS =
Valid action verbs for the explicit rules.
[ # Lets the user create new working copies. :create, # Makes the content of the working copy visible to the user. :read, # Lets the user modify the content of the working copy. # Also lets the user rename the working copy. :write, # Permits the user to delete the working copy. :delete, # Permits the user to invite other users to collaborate on the working copy. :invite_to, # Permits the user to publish the working copy. :publish, # Permits the user to access the publishing history :read_history, ].freeze
Class Method Summary collapse
-
.define(id) {|user| ... } ⇒ Object
Defines a new user.
-
.system_user ⇒ Scrivito::User
Returns an anonymous system user who can always create workspaces, can always read, write, publish, delete, and invite others to collaborate on any workspace.
Instance Method Summary collapse
-
#can_publish?(obj) ⇒ Boolean
Checks whether the User may publish changes to a specific Obj.
-
#restriction_messages_for(obj) ⇒ Array<String>
Checks whether the User may publish changes to an Obj and returns the message specified in a Scrivito::UserDefinition#restrict_obj_publish callback if they may not.
Class Method Details
.define(id) {|user| ... } ⇒ Object
Defines a new user.
77 78 79 80 |
# File 'app/cms/scrivito/user.rb', line 77 def self.define(id, &block) assert_valid_id(id) define_user(id, &block) end |
.system_user ⇒ Scrivito::User
Returns an anonymous system user who can always create workspaces, can always read, write, publish, delete, and invite others to collaborate on any workspace.
96 97 98 |
# File 'app/cms/scrivito/user.rb', line 96 def self.system_user define_user { |user| user.is_admin! } end |
Instance Method Details
#can_publish?(obj) ⇒ Boolean
Checks whether the User may publish changes to a specific Obj.
188 189 190 |
# File 'app/cms/scrivito/user.rb', line 188 def can_publish?(obj) (obj).empty? end |
#restriction_messages_for(obj) ⇒ Array<String>
Checks whether the User may publish changes to an Obj and returns the message specified in a Scrivito::UserDefinition#restrict_obj_publish callback if they may not. If the user may publish the CMS object, an empty array is returned.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'app/cms/scrivito/user.rb', line 201 def (obj) assert_restrictions_applicable(obj) return [] if can_always?(:publish, :workspace) if obj.modification == Modification::EDITED base_revision_obj = obj.in_revision(obj.revision.workspace.base_revision) restriction_set.(obj) | restriction_set.(base_revision_obj) else restriction_set.(obj) end end |