group_add.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.social
  5. * @author Julio Montoya <gugli100@gmail.com>
  6. */
  7. /**
  8. * Initialization
  9. */
  10. $language_file= 'userInfo';
  11. $cidReset = true;
  12. require_once '../inc/global.inc.php';
  13. api_block_anonymous_users();
  14. if (api_get_setting('allow_social_tool') !='true') {
  15. api_not_allowed();
  16. }
  17. if (api_get_setting('allow_students_to_create_groups_in_social') == 'false' && !api_is_allowed_to_edit()) {
  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. $groupId = $usergroup->save($values);
  28. header('Location: groups.php?id='.$groupId.'&action=show_message&message='.urlencode(get_lang('GroupAdded')));
  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_left_content = SocialManager::show_social_menu('group_add');
  37. $social_right_content = '<div class="span9">';
  38. $social_right_content .= $form->return_form();
  39. $social_right_content .= '</div>';
  40. $tpl = $app['template'];
  41. $tpl->setHelp('Groups');
  42. $tpl->assign('social_left_content', $social_left_content);
  43. $tpl->assign('social_right_content', $social_right_content);
  44. $social_layout = $tpl->get_template('layout/social_layout.tpl');
  45. $tpl->display($social_layout);