Minor - UI + query fixes in announcements and groups

skala
Julio Montoya 13 years ago
parent f4dbc099bf
commit b2240f255b
  1. 15
      main/announcements/announcements.inc.php
  2. 135
      main/announcements/announcements.php
  3. 9
      main/inc/lib/groupmanager.lib.php

@ -60,11 +60,12 @@ class AnnouncementManager {
$sql="SELECT DISTINCT announcement.id, announcement.title, announcement.content
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE announcement.id = toolitemproperties.ref
AND toolitemproperties.tool='announcement'
AND announcement.session_id = '$session_id' AND
c_id = $course_id
ORDER BY display_order DESC";
WHERE announcement.id = toolitemproperties.ref AND
toolitemproperties.tool='announcement' AND
announcement.session_id = '$session_id' AND
announcement.c_id = $course_id AND
toolitemproperties.c_id = $course_id
ORDER BY display_order DESC";
$rs = Database::query($sql);
$num_rows = Database::num_rows($rs);
$result = array();
@ -111,6 +112,7 @@ class AnnouncementManager {
*/
public static function delete_all_announcements($_course) {
$announcements = self::get_all_annoucement_by_course($_course, api_get_session_id());
foreach ($announcements as $annon) {
api_item_property_update($_course, TOOL_ANNOUNCEMENT, $annon['id'], 'delete', api_get_user_id());
@ -569,8 +571,7 @@ class AnnouncementManager {
foreach ($group_users as $user){
echo '<option value="'.$user['user_id'].'">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')'.'</option>';
}
echo '</select>';
echo '</select>';
echo "</td>";
// the buttons for adding or removing groups/users

@ -779,12 +779,13 @@ if ($display_form) {
if ($announcement_to_modify=='') {
($email_ann=='1' || !empty($surveyid))?$checked='checked':$checked='';
echo '<div class="row">
<div class="label">
<input class="checkbox" type="checkbox" value="1" name="email_ann" '.$checked.'>
<div class="label">
</div>
<div class="formw">'.
get_lang('EmailOption').': '.get_lang('MyGroup').'&nbsp;&nbsp;<a href="#" onclick="if(document.getElementById(\'recipient_list\').style.display==\'none\') document.getElementById(\'recipient_list\').style.display=\'block\'; else document.getElementById(\'recipient_list\').style.display=\'none\';">'.get_lang('ModifyRecipientList').'</a>';
AnnouncementManager::show_to_form_group($_SESSION['toolgroup']);
<div class="formw">
<input class="checkbox" type="checkbox" value="1" name="email_ann" '.$checked.'>
'.get_lang('EmailOption').': '.get_lang('MyGroup').'&nbsp;&nbsp;
<a href="#" onclick="if(document.getElementById(\'recipient_list\').style.display==\'none\') document.getElementById(\'recipient_list\').style.display=\'block\'; else document.getElementById(\'recipient_list\').style.display=\'none\';">'.get_lang('ModifyRecipientList').'</a>';
AnnouncementManager::show_to_form_group($_SESSION['toolgroup']);
echo '</div></div>';
}
@ -832,10 +833,11 @@ if ($display_form) {
//File attachment
echo ' <div class="row">
<div class="label">
<a href="javascript://" onclick="return plus_attachment();"><span id="plus"><img style="vertical-align:middle;" src="../img/div_show.gif" alt="" />&nbsp;'.get_lang('AddAnAttachment').'</span></a>
<div class="label">
</div>
<div class="formw">
<a href="javascript://" onclick="return plus_attachment();"><span id="plus"><img style="vertical-align:middle;" src="../img/div_show.gif" alt="" />&nbsp;'.get_lang('AddAnAttachment').'</span></a>
<br />
<table id="options" style="display: none;">
<tr>
<td colspan="2">
@ -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);

@ -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;

Loading…
Cancel
Save