Technical support This forum is closed.
Version 1.x > Technical support > Established permissions in new page created View modes: 
User avatar
Member
Member
malaqui - 5/18/2006 8:10:31 PM
   
Established permissions in new page created
Hi,
We need to assing permissions to new pages in the creation time.
We try to modify the insert query in this way

INSERT INTO [Sybarite_FirmaLuxury] ( [ImagenCuadro1], [TextoCuadro1], [TextoCuadro2], [ImagenCuadro3], [TextoCuadro4], [Nombre], [Url], [Telefono] ) VALUES ( @ImagenCuadro1, @TextoCuadro1, @TextoCuadro2, @ImagenCuadro3, @TextoCuadro4, @Nombre, @Url, @Telefono); SELECT @@identity AS [FirmaLuxuryID];

declare @id int

/* para obtener el id del objeto firma luxury creado */
select @id = MAX(FirmaLuxuryID)
from Sybarite_FirmaLuxury

print('identificador')
print(@id)

declare @user int
declare @acl int

/* para obtener el acl y el usuario del objeto firma luxury creado */
select @acl = ACLID , @user = CreatedBYUserID
from cms_tree
where classID=22
and ForeignKeyValue = @id

print('acl')
print(@acl)
print('usuario')
print(@user)
/* para que el usuario que ha creado el objeto firma tenga todos los permisos sobre él */
/*insert into CMS_ACLItem values (@acl,@user,null,0,127,'2006/05/18 00:00:00',@user)*/
if @acl <> null
begin
insert into CMS_ACLItem values (@acl,@user,null,0,127,getdate(),@user)

/* para quitar a cada objeto que el resto de usuarios */

DECLARE MyCursor CURSOR FOR
select distinct(aclid), createdByUserID
from cms_tree
where classID=22
and createdByUserID <> @user

OPEN MyCursor

DECLARE @aclid2 int
DECLARE @user2 int

FETCH NEXT FROM MyCursor
INTO @aclid2, @user2

WHILE @@FETCH_STATUS = 0
BEGIN


print('aclid2')
print(@aclid2)
print('user2')
print(@user2)

declare @cuantos int
select @cuantos = COUNT(*) from CMS_ACLItem where aclid = @aclid2 and userid = @user2

print('cuantos')
print(@cuantos)

if @cuantos = 0
begin
insert into CMS_ACLItem values (@aclid2,@user2,null,127,0,getdate(),@user2)
end
FETCH NEXT FROM MyCursor
INTO @aclid2, @user2
END

CLOSE MyCursor
DEALLOCATE MyCursor

end

But we can't recover ACLId, because it is not yet created.
Where is the error?
Regards

User avatar
Member
Member
Martin_Kentico - 5/19/2006 1:23:09 PM
   
Re: Established permissions in new page created
Hello,

Thank you for your post.

The document creation consists of two steps:

1) Creation of the document data (your custom table with the usage of the application.classname.insert query)

2) Creation of the document tree record

When system calls your insert query, the tree structure is not yet updated (there is still no record) so the ACLID cannot be retrieved.

You can resolve it in two ways:

1) You shouldn't use the direct communication with the database through your custom query, instead you should do the action within the code of your application, for example bind the OnAfterSave() event of the editing form on cmsdesk/Content/Edit.aspx page and do the work in there when detecting particular class. You can find some ACL editing code (hopefully enough for what you need) within the cmsdesk/Content/DocumentPermissions.aspx page.

I would prefer this one, because it is more polite to the system itself and ensures the stability for future versions.

2) You can also edit the query for inserting into the CMS_Tree table and detect the class of you interest in there, but I wouldn't recommend that, because editing the basic queries could cause instability when you update your document template or with newer versions of our system.

Best regards