group_add.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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('allow_social_tool') !='true') {
  12. api_not_allowed();
  13. }
  14. if (api_get_setting('allow_students_to_create_groups_in_social') == 'false' && !api_is_allowed_to_edit()) {
  15. api_not_allowed();
  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', array());
  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('GroupAdded')));
  28. header('Location: group_view.php?id='.$groupId);
  29. exit();
  30. }
  31. $nameTools = get_lang('AddGroup');
  32. $this_section = SECTION_SOCIAL;
  33. $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
  34. $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
  35. $interbreadcrumb[]= array ('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, $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. $tpl->display($social_layout);