dokeos-group
[ class tree: dokeos-group ] [ index: dokeos-group ] [ all elements ]

Source for file group_space.php

Documentation is available at group_space.php

  1. <?php //$Id: group_space.php 14826 2008-04-10 08:10:19Z pcool $
  2. /*
  3. ==============================================================================
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2004-2008 Dokeos SPRL
  7.     Copyright (c) 2003 Ghent University (UGent)
  8.     Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9.     Copyright (c) various contributors
  10.     Copyright (c) Bart Mollet
  11.  
  12.     For a full list of contributors, see "credits.txt".
  13.     The full license can be read in "license.txt".
  14.  
  15.     This program is free software; you can redistribute it and/or
  16.     modify it under the terms of the GNU General Public License
  17.     as published by the Free Software Foundation; either version 2
  18.     of the License, or (at your option) any later version.
  19.  
  20.     See the GNU General Public License for more details.
  21.  
  22.     Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
  23. ==============================================================================
  24. */
  25. /**
  26. ==============================================================================
  27. * This script shows the group space for one specific group, possibly displaying
  28. * a list of users in the group, subscribe or unsubscribe option, tutors...
  29. *
  30. @package dokeos.group
  31. @todo    Display error message if no group ID specified
  32. ==============================================================================
  33. */
  34. /*
  35. ==============================================================================
  36.         INIT SECTION
  37. ==============================================================================
  38. */
  39. // name of the language file that needs to be included
  40. $language_file "group";
  41. include ('../inc/global.inc.php');
  42. /*
  43. -----------------------------------------------------------
  44.     Libraries & config files
  45. -----------------------------------------------------------
  46. */
  47. include_once (api_get_path(LIBRARY_PATH).'course.lib.php');
  48. include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  49. include_once (api_get_path(LIBRARY_PATH).'sortabletable.class.php');
  50. require_once (api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php');
  51. require_once (api_get_path(SYS_CODE_PATH).'forum/forumconfig.inc.php');
  52. /*
  53. ==============================================================================
  54.         MAIN CODE
  55. ==============================================================================
  56. */
  57. $current_group GroupManager :: get_group_properties($_SESSION['_gid']);
  58. if(!is_array($current_group) ) {
  59. //display some error message
  60. }
  61.  
  62. $nameTools get_lang("GroupSpace");
  63. $interbreadcrumb[array ("url" => "group.php""name" => get_lang("GroupManagement"));
  64.  
  65. /*
  66. -----------------------------------------------------------
  67.     Header
  68. -----------------------------------------------------------
  69. */
  70. Display::display_header($nameTools,"Group");
  71.  
  72.  
  73. /*
  74. -----------------------------------------------------------
  75.     Actions and Action links
  76. -----------------------------------------------------------
  77. */
  78. /*
  79.  * User wants to register in this group
  80.  */
  81. if ($_GET['selfReg'&& GroupManager :: is_self_registration_allowed($_SESSION['_user']['user_id']$current_group['id']))
  82. {
  83.     GroupManager :: subscribe_users($_SESSION['_user']['user_id']$current_group['id']);
  84.     Display :: display_normal_message(get_lang('GroupNowMember'));
  85. }
  86.  
  87. /*
  88.  * User wants to unregister from this group
  89.  */
  90. if ($_GET['selfUnReg'&& GroupManager :: is_self_unregistration_allowed($_SESSION['_user']['user_id']$current_group['id']))
  91. {
  92.     GroupManager :: unsubscribe_users($_SESSION['_user']['user_id']$current_group['id']);
  93.     Display::display_normal_message(get_lang('StudentDeletesHimself'));
  94. }
  95. /*
  96.  * Edit the group
  97.  */
  98. if (api_is_allowed_to_edit(or GroupManager :: is_tutor($_user['user_id']))
  99. {
  100.     echo "<a href=\"group_edit.php?origin=$origin\">".get_lang("EditGroup")."</a><br/><br/>";
  101. }
  102.  
  103. /*
  104.  * Register to group
  105.  */
  106. if (GroupManager :: is_self_registration_allowed($_SESSION['_user']['user_id']$current_group['id']))
  107. {
  108.     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>';
  109. }
  110.  
  111. /*
  112.  * Unregister from group
  113.  */
  114. if (GroupManager :: is_self_unregistration_allowed($_SESSION['_user']['user_id']$current_group['id']))
  115. {
  116.     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>';
  117. }
  118.  
  119. ifisset($_GET['action']))
  120. {
  121.     switch$_GET['action'])
  122.     {
  123.         case 'show_msg':
  124.             Display::display_normal_message($_GET['msg']);
  125.             break;
  126.     }
  127. }
  128.  
  129.  
  130.  
  131.  
  132.  
  133. /*
  134. -----------------------------------------------------------
  135.     Main Display Area
  136. -----------------------------------------------------------
  137. */
  138. $course_code $_course['sysCode'];
  139. $is_course_member CourseManager :: is_user_subscribed_in_real_or_linked_course($_SESSION['_user']['user_id']$course_code);
  140.  
  141. /*
  142.  * Group title and comment
  143.  */
  144. api_display_tool_title($nameTools.' '.stripslashes($current_group['name']));
  145. if (!empty($current_group['description']))
  146. {
  147.     echo '<blockquote>'.stripslashes($current_group['description']).'</blockquote>';
  148. }
  149.  
  150.  
  151.  
  152. /*
  153.  * Group Tools
  154.  */
  155. // If the user is subscribed to the group or the user is a tutor of the group then
  156. if (api_is_allowed_to_edit(OR GroupManager :: is_user_in_group($_SESSION['_user']['user_id']$current_group['id']))
  157. {
  158.     $tools '';
  159.     $forums_of_groups get_forums_of_group($current_group['id']);
  160.     if (is_array($forums_of_groups))
  161.     {
  162.         foreach ($forums_of_groups as $key => $value)
  163.         {
  164.             if($value['forum_group_public_private'== 'public' || ($user_subscribe_to_current_group && $value['forum_group_public_private'== 'private'|| $user_is_tutor || api_is_allowed_to_edit())
  165.             {
  166.                 $tools.= Display::return_icon('forum.gif'' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'">'.$value['forum_title'].'</a><br />';
  167.             }
  168.         }
  169.     }
  170.     if$current_group['doc_state'!= TOOL_NOT_AVAILABLE )
  171.     {
  172.         // link to the documents area of this group
  173.         $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>";
  174.     }
  175.     if $current_group['calendar_state'!= TOOL_NOT_AVAILABLE)
  176.     {
  177.         //link to a group-specific part of agenda
  178.         $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>";
  179.     }
  180.     if $current_group['work_state'!= TOOL_NOT_AVAILABLE)
  181.     {
  182.         //link to the works area of this group
  183.         $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>";
  184.     }
  185.     if $current_group['announcements_state'!= TOOL_NOT_AVAILABLE)
  186.     {
  187.         //link to a group-specific part of announcements
  188.         $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>";
  189.     }
  190.  
  191.     echo '<b>'.get_lang("Tools").':</b>';
  192.     if (!empty($tools))
  193.     {
  194.         echo '<blockquote>'.$tools.'</blockquote>';
  195.     }
  196.  
  197. }
  198. else
  199. {
  200.     $tools '';
  201.     $forums_of_groups get_forums_of_group($current_group['id']);
  202.     if (is_array($forums_of_groups))
  203.     {
  204.         foreach ($forums_of_groups as $key => $value)
  205.         {
  206.             if($value['forum_group_public_private'== 'public' )
  207.             {
  208.                 $tools.= Display::return_icon('forum.gif'' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'">'.$value['forum_title'].'</a><br />';
  209.             }
  210.         }
  211.     }    
  212.     if$current_group['doc_state'== TOOL_PUBLIC )
  213.     {
  214.         // link to the documents area of this group
  215.         $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/>";
  216.     }
  217.     if $current_group['calendar_state'== TOOL_PUBLIC )
  218.     {
  219.         //link to a group-specific part of agenda
  220.         $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/>";
  221.     }
  222.     if $current_group['work_state'== TOOL_PUBLIC )
  223.     {
  224.         //link to the works area of this group
  225.         $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/>";
  226.     }
  227.     if $current_group['announcements_state'== TOOL_PUBLIC)
  228.     {
  229.         //link to a group-specific part of announcements
  230.         $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/>";
  231.     }
  232.     echo '<b>'.get_lang("Tools").':</b>';
  233.     if (!empty($tools))
  234.     {
  235.         echo '<blockquote>'.$tools.'</blockquote>';
  236.     }
  237. }
  238.  
  239. /*
  240.  * list all the tutors of the current group
  241.  */
  242. $tutors GroupManager::get_subscribed_tutors($current_group['id']);
  243. if (count($tutors== 0)
  244. {
  245.     $tutor_info get_lang("GroupNoneMasc");
  246. }
  247. else
  248. {
  249.     foreach($tutors as $index => $tutor)
  250.     {
  251.         $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>";
  252.     }
  253. }
  254. echo '<b>'.get_lang("GroupTutors").':</b>';
  255. if (!empty($tutor_info))
  256. {
  257.     echo '<blockquote>'.$tutor_info.'</blockquote>';
  258. }
  259.  
  260.  
  261.  
  262.  
  263. /*
  264.  * list all the members of the current group
  265.  */
  266. echo '<b>'.get_lang("GroupMembers").':</b>';
  267.  
  268. $table new SortableTable('group_users''get_number_of_group_users''get_group_user_data',2);
  269. $parameters array('cidReq' => $_GET['cidReq']'origin'=> $_GET['origin']'gidReq' => $_GET['gidReq']);
  270. $table->set_additional_parameters($parameters);
  271. $table->set_header(0'');
  272. $table->set_header(1get_lang('LastName'));
  273. $table->set_header(2get_lang('FirstName'));
  274. $table->set_header(3get_lang('Email'));
  275. $table->set_column_filter(3'email_filter');
  276. $table->set_column_filter(0'user_icon_filter');
  277. $table->display();
  278.  
  279. /**
  280.  * Get the number of subscribed users to the group
  281.  *
  282.  * @return integer 
  283.  * 
  284.  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  285.  * @version April 2008
  286.  */
  287. {
  288.     global $current_group;
  289.     
  290.     // Database table definition
  291.     $table_group_user Database :: get_course_table(TABLE_GROUP_USER);
  292.     
  293.     // query
  294.     $sql "SELECT count(id) AS number_of_users
  295.                 FROM ".$table_group_user."
  296.                 WHERE group_id='".Database::escape_string($current_group['id'])."'";
  297.     $result api_sql_query($sql,__FILE__,__LINE__);
  298.     $return Database::fetch_array($result,'ASSOC');
  299.     return $return['number_of_users']
  300. }
  301.  
  302. /**
  303.  * Get the details of the users in a group
  304.  *
  305.  * @param integer $from starting row
  306.  * @param integer $number_of_items number of items to be displayed
  307.  * @param integer $column sorting colum
  308.  * @param integer $direction sorting direction
  309.  * @return array 
  310.  * 
  311.  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  312.  * @version April 2008
  313.  */
  314. function get_group_user_data($from$number_of_items$column$direction)
  315. {
  316.     global $current_group;
  317.     
  318.     // Database table definition
  319.     $table_group_user     Database :: get_course_table(TABLE_GROUP_USER);
  320.     $table_user         Database :: get_main_table(TABLE_MAIN_USER);
  321.     
  322.     // query
  323.     $sql "SELECT 
  324.                 user.user_id     AS col0,
  325.                 user.lastname     AS col1,
  326.                 user.firstname     AS col2,
  327.                 user.email        AS col3
  328.                 FROM ".$table_user." user, ".$table_group_user." group_rel_user 
  329.                 WHERE group_rel_user.user_id = user.user_id 
  330.                 AND group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'";
  331.     $sql .= " ORDER BY col$column $direction ";
  332.     $sql .= " LIMIT $from,$number_of_items";
  333.     $return array ();
  334.     $result api_sql_query($sql,__FILE__,__LINE__);
  335.     while ($row Database::fetch_row($result))
  336.     {
  337.         $return[$row;
  338.     }
  339.     return $return
  340. }
  341.  
  342. /**
  343. * Returns a mailto-link
  344. @param string $email An email-address
  345. @return string HTML-code with a mailto-link
  346. */
  347. function email_filter($email)
  348. {
  349.     return Display :: encrypted_mailto_link($email$email);
  350. }
  351.  
  352. /**
  353.  * Display a user icon that links to the user page
  354.  *
  355.  * @param integer $user_id the id of the user
  356.  * @return html code
  357.  * 
  358.  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  359.  * @version April 2008
  360.  */
  361. function user_icon_filter($user_id)
  362. {
  363.     global $origin;
  364.     return "<a href='../user/userInfo.php?origin=".$origin."&amp;uInfo=".$user_id."'><img src='../img/members.gif' >";
  365. }
  366.  
  367. // footer
  368. if ($origin != 'learnpath')
  369. {
  370. }
  371. ?>

Documentation generated on Thu, 12 Jun 2008 13:38:29 -0500 by phpDocumentor 1.4.1