Changeset 8881

Show
Ignore:
Timestamp:
02/18/10 18:45:33 (2 years ago)
Author:
p_lindheimer
Message:

fixes #4057 don't iterate through global array when calling hooks or hooks that do the same will end the loop prematurely

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.7/amp_conf/htdocs/admin/functions.inc.php

    r8843 r8881  
    654654  function install_hooks($viewing_itemid,$target_module,$target_menuid = '') { 
    655655    global $active_modules; 
    656     // loop through all active modules 
     656 
     657    /*  Loop though all active modules and find which ones have hooks. 
     658     *  Then process those hooks. Note we split this into two loops 
     659     *  because of #4057, if drawselects() is called from within a hook 
     660     *  it's interaction with the same $active_modules array renders the 
     661     *  foreach loop done after that module and execution ends. 
     662     */ 
     663    $our_hooks = array(); 
    657664    foreach($active_modules as $this_module) { 
    658665      // look for requested hooks for $module 
     
    660667      $funct = $this_module['rawname'] . '_hook_' . $target_module; 
    661668      if( function_exists( $funct ) ) { 
    662         // execute the function, appending the  
    663         // html output to that of other hooking modules 
    664  
    665         $thismod = $this_module['rawname']; 
    666         if (isset($_COOKIE['lang']) && is_dir("./modules/$thismod/i18n/".$_COOKIE['lang'])) { 
    667           bindtextdomain($thismod,"./modules/$thismod/i18n"); 
    668           bind_textdomain_codeset($thismod, 'utf8'); 
    669           textdomain($thismod); 
    670        
    671           if ($hookReturn = $funct($target_menuid, $viewing_itemid)) { 
    672             $this->hookHtml .= $hookReturn; 
    673           } 
    674  
    675           textdomain('amp'); 
    676         } else { 
    677           if ($hookReturn = $funct($target_menuid, $viewing_itemid)) { 
    678             $this->hookHtml .= $hookReturn; 
    679           } 
     669        // remember who installed hooks 
     670        // we need to know this for processing form vars 
     671        $this->arrHooks[] = $this_module['rawname']; 
     672        $our_hooks[$this_module['rawname']] = $funct; 
     673      } 
     674    } 
     675    foreach($our_hooks as $thismod => $funct) { 
     676      if (isset($_COOKIE['lang']) && is_dir("./modules/$thismod/i18n/".$_COOKIE['lang'])) { 
     677        bindtextdomain($thismod,"./modules/$thismod/i18n"); 
     678        bind_textdomain_codeset($thismod, 'utf8'); 
     679        textdomain($thismod); 
     680        if ($hookReturn = $funct($target_menuid, $viewing_itemid)) { 
     681          $this->hookHtml .= $hookReturn; 
    680682        } 
    681         // remember who installed hooks 
    682         // we need to know this for processing form vars 
    683         $this->arrHooks[] = $this_module['rawname']; 
    684       } 
    685     } 
    686   } 
    687    
     683        textdomain('amp'); 
     684      } else { 
     685        if ($hookReturn = $funct($target_menuid, $viewing_itemid)) { 
     686          $this->hookHtml .= $hookReturn; 
     687        } 
     688      } 
     689    } 
     690  }  
    688691  // process the request from the module we hooked 
    689692  function process_hooks($viewing_itemid, $target_module, $target_menuid, $request) {