From d39655e1269494dd1c8cad06c972e8884cace8ea Mon Sep 17 00:00:00 2001 From: Michael Gapczynski <mtgap@owncloud.com> Date: Mon, 7 Jan 2013 14:15:51 -0500 Subject: [PATCH] Move template parameters around so database error page is properly rendered --- core/js/js.js | 2 +- core/templates/layout.base.php | 1 - core/templates/layout.guest.php | 1 - lib/db.php | 8 ++++++-- lib/setup.php | 4 +++- lib/templatelayout.php | 17 +++++------------ 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/core/js/js.js b/core/js/js.js index 610950995db..b7442f303ac 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -88,7 +88,7 @@ var OC={ PERMISSION_DELETE:8, PERMISSION_SHARE:16, webroot:oc_webroot, - appswebroots:oc_appswebroots, + appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false, currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false, coreApps:['', 'admin','log','search','settings','core','3rdparty'], /** diff --git a/core/templates/layout.base.php b/core/templates/layout.base.php index 47f4b423b3e..cb2f9773839 100644 --- a/core/templates/layout.base.php +++ b/core/templates/layout.base.php @@ -10,7 +10,6 @@ <script type="text/javascript"> var oc_debug = <?php echo (defined('DEBUG') && DEBUG) ? 'true' : 'false'; ?>; var oc_webroot = '<?php echo OC::$WEBROOT; ?>'; - var oc_appswebroots = <?php echo $_['apps_paths'] ?>; var oc_requesttoken = '<?php echo $_['requesttoken']; ?>'; </script> <?php foreach ($_['jsfiles'] as $jsfile): ?> diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index 8395426e4e4..5b39503474d 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -10,7 +10,6 @@ <script type="text/javascript"> var oc_debug = <?php echo (defined('DEBUG') && DEBUG) ? 'true' : 'false'; ?>; var oc_webroot = '<?php echo OC::$WEBROOT; ?>'; - var oc_appswebroots = <?php echo $_['apps_paths'] ?>; var oc_requesttoken = '<?php echo $_['requesttoken']; ?>'; var datepickerFormatDate = <?php echo json_encode($l->l('jsdate', 'jsdate')) ?>; var dayNames = <?php echo json_encode(array((string)$l->t('Sunday'), (string)$l->t('Monday'), (string)$l->t('Tuesday'), (string)$l->t('Wednesday'), (string)$l->t('Thursday'), (string)$l->t('Friday'), (string)$l->t('Saturday'))) ?>; diff --git a/lib/db.php b/lib/db.php index 74e7ca5b0e0..fbefb13a95e 100644 --- a/lib/db.php +++ b/lib/db.php @@ -181,7 +181,9 @@ class OC_DB { try{ self::$PDO=new PDO($dsn, $user, $pass, $opts); }catch(PDOException $e) { - OC_Template::printErrorPage( 'can not connect to database, using '.$type.'. ('.$e->getMessage().')' ); + OC_User::setUserId(null); + OC_Template::printErrorPage('Failed to connect to '.$type.' database. ('.$e->getMessage().')' ); + die(); } // We always, really always want associative arrays self::$PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); @@ -277,7 +279,9 @@ class OC_DB { if( PEAR::isError( self::$MDB2 )) { OC_Log::write('core', self::$MDB2->getUserInfo(), OC_Log::FATAL); OC_Log::write('core', self::$MDB2->getMessage(), OC_Log::FATAL); - OC_Template::printErrorPage( 'can not connect to database, using '.$type.'. ('.self::$MDB2->getUserInfo().')' ); + OC_User::setUserId(null); + OC_Template::printErrorPage('Failed to connect to '.$type.' database. ('.self::$MDB2->getUserInfo().')' ); + die(); } // We always, really always want associative arrays diff --git a/lib/setup.php b/lib/setup.php index fdd10be6824..424414faa6b 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -141,7 +141,9 @@ class OC_Setup { if(count($error) == 0) { OC_Appconfig::setValue('core', 'installedat', microtime(true)); OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true)); - + OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php'); + OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php'); + OC_Group::createGroup('admin'); OC_Group::addToGroup($username, 'admin'); OC_User::login($username, $password); diff --git a/lib/templatelayout.php b/lib/templatelayout.php index 4173e008ba7..83d36199986 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -28,23 +28,16 @@ class OC_TemplateLayout extends OC_Template { break; } } + $apps_paths = array(); + foreach(OC_App::getEnabledApps() as $app) { + $apps_paths[$app] = OC_App::getAppWebPath($app); + } + $this->assign( 'apps_paths', str_replace('\\/', '/', json_encode($apps_paths)), false ); // Ugly unescape slashes waiting for better solution } else if ($renderas == 'guest') { parent::__construct('core', 'layout.guest'); } else { parent::__construct('core', 'layout.base'); } - - $apps_paths = array(); - foreach(OC_App::getEnabledApps() as $app) { - $apps_paths[$app] = OC_App::getAppWebPath($app); - } - $this->assign( 'apps_paths', str_replace('\\/', '/', json_encode($apps_paths)), false ); // Ugly unescape slashes waiting for better solution - - if (OC_Config::getValue('installed', false) && !OC_AppConfig::getValue('core', 'remote_core.css', false)) { - OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php'); - OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php'); - } - // Add the js files $jsfiles = self::findJavascriptFiles(OC_Util::$scripts); $this->assign('jsfiles', array(), false); -- GitLab