public function isValid($value, array $options = array()) { parent::isValid($value, $options); $result = false; $obj =& $this->validator->object; $xpdo =& $obj->xpdo; $validParentClasses = array('Taxonomy', 'Term'); if ($obj->Parent && in_array($obj->Parent->class_key, $validParentClasses)) { $result = true; } if ($result === false) { $this->validator->addMessage($this->field, $this->name, $this->message); } return $result; }
public function isValid($value, array $options = array()) { parent::isValid($value, $options); $result = false; $obj =& $this->validator->object; $xpdo =& $obj->xpdo; $validParentClasses = array('modDocument', 'modWebLink', 'modSymLink', 'modStaticResource'); if ($obj->get('parent') === 0 || $obj->Parent && in_array($obj->Parent->class_key, $validParentClasses)) { $result = true; } if ($result === false) { $this->validator->addMessage($this->field, $this->name, $this->message); } return $result; }
public function isValid($value, array $options = array()) { if (!isset($options['alias'])) { return false; } parent::isValid($value, $options); $result = false; $obj =& $this->validator->object; $xpdo =& $obj->xpdo; $fkdef = $obj->getFKDefinition($options['alias']); if (isset($obj->_relatedObjects[$options['alias']])) { if (!is_object($obj->_relatedObjects[$options['alias']])) { $result = false; } } $criteria = array($fkdef['foreign'] => $obj->get($fkdef['local'])); if (isset($fkdef['criteria']['foreign'])) { $criteria = array($fkdef['criteria']['foreign'], $criteria); } if ($object = $xpdo->getObject($fkdef['class'], $criteria)) { $result = $object !== null; } if ($result === false) { $this->validator->addMessage($this->field, $this->name, $this->message); } return $result; }