More task deletion changes
Completed tasks can be deleted by anyone after a configurable time unless they have reverse dependencies.
This commit is contained in:
parent
a39945ff14
commit
ff4a209d99
2 changed files with 17 additions and 1 deletions
|
@ -5,3 +5,6 @@ $config[ 'core' ][ 'db' ][ 'user' ] = '...';
|
||||||
$config[ 'core' ][ 'db' ][ 'password' ] = '...';
|
$config[ 'core' ][ 'db' ][ 'password' ] = '...';
|
||||||
|
|
||||||
$config[ 'core' ][ 'pages' ][ 'baseTitle' ] = 'Tasks';
|
$config[ 'core' ][ 'pages' ][ 'baseTitle' ] = 'Tasks';
|
||||||
|
|
||||||
|
/* Minimal time before a completed task can be deleted. The default is one week. */
|
||||||
|
// $config[ 't-data' ][ 'minDeletionTime' ] = 7 * 3600 * 24;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
class DAO_Tasks
|
class DAO_Tasks
|
||||||
extends DAO
|
extends DAO
|
||||||
|
implements PackageAware
|
||||||
{
|
{
|
||||||
private static $priorities = array(
|
private static $priorities = array(
|
||||||
'1' => 'Lowest' ,
|
'1' => 'Lowest' ,
|
||||||
|
@ -11,6 +12,16 @@ class DAO_Tasks
|
||||||
'5' => 'Very high' ,
|
'5' => 'Very high' ,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private $package;
|
||||||
|
|
||||||
|
public function setPackage( Package $package )
|
||||||
|
{
|
||||||
|
if ( $this->package !== null ) {
|
||||||
|
throw new Exception( 'trying to call setPackage() twice' );
|
||||||
|
}
|
||||||
|
$this->package = $package;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function translatePriority( $value )
|
public function translatePriority( $value )
|
||||||
{
|
{
|
||||||
|
@ -175,9 +186,11 @@ class DAO_Tasks
|
||||||
public function canDelete( $task )
|
public function canDelete( $task )
|
||||||
{
|
{
|
||||||
if ( $task->completed_by !== null ) {
|
if ( $task->completed_by !== null ) {
|
||||||
|
$minDeletionTime = $this->package->config(
|
||||||
|
'minDeletionTime' , 7 * 3600 * 24 );
|
||||||
$ts = strtotime( $task->completed_at );
|
$ts = strtotime( $task->completed_at );
|
||||||
return empty( $task->reverseDependencies )
|
return empty( $task->reverseDependencies )
|
||||||
&& ( time() - $ts > 7 * 3600 * 24 );
|
&& ( time() - $ts > $minDeletionTime );
|
||||||
}
|
}
|
||||||
return empty( $task->subtasks )
|
return empty( $task->subtasks )
|
||||||
&& empty( $task->reverseDependencies )
|
&& empty( $task->reverseDependencies )
|
||||||
|
|
Loading…
Reference in a new issue