I am trying to add a custom button but I couldn't figure it out; I know about custom_function_default_print_bug_view_page_custom_buttons, but couldn't find anything about how to use it; I looked everywhere to the best of my knowledge.
Is there any code to be added inside: custom_function_default_print_bug_view_page_custom_buttons?
If anyone can send me a sample code that would be great.
Any help would be greatly appreciated.
Thank you in advance,
Mantis version is: 1.1.2
Help with custom buttons
Moderators: Developer, Contributor
Re: Help with custom buttons
Try the Mantis Manual. It's for 1.1.2 but most of it also applies to 1.1.1
http://www.scribd.com/full/2088848?acce ... jvshqlc2hw
http://www.scribd.com/full/2088848?acce ... jvshqlc2hw
-
- Posts: 9
- Joined: 31 Jul 2008, 16:27
Re: Help with custom buttons
Thank you for your reply. I tried the manual but it has nothing about "custom buttons".
Thanks again
Thanks again
-
- Posts: 9
- Joined: 31 Jul 2008, 16:27
Re: Help with custom buttons
Because I have to add a button; that's what I did: (I hope this helps whoever needs help).
I need a button to link Mantis to another application so... (I found 2 solutions to *my* problem). This code is probably a mess but it works for me
First solution:
1- Added new page that only redirects to my other application link_page.php (Code is shown below)
2- In strings_english.txt: $s_link_mantis_to_app = 'Go to App';
3- In config_inc.php: $g_link_mantis_to_app = 'http://thelink_to_my_app.com/file.php?MantisID='.$_POST['bug_id'];
4- Add new table MANTIS_CUSTOM_BUTTONS. Fields(Custom_Button_ID [auto increment], Project_ids [projects ids you want to make this button available to, comma seperated])
5- In html_api.php:
6- Use the same name for config_get and lang_get functions without the $s_/$g_ (Like 'link_mantis_to_app')
Code mentioned in step 1 (link_page.php):
End of first solution (Did the solution give you a headache?
).
Second solution:
My second and easier solution is: (This is much better, at least for me and you'll see why)
1- Added new custom field of type string.
2- The value of the string is a URL to the application I want to connect to.
3- In Page: string_api.php, function: string_insert_hrefs: chagned the code below to append the hyper link with the MantisID value:
End of second solution.
Yeah
Feel free to contact me for any questions. Not like you want to contact after seeing my code but just in case.
I need a button to link Mantis to another application so... (I found 2 solutions to *my* problem). This code is probably a mess but it works for me

First solution:
1- Added new page that only redirects to my other application link_page.php (Code is shown below)
2- In strings_english.txt: $s_link_mantis_to_app = 'Go to App';
3- In config_inc.php: $g_link_mantis_to_app = 'http://thelink_to_my_app.com/file.php?MantisID='.$_POST['bug_id'];
4- Add new table MANTIS_CUSTOM_BUTTONS. Fields(Custom_Button_ID [auto increment], Project_ids [projects ids you want to make this button available to, comma seperated])
5- In html_api.php:
Code: Select all
function html_button_mantis_link( $p_bug_id ) {
$query = 'SELECT PROJECT_IDS FROM MANTIS_CUSTOM_BUTTONS WHERE CUSTOM_BUTTON_ID = 1';
$result = db_query( $query );
$row = db_fetch_array( $result );
$t_project_ids_button = $row['PROJECT_IDS'];
$is_project_id = 0;
$split_project_ids = split(',', $t_project_ids_button); //$t_project_ids_button
$split_project_ids_cnt = count($split_project_ids);
for ($i=0; $i<$split_project_ids_cnt; $i++) {
if (helper_get_current_project() == $split_project_ids[$i]) {
$is_project_id = 1;
}
}
if ( $is_project_id == 1 ) {
html_button( 'link_page.php',
lang_get( 'link_mantis_to_app', 'english' ),
array( 'bug_id' => $p_bug_id, 'action' => 'link' ) );
}
}
Code mentioned in step 1 (link_page.php):
Code: Select all
<?php
require_once( 'core.php' );
$t_redirect = config_get( 'link_mantis_to_app' );
html_meta_redirect( $t_redirect );
?>
<br />
<div align="center">
<?php
echo lang_get( 'operation_successful' ) . '<br />';
print_bracket_link( $t_redirect, lang_get( 'proceed' ) );
?>
</div>
<?php html_page_bottom1( __FILE__ ) ?>

Second solution:
My second and easier solution is: (This is much better, at least for me and you'll see why)
1- Added new custom field of type string.
2- The value of the string is a URL to the application I want to connect to.
3- In Page: string_api.php, function: string_insert_hrefs: chagned the code below to append the hyper link with the MantisID value:
Code: Select all
# Find any URL in a string and replace it by a clickable link
/*$p_string = preg_replace( '/(([[:alpha:]][-+.[:alnum:]]*):\/\/(%[[:digit:]A-Fa-f]{2}|[-_.!~*\';\/?%^\\\\:@&={\|}+$#\(\),\[\][:alnum:]])+)/se',
"'<a href=\"'.rtrim('\\1','.').'\">\\1</a> [<a href=\"'.rtrim('\\1','.').'\" target=\"_blank\">^</a>]'",
$p_string);*/
#TO THIS
$p_string = preg_replace( '/(([[:alpha:]][-+.[:alnum:]]*):\/\/(%[[:digit:]A-Fa-f]{2}|[-_.!~*\';\/?%^\\\\:@&={\|}+$#\(\),\[\][:alnum:]])+)/se',
"'<a href=\"'.rtrim('\\1','.').'?MantisID=".$_GET['id']."\">\\1?MantisID=".$_GET['id']."</a> [<a href=\"'.rtrim('\\1','.').'\" target=\"_blank\">^</a>]'",
$p_string);
Yeah

Feel free to contact me for any questions. Not like you want to contact after seeing my code but just in case.