'group.php', 'name' => get_lang('Groups')); /* Ensure all private groups // Juan Carlos RaƱa Trabado */ $forums_of_groups = get_forums_of_group($current_group['id']); $forum_state_public = 0; if (is_array($forums_of_groups)) { foreach ($forums_of_groups as $key => $value) { if($value['forum_group_public_private'] == 'public') { $forum_state_public = 1; } } } if ($current_group['doc_state'] != 1 && $current_group['calendar_state'] != 1 && $current_group['work_state'] != 1 && $current_group['announcements_state'] != 1 && $current_group['wiki_state'] != 1 && $current_group['chat_state'] != 1 && $forum_state_public != 1) { if (!api_is_allowed_to_edit(null,true) && !GroupManager :: is_user_in_group($_user['user_id'], $current_group['id'])) { echo api_not_allowed($print_headers); } } /* Header */ Display::display_header($nameTools.' '.stripslashes($current_group['name']), 'Group'); /* Introduction section (editable by course admin) */ Display::display_introduction_section(TOOL_GROUP); /* Actions and Action links */ /* * User wants to register in this group */ if (!empty($_GET['selfReg']) && GroupManager :: is_self_registration_allowed($_SESSION['_user']['user_id'], $current_group['id'])) { GroupManager :: subscribe_users($_SESSION['_user']['user_id'], $current_group['id']); Display :: display_normal_message(get_lang('GroupNowMember')); } /* * User wants to unregister from this group */ if (!empty($_GET['selfUnReg']) && GroupManager :: is_self_unregistration_allowed($_SESSION['_user']['user_id'], $current_group['id'])) { GroupManager :: unsubscribe_users($_SESSION['_user']['user_id'], $current_group['id']); Display::display_normal_message(get_lang('StudentDeletesHimself')); } echo '
'; echo ''.Display::return_icon('back.png',get_lang('BackToGroupList'),'','32').''; /* * Register to group */ $subscribe_group = ''; if (GroupManager :: is_self_registration_allowed($_SESSION['_user']['user_id'], $current_group['id'])) { $subscribe_group = ''.get_lang("RegIntoGroup").''; } /* * Unregister from group */ $unsubscribe_group = ''; if (GroupManager :: is_self_unregistration_allowed($_SESSION['_user']['user_id'], $current_group['id'])) { $unsubscribe_group = ''.get_lang("StudentUnsubscribe").''; } echo ' 
'; if (isset($_GET['action'])) { switch ($_GET['action']) { case 'show_msg': Display::display_normal_message(Security::remove_XSS($_GET['msg'])); break; } } /* Main Display Area */ $course_code = $_course['sysCode']; $is_course_member = CourseManager :: is_user_subscribed_in_real_or_linked_course(api_get_user_id(), $course_code); /* * Group title and comment */ /* * Edit the group */ $edit_url = ''; if (api_is_allowed_to_edit(false, true) or GroupManager :: is_tutor_of_group(api_get_user_id(), api_get_group_id())) { $my_origin = isset($origin) ? $origin : ''; $edit_url = ''.Display::return_icon('edit.png', get_lang('EditGroup'),'','22').''; } echo Display::tag('h2', Security::remove_XSS($current_group['name']).' '.$edit_url.' '.$subscribe_group.' '.$unsubscribe_group); if (!empty($current_group['description'])) { echo '

'.Security::remove_XSS($current_group['description']).'

'; } /* * Group Tools */ // If the user is subscribed to the group or the user is a tutor of the group then if (api_is_allowed_to_edit(false, true) OR GroupManager :: is_user_in_group(api_get_user_id(), $current_group['id'])) { echo ''; echo '
'.get_lang('Tools').'
'; if (!empty($tools)) { echo '
'.$tools.'
'; } } else { echo ''; echo '
'.get_lang('Tools').'
'; if (!empty($tools)) { echo '
'.$tools.'
'; } } /* * List all the tutors of the current group */ $tutors = GroupManager::get_subscribed_tutors($current_group['id']); $tutor_info = ''; if (count($tutors) == 0) { $tutor_info = get_lang('GroupNoneMasc'); } else { isset($origin)?$my_origin = $origin:$my_origin=''; foreach($tutors as $index => $tutor) { $image_path = UserManager::get_user_picture_path_by_id($tutor['user_id'], 'web', false, true); $image_repository = $image_path['dir']; $existing_image = $image_path['file']; $photo= ''.api_get_person_name($tutor['firstname'], $tutor['lastname']).''; $tutor_info .= '
'.$photo.' '.api_get_person_name($tutor['firstname'], $tutor['lastname']).'
'; } } echo '
'.get_lang('GroupTutors').'
'; if (!empty($tutor_info)) { echo '
'.$tutor_info.'
'; } echo '
'; /* * List all the members of the current group */ echo ''.get_lang("GroupMembers").''; $table = new SortableTable('group_users', 'get_number_of_group_users', 'get_group_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1); $my_cidreq = isset($_GET['cidReq']) ? Security::remove_XSS($_GET['cidReq']) : ''; $my_origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : ''; $my_gidreq = isset($_GET['gidReq']) ? Security::remove_XSS($_GET['gidReq']) : ''; $parameters = array('cidReq' => $my_cidreq, 'origin'=> $my_origin, 'gidReq' => $my_gidreq); $table->set_additional_parameters($parameters); $table->set_header(0, ''); if (api_is_western_name_order()) { $table->set_header(1, get_lang('FirstName')); $table->set_header(2, get_lang('LastName')); } else { $table->set_header(1, get_lang('LastName')); $table->set_header(2, get_lang('FirstName')); } if (api_get_setting('show_email_addresses') == 'true') { $table->set_header(3, get_lang('Email')); $table->set_column_filter(3, 'email_filter'); } else { if (api_is_allowed_to_edit() == 'true') { $table->set_header(3, get_lang('Email')); $table->set_column_filter(3, 'email_filter'); } } //the order of these calls is important $table->set_column_filter(1, 'user_name_filter'); $table->set_column_filter(2, 'user_name_filter'); $table->set_column_filter(0, 'user_icon_filter'); $table->display(); /** * Get the number of subscribed users to the group * * @return integer * * @author Patrick Cool , Ghent University, Belgium * @version April 2008 */ function get_number_of_group_users() { global $current_group; // Database table definition $table_group_user = Database :: get_course_table(TABLE_GROUP_USER); // Query $sql = "SELECT count(id) AS number_of_users FROM ".$table_group_user." WHERE group_id='".Database::escape_string($current_group['id'])."'"; $result = Database::query($sql); $return = Database::fetch_array($result,'ASSOC'); return $return['number_of_users']; } /** * Get the details of the users in a group * * @param integer $from starting row * @param integer $number_of_items number of items to be displayed * @param integer $column sorting colum * @param integer $direction sorting direction * @return array * * @author Patrick Cool , Ghent University, Belgium * @version April 2008 */ function get_group_user_data($from, $number_of_items, $column, $direction) { global $current_group; // Database table definition $table_group_user = Database :: get_course_table(TABLE_GROUP_USER); $table_user = Database :: get_main_table(TABLE_MAIN_USER); $course_id = api_get_course_int_id(); // Query if (api_get_setting('show_email_addresses') == 'true') { $sql = "SELECT user.user_id AS col0, ".(api_is_western_name_order() ? "user.firstname AS col1, user.lastname AS col2," : "user.lastname AS col1, user.firstname AS col2," )." user.email AS col3 FROM ".$table_user." user, ".$table_group_user." group_rel_user WHERE group_rel_user.c_id = $course_id group_rel_user.user_id = user.user_id AND group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'"; $sql .= " ORDER BY col$column $direction "; $sql .= " LIMIT $from,$number_of_items"; } else { if (api_is_allowed_to_edit()) { $sql = "SELECT user.user_id AS col0, ".(api_is_western_name_order() ? "user.firstname AS col1, user.lastname AS col2," : "user.lastname AS col1, user.firstname AS col2," )." user.email AS col3 FROM ".$table_user." user, ".$table_group_user." group_rel_user WHERE group_rel_user.user_id = user.user_id AND group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'"; $sql .= " ORDER BY col$column $direction "; $sql .= " LIMIT $from,$number_of_items"; } else { $sql = "SELECT user.user_id AS col0, ". (api_is_western_name_order() ? "user.firstname AS col1, user.lastname AS col2 " : "user.lastname AS col1, user.firstname AS col2 " )." FROM ".$table_user." user, ".$table_group_user." group_rel_user WHERE group_rel_user.user_id = user.user_id AND group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'"; $sql .= " ORDER BY col$column $direction "; $sql .= " LIMIT $from,$number_of_items"; } } $return = array(); $result = Database::query($sql); while ($row = Database::fetch_row($result)) { $return[] = $row; } return $return; } /** * Returns a mailto-link * @param string $email An email-address * @return string HTML-code with a mailto-link */ function email_filter($email) { return Display :: encrypted_mailto_link($email, $email); } /** * Display a user icon that links to the user page * * @param integer $user_id the id of the user * @return html code * * @author Patrick Cool , Ghent University, Belgium * @version April 2008 */ function user_icon_filter($user_id) { global $origin; $userinfo = Database::get_user_info_from_id($user_id); $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true); $image_repository = $image_path['dir']; $existing_image = $image_path['file']; $photo = '
'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'
'; return ''.$photo; } /** * Return user profile link around the given user name. * * The parameters use a trick of the sorteable table, where the first param is * the original value of the column * @param string User name (value of the column at the time of calling) * @param string URL parameters * @param array Row of the "sortable table" as it is at the time of function call - we extract the user ID from there * @return string HTML link */ function user_name_filter($name, $url_params, $row) { global $origin; return ''.$name.''; } // Footer $orig = isset($origin) ? $origin : ''; if ($orig != 'learnpath') { Display::display_footer(); }