text
stringlengths
0
234
Create => Create_From_Status'Access).all'Access;
end Create_Status_List;
-- ------------------------------
-- Load the list of blogs.
-- ------------------------------
procedure Load_Blogs (List : in Blog_Admin_Bean) is
use AWA.Blogs.Models;
use AWA.Services;
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
User : constant ADO.Identifier := Ctx.Get_User_Identifier;
Session : ADO.Sessions.Session := List.Module.Get_Session;
Query : ADO.Queries.Context;
begin
Query.Set_Query (AWA.Blogs.Models.Query_Blog_List);
Query.Bind_Param ("user_id", User);
ADO.Sessions.Entities.Bind_Param (Params => Query,
Name => "table",
Table => AWA.Blogs.Models.BLOG_TABLE,
Session => Session);
ADO.Sessions.Entities.Bind_Param (Params => Query,
Name => "entity_type",
Table => AWA.Blogs.Models.POST_TABLE,
Session => Session);
AWA.Blogs.Models.List (List.Blog_List_Bean.all, Session, Query);
List.Flags (INIT_BLOG_LIST) := True;
end Load_Blogs;
-- ------------------------------
-- Get the blog identifier.
-- ------------------------------
function Get_Blog_Id (List : in Blog_Admin_Bean) return ADO.Identifier is
begin
if List.Blog_Id = ADO.NO_IDENTIFIER then
if not List.Flags (INIT_BLOG_LIST) then
Load_Blogs (List);
end if;
if not List.Blog_List.List.Is_Empty then
return List.Blog_List.List.Element (0).Id;
end if;
end if;
return List.Blog_Id;
end Get_Blog_Id;
-- ------------------------------
-- Load the posts associated with the current blog.
-- ------------------------------
procedure Load_Posts (List : in Blog_Admin_Bean) is
use AWA.Blogs.Models;
use AWA.Services;
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
User : constant ADO.Identifier := Ctx.Get_User_Identifier;
Session : ADO.Sessions.Session := List.Module.Get_Session;
Query : ADO.Queries.Context;
Blog_Id : constant ADO.Identifier := List.Get_Blog_Id;
begin
if Blog_Id /= ADO.NO_IDENTIFIER then
Query.Set_Query (AWA.Blogs.Models.Query_Blog_Admin_Post_List);
Query.Bind_Param ("blog_id", Blog_Id);
Query.Bind_Param ("user_id", User);
ADO.Sessions.Entities.Bind_Param (Params => Query,
Name => "table",
Table => AWA.Blogs.Models.BLOG_TABLE,
Session => Session);
ADO.Sessions.Entities.Bind_Param (Params => Query,
Name => "entity_type",
Table => AWA.Blogs.Models.POST_TABLE,
Session => Session);
AWA.Blogs.Models.List (List.Post_List_Bean.all, Session, Query);
List.Flags (INIT_POST_LIST) := True;
end if;
end Load_Posts;
-- ------------------------------
-- Load the comments associated with the current blog.
-- ------------------------------
procedure Load_Comments (List : in Blog_Admin_Bean) is
use AWA.Blogs.Models;
use AWA.Services;
Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
User : constant ADO.Identifier := Ctx.Get_User_Identifier;
Session : ADO.Sessions.Session := List.Module.Get_Session;
Query : ADO.Queries.Context;
Blog_Id : constant ADO.Identifier := List.Get_Blog_Id;
begin
if Blog_Id /= ADO.NO_IDENTIFIER then
Query.Set_Query (AWA.Blogs.Models.Query_Comment_List);
Query.Bind_Param ("blog_id", Blog_Id);
Query.Bind_Param ("user_id", User);
ADO.Sessions.Entities.Bind_Param (Params => Query,
Name => "table",
Table => AWA.Blogs.Models.BLOG_TABLE,
Session => Session);
ADO.Sessions.Entities.Bind_Param (Params => Query,
Name => "entity_type",
Table => AWA.Blogs.Models.POST_TABLE,