Allow sent announcements to all users in course/group - refs BT#12454

remotes/angel/1.11.x
Angel Fernando Quiroz Campos 8 years ago
parent 1697235826
commit 3aa2f72e2c
  1. 22
      main/announcements/announcements.php
  2. 10
      main/inc/lib/AnnouncementManager.php

@ -378,6 +378,9 @@ switch ($action) {
$nameTools = $form_name;
$form->addElement('header', $form_name);
$form->addButtonAdvancedSettings('choose_recipients', [get_lang('ChooseRecipients'), get_lang('AnnouncementChooseRecipientsDescription')]);
$form->addHtml('<div id="choose_recipients_options" style="display: none;">');
$to = [];
if (empty($group_id)) {
if (isset($_GET['remind_inactive'])) {
@ -436,7 +439,8 @@ switch ($action) {
$element = CourseManager::addGroupMultiSelect($form, $group_properties['iid'], array());
}
$form->setRequired($element);
$form->addHtml('</div>');
// $form->setRequired($element);
$form->addCheckBox('email_ann', '', get_lang('EmailOption'));
if (!isset($announcement_to_modify)) {
@ -461,6 +465,21 @@ switch ($action) {
}
}
foreach ($defaults['users'] as $value) {
$parts = explode(':', $value);
if (isset($parts[1]) && !empty($parts[1])) {
$form->addHtml("
<script>
$(document).on('ready', function () {
$('#choose_recipients').click();
});
</script>
");
break;
}
}
$defaults['email_ann'] = true;
$form->addElement('text', 'title', get_lang('EmailTitle'));
@ -500,6 +519,7 @@ switch ($action) {
if ($form->validate()) {
$data = $form->getSubmitValues();
$data['users'] = isset($data['users']) ? $data['users'] : ['everyone'];
$sendToUsersInSession = isset($data['send_to_users_in_session']) ? true : false;

@ -1475,7 +1475,7 @@ class AnnouncementManager
// No group
$cond_user_id = " AND (
ip.lastedit_user_id = '".$user_id."' OR (
ip.to_user_id='".$user_id."' OR
(ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) OR
(ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships)."))
)
) ";
@ -1487,11 +1487,11 @@ class AnnouncementManager
} else {
if ($group_id == 0) {
$cond_user_id = " AND (
ip.to_user_id = $user_id AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships)."))
(ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships)."))
) ";
} else {
$cond_user_id = " AND (
ip.to_user_id = $user_id AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".$group_id."))
(ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".$group_id."))
)";
}
}
@ -1514,10 +1514,10 @@ class AnnouncementManager
if ($allowUserEditSetting && !api_is_anonymous()) {
$cond_user_id = " AND (
ip.lastedit_user_id = '".api_get_user_id()."' OR
(ip.to_user_id='".$user_id."' AND (ip.to_group_id='0' OR ip.to_group_id IS NULL))
((ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND (ip.to_group_id='0' OR ip.to_group_id IS NULL))
) ";
} else {
$cond_user_id = " AND (ip.to_user_id='".$user_id."' AND (ip.to_group_id='0' OR ip.to_group_id IS NULL) ) ";
$cond_user_id = " AND ((ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND (ip.to_group_id='0' OR ip.to_group_id IS NULL) ) ";
}
$sql = "SELECT $select

Loading…
Cancel
Save