show_users.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <script type="text/javascript" src="js/modules/show_users.js"></script>
  2. <style type="text/css">
  3. tr.hide{
  4. display: none;
  5. }
  6. table.userListTable{
  7. border-collapse: collapse;
  8. border: 0px;
  9. }
  10. table.userListTable td{
  11. padding-left: 5px;
  12. }
  13. tr.subusersShowHide{cursor: pointer;}
  14. th.subuserColumn{
  15. width: 140px;
  16. }
  17. td.actions{
  18. cursor: default;
  19. }
  20. </style>
  21. <?php
  22. /*
  23. *
  24. * OGP - Open Game Panel
  25. * Copyright (C) 2008 - 2017 The OGP Development Team
  26. *
  27. * http://www.opengamepanel.org/
  28. *
  29. * This program is free software; you can redistribute it and/or
  30. * modify it under the terms of the GNU General Public License
  31. * as published by the Free Software Foundation; either version 2
  32. * of the License, or any later version.
  33. *
  34. * This program is distributed in the hope that it will be useful,
  35. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  36. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  37. * GNU General Public License for more details.
  38. *
  39. * You should have received a copy of the GNU General Public License
  40. * along with this program; if not, write to the Free Software
  41. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  42. *
  43. */
  44. function exec_ogp_module() {
  45. global $db, $view, $loggedInUserInfo;
  46. $page_user = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1;
  47. $limit_user = (isset($_GET['limit']) && (int)$_GET['limit'] > 0) ? (int)$_GET['limit'] : 10;
  48. $search_field = (isset($_GET['search']) && !empty($_GET['search'])) ? $_GET['search'] : false;
  49. if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !hasValue($_GET['limit'])){
  50. $limit_user = $loggedInUserInfo["users_page_limit"];
  51. }
  52. echo '<h2>'.get_lang('users')."</h2>";
  53. $result = $db->getUserList_limit($page_user, $limit_user, $search_field);
  54. if (empty($result) && $search_field !== false) {
  55. print_failure(get_lang_f('no_results_found', htmlentities($search_field)));
  56. $view->refresh("?m=user_admin", 5);
  57. return;
  58. }
  59. echo '<table style="width: 100%;">
  60. <tr>
  61. <td style="width: 50%; vertical-align: middle; text-align: left;">
  62. <p><a href="?m=user_admin&amp;p=add">'.get_lang("add_new_user").'</a></p>
  63. </td>
  64. <td style="width: 50%; vertical-align: middle; text-align: right;">
  65. <form action="home.php" method="GET" style="float:right;">
  66. <input type ="hidden" name="m" value="user_admin" />
  67. <input name="search" type="text" id="search" />
  68. <input type="submit" value="'.get_lang('search').'" />
  69. </form>
  70. </td>
  71. </tr>
  72. </table>';
  73. echo '<table class="userListTable center" style="width: 100%;margin-top:100px;">';
  74. echo '<tr><th>'.get_lang('actions')."</th><th>".get_lang('username')."</th>";
  75. echo "<th>".get_lang('user_role')."</th>";
  76. echo "<th>".get_lang('email_address')."</th>";
  77. echo "<th>".get_lang('expires')."</th>";
  78. echo "<th class='subuserColumn'>".get_lang('subusers')."</th></tr>";
  79. $i = 0;
  80. foreach ( $result as $row )
  81. {
  82. // Show user's parent
  83. $ownedBy = "";
  84. if(!is_null($row['users_parent'])){
  85. $ownedBy = $row['users_parent'];
  86. }
  87. $user_expires = read_expire($row['user_expires']);
  88. print "<tr class='tr".($i++%2)." ";
  89. print $row['users_role'] . " ";
  90. if(!empty($ownedBy)){
  91. print "hide";
  92. }else{
  93. print "subusersShowHide";
  94. }
  95. print "' uid='" . $row['user_id'] . "'";
  96. if(!empty($ownedBy)){
  97. print "ownedby='" . $ownedBy . "'";
  98. }
  99. print ">";
  100. print "<td class='actions'><a href='?m=user_games&amp;p=assign&amp;user_id=$row[user_id]'>[".
  101. get_lang('assign_homes')."]</a><br />
  102. <a href='?m=user_admin&amp;p=del&amp;user_id=$row[user_id]'>[".get_lang('delete')."]</a><br />
  103. <a href='?m=user_admin&amp;p=edit_user&amp;user_id=$row[user_id]'>[".get_lang('edit_profile')."]</a></td>
  104. <td>".htmlentities($row['users_login'])."</td><td>".htmlentities($row['users_role'])."</td>
  105. <td>".htmlentities($row['users_email'])."</td>
  106. <td>$user_expires</td>";
  107. if(!empty($ownedBy)){
  108. print "<td></td>";
  109. }else{
  110. print "<td class='subUserShowHideTextTd expand' showtext='" . get_lang('show_subusers') . "' hidetext='" . get_lang('hide_subusers') . "'>" . get_lang('show_subusers') . " &darr;</td>";
  111. }
  112. print "</tr>";
  113. }
  114. echo '</table><br>';
  115. $count_users = $db->get_user_count($search_field);
  116. if(isset($_GET['search']) && !empty($_GET['search'])){
  117. $uri = '?m=user_admin&search='.$_GET['search'].'&limit='.$limit_user.'&page=';
  118. }
  119. else{
  120. $uri = '?m=user_admin&limit='.$limit_user.'&page=';
  121. }
  122. echo paginationPages($count_users[0]['total'], $page_user, $limit_user, $uri, 3, 'userManager');
  123. }
  124. ?>