Add new attachment

Only authorized users are allowed to upload new attachments.

This page (revision-8) was last changed on 06-Feb-2011 20:51 by Gerard Perreault  

This page was created on 10-Jan-2006 23:38 by Dirk Frederickx

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Difference between version and

At line 125 added 67 lines
\\
--Gerard Perreault, 2011-02-06
We use version 2.8.4 and everything else was OK for this to work except for 2 things:
* Getting the time from the file wasn't giving the correct value, so we changed it to:
{{{
<%-- OVERWRITE BLOCK --%>
<wiki:PageExists>
<%
java.util.Date now = new java.util.Date();
long anHourAgo = (now.getTime() - (60*60*1000));
long lastChangeTime = 0;
Date d = context.getPage().getLastModified();
if( d != null ) lastChangeTime = d.getTime();
String lastAuthor = context.getPage().getAuthor();
String thisAuthor = context.getWikiSession().getUserPrincipal().getName();
%>
<!-- You can use these traces to debug, and then remove them:
anHourAgo = <%= "" + anHourAgo%><BR>
lastChangeTime = <%= "" + lastChangeTime%><BR>
now = <%= "" + now%><BR>
context.getPage().getLastModified() = <%= "" + context.getPage().getLastModified()%><BR>
-->
<wiki:UserCheck status="authenticated">
<% if( lastAuthor.equals(thisAuthor) ) { /* should be the same author */ %>
<% if( lastChangeTime > anHourAgo ) { /* changes within one hour */ %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Overwrite version: <input type="checkbox" name="overwrite" checked="checked" />
<% } /* changes within one hour */ %>
<% } /* should be the same author */ %>
</wiki:UserCheck>
</wiki:PageExists>
}}}
* The ''else'' section had to be changed like this:
{{{
else
{
if( overwrite != null )
{
if( wikiSession.isAuthenticated() )
{
if( user.equals( wikipage.getAuthor() ) )
{
Date now = new Date();
long anHourAgo = (now.getTime() - (60*60*1000));
long lastchange = 0;
Date d = latestversion.getLastModified();
if( d != null ) lastchange = d.getTime();
if( lastchange > anHourAgo )
{
WikiPage p = wiki.getPage( pagereq);
log.info("OVERWRITE : -- so first delete the latest version");
wiki.deleteVersion( p );
wikipage = wiki.getPage( pagereq);
}
}
}
}
wiki.saveText( wikiContext, text );
}
}}}
Version Date Modified Size Author Changes ... Change note
8 06-Feb-2011 20:51 7.443 kB Gerard Perreault to previous
7 06-Feb-2011 19:54 7.321 kB Gerard Perreault to previous | to last
6 17-Jul-2008 23:42 4.745 kB Mardi Rollow to previous | to last
5 14-Jan-2006 00:03 4.73 kB DirkFrederickx to previous | to last
4 10-Jan-2006 23:52 4.687 kB Dirk Frederickx to previous | to last
3 10-Jan-2006 23:42 4.627 kB Dirk Frederickx to previous | to last
2 10-Jan-2006 23:41 4.579 kB Dirk Frederickx to previous | to last
1 10-Jan-2006 23:38 4.555 kB Dirk Frederickx to last
« This page (revision-8) was last changed on 06-Feb-2011 20:51 by Gerard Perreault