Custom Function override

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
artgroup
Posts: 29
Joined: 02 Jul 2008, 12:35

Custom Function override

Post by artgroup »

Hi all,
I modified the html.api file to highlight the current selected project into the Project Menu Bar and everything was working as expected. Than I moved my modificationt to the custom_functions_inc.php file so that I do not touch the original code, but now it's not working anymore the patch.

Code: Select all

<?php
	function custom_function_override_print_project_menu_bar() {
		$t_project_ids = current_user_get_accessible_projects();
    $t_current_project = helper_get_current_project();
    
		PRINT '<table class="width100" cellspacing="0">';
		PRINT '<tr>';
			PRINT '<td class="menu">';
			if ($t_current_project == ALL_PROJECTS) {
        PRINT '<b><font color="#FF0000"><href="set_project.php?project_id=' . ALL_PROJECTS . '">' . lang_get( 'all_projects' ) . '</style></a></b></font>';
      } 
      else {
      	PRINT '<small><a href="set_project.php?project_id=' . ALL_PROJECTS . '">' . lang_get( 'all_projects' ) . '</a></small>';
      }
      
			foreach ( $t_project_ids as $t_id ) {
        if ($t_current_project == $t_id) {
          PRINT ' | <b><font color="#FF0000"><href=\"set_project.php?project_id=$t_id\">' . string_display( project_get_field( $t_id, 'name' ) ) . '</a></b></font>';
        } 
        else {
          PRINT " | <small><a href=\"set_project.php?project_id=$t_id\">" . string_display( project_get_field( $t_id, 'name' ) ) . '</a></small>';
        }  
				custom_function_override_print_subproject_menu_bar( $t_id, $t_id . ';' );
			}

			PRINT '</td>';
		PRINT '</tr>';
		PRINT '</table>';
	}
?>
<?php
	function custom_function_override_print_subproject_menu_bar( $p_project_id, $p_parents = '' ) {
		$t_subprojects = current_user_get_accessible_subprojects( $p_project_id );
		$t_current_subproject = helper_get_current_project();
		
		$t_char = ':';
		foreach ( $t_subprojects as $t_subproject ) {
      if ($t_current_subproject == $t_subproject) {
        PRINT "$t_char <b><font color='#FF0000'><href=\"set_project.php?project_id=$p_parents$t_subproject\">" . string_display( project_get_field( $t_subproject, 'name' ) ) . '</a></b></font>';
      } 
      else {
        PRINT "<small>$t_char <a href=\"set_project.php?project_id=$p_parents$t_subproject\">" . string_display( project_get_field( $t_subproject, 'name' ) ) . '</a></small>';
      }  
			print_subproject_menu_bar( $t_subproject, $p_parents . $t_subproject . ';' );
			$t_char = ',';
		}
	}
?>
what is wrong?

The code above removes the hyperlink to the current project, set bold as font and RED as text colour.
Chris by ArtGroup

Mantis: 1.1.2
PHP: 5.2.5
SQL: MySQL 5.0.51a
OS: XP SP2
deboutv
Posts: 507
Joined: 15 Jan 2007, 14:31
Location: La Ciotat, FRANCE
Contact:

Re: Custom Function override

Post by deboutv »

Only functions in the file core/custom_function_api.php could be overridden. So you trying to make something impossible.
Want more plugins to customize Mantis?
=> http://deboutv.free.fr/mantis/

Mantis: 1.1.0, 1.1.0a2
PHP: 5.0.4
SQL: MySQL 5.0.19
OS: Linux
mpa
Posts: 28
Joined: 15 Jan 2008, 12:34

Re: Custom Function override

Post by mpa »

I'm having a similar question and want to override a core function, in my case file_normalize_attachment_path
Is there no option or trick to do this?
cas
Posts: 1768
Joined: 11 Mar 2006, 16:08
Contact:

Re: Custom Function override

Post by cas »

Same answer as in 2008 is valid. So if there is no such function defined, you cannot override it. :mrgreen:
Post Reply