/** * @see \wcf\form\IForm::save() */ public function save() { AbstractForm::save(); // set cookies if ($this->useCookies == 1) { UserAuthenticationFactory::getInstance()->getUserAuthentication()->storeAccessData($this->user, $this->username, $this->password); } $oldSessionID = WCF::getSession()->sessionID; // change user WCF::getSession()->changeUser($this->user); // get redirect url $this->checkURL(); $this->saved(); if (isset($_REQUEST['s']) && $_REQUEST['s'] == $oldSessionID && $oldSessionID != WCF::getSession()->sessionID) { // force instant redirect to avoid issues with non-cookie login and the already defined SID_ARG_* constants if (preg_match('~[?&]s=[a-f0-9]{40}~i', $this->url)) { $this->url = preg_replace('~([?&])s=[a-f0-9]{40}~i', '$1s=' . WCF::getSession()->sessionID, $this->url); } else { $this->url .= mb_strpos($this->url, '?') === false ? '?' : '&'; $this->url .= 's=' . WCF::getSession()->sessionID; } HeaderUtil::redirect($this->url); exit; } // redirect to url WCF::getTPL()->assign('__hideUserMenu', true); HeaderUtil::delayedRedirect($this->url, WCF::getLanguage()->get('wcf.user.login.redirect')); exit; }
/** * @see wcf\action\IAction::execute() */ public function execute() { parent::execute(); // mark as trashed $this->statementAction = new UserJcoinsStatementAction($this->statementList->objectIDs, 'trashAll'); $this->statementAction->executeAction(); $this->statementAction = new UserJcoinsStatementAction(array(), 'create', array('data' => array('reason' => 'wcf.jcoins.summaryOfAccountBalances', 'sum' => WCF::getUser()->jCoinsBalance, 'time' => TIME_NOW, 'userID' => WCF::getUser()->userID))); $this->statementAction->executeAction(); $this->executed(); $url = LinkHandler::getInstance()->getLink('OwnCoinsStatement'); HeaderUtil::delayedRedirect($url, WCF::getLanguage()->get('wcf.jcoins.statement.successfullsumup')); exit; }
/** * @see \wcf\form\IForm::save() */ public function save() { AbstractForm::save(); // generate activation code $activationCode = UserRegistrationUtil::getActivationCode(); // save user $this->objectAction = new UserAction(array($this->user), 'update', array('data' => array_merge($this->additionalFields, array('reactivationCode' => $activationCode)))); $this->objectAction->executeAction(); // send activation mail $messageData = array('username' => $this->user->username, 'userID' => $this->user->userID, 'activationCode' => $activationCode); $mail = new Mail(array($this->user->username => $this->user->newEmail), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail', $messageData)); $mail->send(); $this->saved(); // forward to index page HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation'), 10); exit; }
/** * @see \wcf\action\IAction::execute() */ public function execute() { AbstractSecureAction::execute(); // do logout WCF::getSession()->delete(); // remove cookies if (isset($_COOKIE[COOKIE_PREFIX . 'userID'])) { HeaderUtil::setCookie('userID', 0); } if (isset($_COOKIE[COOKIE_PREFIX . 'password'])) { HeaderUtil::setCookie('password', ''); } $this->executed(); // forward to index page HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->get('wcf.user.logout.redirect')); exit; }
/** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); // save file $data = array_merge($this->additionalFields, array('entryID' => $this->entryID, 'uploadTime' => TIME_NOW, 'subject' => $this->subject, 'description' => $this->text, 'isDisabled' => WCF::getSession()->getPermission('user.filebase.canAddEntryWithoutModeration') ? 0 : 1)); $fileData = array('data' => $data, 'entry' => $this->entry, 'fileUpload' => $this->fileUpload); $this->objectAction = new EntryFileAction(array(), 'create', $fileData); $resultValues = $this->objectAction->executeAction(); $this->saved(); if ($resultValues['returnValues']->isDisabled) { HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink('FilebaseOverview', array('application' => 'filebase')), WCF::getLanguage()->get('filebase.entry.file.moderation.redirect'), 30); } else { HeaderUtil::redirect(LinkHandler::getInstance()->getLink('Entry', array('application' => 'filebase', 'object' => $this->entry))); } exit; }
/** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); // enable user $this->objectAction = new UserAction(array($this->user), 'enable', array('skipNotification' => true)); $this->objectAction->executeAction(); $this->saved(); // forward to index page HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->get('wcf.user.registerActivation.success'), 10); exit; }
/** * @see \wcf\action\IAction::execute() */ public function execute() { parent::execute(); if ($this->event !== null) { $sql = "UPDATE\twcf" . WCF_N . "_user_notification_event_to_user\n\t\t\t\tSET\tmailNotificationType = ?\n\t\t\t\tWHERE\tuserID = ?\n\t\t\t\t\tAND eventID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array('none', $this->userID, $this->eventID)); } else { $sql = "UPDATE\twcf" . WCF_N . "_user_notification_event_to_user\n\t\t\t\tSET\tmailNotificationType = ?\n\t\t\t\tWHERE\tuserID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array('none', $this->userID)); } $this->executed(); // redirect to url HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->get('wcf.user.notification.mail.disabled')); exit; }
/** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); // enable new email $this->objectAction = new UserAction(array($this->user), 'update', array('data' => array_merge($this->additionalFields, array('email' => $this->user->newEmail, 'newEmail' => '', 'reactivationCode' => 0)))); $this->objectAction->executeAction(); $this->saved(); // forward to index page HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->get('wcf.user.emailActivation.success')); exit; }
/** * @see \wcf\form\IForm::save() */ public function save() { AbstractForm::save(); // get options $saveOptions = $this->optionHandler->save(); $registerVia3rdParty = false; $avatarURL = ''; if ($this->isExternalAuthentication) { switch (WCF::getSession()->getVar('__3rdPartyProvider')) { case 'github': // GitHub if (WCF::getSession()->getVar('__githubData')) { $githubData = WCF::getSession()->getVar('__githubData'); $this->additionalFields['authData'] = 'github:' . WCF::getSession()->getVar('__githubToken'); WCF::getSession()->unregister('__githubData'); WCF::getSession()->unregister('__githubToken'); if (WCF::getSession()->getVar('__email') && WCF::getSession()->getVar('__email') == $this->email) { $registerVia3rdParty = true; } if (isset($githubData['bio']) && User::getUserOptionID('aboutMe') !== null) { $saveOptions[User::getUserOptionID('aboutMe')] = $githubData['bio']; } if (isset($githubData['location']) && User::getUserOptionID('location') !== null) { $saveOptions[User::getUserOptionID('location')] = $githubData['location']; } } break; case 'twitter': // Twitter if (WCF::getSession()->getVar('__twitterData')) { $twitterData = WCF::getSession()->getVar('__twitterData'); $this->additionalFields['authData'] = 'twitter:' . $twitterData['user_id']; WCF::getSession()->unregister('__twitterData'); if (isset($twitterData['description']) && User::getUserOptionID('aboutMe') !== null) { $saveOptions[User::getUserOptionID('aboutMe')] = $twitterData['description']; } if (isset($twitterData['location']) && User::getUserOptionID('location') !== null) { $saveOptions[User::getUserOptionID('location')] = $twitterData['location']; } } break; case 'facebook': // Facebook if (WCF::getSession()->getVar('__facebookData')) { $facebookData = WCF::getSession()->getVar('__facebookData'); $this->additionalFields['authData'] = 'facebook:' . $facebookData['id']; WCF::getSession()->unregister('__facebookData'); if (isset($facebookData['email']) && $facebookData['email'] == $this->email) { $registerVia3rdParty = true; } if (isset($facebookData['gender']) && User::getUserOptionID('gender') !== null) { $saveOptions[User::getUserOptionID('gender')] = $facebookData['gender'] == 'male' ? UserProfile::GENDER_MALE : UserProfile::GENDER_FEMALE; } if (isset($facebookData['birthday']) && User::getUserOptionID('birthday') !== null) { list($month, $day, $year) = explode('/', $facebookData['birthday']); $saveOptions[User::getUserOptionID('birthday')] = $year . '-' . $month . '-' . $day; } if (isset($facebookData['bio']) && User::getUserOptionID('bio') !== null) { $saveOptions[User::getUserOptionID('aboutMe')] = $facebookData['bio']; } if (isset($facebookData['location']) && User::getUserOptionID('location') !== null) { $saveOptions[User::getUserOptionID('location')] = $facebookData['location']['name']; } if (isset($facebookData['website']) && User::getUserOptionID('website') !== null) { $urls = preg_split('/[\\s,;]/', $facebookData['website'], -1, PREG_SPLIT_NO_EMPTY); if (!empty($urls)) { if (!Regex::compile('^https?://')->match($urls[0])) { $urls[0] = 'http://' . $urls[0]; } $saveOptions[User::getUserOptionID('homepage')] = $urls[0]; } } // avatar if (isset($facebookData['picture']) && !$facebookData['picture']['data']['is_silhouette']) { $avatarURL = $facebookData['picture']['data']['url']; } } break; case 'google': // Google Plus if (WCF::getSession()->getVar('__googleData')) { $googleData = WCF::getSession()->getVar('__googleData'); $this->additionalFields['authData'] = 'google:' . $googleData['id']; WCF::getSession()->unregister('__googleData'); if (isset($googleData['emails'][0]['value']) && $googleData['emails'][0]['value'] == $this->email) { $registerVia3rdParty = true; } if (isset($googleData['gender']) && User::getUserOptionID('gender') !== null) { switch ($googleData['gender']) { case 'male': $saveOptions[User::getUserOptionID('gender')] = UserProfile::GENDER_MALE; break; case 'female': $saveOptions[User::getUserOptionID('gender')] = UserProfile::GENDER_FEMALE; break; } } if (isset($googleData['birthday']) && User::getUserOptionID('birthday') !== null) { $saveOptions[User::getUserOptionID('birthday')] = $googleData['birthday']; } if (isset($googleData['placesLived']) && User::getUserOptionID('location') !== null) { // save primary location $saveOptions[User::getUserOptionID('location')] = current(array_map(function ($element) { return $element['value']; }, array_filter($googleData['placesLived'], function ($element) { return isset($element['primary']) && $element['primary']; }))); } // avatar if (isset($googleData['image']['url'])) { $avatarURL = $googleData['image']['url']; } } break; } // create fake password $this->password = StringUtil::getRandomID(); } $this->additionalFields['languageID'] = $this->languageID; if (LOG_IP_ADDRESS) { $this->additionalFields['registrationIpAddress'] = WCF::getSession()->ipAddress; } // generate activation code $addDefaultGroups = true; if (REGISTER_ACTIVATION_METHOD == 1 && !$registerVia3rdParty || REGISTER_ACTIVATION_METHOD == 2) { $activationCode = UserRegistrationUtil::getActivationCode(); $this->additionalFields['activationCode'] = $activationCode; $addDefaultGroups = false; $this->groupIDs = UserGroup::getGroupIDsByType(array(UserGroup::EVERYONE, UserGroup::GUESTS)); } // check gravatar support if (MODULE_GRAVATAR && Gravatar::test($this->email)) { $this->additionalFields['enableGravatar'] = 1; } // create user $data = array('data' => array_merge($this->additionalFields, array('username' => $this->username, 'email' => $this->email, 'password' => $this->password)), 'groups' => $this->groupIDs, 'languageIDs' => $this->visibleLanguages, 'options' => $saveOptions, 'addDefaultGroups' => $addDefaultGroups); $this->objectAction = new UserAction(array(), 'create', $data); $result = $this->objectAction->executeAction(); $user = $result['returnValues']; $userEditor = new UserEditor($user); // update session WCF::getSession()->changeUser($user); // set avatar if provided if (!empty($avatarURL)) { $userAvatarAction = new UserAvatarAction(array(), 'fetchRemoteAvatar', array('url' => $avatarURL, 'userEditor' => $userEditor)); $userAvatarAction->executeAction(); } // activation management if (REGISTER_ACTIVATION_METHOD == 0) { $this->message = 'wcf.user.register.success'; } else { if (REGISTER_ACTIVATION_METHOD == 1) { // registering via 3rdParty leads to instant activation if ($registerVia3rdParty) { $this->message = 'wcf.user.register.success'; } else { $mail = new Mail(array($this->username => $this->email), WCF::getLanguage()->getDynamicVariable('wcf.user.register.needActivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.register.needActivation.mail', array('user' => $user))); $mail->send(); $this->message = 'wcf.user.register.needActivation'; } } else { if (REGISTER_ACTIVATION_METHOD == 2) { $this->message = 'wcf.user.register.awaitActivation'; } } } // notify admin if (REGISTER_ADMIN_NOTIFICATION) { // get default language $language = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID()); // send mail $mail = new Mail(MAIL_ADMIN_ADDRESS, $language->getDynamicVariable('wcf.user.register.notification.mail.subject'), $language->getDynamicVariable('wcf.user.register.notification.mail', array('user' => $user))); $mail->setLanguage($language); $mail->send(); } if ($this->captchaObjectType) { $this->captchaObjectType->getProcessor()->reset(); } if (WCF::getSession()->getVar('noRegistrationCaptcha')) { WCF::getSession()->unregister('noRegistrationCaptcha'); } // login user UserAuthenticationFactory::getInstance()->getUserAuthentication()->storeAccessData($user, $this->username, $this->password); WCF::getSession()->unregister('registrationRandomFieldNames'); WCF::getSession()->unregister('registrationStartTime'); $this->saved(); // forward to index page HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->getDynamicVariable($this->message, array('user' => $user)), 15); exit; }
/** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); // generate activation code $activationCode = UserRegistrationUtil::getActivationCode(); // save user $parameters = array('activationCode' => $activationCode); if (!empty($this->email)) { $parameters['email'] = $this->email; } $this->objectAction = new UserAction(array($this->user), 'update', array('data' => array_merge($this->additionalFields, $parameters))); $this->objectAction->executeAction(); // reload user to reflect changes $this->user = new User($this->user->userID); // send activation mail $mail = new Mail(array($this->user->username => !empty($this->email) ? $this->email : $this->user->email), WCF::getLanguage()->getDynamicVariable('wcf.user.register.needActivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.register.needActivation.mail', array('user' => $this->user))); $mail->send(); $this->saved(); // forward to index page HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->getDynamicVariable('wcf.user.newActivationCode.success', array('email' => !empty($this->email) ? $this->email : $this->user->email)), 10); exit; }
/** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); // save entry $data = array_merge($this->additionalFields, array('languageID' => $this->languageID, 'time' => TIME_NOW, 'userID' => WCF::getUser()->userID, 'username' => WCF::getUser()->username, 'subject' => $this->subject, 'teaser' => $this->teaser, 'message' => $this->text, 'website' => $this->website, 'isDisabled' => WCF::getSession()->getPermission('user.filebase.canAddEntryWithoutModeration') ? 0 : 1)); $fileData = array('data' => $data, 'fileSubject' => $this->fileSubject, 'categoryIDs' => $this->categoryIDs, 'attachmentHandler' => $this->attachmentHandler, 'fileUpload' => $this->fileUpload); if (MODULE_TAGGING) { $fileData['tags'] = $this->tags; } $this->objectAction = new EntryAction(array(), 'create', $fileData); $resultValues = $this->objectAction->executeAction(); $this->saved(); if ($resultValues['returnValues']->isDisabled) { HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink('FilebaseOverview', array('application' => 'filebase')), WCF::getLanguage()->get('filebase.file.moderation.redirect'), 30); } else { HeaderUtil::redirect(LinkHandler::getInstance()->getLink('Entry', array('application' => 'filebase', 'object' => $resultValues['returnValues']))); } exit; }
/** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); // generate a new lost password key $lostPasswordKey = StringUtil::getRandomID(); // save key and request time in database $this->objectAction = new UserAction(array($this->user), 'update', array('data' => array_merge($this->additionalFields, array('lostPasswordKey' => $lostPasswordKey, 'lastLostPasswordRequestTime' => TIME_NOW)))); $this->objectAction->executeAction(); // send mail $mail = new Mail(array($this->user->username => $this->user->email), WCF::getLanguage()->getDynamicVariable('wcf.user.lostPassword.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.lostPassword.mail', array('username' => $this->user->username, 'userID' => $this->user->userID, 'key' => $lostPasswordKey))); $mail->send(); $this->saved(); // forward to index page HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->get('wcf.user.lostPassword.mail.sent')); exit; }
/** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); // generate new password $this->newPassword = PasswordUtil::getRandomPassword(REGISTER_PASSWORD_MIN_LENGTH > 12 ? REGISTER_PASSWORD_MIN_LENGTH : 12); // update user $this->objectAction = new UserAction(array($this->user), 'update', array('data' => array_merge($this->additionalFields, array('password' => $this->newPassword, 'lastLostPasswordRequestTime' => 0, 'lostPasswordKey' => '')))); $this->objectAction->executeAction(); // send mail $mail = new Mail(array($this->user->username => $this->user->email), WCF::getLanguage()->getDynamicVariable('wcf.user.newPassword.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.newPassword.mail', array('username' => $this->user->username, 'userID' => $this->user->userID, 'newPassword' => $this->newPassword))); $mail->send(); $this->saved(); // forward to index page HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->get('wcf.user.newPassword.success')); exit; }
/** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); // get recipient's language $userLanguage = $this->user->getLanguage(); // build message data $subjectData = array('username' => WCF::getUser()->userID ? WCF::getUser()->username : $this->email, 'subject' => $this->subject); $messageData = array('message' => $this->message, 'recipient' => $this->user, 'username' => WCF::getUser()->userID ? WCF::getUser()->username : $this->email); // build mail $mail = new Mail(array($this->user->username => $this->user->email), $userLanguage->getDynamicVariable('wcf.user.mail.mail.subject', $subjectData), $userLanguage->getDynamicVariable('wcf.user.mail.mail', $messageData)); $mail->setLanguage($userLanguage); // add reply-to tag if (WCF::getUser()->userID) { if ($this->showAddress) { $mail->setHeader('Reply-To: ' . Mail::buildAddress(WCF::getUser()->username, WCF::getUser()->email)); } } else { $mail->setHeader('Reply-To: ' . $this->email); } // send mail $mail->send(); $this->saved(); // forward to profile page HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink('User', array('object' => $this->user)), WCF::getLanguage()->getDynamicVariable('wcf.user.mail.sent', array('user' => $this->user))); exit; }
/** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); $data = array('subject' => $this->subject, 'time' => TIME_NOW, 'message' => $this->text, 'userID' => WCF::getUser()->userID ?: null, 'username' => WCF::getUser()->userID ? WCF::getUser()->username : $this->username, 'languageID' => $this->languageID, 'enableBBCodes' => $this->enableBBCodes, 'enableHtml' => $this->enableHtml, 'enableSmilies' => $this->enableSmilies, 'isDisabled' => WCF::getSession()->getPermission('user.news.canCreateEntryWithoutModeration') ? 0 : 1, 'isDeleted' => 0, 'isFeatured' => $this->isFeatured, 'views' => 0); // delayed publication if ($this->enableDelayedPublication) { $data['isPublished'] = 0; $dateTime = \DateTime::createFromFormat('Y-m-d H:i', $this->publicationDate, WCF::getUser()->getTimeZone()); $data['publicationDate'] = $dateTime->getTimestamp(); } $entryData = array('attachmentHandler' => $this->attachmentHandler, 'categoryIDs' => $this->categoryIDs, 'data' => $data); if (MODULE_TAGGING) { $entryData['tags'] = $this->tags; } $this->objectAction = new EntryAction(array(), 'create', $entryData); $resultValues = $this->objectAction->executeAction(); $this->entry = $resultValues['returnValues']; // quotes MessageQuoteManager::getInstance()->saved(); // polls if ($this->canCreatePoll()) { $pollID = PollManager::getInstance()->save($this->entry->entryID); if ($pollID) { $entryEditor = new EntryEditor($this->entry); $entryEditor->update(array('pollID' => $pollID)); } } $this->saved(); if ($this->entry->isDisabled) { HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink('NewsOverview', array('application' => 'cms')), WCF::getLanguage()->get('cms.news.form.moderation.redirect'), 30); } else { HeaderUtil::redirect(LinkHandler::getInstance()->getLink('NewsEntry', array('application' => 'cms', 'object' => $this->entry))); } exit; }
/** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); $data = array('subject' => $this->subject, 'time' => TIME_NOW, 'message' => $this->text, 'teaser' => $this->teaser, 'website' => $this->website, 'userID' => WCF::getUser()->userID ?: null, 'username' => WCF::getUser()->userID ? WCF::getUser()->username : $this->username, 'languageID' => $this->languageID, 'isDisabled' => WCF::getSession()->getPermission('user.linklist.canAddEntryWithoutModeration') ? 0 : 1); $linkData = array('attachmentHandler' => $this->attachmentHandler, 'categoryIDs' => $this->categoryIDs, 'data' => $data); if (MODULE_TAGGING) { $linkData['tags'] = $this->tags; } $this->objectAction = new EntryAction(array(), 'create', $linkData); $resultValues = $this->objectAction->executeAction(); $this->saved(); if ($resultValues['returnValues']->isDisabled) { HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink('LinklistOverview', array('application' => 'linklist')), WCF::getLanguage()->get('linklist.entry.moderation.redirect'), 30); } else { HeaderUtil::redirect(LinkHandler::getInstance()->getLink('Entry', array('application' => 'linklist', 'object' => $resultValues['returnValues']))); } exit; }