'init' && !empty($module) && !pnModAvailable($modinfo['name'])) { Loader::includeOnce('header.php'); LogUtil::registerError(__f("The '%s' module is not currently accessible.", DataUtil::formatForDisplay(strip_tags($module)))); echo pnModFunc('Errors', 'user', 'main', array('type' => 404)); Loader::includeOnce('footer.php'); pnShutDown(); } if ($modinfo['type'] == 2 || $modinfo['type'] == 3) { // New-new style of loading modules if (!isset($arguments)) { $arguments = array(); } // we need to force the mod load if we want to call a modules interactive init // function because the modules is not active right now $force_modload = ($type=='init') ? true : false; if (empty($type)) $type = 'user'; if (empty($func)) $func = 'main'; if (pnModLoad($modinfo['name'], $type, $force_modload)) { if (pnConfigGetVar('PN_CONFIG_USE_TRANSACTIONS')) { $dbConn = pnDBGetConn(true); $dbConn->StartTrans(); } $return = pnModFunc($modinfo['name'], $type, $func, $arguments); if (pnConfigGetVar('PN_CONFIG_USE_TRANSACTIONS')) { if ($dbConn->HasFailedTrans()) { $return = __('Error! The transaction failed. Please perform a rollback.') . $return; } $dbConn->CompleteTrans(); } } else { $return = false; } // Sort out return of function. Can be // true - finished // false - display error msg // text - return information if ($return !== true) { Loader::includeOnce('header.php'); if ($return === false) { // check for existing errors or set a generic error if (!LogUtil::hasErrors()) { LogUtil::registerError(__f("Could not load the '%s' module (at '%s' function).", array($modinfo['url'], $func)), 404); } echo pnModFunc('Errors', 'user', 'main'); } elseif (is_string($return) && strlen($return) > 1) { // Text echo $return; } elseif (is_array($return)) { $pnRender = & pnRender::getInstance($modinfo['name']); $pnRender->assign($return); if (isset($return['template'])) { echo $pnRender->fetch($return['template']); } else { $modname = strtolower($modinfo['name']); $type = strtolower($type); $func = strtolower($func); echo $pnRender->fetch("{$modname}_{$type}_{$func}.htm"); } } else { LogUtil::registerError(__f('The \'%1$s\' module returned at the \'%2$s\' function.', array($modinfo['url'], $func)), 404); echo pnModFunc('Errors', 'user', 'main'); } Loader::includeOnce('footer.php'); } } elseif ($modinfo['type'] == 1) { // Old-old style of loading modules define('LOADED_AS_MODULE', '1'); // ensure that the module table information is available pnModDBInfoLoad($modinfo['name'], $modinfo['directory']); if (file_exists('modules/' . DataUtil::formatForOS($modinfo['directory']) . '/' . DataUtil::formatForOS($file) . '.php')) { include 'modules/' . DataUtil::formatForOS($modinfo['directory']) . '/' . DataUtil::formatForOS($file) . '.php'; } else { // Failed to load the module header('HTTP/1.0 404 Not Found'); Loader::includeOnce('header.php'); LogUtil::registerError(__f("Could not load the '%s' module.", $modinfo['url']), 404); echo pnModFunc('Errors', 'user', 'main'); Loader::includeOnce('footer.php'); pnShutDown(); } } else { Loader::includeOnce('header.php'); Loader::includeOnce('footer.php'); } pnShutDown();