group_space.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) various contributors
  9. Copyright (c) Bart Mollet
  10. For a full list of contributors, see "credits.txt".
  11. The full license can be read in "license.txt".
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. See the GNU General Public License for more details.
  17. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  18. ==============================================================================
  19. */
  20. /**
  21. ==============================================================================
  22. * This script shows the group space for one specific group, possibly displaying
  23. * a list of users in the group, subscribe or unsubscribe option, tutors...
  24. *
  25. * @package dokeos.group
  26. * @todo Display error message if no group ID specified
  27. ==============================================================================
  28. */
  29. /*
  30. ==============================================================================
  31. INIT SECTION
  32. ==============================================================================
  33. */
  34. // name of the language file that needs to be included
  35. $language_file = "group";
  36. include ('../inc/global.inc.php');
  37. /*
  38. -----------------------------------------------------------
  39. Libraries & config files
  40. -----------------------------------------------------------
  41. */
  42. include_once (api_get_path(LIBRARY_PATH).'course.lib.php');
  43. include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  44. /*
  45. ==============================================================================
  46. MAIN CODE
  47. ==============================================================================
  48. */
  49. $current_group = GroupManager :: get_group_properties($_SESSION['_gid']);
  50. if(!is_array($current_group) ) {
  51. //display some error message
  52. }
  53. $nameTools = get_lang("GroupSpace");
  54. $interbreadcrumb[] = array ("url" => "group.php", "name" => get_lang("GroupManagement"));
  55. /*
  56. -----------------------------------------------------------
  57. Header
  58. -----------------------------------------------------------
  59. */
  60. Display::display_header($nameTools,"Group");
  61. /*
  62. -----------------------------------------------------------
  63. Actions and Action links
  64. -----------------------------------------------------------
  65. */
  66. /*
  67. * User wants to register in this group
  68. */
  69. if ($_GET['selfReg'] && GroupManager :: is_self_registration_allowed($_SESSION['_user']['user_id'], $current_group['id']))
  70. {
  71. GroupManager :: subscribe_users($_SESSION['_user']['user_id'], $current_group['id']);
  72. Display :: display_normal_message(get_lang('GroupNowMember'));
  73. }
  74. /*
  75. * User wants to unregister from this group
  76. */
  77. if ($_GET['selfUnReg'] && GroupManager :: is_self_unregistration_allowed($_SESSION['_user']['user_id'], $current_group['id']))
  78. {
  79. GroupManager :: unsubscribe_users($_SESSION['_user']['user_id'], $current_group['id']);
  80. Display::display_normal_message(get_lang('StudentDeletesHimself'));
  81. }
  82. /*
  83. * Edit the group
  84. */
  85. if (api_is_allowed_to_edit() or GroupManager :: is_tutor($_user['user_id']))
  86. {
  87. echo "<a href=\"group_edit.php?origin=$origin\">".get_lang("EditGroup")."</a><br/><br/>";
  88. }
  89. /*
  90. * Register to group
  91. */
  92. if (GroupManager :: is_self_registration_allowed($_SESSION['_user']['user_id'], $current_group['id']))
  93. {
  94. echo '<p align="right"><a href="'.api_get_self().'?selfReg=1&amp;group_id='.$current_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.get_lang("RegIntoGroup").'</a></p>';
  95. }
  96. /*
  97. * Unregister from group
  98. */
  99. if (GroupManager :: is_self_unregistration_allowed($_SESSION['_user']['user_id'], $current_group['id']))
  100. {
  101. echo '<p align="right"><a href="'.api_get_self().'?selfUnReg=1" onclick="javascript:if(!confirm('."'".addslashes(htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.get_lang("StudentUnsubscribe").'</a></p>';
  102. }
  103. if( isset($_GET['action']))
  104. {
  105. switch( $_GET['action'])
  106. {
  107. case 'show_msg':
  108. Display::display_normal_message($_GET['msg']);
  109. break;
  110. }
  111. }
  112. /*
  113. -----------------------------------------------------------
  114. Main Display Area
  115. -----------------------------------------------------------
  116. */
  117. $course_code = $_course['sysCode'];
  118. $is_course_member = CourseManager :: is_user_subscribed_in_real_or_linked_course($_SESSION['_user']['user_id'], $course_code);
  119. /*
  120. * Group title and comment
  121. */
  122. api_display_tool_title($nameTools.' '.stripslashes($current_group['name']));
  123. if (!empty($current_group['description']))
  124. {
  125. echo '<blockquote>'.stripslashes($current_group['description']).'</blockquote>';
  126. }
  127. /*
  128. * Group Tools
  129. */
  130. // If the user is subscribed to the group or the user is a tutor of the group then
  131. if (api_is_allowed_to_edit() OR GroupManager :: is_user_in_group($_SESSION['_user']['user_id'], $current_group['id']))
  132. {
  133. $tools = '';
  134. // Edited by Patrick Cool, 12 feb 2004: hide the forum link if there is no forum for this group (deleted through forum_admin.php)
  135. if (!is_null($current_group['forum_id']) && $current_group['forum_state'] != TOOL_NOT_AVAILABLE)
  136. {
  137. $tools .= "<a href=\"../forum/viewforum.php?".api_get_cidreq()."&amp;origin=$origin&amp;gidReq=".$current_group['id']."&amp;forum=".$current_group['forum_id']."\">".Display::return_icon('forum.gif')."&nbsp;".get_lang("Forums")."</a></div>";
  138. }
  139. if( $current_group['doc_state'] != TOOL_NOT_AVAILABLE )
  140. {
  141. // link to the documents area of this group
  142. $tools .= "<div style='margin-bottom: 5px;'><a href=\"../document/document.php?".api_get_cidreq()."&amp;gidReq=".$current_group['id']."\">".Display::return_icon('folder_document.gif')."&nbsp;".get_lang("GroupDocument")."</a></div>";
  143. }
  144. if ( $current_group['calendar_state'] != TOOL_NOT_AVAILABLE)
  145. {
  146. //link to a group-specific part of agenda
  147. $tools .= "<div style='margin-bottom: 5px;'><a href=\"../calendar/agenda.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."&amp;group=".$current_group['id']."&amp;acces=0\">".Display::return_icon('agenda.gif')."&nbsp;".get_lang("GroupCalendar")."</a></div>";
  148. }
  149. if ( $current_group['work_state'] != TOOL_NOT_AVAILABLE)
  150. {
  151. //link to the works area of this group
  152. $tools .= "<div style='margin-bottom: 5px;'><a href=\"../work/work.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('works.gif')."&nbsp;".get_lang("GroupWork")."</a></div>";
  153. }
  154. if ( $current_group['announcements_state'] != TOOL_NOT_AVAILABLE)
  155. {
  156. //link to a group-specific part of announcements
  157. $tools .= "<div style='margin-bottom: 5px;'><a href=\"../announcements/announcements.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('valves.gif')."&nbsp;".get_lang("GroupAnnouncements")."</a></div>";
  158. }
  159. echo '<b>'.get_lang("Tools").':</b>';
  160. if (!empty($tools))
  161. {
  162. echo '<blockquote>'.$tools.'</blockquote>';
  163. }
  164. }
  165. else
  166. {
  167. $tools = '';
  168. if ($current_group['forum_state'] == TOOL_PUBLIC && !is_null($current_group['forum_id']))
  169. {
  170. $tools .= "<a href=\"../forum/viewforum.php?".api_get_cidreq()."&amp;origin=$origin&amp;gidReq=".$current_group['id']."&amp;forum=".$current_group['forum_id']."\">".Display::return_icon('forum.gif')."&nbsp;".get_lang("Forums")."</a><br/>";
  171. }
  172. if( $current_group['doc_state'] == TOOL_PUBLIC )
  173. {
  174. // link to the documents area of this group
  175. $tools .= "<a href=\"../document/document.php?".api_get_cidreq()."&amp;gidReq=".$current_group['id']."&amp;origin=$origin\">".Display::return_icon('folder_document.gif')."&nbsp;".get_lang("GroupDocument")."</a><br/>";
  176. }
  177. if ( $current_group['calendar_state'] == TOOL_PUBLIC )
  178. {
  179. //link to a group-specific part of agenda
  180. $tools .= "<a href=\"../calendar/agenda.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."&amp;group=".$current_group['id']."\">".Display::return_icon('agenda.gif')."&nbsp;".get_lang("GroupCalendar")."</a><br/>";
  181. }
  182. if ( $current_group['work_state'] == TOOL_PUBLIC )
  183. {
  184. //link to the works area of this group
  185. $tools .= "<a href=\"../work/work.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."\">".Display::return_icon('works.gif')."&nbsp;".get_lang("GroupWork")."</a><br/>";
  186. }
  187. if ( $current_group['announcements_state'] == TOOL_PUBLIC)
  188. {
  189. //link to a group-specific part of announcements
  190. $tools .= "<a href=\"../announcements/announcements.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."&amp;group=".$current_group['id']."\">".Display::return_icon('valves.gif')."&nbsp;".get_lang("GroupAnnouncements")."</a><br/>";
  191. }
  192. echo '<b>'.get_lang("Tools").':</b>';
  193. if (!empty($tools))
  194. {
  195. echo '<blockquote>'.$tools.'</blockquote>';
  196. }
  197. }
  198. /*
  199. * list all the tutors of the current group
  200. */
  201. $tutors = GroupManager::get_subscribed_tutors($current_group['id']);
  202. if (count($tutors) == 0)
  203. {
  204. $tutor_info = get_lang("GroupNoneMasc");
  205. }
  206. else
  207. {
  208. foreach($tutors as $index => $tutor)
  209. {
  210. $tutor_info .= "<div style='margin-bottom: 5px;'><a href='../user/userInfo.php?origin=".$origin."&amp;uInfo=".$tutor['user_id']."'><img src='../img/coachs.gif' align='absbottom'>&nbsp;".$tutor['firstname']." ".$tutor['lastname']."</a></div>";
  211. }
  212. }
  213. echo '<b>'.get_lang("GroupTutors").':</b>';
  214. if (!empty($tutor_info))
  215. {
  216. echo '<blockquote>'.$tutor_info.'</blockquote>';
  217. }
  218. /*
  219. * list all the members of the current group
  220. */
  221. $tutors = GroupManager::get_subscribed_users($current_group['id']);
  222. if (count($tutors) == 0)
  223. {
  224. $member_info = get_lang("GroupNoneMasc");
  225. }
  226. else
  227. {
  228. foreach($tutors as $index => $member)
  229. {
  230. $member_info .= "<div style='margin-bottom: 5px;'><a href='../user/userInfo.php?origin=".$origin."&amp;uInfo=".$member['user_id']."'><img src='../img/members.gif' align='absbottom'>&nbsp;".$member['firstname']." ".$member['lastname']."</a></div>";
  231. }
  232. }
  233. echo '<b>'.get_lang("GroupMembers").':</b><blockquote>'.$member_info.'</blockquote>';
  234. /*
  235. ==============================================================================
  236. FOOTER
  237. ==============================================================================
  238. */
  239. if ($origin != 'learnpath')
  240. {
  241. Display::display_footer();
  242. }
  243. ?>