Yishay Mor wrote:
I'm having some strange issues with access rights
on
http://patternlanguagenetwork.myxwiki.org/xwiki/bin/view/Cases/
Issue 1
======
I configured the space to permit view for unauthorized users. Yet when
loggen out I get:
Error number 4001 in 4: Error while parsing velocity page Cases.WebHome
Wrapped Exception: Failed to evaluate content with id
<http://patternlanguagenetwork.myxwiki.org/xwiki/bin/view/Cases/>Web
Home<http://patternlanguagenetwork.myxwiki.org/xwiki/bin/view/Cases/>
the root exception seems to be:
org.apache.velocity.exception.MethodInvocationException: Invocation of
method 'formatDate' in class com.xpn.xwiki.api.XWiki threw exception
java.lang.NullPointerException @ Cases.WebHome74,17?
When logged in, the page displays fine:
[snip]
The troublesome code is probably this:
<td> $xwiki.formatDate($caseDoc.getCreationDate(),"dd MMM yyyy")
</td>
<td> $xwiki.formatDate($caseDoc.getDate(),"dd MMM yyyy") </td>
Although you allowed view rights on the space, some of those documents
have stricter access rights ("Woodforthetrees" and "test"). It is
normal
that document access rights are stronger than space access rights, so
those documents won't be returned by the call to $xwiki.getDocument. You
should put an #if($xwiki.hasAccessLevel("view", $context.user, $case))
inside the foreach.
issue 2
=====
I use this code to create new pages in the space:
#if ($xwiki.hasAccessLevel("edit"))
</p><form action="" id="newdoc" method="post">
<div>
<input name="parent" value="XWiki.CaseClass"
type="hidden">
<input name="template" value="Cases.CaseClassTemplate"
type="hidden">
<input name="sheet" value="1" type="hidden">
<input name="webname" value="Cases" size="8"
type="hidden">
Name: <input name="name" value="Name of your case study"
type="text"
size="20">
<input value="Create" onclick='if (updateName(this.form.name))
{this.form.action="../../inline/" + this.form.webname.value + "/" +
this.form.name.value; this.form.submit(); }' type="button">
</div>
</form><p>
#else
sorry, you have to log in to enter a case study.
#end
It works fine, users can create new pages, but then they can't edit them!
In my desperation, I added this to the class sheet:
## set rights to allow creator and contributors to edit
## THIS DOESN'T WORK: CHICKEN & EGG PROBLEM => TURNED OFF SAVE
#macro(allowEdit $user)
#set ($rights = $doc.getObject("XWiki.XWikiRights", true))
#set ($result = $rights.set("levels", "edit"))
#set ($result = $rights.set("users", $user))
#set ($result = $rights.set("allow", 1))
## $doc.save()
#end
#allowEdit($doc.getCreator())
#foreach($contributor in $doc.getObject("Cases.CaseClass").contributors)
#allowEdit($contributor)
#end
but as you can see in the comment, it fails because if a user doesn't have
edit rights to begin with, save fails.
I see that you granted edit rights only to some groups. Can users in
those groups edit the documents they create? Only users not in one of
those groups cannot edit?
--
Sergiu Dumitriu
http://purl.org/net/sergiu/