public static ErrorData OnUpdating(Context context, SiteSettings ss, SiteModel siteModel) { if (!context.CanManageSite(ss: ss)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } ss.SetColumnAccessControls(context: context, mine: siteModel.Mine(context: context)); foreach (var controlId in context.Forms.Keys) { switch (controlId) { case "Sites_Title": if (siteModel.Title_Updated(context: context) && !ss.GetColumn(context: context, columnName: "Title").CanUpdate) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Sites_Body": if (siteModel.Body_Updated(context: context) && !ss.GetColumn(context: context, columnName: "Body").CanUpdate) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Sites_ReferenceType": if (siteModel.ReferenceType_Updated(context: context) && !ss.GetColumn(context: context, columnName: "ReferenceType").CanUpdate) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Sites_InheritPermission": if (siteModel.InheritPermission_Updated(context: context) && !ss.GetColumn(context: context, columnName: "InheritPermission").CanUpdate) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "InheritPermission": var errorData = InheritPermission(context: context, ss: ss); if (errorData.Type != Error.Types.None) { return(errorData); } break; case "CurrentPermissionsAll": if (!context.CanManagePermission(ss: ss)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } if (!new PermissionCollection( context: context, referenceId: ss.SiteId, permissions: context.Forms.List("CurrentPermissionsAll")) .InTenant(context: context)) { return(new ErrorData(type: Error.Types.InvalidRequest)); } break; case "SearchPermissionElements": case "OpenPermissionsDialog": case "AddPermissions": case "DeletePermissions": if (!context.CanManagePermission(ss: ss)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Comments": if (!ss.GetColumn(context: context, columnName: "Comments").CanUpdate) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; } } return(new ErrorData(type: Error.Types.None)); }
public static Error.Types OnUpdating(SiteSettings ss, SiteModel siteModel) { if (!ss.CanManageSite()) { return(Error.Types.HasNotPermission); } ss.SetColumnAccessControls(siteModel.Mine()); foreach (var controlId in Forms.Keys()) { switch (controlId) { case "Sites_Title": if (siteModel.Title_Updated() && !ss.GetColumn("Title").CanUpdate) { return(Error.Types.HasNotPermission); } break; case "Sites_Body": if (siteModel.Body_Updated() && !ss.GetColumn("Body").CanUpdate) { return(Error.Types.HasNotPermission); } break; case "Sites_ReferenceType": if (siteModel.ReferenceType_Updated() && !ss.GetColumn("ReferenceType").CanUpdate) { return(Error.Types.HasNotPermission); } break; case "Sites_InheritPermission": if (siteModel.InheritPermission_Updated() && !ss.GetColumn("InheritPermission").CanUpdate) { return(Error.Types.HasNotPermission); } break; case "InheritPermission": var type = InheritPermission(ss); if (type != Error.Types.None) { return(type); } break; case "CurrentPermissionsAll": if (!ss.CanManagePermission()) { return(Error.Types.HasNotPermission); } if (!new PermissionCollection( ss.SiteId, Forms.List("CurrentPermissionsAll")).InTenant()) { return(Error.Types.InvalidRequest); } break; case "SearchPermissionElements": case "OpenPermissionsDialog": case "AddPermissions": case "DeletePermissions": if (!ss.CanManagePermission()) { return(Error.Types.HasNotPermission); } break; case "Comments": if (!ss.GetColumn("Comments").CanUpdate) { return(Error.Types.HasNotPermission); } break; } } return(Error.Types.None); }