本文整理汇总了C#中SobekCM.Library.Users.User_Object.Can_Delete_This_Item方法的典型用法代码示例。如果您正苦于以下问题:C# User_Object.Can_Delete_This_Item方法的具体用法?C# User_Object.Can_Delete_This_Item怎么用?C# User_Object.Can_Delete_This_Item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SobekCM.Library.Users.User_Object
的用法示例。
在下文中一共展示了User_Object.Can_Delete_This_Item方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete_Item_MySobekViewer
/// <summary> Constructor for a new instance of the Delete_Item_MySobekViewer class </summary>
/// <param name="User"> Authenticated user information </param>
/// <param name="Current_Mode"> Mode / navigation information for the current request</param>
/// <param name="Current_Item"> Individual digital resource to be deleted by the user </param>
/// <param name="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="SobekCM.Library.Application_State.Single_Item"/> objects.</param>
/// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
public Delete_Item_MySobekViewer(User_Object User,
SobekCM_Navigation_Object Current_Mode,
SobekCM_Item Current_Item,
Item_Lookup_Object All_Items_Lookup,
Custom_Tracer Tracer)
: base(User)
{
Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Delete this item");
// Save mode and set defaults
currentMode = Current_Mode;
item = Current_Item;
errorCode = -1;
// Second, ensure this is a logged on user and system administrator before continuing
Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Validate user permissions" );
if ((User == null) || ( !User.LoggedOn ))
{
Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "User does not have delete permissions", Custom_Trace_Type_Enum.Error );
errorCode = 1;
}
else
{
bool canDelete = false;
if ((User.Can_Delete_All) || (User.Is_System_Admin))
{
canDelete = true;
}
else
{
// In this case, we actually need to build this!
try
{
// SobekCM_Item testItem = SobekCM_Item_Factory.Get_Item(Current_Mode.BibID, Current_Mode.VID, null, Tracer);
if (User.Can_Delete_This_Item(item))
canDelete = true;
}
catch
{
canDelete = false;
}
}
if (!canDelete)
{
Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "User does not have delete permissions", Custom_Trace_Type_Enum.Error);
errorCode = 1;
}
}
// Ensure the item is valid
if (errorCode == -1)
{
Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Validate item exists");
if (!All_Items_Lookup.Contains_BibID_VID(Current_Mode.BibID, Current_Mode.VID))
{
Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Item indicated is not valid", Custom_Trace_Type_Enum.Error);
errorCode = 2;
}
}
// If this is a postback, handle any events first
if ((currentMode.isPostBack) && ( errorCode < 0 ))
{
Debug.Assert(User != null, "User != null");
// Pull the standard values
string save_value = HttpContext.Current.Request.Form["admin_delete_item"];
string text_value = HttpContext.Current.Request.Form["admin_delete_confirm"];
// Better say "DELETE", or just send back to the item
if (( save_value == null ) || ( save_value.ToUpper() != "DELETE" ) || ( text_value.ToUpper() != "DELETE"))
{
HttpContext.Current.Response.Redirect(Current_Mode.Base_URL + currentMode.BibID + "/" + currentMode.VID, false);
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
}
else
{
if (currentMode.BibID.ToUpper() == "TEMP000001")
{
for (int deleteVID = 2124; deleteVID <= 2134; deleteVID++)
{
currentMode.VID = deleteVID.ToString().PadLeft(5, '0');
Delete_Item(User, All_Items_Lookup, Tracer);
}
}
else
{
Delete_Item(User, All_Items_Lookup, Tracer);
}
}
}
//.........这里部分代码省略.........