PageRenderTime 55ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/phpmyfaq/admin/user.php

https://github.com/cyrke/phpMyFAQ
PHP | 633 lines | 524 code | 45 blank | 64 comment | 92 complexity | 941bbd4e0f84b116a89abd527e87eb18 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /**
  3. * Displays the user managment frontend
  4. *
  5. * PHP 5.2
  6. *
  7. * This Source Code Form is subject to the terms of the Mozilla Public License,
  8. * v. 2.0. If a copy of the MPL was not distributed with this file, You can
  9. * obtain one at http://mozilla.org/MPL/2.0/.
  10. *
  11. * @category phpMyFAQ
  12. * @package Administration
  13. * @author Lars Tiedemann <php@larstiedemann.de>
  14. * @author Uwe Pries <uwe.pries@digartis.de>
  15. * @author Sarah Hermann <sayh@gmx.de>
  16. * @author Thorsten Rinne <thorsten@phpmyfaq.de>
  17. * @copyright 2005-2012 phpMyFAQ Team
  18. * @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
  19. * @link http://www.phpmyfaq.de
  20. * @since 2005-12-15
  21. */
  22. if (!defined('IS_VALID_PHPMYFAQ')) {
  23. header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']));
  24. exit();
  25. }
  26. if ($permission['edituser'] || $permission['deluser'] || $permission['adduser']) {
  27. // set some parameters
  28. $selectSize = 10;
  29. $defaultUserAction = 'list';
  30. $defaultUserStatus = 'active';
  31. // what shall we do?
  32. // actions defined by url: user_action=
  33. $userAction = PMF_Filter::filterInput(INPUT_GET, 'user_action', FILTER_SANITIZE_STRING, $defaultUserAction);
  34. // actions defined by submit button
  35. if (isset($_POST['user_action_deleteConfirm'])) {
  36. $userAction = 'delete_confirm';
  37. }
  38. if (isset($_POST['cancel'])) {
  39. $userAction = $defaultUserAction;
  40. }
  41. // update user rights
  42. if ($userAction == 'update_rights' && $permission['edituser']) {
  43. $message = '';
  44. $userAction = $defaultUserAction;
  45. $userId = PMF_Filter::filterInput(INPUT_POST, 'user_id', FILTER_VALIDATE_INT, 0);
  46. if ($userId == 0) {
  47. $message .= sprintf('<p class="alert alert-error">%s</p>', $PMF_LANG['ad_user_error_noId']);
  48. } else {
  49. $user = new PMF_User($faqConfig);
  50. $perm = $user->perm;
  51. // @todo: Add PMF_Filter::filterInputArray()
  52. $userRights = isset($_POST['user_rights']) ? $_POST['user_rights'] : array();
  53. if (!$perm->refuseAllUserRights($userId)) {
  54. $message .= sprintf('<p class="alert alert-error">%s</p>', $PMF_LANG['ad_msg_mysqlerr']);
  55. }
  56. foreach ($userRights as $rightId) {
  57. $perm->grantUserRight($userId, $rightId);
  58. }
  59. $idUser = $user->getUserById($userId);
  60. $message .= sprintf('<p class="alert alert-success">%s <strong>%s</strong> %s</p>',
  61. $PMF_LANG['ad_msg_savedsuc_1'],
  62. $user->getLogin(),
  63. $PMF_LANG['ad_msg_savedsuc_2']);
  64. $message .= '<script type="text/javascript">updateUser('.$userId.');</script>';
  65. }
  66. }
  67. // update user data
  68. if ($userAction == 'update_data' && $permission['edituser']) {
  69. $message = '';
  70. $userAction = $defaultUserAction;
  71. $userId = PMF_Filter::filterInput(INPUT_POST, 'user_id', FILTER_VALIDATE_INT, 0);
  72. if ($userId == 0) {
  73. $message .= sprintf('<p class="alert alert-error">%s</p>', $PMF_LANG['ad_user_error_noId']);
  74. } else {
  75. $userData = array();
  76. $userData['display_name'] = PMF_Filter::filterInput(INPUT_POST, 'display_name', FILTER_SANITIZE_STRING, '');
  77. $userData['email'] = PMF_Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL, '');
  78. $userData['last_modified'] = PMF_Filter::filterInput(INPUT_POST, 'last_modified', FILTER_SANITIZE_STRING, '');
  79. $userStatus = PMF_Filter::filterInput(INPUT_POST, 'user_status', FILTER_SANITIZE_STRING, $defaultUserStatus);
  80. $user = new PMF_User($faqConfig);
  81. $user->getUserById($userId);
  82. $stats = $user->getStatus();
  83. // set new password an send email if user is switched to active
  84. if ($stats == 'blocked' && $userStatus == 'active') {
  85. $consonants = array("b","c","d","f","g","h","j","k","l","m","n","p","r","s","t","v","w","x","y","z");
  86. $vowels = array("a","e","i","o","u");
  87. $newPassword = '';
  88. srand((double)microtime()*1000000);
  89. for ($i = 1; $i <= 4; $i++) {
  90. $newPassword .= $consonants[rand(0,19)];
  91. $newPassword .= $vowels[rand(0,4)];
  92. }
  93. $user->changePassword($newPassword);
  94. $mail = new PMF_Mail($faqConfig);
  95. $mail->addTo($userData['email']);
  96. $mail->subject = '[%sitename%] Login name / activation';
  97. $mail->message = sprintf("\nName: %s\nLogin name: %s\nNew password: %s\n\n",
  98. $userData['display_name'],
  99. $user->getLogin(),
  100. $newPassword);
  101. $result = $mail->send();
  102. unset($mail);
  103. }
  104. if (!$user->userdata->set(array_keys($userData), array_values($userData)) or !$user->setStatus($userStatus)) {
  105. $message .= sprintf('<p class="alert alert-error">%s</p>', $PMF_LANG['ad_msg_mysqlerr']);
  106. } else {
  107. $message .= sprintf('<p class="alert alert-success">%s <strong>%s</strong> %s</p>',
  108. $PMF_LANG['ad_msg_savedsuc_1'],
  109. $user->getLogin(),
  110. $PMF_LANG['ad_msg_savedsuc_2']);
  111. $message .= '<script type="text/javascript">updateUser('.$userId.');</script>';
  112. }
  113. }
  114. }
  115. // delete user confirmation
  116. if ($userAction == 'delete_confirm' && $permission['deluser']) {
  117. $message = '';
  118. $user = new PMF_User_CurrentUser($faqConfig);
  119. $userId = PMF_Filter::filterInput(INPUT_POST, 'user_list_select', FILTER_VALIDATE_INT, 0);
  120. if ($userId == 0) {
  121. $message .= sprintf('<p class="alert alert-error">%s</p>', $PMF_LANG['ad_user_error_noId']);
  122. $userAction = $defaultUserAction;
  123. } else {
  124. $user->getUserById($userId);
  125. // account is protected
  126. if ($user->getStatus() == 'protected' || $userId == 1) {
  127. $message .= sprintf('<p class="alert alert-error">%s</p>', $PMF_LANG['ad_user_error_protectedAccount']);
  128. $userAction = $defaultUserAction;
  129. } else {
  130. ?>
  131. <header>
  132. <h2><?php print $PMF_LANG['ad_user_deleteUser']; ?> <strong><?php print $user->getLogin(); ?></strong></h2>
  133. </header>
  134. <p class="alert alert-danger"><?php print $PMF_LANG["ad_user_del_3"].' '.$PMF_LANG["ad_user_del_1"].' '.$PMF_LANG["ad_user_del_2"]; ?></p>
  135. <form action ="?action=user&amp;user_action=delete" method="post">
  136. <input type="hidden" name="user_id" value="<?php print $userId; ?>" />
  137. <input type="hidden" name="csrf" value="<?php print $user->getCsrfTokenFromSession(); ?>" />
  138. <p align="center">
  139. <button class="btn btn-danger" type="submit">
  140. <?php print $PMF_LANG["ad_gen_yes"]; ?>
  141. </button>
  142. <a class="btn btn-info" href="?action=user">
  143. <?php print $PMF_LANG["ad_gen_no"]; ?>
  144. </a>
  145. </p>
  146. </form>
  147. <?php
  148. }
  149. }
  150. }
  151. // delete user
  152. if ($userAction == 'delete' && $permission['deluser']) {
  153. $message = '';
  154. $user = new PMF_User($faqConfig);
  155. $userId = PMF_Filter::filterInput(INPUT_POST, 'user_id', FILTER_VALIDATE_INT, 0);
  156. $csrfOkay = true;
  157. $csrfToken = PMF_Filter::filterInput(INPUT_POST, 'csrf', FILTER_SANITIZE_STRING);
  158. if (!isset($_SESSION['phpmyfaq_csrf_token']) || $_SESSION['phpmyfaq_csrf_token'] !== $csrfToken) {
  159. $csrfOkay = false;
  160. }
  161. $userAction = $defaultUserAction;
  162. if ($userId == 0 && !$csrfOkay) {
  163. $message .= sprintf('<p class="alert alert-error">%s</p>', $PMF_LANG['ad_user_error_noId']);
  164. } else {
  165. if (!$user->getUserById($userId)) {
  166. $message .= sprintf('<p class="alert alert-error">%s</p>', $PMF_LANG['ad_user_error_noId']);
  167. }
  168. if (!$user->deleteUser()) {
  169. $message .= sprintf('<p class="alert alert-error">%s</p>', $PMF_LANG['ad_user_error_delete']);
  170. } else {
  171. // Move the categories ownership to admin (id == 1)
  172. $oCat = new PMF_Category($faqConfig, false);
  173. $oCat->setUser($currentAdminUser);
  174. $oCat->setGroups($currentAdminGroups);
  175. $oCat->moveOwnership($userId, 1);
  176. // Remove the user from groups
  177. if ('medium' == $faqConfig->get('security.permLevel')) {
  178. $oPerm = PMF_Perm::selectPerm('medium', $faqConfig);
  179. $oPerm->removeFromAllGroups($userId);
  180. }
  181. $message .= sprintf('<p class="alert alert-success">%s</p>', $PMF_LANG['ad_user_deleted']);
  182. }
  183. $userError = $user->error();
  184. if ($userError != "") {
  185. $message .= sprintf('<p class="alert alert-error">%s</p>', $userError);
  186. }
  187. }
  188. }
  189. // save new user
  190. if ($userAction == 'addsave' && $permission['adduser']) {
  191. $user = new PMF_User($faqConfig);
  192. $message = '';
  193. $messages = array();
  194. $user_name = PMF_Filter::filterInput(INPUT_POST, 'user_name', FILTER_SANITIZE_STRING, '');
  195. $user_realname = PMF_Filter::filterInput(INPUT_POST, 'user_realname', FILTER_SANITIZE_STRING, '');
  196. $user_password = PMF_Filter::filterInput(INPUT_POST, 'user_password', FILTER_SANITIZE_STRING, '');
  197. $user_email = PMF_Filter::filterInput(INPUT_POST, 'user_email', FILTER_VALIDATE_EMAIL);
  198. $user_password = PMF_Filter::filterInput(INPUT_POST, 'user_password', FILTER_SANITIZE_STRING, '');
  199. $user_password_confirm = PMF_Filter::filterInput(INPUT_POST, 'user_password_confirm', FILTER_SANITIZE_STRING, '');
  200. $csrfOkay = true;
  201. $csrfToken = PMF_Filter::filterInput(INPUT_POST, 'csrf', FILTER_SANITIZE_STRING);
  202. if (!isset($_SESSION['phpmyfaq_csrf_token']) || $_SESSION['phpmyfaq_csrf_token'] !== $csrfToken) {
  203. $csrfOkay = false;
  204. }
  205. if ($user_password != $user_password_confirm) {
  206. $user_password = '';
  207. $user_password_confirm = '';
  208. $messages[] = $PMF_LANG['ad_user_error_passwordsDontMatch'];
  209. }
  210. // check login name
  211. if (!$user->isValidLogin($user_name)) {
  212. $user_name = '';
  213. $messages[] = $PMF_LANG['ad_user_error_loginInvalid'];
  214. }
  215. if ($user->getUserByLogin($user_name)) {
  216. $user_name = '';
  217. $messages[] = $PMF_LANG['ad_adus_exerr'];
  218. }
  219. // check realname
  220. if ($user_realname == '') {
  221. $user_realname = '';
  222. $messages[] = $PMF_LANG['ad_user_error_noRealName'];
  223. }
  224. // check e-mail
  225. if (is_null($user_email)) {
  226. $user_email = '';
  227. $messages[] = $PMF_LANG['ad_user_error_noEmail'];
  228. }
  229. // ok, let's go
  230. if (count($messages) == 0 && $csrfOkay) {
  231. // create user account (login and password)
  232. if (!$user->createUser($user_name, $user_password)) {
  233. $messages[] = $user->error();
  234. } else {
  235. // set user data (realname, email)
  236. $user->userdata->set(array('display_name', 'email'), array($user_realname, $user_email));
  237. // set user status
  238. $user->setStatus($defaultUserStatus);
  239. }
  240. }
  241. // no errors, show list
  242. if (count($messages) == 0) {
  243. $userAction = $defaultUserAction;
  244. $message = sprintf('<p class="alert alert-success">%s</p>', $PMF_LANG['ad_adus_suc']);
  245. // display error messages and show form again
  246. } else {
  247. $userAction = 'add';
  248. $message = '<p class="alert alert-error">';
  249. foreach ($messages as $err) {
  250. $message .= $err . '<br />';
  251. }
  252. $message .= '</p>';
  253. }
  254. }
  255. if (!isset($message)) {
  256. $message = '';
  257. }
  258. // show new user form
  259. if ($userAction == 'add' && $permission['adduser']) {
  260. ?>
  261. <header>
  262. <h2><?php print $PMF_LANG["ad_adus_adduser"]; ?></h2>
  263. </header>
  264. <div id="user_message"><?php print $message; ?></div>
  265. <div id="user_create">
  266. <form class="form-horizontal" action="?action=user&amp;user_action=addsave" method="post">
  267. <input type="hidden" name="csrf" value="<?php print $user->getCsrfTokenFromSession(); ?>" />
  268. <div class="control-group">
  269. <label class="control-label" for="user_name"><?php print $PMF_LANG["ad_adus_name"]; ?></label>
  270. <div class="controls">
  271. <input type="text" name="user_name" id="user_name" required tabindex="1"
  272. value="<?php print (isset($user_name) ? $user_name : ''); ?>" />
  273. </div>
  274. </div>
  275. <div class="control-group">
  276. <label class="control-label" for="user_realname"><?php print $PMF_LANG["ad_user_realname"]; ?></label>
  277. <div class="controls">
  278. <input type="text" name="user_realname" id="user_realname" required tabindex="2"
  279. value="<?php print (isset($user_realname) ? $user_realname : ''); ?>" />
  280. </div>
  281. </div>
  282. <div class="control-group">
  283. <label class="control-label" for="user_email"><?php print $PMF_LANG["ad_entry_email"]; ?></label>
  284. <div class="controls">
  285. <input type="email" name="user_email" id="user_email" required tabindex="3"
  286. value="<?php print (isset($user_email) ? $user_email : ''); ?>" />
  287. </div>
  288. </div>
  289. <div class="control-group">
  290. <label class="control-label" for="password"><?php print $PMF_LANG["ad_adus_password"]; ?></label>
  291. <div class="controls">
  292. <input type="password" name="user_password" id="password" required tabindex="4"
  293. value="<?php print (isset($user_password) ? $user_password : ''); ?>" />
  294. </div>
  295. </div>
  296. <div class="control-group">
  297. <label class="control-label" for="password_confirm"><?php print $PMF_LANG["ad_passwd_con"]; ?></label>
  298. <div class="controls">
  299. <input type="password" name="user_password_confirm" id="password_confirm" required
  300. tabindex="5" value="<?php print (isset($user_password_confirm) ? $user_password_confirm : ''); ?>" />
  301. </div>
  302. </div>
  303. <div class="form-actions">
  304. <button class="btn btn-success" type="submit">
  305. <?php print $PMF_LANG["ad_gen_save"]; ?>
  306. </button>
  307. <a class="btn btn-info" href="?action=user">
  308. <?php print $PMF_LANG['ad_gen_cancel']; ?>
  309. </a>
  310. </div>
  311. </form>
  312. </div> <!-- end #user_create -->
  313. <?php
  314. }
  315. // show list of users
  316. if ($userAction == 'list') {
  317. ?>
  318. <header>
  319. <h2><?php print $PMF_LANG['ad_user']; ?></h2>
  320. </header>
  321. <script type="text/javascript" src="assets/js/user.js"></script>
  322. <script type="text/javascript">
  323. /* <![CDATA[ */
  324. /**
  325. * Returns the user data as JSON object
  326. *
  327. * @param user_id User ID
  328. */
  329. function getUserData(user_id) {
  330. $('#user_data_table').empty();
  331. $.getJSON("index.php?action=ajax&ajax=user&ajaxaction=get_user_data&user_id=" + user_id, function(data) {
  332. $('#update_user_id').val(data.user_id);
  333. $('#user_status_select').val(data.status);
  334. $('#user_list_autocomplete').val(data.login);
  335. $("#user_list_select").val(data.user_id);
  336. // Append input fields
  337. $('#user_data_table').append(
  338. '<div class="control-group">' +
  339. '<label class="control-label"><?php print $PMF_LANG["ad_user_realname"]; ?></label>' +
  340. '<div class="controls">' +
  341. '<input type="text" name="display_name" value="' + data.display_name + '" required />' +
  342. '</div>' +
  343. '</div>' +
  344. '<div class="control-group">' +
  345. '<label class="control-label"><?php print $PMF_LANG["ad_entry_email"]; ?></label>' +
  346. '<div class="controls">' +
  347. '<input type="email" name="email" value="' + data.email + '" required />' +
  348. '</div>' +
  349. '</div>' +
  350. '<input type="hidden" name="last_modified" value="' + data.last_modified + '" />'
  351. );
  352. });
  353. }
  354. /* ]]> */
  355. </script>
  356. <div id="user_message"><?php print $message; ?></div>
  357. <div class="row-fluid">
  358. <div class="span4" id="userAccounts">
  359. <fieldset>
  360. <legend><?php print $PMF_LANG["ad_user_username"]; ?></legend>
  361. <form name="user_select" id="user_select" action="?action=user&amp;user_action=delete_confirm"
  362. method="post">
  363. <label for="user_list_autocomplete"><?php print $PMF_LANG['ad_auth_user']; ?>:</label>
  364. <input type="text" id="user_list_autocomplete" name="user_list_search" data-provide="typeahead" />
  365. <script type="text/javascript">
  366. //<![CDATA[
  367. var mappedIds,
  368. userNames;
  369. $('#user_list_autocomplete').typeahead({
  370. source: function (query, process) {
  371. return $.get("index.php?action=ajax&ajax=user&ajaxaction=get_user_list", { q: query }, function (data) {
  372. mappedIds = [];
  373. userNames = [];
  374. $.each(data, function(i, user) {
  375. mappedIds[user.name] = user.user_id;
  376. userNames.push(user.name);
  377. });
  378. return process(userNames);
  379. });
  380. },
  381. updater: function(userName) {
  382. userId = mappedIds[userName];
  383. $("#user_list_select").val(userId);
  384. getUserData(userId);
  385. getUserRights(userId);
  386. }
  387. });
  388. //]]>
  389. </script>
  390. <p>
  391. <input type="hidden" id="user_list_select" name="user_list_select" value="" />
  392. <button class="btn btn-danger" type="submit">
  393. <?php print $PMF_LANG['ad_gen_delete']; ?>
  394. </button>
  395. </p>
  396. </form>
  397. </fieldset>
  398. <fieldset>
  399. <p>
  400. <a class="btn btn-success" href="?action=user&amp;user_action=add">
  401. <?php print $PMF_LANG["ad_user_add"]; ?>
  402. </a>
  403. <?php if ($permission['edituser']): ?>
  404. <br/>
  405. <br/>
  406. <a class="btn btn-info" href="?action=user&amp;user_action=listallusers">
  407. <?php print $PMF_LANG['list_all_users']; ?>
  408. </a>
  409. <?php endif; ?>
  410. </p>
  411. </fieldset>
  412. </div>
  413. <div class="span4" id="userDetails">
  414. <fieldset>
  415. <legend id="user_data_legend"><?php print $PMF_LANG["ad_user_profou"]; ?></legend>
  416. <form action="?action=user&amp;user_action=update_data" method="post">
  417. <input id="update_user_id" type="hidden" name="user_id" value="0" />
  418. <p>
  419. <label for="user_status_select" class="small">
  420. <?php print $PMF_LANG['ad_user_status']; ?>
  421. </label>
  422. <select id="user_status_select" name="user_status" >
  423. <option value="active"><?php print $PMF_LANG['ad_user_active']; ?></option>
  424. <option value="blocked"><?php print $PMF_LANG['ad_user_blocked']; ?></option>
  425. <option value="protected"><?php print $PMF_LANG['ad_user_protected']; ?></option>
  426. </select>
  427. </p>
  428. <div id="user_data_table"></div><!-- end #user_data_table -->
  429. <p>
  430. <button class="btn btn-primary" type="submit">
  431. <?php print $PMF_LANG["ad_gen_save"]; ?>
  432. </button>
  433. </p>
  434. </form>
  435. </fieldset>
  436. </div>
  437. <div class="span4" id="userRights">
  438. <form id="rightsForm" action="?action=user&amp;user_action=update_rights" method="post">
  439. <fieldset>
  440. <legend id="user_rights_legend"><?php print $PMF_LANG["ad_user_rights"]; ?></legend>
  441. <input id="rights_user_id" type="hidden" name="user_id" value="0" />
  442. <a class="btn btn-small" href="javascript:formCheckAll('rightsForm')">
  443. <?php print $PMF_LANG['ad_user_checkall']; ?>
  444. </a>
  445. <a class="btn btn-small" href="javascript:formUncheckAll('rightsForm')">
  446. <?php print $PMF_LANG['ad_user_uncheckall']; ?>
  447. </a>
  448. <?php foreach ($user->perm->getAllRightsData() as $right): ?>
  449. <label class="checkbox">
  450. <input id="user_right_<?php print $right['right_id']; ?>" type="checkbox"
  451. name="user_rights[]" value="<?php print $right['right_id']; ?>"/>
  452. <?php
  453. if (isset($PMF_LANG['rightsLanguage'][$right['name']])) {
  454. echo $PMF_LANG['rightsLanguage'][$right['name']];
  455. } else {
  456. echo $right['description'];
  457. }
  458. ?>
  459. </label>
  460. <?php endforeach; ?>
  461. <button class="btn btn-primary" type="submit">
  462. <?php print $PMF_LANG["ad_gen_save"]; ?>
  463. </button>
  464. </fieldset>
  465. </form>
  466. </div>
  467. </div>
  468. <?php
  469. if (isset($_GET['user_id'])) {
  470. $userId = PMF_Filter::filterInput(INPUT_GET, 'user_id', FILTER_VALIDATE_INT, 0);
  471. echo '<script type="text/javascript">updateUser('.$userId.');</script>';
  472. }
  473. }
  474. // show list of all users
  475. if ($userAction == 'listallusers' && $permission['edituser']) {
  476. $allUsers = $user->getAllUsers();
  477. $numUsers = count($allUsers);
  478. $page = PMF_Filter::filterInput(INPUT_GET, 'page', FILTER_VALIDATE_INT, 0);
  479. $perPage = 25;
  480. $numPages = ceil($numUsers / $perPage);
  481. $lastPage = $page * $perPage;
  482. $firstPage = $lastPage - $perPage;
  483. $baseUrl = sprintf(
  484. '%s?action=user&amp;user_action=listallusers&amp;page=%d',
  485. PMF_Link::getSystemRelativeUri(),
  486. $page
  487. );
  488. // Pagination options
  489. $options = array(
  490. 'baseUrl' => $baseUrl,
  491. 'total' => $numUsers,
  492. 'perPage' => $perPage,
  493. 'pageParamName' => 'page',
  494. 'layoutTpl' => '<strong>{LAYOUT_CONTENT}</strong>'
  495. );
  496. $pagination = new PMF_Pagination($faqConfig, $options);
  497. ?>
  498. <header>
  499. <h2><?php print $PMF_LANG['ad_user']; ?></h2>
  500. </header>
  501. <div id="user_message"><?php print $message; ?></div>
  502. <table class="table table-striped">
  503. <thead>
  504. <tr>
  505. <th><?php print $PMF_LANG['ad_entry_id'] ?></th>
  506. <th><?php print $PMF_LANG['ad_user_status'] ?></th>
  507. <th><?php print $PMF_LANG['ad_user_realname'] ?></th>
  508. <th><?php print $PMF_LANG['ad_auth_user'] ?></th>
  509. <th><?php print $PMF_LANG['msgNewContentMail'] ?></th>
  510. <th colspan="2">&nbsp;</th>
  511. </tr>
  512. </thead>
  513. <?php if ($perPage < $numUsers): ?>
  514. <tfoot>
  515. <tr>
  516. <td colspan="7"><?php print $pagination->render(); ?></td>
  517. </tr>
  518. </tfoot>
  519. <?php endif; ?>
  520. <tbody>
  521. <?php
  522. $counter = $displayedCounter = 0;
  523. foreach ($allUsers as $userId) {
  524. $user->getUserById($userId);
  525. if ($displayedCounter >= $perPage) {
  526. continue;
  527. }
  528. $counter++;
  529. if ($counter <= $firstPage) {
  530. continue;
  531. }
  532. $displayedCounter++;
  533. ?>
  534. <tr class="row_user_id_<?php print $user->getUserId() ?>">
  535. <td><?php print $user->getUserId() ?></td>
  536. <td>
  537. <?php print $user->getStatus() ?>
  538. </td>
  539. <td><?php print $user->getUserData('display_name') ?></td>
  540. <td><?php print $user->getLogin() ?></td>
  541. <td>
  542. <a href="mailto:<?php print $user->getUserData('email') ?>">
  543. <?php print $user->getUserData('email') ?>
  544. </a>
  545. </td>
  546. <td>
  547. <a href="?action=user&amp;user_id=<?php print $user->getUserData('user_id')?>" class="btn btn-info">
  548. <?php print $PMF_LANG['ad_user_edit'] ?>
  549. </a>
  550. </td>
  551. <td>
  552. <?php if ($user->getStatus() !== 'protected'): ?>
  553. <a onclick="deleteUser(<?php print $user->getUserData('user_id') ?>); return false;"
  554. href="javascript:;" class="btn btn-danger">
  555. <?php print $PMF_LANG['ad_user_delete'] ?>
  556. </a>
  557. <?php endif; ?>
  558. </td>
  559. </tr>
  560. <?php
  561. }
  562. ?>
  563. </tbody>
  564. </table>
  565. <script type="text/javascript">
  566. /* <![CDATA[ */
  567. /**
  568. * Ajax call to delete user
  569. *
  570. * @param userId
  571. */
  572. function deleteUser(userId)
  573. {
  574. if (confirm('<?php print $PMF_LANG['ad_user_del_3'] ?>')) {
  575. $.getJSON("index.php?action=ajax&ajax=user&ajaxaction=delete_user&user_id=" + userId,
  576. function(response) {
  577. $('#user_message').html(response);
  578. $('.row_user_id_' + userId).fadeOut('slow');
  579. });
  580. }
  581. }
  582. /* ]]> */
  583. </script>
  584. <?php
  585. }
  586. } else {
  587. print $PMF_LANG['err_NotAuth'];
  588. }