IDEMPIERE-5781 Any user can destroy a configured SQL Query (#1913)

* IDEMPIERE-5781 Any user can destroy a configured SQL Query

* - fix problem not showing the advanced toolbar back

* - implement suggestion from Heng Sin
This commit is contained in:
Carlos Ruiz 2023-06-29 04:58:55 +02:00 committed by GitHub
parent 7b42d4acb8
commit 7bf225683c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 18 deletions

View File

@ -331,7 +331,7 @@ public class MUserQuery extends X_AD_UserQuery
} }
/** /**
* Returns true if the current user can save the query privately * Returns true if the current user can save the query privately and is not a SQL Query
* @return * @return
*/ */
public boolean userCanSave() { public boolean userCanSave() {
@ -340,12 +340,12 @@ public class MUserQuery extends X_AD_UserQuery
get_Value(COLUMNNAME_AD_User_ID) == null) //Cannot save privately (user-specific) an already existing global query get_Value(COLUMNNAME_AD_User_ID) == null) //Cannot save privately (user-specific) an already existing global query
return false; return false;
return true; return !getCode().startsWith("@SQL=");
} }
/** /**
* Returns true if the current users has permission * Returns true if the current users has permission
* to share or modify the query globally * to share or modify the query globally and is not a SQL Query
* @return * @return
*/ */
public boolean userCanShare() { public boolean userCanShare() {
@ -353,7 +353,7 @@ public class MUserQuery extends X_AD_UserQuery
getAD_Client_ID() != Env.getAD_Client_ID(Env.getCtx())) //Cannot modify a query from another client (e.g. System) getAD_Client_ID() != Env.getAD_Client_ID(Env.getCtx())) //Cannot modify a query from another client (e.g. System)
return false; return false;
return true; return !getCode().startsWith("@SQL=");
} }
/** Set User/Contact. /** Set User/Contact.

View File

@ -286,7 +286,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
/** IDEMPIERE-2836 User Query Where */ /** IDEMPIERE-2836 User Query Where */
private String m_whereUserQuery; private String m_whereUserQuery;
/** Toolbar for avdance search tab. North of {@link #winAdvanced}. */ /** Toolbar for advance search tab. North of {@link #winAdvanced}. */
private ToolBar advancedPanelToolBar; private ToolBar advancedPanelToolBar;
/**IDEMPIERE-4085*/ /**IDEMPIERE-4085*/
@ -634,7 +634,6 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
listhead.appendChild(lstHQueryTo); listhead.appendChild(lstHQueryTo);
listhead.appendChild(lstHRightBracket); listhead.appendChild(lstHRightBracket);
advancedPanel.appendChild(listhead); advancedPanel.appendChild(listhead);
ZKUpdateUtil.setVflex(advancedPanel, true);
Borderlayout layout = new Borderlayout(); Borderlayout layout = new Borderlayout();
ZKUpdateUtil.setHflex(layout, "1"); ZKUpdateUtil.setHflex(layout, "1");
@ -1724,18 +1723,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
fQueryName.setReadonly(false); fQueryName.setReadonly(false);
} }
msgLabel.setText(""); msgLabel.setText("");
onSelectedQueryChanged();
if(index == 0)
{ // no query - wipe and start over.
List<?> rowList = advancedPanel.getChildren();
for (int rowIndex = rowList.size() - 1; rowIndex >= 1; rowIndex--)
rowList.remove(rowIndex);
createFields();
}
else
{
parseUserQuery(userQueries[index-1]);
}
} }
else if (event.getTarget() instanceof Combobox) else if (event.getTarget() instanceof Combobox)
{ {
@ -3567,6 +3555,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
private void showAdvanced() { private void showAdvanced() {
advancedPanelToolBar.setVisible(true); advancedPanelToolBar.setVisible(true);
advancedPanel.setVisible(true); advancedPanel.setVisible(true);
winAdvanced.invalidate();
} }
/** /**