Username.php 860 B

12345678910111213141516171819202122232425262728
  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 boolean True if username is of the correct format
  15. * @author Modified by Ivan Tcholakov, 15-SEP-2009.
  16. * @see HTML_QuickForm_Rule
  17. * The validation rule is served by the UserManager class as of this moment.
  18. */
  19. public function validate($username, $options)
  20. {
  21. if (api_get_setting('login_is_email') == 'true') {
  22. return api_valid_email($username);
  23. } else {
  24. return UserManager::is_username_valid($username);
  25. }
  26. }
  27. }