Updated SQLITE builder using GLOBAL_SETTINGS to map 0 to 0, by default 0 -> NULL

Updated CMS_NODE_API, with status, not_published, published and trashed.
Updated Form response to use permission scopes.
Updated sqlquery to retrieve user author.
Added logger info in cms_response
Updated CMS_NODE with a new status attribute.
Updated table nodes to support trashing (or soft deletes) of node using the new status field
Updated Sqlite builder to test different scenarios for users and roles.
Updated NODE_FORM_RESPONSE.edit_form feature to add a delete operation
  if there is a node ie node id >0 and the current user has delete permission on it.
Updated NODE_HANDLER.do_post to handle the operation "DELETE".
Updated queries to retrieve nodes filter by no logical deleted rows (ie. status is trashed).


Signed-off-by: jvelilla <javier.hector@gmail.com>
This commit is contained in:
2015-05-12 22:02:23 +02:00
parent fdff2bef36
commit 9514f1de9c
7 changed files with 171 additions and 62 deletions

View File

@@ -249,6 +249,29 @@ feature -- Access: Node
end
end
is_author_of_node (u: CMS_USER; a_node: CMS_NODE): BOOLEAN
-- Is the user `u' owner of the node `n'.
do
if attached node_storage.node_author (a_node.id) as l_author then
Result := u.same_as (l_author)
end
end
feature -- Permission Scope: Node
permission_scope (u: detachable CMS_USER; a_node: CMS_NODE): STRING
-- Result 'own' if the user `u' is the owner of the node `a_node', in other case
-- `any'.
do
-- FIXME: check if this is ok, since a role may have "any" permission enabled, and "own" disabled,
-- in this case, we should check both permissions
-- obviously such case should be rare, and look like bad configured permissions, but this may occurs.
Result := "any"
if u /= Void and then is_author_of_node (u, a_node) then
Result := "own"
end
end
feature -- Change: Node
save_node (a_node: CMS_NODE)
@@ -279,32 +302,16 @@ feature -- Change: Node
node_storage.update_node (a_node)
end
-- update_node_title (a_user_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_title: READABLE_STRING_32)
-- -- Update node title, with user identified by `a_id', with node id `a_node_id' and a new title `a_title'.
-- do
-- debug ("refactor_fixme")
-- fixme ("Check preconditions")
-- end
-- node_storage.update_node_title (a_user_id, a_node_id, a_title)
-- end
-- update_node_summary (a_user_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_summary: READABLE_STRING_32)
-- -- Update node summary, with user identified by `a_user_id', with node id `a_node_id' and a new summary `a_summary'.
-- do
-- debug ("refactor_fixme")
-- fixme ("Check preconditions")
-- end
-- node_storage.update_node_summary (a_user_id, a_node_id, a_summary)
-- end
feature -- Node status
-- update_node_content (a_user_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_content: READABLE_STRING_32)
-- -- Update node content, with user identified by `a_user_id', with node id `a_node_id' and a new content `a_content'.
-- do
-- debug ("refactor_fixme")
-- fixme ("Check preconditions")
-- end
-- node_storage.update_node_content (a_user_id, a_node_id, a_content)
-- end
Not_published: INTEGER = 0
-- The node is not published.
Published: INTEGER = 1
-- The node is published.
Trashed: INTEGER = -1
-- The node is trashed (soft delete), ready to be deleted/destroyed from storage.
end