Fixed bug in program that did not allow user to delete a folder after it was created due to applying security incorrectly.

This commit is contained in:
Rich 2013-12-06 04:16:39 +00:00
parent bfa53bc1d2
commit 7b9a359d06
2 changed files with 45 additions and 11 deletions

View File

@ -303,10 +303,10 @@ namespace VEPROMS.CSLA.Library
{ {
try try
{ {
SessionPing cmd = new SessionPing(); SessionPing cmd = new SessionPing();
cmd.SessionID = sessionID; cmd.SessionID = sessionID;
DataPortal.Execute<SessionPing>(cmd); DataPortal.Execute<SessionPing>(cmd);
} }
catch (Exception ex) catch (Exception ex)
{ {
_MyLog.Warn("Session Ping Failure", ex); _MyLog.Warn("Session Ping Failure", ex);
@ -704,6 +704,31 @@ namespace VEPROMS.CSLA.Library
} }
return false; return false;
} }
public bool IsSetAdministrator(FolderInfo fi)
{
if (this.UserMembershipCount == 0)
return false;
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty)
{
Dictionary<int, int> folders = new Dictionary<int, int>();
//FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
while (fi.FolderID > 1)
{
folders.Add(fi.FolderID, fi.FolderID);
fi = fi.MyParent;
}
folders.Add(1, 1);
foreach (AssignmentInfo ai in mi.MyGroup.GroupAssignments)
{
if (folders.ContainsKey(ai.FolderID) && ai.MyRole.Name == "Set Administrator")
return true;
}
}
}
return false;
}
public bool IsSetAdministrator(DocVersionInfo dv) public bool IsSetAdministrator(DocVersionInfo dv)
{ {
if (this.UserMembershipCount == 0) if (this.UserMembershipCount == 0)

View File

@ -515,7 +515,7 @@ namespace Volian.Controls.Library
// folders then can only add another folder, and if children are docversions can only // folders then can only add another folder, and if children are docversions can only
// add docversion. // add docversion.
FolderInfo fi = tn.VEObject as FolderInfo; FolderInfo fi = tn.VEObject as FolderInfo;
if (ui.IsAdministrator()) if (ui.IsAdministrator() || ui.IsSetAdministrator(fi))
{ {
if (fi.MyParent != null) // don't allow insert before/after if at top node if (fi.MyParent != null) // don't allow insert before/after if at top node
{ {
@ -742,7 +742,13 @@ namespace Volian.Controls.Library
cm.MenuItems.Add("Copy", new EventHandler(mi_Click)); cm.MenuItems.Add("Copy", new EventHandler(mi_Click));
} }
#endregion #endregion
bool ok = tn.VEObject as FolderInfo != null ? false : tn.VEObject as DocVersionInfo != null ? (ui.IsAdministrator() || ui.IsSetAdministrator(tn.VEObject as DocVersionInfo) || ui.IsWriter(tn.VEObject as DocVersionInfo)) : (ui.IsAdministrator() || ui.IsSetAdministrator((tn.VEObject as ItemInfo).MyProcedure.MyDocVersion) || ui.IsWriter((tn.VEObject as ItemInfo).MyProcedure.MyDocVersion)); bool ok = false;
if (tn.VEObject is FolderInfo && (ui.IsAdministrator() || ui.IsSetAdministrator(tn.VEObject as FolderInfo)))
ok = true;
else if (tn.VEObject is DocVersionInfo && (ui.IsAdministrator() || ui.IsSetAdministrator(tn.VEObject as DocVersionInfo)))
ok = true;
else if (ui.IsAdministrator() || ui.IsSetAdministrator((tn.VEObject as ItemInfo).MyProcedure.MyDocVersion) || ui.IsWriter((tn.VEObject as ItemInfo).MyProcedure.MyDocVersion))
ok = true;
if(ok) if(ok)
Menu_Paste(tn, cm); Menu_Paste(tn, cm);
#region Menu_Delete #region Menu_Delete
@ -1935,13 +1941,16 @@ namespace Volian.Controls.Library
if (_LastFolderInfo != null) if (_LastFolderInfo != null)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
foreach (DocVersionInfo dvi in _LastFolderInfo.FolderDocVersions) if (_LastFolderInfo.FolderDocVersionCount > 0)
{ {
foreach (ProcedureInfo pi in dvi.Procedures) foreach (DocVersionInfo dvi in _LastFolderInfo.FolderDocVersions)
{ {
if (!MySessionInfo.CanCheckOutItem(pi.ItemID, CheckOutType.Procedure, ref message)) foreach (ProcedureInfo pi in dvi.Procedures)
sb.AppendLine(message); {
message = string.Empty; if (!MySessionInfo.CanCheckOutItem(pi.ItemID, CheckOutType.Procedure, ref message))
sb.AppendLine(message);
message = string.Empty;
}
} }
} }
if (sb.Length > 0) if (sb.Length > 0)