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/>.
21 require_once 'common/mvc/Controler.class.php';
22 require_once 'hudsonViews.class.php';
23 require_once 'hudsonActions.class.php';
26 class hudson extends Controler {
31 $p = PluginManager::instance()->getPluginByName('hudson');
32 $this->themePath = $p->getThemePath();
35 function getThemePath() {
36 return $this->themePath;
38 function getIconsPath() {
39 return $this->themePath . "/images/ic/";
43 global $feedback, $error_msg;
44 $request =& HTTPRequest::instance();
45 $vgi = new Valid_GroupId();
47 if ($request->valid($vgi)) {
48 $group_id = $request->get('group_id');
49 $pm = ProjectManager::instance();
50 $project = $pm->getProject($group_id);
51 if ($project->usesService('hudson')) {
52 $user = UserManager::instance()->getCurrentUser();
53 if ($user->isMember($group_id)) {
54 switch($request->get('action')) {
56 if ($user->isMember($group_id, 'A')) {
57 if ( $request->exist('hudson_job_url') && trim($request->get('hudson_job_url') != '') ) {
58 $this->action = 'addJob';
60 $error_msg .= _("Missing Hudson job url (eg: http://myCIserver:8080/hudson/job/MyJob)");
62 $this->view = 'projectOverview';
64 $error_msg .= _("Permission Denied");
65 $this->view = 'projectOverview';
69 if ($user->isMember($group_id,'A')) {
70 if ($request->exist('job_id')) {
71 $this->view = 'editJob';
73 $error_msg .= _("Missing Hudson job ID");
76 $error_msg .= _("Permission Denied");
77 $this->view = 'projectOverview';
81 if ($user->isMember($group_id,'A')) {
82 if ($request->exist('job_id')) {
83 if ($request->exist('new_hudson_job_url') && $request->get('new_hudson_job_url') != '') {
84 $this->action = 'updateJob';
86 $error_msg .= _("Missing Hudson job url (eg: http://myCIserver:8080/hudson/job/MyJob)");
89 $error_msg .= _("Missing Hudson job ID");
91 $this->view = 'projectOverview';
93 $error_msg .= _("Permission Denied");
94 $this->view = 'projectOverview';
98 if ($user->isMember($group_id,'A')) {
99 if ($request->exist('job_id')) {
100 $this->action = 'deleteJob';
102 $error_msg .= _("Missing Hudson job ID");
104 $this->view = 'projectOverview';
106 $error_msg .= _("Permission Denied");
107 $this->view = 'projectOverview';
111 $this->view = 'job_details';
114 $this->view = 'build_number';
116 case "view_last_build":
117 $this->view = 'last_build';
119 case "view_last_test_result":
120 $this->view = 'last_test_result';
122 case "view_test_trend":
123 $this->view = 'test_trend';
126 $this->view = 'projectOverview';
130 $error_msg .= _("Permission Denied");
134 $error_msg .= _("Hudson service is not enabled");
137 $error_msg .= _("Missing group_id parameter.");