add_to_group.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2017 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. function exec_ogp_module()
  25. {
  26. global $db;
  27. global $view;
  28. $group_id = $_REQUEST['group_id'];
  29. if ( !$db->isAdmin($_SESSION['user_id']) )
  30. {
  31. $result = $db->getUserGroupList($_SESSION['user_id']);
  32. foreach ( $result as $row ) #loop through the groups
  33. {
  34. if ( $row['group_id'] == $group_id )
  35. {
  36. $own_group = TRUE;
  37. }
  38. }
  39. }
  40. if(!$db->isAdmin($_SESSION['user_id']) && !isset($own_group))
  41. {
  42. echo "<p class='note'>".get_lang('not_available')."</p>";
  43. return;
  44. }
  45. if( isset($_POST['add_user_to_group']) )
  46. {
  47. $group_id = trim($_POST['group_id']);
  48. $user_id = trim($_POST['user_to_add']);
  49. $user = $db->getUserById($user_id);
  50. $group = $db->getGroupById($group_id);
  51. if ( $group['main_user_id'] == $user_id or !$db->addUsertoGroup($user_id,$group_id))
  52. {
  53. print_failure(get_lang_f('could_not_add_user_to_group', $user['users_login'], $group['group_name']));
  54. $view->refresh("?m=user_admin&amp;p=show_groups");
  55. return;
  56. }
  57. echo "<p class='success'>".get_lang_f('successfully_added_to_group', $user['users_login'], $group['group_name'])."</p>";
  58. $db->logger(get_lang_f('successfully_added_to_group', $user['users_login'], $group['group_name']));
  59. $view->refresh("?m=user_admin&amp;p=show_groups");
  60. }
  61. }
  62. ?>