group_add.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.social
  5. *
  6. * @author Julio Montoya <gugli100@gmail.com>
  7. */
  8. $cidReset = true;
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. api_block_anonymous_users();
  11. if (api_get_setting('allow_social_tool') !== 'true') {
  12. api_not_allowed(true);
  13. }
  14. if (api_get_setting('allow_students_to_create_groups_in_social') === 'false' && !api_is_allowed_to_edit()) {
  15. api_not_allowed(true);
  16. }
  17. $table_message = Database::get_main_table(TABLE_MESSAGE);
  18. $usergroup = new UserGroup();
  19. $form = new FormValidator('add_group');
  20. $usergroup->setGroupType($usergroup::SOCIAL_CLASS);
  21. $usergroup->setForm($form, 'add', []);
  22. if ($form->validate()) {
  23. $values = $form->exportValues();
  24. $values['group_type'] = UserGroup::SOCIAL_CLASS;
  25. $values['relation_type'] = GROUP_USER_PERMISSION_ADMIN;
  26. $groupId = $usergroup->save($values);
  27. Display::addFlash(Display::return_message(get_lang('Group added')));
  28. header('Location: group_view.php?id='.$groupId);
  29. exit();
  30. }
  31. $nameTools = get_lang('Add group');
  32. $this_section = SECTION_SOCIAL;
  33. $interbreadcrumb[] = ['url' => 'home.php', 'name' => get_lang('Social')];
  34. $interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
  35. $interbreadcrumb[] = ['url' => '#', 'name' => $nameTools];
  36. $social_avatar_block = SocialManager::show_social_avatar_block('group_add');
  37. $social_menu_block = SocialManager::show_social_menu('group_add');
  38. $social_right_content = $form->returnForm();
  39. $tpl = new Template(null);
  40. SocialManager::setSocialUserBlock($tpl, api_get_user_id(), null, null);
  41. $tpl->setHelp('Groups');
  42. $tpl->assign('social_menu_block', $social_menu_block);
  43. $tpl->assign('social_right_content', $social_right_content);
  44. $social_layout = $tpl->get_template('social/add_groups.tpl');
  45. $content = $tpl->fetch($social_layout);
  46. $tpl->assign('content', $content);
  47. $tpl->display_one_col_template();