protected function FeedsCommentProcessor::entityValidate in Feeds Comment Processor 7
File
- ./
FeedsCommentProcessor.inc, line 55 - Contains FeedsCommentProcessor.
Class
- FeedsCommentProcessor
- Creates comments from feed items.
Code
protected function entityValidate($comment) {
if (!$comment->nid) {
throw new FeedsValidationException(t('Unable to create comment with empty NID.'));
}
if ($comment->pid && !comment_load($comment->pid)) {
throw new FeedsValidationException(t('Invalid parent comment id.'));
}
$comment->status = empty($comment->status) ? COMMENT_NOT_PUBLISHED : COMMENT_PUBLISHED;
$this
->prepareCommentSubject($comment);
$comment->mail = valid_email_address($comment->mail) ? $comment->mail : '';
// If there is a valid user id, populate any default values.
if ($comment->uid && ($account = user_load($comment->uid))) {
$comment->name = $comment->name ? $comment->name : $account->name;
$comment->mail = $comment->mail ? $comment->mail : $account->mail;
// Unpublish comments by users that are not allowed to skip approval.
if (!user_access('skip comment approval', $account)) {
$comment->status = COMMENT_NOT_PUBLISHED;
}
}
elseif (!$comment->uid && !$comment->name) {
$comment->name = variable_get('anonymous', t('Anonymous'));
}
}