From 30d28ce456d7ad8ebfd9f74081387b6b7d4d412d Mon Sep 17 00:00:00 2001 From: Byrne Date: Tue, 10 Nov 2009 22:44:09 -0800 Subject: [PATCH] [PATCH 20/24] Initial commit of refactoring system settings into a single screen as well. This commit: * makes necessary style changes * added javascript to show and hide system settings fieldsets * refactors fieldset/form elements into includes (prefs/sys_*.tmpl) * adds necessary menu items to CMS * removes obsolete menu items from CMS * adds method handler to Tools.pm Signed-off-by: Open Melody Software Group --- lib/MT/App/CMS.pm | 34 +---- lib/MT/CMS/Tools.pm | 85 +++++++++++ mt-static/melody/styles.css | 1 + tmpl/cms/cfg_system_feedback.tmpl | 62 +------- tmpl/cms/cfg_system_general.tmpl | 51 ++----- tmpl/cms/cfg_system_settings.tmpl | 100 ++++++++++++ tmpl/cms/cfg_system_users.tmpl | 153 +------------------ tmpl/cms/include/cfg_system_content_nav.tmpl | 29 +++- tmpl/cms/prefs/sys_feedback.tmpl | 61 ++++++++ tmpl/cms/prefs/sys_general.tmpl | 44 ++++++ tmpl/cms/prefs/sys_users.tmpl | 152 ++++++++++++++++++ 11 files changed, 487 insertions(+), 285 deletions(-) create mode 100644 tmpl/cms/cfg_system_settings.tmpl create mode 100644 tmpl/cms/prefs/sys_feedback.tmpl create mode 100644 tmpl/cms/prefs/sys_general.tmpl create mode 100644 tmpl/cms/prefs/sys_users.tmpl diff --git a/lib/MT/App/CMS.pm b/lib/MT/App/CMS.pm index 33764d578..f732aad39 100644 --- a/lib/MT/App/CMS.pm +++ b/lib/MT/App/CMS.pm @@ -171,9 +171,10 @@ sub core_methods { 'handshake' => "${pkg}Blog::handshake", 'itemset_action' => "${pkg}Tools::do_list_action", 'page_action' => "${pkg}Tools::do_page_action", - 'cfg_system' => "${pkg}Tools::cfg_system_general", - 'cfg_system_users' => "${pkg}User::cfg_system_users", - 'cfg_system_feedback' => "${pkg}Comment::cfg_system_feedback", + 'cfg_system_settings' => "${pkg}Tools::cfg_system_settings", +# 'cfg_system' => "${pkg}Tools::cfg_system_general", +# 'cfg_system_users' => "${pkg}User::cfg_system_users", +# 'cfg_system_feedback' => "${pkg}Comment::cfg_system_feedback", 'save_plugin_config' => "${pkg}Plugin::save_config", 'reset_plugin_config' => "${pkg}Plugin::reset_config", 'save_cfg_system_feedback' => @@ -1354,31 +1355,10 @@ sub core_menus { system_permission => "edit_templates", }, - 'prefs:general' => { - label => "General", + 'prefs:system' => { + label => "System Settings", order => 100, - mode => "cfg_system", - view => "system", - permission => "administer", - }, - 'prefs:user' => { - label => "User", - order => 200, - mode => "cfg_system_users", - view => "system", - permission => "administer", - }, - 'prefs:feedback' => { - label => "Feedback", - order => 300, - mode => "cfg_system_feedback", - view => "system", - permission => "administer", - }, - 'prefs:general' => { - label => "General", - order => 100, - mode => "cfg_system", + mode => "cfg_system_settings", view => "system", permission => "administer", }, diff --git a/lib/MT/CMS/Tools.pm b/lib/MT/CMS/Tools.pm index 24733306a..0debca26f 100644 --- a/lib/MT/CMS/Tools.pm +++ b/lib/MT/CMS/Tools.pm @@ -382,6 +382,91 @@ sub do_page_action { $the_action->{code}->($app); } +sub cfg_system_settings { + my $app = shift; + my %param; + if ( $app->param('blog_id') ) { + return $app->return_to_dashboard( redirect => 1 ); + } + + return $app->errtrans("Permission denied.") + unless $app->user->is_superuser(); + my $cfg = $app->config; + $param{languages} = + $app->languages_list( $app->config('DefaultUserLanguage') ); + my $tag_delim = $app->config('DefaultUserTagDelimiter') || 'comma'; + $param{"tag_delim_$tag_delim"} = 1; + + ( my $tz = $app->config('DefaultTimezone') ) =~ s![-\.]!_!g; + $tz =~ s!_00$!!; + $param{ 'server_offset_' . $tz } = 1; + + $param{default_site_root} = $app->config('DefaultSiteRoot'); + $param{default_site_url} = $app->config('DefaultSiteURL'); + $param{personal_weblog_readonly} = + $app->config->is_readonly('NewUserAutoProvisioning'); + $param{personal_weblog} = $app->config->NewUserAutoProvisioning ? 1 : 0; + if ( my $id = $param{new_user_template_blog_id} = + $app->config('NewUserTemplateBlogId') || '' ) + { + my $blog = MT->model('blog')->load($id); + if ($blog) { + $param{new_user_template_blog_name} = $blog->name; + } + else { + $app->config( 'NewUserTemplateBlogId', undef, 1 ); + $cfg->save_config(); + delete $param{new_user_template_blog_id}; + } + } + + if ($app->param('to_email_address')) { + return $app->errtrans("You don't have a system email address configured. Please set this first, save it, then try the test email again.") + unless ($cfg->EmailAddressMain); + return $app->errtrans("Please enter a valid email address") + unless (MT::Util::is_valid_email($app->param('to_email_address'))); + + my %head = ( + To => $app->param('to_email_address'), + From => $cfg->EmailAddressMain, + Subject => $app->translate("Test email from Movable Type") + ); + + my $body = $app->translate( + "This is the test email sent by your installation of Movable Type." + ); + + require MT::Mail; + MT::Mail->send( \%head, $body ) + or return $app->error( $app->translate("Mail was not properly sent") ); + + $app->log({ + message => $app->translate('Test e-mail was successfully sent to [_1]', $app->param('to_email_address')), + level => MT::Log::INFO(), + class => 'system', + }); + $param{test_mail_sent} = 1; + } + + my @config_warnings; + for my $config_directive ( qw( EmailAddressMain DebugMode PerformanceLogging + PerformanceLoggingPath PerformanceLoggingThreshold ) ) { + push(@config_warnings, $config_directive) if $app->config->is_readonly($config_directive); + } + my $config_warning = join(", ", @config_warnings) if (@config_warnings); + + $param{config_warning} = $app->translate("These setting(s) are overridden by a value in the MT configuration file: [_1]. Remove the value from the configuration file in order to control the value on this page.", $config_warning) if $config_warning; + $param{system_email_address} = $cfg->EmailAddressMain; + $param{system_debug_mode} = $cfg->DebugMode; + $param{system_performance_logging} = $cfg->PerformanceLogging; + $param{system_performance_logging_path} = $cfg->PerformanceLoggingPath; + $param{system_performance_logging_threshold} = $cfg->PerformanceLoggingThreshold; + $param{saved} = $app->param('saved'); + $param{error} = $app->param('error'); + $param{screen_class} = "settings-screen system-general-settings"; + $app->load_tmpl( 'cfg_system_settings.tmpl', \%param ); +} + sub cfg_system_general { my $app = shift; my $q = $app->query; diff --git a/mt-static/melody/styles.css b/mt-static/melody/styles.css index dbc919094..18e251528 100644 --- a/mt-static/melody/styles.css +++ b/mt-static/melody/styles.css @@ -30,6 +30,7 @@ } /* Redesign Blog Settings */ +.sys-preferences, .blog-preferences { display: none; } diff --git a/tmpl/cms/cfg_system_feedback.tmpl b/tmpl/cms/cfg_system_feedback.tmpl index 7ab023561..e88ca0e93 100644 --- a/tmpl/cms/cfg_system_feedback.tmpl +++ b/tmpl/cms/cfg_system_feedback.tmpl @@ -21,67 +21,7 @@ " /> " /> -
- -

<__trans phrase="Feedback: Master Switch">

- -
- - " - content_class="field-content-text" - hint="<__trans phrase="This will override all individual blog settings.">"> - checked="checked" class="cb" /> - - - " - content_class="field-content-text" - hint="<__trans phrase="This will override all individual blog settings.">"> - checked="checked" class="cb" /> - - -
- -
- -
- -

<__trans phrase="Outbound Notifications">

- -
- - " - content_class="field-content-text" - hint="<__trans phrase="This feature allows you to disable sending notification pings when a new entry is created.">"> - checked="checked" class="cb" /> - - - " - content_class="field-content-text" - hint="<__trans phrase="Limit outbound TrackBacks and TrackBack auto-discovery for the purposes of keeping your installation private.">" - show_hint="1"> -
    -
  • checked="checked" class="cb" />
  • -
  • checked="checked" class="cb" /> <__trans phrase="(No outbound TrackBacks)">
  • -
  • checked="checked" class="cb" />
  • -
  • checked="checked" class="cb" />
    -
    - -
    -
  • -
-
- -
- -
+<$mt:include name="prefs/sys_feedback.tmpl"$> + + + + + +

+ +
" method="post" onsubmit="return validate(this);"> + +" /> +" /> +
+ " + hint="<__trans phrase="The email address where you want to send test email to.">" + show_hint="1"> +
+ +
+ +
+ + + + + + + diff --git a/tmpl/cms/cfg_system_users.tmpl b/tmpl/cms/cfg_system_users.tmpl index a46eba1ad..3a83697ba 100644 --- a/tmpl/cms/cfg_system_users.tmpl +++ b/tmpl/cms/cfg_system_users.tmpl @@ -78,158 +78,7 @@ function clearNotifyUsers() { " /> " /> - -
- -

<__trans phrase="User Registration">

- - " - content_class="field-content-text" - hint="<__trans phrase="Select a system administrator you wish to notify when commenters successfully registered themselves.">"> -

checked="checked" class="cb" />

- " /> -

<__trans phrase="Notify the following administrators upon registration:">
- - - - - <__trans phrase="(None selected)"> - - -
- <__trans phrase="Select Administrators"> - | <__trans phrase="Clear"> -

- - -
<__trans phrase="Note: System Email Address is not set. Emails will not be sent.">
-
-
- -
-
-
- -

<__trans phrase="New User Defaults">

- - " - content_class="field-content-text" - hint="<__trans phrase="Check to have the system automatically create a new personal blog when a user is created in the system. The user will be granted a blog administrator role on the blog.">"> - checked="checked" class="cb" disabled="disabled" /> - - - " - content_class="field-content-text" - hint="<__trans phrase="Select a blog you wish to use as the source for new personal blogs. The new blog will be identical to the source except for the name, publishing paths and permissions.">"> - " /> -
- - () - - <__trans phrase="Clear"> - - - <__trans phrase="(No blog selected)"> - -
- - <__trans phrase="Change blog"><__trans phrase="Select blog"> - -
- - " - hint="<__trans phrase="Define the default site URL for new blogs. This URL will be appended with a unique identifier for the blog.">"> -
- " size="50" disabled="disabled" /> -
-
- - - " - hint="<__trans phrase="Define the default site root for new blogs. This path will be appended with a unique identifier for the blog.">"> -
- " size="50" disabled="disabled" /> -
-
- - - " - hint="<__trans phrase="Define the default language to apply to all new users.">"> - - - - - " - hint="<__trans phrase="Select your timezone from the pulldown menu.">" - help_page="blog_settings_general" - help_section="blog_timezone"> - - - - - " - hint="<__trans phrase="Define the default delimiter for entering tags.">"> - - - -
+<$mt:include name="prefs/sys_users.tmpl"$>