Format code fix validation.

1.10.x
Julio 8 years ago
parent 559b244bf2
commit 24411bf33d
  1. 2
      main/inc/lib/api.lib.php
  2. 9
      main/inc/lib/message.lib.php
  3. 59
      main/inc/lib/system_announcements.lib.php

@ -7981,7 +7981,7 @@ function api_mail_html(
// Attachment ...
if (!empty($data_file)) {
$o = 0;
foreach ($data_file as $file_attach) {
foreach ($data_file as $file_attach) {
if (!empty($file_attach['path']) && !empty($file_attach['filename'])) {
$mail->AddAttachment($file_attach['path'], $file_attach['filename']);
}

@ -280,16 +280,12 @@ class MessageManager
$now = api_get_utc_datetime();
if (!empty($receiver_user_id) || !empty($group_id)) {
// message for user friend
$clean_subject = Database::escape_string($subject);
$clean_content = Database::escape_string($content);
//message in inbox for user friend
//@todo it's possible to edit a message? yes, only for groups
if ($edit_message_id) {
$query = " UPDATE $table_message SET
update_date = '".$now."',
content = '$clean_content'
content = '".Database::escape_string($content)."'
WHERE id = '$edit_message_id' ";
Database::query($query);
$inbox_last_id = $edit_message_id;
@ -362,7 +358,7 @@ class MessageManager
// Load user settings.
$notification = new Notification();
$sender_info = api_get_user_info($user_sender_id);
// add file attachment additional attributes
foreach ($file_attachments as $index => $file_attach) {
$file_attachments[$index]['path'] = $file_attach['tmp_name'];
@ -450,7 +446,6 @@ class MessageManager
);
if ($sendCopyToDrhUsers) {
$userInfo = api_get_user_info($receiver_user_id);
$drhList = UserManager::getDrhListFromUser($receiver_user_id);
if (!empty($drhList)) {

@ -347,15 +347,17 @@ class SystemAnnouncementManager
Display :: display_normal_message(get_lang('InvalidEndDate'));
return false;
}
if (strlen(trim($title)) == 0) {
Display::display_normal_message(get_lang('InvalidTitle'));
return false;
}
$start = api_get_utc_datetime($date_start);
$end = api_get_utc_datetime($date_end);
//Fixing urls that are sent by email
// Fixing urls that are sent by email
$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content);
$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content);
@ -381,7 +383,6 @@ class SystemAnnouncementManager
$resultId = Database::insert($db_table, $params);
if ($resultId) {
if ($sendEmailTest) {
SystemAnnouncementManager::send_system_announcement_by_email(
$title,
@ -505,6 +506,12 @@ class SystemAnnouncementManager
$sendEmailTest = false
) {
$em = Database::getManager();
$announcement = $em->find('ChamiloCoreBundle:SysAnnouncement', $id);
if (!$announcement) {
return false;
}
$a_dateS = explode(' ',$date_start);
$a_arraySD = explode('-',$a_dateS[0]);
@ -520,6 +527,7 @@ class SystemAnnouncementManager
if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) {
Display :: display_normal_message(get_lang('InvalidStartDate'));
return false;
}
@ -529,23 +537,23 @@ class SystemAnnouncementManager
!checkdate($date_end_to_compare[1], $date_end_to_compare[2], $date_end_to_compare[0])
) {
Display :: display_normal_message(get_lang('InvalidEndDate'));
return false;
}
if (strlen(trim($title)) == 0) {
Display::display_normal_message(get_lang('InvalidTitle'));
return false;
}
$start = api_get_utc_datetime($date_start);
$end = api_get_utc_datetime($date_end);
$start = api_get_utc_datetime($date_start);
$end = api_get_utc_datetime($date_end);
//Fixing urls that are sent by email
// Fixing urls that are sent by email
$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content);
$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content);
$id = intval($id);
if ($sendEmailTest) {
SystemAnnouncementManager::send_system_announcement_by_email(
$title,
@ -567,12 +575,6 @@ class SystemAnnouncementManager
}
}
$announcement = $em->find('ChamiloCoreBundle:SysAnnouncement', $id);
if (!$announcement) {
return false;
}
$dateStart = new DateTime($start, new DateTimeZone('UTC'));
$dateEnd = new DateTime($end, new DateTimeZone('UTC'));
@ -658,20 +660,28 @@ class SystemAnnouncementManager
/**
* Send a system announcement by e-mail to all teachers/students depending on parameters
* @param string Title
* @param string Content
* @param int Whether to send to all teachers (1) or not (0)
* @param int Whether to send to all students (1) or not (0)
* @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.
* @param string $title
* @param string $content
* @param int $teacher Whether to send to all teachers (1) or not (0)
* @param int $student Whether to send to all students (1) or not (0)
* @param string $language Language (optional, considered for all languages if left empty)
* @param bool $sendEmailTest
* @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, $sendEmailTest = false)
{
public static function send_system_announcement_by_email(
$title,
$content,
$teacher,
$student,
$language = null,
$sendEmailTest = false
) {
$content = str_replace(array('\r\n', '\n', '\r'),'', $content);
$now = api_get_utc_datetime();
if ($sendEmailTest) {
MessageManager::send_message_simple(api_get_user_id(), $title, $content);
return true;
}
@ -713,16 +723,17 @@ class SystemAnnouncementManager
$sql .= " AND (expiration_date = '' OR expiration_date IS NULL OR expiration_date > '$now') ";
if ((empty($teacher) || $teacher == '0') && (empty($student) || $student == '0')) {
return true;
return true;
}
$result = Database::query($sql);
if ($result === false) {
return false;
return false;
}
$message_sent = false;
while ($row = Database::fetch_array($result,'ASSOC')) {
MessageManager::send_message_simple($row['user_id'], $title, $content);
$message_sent = true;

Loading…
Cancel
Save