diff --git a/src/IDF/Views/Wiki.php b/src/IDF/Views/Wiki.php index f7888c3..d394d43 100644 --- a/src/IDF/Views/Wiki.php +++ b/src/IDF/Views/Wiki.php @@ -430,6 +430,44 @@ class IDF_Views_Wiki } /** + * Remove a revision of a resource. + */ + public $deleteResourceRev_precond = array('IDF_Precondition::accessWiki', + 'IDF_Precondition::projectMemberOrOwner'); + public function deleteResourceRev($request, $match) + { + $prj = $request->project; + $oldrev = Pluf_Shortcuts_GetObjectOr404('IDF_Wiki_ResourceRevision', $match[2]); + $resource = $oldrev->get_wikiresource(); + $prj->inOr404($resource); + if ($oldrev->is_head == true) { + return new Pluf_HTTP_Response_NotFound($request); + } + if ($request->method == 'POST') { + $oldrev->delete(); + $request->user->setMessage(__('The old revision has been deleted.')); + $url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::viewResource', + array($prj->shortname, $resource->title)); + return new Pluf_HTTP_Response_Redirect($url); + } + + $title = sprintf(__('Delete Old Revision of %s'), $resource->title); + $revision = $resource->get_current_revision(); + $false = Pluf_DB_BooleanToDb(false, $resource->getDbConnection()); + $revs = $resource->get_revisions_list(array('order' => 'creation_dtime DESC', + 'filter' => 'is_head='.$false)); + return Pluf_Shortcuts_RenderToResponse('idf/wiki/deleteResourceRev.html', + array( + 'page_title' => $title, + 'resource' => $resource, + 'oldrev' => $oldrev, + 'rev' => $revision, + 'revs' => $revs, + ), + $request); + } + + /** * Update a documentation page. */ public $updatePage_precond = array('IDF_Precondition::accessWiki', diff --git a/src/IDF/templates/idf/wiki/deleteResourceRev.html b/src/IDF/templates/idf/wiki/deleteResourceRev.html new file mode 100644 index 0000000..8523192 --- /dev/null +++ b/src/IDF/templates/idf/wiki/deleteResourceRev.html @@ -0,0 +1,49 @@ +{extends "idf/wiki/base.html"} +{block extraheader}{if $oldrev}{/if}{/block} +{block docclass}yui-t3{assign $inResourceView=true}{/block} +{block body} + +{assign $submitter = $oldrev.get_submitter()}{aurl 'url', 'IDF_Views_Wiki::viewResource', array($project.shortname, $resource.title)} +
+

{blocktrans}You are looking at an old revision ({$oldrev.summary}) of the resource +{$resource.title}. This revision was created by {$submitter}.{/blocktrans}

+
+

{blocktrans}If you delete this old revision, it will be removed from the database and you will not be able to recover it.{/blocktrans}

+
+ + + + + +
  | {trans 'Cancel'} +
+
+ +

{$resource.summary}

+ +{assign $preview = $rev.renderRaw()} +{if $preview == ''} + {assign $preview = __('Unable to render preview for this MIME type.')} +{/if} +

{$preview|unsafe}

+ + +{/block} + +{/block} +{block context} +{assign $submitter = $resource.get_submitter()} +

{trans 'Created:'} {$resource.creation_dtime|dateago}
{blocktrans}by {$submitter}{/blocktrans}

+{if $rev.creation_dtime != $resource.creation_dtime}

{assign $submitter = $rev.get_submitter()} +{trans 'Updated:'} {$rev.creation_dtime|dateago}
{blocktrans}by {$submitter}{/blocktrans}

{/if} +{if $revs.count() > 0} +

{trans 'Old Revisions'}

+ +{/if} +{/block}