Skip to content

Commit 9a577a1

Browse files
committed
Fix whitespace and indentations
1 parent e8143c9 commit 9a577a1

File tree

1 file changed

+113
-110
lines changed

1 file changed

+113
-110
lines changed

TimeTracking/TimeTracking.php

+113-110
Original file line numberDiff line numberDiff line change
@@ -16,87 +16,89 @@
1616
1717
Notes: Based on the Time Tracking plugin by Elmar:
1818
2005 by Elmar Schumacher - GAMBIT Consulting GmbH
19-
http://www.mantisbt.org/forums/viewtopic.php?f=4&t=589
19+
http://www.mantisbt.org/forums/viewtopic.php?f=4&t=589
2020
*/
2121
class TimeTrackingPlugin extends MantisPlugin {
2222

23-
function register() {
24-
$this->name = 'Time Tracking';
25-
$this->description = 'Time tracking plugin that supports entering date worked, time and notes. Also includes limited permissions per user.';
26-
$this->page = 'config_page';
27-
28-
$this->version = '1.0.4';
29-
$this->requires = array(
30-
'MantisCore' => '1.2.0'
31-
);
32-
33-
$this->author = 'Michael Baker';
34-
$this->contact = '[email protected]';
35-
$this->url = '';
36-
}
37-
38-
function hooks() {
39-
return array(
40-
'EVENT_VIEW_BUG_EXTRA' => 'view_bug_time',
41-
'EVENT_MENU_ISSUE' => 'timerecord_menu',
42-
'EVENT_MENU_MAIN' => 'showreport_menu',
43-
);
44-
}
45-
46-
function config() {
47-
return array(
48-
'admin_own_threshold' => DEVELOPER,
49-
'view_others_threshold' => MANAGER,
50-
'admin_threshold' => ADMINISTRATOR
51-
);
52-
}
53-
54-
function init() {
55-
$t_path = config_get_global('plugin_path' ). plugin_get_current() . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR;
56-
set_include_path(get_include_path() . PATH_SEPARATOR . $t_path);
57-
}
23+
function register() {
24+
$this->name = 'Time Tracking';
25+
$this->description = 'Time tracking plugin that supports entering date worked, time and notes. Also includes limited permissions per user.';
26+
$this->page = 'config_page';
27+
28+
$this->version = '1.0.4';
29+
$this->requires = array(
30+
'MantisCore' => '1.2.0'
31+
);
32+
33+
$this->author = 'Michael Baker';
34+
$this->contact = '[email protected]';
35+
$this->url = '';
36+
}
37+
38+
function hooks() {
39+
return array(
40+
'EVENT_VIEW_BUG_EXTRA' => 'view_bug_time',
41+
'EVENT_MENU_ISSUE' => 'timerecord_menu',
42+
'EVENT_MENU_MAIN' => 'showreport_menu',
43+
);
44+
}
45+
46+
function config() {
47+
return array(
48+
'admin_own_threshold' => DEVELOPER,
49+
'view_others_threshold' => MANAGER,
50+
'admin_threshold' => ADMINISTRATOR
51+
);
52+
}
53+
54+
function init() {
55+
$t_path = config_get_global('plugin_path' ). plugin_get_current() . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR;
56+
set_include_path(get_include_path() . PATH_SEPARATOR . $t_path);
57+
}
5858

5959

6060
/**
6161
* Show TimeTracking information when viewing bugs.
6262
* @param string Event name
6363
* @param int Bug ID
6464
*/
65-
function view_bug_time( $p_event, $p_bug_id ) {
66-
$table = plugin_table('data');
67-
$t_user_id = auth_get_current_user_id();
68-
69-
# Pull all Time-Record entries for the current Bug
70-
if (access_has_bug_level( plugin_config_get( 'view_others_threshold' ), $p_bug_id ) ) {
71-
$query_pull_timerecords = "SELECT * FROM $table WHERE bug_id = $p_bug_id ORDER BY timestamp DESC";
72-
73-
} else if (access_has_bug_level( plugin_config_get( 'admin_own_threshold' ), $p_bug_id ) ) {
74-
$query_pull_timerecords = "SELECT * FROM $table WHERE bug_id = $p_bug_id and user = $t_user_id ORDER BY timestamp DESC";
75-
}
76-
$result_pull_timerecords = db_query($query_pull_timerecords);
77-
$num_timerecords = db_num_rows( $result_pull_timerecords );
78-
79-
# Get Sum for this bug
80-
$query_pull_hours = "SELECT SUM(hours) as hours FROM $table WHERE bug_id = $p_bug_id";
81-
$result_pull_hours = db_query( $query_pull_hours );
82-
$row_pull_hours = db_fetch_array( $result_pull_hours );
83-
84-
if ( (access_has_bug_level( plugin_config_get( 'admin_own_threshold' ), $p_bug_id ) )
85-
|| (access_has_bug_level( plugin_config_get( 'view_others_threshold' ), $p_bug_id ) ) ) {
65+
function view_bug_time( $p_event, $p_bug_id ) {
66+
$table = plugin_table('data');
67+
$t_user_id = auth_get_current_user_id();
68+
69+
# Pull all Time-Record entries for the current Bug
70+
if( access_has_bug_level( plugin_config_get( 'view_others_threshold' ), $p_bug_id ) ) {
71+
$query_pull_timerecords = "SELECT * FROM $table WHERE bug_id = $p_bug_id ORDER BY timestamp DESC";
72+
} else if( access_has_bug_level( plugin_config_get( 'admin_own_threshold' ), $p_bug_id ) ) {
73+
$query_pull_timerecords = "SELECT * FROM $table WHERE bug_id = $p_bug_id and user = $t_user_id ORDER BY timestamp DESC";
74+
}
75+
76+
$result_pull_timerecords = db_query( $query_pull_timerecords );
77+
$num_timerecords = db_num_rows( $result_pull_timerecords );
78+
79+
# Get Sum for this bug
80+
$query_pull_hours = "SELECT SUM(hours) as hours FROM $table WHERE bug_id = $p_bug_id";
81+
$result_pull_hours = db_query( $query_pull_hours );
82+
$row_pull_hours = db_fetch_array( $result_pull_hours );
83+
84+
if( (access_has_bug_level( plugin_config_get( 'admin_own_threshold' ), $p_bug_id ) )
85+
|| (access_has_bug_level( plugin_config_get( 'view_others_threshold' ), $p_bug_id ) ) ) {
86+
8687
?>
8788

8889

8990
<a name="timerecord" id="timerecord" /><br />
9091

9192
<?php
92-
collapse_open( 'timerecord' );
93+
collapse_open( 'timerecord' );
9394
?>
9495
<table class="width100" cellspacing="1">
9596
<tr>
9697
<td colspan="6" class="form-title">
9798
<?php
98-
collapse_icon( 'timerecord' ); ?>
99-
<?php echo plugin_lang_get( 'title' ); ?>
99+
collapse_icon( 'timerecord' );
100+
echo plugin_lang_get( 'title' );
101+
?>
100102
</td>
101103
</tr>
102104
<tr class="row-category">
@@ -109,17 +111,17 @@ function view_bug_time( $p_event, $p_bug_id ) {
109111
</tr>
110112

111113

112-
<?php
113-
if ( access_has_bug_level( plugin_config_get( 'admin_own_threshold' ), $p_bug_id ) ) {
114-
$current_date = explode("-", date("Y-m-d"));
114+
<?php
115+
if ( access_has_bug_level( plugin_config_get( 'admin_own_threshold' ), $p_bug_id ) ) {
116+
$current_date = explode("-", date("Y-m-d"));
115117
?>
116118

117119

118120
<form name="time_tracking" method="post" action="<?php echo plugin_page('add_record') ?>" >
119121
<?php echo form_security_field( 'plugin_TimeTracking_add_record' ) ?>
120122

121123
<input type="hidden" name="bug_id" value="<?php echo $p_bug_id; ?>">
122-
124+
123125
<tr <?php echo helper_alternate_class() ?>>
124126
<td><?php echo user_get_name( auth_get_current_user_id() ) ?></td>
125127
<td nowrap>
@@ -137,10 +139,10 @@ function view_bug_time( $p_event, $p_bug_id ) {
137139
</form>
138140

139141
<?php
140-
} # END Access Control
142+
} # END Access Control
141143

142-
for ( $i=0; $i < $num_timerecords; $i++ ) {
143-
$row = db_fetch_array( $result_pull_timerecords );
144+
for ( $i=0; $i < $num_timerecords; $i++ ) {
145+
$row = db_fetch_array( $result_pull_timerecords );
144146
?>
145147

146148

@@ -151,30 +153,30 @@ function view_bug_time( $p_event, $p_bug_id ) {
151153
<td><div align="center"><?php echo string_display_links($row["info"]); ?></div></td>
152154
<td><div align="center"><?php echo date( config_get("complete_date_format"), strtotime($row["timestamp"])); ?> </div></td>
153155

154-
<?php
155-
$user = auth_get_current_user_id();
156-
if ( ($user == $row["user"] && access_has_bug_level( plugin_config_get( 'admin_own_threshold' ), $p_bug_id) )
157-
|| access_has_bug_level( plugin_config_get( 'admin_threshold' ), $p_bug_id) ) {
156+
<?php
157+
$user = auth_get_current_user_id();
158+
if( ($user == $row["user"] && access_has_bug_level( plugin_config_get( 'admin_own_threshold' ), $p_bug_id) )
159+
|| access_has_bug_level( plugin_config_get( 'admin_threshold' ), $p_bug_id) ) {
158160
?>
159161

160162

161163
<td><a href="<?php echo plugin_page('delete_record') ?>&bug_id=<?php echo $p_bug_id; ?>&delete_id=<?php echo $row["id"]; ?><?php echo form_security_param( 'plugin_TimeTracking_delete_record' ) ?>"><?php echo plugin_lang_get( 'delete' ) ?>
162164
</a></td>
163165

164-
<?php
165-
}
166-
else {
166+
<?php
167+
}
168+
else {
167169
?>
168170
<td>&nbsp;</td>
169171

170172
<?php
171-
}
173+
}
172174
?>
173175
</tr>
174176

175177

176178
<?php
177-
} # End for loop
179+
} # End for loop
178180
?>
179181

180182

@@ -189,7 +191,7 @@ function view_bug_time( $p_event, $p_bug_id ) {
189191
</table>
190192

191193
<?php
192-
collapse_closed( 'timerecord' );
194+
collapse_closed( 'timerecord' );
193195
?>
194196

195197
<table class="width100" cellspacing="1">
@@ -202,48 +204,49 @@ function view_bug_time( $p_event, $p_bug_id ) {
202204
</table>
203205

204206
<?php
205-
collapse_end( 'timerecord' );
206-
207-
} # Add access
208-
} # function end
209-
210-
function schema() {
211-
return array(
212-
array( 'CreateTableSQL', array( plugin_table( 'data' ), "
213-
id I NOTNULL UNSIGNED AUTOINCREMENT PRIMARY,
214-
bug_id I DEFAULT NULL UNSIGNED,
215-
user I DEFAULT NULL UNSIGNED,
216-
expenditure_date T DEFAULT NULL,
217-
hours F(15,3) DEFAULT NULL,
218-
timestamp T DEFAULT NULL,
219-
info C(255) DEFAULT NULL
220-
" ) ),
221-
);
222-
}
223-
224-
function timerecord_menu() {
225-
$bugid = gpc_get_int( 'id' );
226-
if ( access_has_bug_level( plugin_config_get( 'admin_own_threshold' ), $bugid )
227-
|| access_has_bug_level( plugin_config_get( 'view_others_threshold' ), $bugid ) ){
228-
$import_page ='view.php?';
229-
$import_page .='id=';
230-
$import_page .= $bugid ;
231-
$import_page .= '#timerecord';
232-
233-
return array( plugin_lang_get( 'timerecord_menu' ) => $import_page);
207+
collapse_end( 'timerecord' );
208+
209+
} # Add access
210+
} # function end
211+
212+
function schema() {
213+
return array(
214+
array( 'CreateTableSQL', array( plugin_table( 'data' ), "
215+
id I NOTNULL UNSIGNED AUTOINCREMENT PRIMARY,
216+
bug_id I DEFAULT NULL UNSIGNED,
217+
user I DEFAULT NULL UNSIGNED,
218+
expenditure_date T DEFAULT NULL,
219+
hours F(15,3) DEFAULT NULL,
220+
timestamp T DEFAULT NULL,
221+
info C(255) DEFAULT NULL
222+
" )
223+
),
224+
);
225+
}
226+
227+
function timerecord_menu() {
228+
$bugid = gpc_get_int( 'id' );
229+
if( access_has_bug_level( plugin_config_get( 'admin_own_threshold' ), $bugid )
230+
|| access_has_bug_level( plugin_config_get( 'view_others_threshold' ), $bugid ) ) {
231+
$import_page = 'view.php?';
232+
$import_page .= 'id=';
233+
$import_page .= $bugid ;
234+
$import_page .= '#timerecord';
235+
236+
return array( plugin_lang_get( 'timerecord_menu' ) => $import_page);
234237
}
235238
else {
236239
return array ();
237240
}
238241
}
239242

240-
function showreport_menu() {
241-
if ( access_has_global_level( plugin_config_get( 'admin_own_threshold' ) ) ){
242-
return array( '<a href="' . plugin_page( 'show_report' ) . '">' . plugin_lang_get( 'title' ) . '</a>', );
243+
function showreport_menu() {
244+
if ( access_has_global_level( plugin_config_get( 'admin_own_threshold' ) ) ){
245+
return array( '<a href="' . plugin_page( 'show_report' ) . '">' . plugin_lang_get( 'title' ) . '</a>', );
243246
}
244247
else {
245248
return array ('');
246-
}
249+
}
247250
}
248251

249252

0 commit comments

Comments
 (0)