/** * @param string $rawvalue the user to validate * @return int|string|void */ public function validate($rawvalue) { $rawvalue = parent::validate($rawvalue); if ($this->config['existingonly']) { /** @var \DokuWiki_Auth_Plugin $auth */ global $auth; $info = $auth->getUserData($rawvalue, false); if ($info === false) { throw new ValidationException('User not found', $rawvalue); } } return $rawvalue; }
/** * @param int|string $rawvalue * @return int|string * @throws ValidationException */ public function validate($rawvalue) { $rawvalue = parent::validate($rawvalue); $rawvalue = str_replace(',', '.', $rawvalue); // we accept both if ((string) $rawvalue != (string) floatval($rawvalue)) { throw new ValidationException('Decimal needed'); } if ($this->config['min'] !== '' && floatval($rawvalue) <= floatval($this->config['min'])) { throw new ValidationException('Decimal min', floatval($this->config['min'])); } if ($this->config['max'] !== '' && floatval($rawvalue) >= floatval($this->config['max'])) { throw new ValidationException('Decimal max', floatval($this->config['max'])); } return $rawvalue; }
/** * When using titles, we need to compare against the title table, too * * @param QueryBuilder $QB * @param string $tablealias * @param string $colname * @param string $comp * @param string $value * @param string $op */ public function filter(QueryBuilder $QB, $tablealias, $colname, $comp, $value, $op) { if (!$this->config['usetitles']) { parent::filter($QB, $tablealias, $colname, $comp, $value, $op); return; } $rightalias = $QB->generateTableAlias(); $QB->addLeftJoin($tablealias, 'titles', $rightalias, "{$tablealias}.{$colname} = {$rightalias}.pid"); // compare against page and title $sub = $QB->filters()->where($op); $pl = $QB->addValue($value); $sub->whereOr("{$tablealias}.{$colname} {$comp} {$pl}"); $pl = $QB->addValue($value); $sub->whereOr("{$rightalias}.title {$comp} {$pl}"); }