When sending emails we sent it also to the chamilo inbox

skala
Julio Montoya 13 years ago
parent 996a0ee752
commit 4f411cd564
  1. 3
      main/admin/system_announcements.php
  2. 17
      main/inc/lib/system_announcements.lib.php

@ -19,10 +19,9 @@ require_once '../inc/global.inc.php';
// Including additional libraries.
require_once api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
// Setting the section (for the tabs).
$this_section=SECTION_PLATFORM_ADMIN;
$this_section = SECTION_PLATFORM_ADMIN;
$_SESSION['this_section']=$this_section;
// Access restrictions

@ -537,15 +537,15 @@ class SystemAnnouncementManager {
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
if ($teacher <> 0 AND $student == 0) {
$sql = "SELECT firstname, lastname, email, status FROM $user_table u $url_condition WHERE status = '1' ";
$sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '1' ";
}
if ($teacher == 0 AND $student <> 0) {
$sql = "SELECT firstname, lastname, email, status FROM $user_table u $url_condition WHERE status = '5' ";
$sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' ";
}
if ($teacher<> 0 AND $student <> 0) {
$sql = "SELECT firstname, lastname, email FROM $user_table u $url_condition WHERE 1=1 ";
$sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 ";
}
if (!empty($language)) { //special condition because language was already treated for SQL insert before
@ -570,13 +570,14 @@ class SystemAnnouncementManager {
$title = api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset);
$content = api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'),'', $content)), ENT_QUOTES, $charset);
$admin_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$message_sent = false;
while ($row = Database::fetch_array($result,'ASSOC')) {
$name = api_get_person_name($row['firstname'], $row['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
$res = @api_mail_html($name, $row['email'], $title, $content, $admin_name, api_get_setting('emailAdministrator'));
MessageManager::send_message_simple($row['user_id'], $title, $content);
$message_sent = true;
}
return $res; //true if at least one e-mail was sent
return $message_sent; //true if at least one e-mail was sent
}

Loading…
Cancel
Save