XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
RegistMailBuilder.class.php
1<?php
7
8if (!defined('XOOPS_ROOT_PATH')) {
9 exit();
10}
11
12/***
13 * @internal
14 * This class commands a builder to build mail. It's a kind of builder pattern,
15 * and made for separating the building logic and the business logic.
16 */
18{
19 /***
20 * @var User_RegistUserActivateMailBuilder
21 */
22 public $mBuilder;
23
24 /***
25 * @var XoopsUser
26 */
27 public $mUser;
28
29 public $mXoopsConfig;
30
31 public $mUserConfig;
32
33 public function __construct(&$builder, &$user, $xoopsConfig, $userConfig)
34 {
35 $this->mBuilder = &$builder;
36
37 $this->mUser = &$user;
38 $this->mXoopsConfig = $xoopsConfig;
39 $this->mUserConfig = $userConfig;
40 }
41
42 /***
43 * With setting variables to a builder, triggers building the mail of a
44 * builder.
45 */
46 public function contruct()
47 {
48 $this->mBuilder->setTemplate();
49 $this->mBuilder->setToUsers($this->mUser, $this->mUserConfig);
50 $this->mBuilder->setFromEmail($this->mXoopsConfig);
51 $this->mBuilder->setSubject($this->mUser, $this->mXoopsConfig);
52 $this->mBuilder->setBody($this->mUser, $this->mXoopsConfig);
53 }
54}
55
56/***
57 * @internal
58 * This class is a builder for User_UserRegistMailDirector and the base class,
59 * and the base class for other builders. Use register.tpl as the template.
60 * That's the first mail at procedure of the user registration, and written
61 * about the special URL which activates the registration application.
62 */
64{
65 public $mMailer;
66
67 public function __construct()
68 {
69 $this->mMailer = &getMailer();
70 $this->mMailer->useMail();
71 }
72
73 /***
74 * Set the template itself.
75 */
76 public function setTemplate()
77 {
78 $root = &XCube_Root::getSingleton();
79 $language = $root->mContext->getXoopsConfig('language');
80 $this->mMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/user/language/' . $language . '/mail_template/');
81 $this->mMailer->setTemplate('register.tpl');
82 }
83
84 public function setToUsers($user, $userConfig)
85 {
86 $this->mMailer->setToUsers($user);
87 }
88
89 public function setFromEmail($xoopsConfig)
90 {
91 $this->mMailer->setFromEmail(defined('XOOPS_NOTIFY_FROM_EMAIL') ? XOOPS_NOTIFY_FROM_EMAIL : $xoopsConfig['adminmail']);
92 $this->mMailer->setFromName(defined('XOOPS_NOTIFY_FROM_NAME') ? XOOPS_NOTIFY_FROM_NAME : $xoopsConfig['sitename']);
93 }
94
95 public function setSubject($user, $xoopsConfig)
96 {
97 $this->mMailer->setSubject(@sprintf(_MD_USER_LANG_USERKEYFOR, $user->getShow('uname')));
98 }
99
100 public function setBody($user, $xoopsConfig)
101 {
102 $this->mMailer->assign('SITENAME', $xoopsConfig['sitename']);
103 $this->mMailer->assign('ADMINMAIL', (!defined('XOOPS_NOTIFY_FROM_EMAIL') || XOOPS_NOTIFY_FROM_EMAIL === $xoopsConfig['adminmail']) ? $xoopsConfig['adminmail'] : '');
104 $this->mMailer->assign('SITEURL', XOOPS_URL . '/');
105 $this->mMailer->assign('USERACTLINK', XOOPS_URL . '/user.php?op=actv&uid=' . $user->getVar('uid') . '&actkey=' . $user->getShow('actkey'));
106 }
107
108 public function &getResult()
109 {
110 return $this->mMailer;
111 }
112}
113
114/***
115 * @internal
116 * This class is a builder which uses adminactivate.tpl as the template. The
117 * mail which this class builds, requests activating the new registration for
118 * administrators.
119 */
121{
122 public function setTemplate()
123 {
124 $root = &XCube_Root::getSingleton();
125 $language = $root->mContext->getXoopsConfig('language');
126 $this->mMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/user/language/' . $language . '/mail_template/');
127 $this->mMailer->setTemplate('adminactivate.tpl');
128 }
129
130 public function setToUsers($user, $userConfig)
131 {
132 $memberHandler = &xoops_gethandler('member');
133 $this->mMailer->setToGroups($memberHandler->getGroup($userConfig['activation_group']));
134 }
135
136 public function setFromUser($xoopsConfig)
137 {
138 $this->mMailer->setFromEmail(defined('XOOPS_NOTIFY_FROM_EMAIL') ? XOOPS_NOTIFY_FROM_EMAIL : $xoopsConfig['adminmail']);
139 $this->mMailer->setFromName(defined('XOOPS_NOTIFY_FROM_NAME') ? XOOPS_NOTIFY_FROM_NAME : $xoopsConfig['sitename']);
140 }
141
142 public function setSubject($user, $xoopsConfig)
143 {
144 $this->mMailer->setSubject(@sprintf(_MD_USER_LANG_USERKEYFOR, $user->getVar('uname')));
145 }
146
147 public function setBody($user, $xoopsConfig)
148 {
149 parent::setBody($user, $xoopsConfig);
150 $this->mMailer->assign('USERNAME', $user->getVar('uname'));
151 $this->mMailer->assign('USEREMAIL', $user->getVar('email'));
152 $this->mMailer->assign('USERACTLINK', XOOPS_URL . '/user.php?op=actv&uid=' . $user->getVar('uid') . '&actkey=' . $user->getVar('actkey'));
153 }
154}
155
156/***
157 * @internal
158 * [Notice]
159 * Uncompleted?
160 *
161 * @todo Implement setTemplate()
162 */
164{
165 public function setTemplate()
166 { }
167
168 public function setToUsers($user, $userConfig)
169 {
170 $memberHandler = &xoops_gethandler('member');
171 $this->mMailer->setToGroups($memberHandler->getGroup($userConfig['new_user_notify_group']));
172 }
173
174 public function setSubject($user, $xoopsConfig)
175 {
176 $this->mMailer->setSubject(@sprintf(_MD_USER_LANG_NEWUSERREGAT, $xoopsConfig['sitename']));
177 }
178
179 public function setBody($user, $xoopsConfig)
180 {
181 $this->mMailer->setBody(@sprintf(_MD_USER_LANG_HASJUSTREG, $user->getVar('uname')));
182 }
183}
184
185/***
186 * @internal
187 * This class is a builder which uses activated.tpl as the template. The mail
188 * which this class builds, reports completed activation for a new user.
189 */
191{
192 public function setTemplate()
193 {
194 $root = &XCube_Root::getSingleton();
195 $language = $root->mContext->getXoopsConfig('language');
196 $this->mMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/user/language/' . $language . '/mail_template/');
197 $this->mMailer->setTemplate('activated.tpl');
198 }
199
200 public function setSubject($user, $xoopsConfig)
201 {
202 $this->mMailer->setSubject(@sprintf(_MD_USER_LANG_YOURACCOUNT, $xoopsConfig['sitename']));
203 }
204}