Added the possible deletion of the repository when deleting a subversion project.
This commit is contained in:
parent
fcefbe719f
commit
2ab52e7eaf
@ -66,6 +66,8 @@ need to put the following in your configuration file:
|
||||
$cfg['idf_plugin_syncsvn_authz_file'] = '/home/svn/dav_svn.authz';
|
||||
$cfg['idf_plugin_syncsvn_passwd_file'] = '/home/svn/dav_svn.passwd';
|
||||
$cfg['idf_plugin_syncsvn_svn_path'] = '/home/svn/repositories';
|
||||
// Delete the corresponding repository when deleting the project
|
||||
$cfg['idf_plugin_syncsvn_remove_orphans'] = false;
|
||||
|
||||
You can have more control over the permissions given to the owners,
|
||||
members, extra authorized users and anonymous users if you want with
|
||||
|
@ -52,6 +52,9 @@ class IDF_Plugin_SyncSvn
|
||||
case 'Pluf_User::passwordUpdated':
|
||||
$plug->processSyncPasswd($params['user']);
|
||||
break;
|
||||
case 'IDF_Project::preDelete':
|
||||
$plug->processSvnDelete($params['project']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,6 +87,31 @@ class IDF_Plugin_SyncSvn
|
||||
return ($return == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the project from the drive and update the access rights.
|
||||
*
|
||||
* @param IDF_Project
|
||||
* @return bool Success
|
||||
*/
|
||||
function processSvnDelete($project)
|
||||
{
|
||||
if (!Pluf::f('idf_plugin_syncsvn_remove_orphans', false)) {
|
||||
return;
|
||||
}
|
||||
if ($project->getConf()->getVal('scm') != 'svn') {
|
||||
return false;
|
||||
}
|
||||
$this->SyncAccess($project); // exclude $project
|
||||
$shortname = $project->shortname;
|
||||
if (false===($svn_path=Pluf::f('idf_plugin_syncsvn_svn_path',false))) {
|
||||
throw new Pluf_Exception_SettingError("'idf_plugin_syncsvn_svn_path' must be defined in your configuration file.");
|
||||
}
|
||||
if (file_exists($svn_path.'/'.$shortname)) {
|
||||
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'rm -rf '.$svn_path.'/'.$shortname;
|
||||
exec($cmd);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronise an user's password.
|
||||
*
|
||||
@ -156,8 +184,10 @@ class IDF_Plugin_SyncSvn
|
||||
* We rebuild the complete file each time. This is just to be sure
|
||||
* not to bork the rights when trying to just edit part of the
|
||||
* file.
|
||||
*
|
||||
* @param IDF_Project Possibly exclude a project (null)
|
||||
*/
|
||||
function SyncAccess()
|
||||
function SyncAccess($exclude=null)
|
||||
{
|
||||
$authz_file = Pluf::f('idf_plugin_syncsvn_authz_file');
|
||||
$access_owners = Pluf::f('idf_plugin_syncsvn_access_owners', 'rw');
|
||||
@ -170,6 +200,9 @@ class IDF_Plugin_SyncSvn
|
||||
}
|
||||
$fcontent = '';
|
||||
foreach (Pluf::factory('IDF_Project')->getList() as $project) {
|
||||
if ($exclude and $exclude->id == $project->id) {
|
||||
continue;
|
||||
}
|
||||
$conf = new IDF_Conf();
|
||||
$conf->setProject($project);
|
||||
if ($conf->getVal('scm') != 'svn' or
|
||||
|
@ -586,6 +586,28 @@ class IDF_Project extends Pluf_Model
|
||||
*/
|
||||
public function preDelete()
|
||||
{
|
||||
/**
|
||||
* [signal]
|
||||
*
|
||||
* IDF_Project::preDelete
|
||||
*
|
||||
* [sender]
|
||||
*
|
||||
* IDF_Project
|
||||
*
|
||||
* [description]
|
||||
*
|
||||
* This signal allows an application to perform special
|
||||
* operations at the deletion of a project.
|
||||
*
|
||||
* [parameters]
|
||||
*
|
||||
* array('project' => $project)
|
||||
*
|
||||
*/
|
||||
$params = array('project' => $this);
|
||||
Pluf_Signal::send('IDF_Project::preDelete',
|
||||
'IDF_Project', $params);
|
||||
$what = array('IDF_Upload', 'IDF_Review', 'IDF_Issue',
|
||||
'IDF_WikiPage', 'IDF_Commit',
|
||||
);
|
||||
|
@ -54,7 +54,8 @@ Pluf_Signal::connect('IDF_Project::created',
|
||||
array('IDF_Plugin_SyncSvn', 'entry'));
|
||||
Pluf_Signal::connect('Pluf_User::passwordUpdated',
|
||||
array('IDF_Plugin_SyncSvn', 'entry'));
|
||||
|
||||
Pluf_Signal::connect('IDF_Project::preDelete',
|
||||
array('IDF_Plugin_SyncSvn', 'entry'));
|
||||
#
|
||||
# Mercurial synchronization
|
||||
Pluf_Signal::connect('IDF_Project::membershipsUpdated',
|
||||
|
Loading…
Reference in New Issue
Block a user