Pass UserInfo (for security settings) to DisplayRO and StepTabRibbon

Check to see if the use is allowed to run the RO Editor before enabling the GoToRO button.
If an RO is selected in the text, the check to see if the user is allowed to run the RO Editor before enabling the GoTo button on the ribbon and context menu button, as well as enabling the <Shift><Ctrl><G> keystroke.
This commit is contained in:
2015-07-30 14:18:55 +00:00
parent 1ebe496589
commit 28a3a99c50
3 changed files with 36 additions and 3 deletions

View File

@@ -1039,6 +1039,8 @@ namespace VEPROMS
ui = UserInfo.Get(u.UID); ui = UserInfo.Get(u.UID);
} }
ctrlAnnotationDetails.MyUserInfo = ui; ctrlAnnotationDetails.MyUserInfo = ui;
DisplayRO.MyUserInfo = ui; // set the user's security information in the properties RO panel
StepTabRibbon.MyUserInfo = ui; // set the user's security information in the ribbon
bool isVisible = ui.IsAdministrator(); bool isVisible = ui.IsAdministrator();
btnManageSecurity.Visible = isVisible; btnManageSecurity.Visible = isVisible;
btnUpdateFormats.Visible = isVisible; btnUpdateFormats.Visible = isVisible;

View File

@@ -186,6 +186,14 @@ namespace Volian.Controls.Library
// } // }
//} //}
private static UserInfo _MyUserInfo = null;
public static UserInfo MyUserInfo
{
get { return _MyUserInfo; }
set { _MyUserInfo = value; }
}
#endregion #endregion
#region Constructors #region Constructors
public DisplayRO() public DisplayRO()
@@ -224,7 +232,7 @@ namespace Volian.Controls.Library
childroid = childroid.Substring(0, 16); childroid = childroid.Substring(0, 16);
btnSaveRO.Enabled = ((_SavCurROLink == null) || !(childroid.Equals(SavROLink.ROID.ToLower()))); btnSaveRO.Enabled = ((_SavCurROLink == null) || !(childroid.Equals(SavROLink.ROID.ToLower())));
btnCancelRO.Enabled = ((_SavCurROLink != null) && childroid != SavROLink.ROID.ToLower()); btnCancelRO.Enabled = ((_SavCurROLink != null) && childroid != SavROLink.ROID.ToLower());
btnGoToRO.Enabled = true; btnGoToRO.Enabled = CanEditROs(); // Writers and Reviewers cannot edit ROs (run the RO Editor)
switch (chld.type) switch (chld.type)
{ {
case 1: // standard (regular) text RO type case 1: // standard (regular) text RO type
@@ -843,10 +851,18 @@ namespace Volian.Controls.Library
#endregion // utils #endregion // utils
private bool CanEditROs()
{
// Test to see if the user is allowed to run the RO Edior
// writers and reviewers are not allowed to run the RO Editor
return MyUserInfo.IsAdministrator() || MyUserInfo.IsSetAdministrator(Mydvi) || MyUserInfo.IsROEditor(Mydvi);
}
private string _SelectedRoidBeforeRoEditor = null; private string _SelectedRoidBeforeRoEditor = null;
private void lbROId_DoubleClick(object sender, EventArgs e) private void lbROId_DoubleClick(object sender, EventArgs e)
{ {
if (tvROFST.SelectedNode == null) return; if (tvROFST.SelectedNode == null) return;
if (!CanEditROs()) return; // do not allow writers and reviews to run the RO Editor
if (VlnSettings.ReleaseMode.Equals("DEMO")) if (VlnSettings.ReleaseMode.Equals("DEMO"))
{ {
MessageBox.Show("Referenced Object Editor not available in the Demo version.", "PROMS Demo Version"); MessageBox.Show("Referenced Object Editor not available in the Demo version.", "PROMS Demo Version");

View File

@@ -101,6 +101,14 @@ namespace Volian.Controls.Library
return null; return null;
} }
} }
private static UserInfo _MyUserInfo = null;
public static UserInfo MyUserInfo
{
get { return _MyUserInfo; }
set { _MyUserInfo = value; }
}
private DevComponents.DotNetBar.ButtonItem _DefaultContextMenu; private DevComponents.DotNetBar.ButtonItem _DefaultContextMenu;
public void ClearContextMenu() public void ClearContextMenu()
@@ -659,17 +667,24 @@ namespace Volian.Controls.Library
btnCMEditRO.Enabled = false; btnCMEditRO.Enabled = false;
} }
} }
private bool CanEditROs()
{
// Test to see if the user is allowed to run the RO Edior
// writers and reviewers are not allowed to run the RO Editor
return MyUserInfo.IsAdministrator() || MyUserInfo.IsSetAdministrator(MyDVI) || MyUserInfo.IsROEditor(MyDVI);
}
private void SetupGoToButton() private void SetupGoToButton()
{ {
if (MyEditItem is GridItem && (MyEditItem as GridItem).MyFlexGrid.IsRoTable) if (MyEditItem is GridItem && (MyEditItem as GridItem).MyFlexGrid.IsRoTable)
btnCMGoTo.Enabled = btnGoTo.Enabled = true; btnCMGoTo.Enabled = btnGoTo.Enabled = CanEditROs();//Don't allow Writers and Reviews run the RO Editor
else else
{ {
if (_MyStepRTB == null) return; if (_MyStepRTB == null) return;
if (_MyStepRTB.IsSelectionLinked(_MyStepRTB.SelectionStart, _MyStepRTB.SelectionLength)) if (_MyStepRTB.IsSelectionLinked(_MyStepRTB.SelectionStart, _MyStepRTB.SelectionLength))
{ {
// if selected text = ?, i.e. a missing/undefined destination, don't allow go to // if selected text = ?, i.e. a missing/undefined destination, don't allow go to
btnCMGoTo.Enabled = btnGoTo.Enabled = !_MyStepRTB.SelectedText.StartsWith("?"); // if the selected link is an RO then check to see if the user is allowed to run the RO Editor (writers and reviewers cannot run the RO Editor)
btnCMGoTo.Enabled = btnGoTo.Enabled = !_MyStepRTB.SelectedText.StartsWith("?") && (_MyStepRTB.SelectedText.Contains("Transition") || (_MyStepRTB.SelectedText.Contains("ReferencedObject") && CanEditROs()));
} }
else else
btnCMGoTo.Enabled = btnGoTo.Enabled = false; btnCMGoTo.Enabled = btnGoTo.Enabled = false;