Column created in 1.1.x don't work in 1.2.x

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
drb001
Posts: 15
Joined: 06 Nov 2012, 09:08

Column created in 1.1.x don't work in 1.2.x

Post by drb001 »

Hello, I builded a column in the view_all_bug_page.php that shows the total time per bug, thast works great in every version of 1.1.x but in 1.2.x not, this is the code of my column working on 1.1.x but I don't know why in the new mantis don't work, please help me

In config_inc.php:

Code: Select all

$g_view_issues_page_columns = array ( 'selection', 'edit', 'priority', 'id', 'sponsorship_total', 'bugnotes_count', 
'custom_Horas Estimadas', 'bugnotes_tracking', 'attachment', 'category', 'severity', 'status', 'last_updated', 
'summary' );
$g_print_issues_page_columns = array ( 'selection', 'priority', 'id', 'sponsorship_total', 'bugnotes_count', 
'custom_Horas Estimadas', 'bugnotes_tracking', 'attachment', 'category', 'severity', 'status', 'last_updated', 
'summary' );
In lang/strings_spanish.txt:

Code: Select all

$s_bugnotes_tracking ="TT";
In core/columns_api.php:

Code: Select all

function print_column_bugnotes_tracking( $p_row, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
                global $t_filter;
                $total_time_per_bug = bug_get_bugnote_tracking( $p_row['id'] );
                if (empty($total_time_per_bug)){ $total_time_per_bug = "0.0000"; }
                $total_time_per_bug = db_minutes_to_hhmm( $total_time_per_bug );
                echo '<td class="center">';
                echo $total_time_per_bug;
                echo '</td>';
        }

function print_column_title_bugnotes_tracking( $p_sort, $p_dir, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE 
) {
                if ( $p_columns_target != COLUMNS_TARGET_CSV_PAGE ) {
                        echo '<td> TT </td>';
                } else {
                        echo 'TT';
                }
        }
In core/bug_api.php:

Code: Select all

        function bug_get_bugnote_tracking( $p_bug_id ) {
                $c_bug_id = db_prepare_int( $p_bug_id );

                $t_project_id = bug_get_field( $p_bug_id, 'project_id' );

                if ( !access_has_project_level( config_get( 'private_bugnote_threshold' ), $t_project_id 
) ) {
                        $t_restriction = 'AND view_state=' . VS_PUBLIC;
                } else {
                        $t_restriction = '';
                }

                $t_bugnote_table = config_get( 'mantis_bugnote_table' );
                $query = "SELECT sum(time_tracking)
                                  FROM $t_bugnote_table
                                  WHERE bug_id ='$c_bug_id' $t_restriction";
                $result = db_query( $query );

                return db_result( $result );
        }
Last edited by drb001 on 06 Feb 2013, 09:02, edited 1 time in total.
drb001
Posts: 15
Joined: 06 Nov 2012, 09:08

Re: Column created in 1.1.x don't work in 1.2.x

Post by drb001 »

Nobody?

Please someone can help me?

Thanks
drb001
Posts: 15
Joined: 06 Nov 2012, 09:08

Re: Column created in 1.1.x don't work in 1.2.x

Post by drb001 »

I changed some code based on other configuration files:

- columns_api.php:

Code: Select all

function print_column_bugnotes_tracking( $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
                global $t_filter;
                $total_time_per_bug = bug_get_bugnote_tracking( $p_bug->id );
                if (empty($total_time_per_bug)){ $total_time_per_bug = "0.0000"; }
                $total_time_per_bug = db_minutes_to_hhmm( $total_time_per_bug );
                echo '<td class="center">';
                echo $total_time_per_bug;
                echo '</td>';
        }

function print_column_title_bugnotes_tracking( $p_sort, $p_dir, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE 
) {
                if ( $p_columns_target != COLUMNS_TARGET_CSV_PAGE ) {
                        echo '<td> TT </td>';
                } else {
                        echo '<td> TT </td>';
                }
        }
- bug_api.php:

Code: Select all

function bug_get_bugnote_tracking( $p_bug_id ) {
                $c_bug_id = db_prepare_int( $p_bug_id );

                $t_project_id = bug_get_field( $p_bug_id, 'project_id' );

                if ( !access_has_project_level( config_get( 'private_bugnote_threshold' ), $t_project_id ) ) {

                        $t_restriction = 'AND view_state=' . VS_PUBLIC;
                } else {
                        $t_restriction = '';
                }

                $t_bugnote_table = config_get( 'mantis_bugnote_table' );
                $query = "SELECT SUM(time_tracking)
                                  FROM $t_bugnote_table
                                  WHERE bug_id =" . db_param() . " $t_restriction";
                $result = db_query_bound( $query );

                return db_result( $result );
        }
Please if anyone could help I would be grateful because I have too much knowledge of php
drb001
Posts: 15
Joined: 06 Nov 2012, 09:08

Re: Column created in 1.1.x don't work in 1.2.x

Post by drb001 »

This code does is give me the page view_all_bug_page.php the hours are accumulated in issues

Please if anyone could help I would be grateful
atrol
Site Admin
Posts: 8558
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Column created in 1.1.x don't work in 1.2.x

Post by atrol »

What does this mean?
in the new mantis don't work
Do you get any errors on page or in web server log?
Check also pages "My Account" > "Columns" and "Manage" > "Manage Configuration" > "Manage Columns"

BWW, changing any original source of MantisBT is no good idea.
The preferred solution is to write plugins or custom functions in your own files.
Please use Search before posting and read the Manual
drb001
Posts: 15
Joined: 06 Nov 2012, 09:08

Re: Column created in 1.1.x don't work in 1.2.x

Post by drb001 »

Hello atrol,

When I said "new mantis" im refering to the 1.2.11 mantis version, I only added that part in the original code that creates a new column in the bug view pages that shows the total time of all the issues, that calculate and create the new column in tha view, I tried to create a plugin but don't work, and in the code directly writed doesn't work in mantis 1.2.11, but in my old version of mantis (1.1.1) yes works fine, and I don't know if the structure of mantis or the code has changed but it doesn't work a functionality that works fine in old version written directly in the code

I don't have any errors in pages "My Account" > "Columns" and "Manage" > "Manage Configuration" > "Manage Columns"

Thanks atrol, I waiting your response
atrol
Site Admin
Posts: 8558
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Column created in 1.1.x don't work in 1.2.x

Post by atrol »

Check also pages "My Account" > "Columns" and "Manage" > "Manage Configuration" > "Manage Columns"
I wrote this to show you that there is a new column management in version 1.2
Start looking at functions columns_get_all and columns_get_standard in core/columns_api.php
Please use Search before posting and read the Manual
drb001
Posts: 15
Joined: 06 Nov 2012, 09:08

Re: Column created in 1.1.x don't work in 1.2.x

Post by drb001 »

Hello atrol,

A lot of thanks, I watched the files and my customization works great! :)
But I need to build that like a plugin but I don't know what I have to do

Thanks :)
drb001
Posts: 15
Joined: 06 Nov 2012, 09:08

Re: Column created in 1.1.x don't work in 1.2.x

Post by drb001 »

Could anyone help me ? as I can not write this code to be a plugin, do not really understand the structure of the plugins, I tried copying one but I don't achieve

Thanks
drb001
Posts: 15
Joined: 06 Nov 2012, 09:08

Re: Column created in 1.1.x don't work in 1.2.x

Post by drb001 »

Can somebody the syntax to create a mantis plugins? I read the guides but I don't understand

Thanks everybody
drb001
Posts: 15
Joined: 06 Nov 2012, 09:08

Re: Column created in 1.1.x don't work in 1.2.x

Post by drb001 »

Hello

Can somebody help me, I don't understand the syntax of pluigns

Thanks
drb001
Posts: 15
Joined: 06 Nov 2012, 09:08

Re: Column created in 1.1.x don't work in 1.2.x

Post by drb001 »

Can help me somebody

Thanks
Post Reply