Username.php 867 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * QuickForm rule to check if a username is of the correct format.
  5. */
  6. class HTML_QuickForm_Rule_Username extends HTML_QuickForm_Rule
  7. {
  8. /**
  9. * Function to check if a username is of the correct format.
  10. *
  11. * @param string $username Wanted username
  12. * @param array $options
  13. *
  14. * @return bool True if username is of the correct format
  15. *
  16. * @author Modified by Ivan Tcholakov, 15-SEP-2009.
  17. *
  18. * @see HTML_QuickForm_Rule
  19. * The validation rule is served by the UserManager class as of this moment.
  20. */
  21. public function validate($username, $options)
  22. {
  23. if (api_get_setting('login_is_email') == 'true') {
  24. return api_valid_email($username);
  25. } else {
  26. return UserManager::is_username_valid($username);
  27. }
  28. }
  29. }