1<?php if (!defined('BASEPATH')) { 2 exit('No direct script access allowed'); 3} 4/* 5 * LimeSurvey 6 * Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz 7 * All rights reserved. 8 * License: GNU/GPL License v2 or later, see LICENSE.php 9 * LimeSurvey is free software. This version may have been modified pursuant 10 * to the GNU General Public License, and as distributed it includes or 11 * is derivative of works licensed under the GNU General Public License or 12 * other free or open source software licenses. 13 * See COPYRIGHT.php for copyright notices and details. 14 * 15 */ 16//Ensure script is not run directly, avoid path disclosure 17//if (!isset($homedir) || isset($_REQUEST['$homedir'])) {die("Cannot run this script directly");} 18injectglobalsettings(); 19 20 21function injectglobalsettings() 22{ 23 $settings = SettingGlobal::model()->findAll(); 24 25 //if ($dbvaluearray!==false) 26 if (count($settings) > 0) { 27 foreach ($settings as $setting) { 28 Yii::app()->setConfig($setting->getAttribute('stg_name'), $setting->getAttribute('stg_value')); 29 } 30 } 31} 32/** 33 * Returns a global setting 34 * @deprecated : use App()->getConfig($settingname) 35 * since all config are set at start of App : no need to read and test again 36 * 37 * @param string $settingname 38 * @return string 39 */ 40function getGlobalSetting($settingname) 41{ 42 $dbvalue = Yii::app()->getConfig($settingname); 43 44 if ($dbvalue === false) { 45 $dbvalue = SettingGlobal::model()->findByPk($settingname); 46 47 if ($dbvalue === null) { 48 Yii::app()->setConfig($settingname, null); 49 $dbvalue = ''; 50 } else { 51 $dbvalue = $dbvalue->getAttribute('stg_value'); 52 } 53 54 if (Yii::app()->getConfig($settingname) !== false) { 55 // If the setting was not found in the setting table but exists as a variable (from config.php) 56 // get it and save it to the table 57 SettingGlobal::setSetting($settingname, Yii::app()->getConfig($settingname)); 58 $dbvalue = Yii::app()->getConfig($settingname); 59 } 60 } 61 62 return $dbvalue; 63} 64