modGeneratePassNone.class.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. * or see https://www.gnu.org/
  17. */
  18. /**
  19. * \file htdocs/core/modules/security/generate/modGeneratePassNone.class.php
  20. * \ingroup core
  21. * \brief File to manage no password generation.
  22. */
  23. require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassword.php';
  24. /**
  25. * Class to generate a password according to rule 'no password'
  26. */
  27. class modGeneratePassNone extends ModeleGenPassword
  28. {
  29. /**
  30. * @var int ID
  31. */
  32. public $id;
  33. public $picto = 'fa-keyboard';
  34. /**
  35. * Minimum length (text visible by end user)
  36. *
  37. * @var string
  38. */
  39. public $length;
  40. /**
  41. * Minimum length in number of characters
  42. *
  43. * @var integer
  44. */
  45. public $length2;
  46. /**
  47. * @var DoliDB Database handler.
  48. */
  49. public $db;
  50. public $conf;
  51. public $lang;
  52. public $user;
  53. /**
  54. * Constructor
  55. *
  56. * @param DoliDB $db Database handler
  57. * @param Conf $conf Handler de conf
  58. * @param Translate $langs Handler de langue
  59. * @param User $user Handler du user connecte
  60. */
  61. public function __construct($db, $conf, $langs, $user)
  62. {
  63. $this->id = "none";
  64. $this->length = 0;
  65. $this->length2 = 0;
  66. $this->db = $db;
  67. $this->conf = $conf;
  68. $this->langs = $langs;
  69. $this->user = $user;
  70. }
  71. /**
  72. * Return description of module
  73. *
  74. * @return string Description of text
  75. */
  76. public function getDescription()
  77. {
  78. global $langs;
  79. return $langs->trans("PasswordGenerationNone");
  80. }
  81. /**
  82. * Return an example of password generated by this module
  83. *
  84. * @return string Example of password
  85. */
  86. public function getExample()
  87. {
  88. return $this->langs->trans("None");
  89. }
  90. /**
  91. * Build new password
  92. *
  93. * @return string Return a new generated password
  94. */
  95. public function getNewGeneratedPassword()
  96. {
  97. return "";
  98. }
  99. /**
  100. * Validate a password.
  101. * This function is called by User->setPassword() and internally to validate that the password matches the constraints.
  102. *
  103. * @param string $password Password to check
  104. * @return int 0 if KO, >0 if OK
  105. */
  106. public function validatePassword($password)
  107. {
  108. return 1;
  109. }
  110. }