XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
UserRegisterAction.class.php
1<?php
7
8if (!defined('XOOPS_ROOT_PATH')) {
9 exit();
10}
11
12require_once XOOPS_MODULE_PATH . '/user/forms/UserRegisterEditForm.class.php';
13
14/***
15 * @internal
16 * @public
17 * This action uses the special technic to realize confirming. It set the
18 * register action form to Session through serialize(), then forward to the
19 * confirm action. Because the confirm action can't work without the register
20 * action form which it fetches from Session, the confim action doesn't need
21 * to check the permission to register.
22 */
23class User_UserRegisterAction extends User_Action
24{
25 public $mActionForm = null;
26 public $mConfig;
27 public $mEnableAgreeFlag = false;
28
29 public function prepare(&$controller, &$xoopsUser, $moduleConfig)
30 {
31 $this->mConfig = $moduleConfig;
32
33 if (is_object($xoopsUser)) {
34 //
35 // If user is registered, kick to his information page.
36 //
37 $controller->executeForward(XOOPS_URL . '/user.php');
38 }
39 if (empty($this->mConfig['allow_register'])) {
40 $controller->executeRedirect(XOOPS_URL . '/', 6, _MD_USER_LANG_NOREGISTER);
41 }
42 }
43
44 public function execute(&$controller, &$xoopsUser)
45 {
46 $this->_processActionForm();
47 $this->mActionForm->fetch();
48 $this->mActionForm->validate();
49
50 XCube_DelegateUtils::call('Legacy.Event.RegistUser.Validate', new XCube_Ref($this->mActionForm));
51
52 if ($this->mActionForm->hasError()) {
53 return USER_FRAME_VIEW_INPUT;
54 } else {
55 $_SESSION['user_register_actionform'] = serialize($this->mActionForm);
56 $controller->executeForward('./register.php?action=confirm');
57 }
58 }
59
60 public function getDefaultView(&$controller, &$xoopsUser)
61 {
62 $this->_processActionForm();
63 return USER_FRAME_VIEW_INPUT;
64 }
65
66 public function _processActionForm()
67 {
68 if (isset($_SESSION['user_register_actionform'])) {
69 $this->mActionForm = unserialize($_SESSION['user_register_actionform']);
70 unset($_SESSION['user_register_actionform']);
71 return;
72 }
73
74 if (0 != $this->mConfig['reg_dispdsclmr'] && null != $this->mConfig['reg_disclaimer']) {
75 $this->mEnableAgreeFlag = true;
76 $this->mActionForm =new User_RegisterAgreeEditForm($this->mConfig);
77 } else {
78 $this->mActionForm =new User_RegisterEditForm($this->mConfig);
79 }
80
81 $this->mActionForm->prepare();
82
83 $root =& XCube_Root::getSingleton();
84 $this->mActionForm->set('timezone_offset', $root->mContext->getXoopsConfig('default_TZ'));
85 }
86
92 public function executeViewInput(&$controller, &$xoopsUser, &$renderSystem)
93 {
94 $renderSystem->setTemplateName('user_register_form.html');
95 //
96 // Get some objects for input form.
97 //
98 $tzoneHandler =& xoops_gethandler('timezone');
99 $timezones =& $tzoneHandler->getObjects();
100 $renderSystem->setAttribute('timezones', $timezones);
101 $renderSystem->setAttribute('actionForm', $this->mActionForm);
102 $renderSystem->setAttribute('enableAgree', $this->mEnableAgreeFlag);
103 if ($this->mEnableAgreeFlag) {
104 $renderSystem->setAttribute('disclaimer', $this->mConfig['reg_disclaimer']);
105 }
106
107 $validators = [];
108 //
109 // set `$validators[] = array('caption' => 'Any Caption HTML', 'element' => 'Form element HTML');` in the preload function.
110 //
111 XCube_DelegateUtils::call('Legacy.Event.RegistUser.SetValidators', new XCube_Ref($validators));
112 $renderSystem->setAttribute('validators', $validators);
113 }
114}
executeViewInput(&$controller, &$xoopsUser, &$renderSystem)