group_add.php 1.8 KB

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