XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
UserRegister_confirmAction.class.php
1<?php
7
8if (!defined('XOOPS_ROOT_PATH')) {
9 exit();
10}
11
12require_once XOOPS_MODULE_PATH . '/user/forms/UserConfirmForm.class.php';
13require_once XOOPS_MODULE_PATH . '/user/forms/UserRegisterEditForm.class.php';
14require_once XOOPS_MODULE_PATH . '/user/class/RegistMailBuilder.class.php';
15
16/***
17 * @internal
18 * This action uses the special technic to realize confirming. It gets the
19 * register action form which has been inputted in UserRegister, through
20 * unserialize(). And, it uses a simple action form to confirm lastly.
21 */
22class User_UserRegister_confirmAction extends User_Action
23{
24 public $mActionForm = null;
25 public $mRegistForm = null;
26 public $mConfig = null;
27
28 public $mNewUser = null;
29
30 public $mRedirectMessage = null;
31
32 /***
33 * TODO this member function uses the old style delegate.
34 * @param $controller
35 * @param $xoopsUser
36 * @param $moduleConfig
37 */
38 public function prepare(&$controller, &$xoopsUser, $moduleConfig)
39 {
40 $this->mConfig = $moduleConfig;
41
42 $this->_getRegistForm($controller);
43 $this->_processActionForm();
44 }
45
46 public function execute(&$controller, &$xoopsUser)
47 {
48 if (null != XCube_Root::getSingleton()->mContext->mRequest->getRequest('_form_control_cancel')) {
49 return USER_FRAME_VIEW_CANCEL;
50 }
51
52 $memberHandler =& xoops_gethandler('member');
53 $this->mNewUser =& $memberHandler->createUser();
54 $this->mRegistForm->update($this->mNewUser);
55 $this->mNewUser->set('uorder', $controller->mRoot->mContext->getXoopsConfig('com_order'), true);
56 $this->mNewUser->set('umode', $controller->mRoot->mContext->getXoopsConfig('com_mode'), true);
57 if (1 == $this->mConfig['activation_type']) {
58 $this->mNewUser->set('level', 1, true);
59 }
60
61 if (!$memberHandler->insertUser($this->mNewUser)) {
62 $this->mRedirectMessage = _MD_USER_LANG_REGISTERNG;
63 return USER_FRAME_VIEW_ERROR;
64 }
65
66 if (!$memberHandler->addUserToGroup(XOOPS_GROUP_USERS, $this->mNewUser->get('uid'))) {
67 $this->mRedirectMessage = _MD_USER_LANG_REGISTERNG;
68 return USER_FRAME_VIEW_ERROR;
69 }
70
71 $this->_clearRegistForm($controller);
72
73 $this->_processMail($controller);
74 $this->_eventNotifyMail($controller);
75
76 XCube_DelegateUtils::call('Legacy.Event.RegistUser.Success', new XCube_Ref($this->mNewUser));
77
78 return USER_FRAME_VIEW_SUCCESS;
79 }
80
81 public function getDefaultView(&$controller, &$xoopsUser)
82 {
83 return USER_FRAME_VIEW_INPUT;
84 }
85
86 /***
87 * Get regist actionform from Session and set it to the member property.
88 * @access private
89 * @param $controller
90 */
91 public function _getRegistForm(&$controller)
92 {
93 $this->mRegistForm = unserialize($_SESSION['user_register_actionform']);
94 if (!is_object($this->mRegistForm)) {
95 $controller->executeForward('./register.php?action=UserRegister');
96 }
97 }
98
99 /***
100 * Clear session.
101 * @access private
102 * @param $controller
103 */
104 public function _clearRegistForm(&$controller)
105 {
106 unset($_SESSION['user_register_actionform']);
107 }
108
109 public function _processMail(&$controller)
110 {
111 $activationType = $this->mConfig['activation_type'];
112
113 if (1 == $activationType) {
114 return;
115 }
116
117 // Wmm..
118 $builder = (0 == $activationType) ? new User_RegistUserActivateMailBuilder()
120
121 $director =new User_UserRegistMailDirector($builder, $this->mNewUser, $controller->mRoot->mContext->getXoopsConfig(), $this->mConfig);
122 $director->contruct();
123 $mailer =& $builder->getResult();
124 XCube_DelegateUtils::call('Legacy.Event.RegistUser.SendMail', new XCube_Ref($mailer), (0 == $activationType)? 'Register' : 'AdminActivate');
125
126 if (!$mailer->send()) {
127 // TODO CHECKS and use '_MD_USER_ERROR_YOURREGMAILNG'
128 }
129 }
130
131 public function _eventNotifyMail(&$controller)
132 {
133 if (1 == $this->mConfig['new_user_notify'] && !empty($this->mConfig['new_user_notify_group'])) {
134 $builder =new User_RegistUserNotifyMailBuilder();
135 $director =new User_UserRegistMailDirector($builder, $this->mNewUser, $controller->mRoot->mContext->getXoopsConfig(), $this->mConfig);
136 $director->contruct();
137 $mailer =& $builder->getResult();
138 XCube_DelegateUtils::call('Legacy.Event.RegistUser.SendMail', new XCube_Ref($mailer), 'Notify');
139 $mailer->send();
140 }
141 }
142
143 public function _processActionForm()
144 {
145 $this->mActionForm =new User_UserConfirmForm();
146 $this->mActionForm->prepare();
147 }
148
149 public function executeViewError(&$controller, &$xoopsUser, &$render)
150 {
151 $controller->executeRedirect(XOOPS_URL . '/', 1, $this->mRedirectMessage);
152 }
153
163 public function executeViewCancel(&$controller, &$xoopsUser, &$render)
164 {
165 $controller->executeForward(XOOPS_URL.'/register.php');
166 }
167
168 public function executeViewInput(&$controller, &$xoopsUser, &$render)
169 {
170 $render->setTemplateName('user_register_confirm.html');
171 $render->setAttribute('actionForm', $this->mActionForm);
172 $render->setAttribute('registForm', $this->mRegistForm);
173 }
174
175 public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
176 {
177 $activationType = $this->mConfig['activation_type'];
178
179 if (0 == $activationType) {
180 $render->setTemplateName('user_register_finish.html');
181 $render->setAttribute('complete_message', _MD_USER_MESSAGE_YOURREGISTERED);
182 } elseif (1 == $activationType) {
183 $controller->executeRedirect(XOOPS_URL . '/', 4, _MD_USER_MESSAGE_ACTLOGIN);
184 } elseif (2 == $activationType) {
185 $render->setTemplateName('user_register_finish.html');
186 $render->setAttribute('complete_message', _MD_USER_MESSAGE_YOURREGISTERED2);
187 } else {
188 //
189 // This case is never.
190 //
191 $render->setTemplateName('user_register_finish.html');
192 $render->setAttribute('complete_message', _MD_USER_MESSAGE_YOURREGISTERED2);
193 }
194 }
195}
executeViewCancel(&$controller, &$xoopsUser, &$render)