You are here

function _og_massadd_textareavalidate in Organic Groups Mass Add 7

Same name and namespace in other branches
  1. 6 og_massadd.module \_og_massadd_textareavalidate()

Validate text area contents

1 call to _og_massadd_textareavalidate()
og_massadd_massadd_form_validate in ./og_massadd.module
Mass adding users validation

File

./og_massadd.module, line 175
The og_massadd module file

Code

function _og_massadd_textareavalidate($input) {
  $data = explode("\n", $input);
  foreach ($data as $i => $line) {
    if (trim($line)) {
      $line = array_map("trim", explode(",", $line));
      if (!(count($line) > 0 && count($line) < 5)) {

        // Check number of fields 1-5
        return FALSE;
      }
      if (count($line) == 5) {
        $email = $line[3];
      }
      else {
        $email = end($line);
      }
      if ((!valid_email_address($email) || empty($email)) && !user_load_by_name($email)) {
        return FALSE;
      }
    }
  }
  return TRUE;
}