public static function checkFields(Result $result, $primary, array $data) { parent::checkFields($result, $primary, $data); if (!$result->isSuccess()) { return; } $query = new Entity\Query(static::getEntity()); $res = $query->setSelect(array('ID', 'STATUS'))->setFilter(array('=TO_ENTITY' => $data['TO_ENTITY'], '=REAL_OBJECT_ID' => $data['REAL_OBJECT_ID']))->setLimit(2)->exec(); while ($existing = $res->fetch()) { if (!isset($primary) || $primary != $existing['ID']) { if ($existing['STATUS'] == self::STATUS_IS_DECLINED) { static::delete($existing['ID']); } else { $result->addError(new Entity\EntityError(Loc::getMessage("DISK_SHARING_ENTITY_ERROR_NON_UNIQUE"))); } } } }
public static function checkFields(Result $result, $primary, array $data) { if ($result instanceof Entity\UpdateResult) { if (isset($data['STORAGE_ID'])) { $field = static::getEntity()->getField('STORAGE_ID'); $result->addError(new Entity\FieldError($field, Loc::getMessage("DISK_OBJECT_ENTITY_ERROR_UPDATE_STORAGE_ID", array("#FIELD#" => $field->getTitle())))); } if (isset($data['PARENT_ID'])) { $field = static::getEntity()->getField('PARENT_ID'); $result->addError(new Entity\FieldError($field, Loc::getMessage("DISK_OBJECT_ENTITY_ERROR_UPDATE_PARENT_ID", array("#FIELD#" => $field->getTitle())))); } } if (!empty($data['NAME']) && (!IO\Path::validateFilename($data['NAME']) || strpos($data['NAME'], '%') !== false)) { $field = static::getEntity()->getField('NAME'); $result->addError(new Entity\FieldError($field, Loc::getMessage("DISK_OBJECT_ENTITY_ERROR_FIELD_NAME_HAS_INVALID_CHARS", array("#FIELD#" => $field->getTitle())))); } parent::checkFields($result, $primary, $data); }