FixUsersLongLogin.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. Lib::loadClass('RouteBase');
  3. class Route_FixUsersLongLogin extends RouteBase {
  4. public function handleAuth() {
  5. if (!User::logged()) {
  6. throw new HttpException('Unauthorized', 401);
  7. }
  8. }
  9. public function defaultAction() {
  10. SE_Layout::gora();
  11. SE_Layout::menu();
  12. $this->_menu();
  13. SE_Layout::dol();
  14. }
  15. private function _menu($selectedMonth) {
  16. $usersTodoList = $this->getUsersWithTooLongLogin();
  17. ?>
  18. <div class="container">
  19. <?php if (empty($usersTodoList)) : ?>
  20. <div class="alert alert-info">
  21. Brak użytwkoników z loginem dłuższym niż 20 znaków
  22. </div>
  23. <?php else : ?>
  24. <table class="table table-bordered table-hovered">
  25. <tr>
  26. <th>Lp.</th>
  27. <th>Nr</th>
  28. <th>Login</th>
  29. <th>Poziom Uprawnień</th>
  30. <th>Status</th>
  31. <th>Data synch.</th>
  32. <th>Nowy login</th>
  33. <th>Synch. nowy login</th>
  34. </tr>
  35. <?php $i = 0; foreach ($usersTodoList as $user) : $i++ ?>
  36. <?php $newLogin = substr($user->ADM_ACCOUNT, 0, 20); ?>
  37. <tr>
  38. <td><?php echo $i; ?></td>
  39. <td><?php echo $user->ID; ?></td>
  40. <td style="font-family:monospace">
  41. <span style=""><?php echo substr($user->ADM_ACCOUNT, 0, 20); ?></span><span style="color:red"><?php echo substr($user->ADM_ACCOUNT, 20); ?></span>
  42. </td>
  43. <td><?php echo $user->ADM_ADMIN_LEVEL; ?></td>
  44. <td><?php echo $user->A_STATUS; ?></td>
  45. <td><?php echo $user->A_SYNC_LDAP_DATE; ?></td>
  46. <td><?php echo $newLogin; ?></td>
  47. <td><a target="_blank"
  48. href="https://biuro.biall-net.pl/SE/version-git/index.php?MENU_INIT=SYNC_LDAP_PERMS&syncUsr=<?php echo $newLogin; ?>">synchronizuj do LDAP (<?php echo $newLogin; ?>)</td>
  49. </tr>
  50. <?php endforeach; ?>
  51. </table>
  52. <?php endif; ?>
  53. </div>
  54. <?php
  55. }
  56. public function getUsersWithTooLongLogin() {
  57. $usersTodoList = array();
  58. $db = DB::getDB();
  59. $sql = <<<SQL
  60. select `ID`, `ADM_ACCOUNT`, `A_STATUS`
  61. , `ADM_ADMIN_LEVEL`
  62. , `A_SYNC_LDAP_DATE`
  63. from `ADMIN_USERS`
  64. where LENGTH(`ADM_ACCOUNT`) > 20
  65. SQL;
  66. $res = $db->query($sql);
  67. while ($r = $db->fetch($res)) {
  68. $usersTodoList[$r->ADM_ACCOUNT] = $r;
  69. }
  70. return $usersTodoList;
  71. }
  72. }