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 'HudsonOverviewWidget.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_ProjectJobsOverview extends HudsonOverviewWidget {
32 var $_not_monitored_jobs;
33 var $_use_global_status = true;
36 var $_global_status_icon;
38 function hudson_Widget_ProjectJobsOverview($plugin) {
39 $this->Widget('plugin_hudson_project_jobsoverview');
40 $this->plugin = $plugin;
42 $request =& HTTPRequest::instance();
43 $this->group_id = $request->get('group_id');
45 if ($this->_use_global_status == "true") {
46 $this->_all_status = array(
52 $this->computeGlobalStatus();
57 function computeGlobalStatus() {
58 $jobs = $this->getJobsByGroup($this->group_id);
59 foreach ($jobs as $job) {
60 $this->_all_status[(string)$job->getColorNoAnime()] = $this->_all_status[(string)$job->getColorNoAnime()] + 1;
62 if ($this->_all_status['grey'] > 0 || $this->_all_status['red'] > 0) {
63 $this->_global_status = _("One or more failure or pending job");
64 $this->_global_status_icon = $this->plugin->getThemePath() . "/images/ic/" . "status_red.png";
65 } elseif ($this->_all_status['yellow'] > 0) {
66 $this->_global_status = _("One or more unstable job");
67 $this->_global_status_icon = $this->plugin->getThemePath() . "/images/ic/" . "status_yellow.png";
69 $this->_global_status = _("Success");
70 $this->_global_status_icon = $this->plugin->getThemePath() . "/images/ic/" . "status_blue.png";
76 if ($this->_use_global_status == "true") {
77 $title = '<img src="'.$this->_global_status_icon.'" title="'.$this->_global_status.'" alt="'.$this->_global_status.'" /> ';
79 $title .= _("Hudson Jobs");
83 function getDescription() {
84 return _("Shows an overview of all the jobs associated with this project. You can always choose the ones you want to display in the widget (preferences link).");
87 function getContent() {
88 $jobs = $this->getJobsByGroup($this->group_id);
89 if (sizeof($jobs) > 0) {
91 $html .= '<table style="width:100%">';
94 foreach ($jobs as $job_id => $job) {
96 $class="boxitemalt bgcolor-white";
98 $class="boxitem bgcolor-grey";
103 $html .= '<tr class="'. $class .'">';
105 $html .= ' <img src="'.$job->getStatusIcon().'" title="'.$job->getStatus().'" >';
107 $html .= ' <td style="width:99%">';
108 $html .= ' <a href="/plugins/hudson/?action=view_job&group_id='.$this->group_id.'&job_id='.$job_id.'">'.$job->getName().'</a><br />';
114 } catch (Exception $e) {
115 // Do not display wrong jobs