From eb8070d31817764d70a75cd444adaabec4849c55 Mon Sep 17 00:00:00 2001 From: Nigel McNie Date: Mon, 6 Nov 2006 09:48:29 +1300 Subject: [PATCH] Added checking for if the internal plugins are installed. --- htdocs/init.php | 1 + htdocs/lib/mahara.php | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/htdocs/init.php b/htdocs/init.php index 449c285be4..62988072ee 100644 --- a/htdocs/init.php +++ b/htdocs/init.php @@ -100,6 +100,7 @@ try { $db->SetFetchMode(ADODB_FETCH_ASSOC); configure_dbconnection(); + ensure_internal_plugins_exist(); ob_end_clean(); } diff --git a/htdocs/lib/mahara.php b/htdocs/lib/mahara.php index 3384ef1ae8..7c42aabf66 100644 --- a/htdocs/lib/mahara.php +++ b/htdocs/lib/mahara.php @@ -58,7 +58,7 @@ function ensure_sanity() { // register globals workaround if (ini_get_bool('register_globals')) { log_environ(get_string('registerglobals', 'error')); - $massivearray = array_keys(array_merge($_POST,$_GET,$_COOKIE,$_SERVER,$_REQUEST,$_FILES)); + $massivearray = array_keys(array_merge($_POST, $_GET, $_COOKIE, $_SERVER, $_REQUEST, $_FILES)); foreach ($massivearray as $tounset) { unset($GLOBALS[$tounset]); } @@ -120,16 +120,26 @@ function ensure_sanity() { throw new ConfigSanityException(get_string('datarootnotwritable', 'error', get_config('dataroot'))); } - // Json functions not available - //if (!function_exists('json_encode') || !function_exists('json_decode')) { - // throw new ConfigSanityException(get_string('jsonextensionnotloaded', 'error')); - //} - + // @todo the results of these should be checked check_dir_exists(get_config('dataroot').'smarty/compile'); check_dir_exists(get_config('dataroot').'smarty/cache'); } +/** + * Check to see if the internal plugins are installed. Die if they are not. + */ +function ensure_internal_plugins_exist() { + // Internal things installed + if (!get_config('installed')) { + foreach (plugin_types() as $type) { + if (!record_exists($type . '_installed', 'name', 'internal')) { + throw new ConfigSanityException(get_string($type . 'notinstalled')); + } + } + } +} + function get_string($identifier, $section='mahara') { $langconfigstrs = array('parentlanguage', 'strftimedate', 'strftimedateshort', 'strftimedatetime', -- GitLab