Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattpiwik <matthieu.aubry@gmail.com>2010-07-24 20:48:45 +0400
committermattpiwik <matthieu.aubry@gmail.com>2010-07-24 20:48:45 +0400
commitfeb13838b96f12b3debc12e7ee625a6315659f68 (patch)
treee82ef8806a8300d3fc01eacc1f040884851ae489
parentafb90bb3fc57d29e5b52a175f03049f7c8754768 (diff)
Fixes #1509 - Thanks Jeremy for initial code!
Refs #71 Note: I haven't tested SMTP myself. will require beta tests git-svn-id: http://dev.piwik.org/svn/trunk@2662 59fd770c-687e-43c8-a1e3-f5a4ff64c105
-rw-r--r--config/global.ini.php12
-rw-r--r--core/Mail.php58
-rw-r--r--lang/en.php13
-rw-r--r--plugins/CoreAdminHome/Controller.php14
-rw-r--r--plugins/CoreAdminHome/templates/generalSettings.js25
-rw-r--r--plugins/CoreAdminHome/templates/generalSettings.tpl62
-rw-r--r--plugins/CoreAdminHome/templates/styles.css4
7 files changed, 142 insertions, 46 deletions
diff --git a/config/global.ini.php b/config/global.ini.php
index 5248994cd7..c28b06f8b9 100644
--- a/config/global.ini.php
+++ b/config/global.ini.php
@@ -304,9 +304,9 @@ PluginsInstalled[] = Installation
Plugins_Tracker[] = Provider
[mail]
-transport = ; name of the protocol: smtp
-port = 25 ; port of the smtp: by default 25
-host = ; server address example: smtp.gmail.com
-type = ; by default: NONE for example: LOGIN
-username = ; your username
-password = ; your password
+transport = ; smtp or empty
+port = 25
+host = ; SMTP server address
+type = ; SMTP Auth type. By default: NONE. For example: LOGIN
+username = ; SMTP username
+password = ; SMTP password
diff --git a/core/Mail.php b/core/Mail.php
index 625b067585..f1ee26cba4 100644
--- a/core/Mail.php
+++ b/core/Mail.php
@@ -20,55 +20,39 @@
class Piwik_Mail extends Zend_Mail
{
/**
- * Public constructor, default charset utf-8
- *
+ * Default charset utf-8
* @param string $charset
*/
public function __construct($charset = 'utf-8')
{
parent::__construct($charset);
- $this->setTransport();
+ $this->initSmtpTransport();
}
-
- public function setTransport()
+ private function initSmtpTransport()
{
- try
+ $config = Zend_Registry::get('config')->mail;
+ if ( empty($config->host)
+ || !empty($config->port)
+ || $config->transport != 'smtp')
{
- $config = Zend_Registry::get('config')->mail;
- if ( !empty($config->host)
- && !empty($config->port)
- && strcmp($config->transport,"smtp") ==0
- )
- {
- if ( !empty($config->auth->type)
- || !empty($config->auth->username)
- || !empty($config->auth->password)
- )
- {
- $config_param = array('auth' => $config->auth->type,
- 'username' => $config->auth->username,
- 'password' => $config->auth->password);
- }
-
- $smtp_address = $config->host;
- $smtp_port = $config->port;
- if(isset($config_param))
- {
- $tr = new Zend_Mail_Transport_Smtp("$smtp_address",$config_param);
- }
- else
- {
- $tr = new Zend_Mail_Transport_Smtp("$smtp_address");
- }
- Piwik_Mail::setDefaultTransport($tr);
- ini_set("smtp_port","$smtp_port");
- }
+ return;
}
- catch(Exception $e)
+ $smtpConfig = array();
+ if ( !empty($config->auth->type)
+ || !empty($config->auth->username)
+ || !empty($config->auth->password)
+ )
{
- throw new Exception("Configuration SMTP error");
+ $smtpConfig = array(
+ 'auth' => $config->auth->type,
+ 'username' => $config->auth->username,
+ 'password' => $config->auth->password
+ );
}
+ $tr = new Zend_Mail_Transport_Smtp($config->host,$smtpConfig);
+ Piwik_Mail::setDefaultTransport($tr);
+ ini_set("smtp_port",$config->port);
}
}
diff --git a/lang/en.php b/lang/en.php
index b361ce732b..3308bbea0c 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -189,6 +189,17 @@ $translations = array(
'General_WarningFileIntegrityNoManifest' => 'File integrity check could not be performed due to missing manifest.inc.php.',
'General_WarningFileIntegrityNoMd5file' => 'File integrity check could not be completed due to missing md5_file() function.',
'General_FileIntegrityWarningExplanation' => 'File integrity check failed and reported some errors. This is most likely due to a partial or failed upload of some of the Piwik files. You should reupload all the Piwik files in BINARY mode and refresh this page until it shows no error.',
+ 'General_UseSMTPServerForEmail'=>'Use SMTP server for e-mail',
+ 'General_SmtpServerAddress' => 'SMTP server address ',
+ 'General_SmtpPort' => 'SMTP Port ',
+ 'General_AuthenticationMethodSmtp' => 'Authentification method for SMTP',
+ 'General_SmtpUsername' => 'SMTP username',
+ 'General_SmtpPassword' => 'SMTP password ',
+ 'General_SelectYesIfYouWantToSendEmailsViaServer' => 'Select "Yes" if you want or have to send e-mail via a named server instead of the local mail function',
+ 'General_OnlyUsedIfUserPwdIsSet' => 'Only used if a username/password is set, ask your provider if you are unsure which method to use.',
+ 'General_OnlyEnterIfRequired' => 'Only enter a username if your SMTP server requires it',
+ 'General_OnlyEnterIfRequiredPassword' => 'Only enter a password if your SMTP server requires it',
+ 'General_WarningPasswordStored' => '%sWarning:%s This password will be stored in the config file visible to everybody how can access it.',
'Actions_PluginDescription' => 'Reports about the page views, the outlinks and downloads. Outlinks and Downloads tracking is automatic!',
'Actions_Actions' => 'Actions',
'Actions_SubmenuPages' => 'Pages',
@@ -221,7 +232,7 @@ $translations = array(
'CoreHome_WebAnalyticsReports' => 'Web Analytics Reports',
'CoreHome_NoPrivileges' => 'You are logged in as \'%s\' but it seems you don\'t have any permission set in Piwik.<br />Ask your Piwik administrator to give you \'view\' access to a website.',
'CoreHome_JavascriptDisabled' => 'JavaScript must be enabled in order for you to use Piwik in standard view.<br />However, it seems JavaScript is either disabled or not supported by your browser.<br />To use standard view, enable JavaScript by changing your browser options, then %1$stry again%2$s.<br />',
- 'CoreHome_TableNoData' => 'No data for this table.',
+ 'CoreHome_ThereIsNoDataForThisReport' => 'There is no data for this report.',
'CoreHome_CategoryNoData' => 'No data in this category. Try to "Include all population".',
'CoreHome_ShowJSCode' => 'Show the JavaScript code to insert',
'CoreHome_IncludeAllPopulation_js' => 'Include all population',
diff --git a/plugins/CoreAdminHome/Controller.php b/plugins/CoreAdminHome/Controller.php
index 023b7250e7..a4abb57614 100644
--- a/plugins/CoreAdminHome/Controller.php
+++ b/plugins/CoreAdminHome/Controller.php
@@ -35,6 +35,9 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller
$view->showWarningCron = $showWarningCron;
$view->todayArchiveTimeToLive = $todayArchiveTimeToLive;
$view->enableBrowserTriggerArchiving = $enableBrowserTriggerArchiving;
+
+ $view->mail = Zend_Registry::get('config')->mail->toArray();
+
$this->setBasicVariablesView($view);
$view->topMenu = Piwik_GetTopMenu();
$view->menu = Piwik_GetAdminMenu();
@@ -52,6 +55,17 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller
Piwik_ArchiveProcessing::setBrowserTriggerArchiving((bool)$enableBrowserTriggerArchiving);
Piwik_ArchiveProcessing::setTodayArchiveTimeToLive($todayArchiveTimeToLive);
+
+ // Update email settings
+ $mail = Zend_Registry::get('config')->mail;
+ $mail->transport = (Piwik_Common::getRequestVar('mailUseSmtp') == '1') ? 'smtp' : '';
+ $mail->port = Piwik_Common::getRequestVar('mailPort', 25);
+ $mail->host = Piwik_Common::getRequestVar('mailHost', '');
+ $mail->type = Piwik_Common::getRequestVar('mailType', '');
+ $mail->username = Piwik_Common::getRequestVar('mailUsername', '');
+ $mail->password = Piwik_Common::getRequestVar('mailPassword', '');
+ Zend_Registry::get('config')->mail = $mail->toArray();
+
$toReturn = $response->getResponse();
} catch(Exception $e ) {
$toReturn = $response->getResponseException( $e );
diff --git a/plugins/CoreAdminHome/templates/generalSettings.js b/plugins/CoreAdminHome/templates/generalSettings.js
index f77a5ff9f5..6d9a099f97 100644
--- a/plugins/CoreAdminHome/templates/generalSettings.js
+++ b/plugins/CoreAdminHome/templates/generalSettings.js
@@ -10,15 +10,40 @@ function getGeneralSettingsAJAX()
request += '&enableBrowserTriggerArchiving='+enableBrowserTriggerArchiving;
request += '&todayArchiveTimeToLive='+todayArchiveTimeToLive;
request += '&token_auth=' + piwik.token_auth;
+ request += '&mailUseSmtp=' + isSmtpEnabled();
+ request += '&mailPort=' + $('#mailPort').val();
+ request += '&mailHost=' + $('#mailHost').val();
+ request += '&mailType=' + $('#mailType').val();
+ request += '&mailUsername=' + $('#mailUsername').val();
+ request += '&mailPassword=' + $('#mailPassword').val();
ajaxRequest.data = request;
return ajaxRequest;
}
+function showSmtpSettings(value)
+{
+ if(value == 1)
+ {
+ $('#smtpSettings').show();
+ }
+ else
+ {
+ $('#smtpSettings').hide();
+ }
+}
+function isSmtpEnabled()
+{
+ return $('input[name="mailUseSmtp"]:checked').attr('value');
+}
$(document).ready( function() {
+ showSmtpSettings(isSmtpEnabled());
$('#generalSettingsSubmit').click( function() {
$.ajax( getGeneralSettingsAJAX() );
});
+ $('input[name=mailUseSmtp]').click(function(){
+ showSmtpSettings($(this).attr('value'));
+ });
$('input').keypress( function(e) {
var key=e.keyCode || e.which;
if (key==13) {
diff --git a/plugins/CoreAdminHome/templates/generalSettings.tpl b/plugins/CoreAdminHome/templates/generalSettings.tpl
index 71445b9f2e..88f0ac756d 100644
--- a/plugins/CoreAdminHome/templates/generalSettings.tpl
+++ b/plugins/CoreAdminHome/templates/generalSettings.tpl
@@ -31,7 +31,7 @@
</td>
</tr>
<tr>
- <td><label for="todayArchiveTTL">{'General_ReportsForTodayWillBeProcessedAtMostEvery'|translate}</label></td>
+ <td><label for="todayArchiveTimeToLive">{'General_ReportsForTodayWillBeProcessedAtMostEvery'|translate}</label></td>
<td>
{'General_NSeconds'|translate:"<input size='3' value='$todayArchiveTimeToLive' id='todayArchiveTimeToLive' />"}
</td>
@@ -51,9 +51,67 @@
</td>
</tr>
+<div id='emailSettings'>
+<table class="adminTable adminTableNoBorder" style='width:600px;'>
+ <tr>
+ <td>{'General_UseSMTPServerForEmail'|translate}</label><br>
+ <span class="form-description">{'General_SelectYesIfYouWantToSendEmailsViaServer'|translate}</span>
+ </td>
+ <td style='width:200px'>
+ <label><input type="radio" name="mailUseSmtp" value="1" {if $mail.transport eq 'smtp'} checked {/if}> {'General_Yes'|translate}</label>
+ <label><input type="radio" name="mailUseSmtp" value="0" style ="margin-left:20px;" {if $mail.transport eq ''} checked {/if}> {'General_No'|translate}</label>
+ </td>
+ </tr>
+</table>
+
+
+<div id='smtpSettings'>
+ <table class="adminTable adminTableNoBorder" style='width:550px;'>
+ <tr>
+ <td><label for="mailHost">{'General_SmtpServerAddress'|translate}</label></td>
+ <td style='width:200px'><input type="text" id="mailHost" value="{$mail.host}"></td>
+ </tr>
+ <tr>
+ <td><label for="mailPort">{'General_SmtpPort'|translate}</label></td>
+ <td><input type="text" id="mailPort" value="{$mail.port}"></td>
+ </tr>
+ <tr>
+ <td><label for="mailType">{'General_AuthenticationMethodSmtp'|translate}</label><br>
+ <span class="form-description">{'General_OnlyUsedIfUserPwdIsSet'|translate}</span>
+ </td>
+ <td>
+ <select id="mailType" >
+ <option value="" {if $mail.type eq ''} selected="selected" {/if}></option>
+ <option id="plain" {if $mail.type eq 'PLAIN'} selected="selected" {/if} value="PLAIN">PLAIN</option>
+ <option id="login" {if $mail.type eq 'LOGIN'} selected="selected" {/if} value="LOGIN"> LOGIN</option>
+ <option id="cram-md5" {if $mail.type eq 'CRAM-MD5'} selected="selected" {/if} value="CRAM-MD5"> CRAM-MD5</option>
+ <option id="digest-md5" {if $mail.type eq 'DIGEST-MD5'} selected="selected" {/if} value="DIGEST-MD5"> DIGEST-MD5</option>
+ <option id="pop-before-smtp" {if $mail.type eq 'POP-before-SMTP'} selected="selected" {/if} value="POP-before-SMTP"> POP-before-SMTP</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td><label for="mailUsername">{'General_SmtpUsername'|translate}</label><br>
+ <span class="form-description">{'General_OnlyEnterIfRequired'|translate}</i></td>
+ <td>
+ <input type="text" id="mailUsername" value = "{$mail.username}" >
+ </td>
+ </tr>
+ <tr>
+ <td><label for="mailPassword">{'General_SmtpPassword'|translate}</label><br>
+ <span class="form-description">{'General_OnlyEnterIfRequiredPassword'|translate}<br/>
+ {'General_WarningPasswordStored'|translate}</span>
+ </td>
+ <td>
+ <input type="password" id="mailPassword" value = "{$mail.password}" >
+ </td>
+ </tr>
+ </table>
+</div>
+</div>
+
</table>
<input type="submit" value="{'General_Save'|translate}" id="generalSettingsSubmit" class="submit" />
<br /><br />
-
{include file="CoreAdminHome/templates/footer.tpl"}
diff --git a/plugins/CoreAdminHome/templates/styles.css b/plugins/CoreAdminHome/templates/styles.css
index bd2beff4a4..a92bf39380 100644
--- a/plugins/CoreAdminHome/templates/styles.css
+++ b/plugins/CoreAdminHome/templates/styles.css
@@ -208,4 +208,8 @@ input[disabled] {
color:#666666;
font-style:italic;
margin-left:10px;
+}
+
+#smtpSettings {
+ margin-left:50px;
} \ No newline at end of file