28 public $mActionForm =
null;
30 public function prepare(&$controller, &$xoopsUser, $moduleConfig)
33 $this->mActionForm->prepare();
36 public function isSecure()
42 public function hasPermission(&$controller, &$xoopsUser, $moduleConfig)
44 return !$controller->mRoot->mContext->mUser->mIdentity->isAuthenticated();
47 public function getDefaultView(&$controller, &$xoopsUser)
49 $root =& XCube_Root::getSingleton();
50 $code = $root->mContext->mRequest->getRequest(
'code');
51 $email = $root->mContext->mRequest->getRequest(
'email');
52 if (0 == strlen($code) || 0 == strlen($email)) {
53 return USER_FRAME_VIEW_INPUT;
55 return $this->_updatePassword($controller);
59 public function _updatePassword(&$controller)
62 $this->mActionForm->fetch();
64 $userHandler =& xoops_gethandler(
'user');
66 $criteria->add(
new Criteria(
'pass', $this->mActionForm->get(
'code'),
'=',
'',
'LEFT(%s, 5)'));
67 $lostUserArr =& $userHandler->getObjects($criteria);
69 if (is_array($lostUserArr) && count($lostUserArr) > 0) {
70 $lostUser =& $lostUserArr[0];
72 return USER_FRAME_VIEW_ERROR;
75 $newpass = xoops_makepass();
76 $extraVars[
'newpass'] = $newpass;
79 if (!$userHandler->insert($lostUser,
true)) {
80 return USER_FRAME_VIEW_ERROR;
85 $getXConfig = $controller->mRoot->mContext->getXoopsConfig();
89 $director->contruct();
90 $xoopsMailer =& $builder->getResult();
91 XCube_DelegateUtils::call(
'Legacy.Event.RegistUser.SendMail',
new XCube_Ref($xoopsMailer),
'LostPass2');
92 if (!$xoopsMailer->send()) {
94 return USER_FRAME_VIEW_ERROR;
97 return USER_FRAME_VIEW_SUCCESS;
100 public function execute(&$controller, &$xoopsUser)
102 $this->mActionForm->fetch();
103 $this->mActionForm->validate();
105 if ($this->mActionForm->hasError()) {
106 return USER_FRAME_VIEW_INPUT;
109 $userHandler =& xoops_gethandler(
'user');
110 $lostUserArr =& $userHandler->getObjects(
new Criteria(
'email', $this->mActionForm->get(
'email')));
112 if (is_array($lostUserArr) && (count($lostUserArr) > 0) ) {
113 $lostUser =& $lostUserArr[0];
115 return USER_FRAME_VIEW_ERROR;
121 $root =& XCube_Root::getSingleton();
122 $getXConfig = $root->mContext->getXoopsConfig();
126 $director->contruct();
127 $xoopsMailer =& $builder->getResult();
128 XCube_DelegateUtils::call(
'Legacy.Event.RegistUser.SendMail',
new XCube_Ref($xoopsMailer),
'LostPass1');
130 if (!$xoopsMailer->send()) {
132 return USER_FRAME_VIEW_ERROR;
135 return USER_FRAME_VIEW_SUCCESS;
138 public function executeViewInput(&$controller, &$xoopsUser, &$render)
140 $render->setTemplateName(
'user_lostpass.html');
141 $render->setAttribute(
'actionForm', $this->mActionForm);
144 public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
146 $controller->executeRedirect(XOOPS_URL .
'/', 3, _MD_USER_MESSAGE_SEND_PASSWORD);
149 public function executeViewError(&$controller, &$xoopsUser, &$render)
151 $controller->executeRedirect(XOOPS_URL .
'/', 3, _MD_USER_ERROR_SEND_MAIL);