ON $tbl_user.user_id = $tbl_session_course_user.id_user AND
$tbl_session_course_user.course_code = '$course_code' AND
@ -108,10 +102,8 @@ class AnnouncementEmail
}
$rs = Database::query($sql);
$result = array();
while ($data = Database::fetch_array($rs))
{
while ($data = Database::fetch_array($rs)) {
$result[] = $data;
}
return $result;
@ -119,7 +111,7 @@ class AnnouncementEmail
/**
* Returns users and groups an announcement item has been sent to.
*
*
* @return array Array of users and groups to whom the element has been sent
*/
public function sent_to_info()
@ -134,25 +126,19 @@ class AnnouncementEmail
$id = $this->announcement('id');
$course_id = $this->course('id');
$sql = "SELECT to_group_id, to_user_id FROM $tbl_item_property WHERE c_id = $course_id AND tool = '$tool' AND ref=$id";
$sql = "SELECT to_group_id, to_user_id FROM $tbl_item_property WHERE c_id = $course_id AND tool = '$tool' AND ref=$id AND id_session = {$this->session_id} ";
$rs = Database::query($sql);
$sent_to_group = array();
$sent_to_user = array();
while ($row = Database::fetch_array($rs))
{
while ($row = Database::fetch_array($rs, 'ASSOC')) {
// if to_group_id is null then it is sent to a specific user
// if to_group_id = 0 then it is sent to everybody
$group_id = $row['to_group_id'];
if (!empty($group_id))
{
if (!empty($group_id)) {
$result['groups'][] = (int)$group_id;
}
// if to_user_id <> 0 then it is sent to a specific user
$user_id = $row['to_user_id'];
if (!empty($user_id))
{
if (!empty($user_id)) {
$result['users'][] = (int)$user_id;
}
}
@ -161,9 +147,9 @@ class AnnouncementEmail
/**
* Returns the list of user info to which an announcement was sent.
* This function returns a list of actual users even when recipient
* This function returns a list of actual users even when recipient