/** * Confirm that the current search suggestion is valid. */ public function validate() { $result = parent::validate(); // Confirm that the current search suggestion matches the minimum autocomplete length and doesn't already exist. if ($result->valid() && strlen($this->Term) < 3) { $result->error('Minimum autocomplete length required!'); } else { if ($result->valid() && ExtensibleSearchSuggestion::get_one('ExtensibleSearchSuggestion', "ID != " . (int) $this->ID . " AND Term = '" . Convert::raw2sql($this->Term) . "' AND ExtensibleSearchPageID = " . (int) $this->ExtensibleSearchPageID)) { $result->error('Suggestion already exists!'); } } return $result; }
/** * Confirm that the current search suggestion is valid. */ public function validate() { $result = parent::validate(); // Confirm that the current search suggestion matches the minimum autocomplete length and doesn't already exist. if ($result->valid() && strlen($this->Term) < 3) { $result->error('Minimum autocomplete length required!'); } else { if ($result->valid() && ExtensibleSearchSuggestion::get_one('ExtensibleSearchSuggestion', array('ID != ?' => $this->ID, 'Term = ?' => $this->Term, 'ExtensibleSearchPageID = ?' => $this->ExtensibleSearchPageID))) { $result->error('Suggestion already exists!'); } } // Allow extension customisation. $this->extend('validateExtensibleSearchSuggestion', $result); return $result; }