InDefero

Sign in or create your account | Project List | Help

InDefero Commit Details

Date:2009-06-25 21:37:46 (8 months 14 days ago)
Author:Loïc d'Anterroches
Commit:2ab52e7eaf2c72deb196aecb7f3c9104523668ad
Message:Added the possible deletion of the repository when deleting a subversion project.

Files: doc/syncsvn.mdtext (1 diff)
src/IDF/Plugin/SyncSvn.php (4 diffs)
src/IDF/Project.php (1 diff)
src/IDF/relations.php (1 diff)

Change Details

doc/syncsvn.mdtext
6666    $cfg['idf_plugin_syncsvn_authz_file'] = '/home/svn/dav_svn.authz';
6767    $cfg['idf_plugin_syncsvn_passwd_file'] = '/home/svn/dav_svn.passwd';
6868    $cfg['idf_plugin_syncsvn_svn_path'] = '/home/svn/repositories';
69    // Delete the corresponding repository when deleting the project
70    $cfg['idf_plugin_syncsvn_remove_orphans'] = false;
6971
7072You can have more control over the permissions given to the owners,
7173members, extra authorized users and anonymous users if you want with
src/IDF/Plugin/SyncSvn.php
5252        case 'Pluf_User::passwordUpdated':
5353            $plug->processSyncPasswd($params['user']);
5454            break;
55        case 'IDF_Project::preDelete':
56            $plug->processSvnDelete($params['project']);
57            break;
5558        }
5659    }
5760
...... 
8386        $ll = exec($cmd, $output, $return);
8487        return ($return == 0);
8588    }
89
90    /**
91     * Remove the project from the drive and update the access rights.
92     *
93     * @param IDF_Project
94     * @return bool Success
95     */
96    function processSvnDelete($project)
97    {
98        if (!Pluf::f('idf_plugin_syncsvn_remove_orphans', false)) {
99            return;
100        }
101        if ($project->getConf()->getVal('scm') != 'svn') {
102            return false;
103        }
104        $this->SyncAccess($project); // exclude $project
105        $shortname = $project->shortname;
106        if (false===($svn_path=Pluf::f('idf_plugin_syncsvn_svn_path',false))) {
107            throw new Pluf_Exception_SettingError("'idf_plugin_syncsvn_svn_path' must be defined in your configuration file.");
108        }
109        if (file_exists($svn_path.'/'.$shortname)) {
110            $cmd = Pluf::f('idf_exec_cmd_prefix', '').'rm -rf '.$svn_path.'/'.$shortname;
111            exec($cmd);
112        }
113    }
86114
87115    /**
88116     * Synchronise an user's password.
...... 
156184     * We rebuild the complete file each time. This is just to be sure
157185     * not to bork the rights when trying to just edit part of the
158186     * file.
187     *
188     * @param IDF_Project Possibly exclude a project (null)
159189     */
160    function SyncAccess()
190    function SyncAccess($exclude=null)
161191    {
162192        $authz_file = Pluf::f('idf_plugin_syncsvn_authz_file');
163193        $access_owners = Pluf::f('idf_plugin_syncsvn_access_owners', 'rw');
...... 
170200        }
171201        $fcontent = '';
172202        foreach (Pluf::factory('IDF_Project')->getList() as $project) {
203            if ($exclude and $exclude->id == $project->id) {
204                continue;
205            }
173206            $conf = new IDF_Conf();
174207            $conf->setProject($project);
175208            if ($conf->getVal('scm') != 'svn' or
src/IDF/Project.php
586586     */
587587    public function preDelete()
588588    {
589        /**
590         * [signal]
591         *
592         * IDF_Project::preDelete
593         *
594         * [sender]
595         *
596         * IDF_Project
597         *
598         * [description]
599         *
600         * This signal allows an application to perform special
601         * operations at the deletion of a project.
602         *
603         * [parameters]
604         *
605         * array('project' => $project)
606         *
607         */
608        $params = array('project' => $this);
609        Pluf_Signal::send('IDF_Project::preDelete',
610                          'IDF_Project', $params);
589611        $what = array('IDF_Upload', 'IDF_Review', 'IDF_Issue',
590612                      'IDF_WikiPage', 'IDF_Commit',
591613                      );
src/IDF/relations.php
5454                     array('IDF_Plugin_SyncSvn', 'entry'));
5555Pluf_Signal::connect('Pluf_User::passwordUpdated',
5656                     array('IDF_Plugin_SyncSvn', 'entry'));
57
57Pluf_Signal::connect('IDF_Project::preDelete',
58                     array('IDF_Plugin_SyncSvn', 'entry'));
5859#
5960# Mercurial synchronization
6061Pluf_Signal::connect('IDF_Project::membershipsUpdated',

Archive Download the corresponding diff file

Branches:
dev
master
newdiff
svn