function validate_form(&$errors)
 {
     global $lang_str, $data, $config;
     if (false === parent::validate_form($errors)) {
         return false;
     }
     $an =& $config->attr_names;
     $d_h =& Domains::singleton();
     if (is_null($this->opt['register_in_domain']) and is_null($this->opt['create_new_domain'])) {
         if (!isset($_POST['domain']) or $_POST['domain'] === "") {
             $errors[] = $lang_str['fe_domain_not_selected'];
             return false;
         }
         $this->did = $_POST['domain'];
         if (!isset($this->domain_names[$this->did])) {
             $errors[] = "You haven't access to domain which you selected: " . $d_h->get_domain_name($this->did);
             return false;
         }
     } elseif (!is_null($this->opt['register_in_domain'])) {
         $this->did = $this->opt['register_in_domain'];
     } else {
         $this->did = null;
     }
     /* vhen user do not have admin privilege, check username assignment mode */
     if (!$this->opt['admin_priv']) {
         if (false === ($this->uname_assign_mode = $this->get_uname_assign_mode($this->did))) {
             return false;
         }
         switch ($this->uname_assign_mode) {
             case "adminonly":
                 $errors[] = "Only admins could register users in this domain";
                 return false;
                 break;
             case "email":
                 //email verification
                 $email_parts = explode("@", $_POST['email'], 2);
                 $email_username = $email_parts[0];
                 $email_domain = $email_parts[1];
                 //set username by the email username
                 $_POST['uname'] = $email_username;
                 if ($this->opt['create_new_domain'] and $email_domain != $this->opt['create_new_domain']) {
                     $errors[] = $lang_str["err_domain_of_email_not_match"];
                     return false;
                 } else {
                     if (false === ($domain_names = $d_h->get_domain_names($this->did))) {
                         return false;
                     }
                     if (!in_array($email_domain, $domain_names)) {
                         $errors[] = $lang_str["err_domain_of_email_not_match"];
                         return false;
                     }
                 }
                 /* confirmation of registration is always required in this case */
                 $this->opt['require_confirmation'] = true;
                 break;
             case "fcfs":
                 //first come first served
                 break;
             default:
                 ErrorHandler::log_errors(PEAR::raiseError("Unknown value of username assignment mode: '" . $this->uname_assign_mode . "'"));
                 return false;
         }
     }
     if (is_null($this->opt['create_new_domain'])) {
         if (0 === ($user_exists = $data->is_user_exists($_POST['uname'], $this->did))) {
             return false;
         }
         if ($user_exists < 0) {
             $errors[] = $lang_str['fe_uname_already_choosen_1'] . " '" . $_POST['uname'] . "' " . $lang_str['fe_uname_already_choosen_2'];
             return false;
         }
     }
     if ($this->opt['choose_passw'] and $_POST['passwd'] != $_POST['passwd_r']) {
         $errors[] = $lang_str['fe_passwords_not_match'];
         return false;
     }
     if ($this->opt['terms_file'] and empty($_POST['accept'])) {
         $errors[] = $lang_str['fe_not_accepted_terms'];
         return false;
     }
     //check values of attributes
     $opt = array();
     if (false === Attributes::validate_form_attrs($this->attributes, $opt, $errors)) {
         return false;
     }
     /* Check email for the case somebody makes the attribute optional.
      * We need it.
      */
     if (!$_POST[$an['email']]) {
         $errors[] = $lang_str['fe_not_valid_email'];
         return false;
     }
     return true;
 }