src/plugins/scmgit/bin/db-upgrade.pl -text svneol=unset#text/x-perl
src/plugins/scmgit/common/GitPlugin.class.php -text
src/plugins/scmgit/common/scmgit-init.php -text
+src/plugins/scmgit/common/scmgit_Widget_MyRepositories.class.php -text
src/plugins/scmgit/db/scmgit-init.sql -text
src/plugins/scmgit/etc/plugins/scmgit/config.php -text
src/plugins/scmgit/etc/scmgit.ini -text
*/
function SCMPlugin () {
$this->Plugin() ;
- $this->hooks[] = 'scm_plugin';
- $this->hooks[] = 'scm_page';
- $this->hooks[] = 'scm_admin_page';
- $this->hooks[] = 'scm_admin_update';
- $this->hooks[] = 'scm_stats';
- $this->hooks[] = 'scm_create_repo';
+ $this->_addHook('scm_plugin');
+ $this->_addHook('scm_page');
+ $this->_addHook('scm_admin_page');
+ $this->_addHook('scm_admin_update');
+ $this->_addHook('scm_stats');
+ $this->_addHook('scm_create_repo');
+
# Other common hooks that can be enabled per plugin:
# scm_generate_snapshots
# scm_gather_stats
global $HTML ;
switch ($hookname) {
- case 'scm_plugin':
- $scm_plugins=& $params['scm_plugins'];
- $scm_plugins[]=$this->name;
- break;
- case 'scm_page':
- $this->printPage ($params) ;
- break ;
- case 'scm_browser_page':
- $this->printBrowserPage ($params) ;
- break ;
- case 'scm_admin_page':
- $this->printAdminPage ($params) ;
- break ;
- case 'scm_admin_update':
- $this->adminUpdate($params);
- break ;
- case 'scm_stats':
- $this->printShortStats ($params) ;
- break;
- case 'scm_create_repo':
- session_set_admin();
- $this->createOrUpdateRepo($params);
- break;
- case 'scm_update_repolist':
- session_set_admin () ;
- $this->updateRepositoryList ($params) ;
- break;
- case 'scm_generate_snapshots': // Optional
- session_set_admin () ;
- $this->generateSnapshots ($params) ;
- break;
- case 'scm_gather_stats': // Optional
- session_set_admin () ;
- $this->gatherStats ($params) ;
- break;
- default:
- // Forgot something
+ case 'scm_plugin': {
+ $scm_plugins=& $params['scm_plugins'];
+ $scm_plugins[]=$this->name;
+ break;
+ }
+ case 'scm_page': {
+ $this->printPage ($params) ;
+ break ;
+ }
+ case 'scm_browser_page': {
+ $this->printBrowserPage ($params) ;
+ break ;
+ }
+ case 'scm_admin_page': {
+ $this->printAdminPage ($params) ;
+ break ;
+ }
+ case 'scm_admin_update': {
+ $this->adminUpdate($params);
+ break ;
+ }
+ case 'scm_stats': {
+ $this->printShortStats ($params) ;
+ break;
+ }
+ case 'scm_create_repo': {
+ session_set_admin();
+ $this->createOrUpdateRepo($params);
+ break;
+ }
+ case 'scm_update_repolist': {
+ session_set_admin () ;
+ $this->updateRepositoryList ($params) ;
+ break;
+ }
+ case 'scm_generate_snapshots': {// Optional
+ session_set_admin () ;
+ $this->generateSnapshots ($params) ;
+ break;
+ }
+ case 'scm_gather_stats': { // Optional
+ session_set_admin () ;
+ $this->gatherStats ($params) ;
+ break;
+ }
+ case "widgets": { // Optional
+ $this->widgets($params);
+ break;
+ }
+ case "widget_instance": { // Optional
+ $this->myPageBox($params);
+ break;
+ }
+ default: { // Forgot something
+ }
}
}
$this->_addHook('scm_update_repolist');
$this->_addHook('scm_generate_snapshots');
$this->_addHook('scm_gather_stats');
-
+ $this->_addHook('widget_instance', 'myPageBox', false);
+ $this->_addHook('widgets', 'widgets', false);
$this->register();
}
unlink ("$tmp/tarball") ;
system ("rm -rf $tmp") ;
}
+
+ function widgets($params) {
+ require_once('common/widget/WidgetLayoutManager.class.php');
+ if ($params['owner_type'] == WidgetLayoutManager::OWNER_TYPE_GROUP) {
+ $params['fusionforge_widgets'][] = 'plugin_scmgit_project_latestcommits';
+ }
+ if ($params['owner_type'] == WidgetLayoutManager::OWNER_TYPE_USER) {
+ $params['fusionforge_widgets'][] = 'plugin_scmgit_user_myrepositories';
+ }
+ return true;
+ }
+
+ function myPageBox($params) {
+ global $gfplugins;
+ $user = UserManager::instance()->getCurrentUser();
+ require_once('common/widget/WidgetLayoutManager.class.php');
+ if ($params['widget'] == 'plugin_scmgit_user_myrepositories') {
+ require_once $gfplugins.$this->name.'/common/scmgit_Widget_MyRepositories.class.php';
+ $params['instance'] = new scmgit_Widget_MyRepositories(WidgetLayoutManager::OWNER_TYPE_USER, $user->getId());
+ }
+ }
}
// Local Variables:
--- /dev/null
+<?php
+/**
+ * Copyright 2011, Franck Villaume - Capgemini
+ * http://fusionforge.org
+ *
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+require_once('common/widget/Widget.class.php');
+require_once('common/widget/WidgetLayoutManager.class.php');
+
+class scmgit_Widget_MyRepositories extends Widget {
+ function scmgit_Widget_MyRepositories($owner_type, $owner_id) {
+ $this->Widget('plugin_scmgit_user_myrepositories');
+ $this->setOwner($owner_id, $owner_type);
+ }
+
+ function getTitle() {
+ return _("SCMGit Repository List");
+ }
+
+ function getCategory() {
+ return _('SCM');
+ }
+
+ function getDescription() {
+ return _("Get the list of URLS of your personal Git repository cloned from projects.");
+ }
+
+ function getContent() {
+ $user = UserManager::instance()->getCurrentUser();
+ $scmgitplugin = plugin_get_object('scmgit');
+ $GitRepositories = $this->getMyRepositoriesList();
+ if (count($GitRepositories)) {
+ $returnhtml = '<table>';
+ foreach ($GitRepositories as $GitRepository) {
+ $project = group_get_object($GitRepository);
+ $returnhtml .= '<tr><td><tt>git clone git+ssh://'.$user->getUnixName().'@' . $scmgitplugin->getBoxForProject($project) . forge_get_config('repos_path', 'scmgit') .'/'. $project->getUnixName() .'/users/'. $user->getUnixName() .'.git</tt></p></td><tr>';
+ }
+ $returnhtml .= '</table>';
+ return $returnhtml;
+ } else {
+ return '<p class="information">'._('No personal git repository').'</div>';
+ }
+ }
+
+ function getMyRepositoriesList() {
+ $returnedArray = array();
+ $res = db_query_params('SELECT p.group_id FROM plugin_scmgit_personal_repos p, users u WHERE u.user_id=p.user_id AND u.unix_status = $1 AND u.user_id = $2',
+ array('A',$this->owner_id));
+ if (!$res) {
+ return $returnedArray;
+ } else {
+ $rows = db_numrows($res);
+ for ($i=0; $i<$rows; $i++) {
+ $returnedArray[] = db_result($res,$i,'group_id');
+ }
+ }
+ return $returnedArray;
+ }
+}
+
+?>