Refactor directory structrue
This commit is contained in:
19
library/model/cms_model-safe.ecf
Normal file
19
library/model/cms_model-safe.ecf
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="cms_model" uuid="57C6F407-E894-4554-8A59-C8D1F3BBC5D7" library_target="cms_model">
|
||||
<target name="cms_model">
|
||||
<root all_classes="True"/>
|
||||
<option warning="true">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY/library/base/base-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<cluster name="cms_model" location=".\src" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
3
library/model/license.lic
Normal file
3
library/model/license.lic
Normal file
@@ -0,0 +1,3 @@
|
||||
${NOTE_KEYWORD}
|
||||
copyright: "2011-${YEAR}, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
15
library/model/src/content/cms_content_type.e
Normal file
15
library/model/src/content/cms_content_type.e
Normal file
@@ -0,0 +1,15 @@
|
||||
note
|
||||
description: "[
|
||||
Interface defining a CMS content type.
|
||||
]"
|
||||
status: "draft"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_CONTENT_TYPE
|
||||
|
||||
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
|
||||
196
library/model/src/content/cms_node.e
Normal file
196
library/model/src/content/cms_node.e
Normal file
@@ -0,0 +1,196 @@
|
||||
note
|
||||
description: "[
|
||||
CMS abstraction for CMS content entity, named "node".
|
||||
]"
|
||||
status: "draft"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_NODE
|
||||
|
||||
inherit
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature{NONE} -- Initialization
|
||||
|
||||
make (a_content: READABLE_STRING_32; a_summary: READABLE_STRING_32; a_title: READABLE_STRING_32)
|
||||
-- Create current node with `a_content', `a_summary' and `a_title'.
|
||||
local
|
||||
l_time: DATE_TIME
|
||||
do
|
||||
create l_time.make_now_utc
|
||||
set_content (a_content)
|
||||
set_summary (a_summary)
|
||||
set_title (a_title)
|
||||
set_creation_date (l_time)
|
||||
set_modification_date (l_time)
|
||||
set_publication_date (l_time)
|
||||
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Remove default harcoded format")
|
||||
end
|
||||
set_format ("HTML")
|
||||
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Remove default harcoded content type")
|
||||
end
|
||||
set_content_type ("Page")
|
||||
ensure
|
||||
content_set: content = a_content
|
||||
summary_set: summary = a_summary
|
||||
title_set: title = a_title
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
id: INTEGER_64 assign set_id
|
||||
-- Unique id.
|
||||
|
||||
content: READABLE_STRING_32
|
||||
-- Content of the node.
|
||||
|
||||
summary: READABLE_STRING_32
|
||||
-- A short summary of the node.
|
||||
|
||||
title: READABLE_STRING_32
|
||||
-- Full title of the node.
|
||||
|
||||
modification_date: DATE_TIME
|
||||
-- When the node was updated.
|
||||
|
||||
creation_date: DATE_TIME
|
||||
-- When the node was created.
|
||||
|
||||
publication_date: DATE_TIME
|
||||
-- When the node was published.
|
||||
|
||||
publication_date_output: READABLE_STRING_32
|
||||
-- Formatted output.
|
||||
|
||||
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.
|
||||
|
||||
author: detachable CMS_USER
|
||||
-- Author of current node.
|
||||
|
||||
collaborators: detachable LIST[CMS_USER]
|
||||
-- Users contributed to current Node.
|
||||
|
||||
feature -- status report
|
||||
|
||||
has_id: BOOLEAN
|
||||
-- Has unique identifier?
|
||||
do
|
||||
Result := id > 0
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_content (a_content: like content)
|
||||
-- Assign `content' with `a_content'.
|
||||
do
|
||||
content := a_content
|
||||
ensure
|
||||
content_assigned: content = a_content
|
||||
end
|
||||
|
||||
set_summary (a_summary: like summary)
|
||||
-- Assign `summary' with `a_summary'.
|
||||
do
|
||||
summary := a_summary
|
||||
ensure
|
||||
summary_assigned: summary = a_summary
|
||||
end
|
||||
|
||||
set_title (a_title: like title)
|
||||
-- Assign `title' with `a_title'.
|
||||
do
|
||||
title := a_title
|
||||
ensure
|
||||
title_assigned: title = a_title
|
||||
end
|
||||
|
||||
set_modification_date (a_modification_date: like modification_date)
|
||||
-- Assign `modification_date' with `a_modification_date'.
|
||||
do
|
||||
modification_date := a_modification_date
|
||||
ensure
|
||||
modification_date_assigned: modification_date = a_modification_date
|
||||
end
|
||||
|
||||
set_creation_date (a_creation_date: like creation_date)
|
||||
-- Assign `creation_date' with `a_creation_date'.
|
||||
do
|
||||
creation_date := a_creation_date
|
||||
ensure
|
||||
creation_date_assigned: creation_date = a_creation_date
|
||||
end
|
||||
|
||||
set_publication_date (a_publication_date: like publication_date)
|
||||
-- Assign `publication_date' with `a_publication_date'.
|
||||
do
|
||||
publication_date := a_publication_date
|
||||
publication_date_output := publication_date.formatted_out ("yyyy/[0]mm/[0]dd")
|
||||
ensure
|
||||
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
|
||||
id := an_id
|
||||
ensure
|
||||
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
|
||||
|
||||
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
|
||||
53
library/model/src/link/cms_external_link.e
Normal file
53
library/model/src/link/cms_external_link.e
Normal file
@@ -0,0 +1,53 @@
|
||||
note
|
||||
description: "[
|
||||
Abstraction to represent a link outside current CMS system.
|
||||
For instance, a web url.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision: 95883 $"
|
||||
|
||||
class
|
||||
CMS_EXTERNAL_LINK
|
||||
|
||||
inherit
|
||||
CMS_LINK
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_title: like title; a_location: like location)
|
||||
-- Create current external link with optional title `a_title' and location `a_location'.
|
||||
do
|
||||
title := a_title
|
||||
location := a_location
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_active: BOOLEAN = False
|
||||
-- <Precursor>
|
||||
|
||||
is_expanded: BOOLEAN = False
|
||||
-- <Precursor>
|
||||
|
||||
is_collapsed: BOOLEAN = False
|
||||
-- <Precursor>
|
||||
|
||||
is_expandable: BOOLEAN = False
|
||||
-- <Precursor>
|
||||
|
||||
has_children: BOOLEAN = False
|
||||
-- <Precursor>
|
||||
|
||||
feature -- Access
|
||||
|
||||
children: detachable LIST [CMS_LINK]
|
||||
-- <Precursor>
|
||||
|
||||
invariant
|
||||
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
|
||||
92
library/model/src/link/cms_link.e
Normal file
92
library/model/src/link/cms_link.e
Normal file
@@ -0,0 +1,92 @@
|
||||
note
|
||||
description: "[
|
||||
Abstraction to represent a URI link in the CMS system.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_LINK
|
||||
|
||||
inherit
|
||||
REFACTORING_HELPER
|
||||
|
||||
DEBUG_OUTPUT
|
||||
|
||||
ITERABLE [CMS_LINK]
|
||||
|
||||
feature -- Access
|
||||
|
||||
title: READABLE_STRING_32
|
||||
-- Associated title.
|
||||
|
||||
location: READABLE_STRING_8
|
||||
-- Associated url location.
|
||||
|
||||
feature -- status report
|
||||
|
||||
is_active: BOOLEAN
|
||||
-- Is current link active?
|
||||
-- i.e: related to requested url.
|
||||
deferred
|
||||
end
|
||||
|
||||
is_expanded: BOOLEAN
|
||||
-- Is expanded and visually expanded?
|
||||
deferred
|
||||
end
|
||||
|
||||
is_collapsed: BOOLEAN
|
||||
-- Is expanded, but visually collapsed?
|
||||
deferred
|
||||
ensure
|
||||
Result implies is_expandable
|
||||
end
|
||||
|
||||
is_expandable: BOOLEAN
|
||||
-- Is expandable?
|
||||
deferred
|
||||
end
|
||||
|
||||
has_children: BOOLEAN
|
||||
-- Has sub link?
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
parent: detachable CMS_LINK
|
||||
-- Optional parent link.
|
||||
|
||||
children: detachable LIST [CMS_LINK]
|
||||
-- Optional children links.
|
||||
-- Useful to have a non flat menu.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: ITERATION_CURSOR [CMS_LINK]
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
if attached children as lst then
|
||||
Result := lst.new_cursor
|
||||
else
|
||||
Result := (create {ARRAYED_LIST [CMS_LINK]}.make (0)).new_cursor
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
debug_output: STRING_32
|
||||
-- String that should be displayed in debugger to represent `Current'.
|
||||
do
|
||||
create Result.make_from_string (title)
|
||||
Result.append_string_general (" -> ")
|
||||
Result.append_string_general (location)
|
||||
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
|
||||
52
library/model/src/link/cms_link_composite.e
Normal file
52
library/model/src/link/cms_link_composite.e
Normal file
@@ -0,0 +1,52 @@
|
||||
note
|
||||
description: "[
|
||||
Abstraction to represent a links container in the CMS system.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_LINK_COMPOSITE
|
||||
|
||||
inherit
|
||||
ITERABLE [CMS_LINK]
|
||||
|
||||
feature -- Access
|
||||
|
||||
items: detachable LIST [CMS_LINK]
|
||||
-- Children links.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
extend (lnk: CMS_LINK)
|
||||
-- Add `lnk' as a sub link.
|
||||
deferred
|
||||
end
|
||||
|
||||
remove (lnk: CMS_LINK)
|
||||
-- Remove link `lnk' from Current container.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- status report
|
||||
|
||||
is_empty: BOOLEAN
|
||||
-- Is container empty?
|
||||
do
|
||||
Result := not attached items as l_items or else l_items.is_empty
|
||||
end
|
||||
|
||||
count: INTEGER
|
||||
-- Number of immediate sub links.
|
||||
do
|
||||
if attached items as l_items then
|
||||
Result := l_items.count
|
||||
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
|
||||
173
library/model/src/link/cms_local_link.e
Normal file
173
library/model/src/link/cms_local_link.e
Normal file
@@ -0,0 +1,173 @@
|
||||
note
|
||||
description: "[
|
||||
Abstraction to represent a link to a CMS resource.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_LOCAL_LINK
|
||||
|
||||
inherit
|
||||
CMS_LINK
|
||||
|
||||
CMS_LINK_COMPOSITE
|
||||
rename
|
||||
items as children,
|
||||
extend as add_link,
|
||||
remove as remove_link
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_title: detachable like title; a_location: like location)
|
||||
-- Create current local link with optional title `a_title' and location `a_location'.
|
||||
do
|
||||
if a_title /= Void then
|
||||
title := a_title
|
||||
else
|
||||
title := a_location
|
||||
end
|
||||
location := a_location
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
permission_arguments: detachable ITERABLE [READABLE_STRING_8]
|
||||
-- Permissions required by current link resource.
|
||||
|
||||
children: detachable LIST [CMS_LINK]
|
||||
-- <Precursor>
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_active: BOOLEAN
|
||||
-- <Precursor>
|
||||
|
||||
is_expanded: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := is_expandable and then internal_is_expanded
|
||||
end
|
||||
|
||||
is_collapsed: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := is_expandable and then internal_is_collapsed
|
||||
end
|
||||
|
||||
is_expandable: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := internal_is_expandable or internal_is_expanded or has_children
|
||||
end
|
||||
|
||||
has_children: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := attached children as l_children and then not l_children.is_empty
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
add_link (lnk: CMS_LINK)
|
||||
-- <Precursor>
|
||||
local
|
||||
lst: like children
|
||||
do
|
||||
lst := children
|
||||
if lst = Void then
|
||||
create {ARRAYED_LIST [CMS_LINK]} lst.make (1)
|
||||
children := lst
|
||||
end
|
||||
lst.force (lnk)
|
||||
end
|
||||
|
||||
remove_link (lnk: CMS_LINK)
|
||||
-- <Precursor>
|
||||
local
|
||||
lst: like children
|
||||
do
|
||||
lst := children
|
||||
if lst /= Void then
|
||||
lst.prune_all (lnk)
|
||||
if lst.is_empty then
|
||||
children := Void
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_children (lst: like children)
|
||||
-- Set `children' to `lst'.
|
||||
do
|
||||
children := lst
|
||||
ensure
|
||||
children_set: children = lst
|
||||
end
|
||||
|
||||
set_permission_arguments (args: like permission_arguments)
|
||||
-- Set `permission_arguments' to `args'.
|
||||
do
|
||||
permission_arguments := args
|
||||
ensure
|
||||
permission_arguments_set: permission_arguments = args
|
||||
end
|
||||
|
||||
feature -- Status change
|
||||
|
||||
set_is_active (b: BOOLEAN)
|
||||
-- Set `is_active' to `b'.
|
||||
do
|
||||
is_active := b
|
||||
ensure
|
||||
is_active: is_active = b
|
||||
end
|
||||
|
||||
set_expanded (b: like is_expanded)
|
||||
-- Set `is_expanded' to `b'.
|
||||
do
|
||||
if b then
|
||||
set_expandable (True)
|
||||
set_collapsed (False)
|
||||
end
|
||||
internal_is_expanded := b
|
||||
ensure
|
||||
is_expanded: is_expanded = b
|
||||
end
|
||||
|
||||
set_collapsed (b: like is_collapsed)
|
||||
-- Set `is_collapsed' to `b'.
|
||||
do
|
||||
if b then
|
||||
set_expanded (False)
|
||||
end
|
||||
internal_is_collapsed := b
|
||||
ensure
|
||||
is_collapsed: is_collapsed= b
|
||||
end
|
||||
|
||||
set_expandable (b: like is_expandable)
|
||||
-- Set `is_expandable' to `b'.
|
||||
do
|
||||
internal_is_expandable := b
|
||||
ensure
|
||||
is_expandable: is_expandable = b
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
internal_is_expandable: BOOLEAN
|
||||
|
||||
internal_is_expanded: BOOLEAN
|
||||
|
||||
internal_is_collapsed: BOOLEAN
|
||||
|
||||
invariant
|
||||
|
||||
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
|
||||
96
library/model/src/link/cms_menu.e
Normal file
96
library/model/src/link/cms_menu.e
Normal file
@@ -0,0 +1,96 @@
|
||||
note
|
||||
description: "[
|
||||
Abstraction to represent a MENU in the CMS system.
|
||||
It has items as sub menu/link.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_MENU
|
||||
|
||||
inherit
|
||||
CMS_LINK_COMPOSITE
|
||||
redefine
|
||||
is_empty
|
||||
end
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_title
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: like name; a_capacity: INTEGER)
|
||||
-- Create menu with name `a_name' and a capacity of `a_capacity'.
|
||||
do
|
||||
name := a_name
|
||||
create items.make (a_capacity)
|
||||
ensure
|
||||
name_set: name = a_name
|
||||
items_set: items.capacity = a_capacity
|
||||
end
|
||||
|
||||
make_with_title (a_name: like name; a_title: READABLE_STRING_32; a_capacity: INTEGER)
|
||||
-- Create menu with name `a_name' and a capacity of `a_capacity', and title `a_title'
|
||||
do
|
||||
make (a_name, a_capacity)
|
||||
set_title (a_title)
|
||||
ensure
|
||||
name_set: name = a_name
|
||||
title_set: title = a_title
|
||||
items_set: items.capacity = a_capacity
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: READABLE_STRING_8
|
||||
-- Identifier for Current menu.
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
-- Optional title.
|
||||
|
||||
items: ARRAYED_LIST [CMS_LINK]
|
||||
-- <Precursor>
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_empty: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := items.is_empty
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
extend (lnk: CMS_LINK)
|
||||
-- <Precursor>
|
||||
do
|
||||
items.extend (lnk)
|
||||
end
|
||||
|
||||
remove (lnk: CMS_LINK)
|
||||
-- <Precursor>
|
||||
do
|
||||
items.prune_all (lnk)
|
||||
end
|
||||
|
||||
set_title (t: like title)
|
||||
do
|
||||
title := t
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: ITERATION_CURSOR [CMS_LINK]
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
Result := items.new_cursor
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
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
|
||||
184
library/model/src/user/cms_user.e
Normal file
184
library/model/src/user/cms_user.e
Normal 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
|
||||
56
library/model/src/user/cms_user_profile.e
Normal file
56
library/model/src/user/cms_user_profile.e
Normal 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
|
||||
120
library/model/src/user/cms_user_role.e
Normal file
120
library/model/src/user/cms_user_role.e
Normal 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
|
||||
Reference in New Issue
Block a user