/** * Execute module function * * This function will execute function of the module * If function does not exists, it will display error message * * @param string $module_name name of the module * @param string $function_name function's name * @param array $parameters_override _REQUEST parameters to rewrite */ function executeFunction($module_name, $function_name, $parameters_override = array(), $pageID = false) { if (SJB_Users_CookiePreferences::isModuleDisabled($function_name)) { return; } ob_start(); if ($this->isFunctionAccessible($module_name, $function_name)) { $script_filename = $this->getFunctionScriptFilename($module_name, $function_name); if ($script_filename != null && is_readable($script_filename)) { $adminAccessType = SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') == SJB_System::getSystemSettings('ADMIN_ACCESS_TYPE'); $this->prepareFunctionEnvironment($parameters_override); $this->pushExecutionStack($module_name, $function_name); $function = $this->getFunction($function_name, $module_name, $parameters_override); // permissions checking if (!$function->isAccessible()) { if ($adminAccessType && SJB_SubAdmin::admin_authed()) { $function = $this->getFunction('function_is_not_accessible_for_subadmin', 'miscellaneous'); } else { $function = $this->getFunction('function_is_not_accessible', 'miscellaneous'); } SJB_Request::getInstance()->setPageTemplate('index.tpl'); } if (SJB_Profiler::getInstance()->isProfilerEnable()) { SJB_DB::setFunctionInfo($function_name, $module_name); $startTime = microtime(true); $function->execute(); $spendTime = microtime(true) - $startTime; $spendTime = number_format($spendTime, 8); SJB_Profiler::getInstance()->gatherFunctionInfo($module_name, $function_name, $spendTime); } else { $function->execute(); } if (SJB_FlashMessages::getInstance()->isErrors()) { $errors = SJB_FlashMessages::getInstance()->getErrorsAndRemove(); $function = $this->getFunctionForErrors($errors); if ($function) { ob_clean(); $function->execute(); SJB_Request::getInstance()->setPageTemplate('index.tpl'); } } $this->popExecutionStack(); $this->restoreEnvironment(); } else { return "<!-- Either wrong module/function or function script file does not exist for {$module_name}, {$function_name} -->"; } } else { return "<!-- No such function or function is not accessible for {$module_name}, {$function_name} -->"; } return ob_get_clean(); }