diff --git a/documentation/changelog.html b/documentation/changelog.html index d89950d03f..8096f4df0c 100644 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -30,6 +30,7 @@
  • Added sessions history (optional access to previous sessions in read-only for students)
  • Added advanced search in sessions: you can also search by session name, session category, tutor and visibility. (DT#5541)
  • Added an option to configure courses as "auto-registered" (every user has it in his courses list and is automatically subscribed)
  • +
  • Added chat tool to the groups(DT#3318)
  • Allowed password to be recovered using username *or* e-mail
  • Added editable section to the registration form
  • Reporting: notification of user who have never been active yet
  • diff --git a/main/chat/chat_banner.php b/main/chat/chat_banner.php index 8fa8c32be1..d3ddf87760 100755 --- a/main/chat/chat_banner.php +++ b/main/chat/chat_banner.php @@ -31,15 +31,54 @@ */ $language_file = array ('chat'); - include('../inc/global.inc.php'); +require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; + +//$interbreadcrumb[] = array ("url" => "chat.php", "name" => get_lang("Chat")); +//$noPHP_SELF=true; +//$shortBanner=false; +//Display::display_header(null,"Chat"); + +$tool_name = get_lang('Chat'); + +// If it is a group chat then the breadcrumbs. +if ($_SESSION['_gid'] OR $_GET['group_id']) { + + if (isset($_SESSION['_gid'])) { + $_clean['group_id']=(int)$_SESSION['_gid']; + } + if (isset($_GET['group_id'])) { + $_clean['group_id']=(int)Database::escape_string($_GET['group_id']); + } + $group_properties = GroupManager :: get_group_properties($_clean['group_id']); + $interbreadcrumb[] = array ("url" => "../group/group.php", "name" => get_lang('Groups')); + $interbreadcrumb[] = array ("url"=>"../group/group_space.php?gidReq=".$_SESSION['_gid'], "name"=> get_lang('GroupSpace').' ('.$group_properties['name'].')'); + $noPHP_SELF=true; + $shortBanner=false; + $add_group_to_title = ' ('.$group_properties['name'].')'; + $groupfilter='group_id="'.$_clean['group_id'].'"'; -$interbreadcrumb[] = array ("url" => "chat.php", "name" => get_lang("Chat")); -$noPHP_SELF=true; -$shortBanner=false; + //ensure this tool in groups whe it's private or deactivated + /*if ($group_properties['chat_state']==0) + { + echo api_not_allowed(); + } + elseif ($group_properties['chat_state']==2) + { + if (!api_is_allowed_to_edit(false,true) and !GroupManager :: is_user_in_group($_user['user_id'], $_SESSION['_gid'])) + { + echo api_not_allowed(); + } + }*/ -Display::display_header(null,"Chat"); +} +else +{ + $groupfilter='group_id=0'; +} +Display::display_header($tool_name, 'Chat'); +//$is_allowed_to_edit = api_is_allowed_to_edit(false,true); ?> diff --git a/main/group/group_space.php b/main/group/group_space.php index b2c5851840..f8dab56f7e 100644 --- a/main/group/group_space.php +++ b/main/group/group_space.php @@ -79,7 +79,7 @@ if (is_array($forums_of_groups)) { } } -if ($current_group['doc_state']!=1 and $current_group['calendar_state']!=1 and $current_group['work_state']!=1 and $current_group['announcements_state']!=1 and $current_group['wiki_state']!=1 and $forum_state_public!=1) { +if ($current_group['doc_state']!=1 and $current_group['calendar_state']!=1 and $current_group['work_state']!=1 and $current_group['announcements_state']!=1 and $current_group['wiki_state']!=1 and $current_group['chat_state']!=1 and $forum_state_public!=1) { if (!api_is_allowed_to_edit(null,true) and !GroupManager :: is_user_in_group($_user['user_id'], $current_group['id'])) { echo api_not_allowed($print_headers); } @@ -214,6 +214,13 @@ if (api_is_allowed_to_edit(false,true) OR GroupManager :: is_user_in_group($_SES //link to the wiki area of this group $tools .= "
    ".Display::return_icon('wiki.gif', get_lang("GroupWiki"))." ".get_lang("GroupWiki")."
    "; } + + if ( $current_group['chat_state'] != TOOL_NOT_AVAILABLE) + { + //link to the chat area of this group + $tools .= "
    ".Display::return_icon('chat.gif', get_lang("Chat"))." ".get_lang("Chat")."
    "; + } + echo '
    '.get_lang("Tools").':
    '; if (!empty($tools)) { @@ -262,6 +269,12 @@ if (api_is_allowed_to_edit(false,true) OR GroupManager :: is_user_in_group($_SES //link to the wiki area of this group $tools .= "".Display::return_icon('wiki.gif', get_lang('GroupWiki'))." ".get_lang('GroupWiki')."
    "; } + + if ( $current_group['chat_state'] == TOOL_PUBLIC ) + { + //link to the chat area of this group + $tools .= "".Display::return_icon('chat.gif', get_lang('Chat'))." ".get_lang('Chat')."
    "; + } echo '
    '; diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index 9b00f819d8..5816d933c1 100644 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -68,6 +68,7 @@ define("GROUP_TOOL_CALENDAR","2"); define("GROUP_TOOL_ANNOUNCEMENT","3"); define("GROUP_TOOL_WORK","4"); define("GROUP_TOOL_WIKI", "5"); +define("GROUP_TOOL_CHAT", "6"); /** * Fixed id's for group categories @@ -226,7 +227,7 @@ class GroupManager { } $sql = "INSERT INTO ".$table_group." SET category_id='".Database::escape_string($category_id)."', max_student = '".$places."', doc_state = '".$category['doc_state']."', - calendar_state = '".$category['calendar_state']."', work_state = '".$category['work_state']."', announcements_state = '".$category['announcements_state']."', forum_state = '".$category['forum_state']."', wiki_state = '".$category['wiki_state']."', self_registration_allowed = '".$category['self_reg_allowed']."', self_unregistration_allowed = '".$category['self_unreg_allowed']."', session_id='".Database::escape_string($my_id_session)."'"; + calendar_state = '".$category['calendar_state']."', work_state = '".$category['work_state']."', announcements_state = '".$category['announcements_state']."', forum_state = '".$category['forum_state']."', wiki_state = '".$category['wiki_state']."', chat_state = '".$category['chat_state']."', self_registration_allowed = '".$category['self_reg_allowed']."', self_unregistration_allowed = '".$category['self_unreg_allowed']."', session_id='".Database::escape_string($my_id_session)."'"; Database::query($sql,__FILE__,__LINE__); $lastId = Database::insert_id(); /*$secret_directory = uniqid("")."_team_".$lastId; @@ -470,6 +471,7 @@ class GroupManager { $result['announcements_state'] = $db_object->announcements_state; $result['forum_state'] = $db_object->forum_state; $result['wiki_state'] = $db_object->wiki_state; + $result['chat_state'] = $db_object->chat_state; $result['directory'] = $db_object->secret_directory; $result['self_registration_allowed'] = $db_object->self_registration_allowed; $result['self_unregistration_allowed'] = $db_object->self_unregistration_allowed; @@ -489,11 +491,12 @@ class GroupManager { * @param int Announcement tool's visibility (0=none,1=private,2=public) * @param int Forum tool's visibility (0=none,1=private,2=public) * @param int Wiki tool's visibility (0=none,1=private,2=public) + * @param int Chat tool's visibility (0=none,1=private,2=public) * @param bool Whether self registration is allowed or not * @param bool Whether self unregistration is allowed or not * @return bool TRUE if properties are successfully changed, false otherwise */ - public static function set_group_properties ($group_id, $name, $description, $maximum_number_of_students, $doc_state, $work_state, $calendar_state, $announcements_state, $forum_state,$wiki_state, $self_registration_allowed, $self_unregistration_allowed) { + public static function set_group_properties ($group_id, $name, $description, $maximum_number_of_students, $doc_state, $work_state, $calendar_state, $announcements_state, $forum_state, $wiki_state, $chat_state, $self_registration_allowed, $self_unregistration_allowed) { $table_group = Database :: get_course_table(TABLE_GROUP); $table_forum = Database :: get_course_table(TABLE_FORUM); //$forum_id = get_forums_of_group($group_id); @@ -506,6 +509,7 @@ class GroupManager { announcements_state = '".Database::escape_string($announcements_state)."', forum_state = '".Database::escape_string($forum_state)."', wiki_state = '".Database::escape_string($wiki_state)."', + chat_state = '".Database::escape_string($chat_state)."', description='".Database::escape_string(trim($description))."', max_student=".Database::escape_string($maximum_number_of_students).", self_registration_allowed='".Database::escape_string($self_registration_allowed)."', @@ -642,7 +646,7 @@ class GroupManager { * @param int $max_number_of_students * @param int $groups_per_user */ - public static function create_category ($title, $description, $doc_state, $work_state, $calendar_state, $announcements_state, $forum_state, $wiki_state, $self_registration_allowed, $self_unregistration_allowed, $maximum_number_of_students, $groups_per_user) { + public static function create_category ($title, $description, $doc_state, $work_state, $calendar_state, $announcements_state, $forum_state, $wiki_state, $chat_state, $self_registration_allowed, $self_unregistration_allowed, $maximum_number_of_students, $groups_per_user) { $table_group_category = Database :: get_course_table(TABLE_GROUP_CATEGORY); $sql = "SELECT MAX(display_order)+1 as new_order FROM $table_group_category "; $res = Database::query($sql,__FILE__,__LINE__); @@ -661,6 +665,7 @@ class GroupManager { announcements_state = '".Database::escape_string($announcements_state)."', forum_state = '".Database::escape_string($forum_state)."', wiki_state = '".Database::escape_string($wiki_state)."', + chat_state = '".Database::escape_string($chat_state)."', groups_per_user = '".Database::escape_string($groups_per_user)."', self_reg_allowed = '".Database::escape_string($self_registration_allowed)."', self_unreg_allowed = '".Database::escape_string($self_unregistration_allowed)."', @@ -686,7 +691,7 @@ class GroupManager { * @param int $max_number_of_students * @param int $groups_per_user */ - public static function update_category ($id, $title, $description, $doc_state, $work_state, $calendar_state, $announcements_state, $forum_state, $wiki_state, $self_registration_allowed, $self_unregistration_allowed, $maximum_number_of_students, $groups_per_user) { + public static function update_category ($id, $title, $description, $doc_state, $work_state, $calendar_state, $announcements_state, $forum_state, $wiki_state, $chat_state, $self_registration_allowed, $self_unregistration_allowed, $maximum_number_of_students, $groups_per_user) { $table_group_category = Database :: get_course_table(TABLE_GROUP_CATEGORY); $id = Database::escape_string($id); $sql = "UPDATE ".$table_group_category." @@ -698,6 +703,7 @@ class GroupManager { announcements_state = '".Database::escape_string($announcements_state)."', forum_state = '".Database::escape_string($forum_state)."', wiki_state = '".Database::escape_string($wiki_state)."', + chat_state = '".Database::escape_string($chat_state)."', groups_per_user = ".Database::escape_string($groups_per_user).", self_reg_allowed = '".Database::escape_string($self_registration_allowed)."', self_unreg_allowed = '".Database::escape_string($self_unregistration_allowed)."', @@ -1485,6 +1491,9 @@ class GroupManager { case GROUP_TOOL_WIKI : $state_key = 'wiki_state'; break; + case GROUP_TOOL_CHAT : + $state_key = 'chat_state'; + break; default: return false; }