phpDocumentor pond
[ class tree: pond ] [ index: pond ] [ all elements ]

Source for file settings.ctrl.php

Documentation is available at settings.ctrl.php

  1. <?php
  2. /**
  3.  * This file implements the UI controller for settings management.
  4.  *
  5.  * This file is part of Quam Plures - {@link http://quamplures.net/}
  6.  * See also {@link https://launchpad.net/quam-plures}.
  7.  *
  8.  * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
  9.  * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
  10.  *  Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
  11.  *
  12.  *  {@internal License choice
  13.  *  - If you have received this file as part of a package, please find the license.txt file in
  14.  *    the same folder or the closest folder above for complete license terms.
  15.  *  - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  16.  *    then you must choose one of the following licenses before using the file:
  17.  *    - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  18.  *    - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  19.  *  }}}
  20.  *
  21.  *  {@internal Open Source relicensing agreement:
  22.  *  Daniel HAHLER grants Francois PLANQUE the right to license
  23.  *  Daniel HAHLER's contributions to this file and the b2evolution project
  24.  *  under any OSI approved OSS license (http://www.opensource.org/licenses/).
  25.  *  }}}
  26.  *
  27.  *  {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  28.  * @author blueyed: Daniel HAHLER
  29.  * @author fplanque: Francois PLANQUE
  30.  *
  31.  * @package pond
  32.  */
  33. if!defined('QP_MAIN_INIT') ) die'Please, do not access this page directly.' );
  34.  
  35. // Check minimum permission:
  36. $current_User->check_perm'options''view'true );
  37.  
  38. $AdminUI->set_path'options''general' );
  39.  
  40. param'action''string' );
  41. param'edit_locale''string' );
  42. param'loc_transinfo''integer');
  43.  
  44. ifin_array$actionarray'update''reset''updatelocale''createlocale''deletelocale''extract''prioup''priodown' ) ) )
  45. // We have an action to do..
  46.     // Check permission:
  47.     $current_User->check_perm'options''edit'true );
  48.  
  49.     // clear settings cache
  50.     $cache_settings '';
  51.  
  52.     switch$action )
  53.     {
  54.         case 'update':
  55.         // Check permission:
  56.         $current_User->check_perm'options''edit'true );
  57.  
  58.         param'submit''array'array() );
  59.         ifisset($submit['restore_defaults']) )
  60.         {
  61.             /*
  62.             // TODO: insert some default settings rather than just delete them all, as per original configuration in the _advanced.php file:
  63.  
  64.             fp>> Isn't this done in $Settings anyway?
  65.  
  66.             # mailserver settings
  67.             $mailserver_url = 'mail.example.com';
  68.             $mailserver_login = 'login@example.com';
  69.             $mailserver_pass = 'password';
  70.             $mailserver_port = 110;
  71.             # by default posts will have this category
  72.             $default_category = 1;
  73.             # subject prefix
  74.             $subjectprefix = 'blog:';
  75.             # body terminator string (starting from this string, everything will be ignored, including this string)
  76.             $bodyterminator = "___";
  77.             # set this to 1 to run in test mode
  78.             $thisisforfunonly = 0;
  79.             ### Special Configuration for some phone email services
  80.             # some mobile phone email services will send identical subject & content on the same line
  81.             # if you use such a service, set $use_phoneemail to 1, and indicate a separator string
  82.             # when you compose your message, you'll type your subject then the separator string
  83.             # then you type your login:password, then the separator, then content
  84.             $use_phoneemail = 0;
  85.             $phoneemail_separator = ':::';
  86.             */
  87.  
  88.             $Settings->delete_arrayarray(
  89.                     'outbound_notifications_mode',
  90.                     'eblog_enabled',
  91.                     'eblog_method',
  92.                     'eblog_server_host',
  93.                     'eblog_server_port',
  94.                     'eblog_encrypt',
  95.                     'eblog_username',
  96.                     'eblog_password',
  97.                     'eblog_default_category',
  98.                     'eblog_subject_prefix',
  99.                     'eblog_novalidatecert',
  100.                     'eblog_add_imgtag',
  101.                     'AutoBR',
  102.                     'eblog_body_terminator',
  103.                     'eblog_test_mode',
  104.                     'allow_moving_chapters',
  105.                     'chapter_ordering',
  106.                     'newusers_canregister',
  107.                     'newusers_grp_ID',
  108.                     'newusers_level',
  109.                     'default_blog_ID',
  110.                     'newusers_mustvalidate',
  111.                     'newusers_revalidate_emailchg',
  112.                     'fm_enabled',
  113.                     'general_cache_enabled',
  114.                     'webhelp_enabled',
  115.                     'log_public_hits',
  116.                     'log_admin_hits',
  117.                     'auto_prune_stats_mode',
  118.                     'auto_prune_stats',
  119.                     'user_minpwdlen',
  120.                     'js_passwd_hashing',
  121.                     'timeout_sessions',
  122.                     'reloadpage_timeout',
  123.                     'admin_template',
  124.             ) );
  125.  
  126.             if$Settings->dbupdate() )
  127.             {
  128.                 $Messages->addT_('Restored default values.')'success' );
  129.             }
  130.             else
  131.             {
  132.                 $Messages->addT_('Settings have not changed.')'note' );
  133.             }
  134.         }
  135.         else
  136.         {
  137.             // After each new post...
  138.              param'outbound_notifications_mode''string'true );
  139.             $Settings->set'outbound_notifications_mode',  get_param('outbound_notifications_mode') );
  140.  
  141.             // Blog by email
  142.             param'eblog_enabled''boolean');
  143.             $Settings->set'eblog_enabled'$eblog_enabled );
  144.  
  145.             param'eblog_method''string'true );
  146.             $Settings->set'eblog_method'strtolower(trim($eblog_method)));
  147.  
  148.             param'eblog_server_host''string'true );
  149.             $Settings->set'eblog_server_host'strtolower(trim($eblog_server_host)));
  150.  
  151.             param'eblog_server_port''integer'true );
  152.             $Settings->set'eblog_server_port'$eblog_server_port );
  153.  
  154.             param'eblog_encrypt''string'true );
  155.             $Settings->set'eblog_encrypt'$eblog_encrypt );
  156.  
  157.             param'eblog_username''string'true );
  158.             $Settings->set'eblog_username'trim($eblog_username));
  159.  
  160.             param'eblog_password''string'true );
  161.             $Settings->set'eblog_password'trim($eblog_password));
  162.  
  163.             param'eblog_default_category''integer'true );
  164.             $Settings->set'eblog_default_category'$eblog_default_category );
  165.  
  166.             param'eblog_subject_prefix''string'true );
  167.             $Settings->set'eblog_subject_prefix'trim($eblog_subject_prefix) );
  168.  
  169.             param'eblog_novalidatecert''boolean');
  170.             $Settings->set'eblog_novalidatecert'$eblog_novalidatecert );
  171.  
  172.             param'eblog_add_imgtag''boolean');
  173.             $Settings->set'eblog_add_imgtag'$eblog_add_imgtag );
  174.  
  175.             param'AutoBR''boolean');
  176.             $Settings->set'AutoBR'$AutoBR );
  177.  
  178.             param'eblog_body_terminator''string'true );
  179.             $Settings->set'eblog_body_terminator'trim($eblog_body_terminator) );
  180.  
  181.             param'eblog_test_mode''boolean');
  182.             $Settings->set'eblog_test_mode'$eblog_test_mode );
  183.  
  184.             /* tblue> this isn't used/implemented at the moment
  185.             param( 'eblog_phonemail', 'integer', 0 );
  186.             $Settings->set( 'eblog_phonemail', $eblog_phonemail );
  187.  
  188.             param( 'eblog_phonemail_separator', 'string', true );
  189.             $Settings->set( 'eblog_phonemail_separator', trim($eblog_phonemail_separator) );*/
  190.  
  191.             // Categories:
  192.             $Settings->set'allow_moving_chapters'param'allow_moving_chapters''integer') );
  193.             $Settings->set'chapter_ordering'param'chapter_ordering''string''alpha' ) );
  194.  
  195.             // Default user permissions
  196.             param'newusers_canregister''integer');
  197.             $Settings->set'newusers_canregister'$newusers_canregister );
  198.  
  199.             param'newusers_grp_ID''integer'true );
  200.             $Settings->set'newusers_grp_ID'$newusers_grp_ID );
  201.  
  202.             param_integer_range'newusers_level'09T_('User level must be between %d and %d.') );
  203.             $Settings->set'newusers_level'$newusers_level );
  204.  
  205.             // Display options
  206.             param'default_blog_ID''integer'true );
  207.             $Settings->set'default_blog_ID'$default_blog_ID );
  208.  
  209.              param'default_admin_template''string'true );
  210.             $Settings->set'default_admin_template',  get_param('default_admin_template') );
  211.  
  212.             // Email validation
  213.             param'newusers_mustvalidate''integer');
  214.             $Settings->set'newusers_mustvalidate'$newusers_mustvalidate );
  215.  
  216.             param'newusers_revalidate_emailchg''integer');
  217.             $Settings->set'newusers_revalidate_emailchg'$newusers_revalidate_emailchg );
  218.  
  219.             // Features
  220.             param'fm_enabled''integer');
  221.             $Settings->set'fm_enabled'$fm_enabled );
  222.  
  223.             $new_cache_status param'general_cache_enabled''integer');
  224.             $old_cache_status $Settings->get('general_cache_enabled');
  225.             load_class'_core/model/_pagecache.class.php' );
  226.             $PageCache new PageCache(  );
  227.             if$old_cache_status == false && $new_cache_status == true )
  228.             // Caching has been turned ON:
  229.                 if$PageCache->cache_create() )
  230.                 {
  231.                     $Messages->addT_('General caching has been enabled.')'success' );
  232.                 }
  233.                 else
  234.                 {
  235.                     $Messages->addT_('General caching could not be enabled. Check /cache/ folder file permissions.')'error' );
  236.                     $new_cache_status 0;
  237.                 }
  238.             }
  239.             elseif$old_cache_status == true && $new_cache_status == false )
  240.             // Caching has been turned OFF:
  241.                 $PageCache->cache_delete();
  242.                 $Messages->addT_('General caching has been disabled. All general cache contents have been purged.')'note' );
  243.             }
  244.             $Settings->set'general_cache_enabled'$new_cache_status );
  245.  
  246.             param'webhelp_enabled''integer');
  247.             $Settings->set'webhelp_enabled'$webhelp_enabled );
  248.  
  249.             // Hit & Session logging
  250.             $Settings->set'log_public_hits'param'log_public_hits''integer') );
  251.             $Settings->set'log_admin_hits'param'log_admin_hits''integer') );
  252.             $Settings->set'log_spam_hits'param'log_spam_hits''integer') );
  253.  
  254.             // Security options
  255.             param_integer_range'user_minpwdlen'132T_('Minimum password length must be between %d and %d.') );
  256.             $Settings->set'user_minpwdlen'$user_minpwdlen );
  257.  
  258.             param'js_passwd_hashing''integer');
  259.             $Settings->set'js_passwd_hashing'$js_passwd_hashing );
  260.  
  261.             // Timeouts
  262.             $timeout_sessions param'timeout_sessions''integer'$Settings->get_default('timeout_sessions') );
  263.             if$timeout_sessions 300 )
  264.             // lower than 5 minutes: not allowed
  265.                 param_error'timeout_sessions'sprintfT_'You cannot set a session timeout below %d seconds.' )300 ) );
  266.             }
  267.             elseif$timeout_sessions 86400 )
  268.             // lower than 1 day: notice/warning
  269.                 $Messages->addsprintfT_'Warning: your session timeout is just %d seconds. Your users may have to re-login often!' )$timeout_sessions )'note' );
  270.             }
  271.             $Settings->set'timeout_sessions'$timeout_sessions );
  272.  
  273.             param_integer_range'reloadpage_timeout'099999T_('Reload-page timeout must be between %d and %d.') );
  274.             $Settings->set'reloadpage_timeout'$reloadpage_timeout );
  275.  
  276.             // miscellaneous stuff that isn't on the general form but is here for some reason
  277.             param'auto_prune_stats_mode''string'true );
  278.             $Settings->set'auto_prune_stats_mode',  get_param('auto_prune_stats_mode') );
  279.  
  280.             // TODO: offer to set-up cron job if mode == 'cron' and to remove cron job if mode != 'cron'
  281.             param'auto_prune_stats''integer'$Settings->get_default('auto_prune_stats')falsefalsetruefalse );
  282.             $Settings->set'auto_prune_stats'get_param('auto_prune_stats') );
  283.  
  284.             if$Messages->count('error') )
  285.             {
  286.                 if$Settings->dbupdate() )
  287.                 {
  288.                     $Messages->addT_('Settings updated.')'success' );
  289.                 }
  290.                 else
  291.                 {
  292.                     $Messages->addT_('Settings have not changed.')'note' );
  293.                 }
  294.             }
  295.  
  296.         }
  297.         break;
  298.     }
  299.  
  300.     if$Messages->count('error') )
  301.     {
  302.         if$Settings->dbupdate() )
  303.         {
  304.             $Messages->addT_('General settings updated.')'success' );
  305.         }
  306.     }
  307.  
  308. }
  309.  
  310.  
  311. // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
  312. $AdminUI->disp_html_head();
  313.  
  314. // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
  315. $AdminUI->disp_body_top();
  316.  
  317. // Begin payload block:
  318. $AdminUI->disp_payload_begin();
  319.  
  320. // Display VIEW:
  321. $AdminUI->disp_view'settings/views/_general.form.php' );
  322.  
  323. // End payload block:
  324. $AdminUI->disp_payload_end();
  325.  
  326. // Display body bottom, debug info and close </html>:
  327. $AdminUI->disp_global_footer();
  328.  
  329. ?>