- Timestamp:
- 07/21/10 09:25:53 (11 years ago)
- Location:
- trunk/server/www/app
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/www/app/models/validator.php
r352 r388 59 59 60 60 $this->read(); 61 if ($this->data['Request']['id']) { 62 $this->Request->id = $this->data['Request']['id']; 63 $file = $this->Request->getPath(); 64 $destination = $this->data['Request']['path']; 65 } else { 66 $this->Result->id = $this->data['Result']['id']; 67 $file = $this->Result->getPath(); 68 $destination = $this->data['Result']['path']; 69 } 70 71 $className = $this->data['Validator']['name'] . 'Validator'; 72 if (!$this->data['Validator']['name'] || !class_exists($className)) { 73 $this->log('Invalid ODF Validator: ' . $this->data['Validator']['name'] . 'Validator'); 74 return; 75 } 76 77 $validator = new $className(); 61 if (!($validator = $this->_getValidator())) { 62 return; 63 } 64 78 65 $validator->run($file); 79 66 80 67 // Save the validator result to file 68 $destination = $this->_getPath(); 81 69 $destination = FILES . $destination . DS . strtolower($this->data['Validator']['name']) . '-validator.' . $validator->ext; 82 70 file_put_contents($destination, $validator->response); … … 86 74 $this->data['Validator']['response'] = $validator->response; 87 75 $this->save(); 76 } 77 78 /** 79 * Delete the on-disk validator result 80 */ 81 public function beforeDelete($cascade) 82 { 83 if (!$this->id) { 84 return false; 85 } 86 87 $this->read(); 88 if (!($validator = $this->_getValidator())) { 89 return true; 90 } 91 92 if ($destination = $this->_getPath()) { 93 $destination = FILES . $destination . DS . strtolower($this->data['Validator']['name']) . '-validator.' . $validator->ext; 94 if (file_exists($destination)) { 95 @unlink($destination); 96 } 97 } 98 99 return true; 100 } 101 102 /** 103 * Get the validator class based off $this->data 104 */ 105 private function _getValidator() 106 { 107 $className = $this->data['Validator']['name'] . 'Validator'; 108 if (!$this->data['Validator']['name'] || !class_exists($className)) { 109 $this->log('Invalid ODF Validator: ' . $this->data['Validator']['name'] . 'Validator'); 110 return null; 111 } 112 113 return new $className(); 114 } 115 116 /** 117 * Get the Request.path or Result.path from $this->data 118 */ 119 private function _getPath() 120 { 121 if ($this->data['Request']['id']) { 122 $this->Request->id = $this->data['Request']['id']; 123 $file = $this->Request->getPath(); 124 return $this->data['Request']['path']; 125 } 126 127 $this->Result->id = $this->data['Result']['id']; 128 $file = $this->Result->getPath(); 129 return $this->data['Result']['path']; 88 130 } 89 131 } -
trunk/server/www/app/vendors/shells/validators.php
r343 r388 75 75 'Job', 76 76 'Job.Result', 77 'Job.Result.Format', 77 78 'Job.Result.Validator' => array('fields' => 'name'), 78 79 )); … … 102 103 foreach ($results as $result) { 103 104 if (empty($result['Result'])) { 105 continue; 106 } 107 108 // If this is not and ODF roundtrip result, remove any validators and continue. 109 // There was an old bug here that could cause non-ODF results to be assigned validators 110 if ($result['Result']['Format']['code'] != 'odf') { 111 foreach ($result['Result']['Validator'] as $validator_bug) { 112 $this->Validator->id = $validator_bug['id']; 113 $this->Validator->delete(); 114 } 115 104 116 continue; 105 117 }
Note: See TracChangeset
for help on using the changeset viewer.