On 23.03.2010 14:36, Matteo Pelucco wrote:
Something like this:
Implemented with success.
But I see something "strange" in Magnolia calls, take a look in
*isEditDialog* method......
For that reason I can not provide my extension on creating paragraphs,
only while editing them.
Anyway, this is a working code:
************************************************************
public class CustomDialogMVCServlet extends DialogMVCServlet{
private static final long serialVersionUID = 1L;
private static final Logger log =
LoggerFactory.getLogger(TinextDialogMVCServlet.class);
@Override
protected String getDialogName(HttpServletRequest request) {
final String dialogName = super.getDialogName(request);
// Magnolia uses this method also for calling actions (editParagraph
/ saveParagraph...)
// only in EDIT mode, in new paragraph keep Magnolia standard behaviour
if (StringUtils.equals("editParagraph", dialogName) && isEditDialog()){
final String paragraphName =
MgnlContext.getParameter("mgnlParagraph"); // should not change until
Magnolia 5.0
// change for superuser
User loggedUser = MgnlContext.getUser();
if (null != paragraphName && loggedUser.hasRole("superuser")){
Paragraph paragraph =
ParagraphManager.getInstance().getParagraphDefinition(paragraphName);
if (null != paragraph){
Map<String, String> parametersMap = paragraph.getParameters();
if (null != parametersMap){
String superuserDialog = parametersMap.get("superuserDialog");
if (null != superuserDialog) return superuserDialog;
}
}
}
}
// TODO: change for any other roles
return dialogName;
}
private boolean isEditDialog() {
// an edit dialog is recognize because mgnlNode != mgnlNew
final String mgnlNode = MgnlContext.getParameter("mgnlNode");
return !StringUtils.equals("mgnlNew", mgnlNode);
}
}
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------