add_group.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2018 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. if( isset($_POST['add_group']) )
  29. {
  30. $group = sanitizeInputStr($_POST['group_name']);
  31. $groupWithSameName = $db->getGroupByName($group);
  32. if (empty($group))
  33. {
  34. print_failure(get_lang('group_name_empty'));
  35. return;
  36. }
  37. if ($groupWithSameName !== false && is_array($groupWithSameName) && count($groupWithSameName) > 0)
  38. {
  39. print_failure(get_lang_f("failed_to_add_group_exists_already",$group));
  40. $view->refresh("?m=user_admin&amp;p=show_groups", 5);
  41. return;
  42. }
  43. if ( !$db->addGroup($group,$_SESSION['user_id']) )
  44. {
  45. print_failure(get_lang_f("failed_to_add_group",$group));
  46. $view->refresh("?m=user_admin&amp;p=show_groups", 5);
  47. return;
  48. }
  49. print_success(get_lang_f('successfully_added_group',$group));
  50. $db->logger(get_lang_f('successfully_added_group',$group));
  51. $view->refresh("?m=user_admin&amp;p=show_groups");
  52. }
  53. }
  54. ?>