Fixed issue 105 point 2, added deletion of a project.

Note that the source code is not deleted at the moment.
This commit is contained in:
Loic d'Anterroches
2009-02-27 10:42:18 +01:00
parent f986184254
commit 7f4f14e78d
7 changed files with 257 additions and 2 deletions

View File

@@ -425,6 +425,57 @@ class IDF_Project extends Pluf_Model
return $this->_pconf;
}
/**
* Get simple statistics about the project.
*
* This returns an associative array with number of tickets,
* number of downloads, etc.
*
* @return array Stats
*/
public function getStats()
{
$stats = array();
$stats['total'] = 0;
$what = array('downloads' => 'IDF_Upload',
'reviews' => 'IDF_Review',
'issues' => 'IDF_Issue',
'docpages' => 'IDF_WikiPage',
'commits' => 'IDF_Commit',
);
foreach ($what as $key=>$m) {
$i = Pluf::factory($m)->getCount(array('filter' => 'project='.(int)$this->id));
$stats[$key] = $i;
$stats['total'] += $i;
}
/**
* [signal]
*
* IDF_Project::getStats
*
* [sender]
*
* IDF_Project
*
* [description]
*
* This signal allows an application to update the statistics
* array of a project. For example to add the on disk size
* of the repository if available.
*
* [parameters]
*
* array('project' => $project,
* 'stats' => $stats)
*
*/
$params = array('project' => $this,
'stats' => $stats);
Pluf_Signal::send('IDF_Project::getStats',
'IDF_Project', $params);
return $stats;
}
/**
* Needs to be called when you update the memberships of a
* project.