Index: lams_central/src/java/org/lamsfoundation/lams/web/planner/PedagogicalPlannerAction.java =================================================================== diff -u -r563045bff5bdf4ea8cd93ee8047ae396ed41f67f -rf38d16b408d1bac69c9f3493999e8c288f5dc845 --- lams_central/src/java/org/lamsfoundation/lams/web/planner/PedagogicalPlannerAction.java (.../PedagogicalPlannerAction.java) (revision 563045bff5bdf4ea8cd93ee8047ae396ed41f67f) +++ lams_central/src/java/org/lamsfoundation/lams/web/planner/PedagogicalPlannerAction.java (.../PedagogicalPlannerAction.java) (revision f38d16b408d1bac69c9f3493999e8c288f5dc845) @@ -753,13 +753,16 @@ PedagogicalPlannerSequenceNode node = null; PedagogicalPlannerSequenceNodeForm nodeForm = (PedagogicalPlannerSequenceNodeForm) form; + boolean newRootNode = false; if (nodeUid == null) { // It's a new subnode node = new PedagogicalPlannerSequenceNode(); Long parentUid = nodeForm.getParentUid() == 0 ? null : nodeForm.getParentUid(); if (parentUid != null) { PedagogicalPlannerSequenceNode parent = getPedagogicalPlannerDAO().getByUid(parentUid); node.setParent(parent); + } else { + newRootNode = true; } node.setOrder(getPedagogicalPlannerDAO().getNextOrderId(parentUid)); } else { @@ -829,6 +832,16 @@ getPedagogicalPlannerDAO().saveOrUpdateNode(node); // If it was a new subnode, we need to retrieved the assigned UID nodeUid = node.getUid(); + // If it was a new root node, add creator's role + if (newRootNode) { + try { + HttpSession s = SessionManager.getSession(); + UserDTO u = (UserDTO) s.getAttribute(AttributeNames.USER); + getPedagogicalPlannerDAO().saveNodeRole(u.getUserID(), nodeUid, Role.ROLE_AUTHOR_ADMIN); + } catch (Exception e) { + log.error("Error saving role for newly created root node: " + e.getMessage()); + } + } } catch (RepositoryCheckedException e) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(