Author: mflorea
Date: 2008-01-08 16:08:00 +0100 (Tue, 08 Jan 2008)
New Revision: 6671
Modified:
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManager.java
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/plugin/SpaceManagerPluginApi.java
Log:
CURRIKI-1210 + CURRIKI-1321
Modified:
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManager.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManager.java
2008-01-08 15:07:24 UTC (rev 6670)
+++
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManager.java
2008-01-08 15:08:00 UTC (rev 6671)
@@ -350,7 +350,7 @@
public Collection getUsersForRole(String spaceName, String role,
XWikiContext context) throws SpaceManagerException;
/**
- * Checks id the a user is a member in a space
+ * Checks if a user is a member in a space
* @param spaceName
* @param user
* @param context
@@ -360,6 +360,18 @@
public boolean isMember(String spaceName, String user, XWikiContext
context) throws SpaceManagerException;
/**
+ * Checks if the user with the given name is an admin of the specified
space
+ *
+ * @param spaceName
+ * @param userName
+ * @param context
+ * @return
+ * @throws SpaceManagerException
+ */
+ boolean isAdmin(String spaceName, String userName, XWikiContext context)
+ throws SpaceManagerException;
+
+ /**
*
* @param spaceName
* @param context
Modified:
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
2008-01-08 15:07:24 UTC (rev 6670)
+++
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
2008-01-08 15:08:00 UTC (rev 6671)
@@ -46,13 +46,14 @@
public final static String SPACEMANAGER_EXTENSION_CFG_PROP =
"xwiki.spacemanager.extension";
public final static String SPACEMANAGER_DEFAULT_EXTENSION =
"org.xwiki.plugin.spacemanager.impl.SpaceManagerExtensionImpl";
+ public final static String SPACEMANAGER_DEFAULT_MAIL_NOTIFICATION = "1";
/**
* The extension that defines specific functions for this space manager
*/
protected SpaceManagerExtension spaceManagerExtension;
- protected boolean mailNotification = true;
+ protected boolean mailNotification;
/**
* Space manager constructor
@@ -63,6 +64,10 @@
public SpaceManagerImpl(String name, String className, XWikiContext
context)
{
super(name, className, context);
+ String mailNotificationCfg =
+ context.getWiki().Param("xwiki.spacemanager.mailnotification",
+
SpaceManagerImpl.SPACEMANAGER_DEFAULT_MAIL_NOTIFICATION).trim();
+ mailNotification = "1".equals(mailNotificationCfg);
}
/**
@@ -642,6 +647,16 @@
throw new SpaceManagerException(e);
}
}
+
+ public boolean isAdmin(String spaceName, String userName, XWikiContext
context)
+ throws SpaceManagerException
+ {
+ try {
+ return isMemberOfGroup(userName, getAdminGroupName(spaceName),
context);
+ } catch (XWikiException e) {
+ throw new SpaceManagerException(e);
+ }
+ }
public void addUserToRole(String spaceName, String username, String role,
XWikiContext context) throws SpaceManagerException {
try {
@@ -729,6 +744,19 @@
throws SpaceManagerException
{
try {
+ // remove admin role
+ if (isAdmin(spaceName, userName, context)) {
+ removeAdmin(spaceName, userName, context);
+ }
+ // remove all the other roles
+ Iterator it = getRoles(spaceName, context).iterator();
+ while (it.hasNext()) {
+ String role = (String) it.next();
+ removeUserFromRole(spaceName, userName, role, context);
+ }
+ // delete space user profile
+ deleteSpaceUserProfile(spaceName, userName, context);
+ // remove member
removeUserFromGroup(userName, getMemberGroupName(spaceName),
context);
} catch (XWikiException e) {
throw new SpaceManagerException(e);
@@ -840,6 +868,18 @@
public SpaceUserProfile getSpaceUserProfile(String spaceName, String
username, XWikiContext context) throws SpaceManagerException {
return newUserSpaceProfile(username, spaceName, context);
}
+
+ private void deleteSpaceUserProfile(String spaceName, String userName,
XWikiContext context)
+ throws SpaceManagerException
+ {
+ try {
+ String docName = getSpaceUserProfilePageName(userName, spaceName);
+ XWikiDocument doc = context.getWiki().getDocument(docName,
context);
+ context.getWiki().deleteDocument(doc, context);
+ } catch (XWikiException e) {
+ throw new SpaceManagerException(e);
+ }
+ }
public String getSpaceUserProfilePageName(String userName, String
spaceName) {
return
getSpaceManagerExtension().getSpaceUserProfilePageName(userName, spaceName);
Modified:
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/plugin/SpaceManagerPluginApi.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/plugin/SpaceManagerPluginApi.java
2008-01-08 15:07:24 UTC (rev 6670)
+++
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/plugin/SpaceManagerPluginApi.java
2008-01-08 15:08:00 UTC (rev 6671)
@@ -302,7 +302,7 @@
/**
* Join the space
- *
+ *
* @param spaceName
*/
public boolean joinSpace(String spaceName) throws SpaceManagerException {
@@ -326,6 +326,20 @@
}
/**
+ * Removes a wiki user from the list of space members
+ *
+ * @param spaceName
+ * @param wikiName
+ * @throws SpaceManagerException
+ */
+ public void removeMember(String spaceName, String wikiName) throws
SpaceManagerException
+ {
+ if (hasProgrammingRights()) {
+ getSpaceManager().removeMember(spaceName, wikiName, context);
+ }
+ }
+
+ /**
* Add a wiki user as admin in the space
*
* @param spaceName
@@ -336,6 +350,19 @@
getSpaceManager().addAdmin(spaceName, wikiname, context);
}
+ /**
+ * Removes a wiki user from the list of space admins
+ *
+ * @param spaceName
+ * @param wikiName
+ * @throws SpaceManagerException
+ */
+ public void removeAdmin(String spaceName, String wikiName) throws
SpaceManagerException
+ {
+ if (hasProgrammingRights()) {
+ getSpaceManager().removeAdmin(spaceName, wikiName, context);
+ }
+ }
/**
* Search for documents in the space
@@ -365,7 +392,10 @@
/**
* @return the list of all members of the space that are admins
*/
- // public List getAdmins(Space space) throws SpaceManagerException;
+ public Collection getAdmins(String spaceName) throws SpaceManagerException
+ {
+ return getSpaceManager().getAdmins(spaceName, context);
+ }
/**
* Add user to the specific role in the space
@@ -423,4 +453,8 @@
return getSpaceManager().isMember(spaceName, username, context);
}
+ public boolean isAdmin(String spaceName, String userName) throws
SpaceManagerException
+ {
+ return getSpaceManager().isAdmin(spaceName, userName, context);
+ }
}
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications