Source of file DMSTagExtension.php
Size: 1,455 Bytes - Last Modified: 2021-12-23T10:55:49+00:00
/var/www/docs.ssmods.com/process/src/code/extensions/DMSTagExtension.php
1234567891011121314151617181920212223242526272829303132333435363738 | <?php class DMSTagExtension extends DataExtension { public static $undefinedValue = '#undefinedValue#'; public function isValueDefined() { if ($this->owner->Value != self::$undefinedValue) { return true; } return false; } public function validate(ValidationResult $validationResult) { if (!$this->owner->Category) { $validationResult->combineAnd(new ValidationResult(false, _t('DMSTagExtension.NoCategory', 'You must at least enter a category.'))); } else { $this->owner->Category = trim($this->owner->Category); // this is done to prevent the method 'removeTag' in 'DMSDocument' to erase all the tags with same category if no value is defined on the removing Tag if (!$this->owner->Value) { $this->owner->Value = self::$undefinedValue; } else { $this->owner->Value = trim($this->owner->Value); } $query = "SELECT COUNT(*) FROM \"DMSTag\" WHERE \"DMSTag\".\"Category\" LIKE '{$this->owner->Category}' AND \"DMSTag\".\"Value\" LIKE '{$this->owner->Value}'"; if (DB::query($query)->value()) { $validationResult->combineAnd(new ValidationResult(false, _t('DMSTagExtension.CategoryValueNotUnique', 'This tag already exists. Please select it from the multiselect box.'))); } } } } |