/
EmailModule.php
78 lines (59 loc) · 2.87 KB
/
EmailModule.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/*
* Copyright Intermesh
*
* This file is part of Group-Office. You should have received a copy of the
* Group-Office license along with Group-Office. See the file /LICENSE.TXT
*
* If you have questions write an e-mail to info@intermesh.nl
*
*/
/**
* This class is used to parse and write RFC822 compliant recipient lists
*
* @package GO.modules.files
* @version $Id: RFC822.class.inc 7536 2011-05-31 08:37:36Z mschering $
* @author Merijn Schering <mschering@intermesh.nl>
* @copyright Copyright Intermesh BV.
*/
namespace GO\Email;
use GO;
class EmailModule extends \GO\Base\Module{
public static function initListeners() {
$c = new \GO\Core\Controller\ReminderController();
$c->addListener('reminderdisplay', "GO\Email\EmailModule", "reminderDisplay");
$c = new \GO\Core\Controller\AuthController();
$c->addListener('head', 'GO\Email\EmailModule', 'head');
\GO\Base\Model\User::model()->addListener('delete', "GO\Email\EmailModule", "deleteUser");
return parent::initListeners();
}
public function autoInstall() {
return true;
}
public static function head(){
$font_size = \GO::user() ? \GO::config()->get_setting('email_font_size', \GO::user()->id) : false;
if(!$font_size)
$font_size='12px';
echo "\n<!-- Inserted by EmailModule::head() -->\n<style>\n".
'.message-body,.message-body p, .message-body li, .go-html-formatted td, .em-composer .em-plaintext-body-field{'.
'font-size: '.$font_size.';!important'.
"}\n</style>\n<!-- End EmailModule::head() -->\n";
}
public static function deleteUser($user) {
Model\Account::model()->deleteByAttribute('user_id', $user->id);
}
public static function submitSettings(&$settingsController, &$params, &$response, $user) {
GO::config()->save_setting('email_use_plain_text_markup', isset($params['use_html_markup']) ? '0' : '1', GO::user()->user_id);
GO::config()->save_setting('email_show_cc', isset($params['email_show_cc']) ? 1 : 0, GO::user()->user_id);
GO::config()->save_setting('email_show_bcc', isset($params['email_show_bcc']) ? 1 : 0, GO::user()->user_id);
GO::config()->save_setting('email_skip_unknown_recipients', isset($params['skip_unknown_recipients']) ? '1' : '0', GO::user()->user_id);
GO::config()->save_setting('email_always_request_notification', isset($params['always_request_notification']) ? '1' : '0', GO::user()->user_id);
GO::config()->save_setting('email_always_respond_to_notifications', isset($params['always_respond_to_notifications']) ? '1' : '0', GO::user()->user_id);
GO::config()->save_setting('email_font_size', $params['font_size'], GO::user()->user_id);
return parent::submitSettings($settingsController, $params, $response, $user);
}
public static function reminderDisplay($controller, &$html, $params){
if(!empty($params['unseenEmails']))
$html .= '<p>'.str_replace('{new}', $params['unseenEmails'], GO::t('youHaveNewMails','email')).'</p>';
}
}