/**
  * @see	\wcf\form\AbstractForm::save()
  */
 public function save()
 {
     parent::save();
     // get new values
     $saveOptions = $this->optionHandler->save();
     // apply changes
     if ($this->applyChangesToExistingUsers) {
         $optionIDs = array_keys($saveOptions);
         // get changed options
         $sql = "SELECT\toptionID, defaultValue\n\t\t\t\tFROM\twcf" . WCF_N . "_user_option\n\t\t\t\tWHERE\toptionID IN (?" . str_repeat(', ?', count($optionIDs) - 1) . ")";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($optionIDs);
         $optionIDs = $optionValues = array();
         while ($row = $statement->fetchArray()) {
             if ($row['defaultValue'] != $saveOptions[$row['optionID']]) {
                 $optionIDs[] = $row['optionID'];
                 $optionValues[] = $saveOptions[$row['optionID']];
             }
         }
         if (!empty($optionIDs)) {
             $sql = "UPDATE\twcf" . WCF_N . "_user_option_value\n\t\t\t\t\tSET\tuserOption" . implode(' = ?, userOption', $optionIDs) . " = ?";
             $statement = WCF::getDB()->prepareStatement($sql);
             $statement->execute(array_merge($optionValues));
         }
     }
     // save values
     $sql = "UPDATE\twcf" . WCF_N . "_user_option\n\t\t\tSET\tdefaultValue = ?\n\t\t\tWHERE\toptionID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     foreach ($saveOptions as $optionID => $value) {
         $statement->execute(array($value, $optionID));
     }
     // reset cache
     UserOptionCacheBuilder::getInstance()->reset();
     $this->saved();
     WCF::getTPL()->assign('success', true);
 }
Beispiel #2
0
 /**
  * @see	\wcf\form\AbstractForm::save()
  */
 public function save()
 {
     parent::save();
     $saveOptions = $this->optionHandler->save();
     $parameters = array('options' => $saveOptions);
     // static options
     if ($this->category == 'general') {
         $parameters['data'] = array_merge($this->additionalFields, array('languageID' => $this->languageID, 'styleID' => $this->styleID));
         $parameters['languageIDs'] = $this->contentLanguageIDs;
     }
     $this->objectAction = new UserAction(array(WCF::getUser()), 'update', $parameters);
     $this->objectAction->executeAction();
     // static options
     if ($this->category == 'general') {
         // reset user language ids cache
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'languageIDs');
     }
     $this->saved();
     WCF::getTPL()->assign('success', true);
 }