* @package be.bastelstu.chat * @subpackage data.user */ class UserAction extends \wcf\data\AbstractDatabaseObjectAction { /** * @see \wcf\data\AbstractDatabaseObjectAction::$className */ protected $className = 'wcf\data\user\UserEditor'; /** * Validates updating of chat user options */ public function validateUpdateOption() { $this->readString('optionName'); $this->readBoolean('optionValue'); if (!preg_match('~^chat[A-Z]~', $this->parameters['optionName'])) throw new \wcf\system\exception\UserInputException('optionName'); $this->optionID = \wcf\data\user\User::getUserOptionID($this->parameters['optionName']); if (!$this->optionID) throw new \wcf\system\exception\UserInputException('optionName'); } /** * Updates chat user options */ public function updateOption() { $userAction = new \wcf\data\user\UserAction(array(WCF::getUser()), 'update', array( 'options' => array( $this->optionID => $this->parameters['optionValue'] ? 1 : 0 ) )); $userAction->executeAction(); } }