protected object grid_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView drv = null; if (parameter is DataRowView) { drv = (DataRowView)parameter; } else if (parameter is GridViewRow) { drv = (DataRowView)((GridViewRow)parameter).DataItem; } var objectSettingsId = ValidationHelper.GetInteger(drv["ObjectSettingsID"], 0); if ((tmpObjectSettings == null) || (tmpObjectSettings.ObjectSettingsID != objectSettingsId)) { tmpObjectSettings = ObjectSettingsInfo.Provider.Get(objectSettingsId); if (tmpObjectSettings != null) { tmpInfo = ProviderHelper.GetInfoById(tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID); } } if ((tmpInfo != null) && (tmpObjectSettings != null)) { contextResolver.SetNamedSourceData("EditedObject", tmpInfo); switch (sourceName.ToLowerCSafe()) { case "checkin": var checkinButton = (CMSGridActionButton)sender; if (tmpInfo.TypeInfo.SupportsLocking) { checkinButton.OnClientClick = GetConfirmScript(GetString("ObjectEditMenu.CheckInConfirmation"), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnCheckIn); } else { checkinButton.Enabled = false; } break; case "undocheckout": var undoCheckoutButton = (CMSGridActionButton)sender; if (tmpInfo.TypeInfo.SupportsLocking) { undoCheckoutButton.OnClientClick = GetConfirmScript(CMSObjectManager.GetUndoCheckOutConfirmation(tmpInfo, null), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnUndoCheckOut); } else { undoCheckoutButton.Enabled = false; } break; } } return(parameter); }
protected object grid_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView drv = null; if (parameter is DataRowView) { drv = (DataRowView)parameter; } else if (parameter is GridViewRow) { drv = (DataRowView)((GridViewRow)parameter).DataItem; } var objectSettingsId = ValidationHelper.GetInteger(drv["ObjectSettingsID"], 0); if ((tmpObjectSettings == null) || (tmpObjectSettings.ObjectSettingsID != objectSettingsId)) { tmpObjectSettings = ObjectSettingsInfoProvider.GetObjectSettingsInfo(objectSettingsId); tmpInfo = CMSObjectHelper.GetObjectById(tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID); } contextResolver.SetNamedSourceData("EditedObject", tmpInfo); switch (sourceName.ToLowerCSafe()) { case "edit": var editButton = (CMSImageButton)sender; var url = tmpInfo.Generalized.GetEditingPageURL(); if (!string.IsNullOrEmpty(url)) { url = contextResolver.ResolveMacros(url); url = CMSContext.ResolveDialogUrl(url); var queryString = URLHelper.GetQuery(url); url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(queryString)); editButton.OnClientClick = string.Format("modalDialog('{0}', 'objectEdit', '85%', '85%');", url); } else { editButton.Enabled = false; } break; case "checkin": var checkinButton = (CMSImageButton)sender; checkinButton.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/checkin.png"); if (tmpInfo.TypeInfo.SupportsLocking) { checkinButton.Attributes["onclick"] = GetConfirmScript(GetString("ObjectEditMenu.CheckInConfirmation"), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnCheckIn); } else { checkinButton.Enabled = false; } break; case "undocheckout": var undoCheckoutButton = (CMSImageButton)sender; undoCheckoutButton.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/undocheckout.png"); if (tmpInfo.TypeInfo.SupportsLocking) { undoCheckoutButton.Attributes["onclick"] = GetConfirmScript(CMSObjectManager.GetUndoCheckOutConfirmation(tmpInfo, null), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnUndoCheckOut); } else { undoCheckoutButton.Enabled = false; } break; } return(parameter); }
protected object grid_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView drv = null; if (parameter is DataRowView) { drv = (DataRowView)parameter; } else if (parameter is GridViewRow) { drv = (DataRowView)((GridViewRow)parameter).DataItem; } var objectSettingsId = ValidationHelper.GetInteger(drv["ObjectSettingsID"], 0); if ((tmpObjectSettings == null) || (tmpObjectSettings.ObjectSettingsID != objectSettingsId)) { tmpObjectSettings = ObjectSettingsInfoProvider.GetObjectSettingsInfo(objectSettingsId); if (tmpObjectSettings != null) { tmpInfo = BaseAbstractInfoProvider.GetInfoById(tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID); } } if ((tmpInfo != null) && (tmpObjectSettings != null)) { contextResolver.SetNamedSourceData("EditedObject", tmpInfo); switch (sourceName.ToLowerCSafe()) { case "edit": var editButton = (CMSGridActionButton)sender; var url = tmpInfo.Generalized.GetEditingPageURL(); if (!string.IsNullOrEmpty(url)) { url = contextResolver.ResolveMacros(url); // Resolve dialog relative url if (url.StartsWith("~/")) { url = AuthenticationHelper.ResolveDialogUrl(url); } string queryString = URLHelper.GetQuery(url); if (queryString.IndexOfCSafe("&hash=", true) < 0) { url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(queryString)); } editButton.OnClientClick = string.Format("modalDialog('{0}', 'objectEdit', '85%', '85%'); return false", url); } else { editButton.Enabled = false; } break; case "checkin": var checkinButton = (CMSGridActionButton)sender; if (tmpInfo.TypeInfo.SupportsLocking) { checkinButton.OnClientClick = GetConfirmScript(GetString("ObjectEditMenu.CheckInConfirmation"), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnCheckIn); } else { checkinButton.Enabled = false; } break; case "undocheckout": var undoCheckoutButton = (CMSGridActionButton)sender; if (tmpInfo.TypeInfo.SupportsLocking) { undoCheckoutButton.OnClientClick = GetConfirmScript(CMSObjectManager.GetUndoCheckOutConfirmation(tmpInfo, null), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnUndoCheckOut); } else { undoCheckoutButton.Enabled = false; } break; } } return(parameter); }
protected object grid_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView drv = null; if (parameter is DataRowView) { drv = (DataRowView)parameter; } else if (parameter is GridViewRow) { drv = (DataRowView)((GridViewRow)parameter).DataItem; } var objectSettingsId = ValidationHelper.GetInteger(drv["ObjectSettingsID"], 0); if ((tmpObjectSettings == null) || (tmpObjectSettings.ObjectSettingsID != objectSettingsId)) { tmpObjectSettings = ObjectSettingsInfoProvider.GetObjectSettingsInfo(objectSettingsId); if (tmpObjectSettings != null) { tmpInfo = BaseAbstractInfoProvider.GetInfoById(tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID); } } if ((tmpInfo != null) && (tmpObjectSettings != null)) { contextResolver.SetNamedSourceData("EditedObject", tmpInfo); switch (sourceName.ToLowerCSafe()) { case "edit": var editButton = (CMSGridActionButton)sender; var url = tmpInfo.Generalized.GetEditingPageURL(); if (!string.IsNullOrEmpty(url)) { url = contextResolver.ResolveMacros(url); // Resolve dialog relative url if (url.StartsWith("~/")) { url = AuthenticationHelper.ResolveDialogUrl(url); } string queryString = URLHelper.GetQuery(url); if (queryString.IndexOfCSafe("&hash=", true) < 0) { url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(queryString)); } editButton.OnClientClick = string.Format("modalDialog('{0}', 'objectEdit', '85%', '85%'); return false", url); } else { editButton.Enabled = false; } break; case "checkin": var checkinButton = (CMSGridActionButton)sender; if (tmpInfo.TypeInfo.SupportsLocking) { checkinButton.OnClientClick = GetConfirmScript(GetString("ObjectEditMenu.CheckInConfirmation"), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnCheckIn); } else { checkinButton.Enabled = false; } break; case "undocheckout": var undoCheckoutButton = (CMSGridActionButton)sender; if (tmpInfo.TypeInfo.SupportsLocking) { undoCheckoutButton.OnClientClick = GetConfirmScript(CMSObjectManager.GetUndoCheckOutConfirmation(tmpInfo, null), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnUndoCheckOut); } else { undoCheckoutButton.Enabled = false; } break; } } return parameter; }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); ReloadMenu(); var showMenu = menu.HasAnyVisibleAction() || plcDevices.Visible || plcAdditionalControls.Visible; if (showMenu) { if (PreviewMode) { pnlContainer.CssClass = "cms-edit-menu"; } var infoObj = InfoObject; if (SynchronizationHelper.UseCheckinCheckout && ObjectManager.ShowPanel && (infoObj != null) && (infoObj.Generalized.ObjectID > 0) && infoObj.TypeInfo.SupportsLocking) { ObjectSettingsInfo settings = infoObj.ObjectSettings; int currentUserId = CurrentUser.UserID; // Get edited info object type and name for use with info messages var objectType = TypeHelper.GetNiceObjectTypeName(infoObj.TypeInfo.ObjectType, ResourceCulture); var objectName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(infoObj.Generalized.ObjectDisplayName, ResourceCulture)); // Object is checked out by another user, disable editing for current user if (currentUserId != settings.ObjectCheckedOutByUserID) { // Disable actions for current user if (save != null) { save.Enabled = false; } if (infoObj.Generalized.IsCheckedOut) { if (checkin != null) { checkin.Visible = false; } if (checkout != null) { checkout.Visible = false; } if (undocheckout != null) { // Always allow undo-checkout for Global Admin undocheckout.Visible = MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin); } string userName = null; UserInfo ui = UserInfoProvider.GetUserInfo(settings.ObjectCheckedOutByUserID); if (ui != null) { userName = HTMLHelper.HTMLEncode(ui.GetFormattedUserName(IsLiveSite)); } AddInfoText(string.Format(GetString("ObjectEditMenu.CheckedOutByAnotherUser", ResourceCulture), objectType, objectName, userName)); } else { AddInfoText(string.Format(GetString("ObjectEditMenu.CheckOutToEdit", ResourceCulture), objectType, objectName)); } } else if (infoObj.Generalized.IsCheckedOut) { AddInfoText(string.Format(GetString("ObjectEditMenu.CheckInToSubmit", ResourceCulture), objectType, objectName)); } } RegisterActionScripts(); } // Hide menu if required pnlContainer.Visible &= showMenu; // Set the information text if (!String.IsNullOrEmpty(InformationText)) { lblInfo.Text = InformationText; lblInfo.Visible = true; pnlInfoWrapper.Visible = true; } }
protected object grid_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView drv = null; if (parameter is DataRowView) { drv = (DataRowView)parameter; } else if (parameter is GridViewRow) { drv = (DataRowView)((GridViewRow)parameter).DataItem; } var objectSettingsId = ValidationHelper.GetInteger(drv["ObjectSettingsID"], 0); if ((tmpObjectSettings == null) || (tmpObjectSettings.ObjectSettingsID != objectSettingsId)) { tmpObjectSettings = ObjectSettingsInfoProvider.GetObjectSettingsInfo(objectSettingsId); tmpInfo = CMSObjectHelper.GetObjectById(tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID); } contextResolver.SetNamedSourceData("EditedObject", tmpInfo); switch (sourceName.ToLowerCSafe()) { case "edit": var editButton = (CMSImageButton)sender; var url = tmpInfo.Generalized.GetEditingPageURL(); if (!string.IsNullOrEmpty(url)) { url = contextResolver.ResolveMacros(url); url = CMSContext.ResolveDialogUrl(url); var queryString = URLHelper.GetQuery(url); url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(queryString)); editButton.OnClientClick = string.Format("modalDialog('{0}', 'objectEdit', '85%', '85%');", url); } else { editButton.Enabled = false; } break; case "checkin": var checkinButton = (CMSImageButton)sender; checkinButton.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/checkin.png"); if (tmpInfo.TypeInfo.SupportsLocking) { checkinButton.Attributes["onclick"] = GetConfirmScript(GetString("ObjectEditMenu.CheckInConfirmation"), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnCheckIn); } else { checkinButton.Enabled = false; } break; case "undocheckout": var undoCheckoutButton = (CMSImageButton)sender; undoCheckoutButton.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/undocheckout.png"); if (tmpInfo.TypeInfo.SupportsLocking) { undoCheckoutButton.Attributes["onclick"] = GetConfirmScript(CMSObjectManager.GetUndoCheckOutConfirmation(tmpInfo, null), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnUndoCheckOut); } else { undoCheckoutButton.Enabled = false; } break; } return parameter; }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); ReloadMenu(); if (menu.Visible || pnlHelp.Visible) { if (PreviewMode) { pnlMenu.CssClass = "CMSEditMenu"; } if (CMSObjectHelper.UseCheckinCheckout && ObjectManager.ShowPanel && (InfoObject != null) && (InfoObject.Generalized.ObjectID > 0) && InfoObject.TypeInfo.SupportsLocking) { ISynchronizedInfo synchronizedInfo = InfoObject as ISynchronizedInfo; if (synchronizedInfo != null) { ObjectSettingsInfo settings = synchronizedInfo.ObjectSettings; int currentUserId = CurrentUser.UserID; // Get edited info object type and name for use with info messages var objectType = GetString(TypeHelper.GetObjectTypeResourceKey(InfoObject.ObjectType)); var objectName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(InfoObject.Generalized.ObjectDisplayName)); // Object is checked out by another user, disable editing for current user if (currentUserId != settings.ObjectCheckedOutByUserID) { // Disable actions for current user if (save != null) { save.Enabled = false; } if (InfoObject.Generalized.IsCheckedOut) { if (checkin != null) { checkin.Visible = false; } if (checkout != null) { checkout.Visible = false; } if (undocheckout != null) { // Always allow undo-checkout for Global Admin undocheckout.Visible = CMSContext.CurrentUser.UserSiteManagerAdmin; } string userName = null; UserInfo ui = UserInfoProvider.GetUserInfo(settings.ObjectCheckedOutByUserID); if (ui != null) { userName = HTMLHelper.HTMLEncode(ui.GetFormattedUserName(IsLiveSite)); } AddInfoText(string.Format(GetString("ObjectEditMenu.CheckedOutByAnotherUser"), objectType, objectName, userName)); } else { AddInfoText(string.Format(GetString("ObjectEditMenu.CheckOutToEdit"), objectType, objectName)); } } else if (InfoObject.Generalized.IsCheckedOut) { AddInfoText(string.Format(GetString("ObjectEditMenu.CheckInToSubmit"), objectType, objectName)); } } } RegisterActionScripts(); } // Hide menu if required pnlMenu.Visible &= menu.Visible || pnlHelp.Visible; // Set the information text if (!String.IsNullOrEmpty(InformationText)) { lblInfo.Text = InformationText; lblInfo.Visible = true; pnlInfoWrapper.Visible = true; } }