r963 - in xwiki/trunk/src/main: java/com/xpn/xwiki java/com/xpn/xwiki/objects java/com/xpn/xwiki/objects/classes java/com/xpn/xwiki/objects/meta java/com/xpn/xwiki/user/impl/xwiki web/templates

Phung Hai Nam namphunghai at users.forge.objectweb.org
Mon Mar 6 12:01:57 CET 2006


Author: namphunghai
Date: 2006-03-06 12:01:55 +0100 (Mon, 06 Mar 2006)
New Revision: 963

Added:
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/GroupsClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/LevelsClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/UsersClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/GroupsMetaClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/LevelsMetaClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/UsersMetaClass.java
Modified:
   xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/BaseCollection.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/BaseClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/BooleanMetaClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/MetaClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/user/impl/xwiki/XWikiGroupServiceImpl.java
   xwiki/trunk/src/main/web/templates/editrights.vm
   xwiki/trunk/src/main/web/templates/xwiki.vm
Log:


Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java	2006-03-06 11:01:55 UTC (rev 963)
@@ -1555,17 +1555,40 @@
 
         bclass.setName("XWiki." + pagename);
 
-        needsUpdate |= bclass.addTextField("users", "Users", 80);
-        needsUpdate |= bclass.addTextField("groups", "Groups", 80);
-        needsUpdate |= bclass.addTextField("levels", "Levels", 80);
+        PropertyInterface groupsProp = bclass.get("groups");
+        if ((groupsProp != null) && !(groupsProp instanceof GroupsClass)) {
+            bclass.removeField("groups");
+            needsUpdate = true;
+        }
+        needsUpdate |= bclass.addGroupsField("groups", "Groups");
 
+        PropertyInterface levelsProp = bclass.get("levels");
+        if ((levelsProp != null) && !(levelsProp instanceof LevelsClass)) {
+            bclass.removeField("levels");
+            needsUpdate = true;
+        }
+        needsUpdate |= bclass.addLevelsField("levels", "Levels");
+
+        PropertyInterface usersProp = bclass.get("users");
+        if ((usersProp != null) && !(usersProp instanceof UsersClass)) {
+            bclass.removeField("users");
+            needsUpdate = true;
+        }
+        needsUpdate |= bclass.addUsersField("users", "Users");
+
         PropertyInterface allowProp = bclass.get("allow");
         if ((allowProp != null) && (allowProp instanceof NumberClass)) {
             bclass.removeField("allow");
             needsUpdate = true;
         }
         needsUpdate |= bclass.addBooleanField("allow", "Allow/Deny", "allow");
+        BooleanClass afield = (BooleanClass) bclass.get("allow");
+        if (afield.getDefaultValue()!=1) {
+            afield.setDefaultValue(1);
+            needsUpdate = true;
+        }
 
+
         String content = doc.getContent();
         if ((content == null) || (content.equals("")))
             doc.setContent("1 XWiki " + pagename + " Class");

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/BaseCollection.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/BaseCollection.java	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/BaseCollection.java	2006-03-06 11:01:55 UTC (rev 963)
@@ -164,15 +164,19 @@
 
 
     public int getIntValue(String name) {
+        return getIntValue(name, 0);
+    }
+
+    public int getIntValue(String name, int default_value) {
         try {
         NumberProperty prop = (NumberProperty)safeget(name);
         if (prop==null)
-         return 0;
+         return default_value;
         else
          return ((Number)prop.getValue()).intValue();
         }
          catch (Exception e) {
-            return 0;
+            return default_value;
         }
     }
 

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/BaseClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/BaseClass.java	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/BaseClass.java	2006-03-06 11:01:55 UTC (rev 963)
@@ -1,25 +1,25 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ludovic
- * @author sdumitriu
- */
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ludovic
+ * @author sdumitriu
+ */
 
 package com.xpn.xwiki.objects.classes;
 
@@ -265,6 +265,60 @@
         return false;
     }
 
+    public boolean addUsersField(String fieldName, String fieldPrettyName) {
+        return addUsersField(fieldName, fieldPrettyName, 5);
+    }
+
+    public boolean addUsersField(String fieldName, String fieldPrettyName,int size) {
+        if (get(fieldName) == null) {
+            UsersClass users_class = new UsersClass();
+            users_class.setName(fieldName);
+            users_class.setPrettyName(fieldPrettyName);
+            users_class.setSize(size);
+            users_class.setMultiSelect(true);
+            users_class.setObject(this);
+            put(fieldName, users_class);
+            return true;
+        }
+        return false ;
+    }
+
+    public boolean addLevelsField(String fieldName, String fieldPrettyName) {
+        return addLevelsField(fieldName, fieldPrettyName, 3);
+    }
+
+    public boolean addLevelsField(String fieldName, String fieldPrettyName,int size) {
+        if (get(fieldName) == null) {
+            LevelsClass levels_class = new LevelsClass();
+            levels_class.setName(fieldName);
+            levels_class.setPrettyName(fieldPrettyName);
+            levels_class.setSize(size);
+            levels_class.setMultiSelect(true);
+            levels_class.setObject(this);
+            put(fieldName, levels_class);
+            return true;
+        }
+        return false ;
+    }
+
+    public boolean addGroupsField(String fieldName, String fieldPrettyName) {
+        return addGroupsField(fieldName, fieldPrettyName, 5);
+    }
+
+    public boolean addGroupsField(String fieldName, String fieldPrettyName,int size) {
+        if (get(fieldName) == null) {
+            GroupsClass groups_class = new GroupsClass();
+            groups_class.setName(fieldName);
+            groups_class.setPrettyName(fieldPrettyName);
+            groups_class.setSize(size);
+            groups_class.setMultiSelect(true);
+            groups_class.setObject(this);
+            put(fieldName, groups_class);
+            return true;
+        }
+        return false ;
+    }
+
     public boolean addTemplateField(String fieldName, String fieldPrettyName) {
         return addTextAreaField(fieldName, fieldPrettyName, 80, 15);
     }

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java	2006-03-06 11:01:55 UTC (rev 963)
@@ -1,25 +1,25 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ludovic
- * @author sdumitriu
- */
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ludovic
+ * @author sdumitriu
+ */
 
 package com.xpn.xwiki.objects.classes;
 
@@ -51,10 +51,19 @@
         return dtype;
     }
 
+    public void setDefaultValue(int dvalue) {
+        setIntValue("defaultValue", dvalue);
+    }
+
+    public int getDefaultValue() {
+        return getIntValue("defaultValue", -1);
+    }
+
     public void setDisplayType(String type) {
         setStringValue("displayType", type);
     }
 
+
     public BaseProperty fromString(String value) {
         BaseProperty property = newProperty();
         Number nvalue = null;
@@ -100,6 +109,12 @@
                     options[1].setSelected(true);
                 else if (value==0)
                     options[2].setSelected(true);
+            }  else {
+                int value = getDefaultValue();
+                if (value==1)
+                    options[1].setSelected(true);
+                else if (value==0)
+                    options[2].setSelected(true);
             }
         }} catch (Exception e) {
             // This should not happen

Added: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/GroupsClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/GroupsClass.java	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/GroupsClass.java	2006-03-06 11:01:55 UTC (rev 963)
@@ -0,0 +1,107 @@
+package com.xpn.xwiki.objects.classes;
+
+import com.xpn.xwiki.objects.meta.PropertyMetaClass;
+import com.xpn.xwiki.objects.*;
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
+import org.apache.ecs.xhtml.select;
+import org.apache.ecs.xhtml.option;
+import org.apache.commons.lang.StringUtils;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public class GroupsClass extends ListClass {
+
+    public GroupsClass(PropertyMetaClass wclass) {
+        super("groupslist", "Groups List", wclass);
+        setSize(6);
+    }
+
+    public GroupsClass() {
+        this(null);
+    }
+
+    public List getList(XWikiContext context) {
+        List list;
+        try {
+            list = context.getWiki().getGroupService().listAllGroups(context);
+        } catch (XWikiException e) {
+            // TODO add log exception
+            list = new ArrayList();
+
+        }
+
+        list.remove("XWiki.XWikiAllGroup");
+        list.add(0,"XWiki.XWikiAllGroup");
+        if ((context.getWiki().isVirtual()&&(!context.getDatabase().equals("xwiki")))) {
+            list.remove("xwiki:XWiki.XWikiAllGroup");
+            list.add(0,"xwiki:XWiki.XWikiAllGroup");
+        }
+        return list;
+    }
+
+    public BaseProperty newProperty() {
+        return new StringProperty();
+    }
+
+    public BaseProperty fromString(String value) {
+        BaseProperty prop = newProperty();
+        prop.setValue(value);
+        return prop;
+    }
+
+    public BaseProperty fromStringArray(String[] strings) {
+        List list = new ArrayList();
+        for (int i=0;i<strings.length;i++)
+            list.add(strings[i]);
+        BaseProperty prop = newProperty();
+        prop.setValue(StringUtils.join(list.toArray(), ","));
+        return prop;
+    }
+
+    public String getText(String value, XWikiContext context) {
+        return context.getWiki().getUserName(value, null, false, context);
+    }
+
+        public static List getListFromString(String value) {
+        List list = new ArrayList();
+        if (value==null)
+            return list;
+
+        String val = StringUtils.replace(value, "\\,", "%SEP%");
+        String[] result = StringUtils.split(value,", ");
+        for (int i=0;i<result.length;i++)
+            list.add(StringUtils.replace(result[i],"%SEP%", ","));
+        return list;
+    }
+
+      public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
+            select select = new select(prefix + name, 1);
+            select.setMultiple(isMultiSelect());
+            select.setSize(getSize());
+
+            List list = getList(context);
+            List selectlist;
+
+            BaseProperty prop =  (BaseProperty)object.safeget(name);
+            if (prop==null) {
+                selectlist = new ArrayList();
+            } else {
+                selectlist = getListFromString((String)prop.getValue());
+            }
+
+            // Add options from Set
+            for (Iterator it=list.iterator();it.hasNext();) {
+                String value = it.next().toString();
+                option option = new option(value, value);
+                option.addElement(getText(value, context));
+                if (selectlist.contains(value))
+                    option.setSelected(true);
+                select.addElement(option);
+            }
+
+            buffer.append(select.toString());
+    }
+}

Added: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/LevelsClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/LevelsClass.java	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/LevelsClass.java	2006-03-06 11:01:55 UTC (rev 963)
@@ -0,0 +1,107 @@
+package com.xpn.xwiki.objects.classes;
+
+import com.xpn.xwiki.objects.meta.PropertyMetaClass;
+import com.xpn.xwiki.objects.*;
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
+import org.apache.ecs.xhtml.select;
+import org.apache.ecs.xhtml.option;
+import org.apache.commons.lang.StringUtils;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public class LevelsClass extends ListClass {
+
+    public LevelsClass(PropertyMetaClass wclass) {
+        super("levelslist", "Levels List", wclass);
+        setSize(6);
+    }
+
+    public LevelsClass() {
+        this(null);
+    }
+
+    public List getList(XWikiContext context) {
+        List list;
+        try {
+            list = context.getWiki().getGroupService().listAllLevels(context);
+        } catch (XWikiException e) {
+            // TODO add log exception
+            list = new ArrayList();
+
+        }
+        if (!"1".equals(context.getRequest().get("global"))) {
+            list.remove("admin");
+            list.remove("programming");
+            list.remove("delete");
+            list.remove("register");
+        }
+
+        return list;
+    }
+
+    public BaseProperty newProperty() {
+        return new StringProperty();
+    }
+
+    public BaseProperty fromString(String value) {
+        BaseProperty prop = newProperty();
+        prop.setValue(value);
+        return prop;
+    }
+
+    public BaseProperty fromStringArray(String[] strings) {
+        List list = new ArrayList();
+        for (int i=0;i<strings.length;i++)
+            list.add(strings[i]);
+        BaseProperty prop = newProperty();
+        prop.setValue(StringUtils.join(list.toArray(), ","));
+        return prop;
+    }
+
+    public String getText(String value, XWikiContext context) {
+        return context.getWiki().getUserName(value, null, false, context);
+    }
+
+        public static List getListFromString(String value) {
+        List list = new ArrayList();
+        if (value==null)
+            return list;
+
+        String val = StringUtils.replace(value, "\\,", "%SEP%");
+        String[] result = StringUtils.split(value,", ");
+        for (int i=0;i<result.length;i++)
+            list.add(StringUtils.replace(result[i],"%SEP%", ","));
+        return list;
+    }
+
+      public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
+            select select = new select(prefix + name, 1);
+            select.setMultiple(isMultiSelect());
+            select.setSize(getSize());
+
+            List list = getList(context);
+            List selectlist;
+
+            BaseProperty prop =  (BaseProperty)object.safeget(name);
+            if (prop==null) {
+                selectlist = new ArrayList();
+            } else {
+                selectlist = getListFromString((String)prop.getValue());
+            }
+
+            // Add options from Set
+            for (Iterator it=list.iterator();it.hasNext();) {
+                String value = it.next().toString();
+                option option = new option(value, value);
+                option.addElement(getText(value, context));
+                if (selectlist.contains(value))
+                    option.setSelected(true);
+                select.addElement(option);
+            }
+
+            buffer.append(select.toString());
+    }
+}

Added: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/UsersClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/UsersClass.java	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/UsersClass.java	2006-03-06 11:01:55 UTC (rev 963)
@@ -0,0 +1,103 @@
+package com.xpn.xwiki.objects.classes;
+
+import com.xpn.xwiki.objects.meta.PropertyMetaClass;
+import com.xpn.xwiki.objects.*;
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
+import org.apache.ecs.xhtml.select;
+import org.apache.ecs.xhtml.option;
+import org.apache.commons.lang.StringUtils;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public class UsersClass extends ListClass {
+
+    public UsersClass(PropertyMetaClass wclass) {
+        super("userslist", "Users List", wclass);
+        setSize(6);
+    }
+
+    public UsersClass() {
+        this(null);
+    }
+
+    public List getList(XWikiContext context) {
+        List list;
+        try {
+            list = context.getWiki().getGroupService().listMemberForGroup("XWiki.XWikiAllGroup", context);
+        } catch (XWikiException e) {
+            // TODO add log exception
+            list = new ArrayList();
+
+        }
+
+        list.remove("XWiki.XWikiGuest");
+        list.add(0,"XWiki.XWikiGuest");
+        return list;
+    }
+
+    public BaseProperty newProperty() {
+        return new StringProperty();
+    }
+
+    public BaseProperty fromString(String value) {
+        BaseProperty prop = newProperty();
+        prop.setValue(value);
+        return prop;
+    }
+
+    public BaseProperty fromStringArray(String[] strings) {
+        List list = new ArrayList();
+        for (int i=0;i<strings.length;i++)
+            list.add(strings[i]);
+        BaseProperty prop = newProperty();
+        prop.setValue(StringUtils.join(list.toArray(), ","));
+        return prop;
+    }
+
+    public String getText(String value, XWikiContext context) {
+        return context.getWiki().getUserName(value, null, false, context);
+    }
+
+        public static List getListFromString(String value) {
+        List list = new ArrayList();
+        if (value==null)
+            return list;
+
+        String val = StringUtils.replace(value, "\\,", "%SEP%");
+        String[] result = StringUtils.split(value,", ");
+        for (int i=0;i<result.length;i++)
+            list.add(StringUtils.replace(result[i],"%SEP%", ","));
+        return list;
+    }
+
+      public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
+            select select = new select(prefix + name, 1);
+            select.setMultiple(isMultiSelect());
+            select.setSize(getSize());
+
+            List list = getList(context);
+            List selectlist;
+
+            BaseProperty prop =  (BaseProperty)object.safeget(name);
+            if (prop==null) {
+                selectlist = new ArrayList();
+            } else {
+                selectlist = getListFromString((String)prop.getValue());
+            }
+
+            // Add options from Set
+            for (Iterator it=list.iterator();it.hasNext();) {
+                String value = it.next().toString();
+                option option = new option(value, value);
+                option.addElement(getText(value, context));
+                if (selectlist.contains(value))
+                    option.setSelected(true);
+                select.addElement(option);
+            }
+
+            buffer.append(select.toString());
+    }
+}

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/BooleanMetaClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/BooleanMetaClass.java	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/BooleanMetaClass.java	2006-03-06 11:01:55 UTC (rev 963)
@@ -1,30 +1,31 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ludovic
- */
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ludovic
+ */
 
 package com.xpn.xwiki.objects.meta;
 
 import com.xpn.xwiki.objects.BaseCollection;
 import com.xpn.xwiki.objects.classes.BooleanClass;
 import com.xpn.xwiki.objects.classes.StringClass;
+import com.xpn.xwiki.objects.classes.NumberClass;
 import com.xpn.xwiki.XWikiContext;
 
 public class BooleanMetaClass extends PropertyMetaClass {
@@ -39,6 +40,13 @@
         type_class.setPrettyName("Display Type");
         type_class.setSize(20);
         safeput("displayType", type_class);
+
+        NumberClass default_value_class = new NumberClass(this);
+        default_value_class.setName("defaultValue");
+        default_value_class.setPrettyName("Default Value");
+        default_value_class.setSize(5);
+        default_value_class.setClassType("integer");
+        safeput("defaultValue", default_value_class);
     }
 
     public BaseCollection newObject(XWikiContext context) {

Added: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/GroupsMetaClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/GroupsMetaClass.java	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/GroupsMetaClass.java	2006-03-06 11:01:55 UTC (rev 963)
@@ -0,0 +1,18 @@
+package com.xpn.xwiki.objects.meta;
+
+import com.xpn.xwiki.objects.classes.GroupsClass;
+import com.xpn.xwiki.objects.BaseCollection;
+import com.xpn.xwiki.XWikiContext;
+
+public class GroupsMetaClass extends ListMetaClass {
+    public GroupsMetaClass() {
+        super();
+        setPrettyName("Groups List Class");
+        setName(GroupsClass.class.getName());
+
+    }
+
+    public BaseCollection newObject(XWikiContext context) {
+        return new GroupsMetaClass();
+    }
+}

Added: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/LevelsMetaClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/LevelsMetaClass.java	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/LevelsMetaClass.java	2006-03-06 11:01:55 UTC (rev 963)
@@ -0,0 +1,19 @@
+package com.xpn.xwiki.objects.meta;
+
+import com.xpn.xwiki.objects.classes.GroupsClass;
+import com.xpn.xwiki.objects.classes.LevelsClass;
+import com.xpn.xwiki.objects.BaseCollection;
+import com.xpn.xwiki.XWikiContext;
+
+public class LevelsMetaClass extends ListMetaClass {
+    public LevelsMetaClass() {
+        super();
+        setPrettyName("Level Class");
+        setName(LevelsClass.class.getName());
+
+    }
+
+    public BaseCollection newObject(XWikiContext context) {
+        return new LevelsMetaClass();
+    }
+}

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/MetaClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/MetaClass.java	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/MetaClass.java	2006-03-06 11:01:55 UTC (rev 963)
@@ -1,24 +1,24 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ludovic
- */
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ludovic
+ */
 
 package com.xpn.xwiki.objects.meta;
 
@@ -27,6 +27,7 @@
 import com.xpn.xwiki.objects.PropertyInterface;
 import com.xpn.xwiki.objects.classes.BaseClass;
 import com.xpn.xwiki.objects.classes.PropertyClass;
+import com.xpn.xwiki.objects.classes.UsersClass;
 import com.xpn.xwiki.XWikiContext;
 
 public class MetaClass extends BaseClass {
@@ -50,6 +51,12 @@
         safeput(dblistclass.getName(), dblistclass);
         DateMetaClass dateclass = new DateMetaClass();
         safeput(dateclass.getName(), dateclass);
+        GroupsMetaClass groupsclass = new GroupsMetaClass();
+        safeput(groupsclass.getName(), groupsclass);
+        UsersMetaClass usersclass = new UsersMetaClass();
+        safeput(usersclass.getName(), usersclass);
+        LevelsMetaClass levelsclass = new LevelsMetaClass();
+        safeput(levelsclass.getName(), levelsclass);
     }
 
     public void safeput(String name, PropertyInterface property) {

Added: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/UsersMetaClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/UsersMetaClass.java	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/UsersMetaClass.java	2006-03-06 11:01:55 UTC (rev 963)
@@ -0,0 +1,20 @@
+package com.xpn.xwiki.objects.meta;
+
+import com.xpn.xwiki.objects.classes.StaticListClass;
+import com.xpn.xwiki.objects.classes.StringClass;
+import com.xpn.xwiki.objects.classes.UsersClass;
+import com.xpn.xwiki.objects.BaseCollection;
+import com.xpn.xwiki.XWikiContext;
+
+public class UsersMetaClass extends ListMetaClass {
+    public UsersMetaClass() {
+        super();
+        setPrettyName("Users List Class");
+        setName(UsersClass.class.getName());
+
+    }
+
+    public BaseCollection newObject(XWikiContext context) {
+        return new UsersMetaClass();
+    }
+}

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/user/impl/xwiki/XWikiGroupServiceImpl.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/user/impl/xwiki/XWikiGroupServiceImpl.java	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/user/impl/xwiki/XWikiGroupServiceImpl.java	2006-03-06 11:01:55 UTC (rev 963)
@@ -1,35 +1,37 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ludovic
- * @author sdumitriu
- */
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ludovic
+ * @author sdumitriu
+ */
 
 package com.xpn.xwiki.user.impl.xwiki;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Vector;
 
 import com.xpn.xwiki.XWiki;
 import com.xpn.xwiki.XWikiContext;
 import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.objects.BaseObject;
 import com.xpn.xwiki.cache.api.XWikiCache;
 import com.xpn.xwiki.cache.api.XWikiCacheNeedsRefreshException;
 import com.xpn.xwiki.cache.api.XWikiCacheService;
@@ -96,6 +98,55 @@
         list.add(group);
     }
 
+    public List listMemberForGroup(String group, XWikiContext context) throws XWikiException {
+        List list = new ArrayList();
+        String database = context.getDatabase();
+        String sql = "";
+
+        try {
+            String gshortname = Util.getName(group, context);
+            if (gshortname.equals("XWiki.XWikiAllGroup")) {
+                sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'";
+                return context.getWiki().getStore().searchDocumentsNames(sql, context);
+            }
+            else  {
+                XWikiDocument docgroup = context.getWiki().getDocument(gshortname, context);
+                Vector v = docgroup.getObjects("XWiki.XWikiGroups");
+                for (int i=0;i<v.size();i++) {
+                    BaseObject bobj = (BaseObject) v.get(i);
+                    if (bobj!=null) {
+                        String members = bobj.getStringValue("member");
+                        if (members!=null) {
+                            String[] members2 = members.split(" ,");
+                            for (int j=0;j<members2.length;j++) {
+                                list.add(members2[i]);
+                            }
+                        }
+                    }
+                }
+                return list;
+            }
+        } finally {
+            context.setDatabase(database);
+        }
+    }
+
+    public List listAllGroups(XWikiContext context) throws XWikiException
+    {
+        String sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiGroups'";
+        return context.getWiki().getStore().searchDocumentsNames(sql, context);
+    }
+
+    public List listAllLevels(XWikiContext context) throws XWikiException {
+        List list = new ArrayList();
+        String levels ="admin,view,edit,comment,delete,register,programming";
+        String[] level =  levels.split(",");
+        for (int i=0; i<level.length; i++) {
+            list.add(level[i]);
+        }
+        return list;
+    }
+
     public void notify(XWikiNotificationRule rule, XWikiDocument newdoc, XWikiDocument olddoc, int event, XWikiContext context) {
         try {
             if (event==XWikiNotificationInterface.EVENT_CHANGE) {

Modified: xwiki/trunk/src/main/web/templates/editrights.vm
===================================================================
--- xwiki/trunk/src/main/web/templates/editrights.vm	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/web/templates/editrights.vm	2006-03-06 11:01:55 UTC (rev 963)
@@ -27,7 +27,8 @@
 <div id="intro">
 $msg.get("welcometorightseditor")
 </div>
-
+<div style="overflow:hidden;width:100%">
+<div style="float:left">
 <form id="update" method="post" action="$doc.getURL("save")" onsubmit="cancelCancelEdit()">
 <p>
 <input type="hidden" name="xredirect" value="$xwiki.getFormEncoded($redirect)" />
@@ -35,33 +36,28 @@
 #set( $nb = $doc.getObjectNumbers("${class.name}"))
 <input type="hidden" name="${class.name}_nb" value="$nb" />
 </p>
-
-#foreach($obj in $doc.getObjects($class.name))
-<div id="${class.name}_${obj.number}" style="display: #if ($first==1) block #else none #end;">
-#if ($first==1)
-<script type="text/javascript">
-<!--
-currentfield = "${class.name}_${obj.number}";
-// -->
-</script>
-#set ($first = 0)
-#end
-
-
-$msg.get("youcan") <a href="$doc.getURL("objectremove", "classname=${class.name}&amp;classid=${obj.number}&amp;xredirect=${xwiki.getURLEncoded($redirect)}")"
+ <table border="1" cellpadding="4" cellspacing="0" width="90%">
+ <tr>
+    <th>$msg.get("Right")</th><th>$msg.get("Users")</th><th>$msg.get("Groups")</th><th>$msg.get("Level")</th><th>$msg.get("Allow-Deny")</th><th>$msg.get("Remove")</th>
+ </tr>
+#foreach ($obj in $doc.getObjects($class.name))
+#set($class = $obj.xWikiClass)
+    <tr>
+        <td align="center">$!{obj.number}</td>
+        <td align="center">$!doc.displayEdit($class.users,"${class.name}_${obj.number}_",$obj)</td>
+        <td align="center">$!doc.displayEdit($class.groups,"${class.name}_${obj.number}_",$obj)</td>
+        <td align="center">$!doc.displayEdit($class.levels,"${class.name}_${obj.number}_",$obj)</td>
+        <td align="center">$!doc.displayEdit($class.allow,"${class.name}_${obj.number}_",$obj)</td>
+        <td align="center"><a href="$doc.getURL("objectremove", "classname=${class.name}&amp;classid=${obj.number}&amp;xredirect=${xwiki.getURLEncoded($redirect)}")"
     onclick="return confirm('$msg.get("confirmobjectremove")')">
-    $msg.get("removethisrightentry")</a><br /><br /><br />
-
-<table>
-#foreach($prop in $class.properties)
-<tr><td>$prop.prettyName</td>
-<td>$!doc.displayEdit($prop, "${class.name}_${obj.number}_",  $obj)
-</td></tr>
+    $msg.get("removethisrightentry")</a></td>
+    </tr>
 #end
-</table>
-</div>
-#end
+ </table>
 </form>
+</div>
+</div>
+</div>
 #includeHelp("EditRightsHelp")
          </div>
             </div>
@@ -81,10 +77,6 @@
 <h3>$msg.get("currentrights")</h3>
 <a href="" onclick="showobjects('$class.name'); return false;">$class.name</a><br />
 <div id="class_${class.name}">
-#foreach ($obj in $doc.getObjects($class.name))
-&nbsp;&nbsp;<a href="" onclick="show('${class.name}_${obj.number}'); return false;">
-$!{obj.number}: $!doc.display("users",$obj) $!doc.display("groups",$obj)</a><br />
-#end
 <br /><br />
 <h3>$msg.get("addrightentry")</h3>
 <form id="objectadd" method="post" action="$doc.getURL("objectadd")" onsubmit="cancelCancelEdit()">

Modified: xwiki/trunk/src/main/web/templates/xwiki.vm
===================================================================
--- xwiki/trunk/src/main/web/templates/xwiki.vm	2006-03-06 06:52:29 UTC (rev 962)
+++ xwiki/trunk/src/main/web/templates/xwiki.vm	2006-03-06 11:01:55 UTC (rev 963)
@@ -1,6 +1,10 @@
 #set($viewurl = $doc.getURL("view"))
 #set($parent ="<a href='$doc.getParentURL()'>${doc.parent}</a>")
+#if($tdoc)
 #set($headertitle = "<a href='$viewurl'>${tdoc.displayTitle}</a>")
+#else
+#set($headertitle = "<a href='$viewurl'>${doc.displayTitle}</a>")
+#end
 #set($skin=$xwiki.getSkin())
 #set($copyright=$xwiki.getWebCopyright())
 #set($xwikimode=$context.getMode())





More information about the Xwiki-notifications mailing list