Skip to content
Snippets Groups Projects
Commit 242d0284 authored by Alex Barth's avatar Alex Barth
Browse files

Move term and user validation into a validate() method.

parent e8f4538e
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
Feeds 7.x 2.0 XXXXXXXXXXXXXXXXXXX Feeds 7.x 2.0 XXXXXXXXXXXXXXXXXXX
--------------------------------- ---------------------------------
- Move term and user validation into a validate() method.
- Remove check for present name and mail. Needs to be solved on a more pluggable - Remove check for present name and mail. Needs to be solved on a more pluggable
level. level.
- FeedsTermProcessor: Do not filter taxonomy_term_data table by vid when - FeedsTermProcessor: Do not filter taxonomy_term_data table by vid when
......
...@@ -40,6 +40,9 @@ class FeedsTermProcessor extends FeedsProcessor { ...@@ -40,6 +40,9 @@ class FeedsTermProcessor extends FeedsProcessor {
// Save the term. // Save the term.
$term->feeds_importer_id = $this->id; $term->feeds_importer_id = $this->id;
$term->feed_nid = $source->feed_nid; $term->feed_nid = $source->feed_nid;
if (!$this->validateTerm($term)) {
continue;
}
taxonomy_term_save($term); taxonomy_term_save($term);
if ($tid) { if ($tid) {
$state->updated++; $state->updated++;
...@@ -250,4 +253,14 @@ class FeedsTermProcessor extends FeedsProcessor { ...@@ -250,4 +253,14 @@ class FeedsTermProcessor extends FeedsProcessor {
} }
return $term; return $term;
} }
/**
* Validates a term.
*/
protected function validateTerm($term) {
if (!isset($term->name)) {
return FALSE;
}
return TRUE;
}
} }
...@@ -41,6 +41,9 @@ class FeedsUserProcessor extends FeedsProcessor { ...@@ -41,6 +41,9 @@ class FeedsUserProcessor extends FeedsProcessor {
$account = $this->map($source, $parser_result, $account); $account = $this->map($source, $parser_result, $account);
// Save the user. // Save the user.
if (!$this->validateUser($account)) {
continue;
}
user_save($account, (array) $account); user_save($account, (array) $account);
if ($account->uid && $account->openid) { if ($account->uid && $account->openid) {
$authmap = array( $authmap = array(
...@@ -229,4 +232,14 @@ class FeedsUserProcessor extends FeedsProcessor { ...@@ -229,4 +232,14 @@ class FeedsUserProcessor extends FeedsProcessor {
} }
return $account; return $account;
} }
/**
* Validates a user account.
*/
protected function validateUser($account) {
if (empty($account->name) || empty($account->mail) || !valid_email_address($account->mail)) {
return FALSE;
}
return TRUE;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment