/*
* Box Socialâ„¢
* http://boxsocial.net/
* Copyright © 2007, David Lachlan Smith
*
* $Id:$
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BoxSocial;
using BoxSocial.Internals;
using BoxSocial.IO;
using BoxSocial.Groups;
using BoxSocial.Networks;
namespace BoxSocial.FrontEnd
{
public class acl : TPage
{
public acl()
: base("acl.html")
{
}
protected void Page_Load(object sender, EventArgs e)
{
long itemId = core.Functions.FormLong("id", core.Functions.RequestLong("id", 0));
long itemTypeId = core.Functions.FormLong("type", core.Functions.RequestLong("type", 0));
if (itemId == 0 || itemTypeId == 0)
{
core.Functions.Generate404();
return;
}
ItemKey itemKey = null;
try
{
itemKey = new ItemKey(itemId, itemTypeId);
}
catch (InvalidItemTypeException)
{
core.Functions.Generate404();
return;
}
NumberedItem ni = null;
try
{
ni = NumberedItem.Reflect(core, itemKey);
}
catch (MissingMethodException)
{
core.Functions.Generate404();
return;
}
if (!(ni is IPermissibleItem))
{
core.Functions.Generate404();
return;
}
IPermissibleItem pi = (IPermissibleItem)ni;
if (!pi.Access.Can("EDIT_PERMISSIONS"))
{
core.Functions.Generate403();
return;
}
List permissions = AccessControlLists.GetPermissions(core, itemKey);
AccessControlLists acl = new AccessControlLists(core, pi);
if (Request.Form["save"] != null)
{
acl_Save(acl);
}
template.Parse("ITEM_TITLE", pi.DisplayTitle);
acl.ParseACL(template, pi.Owner, "S_PERMISSIONS");
/*Template aclTemplate = new Template(core.Http.TemplatePath, "std.acl.html");
template.ParseRaw("S_PERMISSIONS", aclTemplate.ToString());*/
/*if (!pi.Access.Can("EDIT_PERMISSIONS"))
{
core.Functions.Generate403();
return;
}*/
template.Parse("S_ITEM_ID", itemId.ToString());
template.Parse("S_ITEM_TYPE_ID", itemTypeId.ToString());
EndResponse();
}
private void acl_Save(AccessControlLists acl)
{
try
{
acl.SavePermissions();
}
catch
{
core.Functions.Generate403();
return;
}
}
}
}