1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
|
<?php
/**
* GForge Plugin CVSTracker Class
*
* Copyright 2004 (c) Francisco Gimeno <kikov @nospam@ kikov.org>
* Copyright 2005 (c) Guillaume Smet <guillaume-gforge@smet.org>
*
* @version $Id: cvstrackerPlugin.class 5336 2006-02-17 18:19:26Z marcelo $
* This file is part of GForge-plugin-cvstracker
*
* GForge-plugin-cvstracker 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 License, or (at your option) any later version.
*
* GForge-plugin-cvstracker 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 GForge-plugin-cvstracker; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
*
*/
/**
* The cvstrackerPlugin class. It implements the Hooks for the presentation
* of table in tracker and task in detailed mode.
*
*/
class cvstrackerPlugin extends Plugin {
function cvstrackerPlugin () {
$this->Plugin() ;
$this->name = "cvstracker" ;
$this->text = "Cvs 2 Tracker";
$this->hooks[] = "groupisactivecheckbox";
$this->hooks[] = "groupisactivecheckboxpost";
$this->hooks[] = "artifact_extra_detail";
$this->hooks[] = "task_extra_detail";
//$this->hooks[] = "update_cvs_repository";
}
/**
* It display a table with commit related to this tracker or task_extra_detail
*
* @param string $Query Query to be executed to get the commit entries.
* @param integer $group_id Group_id of the actual Group_id
*
*/
function getCommitEntries($Query,$group_id) {
global $Language, $sys_shortdatefmt;
$group = &group_get_object($group_id);
if (!$group->usesPlugin($this->name)) {
return;
}
$DBResult = db_query($Query);
$Rows= db_numrows($DBResult);
if ($Rows > 0) {
echo '<tr><td colspan="2">';
echo '<h4>'.$Language->getText('plugin_cvstracker','title').':</h4>';
$title_arr=$this->getTitleArr();
echo $GLOBALS['HTML']->listTableTop ($title_arr);
for ($i=0; $i<$Rows; $i++) {
$Row = db_fetch_array($DBResult);
echo '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>'.
'<td>'. $this->getFileLink($group->getUnixName(),
$Row['file']). '</td>'.
'<td>'. date($sys_shortdatefmt, $Row['cvs_date']).'</td>'.
'<td>'. $this->getDiffLink($group->getUnixName(),
$Row['file'],
$Row['prev_version'],
$Row['actual_version']).'</td>'.
'<td>'. $this->getActualVersionLink($group->getUnixName(),
$Row['file'], $Row['actual_version']).
'</td>
<td>'. htmlspecialchars($Row['log_text']).'</td>
<td><a href="/users/'. $Row['author'].'">'.
$Row['author'].'</a></td>
</tr>';
}
echo $GLOBALS['HTML']->listTableBottom();
echo '</td></tr>';
} else {
echo '<h4>'.$Language->getText('plugin_cvstracker','nocommits').'</h4>';
}
}
/**
* Return an array with titles of Box to display the entries
*
* @return Array The array containing the titles
*
*/
function getTitleArr() {
global $Language;
$title_arr=array();
$title_arr[]=$Language->getText('plugin_cvstracker','file');
$title_arr[]=$Language->getText('plugin_cvstracker','date');
$title_arr[]=$Language->getText('plugin_cvstracker','prevVersion');
$title_arr[]=$Language->getText('plugin_cvstracker','actualVersion');
$title_arr[]=$Language->getText('plugin_cvstracker','log');
$title_arr[]=$Language->getText('plugin_cvstracker','author');
return $title_arr;
}
/**
* Return a link to the File in cvsweb
*
* @param String $GroupName is the Name of the project
* @param String $FileName is the FileName ( with path )
*
* @return String The string containing a link to the File in the cvsweb
*
*/
function getFileLink($GroupName, $FileName) {
global $sys_default_domain;
return '<a href="/plugins/scmcvs/cvsweb.php/'.
$FileName.'?cvsroot='.$GroupName.'">'.$FileName.'</a>';
}
/**
* Return a link to the File in cvsweb in the specified Version
*
* @param String $GroupName is the Name of the project
* @param String $FileName is the FileName ( with path )
* @param String $Version the version to retrieve
*
* @return String The string containing a link to the File in the cvsweb
*
*/
function getActualVersionLink($GroupName, $FileName, $Version) {
global $sys_default_domain;
return '<a href="/plugins/scmcvs/cvsweb.php/'.
$FileName.'?cvsroot='.$GroupName.'&rev='.$Version.'&contenttype=text/x-cvsweb-markup">'.
$Version.'</a>';
}
/**
* Return a link to the diff between two versions of a File in cvsweb
*
* @param String $GroupName is the Name of the project
* @param String $FileName is the FileName ( with path )
* @param String $PrevVersion First version to retrieve
* @param String $ActualVersion Second version to retrieve
*
* @return String The string containing a link to the File in the cvsweb
*
*/
function getDiffLink($GroupName, $FileName, $PrevVersion, $ActualVersion) {
global $sys_default_domain,$Language;
return '<a href="/plugins/scmcvs/cvsweb.php/'.
$FileName.'?cvsroot='.$GroupName.'&r1='.$PrevVersion.'&r2='.
$ActualVersion.'&contenttype=text/x-cvsweb-markup">'.
$Language->getText('plugin_cvstracker','diffto').' '.$PrevVersion.'</a>';
}
/**
* The function to be called for a Hook
*
* @param String $hookname The name of the hookname that has been happened
* @param String $params The params of the Hook
*
*/
function CallHook ($hookname, $params) {
global $group_id,$Language, $G_SESSION, $HTML, $use_cvstrackerplugin,$aid ;
if ($hookname == "groupisactivecheckbox") {
//Check if the group is active
$group = &group_get_object($group_id);
if ($group->usesPlugin('scmcvs')) {
echo "<tr>";
echo "<td>";
echo ' <input type="CHECKBOX" name="use_cvstrackerplugin" value="1" ';
// Checked or Unchecked?
if ( $group->usesPlugin ( $this->name ) ) {
echo "CHECKED";
}
echo "><br/>";
echo "</td>";
echo "<td>";
echo "<strong>".$this->text." Plugin</strong>";
echo "</td>";
echo "</tr>";
}
} elseif ($hookname == "groupisactivecheckboxpost") {
$group = &group_get_object($group_id);
if ( $use_cvstrackerplugin == 1 ) {
$group->setPluginUse ( $this->name );
} else {
$group->setPluginUse ( $this->name, false );
}
} elseif ($hookname == "artifact_extra_detail") {
$Query="SELECT * FROM plugin_cvstracker_data_master,".
"plugin_cvstracker_data_artifact".
" WHERE plugin_cvstracker_data_artifact.group_artifact_id='$aid' ".
" AND plugin_cvstracker_data_master.holder_id=".
" plugin_cvstracker_data_artifact.id ORDER BY cvs_date";
$this->getCommitEntries($Query, $group_id);
} elseif ($hookname == "task_extra_detail") {
$Query="SELECT * FROM plugin_cvstracker_data_master,".
"plugin_cvstracker_data_artifact".
" WHERE plugin_cvstracker_data_artifact.project_task_id='".
$params['task_id']."' ".
" AND plugin_cvstracker_data_master.holder_id=".
" plugin_cvstracker_data_artifact.id ORDER BY cvs_date";
$this->getCommitEntries($Query, $group_id);
}
}
}
// Local Variables:
// mode: php
// c-file-style: "bsd"
// End:
?>
|