Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send Email Notifications on newly added reports
Send these notifications to developers@phpmyadmin.net Fix #31 Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
- Loading branch information
1 parent
2a5c559
commit 29a6423
Showing
10 changed files
with
366 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,4 +323,8 @@ | |
'Session' => [ | ||
'defaults' => 'php', | ||
], | ||
|
||
|
||
'NotificationEmailTo' => '', | ||
'NotificationEmailFrom' => '' | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/* vim: set expandtab sw=4 ts=4 sts=4: */ | ||
|
||
/** | ||
* Mailer component handling sending of report notification mails | ||
* | ||
* phpMyAdmin Error reporting server | ||
* Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) | ||
* | ||
* Licensed under The MIT License | ||
* For full copyright and license information, please see the LICENSE.txt | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) | ||
* @license https://opensource.org/licenses/mit-license.php MIT License | ||
* | ||
* @see https://www.phpmyadmin.net/ | ||
*/ | ||
|
||
namespace App\Controller\Component; | ||
|
||
use Cake\Controller\Component; | ||
use Cake\ORM\TableRegistry; | ||
use Cake\Mailer\Email; | ||
use Cake\Core\Configure; | ||
|
||
/** | ||
* Mailer component handling report notification emails. | ||
*/ | ||
class MailerComponent extends Component | ||
{ | ||
/** | ||
* Send an email about the report to configured Email | ||
* | ||
* @param $viewVars Array of View Variables | ||
* | ||
* @return boolean if Email was sent | ||
*/ | ||
public function sendReportMail($viewVars) | ||
{ | ||
$email = new Email(); | ||
$emailTo = Configure::read('NotificationEmailsTo'); | ||
$emailFrom = Configure::read('NotificationEmailsFrom'); | ||
|
||
if (! $emailTo || $emailTo === '' | ||
|| ! $emailFrom || $emailFrom === '' | ||
) { | ||
return false; | ||
} | ||
|
||
$email->transport('default') | ||
->viewVars($viewVars) | ||
->subject( | ||
sprintf( | ||
'A new report has been submitted on the Error Reporting Server: %s', | ||
$viewVars['report']['id'] | ||
) | ||
) | ||
->template('report', 'default') | ||
->emailFormat('html') | ||
->to($emailTo) | ||
->from($emailFrom) | ||
->send(); | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
<?php | ||
/** | ||
* Report Notification Email Template | ||
* | ||
* phpMyAdmin Error reporting server | ||
* Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) | ||
* | ||
* Licensed under The MIT License | ||
* For full copyright and license information, please see the LICENSE.txt | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) | ||
* @license https://opensource.org/licenses/mit-license.php MIT License | ||
* | ||
* @see https://www.phpmyadmin.net/ | ||
*/ | ||
?> | ||
<?php use Cake\Routing\Router; ?> | ||
|
||
<p> | ||
A new error report has been added on the phpMyAdmin's Error Reporting System. | ||
</p> | ||
<p> | ||
The details of the report are as follows: | ||
</p> | ||
|
||
<table cellspacing="0" style="border:1px solid #333"> | ||
<tr> | ||
<td style="width:20%">Error Type</td> | ||
<td><?= $report['exception_type'] ? 'php' : 'js'; ?></td> | ||
</tr> | ||
<tr> | ||
<td>Error Name</td> | ||
<td><?= $report['error_name']; ?></td> | ||
</tr> | ||
<tr> | ||
<td>Error Message</td> | ||
<td><?= $report['error_message']; ?></td> | ||
</tr> | ||
<tr> | ||
<td>PMA Versions</td> | ||
<td> | ||
<?= | ||
$this->Reports->entriesFromIncidents( | ||
$related_entries['pma_version'], | ||
$pma_version_distinct_count, | ||
'pma_version' | ||
); | ||
?> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>PHP Versions</td> | ||
<td> | ||
<?= | ||
$this->Reports->entriesFromIncidents( | ||
$related_entries['php_version'], | ||
$php_version_distinct_count, | ||
'php_version' | ||
); | ||
?> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>Browsers</td> | ||
<td> | ||
<?= | ||
$this->Reports->entriesFromIncidents( | ||
$related_entries['browser'], | ||
$browser_distinct_count, | ||
'browser' | ||
); | ||
?> | ||
</td> | ||
</tr> | ||
<?php if ($incidents[0]['exception_type']): // php ?> | ||
<tr> | ||
<td>Location</td> | ||
<td><?= $report['location']; ?></td> | ||
</tr> | ||
<tr> | ||
<td>Line Number</td> | ||
<td><?= $report['linenumber']; ?></td> | ||
</tr> | ||
<?php else: ?> | ||
<tr> | ||
<td>Script Name</td> | ||
<td> | ||
<?= | ||
$this->Reports->entriesFromIncidents( | ||
$related_entries['script_name'], | ||
$script_name_distinct_count, | ||
'script_name' | ||
); | ||
?> | ||
</td> | ||
</tr> | ||
<?php endif; ?> | ||
<tr> | ||
<td>Configuration Storage</td> | ||
<td> | ||
<?= | ||
$this->Reports->entriesFromIncidents( | ||
$related_entries['configuration_storage'], | ||
$configuration_storage_distinct_count, | ||
'configuration_storage' | ||
); | ||
?> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>Server Software</td> | ||
<td> | ||
<?= | ||
$this->Reports->entriesFromIncidents( | ||
$related_entries['server_software'], | ||
$server_software_distinct_count, | ||
'server_software' | ||
); | ||
?> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>User OS</td> | ||
<td> | ||
<?= | ||
$this->Reports->entriesFromIncidents( | ||
$related_entries['user_os'], | ||
$user_os_distinct_count, | ||
'user_os' | ||
); | ||
?> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>Locale</td> | ||
<td> | ||
<?= | ||
$this->Reports->entriesFromIncidents( | ||
$related_entries['locale'], | ||
$locale_distinct_count, | ||
'locale' | ||
); | ||
?> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>Incident Count</td> | ||
<td><?= count($incidents) . ' incidents of this bug'; ?></td> | ||
</tr> | ||
<tr> | ||
<td>Submission Date</td> | ||
<td> | ||
<?= $report['created']; ?> | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
<p> | ||
You can view the detailed report at | ||
<a href="<?= Router::url('/reports/view/' . $report['id'], true) ?>"> | ||
#<?= $report['id'] ?></a>. | ||
</p> |
Oops, something went wrong.