/** * @see Form::save() */ public function save() { parent::save(); // generate new password $this->newPassword = UserRegistrationUtil::getNewPassword(REGISTER_PASSWORD_MIN_LENGTH > 9 ? REGISTER_PASSWORD_MIN_LENGTH : 9); // update user $this->user->update('', '', $this->newPassword, null, null, array('lastLostPasswordRequest' => 0, 'lostPasswordKey' => '')); // send mail $subjectData = array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE)); $messageData = array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE), '$username' => $this->user->username, '$userID' => $this->user->userID, '$newPassword' => $this->newPassword, 'PAGE_URL' => PAGE_URL, 'MAIL_ADMIN_ADDRESS' => MAIL_ADMIN_ADDRESS); require_once WCF_DIR . 'lib/data/mail/Mail.class.php'; $mail = new Mail(array($this->user->username => $this->user->email), WCF::getLanguage()->get('wcf.user.lostPassword.newPassword.mail.subject', $subjectData), WCF::getLanguage()->get('wcf.user.lostPassword.newPassword.mail', $messageData)); $mail->send(); $this->saved(); // show result page WCF::getTPL()->assign(array('url' => 'index.php' . SID_ARG_1ST, 'message' => WCF::getLanguage()->get('wcf.user.lostPassword.success'))); WCF::getTPL()->display('redirect'); exit; }
/** * @see Action::execute() */ public function execute() { AbstractAction::execute(); // check permission WCF::getUser()->checkPermission('admin.user.canEnableUser'); if (count($this->userIDs) > 0) { // check permission $sql = "SELECT\tDISTINCT groupID\n\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDs) . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (!Group::isAccessibleGroup($row['groupID'])) { throw new PermissionDeniedException(); } } // update groups $sql = "DELETE FROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE\t\tuserID IN (" . implode(',', $this->userIDs) . ")\n\t\t\t\t\t\tAND groupID <> " . Group::getGroupIdByType(Group::EVERYONE); WCF::getDB()->sendQuery($sql); $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\t\t(userID, groupID)\n\t\t\t\tVALUES\t\t\t(" . implode(', ' . Group::getGroupIdByType(Group::GUESTS) . '),(', $this->userIDs) . ", '" . Group::getGroupIdByType(Group::GUESTS) . "')"; WCF::getDB()->sendQuery($sql); // update activation code foreach ($this->userIDs as $userID) { $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\t\tSET\tactivationCode = " . UserRegistrationUtil::getActivationCode() . "\n\t\t\t\t\tWHERE\tuserID = " . $userID; WCF::getDB()->sendQuery($sql); } // unmark users UserEditor::unmarkAll(); // reset sessions Session::resetSessions($this->userIDs); } $this->executed(); if (!empty($this->url)) { HeaderUtil::redirect($this->url); } else { // set active menu item WCFACP::getMenu()->setActiveMenuItem('wcf.acp.menu.link.user.management'); // show succes message WCF::getTPL()->assign('message', 'wcf.acp.user.disable.success'); WCF::getTPL()->display('success'); } exit; }
/** * @see Form::save() */ public function save() { AbstractForm::save(); // generate activation code $activationCode = UserRegistrationUtil::getActivationCode(); $fields = array('reactivationCode' => $activationCode); if (!empty($this->email)) { $fields['newEmail'] = $this->email; } // save user $this->user->update('', '', '', null, null, $fields); // send activation mail $subjectData = array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE)); $messageData = array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE), '$username' => $this->user->username, '$userID' => $this->user->userID, '$activationCode' => $activationCode, 'PAGE_URL' => PAGE_URL, 'MAIL_ADMIN_ADDRESS' => MAIL_ADMIN_ADDRESS); require_once WCF_DIR . 'lib/data/mail/Mail.class.php'; $mail = new Mail(array($this->user->username => !empty($this->email) ? $this->email : $this->user->email), WCF::getLanguage()->get('wcf.user.emailChange.needReactivation.mail.subject', $subjectData), WCF::getLanguage()->get('wcf.user.emailChange.needReactivation.mail', $messageData)); $mail->send(); $this->saved(); // forward to index page WCF::getTPL()->assign(array('url' => 'index.php' . SID_ARG_1ST, 'message' => WCF::getLanguage()->get('wcf.user.emailChange.needReactivation'))); WCF::getTPL()->display('redirect'); exit; }
/** * @see Form::save() */ public function save() { AbstractForm::save(); // save language id $this->additionalFields['languageID'] = $this->languageID; // save registration ip address $this->additionalFields['registrationIpAddress'] = WCF::getSession()->ipAddress; // generate activation code $addDefaultGroups = true; if (REGISTER_ACTIVATION_METHOD == 1 || REGISTER_ACTIVATION_METHOD == 2) { $activationCode = UserRegistrationUtil::getActivationCode(); $this->additionalFields['activationCode'] = $activationCode; $addDefaultGroups = false; $this->groupIDs = Group::getGroupIdsByType(array(Group::EVERYONE, Group::GUESTS)); } // create $this->user = UserEditor::create($this->username, $this->email, $this->password, $this->groupIDs, $this->activeOptions, $this->additionalFields, $this->visibleLanguages, $addDefaultGroups); // update session WCF::getSession()->changeUser($this->user); // activation management if (REGISTER_ACTIVATION_METHOD == 0) { $this->message = 'wcf.user.register.success'; } if (REGISTER_ACTIVATION_METHOD == 1) { $mail = new Mail(array($this->username => $this->email), WCF::getLanguage()->get('wcf.user.register.needActivation.mail.subject', array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE))), WCF::getLanguage()->get('wcf.user.register.needActivation.mail', array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE), '$username' => $this->username, '$userID' => $this->user->userID, '$activationCode' => $activationCode, 'PAGE_URL' => PAGE_URL, 'MAIL_ADMIN_ADDRESS' => MAIL_ADMIN_ADDRESS))); $mail->send(); $this->message = 'wcf.user.register.needActivation'; } if (REGISTER_ACTIVATION_METHOD == 2) { $this->message = 'wcf.user.register.awaitActivation'; } // notify admin if (REGISTER_ADMIN_NOTIFICATION) { // get default language $language = WCF::getLanguage()->getLanguageID() != Language::getDefaultLanguageID() ? new Language(Language::getDefaultLanguageID()) : WCF::getLanguage(); $language->setLocale(); // send mail $mail = new Mail(MAIL_ADMIN_ADDRESS, $language->get('wcf.user.register.notification.mail.subject', array('PAGE_TITLE' => $language->get(PAGE_TITLE))), $language->get('wcf.user.register.notification.mail', array('PAGE_TITLE' => $language->get(PAGE_TITLE), '$username' => $this->username))); $mail->send(); WCF::getLanguage()->setLocale(); } // delete captcha if (REGISTER_USE_CAPTCHA && !WCF::getSession()->getVar('captchaDone')) { $this->captcha->delete(); } WCF::getSession()->unregister('captchaDone'); // login user UserAuth::getInstance()->storeAccessData($this->user, $this->username, $this->password); $this->saved(); // forward to index page WCF::getTPL()->assign(array('url' => 'index.php' . SID_ARG_1ST, 'message' => WCF::getLanguage()->get($this->message, array('$username' => $this->username, '$email' => $this->email)))); WCF::getTPL()->display('redirect'); exit; }
/** * @see Form::save() */ public function save() { parent::save(); // get user editor $editor = WCF::getUser()->getEditor(); $success = array(); // quit if (WCF::getUser()->getPermission('user.profile.canQuit')) { if (!WCF::getUser()->quitStarted && $this->quit == 1) { $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\t\tSET\tquitStarted = " . TIME_NOW . "\n\t\t\t\t\tWHERE\tuserID = " . WCF::getUser()->userID; WCF::getDB()->sendQuery($sql); $this->quitStarted = TIME_NOW; $success[] = 'wcf.user.quit.success'; } else { if (WCF::getUser()->quitStarted && $this->cancelQuit == 1) { $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\t\tSET\tquitStarted = 0\n\t\t\t\t\tWHERE\tuserID = " . WCF::getUser()->userID; WCF::getDB()->sendQuery($sql); $this->quitStarted = 0; $success[] = 'wcf.user.quit.cancel.success'; } } } // username if ($this->canChangeUsername && $this->username != WCF::getUser()->username) { $fields = array(); if (StringUtil::toLowerCase($this->username) != StringUtil::toLowerCase(WCF::getUser()->username)) { if (!$this->canChangeUsername) { $this->username = WCF::getUser()->username; return; } $fields = array('lastUsernameChange' => TIME_NOW, 'oldUsername' => $editor->username); } $editor->update($this->username, '', '', null, null, $fields); $success[] = 'wcf.user.rename.success'; } // email if (WCF::getUser()->getPermission('user.profile.canChangeEmail') && $this->email != WCF::getUser()->email && $this->email != WCF::getUser()->newEmail) { if (REGISTER_ACTIVATION_METHOD == 0 || REGISTER_ACTIVATION_METHOD == 2 || StringUtil::toLowerCase($this->email) == StringUtil::toLowerCase(WCF::getUser()->email)) { // update email $editor->update('', $this->email); $success[] = 'wcf.user.emailChange.success'; } else { if (REGISTER_ACTIVATION_METHOD == 1) { // get reactivation code $activationCode = UserRegistrationUtil::getActivationCode(); // save as new email $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\t\tSET\treactivationCode = " . $activationCode . ",\n\t\t\t\t\t\tnewEmail = '" . escapeString($this->email) . "'\n\t\t\t\t\tWHERE\tuserID = " . WCF::getUser()->userID; WCF::getDB()->registerShutdownUpdate($sql); $subjectData = array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE)); $messageData = array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE), '$username' => WCF::getUser()->username, '$userID' => WCF::getUser()->userID, '$activationCode' => $activationCode, 'PAGE_URL' => PAGE_URL, 'MAIL_ADMIN_ADDRESS' => MAIL_ADMIN_ADDRESS); require_once WCF_DIR . 'lib/data/mail/Mail.class.php'; $mail = new Mail(array(WCF::getUser()->username => $this->email), WCF::getLanguage()->get('wcf.user.emailChange.needReactivation.mail.subject', $subjectData), WCF::getLanguage()->get('wcf.user.emailChange.needReactivation.mail', $messageData)); $mail->send(); $success[] = 'wcf.user.emailChange.needReactivation'; } } } // password if (!empty($this->newPassword) || !empty($this->confirmNewPassword)) { $editor->update('', '', $this->newPassword); // update cookie if (isset($_COOKIE[COOKIE_PREFIX . 'password'])) { HeaderUtil::setCookie('password', StringUtil::getSaltedHash($this->newPassword, $editor->salt), TIME_NOW + 365 * 24 * 3600); } $success[] = 'wcf.user.passwordChange.success'; } // reset session WCF::getSession()->resetUserData(); $this->saved(); // show success message WCF::getTPL()->assign('success', $success); // reset password $this->password = ''; $this->newPassword = $this->confirmNewPassword = ''; }
/** * Creates a new invitation * * @return integer invitation id */ public static function create($email) { $sql = "INSERT \n\t\t\tINTO\twcf" . WCF_N . "_user_invitation\n\t\t\t\t(time, senderID, email, code)\n\t\t\tVALUES\n\t\t\t\t(" . TIME_NOW . ", " . WCF::getUser()->userID . ", '" . escapeString(StringUtil::toLowerCase($email)) . "', " . UserRegistrationUtil::getActivationCode() . ")"; WCF::getDB()->sendQuery($sql); return new Invitation(WCF::getDB()->getInsertID()); }
protected function validateEmail($email) { if (!UserRegistrationUtil::isValidEmail($email)) { throw new UserInputException('email', 'notValid'); } if (!UserUtil::isAvailableEmail($email)) { throw new UserInputException('email', 'alreadyUsed'); } }