diff --git a/VERSION.json b/VERSION.json index e2be50c88..0f832e5e5 100644 --- a/VERSION.json +++ b/VERSION.json @@ -1 +1 @@ -{"major":2, "minor":3, "hotfix":122} \ No newline at end of file +{"major":2, "minor":3, "hotfix":123} \ No newline at end of file diff --git a/app/Controller/AttributesController.php b/app/Controller/AttributesController.php index cc22b23b8..730422dc8 100755 --- a/app/Controller/AttributesController.php +++ b/app/Controller/AttributesController.php @@ -1830,11 +1830,11 @@ class AttributesController extends AppController { $this->set('rpzSettings', $rpzSettings); } - public function reportValidationIssuesAttributes() { + public function reportValidationIssuesAttributes($eventId = false) { // TODO improve performance of this function by eliminating the additional SQL query per attribute // search for validation problems in the attributes if (!self::_isSiteAdmin()) throw new NotFoundException(); - $this->set('result', $this->Attribute->reportValidationIssuesAttributes()); + $this->set('result', $this->Attribute->reportValidationIssuesAttributes($eventId)); } public function generateCorrelation() { diff --git a/app/Model/Attribute.php b/app/Model/Attribute.php index 3772e3122..498826073 100755 --- a/app/Model/Attribute.php +++ b/app/Model/Attribute.php @@ -1412,12 +1412,14 @@ class Attribute extends AppModel { return $k; } - public function reportValidationIssuesAttributes() { + public function reportValidationIssuesAttributes($eventId) { + $conditions = array(); + if ($eventId && is_numeric($eventId)) $conditions = array('event_id' => $eventId); // for efficiency reasons remove the unique requirement $this->validator()->remove('value', 'unique'); // get all attributes.. - $attributes = $this->find('all', array('recursive' => -1, 'fields' => array('id'))); + $attributes = $this->find('all', array('recursive' => -1, 'fields' => array('id'), 'conditions' => $conditions)); // for all attributes.. $result = array(); @@ -1431,7 +1433,10 @@ class Attribute extends AppModel { $errors = $this->validationErrors; $result[$i]['id'] = $attribute['Attribute']['id']; // print_r - $result[$i]['error'] = $errors['value'][0]; + $result[$i]['error'] = array(); + foreach ($errors as $field => $error) { + $result[$i]['error'][$field] = array('value' => $attribute['Attribute'][$field], 'error' => $error[0]); + } $result[$i]['details'] = 'Event ID: [' . $attribute['Attribute']['event_id'] . "] - Category: [" . $attribute['Attribute']['category'] . "] - Type: [" . $attribute['Attribute']['type'] . "] - Value: [" . $attribute['Attribute']['value'] . ']'; $i++; } diff --git a/app/View/Attributes/report_validation_issues_attributes.ctp b/app/View/Attributes/report_validation_issues_attributes.ctp index 925a09e05..209dc4d3f 100644 --- a/app/View/Attributes/report_validation_issues_attributes.ctp +++ b/app/View/Attributes/report_validation_issues_attributes.ctp @@ -4,10 +4,12 @@ foreach ($result as $r) { ?>

Validation errors for attribute:

-
- Attribute details:
- -
+ $error) { + echo '[' . h($field) . ']: Value found: ' . h($error['value']) . ' - Error: ' . h($error['error']) . '
'; + } + ?> + [Attribute details]: