Refactor directory structrue

This commit is contained in:
jvelilla
2014-11-13 11:57:36 -03:00
parent 8ab4343d5b
commit d963fd218b
154 changed files with 12 additions and 11 deletions

View File

@@ -0,0 +1,184 @@
note
description: "[
Interface representing a USER in the CMS system.
]"
date: "$Date$"
revision: "$Revision$"
class
CMS_USER
inherit
DEBUG_OUTPUT
create
make
feature {NONE} -- Initialization
make (a_name: READABLE_STRING_32)
-- Create an object with name `a_name'.
do
name := a_name
create creation_date.make_now_utc
ensure
name_set: name = a_name
end
feature -- Access
id: INTEGER_64
-- Unique id.
name: READABLE_STRING_32
-- User name.
password: detachable READABLE_STRING_32
-- User password.
email: detachable READABLE_STRING_32
-- User email.
profile: detachable CMS_USER_PROFILE
-- User profile.
creation_date: DATE_TIME
-- Creation date.
last_login_date: detachable DATE_TIME
-- User last login.
feature -- Access: data
data: detachable STRING_TABLE [detachable ANY]
-- Additional data.
data_item (k: READABLE_STRING_GENERAL): detachable ANY
-- Additional item data associated with key `k'.
do
if attached data as l_data then
Result := l_data.item (k)
end
end
feature -- Status report
has_id: BOOLEAN
do
Result := id > 0
end
has_email: BOOLEAN
do
Result := attached email as e and then not e.is_empty
end
debug_output: STRING_32
do
create Result.make_from_string (name)
if has_id then
Result.append_character (' ')
Result.append_character ('<')
Result.append_integer_64 (id)
Result.append_character ('>')
end
end
same_as (other: detachable CMS_USER): BOOLEAN
-- Is Current same as `other'?
do
Result := other /= Void and then id = other.id
end
feature -- Change element
set_id (a_id: like id)
-- Set `id' with `a_id'.
do
id := a_id
ensure
id_set: id = a_id
end
set_name (n: like name)
-- Set `name' with `n'.
do
name := n
ensure
name_set: name = n
end
set_password (a_password: like password)
-- Set `password' with `a_password'.
do
password := a_password
ensure
password_set: password = a_password
end
set_email (a_email: like email)
-- Set `email' with `a_email'.
do
email := a_email
ensure
email_set: email = a_email
end
set_profile (prof: like profile)
-- Set `profile' with `prof'.
do
profile := prof
ensure
profile_set: profile = prof
end
set_profile_item (k: READABLE_STRING_8; v: READABLE_STRING_8)
local
prof: like profile
do
prof := profile
if prof = Void then
create prof.make
profile := prof
end
prof.force (v, k)
end
set_last_login_date (dt: like last_login_date)
do
last_login_date := dt
end
set_last_login_date_now
do
set_last_login_date (create {DATE_TIME}.make_now_utc)
end
feature -- Change element: data
set_data_item (k: READABLE_STRING_GENERAL; d: like data_item)
-- Associate data item `d' with key `k'.
local
l_data: like data
do
l_data := data
if l_data = Void then
create l_data.make (1)
data := l_data
end
l_data.force (d, k)
end
remove_data_item (k: READABLE_STRING_GENERAL)
-- Remove data item associated with key `k'.
do
if attached data as l_data then
l_data.remove (k)
end
end
note
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -0,0 +1,56 @@
note
description: "[
User profile used to extend information associated with a {CMS_USER}.
]"
date: "$Date$"
revision: "$Revision$"
class
CMS_USER_PROFILE
inherit
TABLE_ITERABLE [READABLE_STRING_8, READABLE_STRING_GENERAL]
create
make
feature {NONE} -- Initialization
make
-- Create Current profile.
do
create items.make (0)
end
feature -- Access
item (k: READABLE_STRING_GENERAL): detachable READABLE_STRING_8
-- Profile item associated with key `k'.
do
Result := items.item (k)
end
feature -- Change
force (v: READABLE_STRING_8; k: READABLE_STRING_GENERAL)
-- Associated value `v' with key `k'.
do
items.force (v, k)
end
feature -- Access
new_cursor: TABLE_ITERATION_CURSOR [READABLE_STRING_8, READABLE_STRING_GENERAL]
-- Fresh cursor associated with current structure
do
Result := items.new_cursor
end
feature {NONE} -- Implementation
items: STRING_TABLE [READABLE_STRING_8]
;note
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -0,0 +1,120 @@
note
description: "[
The user roles are used for the CMS permission system.
A role has a list of permissions, that describes what users of current role
are authorized to operation.
]"
date: "$Date$"
revision: "$Revision$"
class
CMS_USER_ROLE
inherit
ANY
redefine
is_equal
end
create
make,
make_with_id
feature {NONE} -- Initialization
make_with_id (a_id: like id; a_name: like name)
do
id := a_id
make (a_name)
end
make (a_name: like name)
do
name := a_name
create {ARRAYED_LIST [READABLE_STRING_8]} permissions.make (0)
end
feature -- Status report
has_id: BOOLEAN
-- Has a unique identifier?
do
Result := id > 0
end
has_permission (p: READABLE_STRING_8): BOOLEAN
-- Has permission `p'?
do
Result := across permissions as c some c.item.is_case_insensitive_equal (p) end
end
feature -- Access
id: INTEGER
-- Unique id associated with Current role.
name: READABLE_STRING_8
-- Name of Current role.
permissions: LIST [READABLE_STRING_8]
-- List of permissions.
feature -- Comparison
same_user_role (other: CMS_USER_ROLE): BOOLEAN
-- Is Current role same as role `other' ?
do
Result := other.id = id
end
is_equal (other: like Current): BOOLEAN
-- Is `other' attached to an object considered
-- equal to current object?
do
Result := id = other.id
end
feature -- Change
set_id (a_id: like id)
-- Set `id' with `a_id'.
do
id := a_id
ensure
set_id: id = a_id
end
set_name (a_name: like name)
-- Set `name' with `a_name'.
do
name := a_name
ensure
name_set: name = a_name
end
feature -- Permission change
add_permission (a_permission_name: READABLE_STRING_8)
-- Add permission `a_permission_name' to Current role.
require
is_not_blank: not a_permission_name.is_whitespace
do
permissions.force (a_permission_name)
ensure
has_permission: has_permission (a_permission_name)
end
remove_permission (a_permission_name: READABLE_STRING_8)
-- Remove permission `a_permission_name' from Current role.
require
is_not_blank: not a_permission_name.is_whitespace
do
permissions.prune_all (a_permission_name)
ensure
not_has_permission: not has_permission (a_permission_name)
end
note
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end