|
|
|
|
@ -524,15 +524,13 @@ class SystemAnnouncementManager { |
|
|
|
|
* @param string Language (optional, considered for all languages if left empty) |
|
|
|
|
* @return bool True if the message was sent or there was no destination matching. False on database or e-mail sending error. |
|
|
|
|
*/ |
|
|
|
|
public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language=null) { |
|
|
|
|
global $_user; |
|
|
|
|
global $_setting; |
|
|
|
|
public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null) { |
|
|
|
|
global $charset; |
|
|
|
|
global $_configuration; |
|
|
|
|
$current_access_url_id = 1; |
|
|
|
|
|
|
|
|
|
if ($_configuration['multiple_access_urls']) { |
|
|
|
|
$current_access_url_id = api_get_current_access_url_id(); |
|
|
|
|
$current_access_url_id = api_get_current_access_url_id(); |
|
|
|
|
|
|
|
|
|
if ($_configuration['multiple_access_urls']) { |
|
|
|
|
$url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
|
|
|
$url_condition = " INNER JOIN $url_rel_user uu ON uu.user_id = u.user_id "; |
|
|
|
|
} |
|
|
|
|
@ -553,11 +551,10 @@ class SystemAnnouncementManager { |
|
|
|
|
|
|
|
|
|
if (!empty($language)) { //special condition because language was already treated for SQL insert before |
|
|
|
|
$sql .= " AND language = '".Database::escape_string($language)."' "; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($_configuration['multiple_access_urls']) { |
|
|
|
|
$sql .= " AND access_url_id = '".$current_access_url_id."' "; |
|
|
|
|
$sql .= " AND access_url_id = '".$current_access_url_id."' "; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Sent to active users |
|
|
|
|
@ -565,14 +562,20 @@ class SystemAnnouncementManager { |
|
|
|
|
|
|
|
|
|
if ((empty($teacher) or $teacher == '0') AND (empty($student) or $student == '0')) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
if ($result === false) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
while($row = Database::fetch_array($result,'ASSOC')) { |
|
|
|
|
$res = @api_mail_html(api_get_person_name($row['firstname'], $row['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $row['email'], api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset), api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'),'',$content)), ENT_QUOTES, $charset), api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS), api_get_setting('emailAdministrator')) || $res; |
|
|
|
|
|
|
|
|
|
$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); |
|
|
|
|
|
|
|
|
|
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')); |
|
|
|
|
} |
|
|
|
|
return $res; //true if at least one e-mail was sent |
|
|
|
|
} |
|
|
|
|
|