Drupal investigation

user_import.install 1.0KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Install file for User Import module
  4. * Date of creation: 17.05.2017
  5. * Creator: Yuliia Polna
  6. * TODO:
  7. * - make normal test db
  8. * - manage updating of module
  9. * - add logs
  10. */
  11. use Drupal\user_import\Service\MysqlConnectService;
  12. use Drupal\user_import\Service\AddUserService;
  13. function user_import_install(){
  14. $servername = "localhost";
  15. $username = "root";
  16. $password = "Abccpm80";
  17. $dbname = "test";
  18. $dbConnect = new MysqlConnectService();
  19. $addUser = new AddUserService();
  20. $connection = $dbConnect->connect($servername,$username,$password,$dbname);
  21. $query = "SELECT * FROM adsuser WHERE access='MITARBEITER' ";
  22. $result = mysqli_query($connection,$query) or die("Query failed");
  23. $i = 0; //
  24. while ($row = mysqli_fetch_array($result)) {
  25. if ($i < 3) { //
  26. if(!($addUser->checkIfExists(utf8_encode($row['username'])))) {
  27. $addUser->createUser($row);
  28. }
  29. $i++; //
  30. } else { //
  31. break; //
  32. } //
  33. }
  34. }