3 * Copyright 2011, Franck Villaume - Capgemini
4 * http://fusionforge.org
6 * This file is part of FusionForge. FusionForge is free software;
7 * you can redistribute it and/or modify it under the terms of the
8 * GNU General Public License as published by the Free Software
9 * Foundation; either version 2 of the Licence, or (at your option)
12 * FusionForge is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 require_once('common/widget/Widget.class.php');
22 require_once('common/widget/WidgetLayoutManager.class.php');
24 class scmgit_Widget_MyRepositories extends Widget {
25 function scmgit_Widget_MyRepositories($owner_type, $owner_id) {
26 $this->Widget('plugin_scmgit_user_myrepositories');
27 $this->setOwner($owner_id, $owner_type);
31 return _("SCMGit Repository List");
34 function getCategory() {
38 function getDescription() {
39 return _("Get the list of URLS of your personal Git repository cloned from projects.");
42 function getContent() {
43 $user = UserManager::instance()->getCurrentUser();
44 $scmgitplugin = plugin_get_object('scmgit');
45 $GitRepositories = $this->getMyRepositoriesList();
46 if (count($GitRepositories)) {
47 $returnhtml = '<table>';
48 foreach ($GitRepositories as $GitRepository) {
49 $project = group_get_object($GitRepository);
50 $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>';
52 $returnhtml .= '</table>';
55 return '<p class="information">'._('No personal git repository').'</p>';
59 function getMyRepositoriesList() {
60 $returnedArray = array();
61 $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',
62 array('A',$this->owner_id));
64 return $returnedArray;
66 $rows = db_numrows($res);
67 for ($i=0; $i<$rows; $i++) {
68 $returnedArray[] = db_result($res,$i,'group_id');
71 return $returnedArray;