*/ WBClass::load('WBPAT_Forms_Rule'); /** * patForms Rule _ITS_Obscureid * * Id must match ticket. * * @version 0.1.0 * @package Wombat * @subpackage patForms */ class patForms_Rule_ITS_id extends WBPAT_Forms_Rule { /** * @var WBITS_Ticket */ private $ticket; /** * Config parameter * - namespace * @var array */ protected $config = array( 'namespace' => '' ); /** * Initialize validation codes using gettext * * @access protected * @return bool $success Always returns true. * @see $attributeDefaults */ public function loadValidatiorErrorCodes() { $this->validatorErrorCodes = array( 1 => patI18n::dgettext('wombat', 'Ticket not found.') ); return true; } /** * Find Ticket By ObscureId * * Try to find user by nickname or email address * * @param patForms|patForms_Element form object */ public function applyRule(&$element, $type = PATFORMS_RULE_AFTER_VALIDATION) { if (!($element instanceof patForms_Element)) { $element = $element->getElementByName('obscureid'); } $value = $element->getValue(); // don't bother about empty values if (empty($value)) { return true; } $param = array(); if (!empty($this->config['namespace'])) { $params['namespace'] = $this->config['namespace']; } $this->ticket = WBClass::create('WBITS_Ticket', $param); $this->ticket = $this->ticket->loadById($value); $id = $this->ticket->getId(); if (empty($id)) { $this->addValidationError(1); return false; } return true; } }