text stringlengths 0 234 |
|---|
Query.Set_Filter ("o.invitee_id = :user"); |
Query.Bind_Param ("user", Invitee_Id); |
Invitation.Find (DB, Query, Found); |
if not Found then |
Log.Warn ("Invitation key {0} has been withdawn", Key); |
raise Not_Found; |
end if; |
Member := AWA.Workspaces.Models.Workspace_Member_Ref (Invitation.Get_Member); |
Workspace_Id := Invitation.Get_Workspace.Get_Id; |
-- Update the workspace member relation. |
Member.Set_Join_Date (ADO.Nullable_Time '(Is_Null => False, |
Value => Now)); |
Invitation.Set_Acceptance_Date (ADO.Nullable_Time '(Is_Null => False, |
Value => Now)); |
-- The user who received the invitation is different from the user who is |
-- logged and accepted the validation. Since the key is verified, this is |
-- the same user but the user who accepted the invitation registered using |
-- another email address. |
if Invitee_Id /= User.Get_Id then |
-- Check whether the user is not already part of the workspace. |
Query.Clear; |
Query.Set_Filter ("o.member_id = ? AND o.workspace_id = ?"); |
Query.Add_Param (User.Get_Id); |
Query.Add_Param (Workspace_Id); |
User_Member.Find (DB, Query, Found); |
if Found then |
Member.Delete (DB); |
Invitation.Delete (DB); |
Log.Info ("Invitation accepted by user who is already a member"); |
else |
Member.Set_Member (User); |
Log.Info ("Invitation accepted by user with another email address"); |
Invitation.Set_Invitee (User); |
end if; |
end if; |
if not Member.Is_Null then |
Member.Save (DB); |
end if; |
DB_Key.Delete (DB); |
if not Invitation.Is_Null then |
Invitation.Save (DB); |
-- Send the accepted invitation event. |
declare |
Event : AWA.Events.Module_Event; |
begin |
Event.Set_Parameter ("invitee_email", User.Get_Email.Get_Email); |
Event.Set_Parameter ("invitee_name", User.Get_Name); |
Event.Set_Parameter ("message", Invitation.Get_Message); |
Event.Set_Parameter ("inviter_email", Invitation.Get_Inviter.Get_Email.Get_Email); |
Event.Set_Parameter ("inviter_name", Invitation.Get_Inviter.Get_Name); |
Event.Set_Event_Kind (Accept_Invitation_Event.Kind); |
Module.Send_Event (Event); |
Function Definition: procedure Add_Permission (Session : in out ADO.Sessions.Master_Session; |
Function Body: User : in ADO.Identifier; |
Entity : in ADO.Objects.Object_Ref'Class; |
Workspace : in ADO.Identifier; |
List : in Security.Permissions.Permission_Index_Array) is |
Ctx : constant ASC.Service_Context_Access := AWA.Services.Contexts.Current; |
Key : constant ADO.Objects.Object_Key := Entity.Get_Key; |
Id : constant ADO.Identifier := ADO.Objects.Get_Value (Key); |
Kind : constant ADO.Entity_Type |
:= ADO.Sessions.Entities.Find_Entity_Type (Session => Session, |
Object => Key); |
Manager : constant AWA.Permissions.Services.Permission_Manager_Access |
:= AWA.Permissions.Services.Get_Permission_Manager (Ctx); |
begin |
for Perm of List loop |
declare |
Member : ADO.Identifier; |
Query : ADO.Queries.Context; |
Names : constant Security.Policies.Roles.Role_Name_Array |
:= Manager.Get_Role_Names (Perm); |
Need_Sep : Boolean := False; |
User_Added : Boolean := False; |
begin |
if Names'Length > 0 then |
Query.Set_Query (AWA.Workspaces.Models.Query_Member_In_Role); |
ADO.SQL.Append (Query.Filter, "user_member.workspace_id = :workspace_id"); |
ADO.SQL.Append (Query.Filter, " AND user_member.member_id IN ("); |
for Name of Names loop |
ADO.SQL.Append (Query.Filter, (if Need_Sep then ",?" else "?")); |
Query.Add_Param (Name.all); |
Need_Sep := True; |
end loop; |
Query.Bind_Param ("workspace_id", Workspace); |
ADO.SQL.Append (Query.Filter, ")"); |
declare |
Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query); |
begin |
Stmt.Execute; |
while Stmt.Has_Elements loop |
Member := Stmt.Get_Identifier (0); |
if Member = User then |
User_Added := True; |
end if; |
Manager.Add_Permission (Session => Session, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.