mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 19:21:40 +09:00
Clean up duplicate configuration actions
This commit is contained in:
parent
b65511eb6c
commit
c735a8a0c2
4 changed files with 18 additions and 65 deletions
|
|
@ -565,6 +565,24 @@ class adminAdminController extends admin
|
|||
// Load advanced mailer module (for lang).
|
||||
$oAdvancedMailerAdminView = getAdminView('advanced_mailer');
|
||||
|
||||
// Validate the mail sender's information.
|
||||
if (!$vars->mail_default_name)
|
||||
{
|
||||
return new Object(-1, 'msg_advanced_mailer_sender_name_is_empty');
|
||||
}
|
||||
if (!$vars->mail_default_from)
|
||||
{
|
||||
return new Object(-1, 'msg_advanced_mailer_sender_email_is_empty');
|
||||
}
|
||||
if (!Mail::isVaildMailAddress($vars->mail_default_from))
|
||||
{
|
||||
return new Object(-1, 'msg_advanced_mailer_sender_email_is_invalid');
|
||||
}
|
||||
if ($vars->mail_default_reply_to && !Mail::isVaildMailAddress($vars->mail_default_reply_to))
|
||||
{
|
||||
return new Object(-1, 'msg_advanced_mailer_reply_to_is_invalid');
|
||||
}
|
||||
|
||||
// Validate the mail driver.
|
||||
$mail_drivers = Rhymix\Framework\Mail::getSupportedDrivers();
|
||||
$mail_driver = $vars->mail_driver;
|
||||
|
|
|
|||
|
|
@ -15,49 +15,9 @@ class Advanced_MailerAdminController extends Advanced_Mailer
|
|||
{
|
||||
// Get and validate the new configuration.
|
||||
$vars = Context::getRequestVars();
|
||||
if (!$vars->sender_name)
|
||||
{
|
||||
return new Object(-1, 'msg_advanced_mailer_sender_name_is_empty');
|
||||
}
|
||||
if (!$vars->sender_email)
|
||||
{
|
||||
return new Object(-1, 'msg_advanced_mailer_sender_email_is_empty');
|
||||
}
|
||||
if (!Mail::isVaildMailAddress($vars->sender_email))
|
||||
{
|
||||
return new Object(-1, 'msg_advanced_mailer_sender_email_is_invalid');
|
||||
}
|
||||
if ($vars->reply_to && !Mail::isVaildMailAddress($vars->reply_to))
|
||||
{
|
||||
return new Object(-1, 'msg_advanced_mailer_reply_to_is_invalid');
|
||||
}
|
||||
|
||||
// Validate the sending method.
|
||||
$sending_methods = Rhymix\Framework\Mail::getSupportedDrivers();
|
||||
$sending_method = $vars->sending_method;
|
||||
if (!array_key_exists($sending_method, $sending_methods))
|
||||
{
|
||||
return new Object(-1, 'msg_advanced_mailer_sending_method_is_invalid');
|
||||
}
|
||||
|
||||
// Validate the configuration for the selected sending method.
|
||||
$sending_method_config = array();
|
||||
foreach ($sending_methods[$sending_method]['required'] as $conf_name)
|
||||
{
|
||||
$conf_value = $vars->{$sending_method . '_' . $conf_name} ?: null;
|
||||
if (!$conf_value)
|
||||
{
|
||||
return new Object(-1, 'msg_advanced_mailer_smtp_host_is_invalid');
|
||||
}
|
||||
$sending_method_config[$conf_name] = $conf_value;
|
||||
}
|
||||
|
||||
// Update the current module's configuration.
|
||||
$config = $this->getConfig();
|
||||
$config->sender_name = $vars->sender_name;
|
||||
$config->sender_email = $vars->sender_email;
|
||||
$config->reply_to = $vars->reply_to;
|
||||
$config->force_sender = toBool($vars->force_sender);
|
||||
$config->log_sent_mail = toBool($vars->log_sent_mail);
|
||||
$config->log_errors = toBool($vars->log_errors);
|
||||
$output = getController('module')->insertModuleConfig('advanced_mailer', $config);
|
||||
|
|
@ -70,17 +30,6 @@ class Advanced_MailerAdminController extends Advanced_Mailer
|
|||
return $output;
|
||||
}
|
||||
|
||||
// Update the webmaster's name and email in the member module.
|
||||
getController('module')->updateModuleConfig('member', (object)array(
|
||||
'webmaster_name' => $config->sender_name,
|
||||
'webmaster_email' => $config->sender_email,
|
||||
));
|
||||
|
||||
// Update system configuration.
|
||||
Rhymix\Framework\Config::set("mail.type", $sending_method);
|
||||
Rhymix\Framework\Config::set("mail.$sending_method", $sending_method_config);
|
||||
Rhymix\Framework\Config::save();
|
||||
|
||||
if (Context::get('success_return_url'))
|
||||
{
|
||||
$this->setRedirectUrl(Context::get('success_return_url'));
|
||||
|
|
|
|||
|
|
@ -14,14 +14,7 @@ class Advanced_MailerAdminView extends Advanced_Mailer
|
|||
public function dispAdvanced_MailerAdminConfig()
|
||||
{
|
||||
$advanced_mailer_config = $this->getConfig();
|
||||
$member_config = getModel('module')->getModuleConfig('member');
|
||||
$sending_methods = Rhymix\Framework\Mail::getSupportedDrivers();
|
||||
|
||||
Context::set('advanced_mailer_config', $advanced_mailer_config);
|
||||
Context::set('sending_methods', $sending_methods);
|
||||
Context::set('sending_method', config('mail.type'));
|
||||
Context::set('webmaster_name', $member_config->webmaster_name ? $member_config->webmaster_name : 'webmaster');
|
||||
Context::set('webmaster_email', $member_config->webmaster_email);
|
||||
|
||||
$this->setTemplatePath($this->module_path.'tpl');
|
||||
$this->setTemplateFile('config');
|
||||
|
|
|
|||
|
|
@ -167,8 +167,6 @@ class memberAdminController extends member
|
|||
'enable_join',
|
||||
'enable_confirm',
|
||||
'enable_find_account_question',
|
||||
'webmaster_name',
|
||||
'webmaster_email',
|
||||
'password_strength',
|
||||
'password_hashing_algorithm',
|
||||
'password_hashing_work_factor',
|
||||
|
|
@ -196,11 +194,6 @@ class memberAdminController extends member
|
|||
$args->password_hashing_auto_upgrade = 'N';
|
||||
}
|
||||
|
||||
if((!$args->webmaster_name || !$args->webmaster_email) && $args->enable_confirm == 'Y')
|
||||
{
|
||||
return new Object(-1, 'msg_mail_authorization');
|
||||
}
|
||||
|
||||
$oModuleController = getController('module');
|
||||
$output = $oModuleController->updateModuleConfig('member', $args);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue