is_null_email() public static method

* FeedWordPress::null_email_set ()
public static is_null_email ( $email )
 function author_id($unfamiliar_author = 'create')
 {
     $a = $this->author();
     $author = $a['name'];
     $email = isset($a['email']) ? $a['email'] : NULL;
     $authorUrl = isset($a['uri']) ? $a['uri'] : NULL;
     $match_author_by_email = !('yes' == get_option("feedwordpress_do_not_match_author_by_email"));
     if ($match_author_by_email and !FeedWordPress::is_null_email($email)) {
         $test_email = $email;
     } else {
         $test_email = NULL;
     }
     // Never can be too careful...
     $login = sanitize_user($author, true);
     $login = apply_filters('pre_user_login', $login);
     $nice_author = sanitize_title($author);
     $nice_author = apply_filters('pre_user_nicename', $nice_author);
     // Do our escape just how $wpdb does it for a string
     $author = addslashes($author);
     // Check for an existing author rule....
     if (isset($this->link->settings['map authors']['name'][strtolower(trim($author))])) {
         $author_rule = $this->link->settings['map authors']['name'][strtolower(trim($author))];
     } else {
         $author_rule = NULL;
     }
     // User name is mapped to a particular author. If that author ID exists, use it.
     if (is_numeric($author_rule) and get_userdata((int) $author_rule)) {
         $id = (int) $author_rule;
         // User name is filtered out
     } elseif ('filter' == $author_rule) {
         $id = NULL;
     } else {
         // Check the database for an existing author record that might fit
         $id = NULL;
         // First try the user core data table.
         if ($user = get_user_by('login', trim(strtolower($login)))) {
             $id = $user->ID;
         } else {
             if ($user = get_user_by('email', trim(strtolower($test_email)))) {
                 $id = $user->ID;
             } else {
                 if ($user = get_user_by('slug', trim(strtolower($nice_author)))) {
                     $id = $user->ID;
                 }
             }
         }
         /* CF: No WP functionality to accomplish this, we're not going 
         			to try the description field right now */
         // If that fails, look for aliases in the user meta data table
         // if (empty($id)) :
         // 	$reg_author = $wpdb->escape(preg_quote($author));
         // 	$id = $wpdb->get_var(
         // 	"SELECT user_id FROM $wpdb->usermeta
         // 	WHERE
         // 		(meta_key = 'description' AND TRIM(LCASE(meta_value)) = TRIM(LCASE('$author')))
         // 		OR (
         // 			meta_key = 'description'
         // 			AND TRIM(LCASE(meta_value))
         // 			RLIKE CONCAT(
         // 				'(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*',
         // 				TRIM(LCASE('$reg_author')),
         // 				'( |\\t|\\r)*(\\n|\$)'
         // 			)
         // 		)
         // 	");
         // endif;
         // ... if you don't find one, then do what you need to do
         if (is_null($id)) {
             if (is_numeric($unfamiliar_author) and get_userdata((int) $unfamiliar_author)) {
                 $id = (int) $unfamiliar_author;
                 // Do the default, assign to admin
             } else {
                 $id = 1;
             }
         }
     }
     if ($id) {
         $this->link->settings['map authors']['name'][strtolower(trim($author))] = $id;
     }
     return $id;
 }
 /**
  * SyndicatedPost::author_id (): get the ID for an author name from
  * the feed. Create the author if necessary.
  *
  * @param string $unfamiliar_author
  *
  * @return NULL|int The numeric ID of the author to attribute the post to
  *	NULL if the post should be filtered out.
  */
 function author_id($unfamiliar_author = 'create')
 {
     global $wpdb;
     $a = $this->named['author'];
     $source = $this->source();
     $forbidden = apply_filters('feedwordpress_forbidden_author_names', array('admin', 'administrator', 'www', 'root'));
     // Prepare the list of candidates to try for author name: name from
     // feed, original source title (if any), immediate source title live
     // from feed, subscription title, prettied version of feed homepage URL,
     // prettied version of feed URL, or, failing all, use "unknown author"
     // as last resort
     $candidates = array();
     $candidates[] = $a['name'];
     if (!is_null($source)) {
         $candidates[] = $source['title'];
     }
     $candidates[] = $this->link->name(true);
     $candidates[] = $this->link->name(false);
     if (strlen($this->link->homepage()) > 0) {
         $candidates[] = feedwordpress_display_url($this->link->homepage());
     }
     $candidates[] = feedwordpress_display_url($this->link->uri());
     $candidates[] = 'unknown author';
     // Pick the first one that works from the list, screening against empty
     // or forbidden names.
     $author = NULL;
     while (is_null($author) and $candidate = each($candidates)) {
         if (!is_null($candidate['value']) and strlen(trim($candidate['value'])) > 0 and !in_array(strtolower(trim($candidate['value'])), $forbidden)) {
             $author = $candidate['value'];
         }
     }
     $email = isset($a['email']) ? $a['email'] : NULL;
     $authorUrl = isset($a['uri']) ? $a['uri'] : NULL;
     $hostUrl = $this->link->homepage();
     if (is_null($hostUrl) or strlen($hostUrl) < 0) {
         $hostUrl = $this->link->uri();
     }
     $match_author_by_email = !('yes' == get_option("feedwordpress_do_not_match_author_by_email"));
     if ($match_author_by_email and !FeedWordPress::is_null_email($email)) {
         $test_email = $email;
     } else {
         $test_email = NULL;
     }
     // Never can be too careful...
     $login = sanitize_user($author, true);
     // Possible for, e.g., foreign script author names
     if (strlen($login) < 1) {
         // No usable characters in author name for a login.
         // (Sometimes results from, e.g., foreign scripts.)
         //
         // We just need *something* in Western alphanumerics,
         // so let's try the domain name.
         //
         // Uniqueness will be guaranteed below if necessary.
         $url = parse_url($hostUrl);
         $login = sanitize_user($url['host'], true);
         if (strlen($login) < 1) {
             // This isn't working. Frak it.
             $login = '******';
         }
     }
     $login = apply_filters('pre_user_login', $login);
     $nice_author = sanitize_title($author);
     $nice_author = apply_filters('pre_user_nicename', $nice_author);
     $reg_author = esc_sql(preg_quote($author));
     $author = esc_sql($author);
     $email = esc_sql($email);
     $test_email = esc_sql($test_email);
     $authorUrl = esc_sql($authorUrl);
     // Check for an existing author rule....
     if (isset($this->link->settings['map authors']['name']['*'])) {
         $author_rule = $this->link->settings['map authors']['name']['*'];
     } elseif (isset($this->link->settings['map authors']['name'][strtolower(trim($author))])) {
         $author_rule = $this->link->settings['map authors']['name'][strtolower(trim($author))];
     } else {
         $author_rule = NULL;
     }
     // User name is mapped to a particular author. If that author ID exists, use it.
     if (is_numeric($author_rule) and get_userdata((int) $author_rule)) {
         $id = (int) $author_rule;
         // User name is filtered out
     } elseif ('filter' == $author_rule) {
         $id = NULL;
     } else {
         // Check the database for an existing author record that might fit
         // First try the user core data table.
         $id = $wpdb->get_var("SELECT ID FROM {$wpdb->users}\n\t\t\tWHERE TRIM(LCASE(display_name)) = TRIM(LCASE('{$author}'))\n\t\t\tOR TRIM(LCASE(user_login)) = TRIM(LCASE('{$author}'))\n\t\t\tOR (\n\t\t\t\tLENGTH(TRIM(LCASE(user_email))) > 0\n\t\t\t\tAND TRIM(LCASE(user_email)) = TRIM(LCASE('{$test_email}'))\n\t\t\t)");
         // If that fails, look for aliases in the user meta data table
         if (is_null($id)) {
             $id = $wpdb->get_var("SELECT user_id FROM {$wpdb->usermeta}\n\t\t\t\tWHERE\n\t\t\t\t\t(meta_key = 'description' AND TRIM(LCASE(meta_value)) = TRIM(LCASE('{$author}')))\n\t\t\t\t\tOR (\n\t\t\t\t\t\tmeta_key = 'description'\n\t\t\t\t\t\tAND TRIM(LCASE(meta_value))\n\t\t\t\t\t\tRLIKE CONCAT(\n\t\t\t\t\t\t\t'(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*',\n\t\t\t\t\t\t\tTRIM(LCASE('{$reg_author}')),\n\t\t\t\t\t\t\t'( |\\t|\\r)*(\\n|\$)'\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t");
         }
         // ... if you don't find one, then do what you need to do
         if (is_null($id)) {
             if ($unfamiliar_author === 'create') {
                 $userdata = array();
                 // WordPress 3 is going to pitch a fit if we attempt to register
                 // more than one user account with an empty e-mail address, so we
                 // need *something* here. Ugh.
                 if (strlen($email) == 0 or FeedWordPress::is_null_email($email)) {
                     $url = parse_url($hostUrl);
                     $email = $nice_author . '@' . $url['host'];
                 }
                 #-- user table data
                 $userdata['ID'] = NULL;
                 // new user
                 $userdata['user_login'] = $login;
                 $userdata['user_nicename'] = $nice_author;
                 $userdata['user_pass'] = substr(md5(uniqid(microtime())), 0, 6);
                 // just something random to lock it up
                 $userdata['user_email'] = $email;
                 $userdata['user_url'] = $authorUrl;
                 $userdata['nickname'] = $author;
                 $parts = preg_split('/\\s+/', trim($author), 2);
                 if (isset($parts[0])) {
                     $userdata['first_name'] = $parts[0];
                 }
                 if (isset($parts[1])) {
                     $userdata['last_name'] = $parts[1];
                 }
                 $userdata['display_name'] = $author;
                 $userdata['role'] = 'contributor';
                 do {
                     // Keep trying until you get it right. Or until PHP crashes, I guess.
                     $id = wp_insert_user($userdata);
                     if (is_wp_error($id)) {
                         $codes = $id->get_error_code();
                         switch ($codes) {
                             case 'empty_user_login':
                             case 'existing_user_login':
                                 // Add a random disambiguator
                                 $userdata['user_login'] .= substr(md5(uniqid(microtime())), 0, 6);
                                 break;
                             case 'existing_user_email':
                                 // No disassemble!
                                 $parts = explode('@', $userdata['user_email'], 2);
                                 // Add a random disambiguator as a gmail-style username extension
                                 $parts[0] .= '+' . substr(md5(uniqid(microtime())), 0, 6);
                                 // Reassemble
                                 $userdata['user_email'] = $parts[0] . '@' . $parts[1];
                                 break;
                         }
                     }
                 } while (is_wp_error($id));
             } elseif (is_numeric($unfamiliar_author) and get_userdata((int) $unfamiliar_author)) {
                 $id = (int) $unfamiliar_author;
             } elseif ($unfamiliar_author === 'default') {
                 $id = 1;
             }
         }
     }
     if ($id) {
         $this->link->settings['map authors']['name'][strtolower(trim($author))] = $id;
         // Multisite: Check whether the author has been recorded
         // on *this* blog before. If not, put her down as a
         // Contributor for *this* blog.
         $user = new WP_User((int) $id);
         if (empty($user->roles)) {
             $user->add_role('contributor');
         }
     }
     return $id;
 }
 function author_id($unfamiliar_author = 'create')
 {
     global $wpdb;
     $a = $this->author();
     $author = $a['name'];
     $email = $a['email'];
     $url = $a['uri'];
     $match_author_by_email = !('yes' == get_option("feedwordpress_do_not_match_author_by_email"));
     if ($match_author_by_email and !FeedWordPress::is_null_email($email)) {
         $test_email = $email;
     } else {
         $test_email = NULL;
     }
     // Never can be too careful...
     $login = sanitize_user($author, true);
     $login = apply_filters('pre_user_login', $login);
     $nice_author = sanitize_title($author);
     $nice_author = apply_filters('pre_user_nicename', $nice_author);
     $reg_author = $wpdb->escape(preg_quote($author));
     $author = $wpdb->escape($author);
     $email = $wpdb->escape($email);
     $test_email = $wpdb->escape($test_email);
     $url = $wpdb->escape($url);
     // Check for an existing author rule....
     if (isset($this->link->settings['map authors']['name'][strtolower(trim($author))])) {
         $author_rule = $this->link->settings['map authors']['name'][strtolower(trim($author))];
     } else {
         $author_rule = NULL;
     }
     // User name is mapped to a particular author. If that author ID exists, use it.
     if (is_numeric($author_rule) and get_userdata((int) $author_rule)) {
         $id = (int) $author_rule;
         // User name is filtered out
     } elseif ('filter' == $author_rule) {
         $id = NULL;
     } else {
         // Check the database for an existing author record that might fit
         #-- WordPress 2.0+
         if (fwp_test_wp_version(FWP_SCHEMA_HAS_USERMETA)) {
             // First try the user core data table.
             $id = $wpdb->get_var("SELECT ID FROM {$wpdb->users}\n\t\t\t\tWHERE\n\t\t\t\t\tTRIM(LCASE(user_login)) = TRIM(LCASE('{$login}'))\n\t\t\t\t\tOR (\n\t\t\t\t\t\tLENGTH(TRIM(LCASE(user_email))) > 0\n\t\t\t\t\t\tAND TRIM(LCASE(user_email)) = TRIM(LCASE('{$test_email}'))\n\t\t\t\t\t)\n\t\t\t\t\tOR TRIM(LCASE(user_nicename)) = TRIM(LCASE('{$nice_author}'))\n\t\t\t\t");
             // If that fails, look for aliases in the user meta data table
             if (is_null($id)) {
                 $id = $wpdb->get_var("SELECT user_id FROM {$wpdb->usermeta}\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(meta_key = 'description' AND TRIM(LCASE(meta_value)) = TRIM(LCASE('{$author}')))\n\t\t\t\t\t\tOR (\n\t\t\t\t\t\t\tmeta_key = 'description'\n\t\t\t\t\t\t\tAND TRIM(LCASE(meta_value))\n\t\t\t\t\t\t\tRLIKE CONCAT(\n\t\t\t\t\t\t\t\t'(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*',\n\t\t\t\t\t\t\t\tTRIM(LCASE('{$reg_author}')),\n\t\t\t\t\t\t\t\t'( |\\t|\\r)*(\\n|\$)'\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t");
             }
             #-- WordPress 1.5.x
         } else {
             $id = $wpdb->get_var("SELECT ID from {$wpdb->users}\n\t\t\t\t WHERE\n\t\t\t\t\tTRIM(LCASE(user_login)) = TRIM(LCASE('{$login}')) OR\n\t\t\t\t\t(\n\t\t\t\t\t\tLENGTH(TRIM(LCASE(user_email))) > 0\n\t\t\t\t\t\tAND TRIM(LCASE(user_email)) = TRIM(LCASE('{$test_email}'))\n\t\t\t\t\t) OR\n\t\t\t\t\tTRIM(LCASE(user_firstname)) = TRIM(LCASE('{$author}')) OR\n\t\t\t\t\tTRIM(LCASE(user_nickname)) = TRIM(LCASE('{$author}')) OR\n\t\t\t\t\tTRIM(LCASE(user_nicename)) = TRIM(LCASE('{$nice_author}')) OR\n\t\t\t\t\tTRIM(LCASE(user_description)) = TRIM(LCASE('{$author}')) OR\n\t\t\t\t\t(\n\t\t\t\t\t\tLOWER(user_description)\n\t\t\t\t\t\tRLIKE CONCAT(\n\t\t\t\t\t\t\t'(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*',\n\t\t\t\t\t\t\tLCASE('{$reg_author}'),\n\t\t\t\t\t\t\t'( |\\t|\\r)*(\\n|\$)'\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t");
         }
         // ... if you don't find one, then do what you need to do
         if (is_null($id)) {
             if ($unfamiliar_author === 'create') {
                 $userdata = array();
                 #-- user table data
                 $userdata['ID'] = NULL;
                 // new user
                 $userdata['user_login'] = $login;
                 $userdata['user_nicename'] = $nice_author;
                 $userdata['user_pass'] = substr(md5(uniqid(microtime())), 0, 6);
                 // just something random to lock it up
                 $userdata['user_email'] = $email;
                 $userdata['user_url'] = $url;
                 $userdata['display_name'] = $author;
                 $id = wp_insert_user($userdata);
             } elseif (is_numeric($unfamiliar_author) and get_userdata((int) $unfamiliar_author)) {
                 $id = (int) $unfamiliar_author;
             } elseif ($unfamiliar_author === 'default') {
                 $id = 1;
             }
         }
     }
     if ($id) {
         $this->link->settings['map authors']['name'][strtolower(trim($author))] = $id;
     }
     return $id;
 }