3 * Default Action Tracker Content Widget Class
5 * Copyright 2016, Franck Villaume - TrivialDev
6 * http://fusionforge.org
8 * This file is a part of Fusionforge.
10 * Fusionforge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * Fusionforge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Fusionforge. If not, see <http://www.gnu.org/licenses/>.
24 require_once 'Widget.class.php';
26 class Widget_TrackerDefaultActions extends Widget {
30 function __construct() {
32 $request =& HTTPRequest::instance();
33 $owner_id = (int)substr($request->get('owner'), 1);
35 $owner_id = $request->get('atid');
37 if ($func == 'detail' || forge_check_perm('tracker_admin', $owner_id)) {
38 parent::__construct('trackerdefaultactions', $owner_id, WidgetLayoutManager::OWNER_TYPE_TRACKER);
39 $this->title = _('Actions');
47 function getDescription() {
48 return _('Default actions widget for monitor, votes & delete.');
51 function isAvailable() {
52 return isset($this->title);
55 function getContent() {
64 if ($func == 'detail') {
65 $return = $HTML->listTableTop();
67 if ($ah->isMonitoring()) {
69 $text=_('Stop monitoring');
74 $cells[][] = util_make_link('/tracker/?group_id='.$group_id.'&artifact_id='.$ah->getID().'&atid='.$ath->getID().'&func=monitor', html_e('strong', array(), html_image('ic/'.$img, 20, 20).' '.$text), array('id' => 'tracker-monitor', 'title' => util_html_secure(html_get_tooltip_description('monitor'))));
75 $return .= $HTML->multiTableRow(array(), $cells);
76 $votes = $ah->getVotes();
79 $cellContent = html_e('span', array('id' => 'tracker-votes', 'title' => html_get_tooltip_description('votes')), html_e('strong', array(), _('Votes') . _(': ')).sprintf('%1$d/%2$d (%3$d%%)', $votes[0], $votes[1], $votes[2]));
80 if ($ath->canVote()) {
82 $key = 'pointer_down';
83 $txt = _('Retract Vote');
86 $txt = _('Cast Vote');
88 $cellContent .= util_make_link('/tracker/?group_id='.$group_id.'&aid='.$ah->getID().'&atid='.$ath->getID().'&func='.$key, html_image('ic/'.$key.'.png', 16, 16), array('id' => 'tracker-vote', 'alt' => $txt, 'title' => util_html_secure(html_get_tooltip_description('vote'))));
90 $cells[][] = $cellContent;
91 $return .= $HTML->multiTableRow(array(), $cells);
93 if (forge_check_perm('tracker', $atid, 'manager')) {
95 $cells[][] = util_make_link('/tracker/?func=deleteartifact&aid='.$aid.'&group_id='.$group_id.'&atid='.$atid, $HTML->getDeletePic().html_e('strong', array(), _('Delete')));
96 $return .= $HTML->multiTableRow(array(), $cells);
98 $return .= $HTML->listTableBottom();
101 return $HTML->information(_('No action available.'));
105 function canBeRemove() {
109 function canBeMinize() {
113 function getCategory() {
114 return _('Trackers');