@@ -928,7 +930,7 @@ if ($display_announcement_list) {
ORDER BY display_order DESC";
}
- } elseif (api_get_group_id() !=0 ) {
+ } elseif (api_get_group_id() != 0 ) {
// A.2. you are a course admin with a GROUP filter
// => see only the messages of this specific group
$sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
@@ -975,81 +977,80 @@ if ($display_announcement_list) {
ORDER BY display_order DESC";
}
}
- } else {
-
+ } else {
//STUDENT
- if (is_array($group_memberships) && count($group_memberships)>0) {
- if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
- if (api_get_group_id() == 0) {
- //No group
- $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ( ip.to_user_id='".$_user['user_id']."'" .
- " OR ip.to_group_id IN (0, ".implode(", ", $group_memberships)."))) ";
- } else {
- $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."'
- OR ip.to_group_id IN (0, ".api_get_group_id()."))";
- }
- //$cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") )) ";
-
+ if (is_array($group_memberships) && count($group_memberships)>0) {
+ if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
+ if (api_get_group_id() == 0) {
+ //No group
+ $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ( ip.to_user_id='".$_user['user_id']."'" .
+ " OR ip.to_group_id IN (0, ".implode(", ", $group_memberships)."))) ";
} else {
- if (api_get_group_id() == 0) {
- $cond_user_id = " AND (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) ";
- } else {
- $cond_user_id = " AND (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".api_get_group_id()."))";
- }
+ $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."'
+ OR ip.to_group_id IN (0, ".api_get_group_id()."))";
}
+ //$cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") )) ";
- $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE announcement.c_id = $course_id AND
- ip.c_id = $course_id AND
- announcement.id = ip.ref
- AND ip.tool='announcement'
- $cond_user_id
- $condition_session
- AND ip.visibility='1'
- ORDER BY display_order DESC";
} else {
- if ($_user['user_id']) {
- if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
- $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR (ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0')) ";
- } else {
- $cond_user_id = " AND (ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0') ";
- }
-
- $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE
- announcement.c_id = $course_id AND
- ip.c_id = $course_id AND
- announcement.id = ip.ref AND
- ip.tool='announcement'
- $cond_user_id
- $condition_session
- AND ip.visibility='1'
- AND announcement.session_id IN(0,".api_get_session_id().")
- ORDER BY display_order DESC";
+ if (api_get_group_id() == 0) {
+ $cond_user_id = " AND (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) ";
} else {
+ $cond_user_id = " AND (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".api_get_group_id()."))";
+ }
+ }
- if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
- $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ip.to_group_id='0' ) ";
- } else {
- $cond_user_id = " AND ip.to_group_id='0' ";
- }
+ $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
+ FROM $tbl_announcement announcement, $tbl_item_property ip
+ WHERE announcement.c_id = $course_id AND
+ ip.c_id = $course_id AND
+ announcement.id = ip.ref
+ AND ip.tool='announcement'
+ $cond_user_id
+ $condition_session
+ AND ip.visibility='1'
+ ORDER BY display_order DESC";
+ } else {
+ if ($_user['user_id']) {
+ if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
+ $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR (ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0')) ";
+ } else {
+ $cond_user_id = " AND (ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0') ";
+ }
- $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
- FROM $tbl_announcement announcement, $tbl_item_property ip
- WHERE
+ $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
+ FROM $tbl_announcement announcement, $tbl_item_property ip
+ WHERE
announcement.c_id = $course_id AND
ip.c_id = $course_id AND
- announcement.id = ip.ref
- AND ip.tool='announcement'
+ announcement.id = ip.ref AND
+ ip.tool='announcement'
$cond_user_id
$condition_session
AND ip.visibility='1'
- AND announcement.session_id IN(0,".api_get_session_id().")";
+ AND announcement.session_id IN(0,".api_get_session_id().")
+ ORDER BY display_order DESC";
+ } else {
+
+ if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
+ $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ip.to_group_id='0' ) ";
+ } else {
+ $cond_user_id = " AND ip.to_group_id='0' ";
}
+
+ $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date
+ FROM $tbl_announcement announcement, $tbl_item_property ip
+ WHERE
+ announcement.c_id = $course_id AND
+ ip.c_id = $course_id AND
+ announcement.id = ip.ref
+ AND ip.tool='announcement'
+ $cond_user_id
+ $condition_session
+ AND ip.visibility='1'
+ AND announcement.session_id IN(0,".api_get_session_id().")";
}
+ }
}
$result = Database::query($sql);
diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php
index c2af82dc37..8fec22fa2a 100644
--- a/main/inc/lib/groupmanager.lib.php
+++ b/main/inc/lib/groupmanager.lib.php
@@ -1037,7 +1037,7 @@ class GroupManager {
$group_id = Database::escape_string($group_id);
$course_id = api_get_course_int_id();
- $sql = "SELECT ug.id, u.user_id, u.lastname, u.firstname, u.email
+ $sql = "SELECT ug.id, u.user_id, u.lastname, u.firstname, u.email, u.username
FROM ".$table_user." u, ".$table_group_user." ug
WHERE ug.c_id = $course_id AND
ug.group_id='".$group_id."' AND
@@ -1045,10 +1045,11 @@ class GroupManager {
$db_result = Database::query($sql);
$users = array ();
while ($user = Database::fetch_object($db_result)) {
- $member['user_id'] = $user->user_id;
+ $member['user_id'] = $user->user_id;
$member['firstname'] = $user->firstname;
- $member['lastname'] = $user->lastname;
- $member['email'] = $user->email;
+ $member['lastname'] = $user->lastname;
+ $member['email'] = $user->email;
+ $member['username'] = $user->username;
$users[] = $member;
}
return $users;
|