Updated navigation templte to include current user.
Updated CMS_NODE, CMS_USER. Added USER_PROFILE and USER_ROLE Updated new USER_DATA_PROVIDER and NODE_DATA_PROVIDER to support new features. Added ROLE_DATA_PROVIDER. Updated test cases. Updated MySQL database schema.
This commit is contained in:
@@ -6,6 +6,10 @@ note
|
||||
class
|
||||
CMS_NODE
|
||||
|
||||
inherit
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
@@ -21,6 +25,10 @@ feature{NONE} -- Initialization
|
||||
set_creation_date (l_time)
|
||||
set_modification_date (l_time)
|
||||
set_publication_date (l_time)
|
||||
fixme ("Remove harcode format")
|
||||
set_format ("HTML")
|
||||
fixme ("Remove harcode content type")
|
||||
set_content_type ("Page")
|
||||
ensure
|
||||
content_set: content = a_content
|
||||
summary_set: summary = a_summary
|
||||
@@ -48,10 +56,32 @@ feature -- Access
|
||||
-- When the node was published.
|
||||
|
||||
publication_date_output: READABLE_STRING_32
|
||||
-- Formatted output.
|
||||
|
||||
id: INTEGER_64 assign set_id
|
||||
-- Unique id.
|
||||
|
||||
format: READABLE_STRING_32
|
||||
-- Format associated with `body'.
|
||||
-- For example: text, mediawiki, html, etc
|
||||
|
||||
content_type: READABLE_STRING_32
|
||||
-- Associated content type name.
|
||||
-- Page, Article, Blog, News, etc.
|
||||
|
||||
feature -- status report
|
||||
|
||||
has_id: BOOLEAN
|
||||
do
|
||||
Result := id > 0
|
||||
end
|
||||
|
||||
author: detachable CMS_USER
|
||||
-- Node's author.
|
||||
|
||||
collaborators: detachable LIST[CMS_USER]
|
||||
-- Node's collaborators.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_content (a_content: like content)
|
||||
@@ -103,6 +133,22 @@ feature -- Element change
|
||||
publication_date_assigned: publication_date = a_publication_date
|
||||
end
|
||||
|
||||
set_content_type (a_content_type: like content_type)
|
||||
-- Assign `content_type' with `a_content_type'.
|
||||
do
|
||||
content_type := a_content_type
|
||||
ensure
|
||||
content_type_assigned: content_type = a_content_type
|
||||
end
|
||||
|
||||
set_format (a_format: like format)
|
||||
-- Assign `format' with `a_format'.
|
||||
do
|
||||
format := a_format
|
||||
ensure
|
||||
format_assigned: format = a_format
|
||||
end
|
||||
|
||||
set_id (an_id: like id)
|
||||
-- Assign `id' with `an_id'.
|
||||
do
|
||||
@@ -111,4 +157,25 @@ feature -- Element change
|
||||
id_assigned: id = an_id
|
||||
end
|
||||
|
||||
set_author (u: like author)
|
||||
-- Assign 'author' with `u'
|
||||
do
|
||||
author := u
|
||||
ensure
|
||||
auther_set: author = u
|
||||
end
|
||||
|
||||
add_collaborator (a_user: CMS_USER)
|
||||
-- Add collaborator `a_user' to the collaborators list.
|
||||
local
|
||||
lst: like collaborators
|
||||
do
|
||||
lst := collaborators
|
||||
if lst = Void then
|
||||
create {ARRAYED_SET [CMS_USER]} lst.make (1)
|
||||
collaborators := lst
|
||||
end
|
||||
lst.force (a_user)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -6,6 +6,10 @@ note
|
||||
class
|
||||
CMS_USER
|
||||
|
||||
inherit
|
||||
|
||||
DEBUG_OUTPUT
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
@@ -15,6 +19,9 @@ feature {NONE} -- Initialization
|
||||
-- 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
|
||||
@@ -31,6 +38,48 @@ feature -- Access
|
||||
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.
|
||||
|
||||
data: detachable STRING_TABLE [detachable ANY]
|
||||
-- Additional user's data.
|
||||
|
||||
data_item (k: READABLE_STRING_GENERAL): detachable ANY
|
||||
-- Additional item data.
|
||||
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
|
||||
do
|
||||
Result := name
|
||||
end
|
||||
|
||||
same_as (u: detachable CMS_USER): BOOLEAN
|
||||
do
|
||||
Result := u /= Void and then id = u.id
|
||||
end
|
||||
|
||||
feature -- Change element
|
||||
|
||||
set_id (a_id: like id)
|
||||
@@ -65,4 +114,53 @@ feature -- Change element
|
||||
email_set: email = m
|
||||
end
|
||||
|
||||
set_profile (prof: like profile)
|
||||
-- Set `profile' with `prof'.
|
||||
do
|
||||
profile := prof
|
||||
ensure
|
||||
profile_set: profile = prof
|
||||
end
|
||||
|
||||
set_data_item (k: READABLE_STRING_GENERAL; d: like data_item)
|
||||
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)
|
||||
do
|
||||
if attached data as l_data then
|
||||
l_data.remove (k)
|
||||
end
|
||||
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
|
||||
|
||||
end
|
||||
|
||||
48
persistence/implementation/common/model/cms_user_profile.e
Normal file
48
persistence/implementation/common/model/cms_user_profile.e
Normal file
@@ -0,0 +1,48 @@
|
||||
note
|
||||
description: "Summary description for {CMS_USER_PROFILE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_USER_PROFILE
|
||||
|
||||
inherit
|
||||
TABLE_ITERABLE [READABLE_STRING_8, READABLE_STRING_8]
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
create items.make (0)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
item (k: READABLE_STRING_8): detachable READABLE_STRING_8
|
||||
do
|
||||
Result := items.item (k.as_string_8)
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
force (v: READABLE_STRING_8; k: READABLE_STRING_8)
|
||||
do
|
||||
items.force (v, k.as_string_8)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: TABLE_ITERATION_CURSOR [READABLE_STRING_8, READABLE_STRING_8]
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
Result := items.new_cursor
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
items: HASH_TABLE [READABLE_STRING_8, STRING_8]
|
||||
|
||||
end
|
||||
90
persistence/implementation/common/model/cms_user_role.e
Normal file
90
persistence/implementation/common/model/cms_user_role.e
Normal file
@@ -0,0 +1,90 @@
|
||||
note
|
||||
description: "Summary description for {CMS_USER_ROLE}."
|
||||
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
|
||||
do
|
||||
Result := id > 0
|
||||
end
|
||||
|
||||
has_permission (p: READABLE_STRING_8): BOOLEAN
|
||||
do
|
||||
Result := across permissions as c some c.item.is_case_insensitive_equal (p) end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
id: INTEGER
|
||||
|
||||
name: READABLE_STRING_8
|
||||
|
||||
permissions: LIST [READABLE_STRING_8]
|
||||
|
||||
feature -- Comparison
|
||||
|
||||
same_user_role (r: CMS_USER_ROLE): BOOLEAN
|
||||
do
|
||||
Result := r.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
|
||||
|
||||
add_permission (n: READABLE_STRING_8)
|
||||
do
|
||||
permissions.force (n)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user