diff --git a/tpl/site/scripts/user.sql b/modules/core/site/scripts/core.sql
similarity index 73%
rename from tpl/site/scripts/user.sql
rename to modules/core/site/scripts/core.sql
index e9efdc1..4f09aef 100644
--- a/tpl/site/scripts/user.sql
+++ b/modules/core/site/scripts/core.sql
@@ -1,4 +1,29 @@
+CREATE TABLE `logs`(
+ `id` INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
+ `category` VARCHAR(255) NOT NULL,
+ `level` INTEGER NOT NULL,
+ `uid` INTEGER,
+ `message` TEXT NOT NULL,
+ `info` TEXT,
+ `link` TEXT,
+ `date` DATETIME NOT NULL
+);
+
+CREATE TABLE `custom_values`(
+ `type` VARCHAR(255) NOT NULL,
+ `name` VARCHAR(255) NOT NULL,
+ `value` TEXT
+);
+
+CREATE TABLE `path_aliases`(
+ `pid` INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
+ `source` VARCHAR(255) NOT NULL,
+ `alias` VARCHAR(255) NOT NULL,
+ `lang` VARCHAR(12)
+);
+
+
CREATE TABLE `users`(
`uid` INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
`name` VARCHAR(100) NOT NULL,
@@ -8,6 +33,7 @@ CREATE TABLE `users`(
`status` INTEGER,
`created` DATETIME NOT NULL,
`signed` DATETIME,
+ `profile_name` VARCHAR(250) NULL,
CONSTRAINT `name`
UNIQUE(`name`)
);
@@ -46,6 +72,7 @@ CREATE TABLE `users_password_recovery` (
CONSTRAINT `token` UNIQUE (`token`)
);
+
CREATE TABLE `auth_temp_users` (
`uid` INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
`name` VARCHAR(100) NOT NULL,
diff --git a/modules/node/handler/cms_node_type_webform_manager.e b/modules/node/handler/cms_node_type_webform_manager.e
index 0ec2c44..a87dc08 100644
--- a/modules/node/handler/cms_node_type_webform_manager.e
+++ b/modules/node/handler/cms_node_type_webform_manager.e
@@ -263,7 +263,7 @@ feature -- Forms ...
feature -- Output
- append_content_as_html_to (a_node: G; is_teaser: BOOLEAN; a_output: STRING; a_response: detachable CMS_RESPONSE)
+ append_content_as_html_to (a_node: G; is_teaser: BOOLEAN; a_output: STRING; a_response: CMS_RESPONSE)
--
local
lnk: detachable CMS_LOCAL_LINK
@@ -275,7 +275,6 @@ feature -- Output
-- Show tabs only if a user is authenticated.
if
not is_teaser and then
- a_response /= Void and then
attached a_response.user as l_user
then
lnk := a_node.link
@@ -322,7 +321,7 @@ feature -- Output
a_output.append ("
")
if attached a_node.author as l_author then
a_output.append (" by ")
- a_output.append (l_node_api.html_encoded (l_author.name))
+ a_output.append (a_response.html_encoded (a_response.user_profile_name (l_author)))
end
if attached a_node.modification_date as l_modified then
a_output.append (" (modified: ")
@@ -333,7 +332,6 @@ feature -- Output
a_output.append ("
")
if
- a_response /= Void and then
attached {CMS_TAXONOMY_API} cms_api.module_api ({CMS_TAXONOMY_MODULE}) as l_taxonomy_api
then
l_taxonomy_api.append_taxonomy_to_xhtml (a_node, a_response, a_output)
@@ -368,7 +366,7 @@ feature -- Output
a_output.append ("")
end
- append_comments_as_html_to (a_node: G; a_output: STRING; a_response: detachable CMS_RESPONSE)
+ append_comments_as_html_to (a_node: G; a_output: STRING; a_response: CMS_RESPONSE)
do
if attached {CMS_COMMENTS_API} cms_api.module_api ({CMS_COMMENTS_MODULE}) as l_comments_api then
if attached l_comments_api.comments_for (a_node) as l_comments and then not l_comments.is_empty then
@@ -383,14 +381,14 @@ feature -- Output
end
end
- append_comment_as_html_to (a_comment: CMS_COMMENT; a_output: STRING; a_response: detachable CMS_RESPONSE)
+ append_comment_as_html_to (a_comment: CMS_COMMENT; a_output: STRING; a_response: CMS_RESPONSE)
local
l_ago: DATE_TIME_AGO_CONVERTER
do
a_output.append ("
")
if attached a_comment.author as l_author then
a_output.append ("")
- a_output.append (cms_api.html_encoded (l_author.name))
+ a_output.append (a_response.html_encoded (a_response.user_profile_name (l_author)))
a_output.append ("")
elseif attached a_comment.author_name as l_author_name then
a_output.append ("")
diff --git a/modules/node/handler/cms_page_node_type_webform_manager.e b/modules/node/handler/cms_page_node_type_webform_manager.e
index 7ee21f2..41a0f2f 100644
--- a/modules/node/handler/cms_page_node_type_webform_manager.e
+++ b/modules/node/handler/cms_page_node_type_webform_manager.e
@@ -150,7 +150,7 @@ feature -- Forms ...
feature -- Output
- append_content_as_html_to (a_node: CMS_PAGE; is_teaser: BOOLEAN; a_output: STRING; a_response: detachable CMS_RESPONSE)
+ append_content_as_html_to (a_node: CMS_PAGE; is_teaser: BOOLEAN; a_output: STRING; a_response: CMS_RESPONSE)
--
local
l_node_api: CMS_NODE_API
diff --git a/modules/node/submodules/page/cms_page_module.e b/modules/node/submodules/page/cms_page_module.e
index 68a2d4c..29d5428 100644
--- a/modules/node/submodules/page/cms_page_module.e
+++ b/modules/node/submodules/page/cms_page_module.e
@@ -101,7 +101,7 @@ feature {CMS_API} -- Module management
do
-- Schema
if attached a_api.storage.as_sql_storage as l_sql_storage then
- if attached a_api.module ({CMS_NODE_MODULE}) as l_node_module then
+ if attached a_api.installed_module ({CMS_NODE_MODULE}) as l_node_module then
l_sql_storage.sql_execute_file_script (a_api.module_resource_location (l_node_module, (create {PATH}.make_from_string ("scripts")).extended (name).appended_with_extension ("sql")), Void)
end
if l_sql_storage.has_error then
diff --git a/modules/oauth20/cms_oauth_20_module.e b/modules/oauth20/cms_oauth_20_module.e
index 9e615eb..8c25424 100644
--- a/modules/oauth20/cms_oauth_20_module.e
+++ b/modules/oauth20/cms_oauth_20_module.e
@@ -84,13 +84,13 @@ feature {CMS_API} -- Module management
-- Schema
if attached api.storage.as_sql_storage as l_sql_storage then
--| Schema
- l_sql_storage.sql_execute_file_script (api.module_resource_location (Current, (create {PATH}.make_from_string ("scripts")).extended ("oauth2_consumers.sql")), Void)
+ l_sql_storage.sql_execute_file_script (api.module_resource_location (Current, (create {PATH}.make_from_string ("scripts")).extended ("install.sql")), Void)
if l_sql_storage.has_error then
api.logger.put_error ("Could not initialize database for module [" + name + "]", generating_type)
else
-- TODO workaround.
- l_sql_storage.sql_execute_file_script (api.module_resource_location (Current, (create {PATH}.make_from_string ("scripts")).extended ("oauth2_consumers_initialize.sql")), Void)
+ l_sql_storage.sql_execute_file_script (api.module_resource_location (Current, (create {PATH}.make_from_string ("scripts")).extended ("data.sql")), Void)
if l_sql_storage.has_error then
api.logger.put_error ("Could not initialize oauth2_consumers for module [" + name + "]", generating_type)
else
diff --git a/modules/oauth20/site/scripts/data.sql b/modules/oauth20/site/scripts/data.sql
new file mode 100644
index 0000000..a600e71
--- /dev/null
+++ b/modules/oauth20/site/scripts/data.sql
@@ -0,0 +1,7 @@
+ -- Change the values TO_COMPLETE based on your API.
+ -- API SECTET KEY AND API PUBLIC KEY
+INSERT INTO oauth2_consumers (name, api_secret, api_key, scope, protected_resource_url, callback_name, extractor, authorize_url, endpoint)
+VALUES ('google', 'TO-COMPLETE', 'TO-COMPLETE', 'email', 'https://www.googleapis.com/plus/v1/people/me', 'callback_google', 'json','https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=$CLIENT_ID&redirect_uri=$REDIRECT_URI','https://accounts.google.com/o/oauth2/token');
+
+INSERT INTO oauth2_consumers (name, api_secret, api_key, scope, protected_resource_url, callback_name, extractor, authorize_url, endpoint )
+VALUES ('facebook', 'TO-COMPLETE', 'TO-COMPLETE', 'email', 'https://graph.facebook.com/me', 'callback_facebook','text','https://www.facebook.com/dialog/oauth?response_type=code&client_id=$CLIENT_ID&redirect_uri=$REDIRECT_URI','https://graph.facebook.com/oauth/access_token');
diff --git a/modules/oauth20/site/scripts/install.sql b/modules/oauth20/site/scripts/install.sql
new file mode 100644
index 0000000..1c7eea6
--- /dev/null
+++ b/modules/oauth20/site/scripts/install.sql
@@ -0,0 +1,18 @@
+
+CREATE TABLE oauth2_consumers(
+ `cid` INTEGER PRIMARY KEY NOT NULL CHECK(`cid`>=0),
+ `name` VARCHAR(255) NOT NULL,
+ `api_secret` TEXT NOT NULL,
+ `api_key` TEXT NOT NULL,
+ `scope` VARCHAR (100) NOT NULL,
+ `protected_resource_url` VARCHAR (255) NOT NULL,
+ `callback_name` VARCHAR(255) NOT NULL,
+ `extractor` VARCHAR(50) NOT NULL,
+ `authorize_url` VARCHAR (255) NOT NULL,
+ `endpoint` VARCHAR (255) NOT NULL,
+ CONSTRAINT `cid`
+ UNIQUE(`cid`),
+ CONSTRAINT `name`
+ UNIQUE(`name`)
+ );
+
diff --git a/modules/session_auth/cms_session_auth_module.e b/modules/session_auth/cms_session_auth_module.e
index bc9b53c..b9f4e5b 100644
--- a/modules/session_auth/cms_session_auth_module.e
+++ b/modules/session_auth/cms_session_auth_module.e
@@ -34,6 +34,7 @@ feature {NONE} -- Initialization
Precursor
version := "1.0"
description := "Service to manage cookie based authentication"
+ enable -- Enabled by default
end
feature -- Access
diff --git a/src/configuration/cms_setup.e b/src/configuration/cms_setup.e
index 176d4ea..5c2d179 100644
--- a/src/configuration/cms_setup.e
+++ b/src/configuration/cms_setup.e
@@ -115,32 +115,59 @@ feature -- Access
feature {CMS_API} -- API Access
- enabled_modules: CMS_MODULE_COLLECTION
+ frozen fill_enabled_modules (api: CMS_API)
-- List of enabled modules.
local
+ l_enabled_modules: CMS_MODULE_COLLECTION
+ l_modules_to_remove: CMS_MODULE_COLLECTION
l_module: CMS_MODULE
+ l_core: CMS_CORE_MODULE
do
- create Result.make (modules.count)
+ l_enabled_modules := api.enabled_modules
+
+ -- Include required CORE module
+ create l_core.make
+ l_core.enable
+ l_enabled_modules.extend (l_core)
+
+ -- Includes other modules.
across
modules as ic
loop
l_module := ic.item
update_module_status_from_configuration (l_module)
+ if not l_module.is_enabled then
+ if
+ api.is_module_enabled (l_module) -- Check from storage!
+ then
+ l_module.enable
+ end
+ end
if l_module.is_enabled then
- Result.extend (l_module)
+ l_enabled_modules.extend (l_module)
end
end
across
- Result as ic
+ l_enabled_modules as ic
loop
l_module := ic.item
- update_module_status_within (l_module, Result)
- if not l_module.is_enabled then
- Result.remove (l_module)
+ update_module_status_within (l_module, l_enabled_modules)
+ if not l_module.is_enabled then -- Check from storage!
+ if l_modules_to_remove = Void then
+ create l_modules_to_remove.make (1)
+ end
+ l_modules_to_remove.extend (l_module)
+ end
+ end
+ if l_modules_to_remove /= Void then
+ across
+ l_modules_to_remove as ic
+ loop
+ l_enabled_modules.remove (ic.item)
end
end
ensure
- only_enabled_modules: across Result as ic all ic.item.is_enabled end
+ only_enabled_modules: across api.enabled_modules as ic all ic.item.is_enabled end
end
feature {CMS_MODULE, CMS_API, CMS_SETUP_ACCESS} -- Restricted access
@@ -184,11 +211,11 @@ feature {NONE} -- Implementation: update
b: BOOLEAN
dft: BOOLEAN
do
- -- By default enabled.
- if false and attached text_item ("modules.*") as l_mod_status then
+ -- By default, keep previous status.
+ if attached text_item ("modules.*") as l_mod_status then
dft := l_mod_status.is_case_insensitive_equal_general ("on")
else
- dft := True
+ dft := m.is_enabled
end
if attached text_item ("modules." + m.name) as l_mod_status then
b := l_mod_status.is_case_insensitive_equal_general ("on")
@@ -430,6 +457,6 @@ feature -- Element change
end
note
- copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
+ copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end
diff --git a/src/modules/cms_core_module.e b/src/modules/cms_core_module.e
new file mode 100644
index 0000000..1a6dafb
--- /dev/null
+++ b/src/modules/cms_core_module.e
@@ -0,0 +1,115 @@
+note
+ description: "Module for core functionalities"
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ CMS_CORE_MODULE
+
+inherit
+ CMS_MODULE
+ redefine
+ initialize,
+ install
+ end
+
+create
+ make
+
+feature {NONE} -- Initialization
+
+ make
+ do
+ version := "1.0.0.1"
+ description := "Core"
+ package := "core"
+ end
+
+feature -- Access
+
+ name: STRING = "core"
+
+feature {CMS_API} -- Module Initialization
+
+ initialize (api: CMS_API)
+ --
+ do
+ Precursor (api)
+ end
+
+feature {CMS_API} -- Module management
+
+ install (a_api: CMS_API)
+ do
+ -- Schema
+ if attached a_api.storage.as_sql_storage as l_sql_storage then
+ l_sql_storage.sql_execute_file_script (a_api.module_resource_location (Current, (create {PATH}.make_from_string ("scripts")).extended (name + ".sql")), Void)
+
+ if l_sql_storage.has_error then
+ a_api.logger.put_error ("Could not initialize database for module [" + name + "]", generating_type)
+ else
+ Precursor {CMS_MODULE} (a_api)
+ end
+ end
+
+ install_core_data (a_api)
+ end
+
+ install_core_data (a_api: CMS_API)
+ local
+ u: CMS_USER
+ l_anonymous_role, l_authenticated_role: CMS_USER_ROLE
+ do
+ --| Roles
+ create l_anonymous_role.make ("anonymous")
+ a_api.user_api.save_user_role (l_anonymous_role)
+
+ create l_authenticated_role.make ("authenticated")
+ a_api.user_api.save_user_role (l_authenticated_role)
+
+ --| Users
+ create u.make ("admin")
+ u.set_password ("istrator#")
+ u.set_email (a_api.setup.site_email)
+ u.set_status ({CMS_USER}.active)
+ a_api.user_api.new_user (u)
+
+ --| Node
+ -- FIXME: move that initialization to node module
+ -- TODO: should we move the initialization to an
+ --! external configuration file?
+ --! at the moment we only have 1 admin to the whole site.
+ --! is that ok?
+ l_anonymous_role.add_permission ("view any page")
+ a_api.user_api.save_user_role (l_anonymous_role)
+
+ l_authenticated_role.add_permission ("create page")
+ l_authenticated_role.add_permission ("view any page")
+ l_authenticated_role.add_permission ("edit any page")
+ l_authenticated_role.add_permission ("delete page")
+ l_authenticated_role.add_permission ("trash page")
+ l_authenticated_role.add_permission ("view own page")
+ l_authenticated_role.add_permission ("edit own page")
+ l_authenticated_role.add_permission ("delete own page")
+ l_authenticated_role.add_permission ("trash own page")
+ a_api.user_api.save_user_role (l_authenticated_role)
+ end
+
+feature -- Router
+
+ setup_router (a_router: WSF_ROUTER; a_api: CMS_API)
+ --
+ do
+ end
+
+note
+ copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
+ license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
+ source: "[
+ Eiffel Software
+ 5949 Hollister Ave., Goleta, CA 93117 USA
+ Telephone 805-685-1006, Fax 805-685-6869
+ Website http://www.eiffel.com
+ Customer support http://support.eiffel.com
+ ]"
+end
diff --git a/src/persistence/sql/cms_storage_sql_builder.e b/src/persistence/sql/cms_storage_sql_builder.e
index 5cead4c..c9f0452 100644
--- a/src/persistence/sql/cms_storage_sql_builder.e
+++ b/src/persistence/sql/cms_storage_sql_builder.e
@@ -16,50 +16,11 @@ inherit
feature -- Initialization
initialize (a_setup: CMS_SETUP; a_storage: CMS_STORAGE_SQL)
- local
- u: CMS_USER
- l_anonymous_role, l_authenticated_role: CMS_USER_ROLE
do
- --| Schema
- a_storage.sql_execute_file_script (a_setup.environment.site_path.extended ("scripts").extended ("core.sql"), Void)
- a_storage.sql_execute_file_script (a_setup.environment.site_path.extended ("scripts").extended ("user.sql"), Void)
-
- --| Roles
- create l_anonymous_role.make ("anonymous")
- a_storage.save_user_role (l_anonymous_role)
-
- create l_authenticated_role.make ("authenticated")
- a_storage.save_user_role (l_authenticated_role)
-
- --| Users
- create u.make ("admin")
- u.set_password ("istrator#")
- u.set_email (a_setup.site_email)
- u.set_status ({CMS_USER}.active)
- a_storage.new_user (u)
-
- --| Node
- -- FIXME: move that initialization to node module
- -- TODO: should we move the initialization to an
- --! external configuration file?
- --! at the moment we only have 1 admin to the whole site.
- --! is that ok?
- l_anonymous_role.add_permission ("view any page")
- a_storage.save_user_role (l_anonymous_role)
-
- l_authenticated_role.add_permission ("create page")
- l_authenticated_role.add_permission ("view any page")
- l_authenticated_role.add_permission ("edit any page")
- l_authenticated_role.add_permission ("delete page")
- l_authenticated_role.add_permission ("trash page")
- l_authenticated_role.add_permission ("view own page")
- l_authenticated_role.add_permission ("edit own page")
- l_authenticated_role.add_permission ("delete own page")
- l_authenticated_role.add_permission ("trash own page")
- a_storage.save_user_role (l_authenticated_role)
+ -- Eventually custom database initialization...
end
note
- copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
+ copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end
diff --git a/src/persistence/user/cms_user_storage_sql_i.e b/src/persistence/user/cms_user_storage_sql_i.e
index 25bce70..bc2843a 100644
--- a/src/persistence/user/cms_user_storage_sql_i.e
+++ b/src/persistence/user/cms_user_storage_sql_i.e
@@ -261,22 +261,18 @@ feature -- Change: user
l_password_salt := user_salt (a_user.name)
end
if
- l_password_hash /= Void and l_password_salt /= Void and
- attached a_user.email as l_email
+ l_password_hash /= Void and l_password_salt /= Void
then
sql_begin_transaction
- write_information_log (generator + ".update_user")
- create l_parameters.make (7)
+ write_information_log (generator + ".update_username")
+ create l_parameters.make (4)
l_parameters.put (a_user.id, "uid")
l_parameters.put (a_new_username, "name")
l_parameters.put (l_password_hash, "password")
l_parameters.put (l_password_salt, "salt")
- l_parameters.put (l_email, "email")
- l_parameters.put (a_user.status, "status")
- l_parameters.put (a_user.last_login_date, "signed")
- sql_modify (sql_update_user, l_parameters)
+ sql_modify (sql_update_user_name, l_parameters)
sql_finalize
if not error_handler.has_error then
a_user.set_name (a_new_username)
@@ -319,7 +315,7 @@ feature -- Change: user
sql_begin_transaction
write_information_log (generator + ".update_user")
- create l_parameters.make (7)
+ create l_parameters.make (8)
l_parameters.put (a_user.id, "uid")
l_parameters.put (a_user.name, "name")
l_parameters.put (l_password_hash, "password")
@@ -327,6 +323,7 @@ feature -- Change: user
l_parameters.put (l_email, "email")
l_parameters.put (a_user.status, "status")
l_parameters.put (a_user.last_login_date, "signed")
+ l_parameters.put (a_user.profile_name, "profile_name")
sql_modify (sql_update_user, l_parameters)
sql_finalize
@@ -870,7 +867,7 @@ feature {NONE} -- Implementation: User
end
fetch_user: detachable CMS_USER
- -- Fetch user from fields: 1:uid, 2:name, 3:password, 4:salt, 5:email, 6:status, 7:created, 8:signed.
+ -- Fetch user from fields: 1:uid, 2:name, 3:password, 4:salt, 5:email, 6:status, 7:created, 8:signed, 9:profile_name.
local
l_id: INTEGER_64
l_name: detachable READABLE_STRING_32
@@ -905,6 +902,9 @@ feature {NONE} -- Implementation: User
if attached sql_read_date_time (8) as l_signed_date then
Result.set_last_login_date (l_signed_date)
end
+ if attached sql_read_string_32 (9) as l_prof_name then
+ Result.set_profile_name (l_prof_name)
+ end
else
check expected_valid_user: False end
end
@@ -940,30 +940,33 @@ feature {NONE} -- Sql Queries: USER
select_users_count: STRING = "SELECT count(*) FROM users;"
-- Number of users.
- select_users: STRING = "SELECT * FROM users;"
+ select_users: STRING = "SELECT uid, name, password, salt, email, status, created, signed, profile_name FROM users;"
-- List of users.
- select_user_by_id: STRING = "SELECT * FROM users WHERE uid =:uid;"
+ select_user_by_id: STRING = "SELECT uid, name, password, salt, email, status, created, signed, profile_name FROM users WHERE uid =:uid;"
-- Retrieve user by id if exists.
- select_user_by_name: STRING = "SELECT * FROM users WHERE name =:name;"
+ select_user_by_name: STRING = "SELECT uid, name, password, salt, email, status, created, signed, profile_name FROM users WHERE name =:name;"
-- Retrieve user by name if exists.
- sql_select_recent_users: STRING = "SELECT uid, name, password, salt, email, status, created, signed FROM users ORDER BY uid DESC, created DESC LIMIT :rows OFFSET :offset;"
+ sql_select_recent_users: STRING = "SELECT uid, name, password, salt, email, status, created, signed, profile_name FROM users ORDER BY uid DESC, created DESC LIMIT :rows OFFSET :offset;"
-- Retrieve recent users
- select_user_by_email: STRING = "SELECT uid, name, password, salt, email, status, created, signed FROM users WHERE email =:email;"
+ select_user_by_email: STRING = "SELECT uid, name, password, salt, email, status, created, signed, profile_name FROM users WHERE email =:email;"
-- Retrieve user by email if exists.
select_salt_by_username: STRING = "SELECT salt FROM users WHERE name =:name;"
-- Retrieve salt by username if exists.
- sql_insert_user: STRING = "INSERT INTO users (name, password, salt, email, created, status) VALUES (:name, :password, :salt, :email, :created, :status);"
+ sql_insert_user: STRING = "INSERT INTO users (name, password, salt, email, created, status, profile_name) VALUES (:name, :password, :salt, :email, :created, :status, :profile_name);"
-- SQL Insert to add a new user.
- sql_update_user: STRING = "UPDATE users SET name=:name, password=:password, salt=:salt, email=:email, status=:status, signed=:signed WHERE uid=:uid;"
+ sql_update_user: STRING = "UPDATE users SET name=:name, password=:password, salt=:salt, email=:email, status=:status, signed=:signed, profile_name=:profile_name WHERE uid=:uid;"
-- SQL update to update an existing user.
+ sql_update_user_name: STRING = "UPDATE users SET name=:name, password=:password, salt=:salt WHERE uid=:uid;"
+ -- SQL update to update `name` for an existing user.
+
sql_delete_user: STRING = "DELETE FROM users WHERE uid=:uid;"
feature {NONE} -- Sql Queries: USER ROLE
@@ -1023,7 +1026,7 @@ feature {NONE} -- Sql Queries: USER ACTIVATION
sql_select_userid_activation: STRING = "SELECT uid FROM users_activations WHERE token = :token;"
-- Retrieve userid given the activation token.
- select_user_by_activation_token: STRING = "SELECT u.* FROM users as u JOIN users_activations as ua ON ua.uid = u.uid and ua.token = :token;"
+ select_user_by_activation_token: STRING = "SELECT u.uid, u.name, u.password, u.salt, u.email, u.status, u.created, u.signed, u.profile_name FROM users as u JOIN users_activations as ua ON ua.uid = u.uid and ua.token = :token;"
-- Retrieve user by activation token if exist.
sql_remove_activation: STRING = "DELETE FROM users_activations WHERE token = :token;"
@@ -1037,7 +1040,7 @@ feature {NONE} -- User Password Recovery
sql_remove_password: STRING = "DELETE FROM users_password_recovery WHERE token = :token;"
-- Retrieve password if exist.
- select_user_by_password_token: STRING = "SELECT u.* FROM users as u JOIN users_password_recovery as ua ON ua.uid = u.uid and ua.token = :token;"
+ select_user_by_password_token: STRING = "SELECT u.uid, u.name, u.password, u.salt, u.email, u.status, u.created, u.signed, u.profile_name FROM users as u JOIN users_password_recovery as ua ON ua.uid = u.uid and ua.token = :token;"
-- Retrieve user by password token if exist.
feature -- Acess: Temp users
diff --git a/src/service/cms_api.e b/src/service/cms_api.e
index c76050f..3c4346f 100644
--- a/src/service/cms_api.e
+++ b/src/service/cms_api.e
@@ -57,8 +57,9 @@ feature {NONE} -- Initialize
end
-- Keep enable modules list.
- l_enabled_modules := setup.enabled_modules
+ create l_enabled_modules.make (setup.modules.count)
enabled_modules := l_enabled_modules
+ setup.fill_enabled_modules (Current)
-- Complete storage setup.
storage.set_api (Current)
@@ -72,6 +73,11 @@ feature {NONE} -- Initialize
-- or the reverse, or merge installation and initialization
-- and leave the responsability to the module to know
-- if this is installed or not...
+ if attached {CMS_CORE_MODULE} l_module as l_core_module then
+ if not l_core_module.is_installed (Current) then
+ l_core_module.install (Current)
+ end
+ end
-- if not l_module.is_installed (Current) then
-- l_module.install (Current)
-- end
@@ -119,7 +125,7 @@ feature {NONE} -- Initialize
formats.extend (f)
end
-feature {CMS_ACCESS} -- Installation
+feature {CMS_ACCESS} -- Module management
install_all_modules
-- Install CMS or uninstalled module which are enabled.
@@ -134,12 +140,19 @@ feature {CMS_ACCESS} -- Installation
-- or the reverse, or merge installation and initialization
-- and leave the responsability to the module to know
-- if this is installed or not...
- if not l_module.is_installed (Current) then
+ if l_module.is_enabled and not l_module.is_installed (Current) then
install_module (l_module)
end
end
end
+ installed_module_version (m: CMS_MODULE): detachable READABLE_STRING_32
+ require
+ module_installed: is_module_installed (m)
+ do
+ Result := m.installed_version (Current)
+ end
+
install_module (m: CMS_MODULE)
-- Install module `m'.
require
@@ -159,6 +172,22 @@ feature {CMS_ACCESS} -- Installation
m.uninstall (Current)
end
+ enable_module (m: CMS_MODULE)
+ -- Enable module `m'.
+ do
+ m.update_status_in_storage (True, Current)
+ ensure
+ module_enabled: is_module_enabled (m)
+ end
+
+ disable_module (m: CMS_MODULE)
+ -- Disable module `m'.
+ do
+ m.update_status_in_storage (False, Current)
+ ensure
+ module_disabled: not is_module_enabled (m)
+ end
+
feature -- Access
setup: CMS_SETUP
@@ -431,13 +460,18 @@ feature -- Query: module
Result := a_module.is_installed (Current)
end
+ is_module_enabled (a_module: CMS_MODULE): BOOLEAN
+ do
+ Result := a_module.is_enabled or a_module.is_enabled_in_storage (Current)
+ end
+
enabled_modules: CMS_MODULE_COLLECTION
module (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE
-- Enabled module typed `a_type', if any.
--| usage: if attached module ({FOO_MODULE}) as mod then ...
do
- Result := setup.modules.item (a_type)
+ Result := installed_module (a_type)
if Result /= Void and then not Result.is_enabled then
Result := Void
end
@@ -445,6 +479,16 @@ feature -- Query: module
Result /= Void implies (Result.is_enabled) -- and a_type.is_conforming_to (Result.generating_type))
end
+ installed_module (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE
+ -- Module typed `a_type', if any.
+ -- It may not be enabled!
+ --| usage: if attached module ({FOO_MODULE}) as mod then ...
+ do
+ Result := setup.modules.item (a_type)
+ ensure
+--FIXME Result /= Void implies (Result.is_enabled) -- and a_type.is_conforming_to (Result.generating_type))
+ end
+
module_api (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE_API
-- Enabled module API associated with module typed `a_type'.
do
diff --git a/src/service/cms_api_export_imp.e b/src/service/cms_api_export_imp.e
index 471ff70..6248362 100644
--- a/src/service/cms_api_export_imp.e
+++ b/src/service/cms_api_export_imp.e
@@ -111,6 +111,9 @@ feature -- Export
u := ic.item
create j.make_empty
j.put_string (u.name, "name")
+ if attached u.profile_name as pn then
+ j.put_string (pn, "profile_name")
+ end
j.put_integer (u.status, "status")
put_string_into_json (u.email, "email", j)
put_string_into_json (u.password, "password", j)
diff --git a/src/service/cms_api_import_imp.e b/src/service/cms_api_import_imp.e
index 4aa47a9..f3fec86 100644
--- a/src/service/cms_api_import_imp.e
+++ b/src/service/cms_api_import_imp.e
@@ -203,6 +203,10 @@ feature -- Import
if attached json_string_8_item (j, "email") as l_email then
Result.set_email (l_email)
end
+ if attached json_string_8_item (j, "profile_name") as l_profile_name then
+ Result.set_profile_name (l_profile_name)
+ end
+
if attached {JSON_ARRAY} j.item ("roles") as j_roles then
create l_roles.make (j_roles.count)
across
diff --git a/src/service/cms_module.e b/src/service/cms_module.e
index 7ae684d..02ffa35 100644
--- a/src/service/cms_module.e
+++ b/src/service/cms_module.e
@@ -92,10 +92,24 @@ feature {CMS_API} -- Access: API
feature {CMS_API} -- Module management
+ installed_version (api: CMS_API): detachable READABLE_STRING_32
+ require
+ is_installed (api)
+ do
+ Result := api.storage.custom_value ("is_installed", "module-" + name)
+ end
+
is_installed (api: CMS_API): BOOLEAN
-- Is Current module installed?
+ local
+ v: detachable READABLE_STRING_32
do
- if attached api.storage.custom_value ("is_initialized", "module-" + name) as v then
+ v := api.storage.custom_value ("is_installed", "module-" + name)
+ if v = Void then
+ -- Kept for backward compabilitiy
+ v := api.storage.custom_value ("is_initialized", "module-" + name)
+ end
+ if v /= Void then
if v.is_case_insensitive_equal_general (version) then
Result := True
elseif v.is_case_insensitive_equal_general ("yes") then
@@ -112,18 +126,58 @@ feature {CMS_API} -- Module management
end
end
+ is_enabled_in_storage (api: CMS_API): BOOLEAN
+ -- Is Current module installed?
+ local
+ v: detachable READABLE_STRING_32
+ do
+ v := api.storage.custom_value ("is_enabled", "module-" + name)
+ if v /= Void then
+ if v.is_case_insensitive_equal_general (version) then
+ Result := True
+ elseif v.is_case_insensitive_equal_general ("yes") then
+ -- Backward compatibility.
+ Result := True
+ elseif v.is_case_insensitive_equal_general ("no") then
+ -- Probably a module that was installed, but now uninstalled.
+ Result := False
+ else
+ -- Maybe a different version is installed.
+ -- For now, let's assume this is installed.
+ Result := True
+ end
+ end
+ end
+
+ update_status_in_storage (a_is_enabled: BOOLEAN; api: CMS_API)
+ -- Is Current module installed?
+ do
+ if a_is_enabled then
+ api.storage.set_custom_value ("is_enabled", version, "module-" + name)
+ enable
+ else
+ api.storage.unset_custom_value ("is_enabled", "module-" + name)
+ disable
+ end
+ end
+
install (api: CMS_API)
require
is_not_installed: not is_installed (api)
do
- api.storage.set_custom_value ("is_initialized", version, "module-" + name)
+ api.storage.set_custom_value ("is_installed", version, "module-" + name)
+ if is_enabled then
+ api.storage.set_custom_value ("is_enabled", version, "module-" + name)
+ else
+ api.storage.unset_custom_value ("is_enabled", "module-" + name)
+ end
end
uninstall (api: CMS_API)
require
is_installed: is_installed (api)
do
- api.storage.set_custom_value ("is_initialized", "no", "module-" + name)
+ api.storage.set_custom_value ("is_installed", "no", "module-" + name)
end
feature -- Router
@@ -195,6 +249,6 @@ invariant
version_set: not version.is_whitespace
note
- copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
+ copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end
diff --git a/src/service/cms_module_collection.e b/src/service/cms_module_collection.e
index 1eea613..97b2b5f 100644
--- a/src/service/cms_module_collection.e
+++ b/src/service/cms_module_collection.e
@@ -48,8 +48,6 @@ feature -- Access
Result := Void
end
end
- ensure
- Result /= Void implies (Result.is_enabled)
end
item_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_MODULE
@@ -129,6 +127,6 @@ feature {NONE} -- Implementation
-- List of available modules.
;note
- copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
+ copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end
diff --git a/src/service/content/cms_content_type_webform_manager.e b/src/service/content/cms_content_type_webform_manager.e
index 8b578f8..6fabd24 100644
--- a/src/service/content/cms_content_type_webform_manager.e
+++ b/src/service/content/cms_content_type_webform_manager.e
@@ -32,7 +32,7 @@ feature -- Access
feature -- Conversion
- append_content_as_html_to (a_content: G; is_teaser: BOOLEAN; a_output: STRING; a_response: detachable CMS_RESPONSE)
+ append_content_as_html_to (a_content: G; is_teaser: BOOLEAN; a_output: STRING; a_response: CMS_RESPONSE)
-- Append `a_content' as html to `a_output', and adapt output according to `is_teaser' (full output, or teaser).
-- In the context of optional `a_response'.
deferred
@@ -49,6 +49,6 @@ feature -- Conversion
end
note
- copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
+ copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end
diff --git a/src/service/handler/cms_admin_install_handler.e b/src/service/handler/cms_admin_install_handler.e
index c60e47b..c878f96 100644
--- a/src/service/handler/cms_admin_install_handler.e
+++ b/src/service/handler/cms_admin_install_handler.e
@@ -91,9 +91,11 @@ feature -- HTTP Methods
if api.is_module_installed (l_module) then
s.append (" was successfully installed.")
- else
+ elseif l_module.is_enabled then
s.append (" could not be installed!")
s.append (" [ERROR]")
+ else
+ s.append (" is not enabled!")
end
s.append ("
%N")
end
@@ -105,6 +107,6 @@ feature -- HTTP Methods
end
note
- copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
+ copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end
diff --git a/src/service/response/cms_response.e b/src/service/response/cms_response.e
index b8759ef..1e68dd5 100644
--- a/src/service/response/cms_response.e
+++ b/src/service/response/cms_response.e
@@ -1127,7 +1127,8 @@ feature -- Generation
add_to_primary_menu (lnk)
api.hooks.invoke_menu_system_alter (menu_system, Current)
- if api.enabled_modules.count = 0 then
+ if api.enabled_modules.count = 1 then
+ -- It is the required CMS_CORE_MODULE!
add_to_primary_menu (create {CMS_LOCAL_LINK}.make ("Install", "admin/install"))
end
@@ -1261,6 +1262,7 @@ feature -- Generation
page.register_variable (request.is_https, "is_https")
if attached user as l_user then
page.register_variable (l_user.name, "user")
+ page.register_variable (user_profile_name (l_user), "user_profile_name")
end
if attached title as l_title then
page.register_variable (l_title, "site_title")
@@ -1373,17 +1375,28 @@ feature -- Helpers: cms link
if a_opt_title /= Void then
create Result.make (a_opt_title, user_url (u))
else
- create Result.make (u.name, user_url (u))
+ create Result.make (user_profile_name (u), user_url (u))
end
end
-feature -- Helpers: html links
+feature -- Helpers: html links
+
+ user_profile_name (u: CMS_USER): READABLE_STRING_32
+ do
+ if attached u.profile_name as pn and then not pn.is_whitespace then
+ Result := pn
+ elseif not u.name.is_whitespace then
+ Result := u.name
+ else
+ Result := {STRING_32} "user #" + u.id.out
+ end
+ end
user_html_link (u: CMS_USER): STRING
require
u_with_name: not u.name.is_whitespace
do
- Result := link (u.name, "user/" + u.id.out, Void)
+ Result := link (user_profile_name (u), "user/" + u.id.out, Void)
end
feature -- Helpers: URLs
diff --git a/tpl/site/scripts/core.sql b/tpl/site/scripts/core.sql
deleted file mode 100644
index 5b5d0fe..0000000
--- a/tpl/site/scripts/core.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-CREATE TABLE `logs`(
- `id` INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
- `category` VARCHAR(255) NOT NULL,
- `level` INTEGER NOT NULL,
- `uid` INTEGER,
- `message` TEXT NOT NULL,
- `info` TEXT,
- `link` TEXT,
- `date` DATETIME NOT NULL
-);
-
-CREATE TABLE `custom_values`(
- `type` VARCHAR(255) NOT NULL,
- `name` VARCHAR(255) NOT NULL,
- `value` TEXT
-);
-
-CREATE TABLE `path_aliases`(
- `pid` INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
- `source` VARCHAR(255) NOT NULL,
- `alias` VARCHAR(255) NOT NULL,
- `lang` VARCHAR(12)
-);