Skip to content
This repository has been archived by the owner on Sep 3, 2018. It is now read-only.

Commit

Permalink
[ENH] submissions: Add an easy way of removing all expired submissions
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/tikiwiki/code/branches/14.x@55596 b456876b-0849-0410-b77d-98878d47e9d5
  • Loading branch information
jonnybradley committed May 29, 2015
1 parent e1d62dd commit 264a157
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/articles/artlib.php
Expand Up @@ -187,6 +187,30 @@ function remove_submission($subId)
}
}

function delete_expired_submissions()
{
$tiki_submissions = TikiDb::get()->table('tiki_submissions');

$expired = $tiki_submissions->fetchColumn(
'subId',
array('expireDate' => $tiki_submissions->lesserThan($this->now))
);

$transaction = $this->begin();

foreach ($expired as $subId) {

$tiki_submissions->delete(array('subId' => $subId));

$this->remove_object('submission', $subId);
}

$transaction->commit();


return true;
}

function replace_submission($title
, $authorName
, $topicId
Expand Down
1 change: 1 addition & 0 deletions templates/tiki-list_submissions.tpl
Expand Up @@ -2,6 +2,7 @@

<div class="t_navbar margin-bottom-md">
{button href="tiki-edit_submission.php" class="btn btn-default" _icon_name="create" _text="{tr}New Submission{/tr}"}
{button href="tiki-list_submissions.php?deleteexpired=y" _icon_name="delete" _text="{tr}Delete Expired Submissions{/tr}"}
{if $tiki_p_read_article eq 'y'}
{button href="tiki-list_articles.php" class="btn btn-default" _icon_name="list" _text="{tr}List Articles{/tr}"}
{/if}
Expand Down
5 changes: 5 additions & 0 deletions tiki-list_submissions.php
Expand Up @@ -52,6 +52,11 @@
}
}
}
if (isset($_REQUEST["deleteexpired"])) {
$access->check_permission('tiki_p_remove_submission');
$access->check_authenticity(tr('Are you sure you want to permanently remove all expired submitted articles?'));
$artlib->delete_expired_submissions();
}
// This script can receive the threshold
// for the information as the number of
// days to get in the log 1,3,4,etc
Expand Down

0 comments on commit 264a157

Please sign in to comment.