diff options
| author | Greg Roach <fisharebest@gmail.com> | 2014-09-17 14:04:37 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2014-09-17 14:04:37 +0100 |
| commit | e678c5007bdab1a58ec295edeeda9f338fe47aec (patch) | |
| tree | 54bf5abd218f59056f5a6237a45ba3ea70564394 | |
| parent | 9e1bde72e0a1c6d5913fd7bb53a02bf81f87d85e (diff) | |
| download | webtrees-e678c5007bdab1a58ec295edeeda9f338fe47aec.tar.gz webtrees-e678c5007bdab1a58ec295edeeda9f338fe47aec.tar.bz2 webtrees-e678c5007bdab1a58ec295edeeda9f338fe47aec.zip | |
Split site-preference getter/setter into two functions
66 files changed, 184 insertions, 164 deletions
diff --git a/action.php b/action.php index 359abf2f17..fa055ef04b 100644 --- a/action.php +++ b/action.php @@ -245,7 +245,7 @@ case 'reject-changes': case 'theme': // Change the current theme $theme_dir=WT_Filter::post('theme'); - if (WT_Site::preference('ALLOW_USER_THEMES') && in_array($theme_dir, get_theme_names())) { + if (WT_Site::getPreference('ALLOW_USER_THEMES') && in_array($theme_dir, get_theme_names())) { $WT_SESSION->theme_dir=$theme_dir; if (Auth::id()) { // Remember our selection diff --git a/admin_pgv_to_wt.php b/admin_pgv_to_wt.php index 48513f1082..a1708f063e 100644 --- a/admin_pgv_to_wt.php +++ b/admin_pgv_to_wt.php @@ -181,20 +181,20 @@ if (ini_get('output_buffering')) { ob_flush(); } // TODO May need to set 'DATA_DIRECTORY' to $INDEX_DIRECTORY when dealing with media?? -@WT_Site::preference('USE_REGISTRATION_MODULE', $USE_REGISTRATION_MODULE); -@WT_Site::preference('REQUIRE_ADMIN_AUTH_REGISTRATION', $REQUIRE_ADMIN_AUTH_REGISTRATION); -@WT_Site::preference('ALLOW_USER_THEMES', $ALLOW_USER_THEMES); -@WT_Site::preference('ALLOW_CHANGE_GEDCOM', $ALLOW_CHANGE_GEDCOM); -@WT_Site::preference('SESSION_TIME', $PGV_SESSION_TIME); -@WT_Site::preference('SMTP_ACTIVE', $PGV_SMTP_ACTIVE ? 'external' : 'internal'); -@WT_Site::preference('SMTP_HOST', $PGV_SMTP_HOST); -@WT_Site::preference('SMTP_HELO', $PGV_SMTP_HELO); -@WT_Site::preference('SMTP_PORT', $PGV_SMTP_PORT); -@WT_Site::preference('SMTP_AUTH', $PGV_SMTP_AUTH); -@WT_Site::preference('SMTP_AUTH_USER', $PGV_SMTP_AUTH_USER); -@WT_Site::preference('SMTP_AUTH_PASS', $PGV_SMTP_AUTH_PASS); -@WT_Site::preference('SMTP_SSL', $PGV_SMTP_SSL); -@WT_Site::preference('SMTP_FROM_NAME', $PGV_SMTP_FROM_NAME); +@WT_Site::setPreference('USE_REGISTRATION_MODULE', $USE_REGISTRATION_MODULE); +@WT_Site::setPreference('REQUIRE_ADMIN_AUTH_REGISTRATION', $REQUIRE_ADMIN_AUTH_REGISTRATION); +@WT_Site::setPreference('ALLOW_USER_THEMES', $ALLOW_USER_THEMES); +@WT_Site::setPreference('ALLOW_CHANGE_GEDCOM', $ALLOW_CHANGE_GEDCOM); +@WT_Site::setPreference('SESSION_TIME', $PGV_SESSION_TIME); +@WT_Site::setPreference('SMTP_ACTIVE', $PGV_SMTP_ACTIVE ? 'external' : 'internal'); +@WT_Site::setPreference('SMTP_HOST', $PGV_SMTP_HOST); +@WT_Site::setPreference('SMTP_HELO', $PGV_SMTP_HELO); +@WT_Site::setPreference('SMTP_PORT', $PGV_SMTP_PORT); +@WT_Site::setPreference('SMTP_AUTH', $PGV_SMTP_AUTH); +@WT_Site::setPreference('SMTP_AUTH_USER', $PGV_SMTP_AUTH_USER); +@WT_Site::setPreference('SMTP_AUTH_PASS', $PGV_SMTP_AUTH_PASS); +@WT_Site::setPreference('SMTP_SSL', $PGV_SMTP_SSL); +@WT_Site::setPreference('SMTP_FROM_NAME', $PGV_SMTP_FROM_NAME); //////////////////////////////////////////////////////////////////////////////// diff --git a/admin_site_config.php b/admin_site_config.php index 02945eeb8b..e6969b20e2 100644 --- a/admin_site_config.php +++ b/admin_site_config.php @@ -70,28 +70,28 @@ $WELCOME_TEXT_AUTH_MODE_OPTIONS = array( <td> <dl> <dt><?php echo WT_I18N::translate('Data folder'), help_link('INDEX_DIRECTORY'); ?></dt> - <dd><?php echo edit_field_inline('site_setting-INDEX_DIRECTORY', WT_Site::preference('INDEX_DIRECTORY'), $controller); ?></dd> + <dd><?php echo edit_field_inline('site_setting-INDEX_DIRECTORY', WT_Site::getPreference('INDEX_DIRECTORY'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Memory limit'), help_link('MEMORY_LIMIT'); ?></dt> - <dd><?php echo edit_field_inline('site_setting-MEMORY_LIMIT', WT_Site::preference('MEMORY_LIMIT'), $controller); ?></dd> + <dd><?php echo edit_field_inline('site_setting-MEMORY_LIMIT', WT_Site::getPreference('MEMORY_LIMIT'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('PHP time limit'), help_link('MAX_EXECUTION_TIME'); ?></dt> - <dd><?php echo edit_field_inline('site_setting-MAX_EXECUTION_TIME', WT_Site::preference('MAX_EXECUTION_TIME'), $controller); ?></dd> + <dd><?php echo edit_field_inline('site_setting-MAX_EXECUTION_TIME', WT_Site::getPreference('MAX_EXECUTION_TIME'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Allow users to select their own theme'), help_link('ALLOW_USER_THEMES'); ?></dt> - <dd><?php echo edit_field_yes_no_inline('site_setting-ALLOW_USER_THEMES', WT_Site::preference('ALLOW_USER_THEMES'), $controller); ?></dd> + <dd><?php echo edit_field_yes_no_inline('site_setting-ALLOW_USER_THEMES', WT_Site::getPreference('ALLOW_USER_THEMES'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Default theme'), help_link('THEME'); ?></dt> - <dd><?php echo select_edit_control_inline('site_setting-THEME_DIR', array_flip(get_theme_names()), null, WT_Site::preference('THEME_DIR'), $controller); ?></dd> + <dd><?php echo select_edit_control_inline('site_setting-THEME_DIR', array_flip(get_theme_names()), null, WT_Site::getPreference('THEME_DIR'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Show list of family trees'), help_link('ALLOW_CHANGE_GEDCOM'); ?></dt> - <dd><?php echo edit_field_yes_no_inline('site_setting-ALLOW_CHANGE_GEDCOM', WT_Site::preference('ALLOW_CHANGE_GEDCOM'), $controller); ?></dd> + <dd><?php echo edit_field_yes_no_inline('site_setting-ALLOW_CHANGE_GEDCOM', WT_Site::getPreference('ALLOW_CHANGE_GEDCOM'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Session timeout'), help_link('SESSION_TIME'); ?></dt> - <dd><?php echo edit_field_inline('site_setting-SESSION_TIME', WT_Site::preference('SESSION_TIME'), $controller); ?></dd> + <dd><?php echo edit_field_inline('site_setting-SESSION_TIME', WT_Site::getPreference('SESSION_TIME'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Website URL'), help_link('SERVER_URL'); ?></dt> - <dd><?php echo select_edit_control_inline('site_setting-SERVER_URL', array(WT_SERVER_NAME.WT_SCRIPT_PATH=>WT_SERVER_NAME.WT_SCRIPT_PATH), '', WT_Site::preference('SERVER_URL'), $controller); ?></dd> + <dd><?php echo select_edit_control_inline('site_setting-SERVER_URL', array(WT_SERVER_NAME.WT_SCRIPT_PATH=>WT_SERVER_NAME.WT_SCRIPT_PATH), '', WT_Site::getPreference('SERVER_URL'), $controller); ?></dd> </dl> </td> </tr> @@ -103,9 +103,9 @@ $WELCOME_TEXT_AUTH_MODE_OPTIONS = array( <td> <dl> <dt><?php echo WT_I18N::translate('Messages'), help_link('SMTP_ACTIVE'); ?></dt> - <dd><?php echo select_edit_control_inline('site_setting-SMTP_ACTIVE', $SMTP_ACTIVE_OPTIONS, null, WT_Site::preference('SMTP_ACTIVE'), $controller); ?></dd> + <dd><?php echo select_edit_control_inline('site_setting-SMTP_ACTIVE', $SMTP_ACTIVE_OPTIONS, null, WT_Site::getPreference('SMTP_ACTIVE'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Sender name'), help_link('SMTP_FROM_NAME'); ?></dt> - <dd><?php echo edit_field_inline('site_setting-SMTP_FROM_NAME', WT_Site::preference('SMTP_FROM_NAME'), $controller); ?></dd> + <dd><?php echo edit_field_inline('site_setting-SMTP_FROM_NAME', WT_Site::getPreference('SMTP_FROM_NAME'), $controller); ?></dd> </dl> </td> </tr> @@ -118,25 +118,25 @@ $WELCOME_TEXT_AUTH_MODE_OPTIONS = array( <td> <dl> <dt><?php echo WT_I18N::translate('Server name'), help_link('SMTP_HOST'); ?></dt> - <dd><?php echo edit_field_inline('site_setting-SMTP_HOST', WT_Site::preference('SMTP_HOST'), $controller); ?></dd> + <dd><?php echo edit_field_inline('site_setting-SMTP_HOST', WT_Site::getPreference('SMTP_HOST'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Port number'), help_link('SMTP_PORT'); ?></dt> - <dd><?php echo edit_field_inline('site_setting-SMTP_PORT', WT_Site::preference('SMTP_PORT'), $controller); ?></dd> + <dd><?php echo edit_field_inline('site_setting-SMTP_PORT', WT_Site::getPreference('SMTP_PORT'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Use password'), help_link('SMTP_AUTH'); ?></dt> - <dd><?php echo edit_field_yes_no_inline('site_setting-SMTP_AUTH', WT_Site::preference('SMTP_AUTH'), $controller); ?></dd> + <dd><?php echo edit_field_yes_no_inline('site_setting-SMTP_AUTH', WT_Site::getPreference('SMTP_AUTH'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Username'), help_link('SMTP_AUTH_USER'); ?></dt> - <dd><?php echo edit_field_inline('site_setting-SMTP_AUTH_USER', WT_Site::preference('SMTP_AUTH_USER'), $controller); ?></dd> + <dd><?php echo edit_field_inline('site_setting-SMTP_AUTH_USER', WT_Site::getPreference('SMTP_AUTH_USER'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Password'), help_link('SMTP_AUTH_PASS'); ?></dt> <dd><?php echo edit_field_inline('site_setting-SMTP_AUTH_PASS', '' /* Don't show password. save.php has special code for this. */, $controller); ?></dd> <dt><?php echo WT_I18N::translate('Secure connection'), help_link('SMTP_SSL'); ?></dt> - <dd><?php echo select_edit_control_inline('site_setting-SMTP_SSL', $SMTP_SSL_OPTIONS, null, WT_Site::preference('SMTP_SSL'), $controller); ?></dd> + <dd><?php echo select_edit_control_inline('site_setting-SMTP_SSL', $SMTP_SSL_OPTIONS, null, WT_Site::getPreference('SMTP_SSL'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Sending server name'), help_link('SMTP_HELO'); ?></dt> - <dd><?php echo edit_field_inline('site_setting-SMTP_HELO', WT_Site::preference('SMTP_HELO'), $controller); ?></dd> + <dd><?php echo edit_field_inline('site_setting-SMTP_HELO', WT_Site::getPreference('SMTP_HELO'), $controller); ?></dd> </dl> </td> </tr> @@ -151,22 +151,22 @@ $WELCOME_TEXT_AUTH_MODE_OPTIONS = array( <td> <dl> <dt><?php echo WT_I18N::translate('Login URL'), help_link('LOGIN_URL'); ?></dt> - <dd><?php echo edit_field_inline('site_setting-LOGIN_URL', WT_Site::preference('LOGIN_URL'), $controller); ?></dd> + <dd><?php echo edit_field_inline('site_setting-LOGIN_URL', WT_Site::getPreference('LOGIN_URL'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Welcome text on login page'), help_link('WELCOME_TEXT_AUTH_MODE'); ?></dt> - <dd><?php echo select_edit_control_inline('site_setting-WELCOME_TEXT_AUTH_MODE', $WELCOME_TEXT_AUTH_MODE_OPTIONS, null, WT_Site::preference('WELCOME_TEXT_AUTH_MODE'), $controller); ?></dd> + <dd><?php echo select_edit_control_inline('site_setting-WELCOME_TEXT_AUTH_MODE', $WELCOME_TEXT_AUTH_MODE_OPTIONS, null, WT_Site::getPreference('WELCOME_TEXT_AUTH_MODE'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Custom welcome text'), ' — ', WT_LOCALE, help_link('WELCOME_TEXT_AUTH_MODE_CUST'); ?></dt> - <dd><?php echo edit_text_inline('site_setting-WELCOME_TEXT_AUTH_MODE_4', WT_Site::preference('WELCOME_TEXT_AUTH_MODE_'.WT_LOCALE), $controller); ?></dd> + <dd><?php echo edit_text_inline('site_setting-WELCOME_TEXT_AUTH_MODE_4', WT_Site::getPreference('WELCOME_TEXT_AUTH_MODE_'.WT_LOCALE), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Allow visitors to request account registration'), help_link('USE_REGISTRATION_MODULE'); ?></dt> - <dd><?php echo edit_field_yes_no_inline('site_setting-USE_REGISTRATION_MODULE', WT_Site::preference('USE_REGISTRATION_MODULE'), $controller); ?></dd> + <dd><?php echo edit_field_yes_no_inline('site_setting-USE_REGISTRATION_MODULE', WT_Site::getPreference('USE_REGISTRATION_MODULE'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Require an administrator to approve new user registrations'), help_link('REQUIRE_ADMIN_AUTH_REGISTRATION'); ?></dt> - <dd><?php echo edit_field_yes_no_inline('site_setting-REQUIRE_ADMIN_AUTH_REGISTRATION', WT_Site::preference('REQUIRE_ADMIN_AUTH_REGISTRATION'), $controller); ?></dd> + <dd><?php echo edit_field_yes_no_inline('site_setting-REQUIRE_ADMIN_AUTH_REGISTRATION', WT_Site::getPreference('REQUIRE_ADMIN_AUTH_REGISTRATION'), $controller); ?></dd> <dt><?php echo WT_I18N::translate('Show acceptable use agreement on “Request new user account” page'), help_link('SHOW_REGISTER_CAUTION'); ?></dt> - <dd><?php echo edit_field_yes_no_inline('site_setting-SHOW_REGISTER_CAUTION', WT_Site::preference('SHOW_REGISTER_CAUTION'), $controller); ?></dd> + <dd><?php echo edit_field_yes_no_inline('site_setting-SHOW_REGISTER_CAUTION', WT_Site::getPreference('SHOW_REGISTER_CAUTION'), $controller); ?></dd> </dl> </td> </tr> diff --git a/admin_trees_download.php b/admin_trees_download.php index fe2dd335a9..264e47d209 100644 --- a/admin_trees_download.php +++ b/admin_trees_download.php @@ -50,9 +50,9 @@ $fileName = WT_GEDCOM; if ($action == "download" && $zip == "yes") { require WT_ROOT.'library/pclzip.lib.php'; - $temppath = WT_Site::preference('INDEX_DIRECTORY') . "tmp/"; + $temppath = WT_Site::getPreference('INDEX_DIRECTORY') . "tmp/"; $zipname = "dl" . date("YmdHis") . $fileName . ".zip"; - $zipfile = WT_Site::preference('INDEX_DIRECTORY') . $zipname; + $zipfile = WT_Site::getPreference('INDEX_DIRECTORY') . $zipname; $gedname = $temppath . $fileName; $removeTempDir = false; diff --git a/admin_trees_manage.php b/admin_trees_manage.php index 682962a46e..53e116f44c 100644 --- a/admin_trees_manage.php +++ b/admin_trees_manage.php @@ -84,7 +84,7 @@ case 'delete': break; case 'setdefault': if (WT_Filter::checkCsrf()) { - WT_Site::preference('DEFAULT_GEDCOM', WT_Filter::post('default_ged')); + WT_Site::setPreference('DEFAULT_GEDCOM', WT_Filter::post('default_ged')); } break; case 'new_tree': @@ -252,7 +252,7 @@ if (Auth::isAdmin()) { '<td><form name="defaultform" method="post" action="', WT_SCRIPT_NAME, '">', '<input type="hidden" name="action" value="setdefault">', WT_Filter::getCsrf(), - select_edit_control('default_ged', WT_Tree::getNameList(), '', WT_Site::preference('DEFAULT_GEDCOM'), 'onchange="document.defaultform.submit();"'), + select_edit_control('default_ged', WT_Tree::getNameList(), '', WT_Site::getPreference('DEFAULT_GEDCOM'), 'onchange="document.defaultform.submit();"'), '</form></td>'; } echo diff --git a/admin_users.php b/admin_users.php index 357a56cff8..2339914456 100644 --- a/admin_users.php +++ b/admin_users.php @@ -407,7 +407,7 @@ case 'createform': <tr> <td>', WT_I18N::translate('Language'), '</td> <td>', edit_field_language('user_language', $user_language), '</td>'; - if (WT_Site::preference('ALLOW_USER_THEMES')) { + if (WT_Site::getPreference('ALLOW_USER_THEMES')) { echo '<td>', WT_I18N::translate('Theme'), help_link('THEME'), '</td> <td> <select name="new_user_theme"> diff --git a/includes/authentication.php b/includes/authentication.php index 421c10dd85..1469d2155c 100644 --- a/includes/authentication.php +++ b/includes/authentication.php @@ -103,7 +103,7 @@ function addMessage($message) { $sender_email, $sender_real_name, // Reply-To: - WT_Site::preference('SMTP_FROM_NAME'), + WT_Site::getPreference('SMTP_FROM_NAME'), $WT_TREE->preference('title'), // Message WT_I18N::translate('webtrees message') . ' - ' . $message['subject'], diff --git a/includes/db_schema/db_schema_10_11.php b/includes/db_schema/db_schema_10_11.php index 17bc8888e6..0aeae07a5d 100644 --- a/includes/db_schema/db_schema_10_11.php +++ b/includes/db_schema/db_schema_10_11.php @@ -40,5 +40,5 @@ self::exec("DELETE FROM `##gedcom_setting` WHERE setting_name IN ('SEARCH_FACTS_ self::exec("ALTER TABLE `##user` CHANGE password password VARCHAR(128) COLLATE utf8_unicode_ci NOT NULL"); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_11_12.php b/includes/db_schema/db_schema_11_12.php index 9473dbf0b4..cba3ae70b0 100644 --- a/includes/db_schema/db_schema_11_12.php +++ b/includes/db_schema/db_schema_11_12.php @@ -46,5 +46,5 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_12_13.php b/includes/db_schema/db_schema_12_13.php index 64dd1ee7c9..f98544dda7 100644 --- a/includes/db_schema/db_schema_12_13.php +++ b/includes/db_schema/db_schema_12_13.php @@ -43,5 +43,5 @@ self::exec("DELETE FROM `##gedcom_setting` WHERE setting_name IN ('SHOW_MEDIA_FI self::exec("DELETE FROM `##default_resn` WHERE tag_type IN ('_PRIM')"); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_13_14.php b/includes/db_schema/db_schema_13_14.php index 27332a94d1..b762493bf5 100644 --- a/includes/db_schema/db_schema_13_14.php +++ b/includes/db_schema/db_schema_13_14.php @@ -39,5 +39,5 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_14_15.php b/includes/db_schema/db_schema_14_15.php index c174c1a968..9208b8887f 100644 --- a/includes/db_schema/db_schema_14_15.php +++ b/includes/db_schema/db_schema_14_15.php @@ -40,5 +40,5 @@ self::exec("DELETE FROM `##user_setting` WHERE setting_name='default'"); self::exec("UPDATE `##gedcom_setting` SET setting_value='SOUR,RESN' WHERE setting_name='NOTE_FACTS_ADD' AND setting_value='SOUR'"); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_15_16.php b/includes/db_schema/db_schema_15_16.php index 701995902e..59e0190c06 100644 --- a/includes/db_schema/db_schema_15_16.php +++ b/includes/db_schema/db_schema_15_16.php @@ -48,5 +48,5 @@ self::exec("DELETE FROM `##site_setting` WHERE setting_name='SERVER_URL' AND set self::exec("ALTER TABLE `##session` CHANGE session_id session_id CHAR(128) COLLATE utf8_unicode_ci NOT NULL"); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_16_17.php b/includes/db_schema/db_schema_16_17.php index fad0cc9dcb..12ee115730 100644 --- a/includes/db_schema/db_schema_16_17.php +++ b/includes/db_schema/db_schema_16_17.php @@ -48,5 +48,5 @@ self::exec("INSERT IGNORE INTO `##block` (gedcom_id, location, block_order, modu self::exec("ALTER TABLE `##module_setting` CHANGE setting_value setting_value MEDIUMTEXT COLLATE utf8_unicode_ci NOT NULL"); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_17_18.php b/includes/db_schema/db_schema_17_18.php index e89850ce1b..f44c342226 100644 --- a/includes/db_schema/db_schema_17_18.php +++ b/includes/db_schema/db_schema_17_18.php @@ -64,5 +64,5 @@ self::exec( //self::exec("DROP TABLE IF EXISTS `##wt_ip_address`"); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_18_19.php b/includes/db_schema/db_schema_18_19.php index 9d0b79caa3..c24e6bc28c 100644 --- a/includes/db_schema/db_schema_18_19.php +++ b/includes/db_schema/db_schema_18_19.php @@ -47,5 +47,5 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_19_20.php b/includes/db_schema/db_schema_19_20.php index 8e43a40733..4d500f9a8c 100644 --- a/includes/db_schema/db_schema_19_20.php +++ b/includes/db_schema/db_schema_19_20.php @@ -35,5 +35,5 @@ self::exec("UPDATE `##default_resn` SET xref =NULL WHERE xref =''"); self::exec("UPDATE `##default_resn` SET tag_type=NULL WHERE tag_type=''"); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_1_2.php b/includes/db_schema/db_schema_1_2.php index 4ff36b297d..57a720c312 100644 --- a/includes/db_schema/db_schema_1_2.php +++ b/includes/db_schema/db_schema_1_2.php @@ -46,4 +46,4 @@ self::exec( ); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_20_21.php b/includes/db_schema/db_schema_20_21.php index 97211cc892..3d7529d6c6 100644 --- a/includes/db_schema/db_schema_20_21.php +++ b/includes/db_schema/db_schema_20_21.php @@ -60,5 +60,5 @@ try { self::exec("UPDATE `##media` SET m_type = SUBSTRING_INDEX(SUBSTRING_INDEX(m_gedcom, '\n3 TYPE ', -1), '\n', 1) WHERE m_gedcom like '%\n3 TYPE %'"); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_21_22.php b/includes/db_schema/db_schema_21_22.php index 0d8935be96..922063080e 100644 --- a/includes/db_schema/db_schema_21_22.php +++ b/includes/db_schema/db_schema_21_22.php @@ -74,4 +74,4 @@ self::exec( ); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_22_23.php b/includes/db_schema/db_schema_22_23.php index 027b396ec9..b3432294d1 100644 --- a/includes/db_schema/db_schema_22_23.php +++ b/includes/db_schema/db_schema_22_23.php @@ -31,7 +31,7 @@ if (!defined('WT_WEBTREES')) { exit; } -$_data_dir = realpath(WT_Site::preference('INDEX_DIRECTORY') ? WT_Site::preference('INDEX_DIRECTORY') : 'data').DIRECTORY_SEPARATOR; +$_data_dir = realpath(WT_Site::getPreference('INDEX_DIRECTORY') ? WT_Site::getPreference('INDEX_DIRECTORY') : 'data').DIRECTORY_SEPARATOR; $_cfgs = self::prepare( "SELECT gs1.gedcom_id AS gedcom_id, gs1.setting_value AS media_directory, gs2.setting_value AS use_media_firewall, gs3.setting_value AS media_firewall_thumbs, gs4.setting_value AS media_firewall_rootdir" . @@ -94,4 +94,4 @@ unset($_data_dir, $_cfgs, $_cfg, $_mf_dir, $_tmp_dir); self::exec("DELETE FROM `##gedcom_setting` WHERE setting_name IN ('USE_MEDIA_FIREWALL', 'MEDIA_FIREWALL_THUMBS', 'MEDIA_FIREWALL_ROOTDIR')"); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_23_24.php b/includes/db_schema/db_schema_23_24.php index 0c7acc97aa..19c45d68c9 100644 --- a/includes/db_schema/db_schema_23_24.php +++ b/includes/db_schema/db_schema_23_24.php @@ -42,4 +42,4 @@ self::exec( ); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_24_25.php b/includes/db_schema/db_schema_24_25.php index fa369303a2..c9ebf7decf 100644 --- a/includes/db_schema/db_schema_24_25.php +++ b/includes/db_schema/db_schema_24_25.php @@ -49,4 +49,4 @@ self::exec( ); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_25_26.php b/includes/db_schema/db_schema_25_26.php index 478a973baa..287f50f889 100644 --- a/includes/db_schema/db_schema_25_26.php +++ b/includes/db_schema/db_schema_25_26.php @@ -43,4 +43,4 @@ self::exec( ); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_26_27.php b/includes/db_schema/db_schema_26_27.php index 9904ee57eb..b525c6127a 100644 --- a/includes/db_schema/db_schema_26_27.php +++ b/includes/db_schema/db_schema_26_27.php @@ -83,4 +83,4 @@ self::exec( // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_27_28.php b/includes/db_schema/db_schema_27_28.php index a875cc5693..dd9a033c84 100644 --- a/includes/db_schema/db_schema_27_28.php +++ b/includes/db_schema/db_schema_27_28.php @@ -59,4 +59,4 @@ WT_DB::exec( //} // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_2_3.php b/includes/db_schema/db_schema_2_3.php index 3cb8bc1e8b..1bb85c41ee 100644 --- a/includes/db_schema/db_schema_2_3.php +++ b/includes/db_schema/db_schema_2_3.php @@ -53,4 +53,4 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_3_4.php b/includes/db_schema/db_schema_3_4.php index 6eb92a0fa5..ab5959f52b 100644 --- a/includes/db_schema/db_schema_3_4.php +++ b/includes/db_schema/db_schema_3_4.php @@ -64,4 +64,4 @@ self::exec( ); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_4_5.php b/includes/db_schema/db_schema_4_5.php index 3623f33903..ffae8d5ea7 100644 --- a/includes/db_schema/db_schema_4_5.php +++ b/includes/db_schema/db_schema_4_5.php @@ -52,4 +52,4 @@ self::exec("DELETE FROM `##gedcom_setting` WHERE setting_name IN ('PAGE_AFTER_LO self::exec("UPDATE `##gedcom_setting` SET setting_value='SOUR' WHERE setting_value='ASSO,SOUR,NOTE,REPO' AND setting_name='NOTE_FACTS_ADD'"); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_5_6.php b/includes/db_schema/db_schema_5_6.php index 86aea09020..959efcbffb 100644 --- a/includes/db_schema/db_schema_5_6.php +++ b/includes/db_schema/db_schema_5_6.php @@ -49,4 +49,4 @@ foreach ($settings as $gedcom_id=>$setting) { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_6_7.php b/includes/db_schema/db_schema_6_7.php index d934c409e6..82dc89bfad 100644 --- a/includes/db_schema/db_schema_6_7.php +++ b/includes/db_schema/db_schema_6_7.php @@ -56,5 +56,5 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_7_8.php b/includes/db_schema/db_schema_7_8.php index a8f5974431..66d38b748a 100644 --- a/includes/db_schema/db_schema_7_8.php +++ b/includes/db_schema/db_schema_7_8.php @@ -42,5 +42,5 @@ self::exec( ); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_8_9.php b/includes/db_schema/db_schema_8_9.php index 4cd61616b8..d9c256ca9b 100644 --- a/includes/db_schema/db_schema_8_9.php +++ b/includes/db_schema/db_schema_8_9.php @@ -40,5 +40,5 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/db_schema/db_schema_9_10.php b/includes/db_schema/db_schema_9_10.php index f1dbc678e9..1bf10b1394 100644 --- a/includes/db_schema/db_schema_9_10.php +++ b/includes/db_schema/db_schema_9_10.php @@ -52,5 +52,5 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/includes/functions/functions.php b/includes/functions/functions.php index 9c3a9b60b3..0990579f1a 100644 --- a/includes/functions/functions.php +++ b/includes/functions/functions.php @@ -27,21 +27,21 @@ // may be different for each. The server logs are used to generate // installation statistics which can be found at http://svn.webtrees.net/statistics.html function fetch_latest_version() { - $last_update_timestamp = WT_Site::preference('LATEST_WT_VERSION_TIMESTAMP'); + $last_update_timestamp = WT_Site::getPreference('LATEST_WT_VERSION_TIMESTAMP'); if ($last_update_timestamp < WT_TIMESTAMP - 24*60*60) { $row = WT_DB::prepare("SHOW VARIABLES LIKE 'version'")->fetchOneRow(); $params = '?w='.WT_VERSION.'&p='.PHP_VERSION.'&m='.$row->value.'&o='.(DIRECTORY_SEPARATOR=='/'?'u':'w'); $latest_version_txt = WT_File::fetchUrl('http://svn.webtrees.net/build/latest-version.txt' . $params); if ($latest_version_txt) { - WT_Site::preference('LATEST_WT_VERSION', $latest_version_txt); - WT_Site::preference('LATEST_WT_VERSION_TIMESTAMP', WT_TIMESTAMP); + WT_Site::setPreference('LATEST_WT_VERSION', $latest_version_txt); + WT_Site::setPreference('LATEST_WT_VERSION_TIMESTAMP', WT_TIMESTAMP); return $latest_version_txt; } else { // Cannot connect to server - use cached version (if we have one) - return WT_Site::preference('LATEST_WT_VERSION'); + return WT_Site::getPreference('LATEST_WT_VERSION'); } } else { - return WT_Site::preference('LATEST_WT_VERSION'); + return WT_Site::getPreference('LATEST_WT_VERSION'); } } diff --git a/includes/session.php b/includes/session.php index 080eebfe80..33d907aae5 100644 --- a/includes/session.php +++ b/includes/session.php @@ -339,10 +339,10 @@ try { // The config.ini.php file must always be in a fixed location. // Other user files can be stored elsewhere... -define('WT_DATA_DIR', realpath(WT_Site::preference('INDEX_DIRECTORY') ? WT_Site::preference('INDEX_DIRECTORY') : 'data').DIRECTORY_SEPARATOR); +define('WT_DATA_DIR', realpath(WT_Site::getPreference('INDEX_DIRECTORY') ? WT_Site::getPreference('INDEX_DIRECTORY') : 'data').DIRECTORY_SEPARATOR); // If we have a preferred URL (e.g. www.example.com instead of www.isp.com/~example), then redirect to it. -$SERVER_URL=WT_Site::preference('SERVER_URL'); +$SERVER_URL=WT_Site::getPreference('SERVER_URL'); if ($SERVER_URL && $SERVER_URL != WT_SERVER_NAME.WT_SCRIPT_PATH) { header('Location: ' . $SERVER_URL . WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''), true, 301); exit; @@ -350,11 +350,11 @@ if ($SERVER_URL && $SERVER_URL != WT_SERVER_NAME.WT_SCRIPT_PATH) { // Request more resources - if we can/want to if (!ini_get('safe_mode')) { - $memory_limit=WT_Site::preference('MEMORY_LIMIT'); + $memory_limit=WT_Site::getPreference('MEMORY_LIMIT'); if ($memory_limit) { ini_set('memory_limit', $memory_limit); } - $max_execution_time=WT_Site::preference('MAX_EXECUTION_TIME'); + $max_execution_time=WT_Site::getPreference('MAX_EXECUTION_TIME'); if ($max_execution_time && strpos(ini_get('disable_functions'), 'set_time_limit')===false) { set_time_limit($max_execution_time); } @@ -435,7 +435,7 @@ define('WT_SESSION_NAME', 'WT_SESSION'); $cfg=array( 'name' => WT_SESSION_NAME, 'cookie_lifetime' => 0, - 'gc_maxlifetime' => WT_Site::preference('SESSION_TIME'), + 'gc_maxlifetime' => WT_Site::getPreference('SESSION_TIME'), 'gc_probability' => 1, 'gc_divisor' => 100, 'cookie_path' => WT_SCRIPT_PATH, @@ -470,7 +470,7 @@ if (isset($_REQUEST['ged'])) { $GEDCOM=$WT_SESSION->GEDCOM; } else { // Try the site default - $GEDCOM=WT_Site::preference('DEFAULT_GEDCOM'); + $GEDCOM=WT_Site::getPreference('DEFAULT_GEDCOM'); } // Choose the selected tree (if it exists), or any valid tree otherwise @@ -549,8 +549,8 @@ define('WT_CLIENT_JD', 2440588 + (int)(WT_CLIENT_TIMESTAMP/86400)); require WT_ROOT . 'includes/config_data.php'; // The login URL must be an absolute URL, and can be user-defined -if (WT_Site::preference('LOGIN_URL')) { - define('WT_LOGIN_URL', WT_Site::preference('LOGIN_URL')); +if (WT_Site::getPreference('LOGIN_URL')) { + define('WT_LOGIN_URL', WT_Site::getPreference('LOGIN_URL')); } else { define('WT_LOGIN_URL', WT_SERVER_NAME.WT_SCRIPT_PATH.'login.php'); } @@ -581,7 +581,7 @@ if (substr(WT_SCRIPT_NAME, 0, 5)=='admin' || WT_SCRIPT_NAME=='module.php' && sub // Administration scripts begin with “admin” and use a special administration theme define('WT_THEME_DIR', WT_THEMES_DIR.'_administration/'); } else { - if (WT_Site::preference('ALLOW_USER_THEMES')) { + if (WT_Site::getPreference('ALLOW_USER_THEMES')) { // Requested change of theme? $THEME_DIR = WT_Filter::get('theme'); if (!in_array($THEME_DIR, get_theme_names())) { @@ -604,7 +604,7 @@ if (substr(WT_SCRIPT_NAME, 0, 5)=='admin' || WT_SCRIPT_NAME=='module.php' && sub $THEME_DIR=get_gedcom_setting(WT_GED_ID, 'THEME_DIR'); } if (!in_array($THEME_DIR, get_theme_names())) { - $THEME_DIR=WT_Site::preference('THEME_DIR'); + $THEME_DIR=WT_Site::getPreference('THEME_DIR'); } if (!in_array($THEME_DIR, get_theme_names())) { $THEME_DIR='webtrees'; diff --git a/library/WT/Controller/Search.php b/library/WT/Controller/Search.php index cdb5e6b5b9..6124dcd5bc 100644 --- a/library/WT/Controller/Search.php +++ b/library/WT/Controller/Search.php @@ -114,7 +114,7 @@ class WT_Controller_Search extends WT_Controller_Page { } // Retrieve the gedcoms to search in - if (count(WT_Tree::getAll())>1 && WT_Site::preference('ALLOW_CHANGE_GEDCOM')) { + if (count(WT_Tree::getAll())>1 && WT_Site::getPreference('ALLOW_CHANGE_GEDCOM')) { foreach (WT_Tree::getAll() as $tree) { $str = str_replace(array (".", "-", " "), array ("_", "_", "_"), $tree->tree_name); if (isset ($_REQUEST["$str"]) || $topsearch) { diff --git a/library/WT/DB.php b/library/WT/DB.php index 70d5b06ba9..e2eec729bc 100644 --- a/library/WT/DB.php +++ b/library/WT/DB.php @@ -212,7 +212,7 @@ class WT_DB { ////////////////////////////////////////////////////////////////////////////// public static function updateSchema($schema_dir, $schema_name, $target_version) { try { - $current_version=(int)WT_Site::preference($schema_name); + $current_version=(int)WT_Site::getPreference($schema_name); } catch (PDOException $e) { // During initial installation, this table won’t exist. // It will only be a problem if we can’t subsequently create it. @@ -227,12 +227,12 @@ class WT_DB { // Due to a bug in webtrees 1.2.5 - 1.2.7, the setup value of "-1" // wasn't being updated. $current_version=12; - WT_Site::preference($schema_name, $current_version); + WT_Site::setPreference($schema_name, $current_version); break; case -2: // Because of the above bug, we now set the version to -2 during setup. $current_version=$target_version; - WT_Site::preference($schema_name, $current_version); + WT_Site::setPreference($schema_name, $current_version); break; } @@ -241,7 +241,7 @@ class WT_DB { $next_version=$current_version+1; require $schema_dir.'db_schema_'.$current_version.'_'.$next_version.'.php'; // The updatescript should update the version or throw an exception - $current_version=(int)WT_Site::preference($schema_name); + $current_version=(int)WT_Site::getPreference($schema_name); if ($current_version!=$next_version) { die("Internal error while updating {$schema_name} to {$next_version}"); } diff --git a/library/WT/Mail.php b/library/WT/Mail.php index c8507c1f1c..69068f3c2f 100644 --- a/library/WT/Mail.php +++ b/library/WT/Mail.php @@ -44,7 +44,7 @@ class WT_Mail { ->setSubject ($subject) ->setBodyHtml($message) ->setBodyText(WT_Filter::unescapeHtml($message)) - ->setFrom (WT_Site::preference('SMTP_FROM_NAME'), $tree->preference('title')) + ->setFrom (WT_Site::getPreference('SMTP_FROM_NAME'), $tree->preference('title')) ->addTo ($to_email, $to_name) ->setReplyTo ($replyto_email, $replyto_name) ->send (WT_Mail::transport()); @@ -69,7 +69,7 @@ class WT_Mail { return self::send( $tree, $user->getEmail(), $user->getRealName(), - WT_Site::preference('SMTP_FROM_NAME'), $tree->preference('title'), + WT_Site::getPreference('SMTP_FROM_NAME'), $tree->preference('title'), $subject, $message ); @@ -78,24 +78,24 @@ class WT_Mail { // Create a transport mechanism for sending mail public static function transport() { - switch (WT_Site::preference('SMTP_ACTIVE')) { + switch (WT_Site::getPreference('SMTP_ACTIVE')) { case 'internal': return new Zend_Mail_Transport_Sendmail(); case 'external': $config = array( - 'name' => WT_Site::preference('SMTP_HELO'), - 'port' => WT_Site::preference('SMTP_PORT'), + 'name' => WT_Site::getPreference('SMTP_HELO'), + 'port' => WT_Site::getPreference('SMTP_PORT'), ); - if (WT_Site::preference('SMTP_AUTH')) { + if (WT_Site::getPreference('SMTP_AUTH')) { $config['auth'] = 'login'; - $config['username'] = WT_Site::preference('SMTP_AUTH_USER'); - $config['password'] = WT_Site::preference('SMTP_AUTH_PASS'); + $config['username'] = WT_Site::getPreference('SMTP_AUTH_USER'); + $config['password'] = WT_Site::getPreference('SMTP_AUTH_PASS'); } - if (WT_Site::preference('SMTP_SSL') !== 'none') { - $config['ssl'] = WT_Site::preference('SMTP_SSL'); + if (WT_Site::getPreference('SMTP_SSL') !== 'none') { + $config['ssl'] = WT_Site::getPreference('SMTP_SSL'); } - return new Zend_Mail_Transport_Smtp(WT_Site::preference('SMTP_HOST'), $config); + return new Zend_Mail_Transport_Smtp(WT_Site::getPreference('SMTP_HOST'), $config); default: // For testing return new Zend_Mail_Transport_File(); diff --git a/library/WT/MenuBar.php b/library/WT/MenuBar.php index 08029686b5..860079e6c4 100644 --- a/library/WT/MenuBar.php +++ b/library/WT/MenuBar.php @@ -26,7 +26,7 @@ use WT\Auth; class WT_MenuBar { public static function getGedcomMenu() { $menu = new WT_Menu(WT_I18N::translate('Home page'), 'index.php?ctype=gedcom&ged='.WT_GEDURL, 'menu-tree'); - $ALLOW_CHANGE_GEDCOM=WT_Site::preference('ALLOW_CHANGE_GEDCOM') && count(WT_Tree::getAll())>1; + $ALLOW_CHANGE_GEDCOM=WT_Site::getPreference('ALLOW_CHANGE_GEDCOM') && count(WT_Tree::getAll())>1; foreach (WT_Tree::getAll() as $tree) { if ($tree->tree_id==WT_GED_ID || $ALLOW_CHANGE_GEDCOM) { $submenu = new WT_Menu( @@ -441,7 +441,7 @@ class WT_MenuBar { public static function getThemeMenu() { global $SEARCH_SPIDER; - if (WT_GED_ID && !$SEARCH_SPIDER && WT_Site::preference('ALLOW_USER_THEMES') && get_gedcom_setting(WT_GED_ID, 'ALLOW_THEME_DROPDOWN')) { + if (WT_GED_ID && !$SEARCH_SPIDER && WT_Site::getPreference('ALLOW_USER_THEMES') && get_gedcom_setting(WT_GED_ID, 'ALLOW_THEME_DROPDOWN')) { $menu=new WT_Menu(WT_I18N::translate('Theme'), '#', 'menu-theme'); foreach (get_theme_names() as $themename=>$themedir) { $submenu=new WT_Menu($themename, get_query_url(array('theme'=>$themedir), '&'), 'menu-theme-'.$themedir); diff --git a/library/WT/Site.php b/library/WT/Site.php index a1731da09a..59dafa3c53 100644 --- a/library/WT/Site.php +++ b/library/WT/Site.php @@ -21,35 +21,55 @@ use WT\Log; class WT_Site { - static $setting=null; + /** + * Everything from the wt_site_setting table. + * + * @var array + */ + static $setting = null; - // Get and Set the site’s configuration settings - public static function preference($setting_name, $setting_value=null) { + /** + * Get the site’s configuration settings + * + * @param string $setting_name + * + * @return string + */ + public static function getPreference($setting_name) { // There are lots of settings, and we need to fetch lots of them on every page // so it is quicker to fetch them all in one go. - if (self::$setting===null) { - self::$setting=WT_DB::prepare( + if (self::$setting === null) { + self::$setting = WT_DB::prepare( "SELECT SQL_CACHE setting_name, setting_value FROM `##site_setting`" )->fetchAssoc(); } - // If $setting_value is null, then GET the setting - if ($setting_value===null) { - // If parameter two is not specified, GET the setting - if (!array_key_exists($setting_name, self::$setting)) { - self::$setting[$setting_name]=null; - } - return self::$setting[$setting_name]; - } else { - // If parameter two is specified, then SET the setting - if (self::preference($setting_name)!=$setting_value) { - // Audit log of changes - Log::addConfigurationLog('Site setting "' . $setting_name . '" set to "' . $setting_value . '"'); - } + // A setting that hasn't yet been set? + if (!array_key_exists($setting_name, self::$setting)) { + self::$setting[$setting_name] = null; + } + + return self::$setting[$setting_name]; + } + + /** + * Set the site’s configuration settings. + * + * @param string $setting_name + * @param string $setting_value + * + * @return void + */ + public static function setPreference($setting_name, $setting_value) { + // Only need to update the database if the setting has actually changed. + if (self::getPreference($setting_name) != $setting_value) { WT_DB::prepare( "REPLACE INTO `##site_setting` (setting_name, setting_value) VALUES (?, LEFT(?, 255))" )->execute(array($setting_name, $setting_value)); - self::$setting[$setting_name]=$setting_value; + + self::$setting[$setting_name] = $setting_value; + + Log::addConfigurationLog('Site setting "' . $setting_name . '" set to "' . $setting_value . '"'); } } } diff --git a/library/WT/Tree.php b/library/WT/Tree.php index 2c2b253beb..937f204b83 100644 --- a/library/WT/Tree.php +++ b/library/WT/Tree.php @@ -345,8 +345,8 @@ class WT_Tree { // Delete everything relating to a tree public static function delete($tree_id) { // If this is the default tree, then unset - if (WT_Site::preference('DEFAULT_GEDCOM')==self::getNameFromId($tree_id)) { - WT_Site::preference('DEFAULT_GEDCOM', ''); + if (WT_Site::getPreference('DEFAULT_GEDCOM')==self::getNameFromId($tree_id)) { + WT_Site::setPreference('DEFAULT_GEDCOM', ''); } // Don't delete the logs. WT_DB::prepare("UPDATE `##log` SET gedcom_id=NULL WHERE gedcom_id =?")->execute(array($tree_id)); @@ -37,7 +37,7 @@ if (WT_USER_ID && WT_GED_ID) { $controller = new WT_Controller_Page(); -$REQUIRE_ADMIN_AUTH_REGISTRATION = WT_Site::preference('REQUIRE_ADMIN_AUTH_REGISTRATION'); +$REQUIRE_ADMIN_AUTH_REGISTRATION = WT_Site::getPreference('REQUIRE_ADMIN_AUTH_REGISTRATION'); $action = WT_Filter::post('action'); $user_realname = WT_Filter::post('user_realname'); @@ -146,7 +146,7 @@ default: echo '<div id="login-page">'; echo '<div id="login-text">'; - switch (WT_Site::preference('WELCOME_TEXT_AUTH_MODE')) { + switch (WT_Site::getPreference('WELCOME_TEXT_AUTH_MODE')) { case 1: echo WT_I18N::translate('<center><b>Welcome to this genealogy website</b></center><br>Access to this site is permitted to every visitor who has a user account.<br><br>If you have a user account, you can login on this page. If you don’t have a user account, you can apply for one by clicking on the appropriate link below.<br><br>After verifying your application, the site administrator will activate your account. You will receive an email when your application has been approved.'); break; @@ -157,7 +157,7 @@ default: echo WT_I18N::translate('<center><b>Welcome to this genealogy website</b></center><br>Access to this site is permitted to <u>family members only</u>.<br><br>If you have a user account you can login on this page. If you don’t have a user account, you can apply for one by clicking on the appropriate link below.<br><br>After verifying the information you provide, the administrator will either approve or decline your request for an account. You will receive an email when your request is approved.'); break; case 4: - echo '<p>', WT_Site::preference('WELCOME_TEXT_AUTH_MODE_'.WT_LOCALE), '</p>'; + echo '<p>', WT_Site::getPreference('WELCOME_TEXT_AUTH_MODE_'.WT_LOCALE), '</p>'; break; } @@ -191,7 +191,7 @@ default: <div> <a href="#" id="passwd_click">', WT_I18N::translate('Request new password'), '</a> </div>'; - if (WT_Site::preference('USE_REGISTRATION_MODULE')) { + if (WT_Site::getPreference('USE_REGISTRATION_MODULE')) { echo '<div><a href="'.WT_LOGIN_URL.'?action=register">', WT_I18N::translate('Request new user account'), '</a></div>'; } } @@ -259,7 +259,7 @@ case 'requestpw': break; case 'register': - if (!WT_Site::preference('USE_REGISTRATION_MODULE')) { + if (!WT_Site::getPreference('USE_REGISTRATION_MODULE')) { header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH); exit; } @@ -398,7 +398,7 @@ case 'register': echo '<div id="login-register-page"> <h2>', $controller->getPageTitle(), '</h2>'; - if (WT_Site::preference('SHOW_REGISTER_CAUTION')) { + if (WT_Site::getPreference('SHOW_REGISTER_CAUTION')) { echo '<div id="register-text">'; echo WT_I18N::translate('<div class="largeError">Notice:</div><div class="error">By completing and submitting this form, you agree:<ul><li>to protect the privacy of living individuals listed on our site;</li><li>and in the text box below, to explain to whom you are related, or to provide us with information on someone who should be listed on our site.</li></ul></div>'); echo '</div>'; @@ -449,7 +449,7 @@ case 'register': break; case 'userverify': - if (!WT_Site::preference('USE_REGISTRATION_MODULE')) { + if (!WT_Site::getPreference('USE_REGISTRATION_MODULE')) { header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH); exit; } @@ -486,7 +486,7 @@ case 'userverify': break; case 'verify_hash': - if (!WT_Site::preference('USE_REGISTRATION_MODULE')) { + if (!WT_Site::getPreference('USE_REGISTRATION_MODULE')) { header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH); exit; } diff --git a/modules_v3/gedcom_block/module.php b/modules_v3/gedcom_block/module.php index af9999b1af..837324c151 100644 --- a/modules_v3/gedcom_block/module.php +++ b/modules_v3/gedcom_block/module.php @@ -43,7 +43,7 @@ class gedcom_block_WT_Module extends WT_Module implements WT_Module_Block { $content = '<table><tr>'; $content .= '<td><a href="pedigree.php?rootid='.$indi_xref.'&ged='.WT_GEDURL.'"><i class="icon-pedigree"></i><br>'.WT_I18N::translate('Default chart').'</a></td>'; $content .= '<td><a href="individual.php?pid='.$indi_xref.'&ged='.WT_GEDURL.'"><i class="icon-indis"></i><br>'.WT_I18N::translate('Default individual').'</a></td>'; - if (WT_Site::preference('USE_REGISTRATION_MODULE') && WT_USER_ID==false) { + if (WT_Site::getPreference('USE_REGISTRATION_MODULE') && WT_USER_ID==false) { $content .= '<td><a href="'.WT_LOGIN_URL.'?action=register"><i class="icon-user_add"></i><br>'.WT_I18N::translate('Request new user account').'</a></td>'; } $content .= "</tr>"; diff --git a/modules_v3/gedcom_favorites/db_schema/db_schema_0_1.php b/modules_v3/gedcom_favorites/db_schema/db_schema_0_1.php index ac240cc206..95c2f8c8ae 100644 --- a/modules_v3/gedcom_favorites/db_schema/db_schema_0_1.php +++ b/modules_v3/gedcom_favorites/db_schema/db_schema_0_1.php @@ -52,4 +52,4 @@ WT_DB::exec( ); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/modules_v3/gedcom_favorites/db_schema/db_schema_1_2.php b/modules_v3/gedcom_favorites/db_schema/db_schema_1_2.php index 6fb8df551f..9a2c111c1e 100644 --- a/modules_v3/gedcom_favorites/db_schema/db_schema_1_2.php +++ b/modules_v3/gedcom_favorites/db_schema/db_schema_1_2.php @@ -89,4 +89,4 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/modules_v3/gedcom_favorites/db_schema/db_schema_2_3.php b/modules_v3/gedcom_favorites/db_schema/db_schema_2_3.php index 9d3e03587f..eaa1a743a0 100644 --- a/modules_v3/gedcom_favorites/db_schema/db_schema_2_3.php +++ b/modules_v3/gedcom_favorites/db_schema/db_schema_2_3.php @@ -50,4 +50,4 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/modules_v3/gedcom_favorites/db_schema/db_schema_3_4.php b/modules_v3/gedcom_favorites/db_schema/db_schema_3_4.php index c6b0051c88..881bade6ff 100644 --- a/modules_v3/gedcom_favorites/db_schema/db_schema_3_4.php +++ b/modules_v3/gedcom_favorites/db_schema/db_schema_3_4.php @@ -39,4 +39,4 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/modules_v3/gedcom_news/db_schema/db_schema_0_1.php b/modules_v3/gedcom_news/db_schema/db_schema_0_1.php index c4a5fcada9..74498479af 100644 --- a/modules_v3/gedcom_news/db_schema/db_schema_0_1.php +++ b/modules_v3/gedcom_news/db_schema/db_schema_0_1.php @@ -46,4 +46,4 @@ WT_DB::exec( ); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/modules_v3/gedcom_news/db_schema/db_schema_1_2.php b/modules_v3/gedcom_news/db_schema/db_schema_1_2.php index 8a3c534108..f7347ccd3a 100644 --- a/modules_v3/gedcom_news/db_schema/db_schema_1_2.php +++ b/modules_v3/gedcom_news/db_schema/db_schema_1_2.php @@ -79,4 +79,4 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/modules_v3/gedcom_news/db_schema/db_schema_2_3.php b/modules_v3/gedcom_news/db_schema/db_schema_2_3.php index 5ff3810af6..5b391c859a 100644 --- a/modules_v3/gedcom_news/db_schema/db_schema_2_3.php +++ b/modules_v3/gedcom_news/db_schema/db_schema_2_3.php @@ -50,4 +50,4 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/modules_v3/googlemap/db_schema/db_schema_0_1.php b/modules_v3/googlemap/db_schema/db_schema_0_1.php index 3f003ddcdd..0cc19a33f5 100644 --- a/modules_v3/googlemap/db_schema/db_schema_0_1.php +++ b/modules_v3/googlemap/db_schema/db_schema_0_1.php @@ -54,4 +54,4 @@ WT_DB::exec( ); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/modules_v3/googlemap/db_schema/db_schema_1_2.php b/modules_v3/googlemap/db_schema/db_schema_1_2.php index 35bf11a21f..1f3755e70d 100644 --- a/modules_v3/googlemap/db_schema/db_schema_1_2.php +++ b/modules_v3/googlemap/db_schema/db_schema_1_2.php @@ -51,4 +51,4 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/modules_v3/googlemap/db_schema/db_schema_2_3.php b/modules_v3/googlemap/db_schema/db_schema_2_3.php index e99278f46c..c2fc45fc82 100644 --- a/modules_v3/googlemap/db_schema/db_schema_2_3.php +++ b/modules_v3/googlemap/db_schema/db_schema_2_3.php @@ -35,4 +35,4 @@ if (!defined('WT_WEBTREES')) { WT_DB::exec("UPDATE `##placelocation` SET pl_icon=REPLACE(pl_icon, '.gif', '.png')"); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/modules_v3/googlemap/db_schema/db_schema_3_4.php b/modules_v3/googlemap/db_schema/db_schema_3_4.php index 86b2a77bf8..e705b60d42 100644 --- a/modules_v3/googlemap/db_schema/db_schema_3_4.php +++ b/modules_v3/googlemap/db_schema/db_schema_3_4.php @@ -40,4 +40,4 @@ self::exec( ); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/modules_v3/googlemap/db_schema/db_schema_4_5.php b/modules_v3/googlemap/db_schema/db_schema_4_5.php index 06b95617d0..0e43dd605c 100644 --- a/modules_v3/googlemap/db_schema/db_schema_4_5.php +++ b/modules_v3/googlemap/db_schema/db_schema_4_5.php @@ -38,4 +38,4 @@ self::exec( ); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/modules_v3/html/module.php b/modules_v3/html/module.php index f00779ddf5..a6756bd3d8 100644 --- a/modules_v3/html/module.php +++ b/modules_v3/html/module.php @@ -52,7 +52,7 @@ class html_WT_Module extends WT_Module implements WT_Module_Block { case '': break; case '__default__': - $GEDCOM=WT_Site::preference('DEFAULT_GEDCOM'); + $GEDCOM=WT_Site::getPreference('DEFAULT_GEDCOM'); if (!$GEDCOM) { foreach (WT_Tree::getAll() as $tree) { $GEDCOM=$tree->tree_name; diff --git a/modules_v3/login_block/module.php b/modules_v3/login_block/module.php index 946fcfb361..3facf47358 100644 --- a/modules_v3/login_block/module.php +++ b/modules_v3/login_block/module.php @@ -76,7 +76,7 @@ class login_block_WT_Module extends WT_Module implements WT_Module_Block { <div> <a href="#" id="passwd_click">'. WT_I18N::translate('Request new password').'</a> </div>'; - if (WT_Site::preference('USE_REGISTRATION_MODULE')) { + if (WT_Site::getPreference('USE_REGISTRATION_MODULE')) { $content.= '<div><a href="'.WT_LOGIN_URL.'?action=register">'. WT_I18N::translate('Request new user account').'</a></div>'; } $content.= '</form>'; // close "login-form" diff --git a/modules_v3/personal_facts/module.php b/modules_v3/personal_facts/module.php index bfbba5baaf..006d1619ae 100644 --- a/modules_v3/personal_facts/module.php +++ b/modules_v3/personal_facts/module.php @@ -122,7 +122,7 @@ class personal_facts_WT_Module extends WT_Module implements WT_Module_Tab { echo ' checked="checked"'; } echo ' onclick="jQuery(\'tr.rela\').toggle();"><label for="checkbox_rela_facts">', WT_I18N::translate('Events of close relatives'), '</label>'; - if (file_exists(WT_Site::preference('INDEX_DIRECTORY').'histo.'.WT_LOCALE.'.php')) { + if (file_exists(WT_Site::getPreference('INDEX_DIRECTORY').'histo.'.WT_LOCALE.'.php')) { echo ' <input id="checkbox_histo" type="checkbox"'; if ($EXPAND_HISTO_EVENTS) { echo ' checked="checked"'; @@ -420,8 +420,8 @@ class personal_facts_WT_Module extends WT_Module implements WT_Module_Tab { $birt_date = $person->getEstimatedBirthDate(); $deat_date = $person->getEstimatedDeathDate(); - if (file_exists(WT_Site::preference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php')) { - require WT_Site::preference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php'; + if (file_exists(WT_Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php')) { + require WT_Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php'; foreach ($histo as $hist) { // Earlier versions of the WIKI encouraged people to use HTML entities, // rather than UTF8 encoding. diff --git a/modules_v3/review_changes/module.php b/modules_v3/review_changes/module.php index 6d3b49351a..c53bb6e97e 100644 --- a/modules_v3/review_changes/module.php +++ b/modules_v3/review_changes/module.php @@ -58,7 +58,7 @@ class review_changes_WT_Module extends WT_Module implements WT_Module_Block { if ($changes && $sendmail=='yes') { // There are pending changes - tell moderators/managers/administrators about them. - if (WT_TIMESTAMP - WT_Site::preference('LAST_CHANGE_EMAIL') > (60*60*24*$days)) { + if (WT_TIMESTAMP - WT_Site::getPreference('LAST_CHANGE_EMAIL') > (60*60*24*$days)) { // Which users have pending changes? foreach (User::all() as $user) { if ($user->getSetting('contactmethod') !== 'none') { @@ -78,7 +78,7 @@ class review_changes_WT_Module extends WT_Module implements WT_Module_Block { } } } - WT_Site::preference('LAST_CHANGE_EMAIL', WT_TIMESTAMP); + WT_Site::setPreference('LAST_CHANGE_EMAIL', WT_TIMESTAMP); } if (WT_USER_CAN_EDIT) { $id=$this->getName().$block_id; @@ -95,8 +95,8 @@ class review_changes_WT_Module extends WT_Module implements WT_Module_Block { $content .= "<a href=\"#\" onclick=\"window.open('edit_changes.php','_blank', chan_window_specs); return false;\">".WT_I18N::translate('There are pending changes for you to moderate.')."</a><br>"; } if ($sendmail=="yes") { - $content .= WT_I18N::translate('Last email reminder was sent ').format_timestamp(WT_Site::preference('LAST_CHANGE_EMAIL'))."<br>"; - $content .= WT_I18N::translate('Next email reminder will be sent after ').format_timestamp(WT_Site::preference('LAST_CHANGE_EMAIL')+(60*60*24*$days))."<br><br>"; + $content .= WT_I18N::translate('Last email reminder was sent ').format_timestamp(WT_Site::getPreference('LAST_CHANGE_EMAIL'))."<br>"; + $content .= WT_I18N::translate('Next email reminder will be sent after ').format_timestamp(WT_Site::getPreference('LAST_CHANGE_EMAIL')+(60*60*24*$days))."<br><br>"; } $changes=WT_DB::prepare( "SELECT xref". diff --git a/modules_v3/user_blog/db_schema/db_schema_0_1.php b/modules_v3/user_blog/db_schema/db_schema_0_1.php index 5b698432d9..4fc62ba496 100644 --- a/modules_v3/user_blog/db_schema/db_schema_0_1.php +++ b/modules_v3/user_blog/db_schema/db_schema_0_1.php @@ -46,4 +46,4 @@ WT_DB::exec( ); // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/modules_v3/user_blog/db_schema/db_schema_1_2.php b/modules_v3/user_blog/db_schema/db_schema_1_2.php index c8e3390998..bba5f481db 100644 --- a/modules_v3/user_blog/db_schema/db_schema_1_2.php +++ b/modules_v3/user_blog/db_schema/db_schema_1_2.php @@ -79,5 +79,5 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); diff --git a/modules_v3/user_blog/db_schema/db_schema_2_3.php b/modules_v3/user_blog/db_schema/db_schema_2_3.php index 5ff3810af6..5b391c859a 100644 --- a/modules_v3/user_blog/db_schema/db_schema_2_3.php +++ b/modules_v3/user_blog/db_schema/db_schema_2_3.php @@ -50,4 +50,4 @@ try { } // Update the version to indicate success -WT_Site::preference($schema_name, $next_version); +WT_Site::setPreference($schema_name, $next_version); @@ -129,7 +129,7 @@ case 'site_setting': // The password will be displayed as "click to edit" on screen. // Accept the update, but pretend to fail. This will leave the "click to edit" on screen if ($value) { - WT_Site::preference($id1, $value); + WT_Site::setPreference($id1, $value); } fail(); default: @@ -138,7 +138,7 @@ case 'site_setting': } // Authorised and valid - make update - WT_Site::preference($id1, $value); + WT_Site::setPreference($id1, $value); ok(); case 'site_access_rule': diff --git a/search.php b/search.php index d544eba2d4..cc97df4e47 100644 --- a/search.php +++ b/search.php @@ -183,7 +183,7 @@ echo '<div id="search-page"> // If the search is a general or soundex search then possibly display checkboxes for the gedcoms if ($controller->action == "general" || $controller->action == "soundex") { // If more than one GEDCOM, switching is allowed AND DB mode is set, let the user select - if ((count(WT_Tree::getAll()) > 1) && WT_Site::preference('ALLOW_CHANGE_GEDCOM')) { + if ((count(WT_Tree::getAll()) > 1) && WT_Site::getPreference('ALLOW_CHANGE_GEDCOM')) { // More Than 3 Gedcom Filess enable elect all & select none buttons if (count(WT_Tree::getAll())>3) { echo '<div class="label"> </div> diff --git a/themes/colors/theme.php b/themes/colors/theme.php index 326d34305e..0990a7ab69 100644 --- a/themes/colors/theme.php +++ b/themes/colors/theme.php @@ -56,7 +56,7 @@ function color_theme_dropdown() { if ($WT_SESSION->subColor == $colorChoice) { $submenu->addClass('','','theme-active'); } - } elseif (WT_Site::preference('DEFAULT_COLOR_PALETTE') == $colorChoice) { /* here when visitor changes palette from default */ + } elseif (WT_Site::getPreference('DEFAULT_COLOR_PALETTE') == $colorChoice) { /* here when visitor changes palette from default */ $submenu->addClass('','','theme-active'); } elseif ($subColor=='ash') { /* here when site has different theme as default and user switches to colors */ if ($subColor == $colorChoice) { @@ -100,7 +100,7 @@ if (isset($_GET['themecolor']) && array_key_exists($_GET['themecolor'], $COLOR_T if (Auth::id()) { Auth::user()->setSetting('themecolor', $subColor); if (Auth::isAdmin()) { - WT_Site::preference('DEFAULT_COLOR_PALETTE', $subColor); + WT_Site::setPreference('DEFAULT_COLOR_PALETTE', $subColor); } } unset($_GET['themecolor']); @@ -118,7 +118,7 @@ if (!$subColor) { } // We haven't selected one this session? Use the site default if (!$subColor) { - $subColor = WT_Site::preference('DEFAULT_COLOR_PALETTE'); + $subColor = WT_Site::getPreference('DEFAULT_COLOR_PALETTE'); } // Make sure our selected palette actually exists if (!array_key_exists($subColor, $COLOR_THEME_LIST)) { |
