3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
5 * This file is a part of Codendi.
7 * Codendi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * Codendi 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
18 * along with Codendi. If not, see <http://www.gnu.org/licenses/>.
22 require_once('HudsonJobWidget.class.php');
23 require_once('common/include/HTTPRequest.class.php');
24 require_once('PluginHudsonJobDao.class.php');
25 require_once('HudsonJob.class.php');
27 class hudson_Widget_JobBuildHistory extends HudsonJobWidget {
29 function hudson_Widget_JobBuildHistory($owner_type, $owner_id) {
30 $request =& HTTPRequest::instance();
31 if ($owner_type == WidgetLayoutManager::OWNER_TYPE_USER) {
32 $this->widget_id = 'plugin_hudson_my_jobbuildhistory';
33 $this->group_id = $owner_id;
35 $this->widget_id = 'plugin_hudson_project_jobbuildhistory';
36 $this->group_id = $request->get('group_id');
38 $this->Widget($this->widget_id);
40 $this->setOwner($owner_id, $owner_type);
46 $title .= vsprintf(_("%s Builds History"), $this->job->getName());
48 $title .= _("Builds History");
53 function getDescription() {
54 return _("Show the build history of the selected job, under the form of RSS feed. For each build of the list, you can see the build number, the status and the date the build has been scheduled.");
57 function loadContent($id) {
58 $sql = "SELECT * FROM plugin_hudson_widget WHERE widget_name=$1 AND owner_id = $2 AND owner_type = $3 AND id = $4";
59 $res = db_query_params($sql,array($this->widget_id,$this->owner_id,$this->owner_type,$id));
60 if ($res && db_numrows($res)) {
61 $data = db_fetch_array($res);
62 $this->job_id = $data['job_id'];
63 $this->content_id = $id;
65 $jobs = $this->getAvailableJobs();
67 if (array_key_exists($this->job_id, $jobs)) {
68 $used_job = $jobs[$this->job_id];
69 $this->job_url = $used_job->getUrl();
70 $this->job = $used_job;
78 function getContent() {
80 if ($this->job != null) {
84 $buildHistoryRSSWidget = new Widget_ProjectRss();
85 $buildHistoryRSSWidget->rss_url = $job->getUrl().'/rssAll';
86 $html .= $buildHistoryRSSWidget->getContent();
89 $html .= _("Job not found.");
97 function getRssUrl() {
99 return $this->job->getUrl().'/rssAll';