/** * Validate and clean up parameters (e.g. from POST request). * @return mixed (true on success, error string on failure) */ protected function doCheckParameters() { $action = $this->getAction(); if ($action === null) { return 'review_param_missing'; // no action specified (approve, reject, de-approve) } elseif (!$this->oldid) { return 'review_no_oldid'; // no revision target } # Get the revision's current flags (if any) $this->oldFrev = FlaggedRevision::newFromTitle($this->page, $this->oldid, FR_MASTER); $this->oldFlags = $this->oldFrev ? $this->oldFrev->getTags() : FlaggedRevision::expandRevisionTags(''); // default # Set initial value for newLastChangeTime (if unchanged on submit) $this->newLastChangeTime = $this->lastChangeTime; # Fill in implicit tag data for binary flag case $iDims = $this->implicitDims(); if ($iDims) { $this->dims = $iDims; // binary flag case } if ($action === 'approve') { # We must at least rate each category as 1, the minimum if (in_array(0, $this->dims, true)) { return 'review_too_low'; } # Special token to discourage fiddling with templates/files... if (!$this->skipValidationKey) { $k = self::validationKey($this->templateParams, $this->imageParams, $this->fileVersion, $this->oldid, $this->sessionKey); if ($this->validatedParams !== $k) { return 'review_bad_key'; } } # Sanity check tags if (!FlaggedRevs::flagsAreValid($this->dims)) { return 'review_bad_tags'; } # Check permissions with tags if (!FlaggedRevs::userCanSetFlags($this->user, $this->dims, $this->oldFlags)) { return 'review_denied'; } } elseif ($action === 'unapprove') { # Check permissions with old tags if (!FlaggedRevs::userCanSetFlags($this->user, $this->oldFlags)) { return 'review_denied'; } } return true; }