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 1 added one line
[{TableOfContents}]
At line 3 changed 2 lines
Everytime your press "SAVE", JSPWiki save a new version of a page.
Since recently, JSPWiki only saves a new version if changes where done to the page. (good;-)
Every time you press "SAVE", JSPWiki saves a new version of a page.
Since recently, JSPWiki only saves a new version if changes were made to the page (good ;-).
At line 8 changed one line
with little or no added value.
with little or no added value. (look at the first 3 version of the page ;-o )
At line 10 changed one line
This page descibes a hack of the current JSPWiki in order to limit the number of new page versions. It was tested on a JSPWiki,v2.3.61.
This page describes a hack of the current JSPWiki in order to limit the number of new page versions.
It was tested on a JSPWiki,v2.3.61.
At line 15 added 2 lines
See also [IdeaSingleVersionForSavesBySameUserWithinHour]
At line 15 changed one line
When following conditions apply, the default behaviour of JSPWiki will be to overwrite the last version of the page instead of creating a new one.
When the following conditions apply, the default behaviour of JSPWiki will be to overwrite the last version
of the page instead of creating a new one.
At line 18 changed 2 lines
Anonymous or asserted user can not overwrite versions, i.e.
each change will be registered with new page versions. (security)
Anonymous or asserted users can not overwrite versions, i.e.,
each change will be registered with new page versions (security).
At line 27 changed one line
However, a checkbox will be added to the edit screen, such that the user can still decide NOT to overwrite, but save the changes to a new version.
However, a checkbox will be added to the edit screen so that the user can still decide NOT to overwrite, but save the changes to a new version.
At line 30 changed one line
and on saving the page. (press save)
and on saving the page (press save).
At line 34 changed one line
You need to make changes to 2 files
You need to make changes to two files:
At line 40 changed 2 lines
This jsp generates the normal edit screen with the Save/Preview/Cancel buttons.
The added stuff inserts the "Overwrite version" checkbox, if needed.
This jsp generates the standard edit screen with the Save/Preview/Cancel buttons.
The added stuff inserts the "Overwrite version" checkbox if needed.
At line 43 changed one line
Add following stuff just after these 3 buttons:
Add following stuff just after these three buttons:
At line 51 added one line
<wiki:PageExists>
At line 68 added one line
</wiki:PageExists>
At line 70 changed one line
First you need to capture the status of the OVERWRITE checkbox. Following lines can be added in the beginning of the file:
First you need to capture the status of the OVERWRITE checkbox. The following lines can be added in the beginning of the file:
At line 85 changed one line
and change it to
and change them to
At line 115 changed 2 lines
Also notice how I implemented the actual overwrite: first the currenct version is deleted; then the new text is save.
WARNING: I only tested this with the {{VersioningFileProvider}}.
Also notice how I implemented the actual overwrite: first the current version is deleted; then the new text is saved.
At line 124 added one line
WARNING: I tested this only with the {{VersioningFileProvider}}.
At line 126 added 2 lines
\\
--Gerard Perreault, 2011-02-06
At line 129 added 63 lines
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