mirror of https://github.com/MISP/MISP
validation
trim all string fields in server. (later bring this to AppModel or behavior level)pull/63/head
parent
80571386ad
commit
fb41a0c2ca
|
@ -104,6 +104,35 @@ class Server extends AppModel {
|
|||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Trim Array Elements (this should probably be in a behavior)
|
||||
*
|
||||
* @param $array
|
||||
*/
|
||||
protected function _trimArray(&$array = array()) {
|
||||
// process some..
|
||||
foreach ($array as &$field) {
|
||||
// remove leading and trailing blanks
|
||||
if (is_string($field)) {
|
||||
$field = trim($field);
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $options
|
||||
*/
|
||||
public function beforeValidate($options = array()) {
|
||||
parent::beforeValidate();
|
||||
|
||||
// process some..
|
||||
$this->_trimArray($this->data['Server']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isOwnedByOrg($serverid, $org) {
|
||||
return $this->field('id', array('id' => $serverid, 'org' => $org)) === $serverid;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue