Source for file settings.ctrl.php
Documentation is available at settings.ctrl.php
* This file implements the UI controller for settings management.
* This file is part of Quam Plures - {@link http://quamplures.net/}
* See also {@link https://launchpad.net/quam-plures}.
* @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
* @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
* Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
* {@internal License choice
* - If you have received this file as part of a package, please find the license.txt file in
* the same folder or the closest folder above for complete license terms.
* - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
* then you must choose one of the following licenses before using the file:
* - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
* - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
* {@internal Open Source relicensing agreement:
* Daniel HAHLER grants Francois PLANQUE the right to license
* Daniel HAHLER's contributions to this file and the b2evolution project
* under any OSI approved OSS license (http://www.opensource.org/licenses/).
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
* @author blueyed: Daniel HAHLER
* @author fplanque: Francois PLANQUE
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
// Check minimum permission:
$current_User->check_perm( 'options', 'view', true );
$AdminUI->set_path( 'options', 'general' );
param( 'action', 'string' );
param( 'edit_locale', 'string' );
param( 'loc_transinfo', 'integer', 0 );
if( in_array( $action, array( 'update', 'reset', 'updatelocale', 'createlocale', 'deletelocale', 'extract', 'prioup', 'priodown' ) ) )
{ // We have an action to do..
$current_User->check_perm( 'options', 'edit', true );
$current_User->check_perm( 'options', 'edit', true );
param( 'submit', 'array', array() );
if( isset ($submit['restore_defaults']) )
// TODO: insert some default settings rather than just delete them all, as per original configuration in the _advanced.php file:
fp>> Isn't this done in $Settings anyway?
$mailserver_url = 'mail.example.com';
$mailserver_login = 'login@example.com';
$mailserver_pass = 'password';
# by default posts will have this category
$subjectprefix = 'blog:';
# body terminator string (starting from this string, everything will be ignored, including this string)
# set this to 1 to run in test mode
### Special Configuration for some phone email services
# some mobile phone email services will send identical subject & content on the same line
# if you use such a service, set $use_phoneemail to 1, and indicate a separator string
# when you compose your message, you'll type your subject then the separator string
# then you type your login:password, then the separator, then content
$phoneemail_separator = ':::';
$Settings->delete_array( array(
'outbound_notifications_mode',
'eblog_default_category',
'newusers_revalidate_emailchg',
if( $Settings->dbupdate() )
$Messages->add( T_('Restored default values.'), 'success' );
$Messages->add( T_('Settings have not changed.'), 'note' );
// After each new post...
param( 'outbound_notifications_mode', 'string', true );
$Settings->set( 'outbound_notifications_mode', get_param('outbound_notifications_mode') );
param( 'eblog_enabled', 'boolean', 0 );
$Settings->set( 'eblog_enabled', $eblog_enabled );
param( 'eblog_method', 'string', true );
param( 'eblog_server_host', 'string', true );
$Settings->set( 'eblog_server_host', strtolower(trim($eblog_server_host)));
param( 'eblog_server_port', 'integer', true );
$Settings->set( 'eblog_server_port', $eblog_server_port );
param( 'eblog_encrypt', 'string', true );
$Settings->set( 'eblog_encrypt', $eblog_encrypt );
param( 'eblog_username', 'string', true );
$Settings->set( 'eblog_username', trim($eblog_username));
param( 'eblog_password', 'string', true );
$Settings->set( 'eblog_password', trim($eblog_password));
param( 'eblog_default_category', 'integer', true );
$Settings->set( 'eblog_default_category', $eblog_default_category );
param( 'eblog_subject_prefix', 'string', true );
$Settings->set( 'eblog_subject_prefix', trim($eblog_subject_prefix) );
param( 'eblog_novalidatecert', 'boolean', 0 );
$Settings->set( 'eblog_novalidatecert', $eblog_novalidatecert );
param( 'eblog_add_imgtag', 'boolean', 0 );
$Settings->set( 'eblog_add_imgtag', $eblog_add_imgtag );
param( 'AutoBR', 'boolean', 0 );
$Settings->set( 'AutoBR', $AutoBR );
param( 'eblog_body_terminator', 'string', true );
$Settings->set( 'eblog_body_terminator', trim($eblog_body_terminator) );
param( 'eblog_test_mode', 'boolean', 0 );
$Settings->set( 'eblog_test_mode', $eblog_test_mode );
/* tblue> this isn't used/implemented at the moment
param( 'eblog_phonemail', 'integer', 0 );
$Settings->set( 'eblog_phonemail', $eblog_phonemail );
param( 'eblog_phonemail_separator', 'string', true );
$Settings->set( 'eblog_phonemail_separator', trim($eblog_phonemail_separator) );*/
$Settings->set( 'allow_moving_chapters', param( 'allow_moving_chapters', 'integer', 0 ) );
$Settings->set( 'chapter_ordering', param( 'chapter_ordering', 'string', 'alpha' ) );
// Default user permissions
param( 'newusers_canregister', 'integer', 0 );
$Settings->set( 'newusers_canregister', $newusers_canregister );
param( 'newusers_grp_ID', 'integer', true );
$Settings->set( 'newusers_grp_ID', $newusers_grp_ID );
$Settings->set( 'newusers_level', $newusers_level );
param( 'default_blog_ID', 'integer', true );
$Settings->set( 'default_blog_ID', $default_blog_ID );
param( 'default_admin_template', 'string', true );
$Settings->set( 'default_admin_template', get_param('default_admin_template') );
param( 'newusers_mustvalidate', 'integer', 0 );
$Settings->set( 'newusers_mustvalidate', $newusers_mustvalidate );
param( 'newusers_revalidate_emailchg', 'integer', 0 );
$Settings->set( 'newusers_revalidate_emailchg', $newusers_revalidate_emailchg );
param( 'fm_enabled', 'integer', 0 );
$Settings->set( 'fm_enabled', $fm_enabled );
$new_cache_status = param( 'general_cache_enabled', 'integer', 0 );
$old_cache_status = $Settings->get('general_cache_enabled');
if( $old_cache_status == false && $new_cache_status == true )
{ // Caching has been turned ON:
if( $PageCache->cache_create() )
$Messages->add( T_('General caching has been enabled.'), 'success' );
$Messages->add( T_('General caching could not be enabled. Check /cache/ folder file permissions.'), 'error' );
elseif( $old_cache_status == true && $new_cache_status == false )
{ // Caching has been turned OFF:
$PageCache->cache_delete();
$Messages->add( T_('General caching has been disabled. All general cache contents have been purged.'), 'note' );
$Settings->set( 'general_cache_enabled', $new_cache_status );
param( 'webhelp_enabled', 'integer', 0 );
$Settings->set( 'webhelp_enabled', $webhelp_enabled );
$Settings->set( 'log_public_hits', param( 'log_public_hits', 'integer', 0 ) );
$Settings->set( 'log_admin_hits', param( 'log_admin_hits', 'integer', 0 ) );
$Settings->set( 'log_spam_hits', param( 'log_spam_hits', 'integer', 0 ) );
param_integer_range( 'user_minpwdlen', 1, 32, T_('Minimum password length must be between %d and %d.') );
$Settings->set( 'user_minpwdlen', $user_minpwdlen );
param( 'js_passwd_hashing', 'integer', 0 );
$Settings->set( 'js_passwd_hashing', $js_passwd_hashing );
$timeout_sessions = param( 'timeout_sessions', 'integer', $Settings->get_default('timeout_sessions') );
if( $timeout_sessions < 300 )
{ // lower than 5 minutes: not allowed
param_error( 'timeout_sessions', sprintf( T_( 'You cannot set a session timeout below %d seconds.' ), 300 ) );
elseif( $timeout_sessions < 86400 )
{ // lower than 1 day: notice/warning
$Messages->add( sprintf( T_( 'Warning: your session timeout is just %d seconds. Your users may have to re-login often!' ), $timeout_sessions ), 'note' );
$Settings->set( 'timeout_sessions', $timeout_sessions );
param_integer_range( 'reloadpage_timeout', 0, 99999, T_('Reload-page timeout must be between %d and %d.') );
$Settings->set( 'reloadpage_timeout', $reloadpage_timeout );
// miscellaneous stuff that isn't on the general form but is here for some reason
param( 'auto_prune_stats_mode', 'string', true );
$Settings->set( 'auto_prune_stats_mode', get_param('auto_prune_stats_mode') );
// TODO: offer to set-up cron job if mode == 'cron' and to remove cron job if mode != 'cron'
param( 'auto_prune_stats', 'integer', $Settings->get_default('auto_prune_stats'), false, false, true, false );
$Settings->set( 'auto_prune_stats', get_param('auto_prune_stats') );
if( ! $Messages->count('error') )
if( $Settings->dbupdate() )
$Messages->add( T_('Settings updated.'), 'success' );
$Messages->add( T_('Settings have not changed.'), 'note' );
if( ! $Messages->count('error') )
if( $Settings->dbupdate() )
$Messages->add( T_('General settings updated.'), 'success' );
// Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
$AdminUI->disp_html_head();
// Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
$AdminUI->disp_body_top();
$AdminUI->disp_payload_begin();
$AdminUI->disp_view( 'settings/views/_general.form.php' );
$AdminUI->disp_payload_end();
// Display body bottom, debug info and close </html>:
$AdminUI->disp_global_footer();
|