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