Пример #1
0
  // Deletes a group
  public void delete() {
    String groupId[] = this.request.getParameterValues("group_id");

    if (groupId == null) {
      this.list();

      return;
    }

    List errors = new ArrayList();
    GroupDAO gm = DataAccessDriver.getInstance().newGroupDAO();

    for (int i = 0; i < groupId.length; i++) {
      int id = Integer.parseInt(groupId[i]);

      if (gm.canDelete(id)) {
        gm.delete(id);
      } else {
        errors.add(I18n.getMessage(I18n.CANNOT_DELETE_GROUP, new Object[] {new Integer(id)}));
      }
    }

    if (errors.size() > 0) {
      this.context.put("errorMessage", errors);
    }

    this.list();
  }
Пример #2
0
  // Edit a group
  public void edit() {
    int groupId = this.request.getIntParameter("group_id");
    GroupDAO gm = DataAccessDriver.getInstance().newGroupDAO();

    this.setTemplateName(TemplateKeys.GROUP_EDIT);

    this.context.put("group", gm.selectById(groupId));
    this.context.put("groups", new TreeGroup().getNodes());
    this.context.put("selectedList", new ArrayList());
    this.context.put("action", "editSave");
  }
Пример #3
0
  // Saves a new group
  public void insertSave() {
    GroupDAO gm = DataAccessDriver.getInstance().newGroupDAO();

    Group g = new Group();
    g.setDescription(this.request.getParameter("group_description"));
    g.setParentId(this.request.getIntParameter("parent_id"));
    g.setName(this.request.getParameter("group_name"));

    gm.addNew(g);

    this.list();
  }
Пример #4
0
  // Permissions
  public void permissions() {
    int id = this.request.getIntParameter("group_id");

    PermissionControl pc = new PermissionControl();
    pc.setRoles(DataAccessDriver.getInstance().newGroupSecurityDAO().loadRoles(id));

    String xmlconfig = SystemGlobals.getValue(ConfigKeys.CONFIG_DIR) + "/permissions.xml";
    List sections = new XMLPermissionControl(pc).loadConfigurations(xmlconfig);

    GroupDAO gm = DataAccessDriver.getInstance().newGroupDAO();

    this.context.put("sections", sections);
    this.context.put("group", gm.selectById(id));
    this.setTemplateName(TemplateKeys.GROUP_PERMISSIONS);
  }