Beispiel #1
0
 /**
  * @see	\wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['id'])) {
         $this->userID = intval($_REQUEST['id']);
     }
     $this->user = UserProfile::getUserProfile($this->userID);
     if ($this->user === null) {
         throw new IllegalLinkException();
     }
     // validate ignore status
     if (WCF::getUser()->userID && $this->user->isIgnoredUser(WCF::getUser()->userID)) {
         throw new PermissionDeniedException();
     }
     $this->canonicalURL = LinkHandler::getInstance()->getLink('Mail', array('object' => $this->user->getDecoratedObject()));
 }
 /**
  * Saves changes to user profile.
  * 
  * @return	array
  */
 public function save()
 {
     $userTitle = null;
     if (isset($this->parameters['values']['__userTitle'])) {
         $userTitle = StringUtil::trim(MessageUtil::stripCrap($this->parameters['values']['__userTitle']));
         unset($this->parameters['values']['__userTitle']);
     }
     $optionHandler = $this->getOptionHandler($this->userProfile->getDecoratedObject());
     $optionHandler->readUserInput($this->parameters);
     $errors = $optionHandler->validate();
     // validate user title
     if ($userTitle !== null) {
         try {
             if (mb_strlen($userTitle) > USER_TITLE_MAX_LENGTH) {
                 throw new UserInputException('__userTitle', 'tooLong');
             }
             if (!StringUtil::executeWordFilter($userTitle, USER_FORBIDDEN_TITLES)) {
                 throw new UserInputException('__userTitle', 'forbidden');
             }
         } catch (UserInputException $e) {
             $errors[$e->getField()] = $e->getType();
         }
     }
     // validation was successful
     if (empty($errors)) {
         $saveOptions = $optionHandler->save();
         $data = array('options' => $saveOptions);
         // save user title
         if ($userTitle !== null) {
             $data['data'] = array('userTitle' => $userTitle);
         }
         $userAction = new UserAction(array($this->userProfile->userID), 'update', $data);
         $userAction->executeAction();
         // check if the user will be automatically added to new
         // user groups because of the changed user options
         UserGroupAssignmentHandler::getInstance()->checkUsers(array($this->userProfile->userID));
         // return parsed template
         $user = new User($this->userProfile->userID);
         // reload option handler
         $optionHandler = $this->getOptionHandler($user, false);
         $options = $optionHandler->getOptionTree();
         WCF::getTPL()->assign(array('options' => $options, 'userID' => $this->userProfile->userID));
         return array('success' => true, 'template' => WCF::getTPL()->fetch('userProfileAbout'));
     } else {
         // validation failed
         WCF::getTPL()->assign(array('errorType' => $errors, 'optionTree' => $optionHandler->getOptionTree(), '__userTitle' => $userTitle !== null ? $userTitle : $this->userProfile->userTitle));
         return array('success' => false, 'template' => WCF::getTPL()->fetch('userProfileAboutEditable'));
     }
 }
Beispiel #3
0
 /**
  * @see	\wcf\page\IPage::show()
  */
 public function show()
 {
     // update profile hits
     if ($this->user->userID != WCF::getUser()->userID && !WCF::getSession()->spiderID && !$this->user->isProtected()) {
         $editor = new UserEditor($this->user->getDecoratedObject());
         $editor->updateCounters(array('profileHits' => 1));
         // save visitor
         if (PROFILE_ENABLE_VISITORS && WCF::getUser()->userID && !WCF::getUser()->canViewOnlineStatus) {
             if (($visitor = UserProfileVisitor::getObject($this->user->userID, WCF::getUser()->userID)) !== null) {
                 $editor = new UserProfileVisitorEditor($visitor);
                 $editor->update(array('time' => TIME_NOW));
             } else {
                 UserProfileVisitorEditor::create(array('ownerID' => $this->user->userID, 'userID' => WCF::getUser()->userID, 'time' => TIME_NOW));
             }
         }
     }
     parent::show();
 }