Unread criteria, iframe reload issue, attachment issue and replace example email with username

This commit is contained in:
Vijay Sebastian
2016-11-02 18:45:09 +05:30
parent dbb118b004
commit 0bc1e99fab
6 changed files with 69 additions and 129 deletions

View File

@@ -252,12 +252,10 @@ class EmailsController extends Controller
$this->emailService($driver, $service_request);
$this->setMailConfig($driver, $username, $name, $password, $enc, $host, $port);
$controller = new \App\Http\Controllers\Common\PhpMailController();
$to = 'example@ladybirdweb.com';
$toname = 'test';
$subject = 'test';
$data = 'test';
//dd(\Config::get('mail'),\Config::get('services'));
$send = $controller->laravelMail($to, $toname, $subject, $data, [], []);
$send = $controller->laravelMail($username, $name, $subject, $data, [], []);
return $send;
}

View File

@@ -172,7 +172,8 @@ class MailController extends Controller
}
$server->setFlag($cert);
$server->setAuthentication($username, $password);
$messages = $server->search('UNSEEN', 10);
$date = date("d M Y", strToTime("-1 days"));
$messages = $server->search("SINCE \"$date\" UNSEEN");
$this->message($messages, $email);
}
}
@@ -257,7 +258,7 @@ class MailController extends Controller
public function manageAttachment($data, $filename, $type, $size, $disposition, $thread_id)
{
$upload = new Ticket_attachments();
$upload->file = $data;
$upload->file = base64_encode($data);
$upload->thread_id = $thread_id;
$upload->name = $filename;
$upload->type = $type;
@@ -337,24 +338,20 @@ class MailController extends Controller
*
* @return type file
*/
public function get_data($id)
{
$attachments = \App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->get();
foreach ($attachments as $attachment) {
header('Content-type: application/'.$attachment->type.'');
header('Content-Disposition: inline; filename='.$attachment->name.'');
header('Content-Transfer-Encoding: binary');
$headers = [
'Content-type: application/'.$attachment->type.'',
'Content-Disposition: inline; filename='.$attachment->name.'',
'Content-Transfer-Encoding: binary',
];
$file = $attachment->file;
echo $file;
// return response($file)
// ->header('Content-Type', $attachment->type)
// ->header('Content-Disposition', 'inline; filename='.$attachment->name.'')
// ->header('Content-Transfer-Encoding', 'binary');
public function get_data($id) {
$attachment = \App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->first();
if (mime($attachment->type) == true) {
echo "<img src=data:$attachment->type;base64," . $attachment->file . ">";
} else {
$file = base64_decode($attachment->file);
return response($file)
->header('Cache-Control', 'no-cache private')
->header('Content-Description', 'File Transfer')
->header('Content-Type', $attachment->type)
->header('Content-length', strlen($file))
->header('Content-Disposition', 'attachment; filename=' . $attachment->name)
->header('Content-Transfer-Encoding', 'binary');
}
}
}

View File

@@ -118,7 +118,7 @@ class Ticket_Thread extends Model
if ($this->attach()->where('poster', 'INLINE')->get()->count() > 0) {
$search = $this->attach()->where('poster', 'INLINE')->lists('name')->toArray();
foreach ($this->attach()->where('poster', 'INLINE')->get() as $key => $attach) {
$replace[$key] = "data:$attach->type;base64,".base64_encode($attach->file);
$replace[$key] = "data:$attach->type;base64,".$attach->file;
}
$body = str_replace($search, $replace, $body);
}

View File

@@ -10,4 +10,21 @@ class Ticket_attachments extends Model
protected $fillable = [
'id', 'thread_id', 'name', 'size', 'type', 'file', 'data', 'poster', 'updated_at', 'created_at',
];
public function getFile() {
$size = $this->size;
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$power = $size > 0 ? floor(log($size, 1024)) : 0;
$value = number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power];
if ($this->poster == 'ATTACHMENT') {
if (mime($this->type) == true) {
$var = '<a href="' . \URL::route('image', array('image_id' => $this->id)) . '" target="_blank"><img style="max-width:200px;height:133px;" src="data:image/jpg;base64,' . $this->file . '"/></a>';
return '<li style="background-color:#f4f4f4;"><span class="mailbox-attachment-icon has-img">' . $var . '</span><div class="mailbox-attachment-info"><b style="word-wrap: break-word;">' . $this->name . '</b><br/><p>' . $value . '</p></div></li>';
} else {
//$var = '<a href="' . URL::route('image', array('image_id' => $attachment->id)) . '" target="_blank"><img style="max-width:200px;height:133px;" src="data:'.$attachment->type.';base64,' . base64_encode($data) . '"/></a>';
$var = '<a style="max-width:200px;height:133px;color:#666;" href="' . \URL::route('image', array('image_id' => $this->id)) . '" target="_blank"><span class="mailbox-attachment-icon" style="background-color:#fff; font-size:18px;">' . strtoupper($this->type) . '</span><div class="mailbox-attachment-info"><span ><b style="word-wrap: break-word;">' . $this->name . '</b><br/><p>' . $value . '</p></span></div></a>';
return '<li style="background-color:#f4f4f4;">' . $var . '</li>';
}
}
}
}