Page 1 of 1

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

Posted: 04 Feb 2013, 15:42
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 );
        }

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

Posted: 06 Feb 2013, 07:15
by drb001
Nobody?

Please someone can help me?

Thanks

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

Posted: 06 Feb 2013, 09:00
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

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

Posted: 06 Feb 2013, 09:10
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

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

Posted: 07 Feb 2013, 05:54
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.

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

Posted: 11 Feb 2013, 07:54
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

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

Posted: 12 Feb 2013, 21:07
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

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

Posted: 14 Feb 2013, 13:38
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 :)

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

Posted: 20 Feb 2013, 07:23
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

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

Posted: 25 Feb 2013, 06:56
by drb001
Can somebody the syntax to create a mantis plugins? I read the guides but I don't understand

Thanks everybody

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

Posted: 08 Mar 2013, 08:25
by drb001
Hello

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

Thanks

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

Posted: 04 Apr 2013, 07:04
by drb001
Can help me somebody

Thanks