@ -275,7 +275,7 @@ class TicketManager
* @param string $subject
* @param string $content
* @param string $personalEmail
* @param $file_a ttachments
* @param array $fileA ttachments
* @param string $source
* @param string $priority
* @param string $status
@ -292,7 +292,7 @@ class TicketManager
$subject,
$content,
$personalEmail = '',
$file_a ttachments = [],
$fileA ttachments = [],
$source = '',
$priority = '',
$status = '',
@ -397,9 +397,9 @@ class TicketManager
));
}
if (!empty($file_a ttachments)) {
if (!empty($fileA ttachments)) {
$attachmentCount = 0;
foreach ($file_a ttachments as $attach) {
foreach ($fileA ttachments as $attach) {
if (!empty($attach['tmp_name'])) {
$attachmentCount++;
}
@ -409,7 +409,7 @@ class TicketManager
$ticketId,
'',
'',
$file_a ttachments,
$fileA ttachments,
$currentUserId
);
}
@ -613,7 +613,7 @@ class TicketManager
* @param int $ticketId
* @param string $subject
* @param string $content
* @param array $file_a ttachments
* @param array $fileA ttachments
* @param int $userId
* @param string $status
* @param bool $sendConfirmation
@ -624,7 +624,7 @@ class TicketManager
$ticketId,
$subject,
$content,
$file_a ttachments,
$fileA ttachments,
$userId,
$status = 'NOL',
$sendConfirmation = false
@ -670,10 +670,10 @@ class TicketManager
WHERE id = $ticketId ";
Database::query($sql);
if (is_array($file_a ttachments)) {
foreach ($file_a ttachments as $file_attach) {
if (is_array($fileA ttachments)) {
foreach ($fileA ttachments as $file_attach) {
if ($file_attach['error'] == 0) {
self::save_message_attachment_f ile(
self::saveMessageAttachmentF ile(
$file_attach,
$ticketId,
$messageId
@ -697,7 +697,7 @@ class TicketManager
* @param $message_id
* @return array
*/
public static function save_message_attachment_f ile(
public static function saveMessageAttachmentF ile(
$file_attach,
$ticketId,
$message_id
@ -717,18 +717,10 @@ class TicketManager
'error'
);
} else {
$new_file_name = uniqid('');
$path_attachment = api_get_path(SYS_ARCHIVE_PATH);
$path_message_attach = $path_attachment.'plugin_ticket_messageattch/';
if (!file_exists($path_message_attach)) {
@mkdir($path_message_attach, api_get_permissions_for_new_directories(), true);
}
$new_path = $path_message_attach.$new_file_name;
if (is_uploaded_file($file_attach['tmp_name'])) {
@copy($file_attach['tmp_name'], $new_path);
}
$safe_file_name = Database::escape_string($file_name);
$safe_new_file_name = Database::escape_string($new_file_name);
$result = api_upload_file('ticket_attachment', $file_attach, $ticketId);
if ($result) {
$safe_file_name = Database::escape_string($new_file_name);
$safe_new_file_name = Database::escape_string($result['path_to_save']);
$sql = "INSERT INTO $table_support_message_attachments (
filename,
path,
@ -752,10 +744,8 @@ class TicketManager
)";
Database::query($sql);
return array(
'path' => $path_message_attach.$safe_new_file_name,
'filename' => $safe_file_name,
);
return true;
}
}
}
@ -1088,6 +1078,23 @@ class TicketManager
return (int)$obj->total;
}
/**
* @param int $id
* @return \Chamilo\TicketBundle\Entity\MessageAttachment
*/
public static function getTicketMessageAttachment($id)
{
$id = (int) $id;
$em = Database::getManager();
$item = $em->getRepository('ChamiloTicketBundle:MessageAttachment')->find($id);
if ($item) {
return $item;
}
return false;
}
/**
* @param int $ticketId
* @return array
@ -1181,8 +1188,8 @@ class TicketManager
$result_attach = Database::query($sql);
while ($row2 = Database::fetch_assoc($result_attach)) {
$archiveURL = $archiveURL = $ webPath.'ticket/download.php?ticket_id='.$ticketId.'&file=' ;
$row2['attachment_link'] = $attach_icon.' < a href = "'.$archiveURL.$row2['path'].'&title='.$row2['filename']. '" > '.$row2['filename'].'< / a > ('.$row2['size'].')';
$archiveURL = $webPath.'ticket/download.php?ticket_id='.$ticketId.'&id='.$row2['id'] ;
$row2['attachment_link'] = $attach_icon.' < a href = "'.$archiveURL.'" > '.$row2['filename'].'< / a > ('.$row2['size'].')';
$message['attachments'][] = $row2;
}
$ticket['messages'][] = $message;