group_add.php 1.9 KB

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