public function editOption(UserOption $inOption) { // check permissions $permEng = PermissionEngine::getInstance(); if (!$permEng->currentUserCanDo('canEditUserOptions')) { return false; } // get db $db = Database::getInstance(); if (!$db->isConnected()) { return false; } $id = $db->escapeString(intval($inOption->getID())); $computerName = $db->escapeString(preg_replace('/\\s+/', '', $inOption->getComputerName())); $humanName = $db->escapeString(strip_tags($inOption->getHumanName())); $description = $db->escapeString(strip_tags($inOption->getDescription())); $result = $db->updateTable('userOption', "optionName='{$computerName}', humanName='{$humanName}', optionDescription='{$description}'", "optionID={$id}"); if ($result === false) { return false; } return true; }
/** * Register an option for the user. * This function registers the option value in the database and in the current user options * * @param string $name The option name, formatted as '<plugin>.<key>' * @param mixed $value The value to set to the option */ public function setOption($name, $value) { $this->getOptions(); $this->options[$name] = $value; list($plugin, $key) = explode('.', $name, 2); $data = array('plugin' => $plugin, 'key' => $key, 'value' => $value); if ($this->isLogged()) { $data['userId'] = $this->id; } else { $data['userIp'] = App::request()->clientIp(); } UserOption::getDbInstance()->replace(UserOption::getTable(), $data); }