1<?php
2# MantisBT - A PHP based bugtracking system
3
4# MantisBT is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 2 of the License, or
7# (at your option) any later version.
8#
9# MantisBT is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Tag View Page
19 *
20 * @package MantisBT
21 * @copyright Copyright 2002  MantisBT Team - mantisbt-dev@lists.sourceforge.net
22 * @link http://www.mantisbt.org
23 *
24 * @uses core.php
25 * @uses access_api.php
26 * @uses authentication_api.php
27 * @uses compress_api.php
28 * @uses config_api.php
29 * @uses form_api.php
30 * @uses gpc_api.php
31 * @uses helper_api.php
32 * @uses html_api.php
33 * @uses lang_api.php
34 * @uses print_api.php
35 * @uses string_api.php
36 * @uses tag_api.php
37 * @uses user_api.php
38 */
39
40require_once( 'core.php' );
41require_api( 'access_api.php' );
42require_api( 'authentication_api.php' );
43require_api( 'compress_api.php' );
44require_api( 'config_api.php' );
45require_api( 'form_api.php' );
46require_api( 'gpc_api.php' );
47require_api( 'helper_api.php' );
48require_api( 'html_api.php' );
49require_api( 'lang_api.php' );
50require_api( 'print_api.php' );
51require_api( 'string_api.php' );
52require_api( 'tag_api.php' );
53require_api( 'user_api.php' );
54
55access_ensure_global_level( config_get( 'tag_view_threshold' ) );
56compress_enable();
57
58$f_tag_id = gpc_get_int( 'tag_id' );
59tag_ensure_exists( $f_tag_id );
60$t_tag_row = tag_get( $f_tag_id );
61
62$t_name = string_display_line( $t_tag_row['name'] );
63$t_description = string_display( $t_tag_row['description'] );
64$t_can_edit = access_has_global_level( config_get( 'tag_edit_threshold' ) );
65$t_can_edit_own = $t_can_edit || auth_get_current_user_id() == tag_get_field( $f_tag_id, 'user_id' )
66	&& access_has_global_level( config_get( 'tag_edit_own_threshold' ) );
67
68
69layout_page_header( sprintf( lang_get( 'tag_details' ), $t_name ) );
70
71layout_page_begin();
72?>
73
74<div class="col-md-12 col-xs-12">
75<div class="space-10"></div>
76<div class="widget-box widget-color-blue2">
77<div class="widget-header widget-header-small">
78<h4 class="widget-title lighter">
79	<?php print_icon( 'fa-tag', 'ace-icon' ); ?>
80	<?php echo sprintf( lang_get( 'tag_details' ), $t_name ) ?>
81</h4>
82</div>
83
84<div class="widget-body">
85<div class="widget-main no-padding">
86	<div class="widget-toolbox padding-8 clearfix">
87		<?php print_link_button( 'search.php?tag_string='.urlencode($t_tag_row['name']),
88			sprintf( lang_get( 'tag_filter_default' ), tag_stats_attached( $f_tag_id ) ),
89			'btn-sm pull-right'); ?>
90	</div>
91	<div class="table-responsive">
92		<table class="table table-bordered table-condensed table-striped">
93
94	<tr>
95		<td class="category">
96			<?php echo lang_get( 'tag_id' ) ?>
97		</td>
98		<td><?php echo $t_tag_row['id'] ?></td>
99	</tr>
100	<tr>
101		<td class="category">
102			<?php echo lang_get( 'tag_name' ) ?>
103		</td>
104		<td><?php echo $t_name ?></td>
105	</tr>
106	<tr>
107		<td class="category">
108			<?php echo lang_get( 'tag_creator' ) ?>
109		</td>
110		<td><?php echo string_display_line( user_get_name($t_tag_row['user_id']) ) ?></td>
111	</tr>
112	<tr>
113		<td class="category">
114			<?php echo lang_get( 'tag_created' ) ?>
115		</td>
116		<td><?php echo date( config_get( 'normal_date_format' ), $t_tag_row['date_created'] ) ?></td>
117	</tr>
118	<tr>
119		<td class="category">
120			<?php echo lang_get( 'tag_updated' ) ?>
121		</td>
122		<td><?php echo date( config_get( 'normal_date_format' ), $t_tag_row['date_updated'] ) ?></td>
123	</tr>
124	<tr>
125		<td class="category">
126			<?php echo lang_get( 'tag_description' ) ?>
127		</td>
128		<td><?php echo $t_description ?></td>
129	</tr>
130
131<?php
132	# Related tags
133
134	$t_tags_related = tag_stats_related( $f_tag_id );
135	if( count( $t_tags_related ) ) {
136?>
137	<tr>
138		<td class="category">
139			<?php echo lang_get( 'tag_related' ) ?>
140		</td>
141			<td>
142<?php
143		foreach( $t_tags_related as $t_tag ) {
144			$t_name = string_display_line( $t_tag['name'] );
145			$t_description = string_display_line( $t_tag['description'] );
146			$t_count = $t_tag['count'];
147			$t_link = string_html_specialchars( 'search.php?tag_string='.urlencode( '+' . $t_tag_row['name'] . config_get( 'tag_separator' ) . '+' . $t_name ) );
148			$t_label = sprintf( lang_get( 'tag_related_issues' ), $t_tag['count'] ); ?>
149			<div class="col-md-3 col-xs-6 no-padding"><a href="tag_view_page.php?tag_id=<?php echo $t_tag['id']; ?>" title="<?php echo $t_description; ?>"><?php echo $t_name; ?></a></div>
150			<div class="col-md-9 col-xs-6 no-padding"><a href="<?php echo $t_link; ?>" class="btn btn-xs btn-primary btn-white btn-round"><?php echo $t_label; ?></a></div>
151			<div class="clearfix"></div>
152			<div class="space-4"></div>
153<?php
154		}
155?>
156			</td>
157	</tr>
158<?php
159	} ?>
160</table >
161</div >
162
163<?php
164	if( $t_can_edit_own || $t_can_edit ) {
165?>
166	<div class="widget-toolbox padding-8 clearfix">
167<?php
168		if( $t_can_edit_own ) {
169?>
170		<form class="form-inline pull-left" action="tag_update_page.php" method="post">
171			<fieldset>
172				<?php # CSRF protection not required here - form does not result in modifications ?>
173				<input type="hidden" name="tag_id" value="<?php echo $f_tag_id ?>" />
174				<input type="submit" class="btn btn-primary btn-white btn-round" value="<?php echo lang_get( 'tag_update_button' ) ?>" />
175			</fieldset>
176		</form><?php
177		}
178
179		if( $t_can_edit ) { ?>
180		<form class="form-inline pull-left" action="tag_delete.php" method="post">
181			<fieldset>
182				<?php echo form_security_field( 'tag_delete' ) ?>
183				<input type="hidden" name="tag_id" value="<?php echo $f_tag_id ?>" />
184				<input type="submit" class="btn btn-primary btn-white btn-round" value="<?php echo lang_get( 'tag_delete_button' ) ?>" />
185			</fieldset>
186		</form><?php
187		} ?>
188	</div><?php
189	} ?>
190	</div>
191	</div>
192	</div>
193</div>
194
195<?php
196layout_page_end();
197