show_users.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 - 2018 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"] && !(isset($_GET['limit']) and !empty($_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" value="' . $search_field . '"/>
  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:50px;">';
  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. $parentInfo = $db->getUserById($ownedBy);
  87. if(is_array($parentInfo) && array_key_exists("user_expires", $parentInfo) && $parentInfo['user_expires'] != "X"){
  88. $row['user_expires'] = $parentInfo['user_expires'];
  89. }
  90. }
  91. $user_expires = read_expire($row['user_expires']);
  92. print "<tr class='tr".($i++%2)." ";
  93. print $row['users_role'] . " ";
  94. if(!empty($ownedBy) && empty($search_field)){
  95. print "hide";
  96. }else{
  97. print "subusersShowHide";
  98. }
  99. print "' uid='" . $row['user_id'] . "'";
  100. if(!empty($ownedBy)){
  101. print "ownedby='" . $ownedBy . "'";
  102. }
  103. print ">";
  104. print "<td class='actions'><a href='?m=user_games&amp;p=assign&amp;user_id=" . $row['user_id'] . "'>[".
  105. get_lang('assign_homes')."]</a><br />
  106. <a href='?m=user_admin&amp;p=del&amp;user_id=" . $row['user_id'] . "'>[".get_lang('delete')."]</a><br />
  107. <a href='?m=user_admin&amp;p=edit_user&amp;user_id=" . $row['user_id'] . "'>[".get_lang('edit_profile')."]</a></td>
  108. <td>".htmlentities($row['users_login'])."</td><td>".htmlentities($row['users_role'])."</td>
  109. <td>".htmlentities($row['users_email'])."</td>
  110. <td>$user_expires</td>";
  111. if(!empty($ownedBy)){
  112. print "<td></td>";
  113. }else{
  114. print "<td class='subUserShowHideTextTd expand' showtext='" . get_lang('show_subusers') . "' hidetext='" . get_lang('hide_subusers') . "'>" . get_lang('show_subusers') . " &darr;</td>";
  115. }
  116. print "</tr>";
  117. }
  118. echo '</table><br>';
  119. $count_users = $db->get_user_count($search_field);
  120. if(isset($_GET['search']) && !empty($_GET['search'])){
  121. $uri = '?m=user_admin&search='.$_GET['search'].'&limit='.$limit_user.'&page=';
  122. }
  123. else{
  124. $uri = '?m=user_admin&limit='.$limit_user.'&page=';
  125. }
  126. echo paginationPages($count_users[0]['total'], $page_user, $limit_user, $uri, 3, 'userManager');
  127. }
  128. ?>