Skip to content

Commit

Permalink
[PATCH 20/24] Initial commit of refactoring system settings into a si…
Browse files Browse the repository at this point in the history
…ngle 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 <admin@openmelody.org>
  • Loading branch information
byrnereese authored and Open Melody Software Group committed Nov 17, 2009
1 parent d6189fc commit 30d28ce
Show file tree
Hide file tree
Showing 11 changed files with 487 additions and 285 deletions.
34 changes: 7 additions & 27 deletions lib/MT/App/CMS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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' =>
Expand Down Expand Up @@ -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",
},
Expand Down
85 changes: 85 additions & 0 deletions lib/MT/CMS/Tools.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions mt-static/melody/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
}

/* Redesign Blog Settings */
.sys-preferences,
.blog-preferences {
display: none;
}
Expand Down
62 changes: 1 addition & 61 deletions tmpl/cms/cfg_system_feedback.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,67 +21,7 @@
<input type="hidden" name="return_args" value="<mt:var name="return_args" escape="html">" />
<input type="hidden" name="magic_token" value="<mt:var name="magic_token">" />

<fieldset>

<h3><__trans phrase="Feedback: Master Switch"></h3>

<div class="inner">

<mtapp:setting
id="comment_disable"
label="<__trans phrase="Comments">"
content_class="field-content-text"
hint="<__trans phrase="This will override all individual blog settings.">">
<input type="checkbox" id="comment_disable" name="comment_disable"<mt:if name="comment_disable"> checked="checked"</mt:if> class="cb" /> <label for="comment_disable"><__trans phrase="Disable comments for all blogs"></label>
</mtapp:setting>

<mtapp:setting
id="ping_disable"
label="<__trans phrase="TrackBacks">"
content_class="field-content-text"
hint="<__trans phrase="This will override all individual blog settings.">">
<input type="checkbox" id="ping_disable" name="ping_disable"<mt:if name="ping_disable"> checked="checked"</mt:if> class="cb" /> <label for="ping_disable"><__trans phrase="Disable TrackBacks for all blogs"></label>
</mtapp:setting>

</div>

</fieldset>

<fieldset>

<h3><__trans phrase="Outbound Notifications"></h3>

<div class="inner">

<mtapp:setting
id="disable_notify_ping"
label="<__trans phrase="Notification pings">"
content_class="field-content-text"
hint="<__trans phrase="This feature allows you to disable sending notification pings when a new entry is created.">">
<input type="checkbox" id="disable_notify_ping" name="disable_notify_ping" value="1"<mt:if name="disabled_notify_ping"> checked="checked"</mt:if> class="cb" /> <label for="disable_notify_ping"><__trans phrase="Disable notification pings for all blogs"></label>
</mtapp:setting>

<mtapp:setting
id="trackback_send"
label="<__trans phrase="Outbound TrackBacks">"
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">
<ul>
<li><input type="radio" name="trackback_send" id="trackback_send_any" value="any"<mt:if name="trackback_send_any"> checked="checked"</mt:if> class="cb" /> <label for="trackback_send_any"><__trans phrase="Allow to any site"></label></li>
<li><input type="radio" name="trackback_send" id="trackback_send_off" value="off"<mt:if name="trackback_send_off"> checked="checked"</mt:if> class="cb" /> <label for="trackback_send_off"><__trans phrase="Disabled"></label> <span class="hint"><__trans phrase="(No outbound TrackBacks)"></span></li>
<li><input type="radio" name="trackback_send" id="trackback_send_local" value="local"<mt:if name="trackback_send_local"> checked="checked"</mt:if> class="cb" /> <label for="trackback_send_local"><__trans phrase="Only allow to blogs on this installation"></label></li>
<li><input type="radio" name="trackback_send" id="trackback_send_selected" value="selected"<mt:if name="trackback_send_selected"> checked="checked"</mt:if> class="cb" /> <label for="trackback_send_selected"><__trans phrase="Only allow the sites on the following domains:"></label><br />
<div class="textarea-wrapper">
<textarea rows="" cols="" name="trackback_send_domains" class="full-width short"><mt:var name="trackback_send_domains" escape="html"></textarea>
</div>
</li>
</ul>
</mtapp:setting>

</div>

</fieldset>
<$mt:include name="prefs/sys_feedback.tmpl"$>

<mt:setvarblock name="action_buttons">
<button
Expand Down
51 changes: 9 additions & 42 deletions tmpl/cms/cfg_system_general.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,48 +49,15 @@ function validate (f) {
<input type="hidden" name="return_args" value="<mt:var name="return_args" escape="html">" />
<input type="hidden" name="magic_token" value="<mt:var name="magic_token">" />

<fieldset>
<mtapp:setting
id="system_email_address"
label="<__trans phrase="System Email">"
hint="<__trans phrase="The email address used in the From: header of each email sent from the system. The address is used in password recovery, commenter registration, comment, trackback notification and a few other minor events.">"
show_hint="1">
<div class="textarea-wrapper">
<input id="system_email_address" name="system_email_address"<mt:if name="system_email_address"> value="<mt:var name="system_email_address" escape="html">"</mt:if> class="full-width" />
</div>
</mt:app:setting>
<mtapp:setting
id="system_debug_mode"
label="<__trans phrase="Debug Mode">"
hint="<__trans phrase='You can find an explanation of the various debug modes in the <a href="http://www.movabletype.org/documentation/developer/plugins/debug-mode.html">documentation</a>'>"
show_hint="1">
<input type="text" size="3" maxlength="3" id="system_debug_mode" name="system_debug_mode" value="<mt:var name="system_debug_mode" escape="html">" />
</mt:app:setting>
<mtapp:setting
id="system_performance_logging"
label="<__trans phrase="Performance Logging">"
hint="<__trans phrase="Turns on or off performance logging.">"
show_hint="1">
<input type="checkbox" id="system_performance_logging" name="system_performance_logging" <mt:if name="system_performance_logging" eq="1">checked="checked"</mt:if> />
</mt:app:setting>
<mtapp:setting
id="system_performance_logging_path"
label="<__trans phrase="Log Paths">"
hint="<__trans phrase="Paths where logs are placed.">"
show_hint="1">
<div class="textarea-wrapper">
<input id="system_performance_logging_path" name="system_performance_logging_path"<mt:if name="system_performance_logging_path"> value="<mt:var name="system_performance_logging_path" escape="html">"</mt:if> class="full-width" />
</div>
</mt:app:setting>
<mtapp:setting
id="system_performance_logging_threshold"
label="<__trans phrase="Logging Threshold">"
hint="<__trans phrase="Logging threshold for the App">"
show_hint="1">
<input type="text" size="3" maxlength="3" id="system_performance_logging_threshold" name="system_performance_logging_threshold" value="<mt:var name="system_performance_logging_threshold" escape="html">" />
</mt:app:setting>
</fieldset>

<div id="general" class="sys-preferences">
<$mt:include name="prefs/sys_general.tmpl"$>
</div>
<div id="user" class="sys-preferences">
<$mt:include name="prefs/sys_users.tmpl"$>
</div>
<div id="feedback" class="sys-preferences">
<$mt:include name="prefs/sys_feedback.tmpl"$>
</div>

<mt:setvarblock name="action_buttons">
<button
Expand Down
100 changes: 100 additions & 0 deletions tmpl/cms/cfg_system_settings.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<mt:setvar name="page_title" value="<__trans phrase="System Settings">">
<$mt:setvar name="position_actions_bottom" value="1"$>
<mt:setvar name="system-general-settings" value="1">
<MTSetVarBlock name="system_msg">
<mt:if name="error">
<mtapp:statusmsg
id="generic-error"
class="error">
<mt:var name="error">
</mtapp:statusmsg>
</mt:if>
<mt:if name="test_mail_sent">
<mtapp:statusmsg
id="saved"
class="success">
<__trans phrase="Test email was sent.">
</mtapp:statusmsg>
</mt:if>
<mt:if name="saved">
<mtapp:statusmsg
id="saved"
class="success">
<__trans phrase="Your settings have been saved.">
</mtapp:statusmsg>
</mt:if>
<mt:if name="config_warning">
<mtapp:statusmsg
id="error"
class="error">
<mt:var name="config_warning">
</mtapp:statusmsg>
</mt:if>
</MTSetVarBlock>
<MTSetVarBlock name="content_nav">
<mt:include name="include/cfg_system_content_nav.tmpl">
</MTSetVarBlock>
<mt:include name="include/header.tmpl">

<script type="text/javascript">
/* <![CDATA[ */
function validate (f) {
return true;
}
/* ]]> */
</script>

<form action="<mt:var name="script_url">" method="post" onsubmit="return validate(this);">
<input type="hidden" name="__mode" value="save_cfg_system_general" />
<input type="hidden" name="return_args" value="<mt:var name="return_args" escape="html">" />
<input type="hidden" name="magic_token" value="<mt:var name="magic_token">" />

<div id="general" class="sys-preferences">
<$mt:include name="prefs/sys_general.tmpl"$>
</div>
<div id="users" class="sys-preferences">
<$mt:include name="prefs/sys_users.tmpl"$>
</div>
<div id="feedback" class="sys-preferences">
<$mt:include name="prefs/sys_feedback.tmpl"$>
</div>

<mt:setvarblock name="action_buttons">
<button
type="submit"
accesskey="s"
title="<__trans phrase="Save changes to these settings (s)">"
class="primary-button"
><__trans phrase="Save Changes"></button>
</mt:setvarblock>
<mt:include name="include/actions_bar.tmpl" bar_position="bottom" hide_pager="1" settings_bar="1">

</form>

<br><br>

<form id="send-test-email" action="<mt:var name="script_url">" method="post" onsubmit="return validate(this);">
<input type="hidden" name="__mode" value="cfg_system" />
<input type="hidden" name="magic_token" value="<mt:var name="magic_token">" />
<input type="hidden" name="return_args" value="<mt:var name="return_args" escape="html">" />
<fieldset>
<mtapp:setting
id="to_email_address"
label="<__trans phrase="Send Email To">"
hint="<__trans phrase="The email address where you want to send test email to.">"
show_hint="1">
<div class="textarea-wrapper">
<input id="to_email_address" name="to_email_address" class="full-width" />
</div>
</mt:app:setting>
</fieldset>
<mt:setvarblock name="action_buttons">
<button
type="submit"
class="primary-button"
><__trans phrase="Send Test Email"></button>
</mt:setvarblock>
<mt:include name="include/actions_bar.tmpl" bar_position="bottom" hide_pager="1" settings_bar="1">
</form>

<mt:include name="include/footer.tmpl">
Loading

0 comments on commit 30d28ce

Please sign in to comment.