public function set($key, $value)
{
if (in_array($key, array('id', 'parent_id', 'status', 'flags', 'pages_id', 'created', 'created_users_id'))) {
$value = (int) $value;
} else {
if ($key == 'text') {
$value = $this->cleanCommentString($value);
} else {
if ($key == 'cite') {
$value = str_replace(array("\r", "\n", "\t"), ' ', substr(strip_tags($value), 0, 128));
} else {
if ($key == 'email') {
$value = $this->sanitizer->email($value);
} else {
if ($key == 'ip') {
$value = filter_var($value, FILTER_VALIDATE_IP);
} else {
if ($key == 'user_agent') {
$value = str_replace(array("\r", "\n", "\t"), ' ', substr(strip_tags($value), 0, 255));
} else {
if ($key == 'website') {
$value = wire('sanitizer')->url($value, array('allowRelative' => false, 'allowQuerystring' => false));
} else {
if ($key == 'upvotes' || $key == 'downvotes') {
$value = (int) $value;
}
}
}
}
}
}
}
}
// save the state so that modules can identify when a comment that was identified as spam
// is then set to not-spam, or when a misidentified 'approved' comment is actually spam
if ($key == 'status' && $this->loaded) {
$this->prevStatus = $this->status;
}
if ($key == 'stars') {
$value = (int) $value;
if ($value < 1) {
$value = 0;
}
if ($value > 5) {
$value = 5;
}
}
return parent::set($key, $value);
}