Minor - format code.

1.9.x
Julio Montoya 11 years ago
parent b6fab01f85
commit 1e8784125e
  1. 381
      main/group/group_space.php

@ -9,8 +9,6 @@
* @todo Display error message if no group ID specified * @todo Display error message if no group ID specified
*/ */
/* INIT SECTION */
// Name of the language file that needs to be included // Name of the language file that needs to be included
$language_file = 'group'; $language_file = 'group';
@ -21,7 +19,6 @@ $current_course_tool = TOOL_GROUP;
api_protect_course_script(true); api_protect_course_script(true);
/* Libraries & config files */ /* Libraries & config files */
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php'; require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
require_once api_get_path(SYS_CODE_PATH).'forum/forumconfig.inc.php'; require_once api_get_path(SYS_CODE_PATH).'forum/forumconfig.inc.php';
@ -32,7 +29,7 @@ $user_id = api_get_user_id();
$current_group = GroupManager :: get_group_properties($group_id); $current_group = GroupManager :: get_group_properties($group_id);
if (empty($current_group)) { if (empty($current_group)) {
api_not_allowed(true); api_not_allowed(true);
} }
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
@ -45,11 +42,11 @@ $forums_of_groups = get_forums_of_group($current_group['id']);
$forum_state_public = 0; $forum_state_public = 0;
if (is_array($forums_of_groups)) { if (is_array($forums_of_groups)) {
foreach ($forums_of_groups as $key => $value) { foreach ($forums_of_groups as $key => $value) {
if ($value['forum_group_public_private'] == 'public') { if ($value['forum_group_public_private'] == 'public') {
$forum_state_public = 1; $forum_state_public = 1;
} }
} }
} }
if ($current_group['doc_state'] != 1 && if ($current_group['doc_state'] != 1 &&
@ -60,10 +57,10 @@ if ($current_group['doc_state'] != 1 &&
$current_group['chat_state'] != 1 && $current_group['chat_state'] != 1 &&
$forum_state_public != 1 $forum_state_public != 1
) { ) {
if (!api_is_allowed_to_edit(null,true) && if (!api_is_allowed_to_edit(null,true) &&
!GroupManager::is_user_in_group($user_id, $group_id)) { !GroupManager::is_user_in_group($user_id, $group_id)) {
api_not_allowed($print_headers); api_not_allowed($print_headers);
} }
} }
/* Header */ /* Header */
@ -79,7 +76,9 @@ Display::display_introduction_section(TOOL_GROUP);
/* /*
* User wants to register in this group * User wants to register in this group
*/ */
if (!empty($_GET['selfReg']) && GroupManager :: is_self_registration_allowed($user_id, $current_group['id'])) { if (!empty($_GET['selfReg']) &&
GroupManager :: is_self_registration_allowed($user_id, $current_group['id'])
) {
GroupManager :: subscribe_users($user_id, $current_group['id']); GroupManager :: subscribe_users($user_id, $current_group['id']);
Display :: display_normal_message(get_lang('GroupNowMember')); Display :: display_normal_message(get_lang('GroupNowMember'));
} }
@ -87,20 +86,24 @@ if (!empty($_GET['selfReg']) && GroupManager :: is_self_registration_allowed($us
/* /*
* User wants to unregister from this group * User wants to unregister from this group
*/ */
if (!empty($_GET['selfUnReg']) && GroupManager :: is_self_unregistration_allowed($user_id, $current_group['id'])) { if (!empty($_GET['selfUnReg']) &&
GroupManager :: is_self_unregistration_allowed($user_id, $current_group['id'])
) {
GroupManager :: unsubscribe_users($user_id, $current_group['id']); GroupManager :: unsubscribe_users($user_id, $current_group['id']);
Display::display_normal_message(get_lang('StudentDeletesHimself')); Display::display_normal_message(get_lang('StudentDeletesHimself'));
} }
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="group.php">'.Display::return_icon('back.png',get_lang('BackToGroupList'),'',ICON_SIZE_MEDIUM).'</a>'; echo '<a href="group.php">'.
Display::return_icon('back.png',get_lang('BackToGroupList'),'',ICON_SIZE_MEDIUM).
'</a>';
/* /*
* Register to group * Register to group
*/ */
$subscribe_group = ''; $subscribe_group = '';
if (GroupManager :: is_self_registration_allowed($user_id, $current_group['id'])) { if (GroupManager :: is_self_registration_allowed($user_id, $current_group['id'])) {
$subscribe_group = '<a class="btn" href="'.api_get_self().'?selfReg=1&amp;group_id='.$current_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."'".')) return false;">'. $subscribe_group = '<a class="btn" href="'.api_get_self().'?selfReg=1&amp;group_id='.$current_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."'".')) return false;">'.
get_lang("RegIntoGroup").'</a>'; get_lang("RegIntoGroup").'</a>';
} }
@ -109,17 +112,17 @@ if (GroupManager :: is_self_registration_allowed($user_id, $current_group['id'])
*/ */
$unsubscribe_group = ''; $unsubscribe_group = '';
if (GroupManager :: is_self_unregistration_allowed($user_id, $current_group['id'])) { if (GroupManager :: is_self_unregistration_allowed($user_id, $current_group['id'])) {
$unsubscribe_group = '<a class="btn" href="'.api_get_self().'?selfUnReg=1" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."'".')) return false;">'. $unsubscribe_group = '<a class="btn" href="'.api_get_self().'?selfUnReg=1" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."'".')) return false;">'.
get_lang("StudentUnsubscribe").'</a>'; get_lang("StudentUnsubscribe").'</a>';
} }
echo '&nbsp;</div>'; echo '&nbsp;</div>';
if (isset($_GET['action'])) { if (isset($_GET['action'])) {
switch ($_GET['action']) { switch ($_GET['action']) {
case 'show_msg': case 'show_msg':
Display::display_normal_message(Security::remove_XSS($_GET['msg'])); Display::display_normal_message(Security::remove_XSS($_GET['msg']));
break; break;
} }
} }
/* Main Display Area */ /* Main Display Area */
@ -146,7 +149,7 @@ echo Display::page_header(
); );
if (!empty($current_group['description'])) { if (!empty($current_group['description'])) {
echo '<p>'.Security::remove_XSS($current_group['description']).'</p>'; echo '<p>'.Security::remove_XSS($current_group['description']).'</p>';
} }
/* /*
@ -160,11 +163,11 @@ if (api_is_allowed_to_edit(false, true) OR
// Link to the forum of this group // Link to the forum of this group
$forums_of_groups = get_forums_of_group($current_group['id']); $forums_of_groups = get_forums_of_group($current_group['id']);
if (is_array($forums_of_groups)) { if (is_array($forums_of_groups)) {
if ($current_group['forum_state'] != GroupManager::TOOL_NOT_AVAILABLE ) { if ($current_group['forum_state'] != GroupManager::TOOL_NOT_AVAILABLE ) {
foreach ($forums_of_groups as $key => $value) { foreach ($forums_of_groups as $key => $value) {
//*!empty($user_subscribe_to_current_group) && */ //*!empty($user_subscribe_to_current_group) && */
if ($value['forum_group_public_private'] == 'public' || if ($value['forum_group_public_private'] == 'public' ||
($value['forum_group_public_private'] == 'private') || ($value['forum_group_public_private'] == 'private') ||
!empty($user_is_tutor) || !empty($user_is_tutor) ||
api_is_allowed_to_edit(false, true) api_is_allowed_to_edit(false, true)
@ -172,139 +175,139 @@ if (api_is_allowed_to_edit(false, true) OR
$actions_array[] = array( $actions_array[] = array(
'url' => '../forum/viewforum.php?forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'&amp;origin=group', 'url' => '../forum/viewforum.php?forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'&amp;origin=group',
'content' => Display::return_icon('forum.png', get_lang('Forum').': '.$value['forum_title'] , array(), 32) 'content' => Display::return_icon('forum.png', get_lang('Forum').': '.$value['forum_title'] , array(), 32)
); );
} }
} }
} }
} }
if ($current_group['doc_state'] != GroupManager::TOOL_NOT_AVAILABLE) { if ($current_group['doc_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
// Link to the documents area of this group // Link to the documents area of this group
$actions_array[] = array( $actions_array[] = array(
'url' => '../document/document.php?'.api_get_cidreq(), 'url' => '../document/document.php?'.api_get_cidreq(),
'content' => Display::return_icon('folder.png', get_lang('GroupDocument'), array(), 32) 'content' => Display::return_icon('folder.png', get_lang('GroupDocument'), array(), 32)
); );
} }
if ($current_group['calendar_state'] != GroupManager::TOOL_NOT_AVAILABLE) { if ($current_group['calendar_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
// Link to a group-specific part of agenda // Link to a group-specific part of agenda
$actions_array[] = array( $actions_array[] = array(
'url' => '../calendar/agenda.php?'.api_get_cidreq(), 'url' => '../calendar/agenda.php?'.api_get_cidreq(),
'content' => Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), 32) 'content' => Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), 32)
); );
} }
if ($current_group['work_state'] != GroupManager::TOOL_NOT_AVAILABLE) { if ($current_group['work_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
// Link to the works area of this group // Link to the works area of this group
$actions_array[] = array( $actions_array[] = array(
'url' => '../work/work.php?'.api_get_cidreq(), 'url' => '../work/work.php?'.api_get_cidreq(),
'content' => Display::return_icon('work.png', get_lang('GroupWork'), array(), 32) 'content' => Display::return_icon('work.png', get_lang('GroupWork'), array(), 32)
); );
} }
if ($current_group['announcements_state'] != GroupManager::TOOL_NOT_AVAILABLE) { if ($current_group['announcements_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
// Link to a group-specific part of announcements // Link to a group-specific part of announcements
$actions_array[] = array( $actions_array[] = array(
'url' => '../announcements/announcements.php?'.api_get_cidreq(), 'url' => '../announcements/announcements.php?'.api_get_cidreq(),
'content' => Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), 32) 'content' => Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), 32)
); );
} }
if ($current_group['wiki_state'] != GroupManager::TOOL_NOT_AVAILABLE) { if ($current_group['wiki_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
// Link to the wiki area of this group // Link to the wiki area of this group
$actions_array[] = array( $actions_array[] = array(
'url' => '../wiki/index.php?'.api_get_cidreq().'&amp;action=show&amp;title=index&amp;session_id='.api_get_session_id().'&amp;group_id='.$current_group['id'], 'url' => '../wiki/index.php?'.api_get_cidreq().'&amp;action=show&amp;title=index&amp;session_id='.api_get_session_id().'&amp;group_id='.$current_group['id'],
'content' => Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32) 'content' => Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32)
); );
} }
if ($current_group['chat_state'] != GroupManager::TOOL_NOT_AVAILABLE) { if ($current_group['chat_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
// Link to the chat area of this group // Link to the chat area of this group
if (api_get_course_setting('allow_open_chat_window')) { if (api_get_course_setting('allow_open_chat_window')) {
$actions_array[] = array( $actions_array[] = array(
'url' => "javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \"", 'url' => "javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \"",
'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32) 'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32)
); );
} else { } else {
$actions_array[] = array( $actions_array[] = array(
'url' => "../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id'], 'url' => "../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id'],
'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32) 'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32)
); );
} }
} }
if (!empty($actions_array)) { if (!empty($actions_array)) {
echo Display::actions($actions_array); echo Display::actions($actions_array);
} }
} else { } else {
$actions_array = array(); $actions_array = array();
// Link to the forum of this group // Link to the forum of this group
$forums_of_groups = get_forums_of_group($current_group['id']); $forums_of_groups = get_forums_of_group($current_group['id']);
if (is_array($forums_of_groups)) { if (is_array($forums_of_groups)) {
if ( $current_group['forum_state'] == GroupManager::TOOL_PUBLIC ) { if ( $current_group['forum_state'] == GroupManager::TOOL_PUBLIC ) {
foreach ($forums_of_groups as $key => $value) { foreach ($forums_of_groups as $key => $value) {
if ($value['forum_group_public_private'] == 'public' ) { if ($value['forum_group_public_private'] == 'public' ) {
$actions_array[] = array( $actions_array[] = array(
'url' => '../forum/viewforum.php?cidReq='.api_get_course_id().'&forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'&amp;origin=group', 'url' => '../forum/viewforum.php?cidReq='.api_get_course_id().'&forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'&amp;origin=group',
'content' => Display::return_icon('forum.png', get_lang('GroupForum'), array(), ICON_SIZE_MEDIUM) 'content' => Display::return_icon('forum.png', get_lang('GroupForum'), array(), ICON_SIZE_MEDIUM)
); );
} }
} }
} }
} }
if ($current_group['doc_state'] == GroupManager::TOOL_PUBLIC) { if ($current_group['doc_state'] == GroupManager::TOOL_PUBLIC) {
// Link to the documents area of this group // Link to the documents area of this group
$actions_array[] = array( $actions_array[] = array(
'url' => '../document/document.php?'.api_get_cidreq().'&amp;origin='.$origin, 'url' => '../document/document.php?'.api_get_cidreq().'&amp;origin='.$origin,
'content' => Display::return_icon('folder.png', get_lang('GroupDocument'), array(), ICON_SIZE_MEDIUM) 'content' => Display::return_icon('folder.png', get_lang('GroupDocument'), array(), ICON_SIZE_MEDIUM)
); );
} }
if ($current_group['calendar_state'] == GroupManager::TOOL_PUBLIC) { if ($current_group['calendar_state'] == GroupManager::TOOL_PUBLIC) {
// Link to a group-specific part of agenda // Link to a group-specific part of agenda
$actions_array[] = array( $actions_array[] = array(
'url' => '../calendar/agenda.php?'.api_get_cidreq(), 'url' => '../calendar/agenda.php?'.api_get_cidreq(),
'content' => Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), ICON_SIZE_MEDIUM) 'content' => Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), ICON_SIZE_MEDIUM)
); );
} }
if ($current_group['work_state'] == GroupManager::TOOL_PUBLIC) { if ($current_group['work_state'] == GroupManager::TOOL_PUBLIC) {
// Link to the works area of this group // Link to the works area of this group
$actions_array[] = array( $actions_array[] = array(
'url' => '../work/work.php?'.api_get_cidreq(), 'url' => '../work/work.php?'.api_get_cidreq(),
'content' => Display::return_icon('work.png', get_lang('GroupWork'), array(), ICON_SIZE_MEDIUM) 'content' => Display::return_icon('work.png', get_lang('GroupWork'), array(), ICON_SIZE_MEDIUM)
); );
} }
if ($current_group['announcements_state'] == GroupManager::TOOL_PUBLIC) { if ($current_group['announcements_state'] == GroupManager::TOOL_PUBLIC) {
// Link to a group-specific part of announcements // Link to a group-specific part of announcements
$actions_array[] = array( $actions_array[] = array(
'url' => '../announcements/announcements.php?'.api_get_cidreq(), 'url' => '../announcements/announcements.php?'.api_get_cidreq(),
'content' => Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), ICON_SIZE_MEDIUM) 'content' => Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), ICON_SIZE_MEDIUM)
); );
} }
if ($current_group['wiki_state'] == GroupManager::TOOL_PUBLIC) { if ($current_group['wiki_state'] == GroupManager::TOOL_PUBLIC) {
// Link to the wiki area of this group // Link to the wiki area of this group
$actions_array[] = array( $actions_array[] = array(
'url' => '../wiki/index.php?'.api_get_cidreq().'&amp;action=show&amp;title=index&amp;session_id='.api_get_session_id().'&amp;group_id='.$current_group['id'], 'url' => '../wiki/index.php?'.api_get_cidreq().'&amp;action=show&amp;title=index&amp;session_id='.api_get_session_id().'&amp;group_id='.$current_group['id'],
'content' => Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32) 'content' => Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32)
); );
} }
if ($current_group['chat_state'] == GroupManager::TOOL_PUBLIC ) { if ($current_group['chat_state'] == GroupManager::TOOL_PUBLIC ) {
// Link to the chat area of this group // Link to the chat area of this group
if (api_get_course_setting('allow_open_chat_window')) { if (api_get_course_setting('allow_open_chat_window')) {
$actions_array[] = array( $actions_array[] = array(
'url' => "javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \"", 'url' => "javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \"",
'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32) 'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32)
); );
} else { } else {
$actions_array[] = array( $actions_array[] = array(
'url' => "../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id'], 'url' => "../chat/chat.php?".api_get_cidreq()."&amp;toolgroup=".$current_group['id'],
'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32) 'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32)
); );
} }
} }
if (!empty($actions_array)) { if (!empty($actions_array)) {
echo Display::actions($actions_array); echo Display::actions($actions_array);
} }
} }
/* /*
@ -314,27 +317,27 @@ $tutors = GroupManager::get_subscribed_tutors($current_group['id']);
$tutor_info = ''; $tutor_info = '';
if (count($tutors) == 0) { if (count($tutors) == 0) {
$tutor_info = get_lang('GroupNoneMasc'); $tutor_info = get_lang('GroupNoneMasc');
} else { } else {
isset($origin) ? $my_origin = $origin:$my_origin=''; isset($origin) ? $my_origin = $origin:$my_origin='';
$tutor_info .= '<ul class="thumbnails">'; $tutor_info .= '<ul class="thumbnails">';
foreach ($tutors as $index => $tutor) { foreach ($tutors as $index => $tutor) {
$tab_user_info = api_get_user_info($tutor['user_id']); $tab_user_info = api_get_user_info($tutor['user_id']);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $tab_user_info['username']), ENT_QUOTES); $username = api_htmlentities(sprintf(get_lang('LoginX'), $tab_user_info['username']), ENT_QUOTES);
$image_path = UserManager::get_user_picture_path_by_id($tutor['user_id'], 'web', false, true); $image_path = UserManager::get_user_picture_path_by_id($tutor['user_id'], 'web', false, true);
$image_repository = $image_path['dir']; $image_repository = $image_path['dir'];
$existing_image = $image_path['file']; $existing_image = $image_path['file'];
$completeName = api_get_person_name($tutor['firstname'], $tutor['lastname']); $completeName = api_get_person_name($tutor['firstname'], $tutor['lastname']);
$photo = '<img src="'.$image_repository.$existing_image.'" alt="'.$completeName.'" width="32" height="32" title="'.$completeName.'" />'; $photo = '<img src="'.$image_repository.$existing_image.'" alt="'.$completeName.'" width="32" height="32" title="'.$completeName.'" />';
$tutor_info .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?origin='.$my_origin.'&amp;uInfo='.$tutor['user_id'].'">'. $tutor_info .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?origin='.$my_origin.'&amp;uInfo='.$tutor['user_id'].'">'.
$photo.'&nbsp;'.$completeName.'</a></li>'; $photo.'&nbsp;'.$completeName.'</a></li>';
} }
$tutor_info .= '</ul>'; $tutor_info .= '</ul>';
} }
echo Display::page_subheader(get_lang('GroupTutors')); echo Display::page_subheader(get_lang('GroupTutors'));
if (!empty($tutor_info)) { if (!empty($tutor_info)) {
echo $tutor_info; echo $tutor_info;
} }
echo '<br />'; echo '<br />';
@ -351,21 +354,21 @@ $parameters = array('cidReq' => $my_cidreq, 'origin'=> $my_origin, 'gidReq' => $
$table->set_additional_parameters($parameters); $table->set_additional_parameters($parameters);
$table->set_header(0, ''); $table->set_header(0, '');
if (api_is_western_name_order()) { if (api_is_western_name_order()) {
$table->set_header(1, get_lang('FirstName')); $table->set_header(1, get_lang('FirstName'));
$table->set_header(2, get_lang('LastName')); $table->set_header(2, get_lang('LastName'));
} else { } else {
$table->set_header(1, get_lang('LastName')); $table->set_header(1, get_lang('LastName'));
$table->set_header(2, get_lang('FirstName')); $table->set_header(2, get_lang('FirstName'));
} }
if (api_get_setting('show_email_addresses') == 'true') { if (api_get_setting('show_email_addresses') == 'true') {
$table->set_header(3, get_lang('Email')); $table->set_header(3, get_lang('Email'));
$table->set_column_filter(3, 'email_filter'); $table->set_column_filter(3, 'email_filter');
} else { } else {
if (api_is_allowed_to_edit() == 'true') { if (api_is_allowed_to_edit() == 'true') {
$table->set_header(3, get_lang('Email')); $table->set_header(3, get_lang('Email'));
$table->set_column_filter(3, 'email_filter'); $table->set_column_filter(3, 'email_filter');
} }
} }
//the order of these calls is important //the order of these calls is important
$table->set_column_filter(1, 'user_name_filter'); $table->set_column_filter(1, 'user_name_filter');
@ -381,19 +384,21 @@ $table->display();
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version April 2008 * @version April 2008
*/ */
function get_number_of_group_users() { function get_number_of_group_users()
global $current_group; {
global $current_group;
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// Database table definition // Database table definition
$table_group_user = Database :: get_course_table(TABLE_GROUP_USER); $table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
// Query // Query
$sql = "SELECT count(id) AS number_of_users FROM ".$table_group_user." $sql = "SELECT count(id) AS number_of_users
WHERE c_id = $course_id AND group_id='".Database::escape_string($current_group['id'])."'"; FROM ".$table_group_user."
$result = Database::query($sql); WHERE c_id = $course_id AND group_id='".Database::escape_string($current_group['id'])."'";
$return = Database::fetch_array($result,'ASSOC'); $result = Database::query($sql);
return $return['number_of_users']; $return = Database::fetch_array($result,'ASSOC');
return $return['number_of_users'];
} }
/** /**
@ -408,80 +413,82 @@ function get_number_of_group_users() {
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version April 2008 * @version April 2008
*/ */
function get_group_user_data($from, $number_of_items, $column, $direction) { function get_group_user_data($from, $number_of_items, $column, $direction)
global $current_group; {
global $current_group;
// Database table definition // Database table definition
$table_group_user = Database :: get_course_table(TABLE_GROUP_USER); $table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
$table_user = Database :: get_main_table(TABLE_MAIN_USER); $table_user = Database :: get_main_table(TABLE_MAIN_USER);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// Query // Query
if (api_get_setting('show_email_addresses') == 'true') { if (api_get_setting('show_email_addresses') == 'true') {
$sql = "SELECT user.user_id AS col0, $sql = "SELECT user.user_id AS col0,
".(api_is_western_name_order() ? ".(api_is_western_name_order() ?
"user.firstname AS col1, "user.firstname AS col1,
user.lastname AS col2," user.lastname AS col2,"
: :
"user.lastname AS col1, "user.lastname AS col1,
user.firstname AS col2," user.firstname AS col2,"
)." )."
user.email AS col3 user.email AS col3
FROM ".$table_user." user, ".$table_group_user." group_rel_user FROM ".$table_user." user, ".$table_group_user." group_rel_user
WHERE group_rel_user.c_id = $course_id AND group_rel_user.user_id = user.user_id WHERE group_rel_user.c_id = $course_id AND group_rel_user.user_id = user.user_id
AND group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'"; AND group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'";
$sql .= " ORDER BY col$column $direction "; $sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items"; $sql .= " LIMIT $from,$number_of_items";
} else { } else {
if (api_is_allowed_to_edit()) { if (api_is_allowed_to_edit()) {
$sql = "SELECT DISTINCT $sql = "SELECT DISTINCT
u.user_id AS col0, u.user_id AS col0,
".(api_is_western_name_order() ? ".(api_is_western_name_order() ?
"u.firstname AS col1, "u.firstname AS col1,
u.lastname AS col2," u.lastname AS col2,"
: :
"u.lastname AS col1, "u.lastname AS col1,
u.firstname AS col2," u.firstname AS col2,"
)." )."
u.email AS col3 u.email AS col3
FROM ".$table_user." u INNER JOIN ".$table_group_user." gu ON (gu.user_id = u.user_id) AND gu.c_id = $course_id FROM ".$table_user." u INNER JOIN ".$table_group_user." gu ON (gu.user_id = u.user_id) AND gu.c_id = $course_id
WHERE gu.group_id = '".Database::escape_string($current_group['id'])."'"; WHERE gu.group_id = '".Database::escape_string($current_group['id'])."'";
$sql .= " ORDER BY col$column $direction "; $sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items"; $sql .= " LIMIT $from,$number_of_items";
} else { } else {
$sql = "SELECT DISTINCT $sql = "SELECT DISTINCT
user.user_id AS col0, user.user_id AS col0,
". (api_is_western_name_order() ? ". (api_is_western_name_order() ?
"user.firstname AS col1, "user.firstname AS col1,
user.lastname AS col2 " user.lastname AS col2 "
: :
"user.lastname AS col1, "user.lastname AS col1,
user.firstname AS col2 " user.firstname AS col2 "
)." )."
FROM ".$table_user." user, ".$table_group_user." group_rel_user FROM ".$table_user." user, ".$table_group_user." group_rel_user
WHERE group_rel_user.c_id = $course_id AND group_rel_user.user_id = user.user_id WHERE group_rel_user.c_id = $course_id AND group_rel_user.user_id = user.user_id
AND group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'"; AND group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'";
$sql .= " ORDER BY col$column $direction "; $sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items"; $sql .= " LIMIT $from,$number_of_items";
} }
} }
$return = array(); $return = array();
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_row($result)) { while ($row = Database::fetch_row($result)) {
$return[] = $row; $return[] = $row;
} }
return $return; return $return;
} }
/** /**
* Returns a mailto-link * Returns a mailto-link
* @param string $email An email-address * @param string $email An email-address
* @return string HTML-code with a mailto-link * @return string HTML-code with a mailto-link
*/ */
function email_filter($email) { function email_filter($email)
return Display :: encrypted_mailto_link($email, $email); {
return Display :: encrypted_mailto_link($email, $email);
} }
/** /**
@ -493,14 +500,15 @@ function email_filter($email) {
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version April 2008 * @version April 2008
*/ */
function user_icon_filter($user_id) { function user_icon_filter($user_id)
global $origin; {
$userinfo = api_get_user_info($user_id); global $origin;
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true); $userinfo = api_get_user_info($user_id);
$image_repository = $image_path['dir']; $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
$existing_image = $image_path['file']; $image_repository = $image_path['dir'];
$photo = '<center><img src="'.$image_repository.$existing_image.'" alt="'.$userinfo['complete_name'].'" width="22" height="22" title="'.$userinfo['complete_name'].'" /></center>'; $existing_image = $image_path['file'];
return '<a href="../user/userInfo.php?origin='.$origin.'&amp;uInfo='.$user_id.'">'.$photo; $photo = '<center><img src="'.$image_repository.$existing_image.'" alt="'.$userinfo['complete_name'].'" width="22" height="22" title="'.$userinfo['complete_name'].'" /></center>';
return '<a href="../user/userInfo.php?origin='.$origin.'&amp;uInfo='.$user_id.'">'.$photo;
} }
/** /**
@ -513,7 +521,8 @@ function user_icon_filter($user_id) {
* @param array Row of the "sortable table" as it is at the time of function call - we extract the user ID from there * @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 * @return string HTML link
*/ */
function user_name_filter($name, $url_params, $row) { function user_name_filter($name, $url_params, $row)
{
$tab_user_info = api_get_user_info($row[0]); $tab_user_info = api_get_user_info($row[0]);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $tab_user_info['username']), ENT_QUOTES); $username = api_htmlentities(sprintf(get_lang('LoginX'), $tab_user_info['username']), ENT_QUOTES);
return '<a href="../user/userInfo.php?uInfo='.$row[0].'&amp;'.$url_params.'" title="'.$username.'">'.$name.'</a>'; return '<a href="../user/userInfo.php?uInfo='.$row[0].'&amp;'.$url_params.'" title="'.$username.'">'.$name.'</a>';
@ -522,5 +531,5 @@ function user_name_filter($name, $url_params, $row) {
// Footer // Footer
$orig = isset($origin) ? $origin : ''; $orig = isset($origin) ? $origin : '';
if ($orig != 'learnpath') { if ($orig != 'learnpath') {
Display::display_footer(); Display::display_footer();
} }

Loading…
Cancel
Save